xiaodao-editor 0.1.12 → 0.1.13
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/dist/block-editor.js +7705 -7622
- package/dist/block-editor.umd.cjs +25 -25
- package/package.json +1 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
(function(se,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(se=typeof globalThis<"u"?globalThis:se||self,t(se.BlockEditor={},se.Vue))})(this,function(se,t){"use strict";var gg=Object.defineProperty;var bg=(se,t,uo)=>t in se?gg(se,t,{enumerable:!0,configurable:!0,writable:!0,value:uo}):se[t]=uo;var gt=(se,t,uo)=>bg(se,typeof t!="symbol"?t+"":t,uo);function uo(e){return typeof e=="string"&&e.length>0}function gc(e){return e.type==="text"}function Ae(e){return e.reduce((n,o)=>o.type==="text"?n+o.text:n,"")}function Wn(e){return e.length===0?[]:[{type:"text",text:e}]}function Ut(e,n){const o=Math.max(0,Math.floor(n));if(o<=0)return[[],e];const r=Ae(e).length;if(o>=r)return[e,[]];const l=[],i=[];let c=0;for(const s of e){if(s.type!=="text"){c<o?l.push(s):i.push(s);continue}const a=s.text.length;if(c+a<=o){l.push(s),c+=a;continue}if(c>=o){i.push(s);continue}const d=o-c,u=s.text.slice(0,d),f=s.text.slice(d);u.length>0&&l.push(s.marks?{...s,text:u}:{...s,text:u,marks:void 0}),f.length>0&&i.push(s.marks?{...s,text:f}:{...s,text:f,marks:void 0}),c+=a}return[l,i]}const Il="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-",Bl=12;function bc(e){const n=globalThis.crypto;if(!n||typeof n.getRandomValues!="function")throw new Error("BlockEditor: Web Crypto getRandomValues is unavailable in this environment.");const o=new Uint8Array(e);return n.getRandomValues(o),o}function fo(){const e=bc(Bl);let n="";for(let o=0;o<Bl;o++)n+=Il[e[o]%Il.length];return n}function kc(e){return e}const yc={empty:e=>e.content.length===0||e.content.every(n=>n.text==="")};function Mr(e){return{type:e.type,attrs:e.attrs??{},content:e.content??"text",nestable:e.nestable??!1,allowedChildren:e.allowedChildren??"*",isolating:e.isolating??!1,listLike:e.listLike??!1,inlineMarks:e.inlineMarks??!0,disallowedMarks:e.disallowedMarks??[],empty:e.empty??yc.empty}}function Gn(e){const n={};for(const[o,r]of Object.entries(e.attrs))n[o]=r.default;return n}function Rl(e,n){const o={};for(const[r,l]of Object.entries(e.attrs)){const i=n[r];i!==void 0&&(!l.validate||l.validate(i))?o[r]=i:o[r]=l.default}return o}function Ll(e,n){return e.nestable?e.allowedChildren==="*"?!0:e.allowedChildren.includes(n):!1}function Ol(e){return e.content==="text"}function Dl(e){return e.isolating}function $l(e,n){return e.empty(n)}class Pl{constructor(n,o){gt(this,"schemas");gt(this,"fallback");this.schemas=n,this.fallback=o}get(n){return this.schemas.get(n)??this.fallback}has(n){return this.schemas.has(n)}defaultAttrsFor(n){return Gn(this.get(n))}coerceAttrsFor(n,o){return Rl(this.get(n),o)}canContain(n,o){return Ll(this.get(n),o)}hasText(n){return Ol(this.get(n))}isIsolating(n){return Dl(this.get(n))}isListLike(n){return this.get(n).listLike}hasInlineMarks(n){return this.get(n).inlineMarks}isMarkDisallowed(n,o){return this.get(n).disallowedMarks.includes(o)}isEmpty(n){return $l(this.get(n.type),n)}}const Hl=new Set(["paragraph","heading","bulletList","orderedList","todoList"]);function Nr(e){const n=new Map,o=new Map,r=new Map,l=new Set,i=p=>{if(p&&!l.has(p)){const h=p;return l.add(h),p&&r.set(p,h),h}let m=fo();for(;l.has(m);)m=fo();return l.add(m),m},c=(p,m)=>{const h=i(p.id);o.set(h,m);const y=[];for(const N of p.children??[])y.push(c(N,h));return n.set(h,{id:h,type:p.type,attrs:p.attrs??{},content:p.content??[],children:y}),h},s=[];for(const p of e.blocks??[])s.push(c(p,null));const a=Array.from(o.values()).every(p=>p===null);let d=!1;for(const p of n.values())if(typeof p.attrs.indent=="number"&&p.attrs.indent>0){d=!0;break}a&&d&&wc(n,o,s);const u=10;for(const[p,m]of n){const h=Math.min(u,Sr(o,p));if((typeof m.attrs.indent=="number"?m.attrs.indent:0)===h)continue;const{indent:N,...L}=m.attrs,S=h>0?{...L,indent:h}:L;n.set(p,{...m,attrs:S})}return{doc:{id:e.id??Tc(),root:s,blocks:n,parent:o},idMap:r}}function wc(e,n,o){const r=[...o];for(const[s,a]of e)e.set(s,{...a,children:[]});const l=[],i=[],c=(s,a)=>{if(s===null){i.push(a),n.set(a,null);return}const d=e.get(s);if(!d){i.push(a),n.set(a,null);return}const u={...d,children:[...d.children,a]};e.set(s,u),n.set(a,s)};for(const s of r){const a=e.get(s);if(!a)continue;const d=typeof a.attrs.indent=="number"?a.attrs.indent:0,u=Hl.has(a.type),f=u?Math.max(0,d):0;for(;l.length>0&&l[l.length-1].indent>=f;)l.pop();let m=l.length>0?l[l.length-1].id:null;for(;m!==null;){const h=e.get(m);if(!h||!Hl.has(h.type))m=n.get(m)??null;else break}c(m,s),u&&l.push({indent:f,id:s})}o.length=0;for(const s of i)o.push(s)}function Vl(e){const n=r=>r.map(l=>l.type==="text"?{type:"text",text:l.text,marks:l.marks&&l.marks.length>0?l.marks.map(i=>({type:i.type,attrs:i.attrs?{...i.attrs}:void 0})):void 0}:{...l}),o=r=>{const l=e.blocks.get(r);if(!l)throw new Error(`BlockEditor: missing block ${r} during serialization`);const i=l.children.map(o);return{id:r,type:l.type,attrs:l.attrs?{...l.attrs}:void 0,content:n(l.content),...i.length?{children:i}:{}}};return{id:e.id,blocks:e.root.map(o)}}function _t(e,n){return e.blocks.get(n)}function on(e,n){const o=e.blocks.get(n);if(!o)throw new Error(`BlockEditor: unknown block ${n}`);return o}function Bt(e,n){return e.parent.get(n)??null}function On(e,n){return Sr(e.parent,n)}function Sr(e,n){let o=0,r=e.get(n);const l=new Set;for(;r!=null&&!l.has(r);)l.add(r),o++,r=e.get(r);return o}function mo(e,n){const o=e.parent.get(n);if(o==null)return e.root;const r=e.blocks.get(o);return r?r.children:e.root}function rn(e,n){return mo(e,n).indexOf(n)}function Ar(e,n){const o=rn(e,n);if(o<=0)return;const r=mo(e,n);return e.blocks.get(r[o-1])}function Ec(e,n){const o=mo(e,n),r=o.indexOf(n);if(!(r<0||r>=o.length-1))return e.blocks.get(o[r+1])}function In(e){const n=[],o=r=>{for(const l of r){n.push(l);const i=e.blocks.get(l);i&&o(i.children)}};return o(e.root),n}function Dn(e,n){const o=In(e),r=o.indexOf(n);if(!(r<=0))return e.blocks.get(o[r-1])}function po(e,n){const o=In(e),r=o.indexOf(n);if(!(r<0||r>=o.length-1))return e.blocks.get(o[r+1])}function Ul(e,n){const o=on(e,n);if(o.children.length===0)return o;const r=o.children[o.children.length-1];return Ul(e,r)}function zl(e,n){const r=[];for(const[l,i]of e.blocks){const c=Math.min(10,Sr(e.parent,l)),s=n?n.get(i.type).attrs:void 0,a=s?"indent"in s:!0,d=a?c:0;if((typeof i.attrs.indent=="number"?i.attrs.indent:0)===d)continue;const{indent:f,...p}=i.attrs,m=d>0&&a?{...p,indent:d}:p;r.push({id:l,attrs:m})}return r}function vc(e,n){return{...e,content:n}}function Cc(e,n){return{...e,attrs:n}}function Tc(){return"doc_"+Math.random().toString(36).slice(2,10)}function _c(e){return{id:e.id,root:e.root,blocks:e.blocks,parent:e.parent}}function Qo(e,n,o){e.blocks.set(n,o),e.changed.add(n)}function So(e,n,o){if(n===null)e.root=o;else{const r=e.blocks.get(n);if(!r)throw new Error(`BlockEditor: unknown parent ${n}`);Qo(e,n,{...r,children:o})}}function Ao(e,n){if(n===null)return e.root;const o=e.blocks.get(n);if(!o)throw new Error(`BlockEditor: unknown parent ${n}`);return o.children}function xc(e,n){if(!e.blocks.get(n))throw new Error(`BlockEditor: cannot remove unknown block ${n}`);const r=e.parent.get(n)??null,l=Ao(e,r).filter(c=>c!==n);So(e,r,l);const i=[n];for(;i.length;){const c=i.pop(),s=e.blocks.get(c);if(s)for(const a of s.children)i.push(a);e.blocks.delete(c),e.parent.delete(c),e.removed.add(c),e.changed.delete(c)}}function Jo(e,n){const o={id:e.id,root:[...e.root],blocks:new Map(e.blocks),parent:new Map(e.parent),changed:new Set,removed:new Set};for(const r of n)switch(r.op){case"insertBlock":{if(o.blocks.has(r.id))throw new Error(`BlockEditor: insertBlock id collision ${r.id}`);const l={id:r.id,type:r.type,attrs:r.attrs,content:r.content,children:[]};o.blocks.set(r.id,l),o.parent.set(r.id,r.parent),o.changed.add(r.id);const i=[...Ao(o,r.parent)],c=Math.max(0,Math.min(r.index,i.length));i.splice(c,0,r.id),So(o,r.parent,i);break}case"removeBlock":{xc(o,r.id);break}case"replaceBlock":{const l=o.blocks.get(r.id);if(!l)throw new Error(`BlockEditor: replaceBlock unknown ${r.id}`);Qo(o,r.id,{...l,type:r.type,attrs:r.attrs});break}case"moveBlock":{if(!o.blocks.get(r.id))throw new Error(`BlockEditor: moveBlock unknown ${r.id}`);const i=o.parent.get(r.id)??null;if(i===r.toParent){const c=Ao(o,i).filter(a=>a!==r.id),s=Math.max(0,Math.min(r.toIndex,c.length));c.splice(s,0,r.id),So(o,i,c)}else{const c=Ao(o,i).filter(d=>d!==r.id);So(o,i,c);const s=[...Ao(o,r.toParent)],a=Math.max(0,Math.min(r.toIndex,s.length));s.splice(a,0,r.id),So(o,r.toParent,s),o.parent.set(r.id,r.toParent)}break}case"setText":{const l=o.blocks.get(r.id);if(!l)throw new Error(`BlockEditor: setText unknown ${r.id}`);Qo(o,r.id,{...l,content:r.content});break}case"setAttrs":{const l=o.blocks.get(r.id);if(!l)throw new Error(`BlockEditor: setAttrs unknown ${r.id}`);Qo(o,r.id,{...l,attrs:r.attrs});break}}return{doc:_c(o),changed:o.changed,removed:o.removed}}function Fl(e,n,o){const{doc:r,changed:l,removed:i}=Jo(e.doc,n.steps),c=n.selectionAfter??e.selection,s={...e.pluginState};for(const a of o)a.applyTransaction&&(s[a.name]=a.applyTransaction(n,e,r,c));return{doc:r,state:{doc:r,selection:c,pluginState:s,version:e.version+1},changed:l,removed:i}}function Ir(e,n,o={}){return{doc:e,selection:n,pluginState:o,version:0}}class Kl{constructor(){gt(this,"steps",[]);gt(this,"selectionAfter");gt(this,"meta",{})}insertBlock(n){const o=n.id??fo();return this.steps.push({op:"insertBlock",parent:n.parent,index:n.index,id:o,type:n.type,attrs:n.attrs??{},content:n.content??[]}),o}removeBlock(n){return this.steps.push({op:"removeBlock",id:n}),this}replaceBlock(n,o,r){return this.steps.push({op:"replaceBlock",id:n,type:o,attrs:r}),this}moveBlock(n,o,r){return this.steps.push({op:"moveBlock",id:n,toParent:o,toIndex:r}),this}setText(n,o){return this.steps.push({op:"setText",id:n,content:o}),this}setAttrs(n,o){return this.steps.push({op:"setAttrs",id:n,attrs:o}),this}peek(){return this.steps}appendSteps(n){for(const o of n)this.steps.push(o);return this}setSelection(n){return this.selectionAfter=n,this}setMeta(n){return this.meta={...this.meta,...n},this}addToHistory(n){return this.meta={...this.meta,addToHistory:n},this}historyGroup(n){return this.meta={...this.meta,historyGroup:n},this}skipDomWrite(n){return this.meta={...this.meta,viewHints:{...this.meta.viewHints,skipDomWrite:n}},this}build(){return{steps:this.steps,selectionAfter:this.selectionAfter,meta:this.meta}}}function Je(){return new Kl}function Wl(e,n){const o=[];for(let r=e.length-1;r>=0;r--){const l=e[r];switch(l.op){case"insertBlock":o.push({op:"removeBlock",id:l.id});break;case"removeBlock":o.push(...Mc(l.id,n));break;case"replaceBlock":{const i=n.blocks.get(l.id);if(!i)break;o.push({op:"replaceBlock",id:l.id,type:i.type,attrs:i.attrs});break}case"moveBlock":{o.push({op:"moveBlock",id:l.id,toParent:Bt(n,l.id),toIndex:rn(n,l.id)});break}case"setText":{const i=n.blocks.get(l.id);if(!i)break;o.push({op:"setText",id:l.id,content:i.content});break}case"setAttrs":{const i=n.blocks.get(l.id);if(!i)break;o.push({op:"setAttrs",id:l.id,attrs:i.attrs});break}}}return o}function Mc(e,n){const o=[],r=l=>{const i=on(n,l);o.push({op:"insertBlock",parent:Bt(n,l),index:rn(n,l),id:l,type:i.type,attrs:i.attrs,content:i.content});for(const c of i.children)r(c)};return r(e),o}function et(e,n){return{kind:"caret",blockId:e,offset:n}}function Br(e,n){return{kind:"text",anchor:e,focus:n}}function Nc(e){return{kind:"blocks",blockIds:[...e]}}function ho(e){return e.kind==="caret"}function qn(e){return e.kind==="text"}function Io(e){return e.kind==="blocks"}function Rr(e){return ho(e)?!0:qn(e)?e.anchor.blockId===e.focus.blockId&&e.anchor.offset===e.focus.offset:e.blockIds.length===0}function Gl(e){return ho(e)?e.blockId:qn(e)?e.focus.blockId:e.blockIds[0]??null}function Sc(e){return ho(e)?e.offset:qn(e)?e.focus.offset:0}function Ac(e,n){return qn(e)?n(e.anchor,e.focus)<=0?[e.anchor,e.focus]:[e.focus,e.anchor]:null}class ql{constructor(){gt(this,"entries",new Map)}register(n){if(this.entries.has(n.name))throw new Error(`BlockEditor: duplicate command "${n.name}"`);this.entries.set(n.name,n)}override(n){this.entries.set(n.name,n)}has(n){return this.entries.has(n)}get(n){return this.entries.get(n)}createProxy(n){const o=this.entries;return new Proxy({},{get:(r,l)=>o.has(l)?i=>n(l,i):()=>!1})}}function er(e){if(Io(e))return null;const n=Gl(e);if(!n)return null;const o=ho(e)?e.offset:e.focus.offset;return{blockId:n,offset:o}}const Lr=10;function sn(e,n,o){const r=n.peek();if(r.length===0)return;const l=Jo(e.doc,r),i=zl(l.doc,o.registries.schema);for(const c of i)n.setAttrs(c.id,c.attrs)}function tr(e){return{name:"insertBlock",run:n=>(o,r)=>{const l=n.type,i=n.attrs??e.registries.schema.defaultAttrsFor(l),c=n.content??[];let s,a;if(n.after){if(!_t(o.doc,n.after))return!1;s=Bt(o.doc,n.after),a=rn(o.doc,n.after)+1}else if(n.parent!==void 0){s=n.parent;const f=s===null?o.doc.root:on(o.doc,s).children;a=n.index??f.length}else s=null,a=o.doc.root.length;if(s!==null){const f=_t(o.doc,s);if(!f)return!1;const p=e.registries.schema.get(f.type);if(!(p!=null&&p.nestable))return!1}const d=Je(),u=d.insertBlock({parent:s,index:a,type:l,attrs:i,content:c});return d.setSelection(et(u,0)),r==null||r(d.build()),!0}}}function Or(e){return{name:"removeBlock",run:n=>(o,r)=>{if(!_t(o.doc,n.id))return!1;const l=Dn(o.doc,n.id),i=po(o.doc,n.id),c=l??i,s=Je(),d=on(o.doc,n.id).children??[];if(d.length>0){const u=Bt(o.doc,n.id),f=rn(o.doc,n.id);if((()=>{if(!l)return!1;const m=e.registries.schema.get(l.type);return!(!(m!=null&&m.nestable)||On(o.doc,l.id)>=Lr)})()&&l){let h=(l.children??[]).length;for(const y of d)s.moveBlock(y,l.id,h),h++}else{let m=f;for(const h of d)s.moveBlock(h,u,m),m++}}if(s.removeBlock(n.id),sn(o,s,e),c){const u=Ae(c.content);s.setSelection(et(c.id,u.length))}return r==null||r(s.build()),!0}}}function Ic(e){return{name:"replaceBlock",run:n=>(o,r)=>{if(!_t(o.doc,n.id))return!1;const i=n.attrs??e.registries.schema.defaultAttrsFor(n.type),c=Je();return c.replaceBlock(n.id,n.type,i),sn(o,c,e),c.setSelection(et(n.id,0)),r==null||r(c.build()),!0}}}function Bc(){return{name:"setText",run:e=>(n,o)=>{if(!_t(n.doc,e.id))return!1;const r=Je();return r.setText(e.id,e.content),e.selectionAfter&&r.setSelection(e.selectionAfter),r.historyGroup("type"),r.skipDomWrite([e.id]),r.setMeta({source:"input",addToHistory:!0}),o==null||o(r.build()),!0}}}function Rc(){return{name:"setAttrs",run:e=>(n,o)=>{if(!_t(n.doc,e.id))return!1;const l=Je();return l.setAttrs(e.id,e.attrs),o==null||o(l.build()),!0}}}function Dr(e){return{name:"splitBlock",run:n=>(o,r)=>{const l=_t(o.doc,n.id);if(!l||!e.registries.schema.hasText(l.type))return!1;const i=Ae(l.content).length,c=Math.max(0,Math.min(n.offset,i)),[s,a]=Ut(l.content,c),d=Bt(o.doc,n.id),u=rn(o.doc,n.id),f=l.children??[],p=n.asType??e.registries.defaultBlockType,m=n.asAttrs??e.registries.schema.defaultAttrsFor(p),h=Je();h.setText(n.id,s);const y=h.insertBlock({parent:d,index:u+1,type:p,attrs:m,content:a});if(f.length>0)for(let N=0;N<f.length;N++)h.moveBlock(f[N],y,N);return sn(o,h,e),h.setSelection(et(y,0)),r==null||r(h.build()),!0}}}function Yl(e){return{name:"mergeBlock",run:n=>(o,r)=>{const l=_t(o.doc,n.id);if(!l)return!1;const i=Dn(o.doc,n.id);if(!i||!e.registries.schema.hasText(i.type))return!1;const c=Ae(i.content),s=[...i.content,...l.content],a=Je();a.setText(i.id,s);const d=l.children??[];if(d.length>0){const u=Bt(o.doc,n.id),f=rn(o.doc,n.id),p=e.registries.schema.get(i.type);if(!!(p!=null&&p.nestable)&&On(o.doc,i.id)<Lr){let y=(i.children??[]).length;for(const N of d)a.moveBlock(N,i.id,y),y++}else{let h=f;for(const y of d)a.moveBlock(y,u,h),h++}}return a.removeBlock(n.id),sn(o,a,e),a.setSelection(et(i.id,c.length)),r==null||r(a.build()),!0}}}function Lc(e){return{name:"enter",run:()=>(n,o)=>{const r=n.selection,l=er(r);if(!l){if(Io(r)&&r.blockIds.length){const d=r.blockIds[r.blockIds.length-1];return tr(e).run({type:e.registries.defaultBlockType,after:d})(n,o)}return!1}const i=on(n.doc,l.blockId),c=e.registries.schema.get(i.type);if(!e.registries.schema.hasText(i.type))return tr(e).run({type:e.registries.defaultBlockType,after:i.id})(n,o);if(c.isolating)return!1;const s=Ae(i.content),a=l.offset>=s.length;return c.listLike&&e.registries.schema.isEmpty(i)?nr(e).run({id:i.id,type:e.registries.defaultBlockType})(n,o):a&&e.registries.schema.isEmpty(i)?tr(e).run({type:e.registries.defaultBlockType,after:i.id})(n,o):c.listLike?Dr(e).run({id:i.id,offset:l.offset,asType:i.type})(n,o):Dr(e).run({id:i.id,offset:l.offset})(n,o)}}}function Oc(e){return{name:"backspace",run:()=>(n,o)=>{const r=n.selection;if(Io(r)&&r.blockIds.length){const s=r.blockIds[0],a=Dn(n.doc,s),d=Je();for(const f of r.blockIds)d.removeBlock(f);const u=a??po(n.doc,r.blockIds[r.blockIds.length-1]);return sn(n,d,e),u&&d.setSelection(et(u.id,Ae(u.content).length)),o==null||o(d.build()),!0}const l=er(r);if(!l)return!1;const i=on(n.doc,l.blockId);if(qn(r)&&!Rr(r)&&r.anchor.blockId===r.focus.blockId){const[s,a]=r.anchor.offset<=r.focus.offset?[r.anchor.offset,r.focus.offset]:[r.focus.offset,r.anchor.offset],d=Ae(i.content),u=Wn(d.slice(0,s)+d.slice(a)),f=Je();return f.setText(i.id,u),f.setSelection(et(i.id,s)),f.skipDomWrite([i.id]),o==null||o(f.build()),!0}if(qn(r)&&!Rr(r)&&r.anchor.blockId!==r.focus.blockId){const s=In(n.doc),a=s.indexOf(r.anchor.blockId),d=s.indexOf(r.focus.blockId);if(a===-1||d===-1)return!1;const[u,f]=a<=d?[r.anchor,r.focus]:[r.focus,r.anchor],p=s.indexOf(u.blockId),m=s.indexOf(f.blockId);if(p===-1||m===-1||p>=m)return!1;const h=on(n.doc,u.blockId),y=on(n.doc,f.blockId),N=Ae(h.content).length,L=Ae(y.content).length,S=Math.min(u.offset,N),G=Math.min(f.offset,L),[K]=Ut(h.content,S),[,F]=Ut(y.content,G),Y=[...K,...F],ae=Ae(K).length,ne=Je();ne.setText(u.blockId,Y);for(let te=m;te>p;te--)ne.removeBlock(s[te]);return ne.setSelection(et(u.blockId,ae)),sn(n,ne,e),o==null||o(ne.build()),!0}if(l.offset>0)return!1;if(On(n.doc,i.id)>0)return Zl(e).run({id:i.id})(n,o);if(e.registries.schema.isListLike(i.type))return nr(e).run({id:i.id,type:e.registries.defaultBlockType})(n,o);if(e.registries.schema.isEmpty(i)&&i.type!==e.registries.defaultBlockType)return nr(e).run({id:i.id,type:e.registries.defaultBlockType})(n,o);const c=Dn(n.doc,i.id);return c?e.registries.schema.isIsolating(i.type)||e.registries.schema.isIsolating(c.type)?e.registries.schema.isEmpty(i)?Or(e).run({id:i.id})(n,o):!1:e.registries.schema.hasText(c.type)?Yl(e).run({id:i.id})(n,o):e.registries.schema.isEmpty(i)?Or(e).run({id:i.id})(n,o):!1:!1}}}function Dc(){return{name:"moveToPreviousBlock",run:()=>(e,n)=>{const o=er(e.selection);if(!o)return!1;const r=Dn(e.doc,o.blockId);if(!r)return!1;const l=Math.min(o.offset,Ae(r.content).length);return n==null||n(Je().setSelection(et(r.id,l)).setMeta({addToHistory:!1}).build()),!0}}}function $c(){return{name:"moveToNextBlock",run:()=>(e,n)=>{const o=er(e.selection);if(!o)return!1;const r=po(e.doc,o.blockId);if(!r)return!1;const l=Math.min(o.offset,Ae(r.content).length);return n==null||n(Je().setSelection(et(r.id,l)).setMeta({addToHistory:!1}).build()),!0}}}function Pc(){return{name:"setSelection",run:e=>(n,o)=>(o==null||o(Je().setSelection(e.selection).setMeta({addToHistory:!1}).build()),!0)}}function Hc(){return{name:"clearSelection",run:()=>(e,n)=>(n==null||n(Je().setSelection({kind:"blocks",blockIds:[]}).setMeta({addToHistory:!1}).build()),!0)}}function Vc(){return{name:"selectAll",run:()=>(e,n)=>{const o=In(e.doc);if(o.length===0)return!1;const r=o[0],l=o[o.length-1],i=on(e.doc,l),c=Ae(i.content).length,s={kind:"text",anchor:{blockId:r,offset:0},focus:{blockId:l,offset:c}};return n==null||n(Je().setSelection(s).setMeta({addToHistory:!1}).build()),!0}}}function Uc(){return{name:"selectBlock",run:e=>(n,o)=>(o==null||o(Je().setSelection({kind:"blocks",blockIds:[e.id]}).setMeta({addToHistory:!1}).build()),!0)}}function zc(e){return{name:"moveBlock",run:n=>(o,r)=>{if(!_t(o.doc,n.id)||n.toParent===n.id)return!1;if(n.toParent!==null){let c=n.toParent;for(;c!==null;){if(c===n.id)return!1;c=Bt(o.doc,c)}}if(n.toParent!==null){const c=_t(o.doc,n.toParent);if(!c)return!1;const s=e.registries.schema.get(c.type);if(!(s!=null&&s.nestable))return!1}const i=Je();return i.moveBlock(n.id,n.toParent,n.toIndex),sn(o,i,e),i.setSelection(et(n.id,0)),r==null||r(i.build()),!0}}}function nr(e){return{name:"convertBlock",run:n=>(o,r)=>{const l=_t(o.doc,n.id);if(!l)return!1;const i={...l.attrs,...n.attrs??{}};let c=e.registries.schema.coerceAttrsFor(n.type,i);const s=e.registries.schema.get(n.type);let a=l.content;if(s.content==="none"&&(a=[]),!s.inlineMarks){a=a.map(m=>({type:"text",text:m.text}));const p={...c};"color"in p&&(p.color="default"),"bgColor"in p&&(p.bgColor="default"),c=p}const d=o.selection.kind==="caret"&&o.selection.blockId===n.id?o.selection.offset:0,u=Je();u.replaceBlock(n.id,n.type,c),a!==l.content&&u.setText(n.id,a),sn(o,u,e);const f=Ae(a).length;return u.setSelection(et(n.id,Math.min(d,f))),r==null||r(u.build()),!0}}}function Fc(e){return{name:"moveBlockUp",run:n=>(o,r)=>{const l=Dn(o.doc,n.id);if(!l)return!1;const i=Bt(o.doc,l.id),s=(i===null?o.doc.root:on(o.doc,i).children).indexOf(l.id),a=i,d=Je();return d.moveBlock(n.id,a,Math.max(0,s)),sn(o,d,e),d.setSelection(et(n.id,0)),r==null||r(d.build()),!0}}}function Kc(e){return{name:"moveBlockDown",run:n=>(o,r)=>{const l=po(o.doc,n.id);if(!l)return!1;const i=Bt(o.doc,n.id),c=i===null?o.doc.root:on(o.doc,i).children,s=c.indexOf(l.id),a=i,d=Je(),u=c.indexOf(n.id),f=s>u?s:s+1;return d.moveBlock(n.id,a,Math.max(0,Math.min(c.length,f))),sn(o,d,e),d.setSelection(et(n.id,0)),r==null||r(d.build()),!0}}}function Wc(e){return{name:"duplicateBlock",run:n=>(o,r)=>{if(!_t(o.doc,n.id))return!1;const i=[],c=[];for(c.push({id:n.id,parentOldId:Bt(o.doc,n.id)});c.length>0;){const{id:f,parentOldId:p}=c.pop(),m=_t(o.doc,f);if(!m)continue;i.push({oldId:f,parentOldId:p});const h=m.children;for(let y=h.length-1;y>=0;y--)c.push({id:h[y],parentOldId:f})}if(i.length===0)return!1;const s=new Map,a=new Map,d=Je();for(const f of i){const p=on(o.doc,f.oldId);let m,h;if(f.oldId===n.id){m=f.parentOldId;const L=m===null?o.doc.root:on(o.doc,m).children,S=L.indexOf(n.id);h=S>=0?S+1:L.length}else{const L=f.parentOldId,S=s.get(L)??null;if(S===null)return!1;m=S,h=a.get(S)??0,a.set(S,h+1)}const y=e.registries.schema.coerceAttrsFor(p.type,p.attrs),N=d.insertBlock({parent:m,index:h,type:p.type,attrs:y,content:p.content});s.set(f.oldId,N)}sn(o,d,e);const u=s.get(n.id)??null;return u&&d.setSelection(et(u,0)),r==null||r(d.build()),!0}}}function Gc(e){return{name:"setBlockAlign",run:n=>(o,r)=>{const l=_t(o.doc,n.id);if(!l||!("align"in e.registries.schema.get(l.type).attrs))return!1;const c=Je();return c.setAttrs(n.id,{...l.attrs,align:n.align}),r==null||r(c.build()),!0}}}function qc(e){return{name:"setBlockColor",run:n=>(o,r)=>{const l=_t(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type))return!1;const i=Je();return i.setAttrs(n.id,{...l.attrs,color:n.color}),r==null||r(i.build()),!0}}}function Yc(e){return{name:"setBlockBgColor",run:n=>(o,r)=>{const l=_t(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type))return!1;const i=Je();return i.setAttrs(n.id,{...l.attrs,bgColor:n.bgColor}),r==null||r(i.build()),!0}}}function Zc(){return{name:"setStartNumber",run:e=>(n,o)=>{const r=_t(n.doc,e.id);if(!r||r.type!=="orderedList")return!1;const l=r.attrs,i=e.startNumber;let c;if(i==null){const{startNumber:a,...d}=l;c=d}else{const a=Math.max(1,Math.floor(i));c={...l,startNumber:a}}const s=Je();return s.setAttrs(e.id,c),o==null||o(s.build()),!0}}}function Xc(e){return{name:"indentBlock",run:n=>(o,r)=>{const l=(n==null?void 0:n.id)??(o.selection.kind==="caret"?o.selection.blockId:o.selection.kind==="text"?o.selection.focus.blockId:o.selection.kind==="blocks"&&o.selection.blockIds[0]?o.selection.blockIds[0]:void 0);if(!l||!_t(o.doc,l))return!1;const c=Ar(o.doc,l);if(!c||!e.registries.schema.get(c.type).nestable||On(o.doc,c.id)>=Lr)return!1;const a=c.id,d=c.children.length,u=Je();return u.moveBlock(l,a,d),sn(o,u,e),u.setSelection(et(l,0)),r==null||r(u.build()),!0}}}function Zl(e){return{name:"outdentBlock",run:n=>(o,r)=>{const l=(n==null?void 0:n.id)??(o.selection.kind==="caret"?o.selection.blockId:o.selection.kind==="text"?o.selection.focus.blockId:o.selection.kind==="blocks"&&o.selection.blockIds[0]?o.selection.blockIds[0]:void 0);if(!l||!_t(o.doc,l))return!1;const c=Bt(o.doc,l);if(c===null)return!1;const s=Bt(o.doc,c),a=mo(o.doc,c),d=a.indexOf(c),u=d===-1?a.length:d+1,f=Je();return f.moveBlock(l,s,u),sn(o,f,e),f.setSelection(et(l,0)),r==null||r(f.build()),!0}}}function jc(e,n){if(e.type!==n.type)return!1;const o=e.attrs?Object.keys(e.attrs):[],r=n.attrs?Object.keys(n.attrs):[];return o.length!==r.length?!1:o.every(l=>e.attrs[l]===n.attrs[l])}function Xl(e,n){return e.length!==n.length?!1:e.every(o=>n.some(r=>jc(o,r)))}function Qc(e){return{name:"toggleMark",run:n=>(o,r)=>{const l=_t(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type)||e.registries.schema.isMarkDisallowed(l.type,n.markType))return!1;const i=Ae(l.content),c=Math.max(0,Math.min(n.from,i.length)),s=Math.max(c,Math.min(n.to,i.length));if(c>=s)return!1;const a=[];let d=0;for(const y of l.content){if(y.type!=="text")continue;const N=(y.marks??[]).map(K=>({...K})),L=d,S=d+y.text.length,G=[L,S];c>L&&c<S&&G.push(c),s>L&&s<S&&G.push(s),G.sort((K,F)=>K-F);for(let K=0;K<G.length-1;K++){const F=G[K],Y=G[K+1];F>=Y||a.push({text:y.text.slice(F-L,Y-L),marks:N.map(ae=>({...ae}))})}d=S}let u=!0;d=0;for(const y of a){const N=d,L=d+y.text.length;if(L>c&&N<s&&!y.marks.some(S=>S.type===n.markType)){u=!1;break}d=L}const f=["bold","italic","underline","strikethrough","color","bgColor","link"];d=0;for(const y of a){const N=d,L=d+y.text.length;L>c&&N<s&&(u?y.marks=y.marks.filter(S=>S.type!==n.markType):n.markType==="code"?(y.marks=y.marks.filter(S=>!f.includes(S.type)),y.marks.some(S=>S.type==="code")||y.marks.push({type:"code"})):f.includes(n.markType)?!y.marks.some(S=>S.type==="code")&&!y.marks.some(S=>S.type===n.markType)&&y.marks.push({type:n.markType}):y.marks.some(S=>S.type===n.markType)||y.marks.push({type:n.markType})),d=L}const p=[];for(const y of a){if(y.text.length===0)continue;const N=p[p.length-1];N&&Xl(N.marks,y.marks)?N.text+=y.text:p.push({text:y.text,marks:[...y.marks]})}const m=p.map(y=>({type:"text",text:y.text,marks:y.marks.length>0?y.marks:void 0})),h=Je();return h.setText(n.id,m),h.setMeta({addToHistory:!0}),h.setSelection(o.selection),r==null||r(h.build()),!0}}}function jl(e){return{name:"setInlineMark",run:n=>(o,r)=>{const l=_t(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type))return!1;const i=Ae(l.content),c=Math.max(0,Math.min(n.from,i.length)),s=Math.max(c,Math.min(n.to,i.length));if(c>=s)return!1;const a=[];let d=0;for(const m of l.content){if(m.type!=="text")continue;const h=(m.marks??[]).map(S=>({...S})),y=d,N=d+m.text.length,L=[y,N];c>y&&c<N&&L.push(c),s>y&&s<N&&L.push(s),L.sort((S,G)=>S-G);for(let S=0;S<L.length-1;S++){const G=L[S],K=L[S+1];G>=K||a.push({text:m.text.slice(G-y,K-y),marks:[...h]})}d=N}d=0;for(const m of a){const h=d,y=d+m.text.length;if(y>c&&h<s){const N=m.marks.some(L=>L.type==="code");if(n.attrs!==null&&N){d=y;continue}n.attrs===null?m.marks=m.marks.filter(L=>L.type!==n.markType):(m.marks=m.marks.filter(L=>L.type!==n.markType),m.marks.push({type:n.markType,attrs:n.attrs}))}d=y}const u=[];for(const m of a){if(m.text.length===0)continue;const h=u[u.length-1];h&&Xl(h.marks,m.marks)?h.text+=m.text:u.push({text:m.text,marks:[...m.marks]})}const f=u.map(m=>({type:"text",text:m.text,marks:m.marks.length>0?m.marks:void 0})),p=Je();return p.setText(n.id,f),p.setMeta({addToHistory:!0}),p.setSelection(o.selection),r==null||r(p.build()),!0}}}function Jc(e){return{name:"setLink",run:n=>(o,r)=>{const l=_t(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type))return!1;const i=Ae(l.content),c=Math.max(0,Math.min(n.from,i.length)),s=Math.max(c,Math.min(n.to,i.length));if(c>=s&&!n.text)return!1;const[a,d]=Ut(l.content,c),[,u]=Ut(d,s-c),p={type:"text",text:n.text??i.slice(c,s),marks:[{type:"link",attrs:{href:n.href}}]},m=[...a,p,...u],h=Je();return h.setText(n.id,m),h.setMeta({addToHistory:!0}),r&&r(h.build()),!0}}}function ea(e){return{name:"unsetLink",run:n=>(o,r)=>{var f;const l=_t(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type))return!1;const i=Ae(l.content),c=Math.max(0,Math.min(n.from,i.length)),s=Math.max(c,Math.min(n.to,i.length));if(c>=s)return!1;let a=!1,d=0;for(const p of l.content){if(p.type!=="text")continue;const m=d+p.text.length;if(m>c&&d<s&&((f=p.marks)!=null&&f.some(h=>h.type==="link"))){a=!0;break}d=m}return a?jl(e).run({id:n.id,markType:"link",attrs:null,from:c,to:s})(o,r):!1}}}function Ql(e){const n={registries:e};return[tr(n),Or(n),Ic(n),Bc(),Rc(),Dr(n),Yl(n),Lc(n),Oc(n),Dc(),$c(),Pc(),Vc(),Uc(),Hc(),zc(n),nr(n),Fc(n),Kc(n),Wc(n),Gc(n),qc(n),Yc(n),Zc(),Xc(n),Zl(n),Qc(n),jl(n),Jc(n),ea(n)]}const ta=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"Cmd":"Ctrl",na={Esc:"Escape",Del:"Delete",Space:" ",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown"};function Jl(e){const n=[];e.ctrlKey&&n.push("Ctrl"),e.metaKey&&n.push("Cmd"),e.altKey&&n.push("Alt"),e.shiftKey&&n.push("Shift");let o=e.key;return o==="Meta"||o==="Control"?"":(o.length===1&&(o=o.toUpperCase()),o=na[o]??o,n.push(o),n.join("-"))}function ei(e,n){return e.replace(/\bMod\b/g,ta).toLowerCase()===n.toLowerCase()}class ti{constructor(){gt(this,"bindings",[])}register(n){for(const o of n)this.bindings.push(o);this.bindings.sort((o,r)=>(o.priority??0)-(r.priority??0))}resolve(n){return this.bindings.find(o=>ei(o.key,n))}}class ni{constructor(){gt(this,"rules",[])}register(n){this.rules.push(n)}get all(){return this.rules}}class oi{constructor(){gt(this,"commands",new Map)}register(n){if(this.commands.has(n.id))throw new Error(`BlockEditor: duplicate slash command "${n.id}"`);this.commands.set(n.id,n)}get all(){return[...this.commands.values()]}search(n){const o=n.trim().toLowerCase();return o?this.all.filter(r=>(r.title+" "+(r.keywords??[]).join(" ")).toLowerCase().includes(o)):this.all}}class ri{constructor(){gt(this,"toMarkdown",new Map);gt(this,"toHTML",new Map)}register(n,o){o.toMarkdown&&this.toMarkdown.set(n,o.toMarkdown),o.toHTML&&this.toHTML.set(n,o.toHTML)}markdownFor(n){var o;return(o=this.toMarkdown.get(n.type))==null?void 0:o(n)}htmlFor(n){var o;return(o=this.toHTML.get(n.type))==null?void 0:o(n)}}class li{constructor(){gt(this,"fromMarkdown",[])}register(n){n.fromMarkdown&&this.fromMarkdown.push(n.fromMarkdown)}parseMarkdownLine(n){for(const o of this.fromMarkdown){const r=o(n);if(r)return r}return null}}function oa(e){var n;return((n=e.schema)==null?void 0:n.type)??null}class ra{constructor(){gt(this,"map",new Map)}register(n,o){if(this.map.has(n))throw new Error(`BlockEditor: duplicate renderer for "${n}"`);this.map.set(n,o)}get(n){return this.map.get(n)}}class la{constructor(){gt(this,"map",new Map)}register(n,o){const r=this.map.get(n)??[];this.map.set(n,[...r,...o])}get(n){return this.map.get(n)??[]}}const ia=Mr({type:"__fallback__",content:"text",nestable:!1});function ii(e){const n=new Map,o=r=>{if(r.uses)for(const l of r.uses)o(l);n.set(r.name,r)};for(const r of e)o(r);return[...n.values()]}function si(e,n={}){const o=ii(e),r=new Map,l=new ra,i=new ql,c=new ti,s=new ni,a=new oi,d=new la,u=new ri,f=new li,p=[],m=[];for(const N of o){let L;if(N.schema){L=N.schema;const S=Mr(L);r.set(S.type,S)}if(N.renderer&&L&&l.register(L.type,N.renderer),N.commands)for(const S of N.commands)m.push(S);if(N.keymap&&c.register(N.keymap),N.inputRules)for(const S of N.inputRules)s.register(S);if(N.slashCommands)for(const S of N.slashCommands)a.register(S);if(N.toolbar&&L&&d.register(L.type,N.toolbar),N.serialize&&L&&u.register(L.type,N.serialize),N.deserialize&&f.register(N.deserialize),N.plugins)for(const S of N.plugins)p.push(S)}const h=n.defaultBlockType??"paragraph";return{schema:new Pl(r,ia),renderers:l,commands:i,keymap:c,inputRules:s,slash:a,toolbar:d,serializers:u,deserializers:f,plugins:p,extensionCommands:m,defaultBlockType:h}}class ci{constructor(n=500){gt(this,"undoStack",[]);gt(this,"redoStack",[]);gt(this,"limit");gt(this,"manualGroupStack",[]);gt(this,"groupCounter",0);this.limit=n}beginGroup(){const n=`g-${++this.groupCounter}`;return this.manualGroupStack.push(n),n}endGroup(){this.manualGroupStack.pop();const n=this.undoStack[this.undoStack.length-1];n&&n.open&&(n.open=!1)}get currentGroup(){const n=this.manualGroupStack;return n.length>0?n[n.length-1]:null}record(n,o,r){if(n.meta.addToHistory===!1||n.steps.length===0)return;const l={original:n.steps,inverse:Wl(n.steps,r),selectionBefore:o},i=this.currentGroup??n.meta.historyGroup??null,c=this.undoStack[this.undoStack.length-1];if(i!==null&&c&&c.open&&c.group===i)c.trs.push(l),c.selectionAfter=n.selectionAfter??o;else{const s={trs:[l],selectionAfter:n.selectionAfter??o,group:i,open:i!==null};this.undoStack.push(s),this.undoStack.length>this.limit&&this.undoStack.shift()}this.redoStack.length=0}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}reset(){this.undoStack.length=0,this.redoStack.length=0}undo(){const n=this.undoStack.pop();if(!n)return null;const o=[];for(let l=n.trs.length-1;l>=0;l--)o.push(...n.trs[l].inverse);const r=n.trs[0].selectionBefore;return this.redoStack.push({...n,open:!1}),Je().setMeta({addToHistory:!1,source:"undo"}).setSelection(r).appendSteps(o).build()}redo(){const n=this.redoStack.pop();if(!n)return null;const o=[];for(const l of n.trs)o.push(...l.original);const r=n.selectionAfter;return this.undoStack.push({...n,open:!1}),Je().setMeta({addToHistory:!1,source:"redo"}).setSelection(r).appendSteps(o).build()}}class ai{constructor(n){gt(this,"registries");gt(this,"state");gt(this,"listeners",new Set);gt(this,"_history");gt(this,"commands");gt(this,"editable");gt(this,"focusBlockId",null);gt(this,"history");this.registries=si(n.extensions,{defaultBlockType:n.defaultBlockType});for(const u of Ql(this.registries))this.registries.commands.register(u);for(const u of this.registries.extensionCommands)this.registries.commands.has(u.name)?this.registries.commands.override(u):this.registries.commands.register(u);const{doc:o}=Nr(n.initialDocument??{blocks:[]}),r=o.root.length===0?this.seedEmptyDocument(o.id):o,l={},i=r.root[0]??null,c=n.initialSelection??(i?et(i,0):{kind:"blocks",blockIds:[]}),s=Ir(r,c,l);for(const u of this.registries.plugins)u.init&&(l[u.name]=u.init(s));this.state=s,this._history=new ci(n.historyLimit);const a=this._history;this.history={canUndo:()=>a.canUndo(),canRedo:()=>a.canRedo(),beginGroup:()=>a.beginGroup(),endGroup:()=>a.endGroup()},this.editable=n.editable??!0,this.registries.commands.register({name:"undo",run:()=>(u,f)=>{if(!f)return this._history.canUndo();const p=this._history.undo();return p?(f(p),!0):!1}}),this.registries.commands.register({name:"redo",run:()=>(u,f)=>{if(!f)return this._history.canRedo();const p=this._history.redo();return p?(f(p),!0):!1}});const d=(u,f)=>{const p=this.registries.commands.get(u);return p?p.run(f)(this.state,m=>this.dispatch(m)):!1};this.commands=this.registries.commands.createProxy(d)}getState(){return this.state}toData(){return Vl(this.state.doc)}toMarkdown(){return pa(this.state.doc)}setDocFromMarkdown(n){this.adoptDoc(wa(n))}setDocument(n){this.adoptDoc(Nr(n).doc)}adoptDoc(n){const o=n.root.length===0?this.seedEmptyDocument(n.id):n,r=o.root[0]??null,l=r?et(r,0):{kind:"blocks",blockIds:[]},i={},c=Ir(o,l,i);for(const s of this.registries.plugins)s.init&&(i[s.name]=s.init(c));this.state=c,this._history.reset(),this.notify({state:c,changed:new Set(In(o)),removed:new Set})}dispatch(n){const o=this.state,r=Fl(o,n,this.registries.plugins);this.state=r.state,this._history.record(n,o.selection,o.doc),this.notify(r)}undo(){const n=this._history.undo();return n?(this.dispatch(n),!0):!1}redo(){const n=this._history.redo();return n?(this.dispatch(n),!0):!1}canUndo(){return this._history.canUndo()}canRedo(){return this._history.canRedo()}subscribe(n){return this.listeners.add(n),()=>this.listeners.delete(n)}notify(n){for(const o of this.listeners)o(n)}eventContext(){return{state:this.state,dispatch:n=>this.dispatch(n),focusBlockId:()=>this.focusBlockId}}handleKeyDown(n){var r;const o=this.eventContext();for(const l of this.registries.plugins)if((r=l.onKeyDown)!=null&&r.call(l,n,o))return!0;return!1}handleInput(n){var r;const o=this.eventContext();for(const l of this.registries.plugins)if((r=l.onInput)!=null&&r.call(l,n,o))return!0;return!1}handleCompositionStart(n){var r;const o=this.eventContext();for(const l of this.registries.plugins)(r=l.onCompositionStart)==null||r.call(l,n,o)}handleCompositionEnd(n){var r;const o=this.eventContext();for(const l of this.registries.plugins)(r=l.onCompositionEnd)==null||r.call(l,n,o)}destroy(){var n;for(const o of this.registries.plugins)(n=o.onDestroy)==null||n.call(o);this.listeners.clear()}seedEmptyDocument(n){const o=fo(),r=this.registries.defaultBlockType,l={id:o,type:r,attrs:this.registries.schema.defaultAttrsFor(r),content:[],children:[]};return{id:n,root:[o],blocks:new Map([[o,l]]),parent:new Map([[o,null]])}}}const sa=/([\\`*_[\]])/g;function ca(e){return e.replace(sa,"\\$1")}function Bo(e,n){var o;return!!((o=e.marks)!=null&&o.some(r=>r.type===n))}function di(e){var o;let n="";for(const r of e){if(r.type!=="text")continue;const l=r.text;if(l.length===0)continue;const i=r.marks??[];let c=Bo(r,"code")?`\`${l}\``:ca(l);Bo(r,"bold")&&(c=`**${c}**`),Bo(r,"italic")&&(c=`*${c}*`),Bo(r,"strikethrough")&&(c=`~~${c}~~`),Bo(r,"underline")&&(c=`++${c}++`);const s=i.find(d=>d.type==="link"),a=typeof((o=s==null?void 0:s.attrs)==null?void 0:o.href)=="string"?s.attrs.href:void 0;a&&(c=`[${c}](${a})`),n+=c}return n}function Ro(e){const n=[];let o=0,r="";const l=()=>{r.length>0&&(n.push({type:"text",text:r}),r="")};for(;o<e.length;){const i=e[o];if(i==="\\"&&o+1<e.length){r+=e[o+1],o+=2;continue}if(i==="["){const s=e.indexOf("]",o+1);if(s!==-1&&e.charAt(s+1)==="("){const a=e.indexOf(")",s+2);if(a!==-1){const d=e.slice(o+1,s),u=e.slice(s+2,a);if(u.length>0){l(),n.push({type:"link",text:d,href:u}),o=a+1;continue}}}}if(i==="`"){const s=e.indexOf("`",o+1);if(s!==-1){l(),n.push({type:"code",text:e.slice(o+1,s)}),o=s+1;continue}}const c=e.startsWith("***",o)?"***":e.startsWith("___",o)?"___":null;if(c){const s=e.indexOf(c,o+3);if(s!==-1){l(),n.push({type:"italic",text:`**${e.slice(o+3,s)}**`}),o=s+3;continue}}if(e.startsWith("**",o)||e.startsWith("__",o)){const s=e.charAt(o+1),a=e.indexOf(s+s,o+2);if(a!==-1){l(),n.push({type:"bold",text:e.slice(o+2,a)}),o=a+2;continue}}if(e.startsWith("~~",o)){const s=e.indexOf("~~",o+2);if(s!==-1){l(),n.push({type:"strikethrough",text:e.slice(o+2,s)}),o=s+2;continue}}if(e.startsWith("++",o)){const s=e.indexOf("++",o+2);if(s!==-1){l(),n.push({type:"underline",text:e.slice(o+2,s)}),o=s+2;continue}}if((i==="*"||i==="_")&&!(e.charAt(o+1)===i&&o+1<e.length)){const s=e.indexOf(i,o+1);if(s!==-1){l(),n.push({type:"italic",text:e.slice(o+1,s)}),o=s+1;continue}}r+=i,o+=1}return l(),n}function aa(e,n){if(e===void 0&&n===void 0)return!0;if(e===void 0||n===void 0)return!1;const o=Object.keys(e),r=Object.keys(n);return o.length!==r.length?!1:o.every(l=>e[l]===n[l])}function da(e,n){return e.length!==n.length?!1:e.every((o,r)=>o.type===n[r].type&&aa(o.attrs,n[r].attrs))}function eo(e){const n=[],o=(l,i)=>{if(l.length===0&&i.length===0)return;const c=n[n.length-1];if(c&&da(c.marks??[],i)){n[n.length-1]={...c,text:c.text+l};return}n.push({type:"text",text:l,marks:i.length>0?[...i]:void 0})},r=(l,i)=>{for(const c of l)c.type==="text"?o(c.text,i):c.type==="link"?o(c.text,[...i,{type:"link",attrs:{href:c.href??""}}]):c.type==="code"?o(c.text,[...i,{type:"code"}]):c.type==="bold"?r(Ro(c.text),[...i,{type:"bold"}]):c.type==="italic"?r(Ro(c.text),[...i,{type:"italic"}]):c.type==="strikethrough"?r(Ro(c.text),[...i,{type:"strikethrough"}]):c.type==="underline"&&r(Ro(c.text),[...i,{type:"underline"}])};return r(Ro(e),[]),n}function ua(e){return e.content.reduce((n,o)=>o.type==="text"?n+o.text:n,"")}function fa(e){const n=typeof e.rows=="number"?e.rows:0,o=typeof e.cols=="number"?e.cols:0,r=Array.isArray(e.cells)&&e.cells.length>0?e.cells:[],l=e.headerRow===!0;if(n===0||o===0)return[];const i=(u,f)=>{const p=r[u],m=p==null?void 0:p[f];return!m||m.covered?"":ma(di(m.content??[]))},c=Array.from({length:o},(u,f)=>i(0,f)),s=Array.from({length:o},()=>"---"),a=[],d=l?1:0;for(let u=d;u<n;u++)a.push(`| ${Array.from({length:o},(f,p)=>i(u,p)).join(" | ")} |`);return[`| ${c.join(" | ")} |`,`| ${s.join(" | ")} |`,...a]}function ma(e){return e.replace(/\\/g,"\\\\").replace(/\|/g,"\\|").replace(/\r?\n/g,"<br>")}function ui(e){return e==="bulletList"||e==="orderedList"||e==="todoList"}function fi(e,n,o){var d,u,f,p;const r=e.blocks.get(n);if(!r)return[];const l=On(e,n),i=" ".repeat(l*2),c=m=>di(m.content);let s=[];switch(r.type){case"heading":{const m=typeof((d=r.attrs)==null?void 0:d.level)=="number"?r.attrs.level:1,h=Math.max(1,Math.min(6,m));s=[`${i}${"#".repeat(h)} ${c(r)}`];break}case"quote":{const m=c(r);m.length>0&&(s=m.split(`
|
|
2
|
-
`).map(
|
|
3
|
-
`).map(
|
|
4
|
-
`)}function
|
|
1
|
+
(function(se,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(se=typeof globalThis<"u"?globalThis:se||self,t(se.BlockEditor={},se.Vue))})(this,function(se,t){"use strict";var wg=Object.defineProperty;var Eg=(se,t,uo)=>t in se?wg(se,t,{enumerable:!0,configurable:!0,writable:!0,value:uo}):se[t]=uo;var wt=(se,t,uo)=>Eg(se,typeof t!="symbol"?t+"":t,uo);function uo(e){return typeof e=="string"&&e.length>0}function wc(e){return e.type==="text"}function Ae(e){return e.reduce((n,o)=>o.type==="text"?n+o.text:n,"")}function Wn(e){return e.length===0?[]:[{type:"text",text:e}]}function Wt(e,n){const o=Math.max(0,Math.floor(n));if(o<=0)return[[],e];const r=Ae(e).length;if(o>=r)return[e,[]];const l=[],s=[];let i=0;for(const c of e){if(c.type!=="text"){i<o?l.push(c):s.push(c);continue}const a=c.text.length;if(i+a<=o){l.push(c),i+=a;continue}if(i>=o){s.push(c);continue}const d=o-i,f=c.text.slice(0,d),u=c.text.slice(d);f.length>0&&l.push(c.marks?{...c,text:f}:{...c,text:f,marks:void 0}),u.length>0&&s.push(c.marks?{...c,text:u}:{...c,text:u,marks:void 0}),i+=a}return[l,s]}const Il="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-",Bl=12;function Ec(e){const n=globalThis.crypto;if(!n||typeof n.getRandomValues!="function")throw new Error("BlockEditor: Web Crypto getRandomValues is unavailable in this environment.");const o=new Uint8Array(e);return n.getRandomValues(o),o}function fo(){const e=Ec(Bl);let n="";for(let o=0;o<Bl;o++)n+=Il[e[o]%Il.length];return n}function vc(e){return e}const Cc={empty:e=>e.content.length===0||e.content.every(n=>n.text==="")};function Mr(e){return{type:e.type,attrs:e.attrs??{},content:e.content??"text",nestable:e.nestable??!1,allowedChildren:e.allowedChildren??"*",isolating:e.isolating??!1,listLike:e.listLike??!1,inlineMarks:e.inlineMarks??!0,disallowedMarks:e.disallowedMarks??[],empty:e.empty??Cc.empty}}function Gn(e){const n={};for(const[o,r]of Object.entries(e.attrs))n[o]=r.default;return n}function Rl(e,n){const o={};for(const[r,l]of Object.entries(e.attrs)){const s=n[r];s!==void 0&&(!l.validate||l.validate(s))?o[r]=s:o[r]=l.default}return o}function Ll(e,n){return e.nestable?e.allowedChildren==="*"?!0:e.allowedChildren.includes(n):!1}function Ol(e){return e.content==="text"}function Dl(e){return e.isolating}function $l(e,n){return e.empty(n)}class Pl{constructor(n,o){wt(this,"schemas");wt(this,"fallback");this.schemas=n,this.fallback=o}get(n){return this.schemas.get(n)??this.fallback}has(n){return this.schemas.has(n)}defaultAttrsFor(n){return Gn(this.get(n))}coerceAttrsFor(n,o){return Rl(this.get(n),o)}canContain(n,o){return Ll(this.get(n),o)}hasText(n){return Ol(this.get(n))}isIsolating(n){return Dl(this.get(n))}isListLike(n){return this.get(n).listLike}hasInlineMarks(n){return this.get(n).inlineMarks}isMarkDisallowed(n,o){return this.get(n).disallowedMarks.includes(o)}isEmpty(n){return $l(this.get(n.type),n)}}const Hl=new Set(["paragraph","heading","bulletList","orderedList","todoList"]);function Nr(e){const n=new Map,o=new Map,r=new Map,l=new Set,s=h=>{if(h&&!l.has(h)){const m=h;return l.add(m),h&&r.set(h,m),m}let p=fo();for(;l.has(p);)p=fo();return l.add(p),p},i=(h,p)=>{const m=s(h.id);o.set(m,p);const k=[];for(const x of h.children??[])k.push(i(x,m));return n.set(m,{id:m,type:h.type,attrs:h.attrs??{},content:h.content??[],children:k}),m},c=[];for(const h of e.blocks??[])c.push(i(h,null));const a=Array.from(o.values()).every(h=>h===null);let d=!1;for(const h of n.values())if(typeof h.attrs.indent=="number"&&h.attrs.indent>0){d=!0;break}a&&d&&Tc(n,o,c);const f=10;for(const[h,p]of n){const m=Math.min(f,Sr(o,h));if((typeof p.attrs.indent=="number"?p.attrs.indent:0)===m)continue;const{indent:x,...D}=p.attrs,U=m>0?{...D,indent:m}:D;n.set(h,{...p,attrs:U})}return{doc:{id:e.id??Nc(),root:c,blocks:n,parent:o},idMap:r}}function Tc(e,n,o){const r=[...o];for(const[c,a]of e)e.set(c,{...a,children:[]});const l=[],s=[],i=(c,a)=>{if(c===null){s.push(a),n.set(a,null);return}const d=e.get(c);if(!d){s.push(a),n.set(a,null);return}const f={...d,children:[...d.children,a]};e.set(c,f),n.set(a,c)};for(const c of r){const a=e.get(c);if(!a)continue;const d=typeof a.attrs.indent=="number"?a.attrs.indent:0,f=Hl.has(a.type),u=f?Math.max(0,d):0;for(;l.length>0&&l[l.length-1].indent>=u;)l.pop();let p=l.length>0?l[l.length-1].id:null;for(;p!==null;){const m=e.get(p);if(!m||!Hl.has(m.type))p=n.get(p)??null;else break}i(p,c),f&&l.push({indent:u,id:c})}o.length=0;for(const c of s)o.push(c)}function Vl(e){const n=r=>r.map(l=>l.type==="text"?{type:"text",text:l.text,marks:l.marks&&l.marks.length>0?l.marks.map(s=>({type:s.type,attrs:s.attrs?{...s.attrs}:void 0})):void 0}:{...l}),o=r=>{const l=e.blocks.get(r);if(!l)throw new Error(`BlockEditor: missing block ${r} during serialization`);const s=l.children.map(o);return{id:r,type:l.type,attrs:l.attrs?{...l.attrs}:void 0,content:n(l.content),...s.length?{children:s}:{}}};return{id:e.id,blocks:e.root.map(o)}}function St(e,n){return e.blocks.get(n)}function ln(e,n){const o=e.blocks.get(n);if(!o)throw new Error(`BlockEditor: unknown block ${n}`);return o}function Bt(e,n){return e.parent.get(n)??null}function Dn(e,n){return Sr(e.parent,n)}function Sr(e,n){let o=0,r=e.get(n);const l=new Set;for(;r!=null&&!l.has(r);)l.add(r),o++,r=e.get(r);return o}function mo(e,n){const o=e.parent.get(n);if(o==null)return e.root;const r=e.blocks.get(o);return r?r.children:e.root}function sn(e,n){return mo(e,n).indexOf(n)}function Ar(e,n){const o=sn(e,n);if(o<=0)return;const r=mo(e,n);return e.blocks.get(r[o-1])}function _c(e,n){const o=mo(e,n),r=o.indexOf(n);if(!(r<0||r>=o.length-1))return e.blocks.get(o[r+1])}function In(e){const n=[],o=r=>{for(const l of r){n.push(l);const s=e.blocks.get(l);s&&o(s.children)}};return o(e.root),n}function $n(e,n){const o=In(e),r=o.indexOf(n);if(!(r<=0))return e.blocks.get(o[r-1])}function po(e,n){const o=In(e),r=o.indexOf(n);if(!(r<0||r>=o.length-1))return e.blocks.get(o[r+1])}function Ul(e,n){const o=ln(e,n);if(o.children.length===0)return o;const r=o.children[o.children.length-1];return Ul(e,r)}function zl(e,n){const r=[];for(const[l,s]of e.blocks){const i=Math.min(10,Sr(e.parent,l)),c=n?n.get(s.type).attrs:void 0,a=c?"indent"in c:!0,d=a?i:0;if((typeof s.attrs.indent=="number"?s.attrs.indent:0)===d)continue;const{indent:u,...h}=s.attrs,p=d>0&&a?{...h,indent:d}:h;r.push({id:l,attrs:p})}return r}function xc(e,n){return{...e,content:n}}function Mc(e,n){return{...e,attrs:n}}function Nc(){return"doc_"+Math.random().toString(36).slice(2,10)}function Sc(e){return{id:e.id,root:e.root,blocks:e.blocks,parent:e.parent}}function Qo(e,n,o){e.blocks.set(n,o),e.changed.add(n)}function Io(e,n,o){if(n===null)e.root=o;else{const r=e.blocks.get(n);if(!r)throw new Error(`BlockEditor: unknown parent ${n}`);Qo(e,n,{...r,children:o})}}function Bo(e,n){if(n===null)return e.root;const o=e.blocks.get(n);if(!o)throw new Error(`BlockEditor: unknown parent ${n}`);return o.children}function Ac(e,n){if(!e.blocks.get(n))throw new Error(`BlockEditor: cannot remove unknown block ${n}`);const r=e.parent.get(n)??null,l=Bo(e,r).filter(i=>i!==n);Io(e,r,l);const s=[n];for(;s.length;){const i=s.pop(),c=e.blocks.get(i);if(c)for(const a of c.children)s.push(a);e.blocks.delete(i),e.parent.delete(i),e.removed.add(i),e.changed.delete(i)}}function Jo(e,n){const o={id:e.id,root:[...e.root],blocks:new Map(e.blocks),parent:new Map(e.parent),changed:new Set,removed:new Set};for(const r of n)switch(r.op){case"insertBlock":{if(o.blocks.has(r.id))throw new Error(`BlockEditor: insertBlock id collision ${r.id}`);const l={id:r.id,type:r.type,attrs:r.attrs,content:r.content,children:[]};o.blocks.set(r.id,l),o.parent.set(r.id,r.parent),o.changed.add(r.id);const s=[...Bo(o,r.parent)],i=Math.max(0,Math.min(r.index,s.length));s.splice(i,0,r.id),Io(o,r.parent,s);break}case"removeBlock":{Ac(o,r.id);break}case"replaceBlock":{const l=o.blocks.get(r.id);if(!l)throw new Error(`BlockEditor: replaceBlock unknown ${r.id}`);Qo(o,r.id,{...l,type:r.type,attrs:r.attrs});break}case"moveBlock":{if(!o.blocks.get(r.id))throw new Error(`BlockEditor: moveBlock unknown ${r.id}`);const s=o.parent.get(r.id)??null;if(s===r.toParent){const i=Bo(o,s).filter(a=>a!==r.id),c=Math.max(0,Math.min(r.toIndex,i.length));i.splice(c,0,r.id),Io(o,s,i)}else{const i=Bo(o,s).filter(d=>d!==r.id);Io(o,s,i);const c=[...Bo(o,r.toParent)],a=Math.max(0,Math.min(r.toIndex,c.length));c.splice(a,0,r.id),Io(o,r.toParent,c),o.parent.set(r.id,r.toParent)}break}case"setText":{const l=o.blocks.get(r.id);if(!l)throw new Error(`BlockEditor: setText unknown ${r.id}`);Qo(o,r.id,{...l,content:r.content});break}case"setAttrs":{const l=o.blocks.get(r.id);if(!l)throw new Error(`BlockEditor: setAttrs unknown ${r.id}`);Qo(o,r.id,{...l,attrs:r.attrs});break}}return{doc:Sc(o),changed:o.changed,removed:o.removed}}function Fl(e,n,o){const{doc:r,changed:l,removed:s}=Jo(e.doc,n.steps),i=n.selectionAfter??e.selection,c={...e.pluginState};for(const a of o)a.applyTransaction&&(c[a.name]=a.applyTransaction(n,e,r,i));return{doc:r,state:{doc:r,selection:i,pluginState:c,version:e.version+1},changed:l,removed:s}}function Ir(e,n,o={}){return{doc:e,selection:n,pluginState:o,version:0}}class Kl{constructor(){wt(this,"steps",[]);wt(this,"selectionAfter");wt(this,"meta",{})}insertBlock(n){const o=n.id??fo();return this.steps.push({op:"insertBlock",parent:n.parent,index:n.index,id:o,type:n.type,attrs:n.attrs??{},content:n.content??[]}),o}removeBlock(n){return this.steps.push({op:"removeBlock",id:n}),this}replaceBlock(n,o,r){return this.steps.push({op:"replaceBlock",id:n,type:o,attrs:r}),this}moveBlock(n,o,r){return this.steps.push({op:"moveBlock",id:n,toParent:o,toIndex:r}),this}setText(n,o){return this.steps.push({op:"setText",id:n,content:o}),this}setAttrs(n,o){return this.steps.push({op:"setAttrs",id:n,attrs:o}),this}peek(){return this.steps}appendSteps(n){for(const o of n)this.steps.push(o);return this}setSelection(n){return this.selectionAfter=n,this}setMeta(n){return this.meta={...this.meta,...n},this}addToHistory(n){return this.meta={...this.meta,addToHistory:n},this}historyGroup(n){return this.meta={...this.meta,historyGroup:n},this}skipDomWrite(n){return this.meta={...this.meta,viewHints:{...this.meta.viewHints,skipDomWrite:n}},this}build(){return{steps:this.steps,selectionAfter:this.selectionAfter,meta:this.meta}}}function et(){return new Kl}function Wl(e,n){const o=[];for(let r=e.length-1;r>=0;r--){const l=e[r];switch(l.op){case"insertBlock":o.push({op:"removeBlock",id:l.id});break;case"removeBlock":o.push(...Ic(l.id,n));break;case"replaceBlock":{const s=n.blocks.get(l.id);if(!s)break;o.push({op:"replaceBlock",id:l.id,type:s.type,attrs:s.attrs});break}case"moveBlock":{o.push({op:"moveBlock",id:l.id,toParent:Bt(n,l.id),toIndex:sn(n,l.id)});break}case"setText":{const s=n.blocks.get(l.id);if(!s)break;o.push({op:"setText",id:l.id,content:s.content});break}case"setAttrs":{const s=n.blocks.get(l.id);if(!s)break;o.push({op:"setAttrs",id:l.id,attrs:s.attrs});break}}}return o}function Ic(e,n){const o=[],r=l=>{const s=ln(n,l);o.push({op:"insertBlock",parent:Bt(n,l),index:sn(n,l),id:l,type:s.type,attrs:s.attrs,content:s.content});for(const i of s.children)r(i)};return r(e),o}function st(e,n){return{kind:"caret",blockId:e,offset:n}}function Br(e,n){return{kind:"text",anchor:e,focus:n}}function Bc(e){return{kind:"blocks",blockIds:[...e]}}function ho(e){return e.kind==="caret"}function qn(e){return e.kind==="text"}function Ro(e){return e.kind==="blocks"}function Rr(e){return ho(e)?!0:qn(e)?e.anchor.blockId===e.focus.blockId&&e.anchor.offset===e.focus.offset:e.blockIds.length===0}function Gl(e){return ho(e)?e.blockId:qn(e)?e.focus.blockId:e.blockIds[0]??null}function Rc(e){return ho(e)?e.offset:qn(e)?e.focus.offset:0}function Lc(e,n){return qn(e)?n(e.anchor,e.focus)<=0?[e.anchor,e.focus]:[e.focus,e.anchor]:null}class ql{constructor(){wt(this,"entries",new Map)}register(n){if(this.entries.has(n.name))throw new Error(`BlockEditor: duplicate command "${n.name}"`);this.entries.set(n.name,n)}override(n){this.entries.set(n.name,n)}has(n){return this.entries.has(n)}get(n){return this.entries.get(n)}createProxy(n){const o=this.entries;return new Proxy({},{get:(r,l)=>o.has(l)?s=>n(l,s):()=>!1})}}function er(e){if(Ro(e))return null;const n=Gl(e);if(!n)return null;const o=ho(e)?e.offset:e.focus.offset;return{blockId:n,offset:o}}const Lr=10;function un(e,n,o){const r=n.peek();if(r.length===0)return;const l=Jo(e.doc,r),s=zl(l.doc,o.registries.schema);for(const i of s)n.setAttrs(i.id,i.attrs)}function tr(e){return{name:"insertBlock",run:n=>(o,r)=>{const l=n.type,s=n.attrs??e.registries.schema.defaultAttrsFor(l),i=n.content??[];let c,a;if(n.after){if(!St(o.doc,n.after))return!1;c=Bt(o.doc,n.after),a=sn(o.doc,n.after)+1}else if(n.parent!==void 0){c=n.parent;const u=c===null?o.doc.root:ln(o.doc,c).children;a=n.index??u.length}else c=null,a=o.doc.root.length;if(c!==null){const u=St(o.doc,c);if(!u)return!1;const h=e.registries.schema.get(u.type);if(!(h!=null&&h.nestable))return!1}const d=et(),f=d.insertBlock({parent:c,index:a,type:l,attrs:s,content:i});return d.setSelection(st(f,0)),r==null||r(d.build()),!0}}}function Or(e){return{name:"removeBlock",run:n=>(o,r)=>{if(!St(o.doc,n.id))return!1;const l=$n(o.doc,n.id),s=po(o.doc,n.id),i=l??s,c=et(),d=ln(o.doc,n.id).children??[];if(d.length>0){const f=Bt(o.doc,n.id),u=sn(o.doc,n.id);if((()=>{if(!l)return!1;const p=e.registries.schema.get(l.type);return!(!(p!=null&&p.nestable)||Dn(o.doc,l.id)>=Lr)})()&&l){let m=(l.children??[]).length;for(const k of d)c.moveBlock(k,l.id,m),m++}else{let p=u;for(const m of d)c.moveBlock(m,f,p),p++}}if(c.removeBlock(n.id),un(o,c,e),i){const f=Ae(i.content);c.setSelection(st(i.id,f.length))}return r==null||r(c.build()),!0}}}function Oc(e){return{name:"replaceBlock",run:n=>(o,r)=>{if(!St(o.doc,n.id))return!1;const s=n.attrs??e.registries.schema.defaultAttrsFor(n.type),i=et();return i.replaceBlock(n.id,n.type,s),un(o,i,e),i.setSelection(st(n.id,0)),r==null||r(i.build()),!0}}}function Dc(){return{name:"setText",run:e=>(n,o)=>{if(!St(n.doc,e.id))return!1;const r=et();return r.setText(e.id,e.content),e.selectionAfter&&r.setSelection(e.selectionAfter),r.historyGroup("type"),r.skipDomWrite([e.id]),r.setMeta({source:"input",addToHistory:!0}),o==null||o(r.build()),!0}}}function $c(){return{name:"setAttrs",run:e=>(n,o)=>{if(!St(n.doc,e.id))return!1;const l=et();return l.setAttrs(e.id,e.attrs),o==null||o(l.build()),!0}}}function Dr(e){return{name:"splitBlock",run:n=>(o,r)=>{const l=St(o.doc,n.id);if(!l||!e.registries.schema.hasText(l.type))return!1;const s=Ae(l.content).length,i=Math.max(0,Math.min(n.offset,s)),[c,a]=Wt(l.content,i),d=Bt(o.doc,n.id),f=sn(o.doc,n.id),u=l.children??[],h=n.asType??e.registries.defaultBlockType,p=n.asAttrs??e.registries.schema.defaultAttrsFor(h),m=et();m.setText(n.id,c);const k=m.insertBlock({parent:d,index:f+1,type:h,attrs:p,content:a});if(u.length>0)for(let x=0;x<u.length;x++)m.moveBlock(u[x],k,x);return un(o,m,e),m.setSelection(st(k,0)),r==null||r(m.build()),!0}}}function Yl(e){return{name:"mergeBlock",run:n=>(o,r)=>{const l=St(o.doc,n.id);if(!l)return!1;const s=$n(o.doc,n.id);if(!s||!e.registries.schema.hasText(s.type))return!1;const i=Ae(s.content),c=[...s.content,...l.content],a=et();a.setText(s.id,c);const d=l.children??[];if(d.length>0){const f=Bt(o.doc,n.id),u=sn(o.doc,n.id),h=e.registries.schema.get(s.type);if(!!(h!=null&&h.nestable)&&Dn(o.doc,s.id)<Lr){let k=(s.children??[]).length;for(const x of d)a.moveBlock(x,s.id,k),k++}else{let m=u;for(const k of d)a.moveBlock(k,f,m),m++}}return a.removeBlock(n.id),un(o,a,e),a.setSelection(st(s.id,i.length)),r==null||r(a.build()),!0}}}function Pc(e){return{name:"enter",run:()=>(n,o)=>{const r=n.selection,l=er(r);if(!l){if(Ro(r)&&r.blockIds.length){const d=r.blockIds[r.blockIds.length-1];return tr(e).run({type:e.registries.defaultBlockType,after:d})(n,o)}return!1}const s=ln(n.doc,l.blockId),i=e.registries.schema.get(s.type);if(!e.registries.schema.hasText(s.type))return tr(e).run({type:e.registries.defaultBlockType,after:s.id})(n,o);if(i.isolating)return!1;const c=Ae(s.content),a=l.offset>=c.length;return i.listLike&&e.registries.schema.isEmpty(s)?nr(e).run({id:s.id,type:e.registries.defaultBlockType})(n,o):a&&e.registries.schema.isEmpty(s)?tr(e).run({type:e.registries.defaultBlockType,after:s.id})(n,o):i.listLike?Dr(e).run({id:s.id,offset:l.offset,asType:s.type})(n,o):Dr(e).run({id:s.id,offset:l.offset})(n,o)}}}function Hc(e){return{name:"backspace",run:()=>(n,o)=>{const r=n.selection;if(Ro(r)&&r.blockIds.length){const c=r.blockIds[0],a=$n(n.doc,c),d=et();for(const u of r.blockIds)d.removeBlock(u);const f=a??po(n.doc,r.blockIds[r.blockIds.length-1]);return un(n,d,e),f&&d.setSelection(st(f.id,Ae(f.content).length)),o==null||o(d.build()),!0}const l=er(r);if(!l)return!1;const s=ln(n.doc,l.blockId);if(qn(r)&&!Rr(r)&&r.anchor.blockId===r.focus.blockId){const[c,a]=r.anchor.offset<=r.focus.offset?[r.anchor.offset,r.focus.offset]:[r.focus.offset,r.anchor.offset],d=Ae(s.content),f=Wn(d.slice(0,c)+d.slice(a)),u=et();return u.setText(s.id,f),u.setSelection(st(s.id,c)),u.skipDomWrite([s.id]),o==null||o(u.build()),!0}if(qn(r)&&!Rr(r)&&r.anchor.blockId!==r.focus.blockId){const c=In(n.doc),a=c.indexOf(r.anchor.blockId),d=c.indexOf(r.focus.blockId);if(a===-1||d===-1)return!1;const[f,u]=a<=d?[r.anchor,r.focus]:[r.focus,r.anchor],h=c.indexOf(f.blockId),p=c.indexOf(u.blockId);if(h===-1||p===-1||h>=p)return!1;const m=ln(n.doc,f.blockId),k=ln(n.doc,u.blockId),x=Ae(m.content).length,D=Ae(k.content).length,U=Math.min(f.offset,x),F=Math.min(u.offset,D),[ee]=Wt(m.content,U),[,$]=Wt(k.content,F),V=[...ee,...$],re=Ae(ee).length,G=et();G.setText(f.blockId,V);for(let ne=p;ne>h;ne--)G.removeBlock(c[ne]);return G.setSelection(st(f.blockId,re)),un(n,G,e),o==null||o(G.build()),!0}if(l.offset>0)return!1;if(Dn(n.doc,s.id)>0)return Zl(e).run({id:s.id})(n,o);if(e.registries.schema.isListLike(s.type))return nr(e).run({id:s.id,type:e.registries.defaultBlockType})(n,o);if(e.registries.schema.isEmpty(s)&&s.type!==e.registries.defaultBlockType)return nr(e).run({id:s.id,type:e.registries.defaultBlockType})(n,o);const i=$n(n.doc,s.id);return i?e.registries.schema.isIsolating(s.type)||e.registries.schema.isIsolating(i.type)?e.registries.schema.isEmpty(s)?Or(e).run({id:s.id})(n,o):!1:e.registries.schema.hasText(i.type)?Yl(e).run({id:s.id})(n,o):e.registries.schema.isEmpty(s)?Or(e).run({id:s.id})(n,o):!1:!1}}}function Vc(){return{name:"moveToPreviousBlock",run:()=>(e,n)=>{const o=er(e.selection);if(!o)return!1;const r=$n(e.doc,o.blockId);if(!r)return!1;const l=Math.min(o.offset,Ae(r.content).length);return n==null||n(et().setSelection(st(r.id,l)).setMeta({addToHistory:!1}).build()),!0}}}function Uc(){return{name:"moveToNextBlock",run:()=>(e,n)=>{const o=er(e.selection);if(!o)return!1;const r=po(e.doc,o.blockId);if(!r)return!1;const l=Math.min(o.offset,Ae(r.content).length);return n==null||n(et().setSelection(st(r.id,l)).setMeta({addToHistory:!1}).build()),!0}}}function zc(){return{name:"setSelection",run:e=>(n,o)=>(o==null||o(et().setSelection(e.selection).setMeta({addToHistory:!1}).build()),!0)}}function Fc(){return{name:"clearSelection",run:()=>(e,n)=>(n==null||n(et().setSelection({kind:"blocks",blockIds:[]}).setMeta({addToHistory:!1}).build()),!0)}}function Kc(){return{name:"selectAll",run:()=>(e,n)=>{const o=In(e.doc);if(o.length===0)return!1;const r=o[0],l=o[o.length-1],s=ln(e.doc,l),i=Ae(s.content).length,c={kind:"text",anchor:{blockId:r,offset:0},focus:{blockId:l,offset:i}};return n==null||n(et().setSelection(c).setMeta({addToHistory:!1}).build()),!0}}}function Wc(){return{name:"selectBlock",run:e=>(n,o)=>(o==null||o(et().setSelection({kind:"blocks",blockIds:[e.id]}).setMeta({addToHistory:!1}).build()),!0)}}function Gc(e){return{name:"moveBlock",run:n=>(o,r)=>{if(!St(o.doc,n.id)||n.toParent===n.id)return!1;if(n.toParent!==null){let i=n.toParent;for(;i!==null;){if(i===n.id)return!1;i=Bt(o.doc,i)}}if(n.toParent!==null){const i=St(o.doc,n.toParent);if(!i)return!1;const c=e.registries.schema.get(i.type);if(!(c!=null&&c.nestable))return!1}const s=et();return s.moveBlock(n.id,n.toParent,n.toIndex),un(o,s,e),s.setSelection(st(n.id,0)),r==null||r(s.build()),!0}}}function nr(e){return{name:"convertBlock",run:n=>(o,r)=>{const l=St(o.doc,n.id);if(!l)return!1;const s={...l.attrs,...n.attrs??{}};let i=e.registries.schema.coerceAttrsFor(n.type,s);const c=e.registries.schema.get(n.type);let a=l.content;if(c.content==="none"&&(a=[]),!c.inlineMarks){a=a.map(p=>({type:"text",text:p.text}));const h={...i};"color"in h&&(h.color="default"),"bgColor"in h&&(h.bgColor="default"),i=h}const d=o.selection.kind==="caret"&&o.selection.blockId===n.id?o.selection.offset:0,f=et();f.replaceBlock(n.id,n.type,i),a!==l.content&&f.setText(n.id,a),un(o,f,e);const u=Ae(a).length;return f.setSelection(st(n.id,Math.min(d,u))),r==null||r(f.build()),!0}}}function qc(e){return{name:"moveBlockUp",run:n=>(o,r)=>{const l=$n(o.doc,n.id);if(!l)return!1;const s=Bt(o.doc,l.id),c=(s===null?o.doc.root:ln(o.doc,s).children).indexOf(l.id),a=s,d=et();return d.moveBlock(n.id,a,Math.max(0,c)),un(o,d,e),d.setSelection(st(n.id,0)),r==null||r(d.build()),!0}}}function Yc(e){return{name:"moveBlockDown",run:n=>(o,r)=>{const l=po(o.doc,n.id);if(!l)return!1;const s=Bt(o.doc,n.id),i=s===null?o.doc.root:ln(o.doc,s).children,c=i.indexOf(l.id),a=s,d=et(),f=i.indexOf(n.id),u=c>f?c:c+1;return d.moveBlock(n.id,a,Math.max(0,Math.min(i.length,u))),un(o,d,e),d.setSelection(st(n.id,0)),r==null||r(d.build()),!0}}}function Zc(e){return{name:"duplicateBlock",run:n=>(o,r)=>{if(!St(o.doc,n.id))return!1;const s=[],i=[];for(i.push({id:n.id,parentOldId:Bt(o.doc,n.id)});i.length>0;){const{id:u,parentOldId:h}=i.pop(),p=St(o.doc,u);if(!p)continue;s.push({oldId:u,parentOldId:h});const m=p.children;for(let k=m.length-1;k>=0;k--)i.push({id:m[k],parentOldId:u})}if(s.length===0)return!1;const c=new Map,a=new Map,d=et();for(const u of s){const h=ln(o.doc,u.oldId);let p,m;if(u.oldId===n.id){p=u.parentOldId;const D=p===null?o.doc.root:ln(o.doc,p).children,U=D.indexOf(n.id);m=U>=0?U+1:D.length}else{const D=u.parentOldId,U=c.get(D)??null;if(U===null)return!1;p=U,m=a.get(U)??0,a.set(U,m+1)}const k=e.registries.schema.coerceAttrsFor(h.type,h.attrs),x=d.insertBlock({parent:p,index:m,type:h.type,attrs:k,content:h.content});c.set(u.oldId,x)}un(o,d,e);const f=c.get(n.id)??null;return f&&d.setSelection(st(f,0)),r==null||r(d.build()),!0}}}function Xc(e){return{name:"setBlockAlign",run:n=>(o,r)=>{const l=St(o.doc,n.id);if(!l||!("align"in e.registries.schema.get(l.type).attrs))return!1;const i=et();return i.setAttrs(n.id,{...l.attrs,align:n.align}),r==null||r(i.build()),!0}}}function jc(e){return{name:"setBlockColor",run:n=>(o,r)=>{const l=St(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type))return!1;const s=et();return s.setAttrs(n.id,{...l.attrs,color:n.color}),r==null||r(s.build()),!0}}}function Qc(e){return{name:"setBlockBgColor",run:n=>(o,r)=>{const l=St(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type))return!1;const s=et();return s.setAttrs(n.id,{...l.attrs,bgColor:n.bgColor}),r==null||r(s.build()),!0}}}function Jc(){return{name:"setStartNumber",run:e=>(n,o)=>{const r=St(n.doc,e.id);if(!r||r.type!=="orderedList")return!1;const l=r.attrs,s=e.startNumber;let i;if(s==null){const{startNumber:a,...d}=l;i=d}else{const a=Math.max(1,Math.floor(s));i={...l,startNumber:a}}const c=et();return c.setAttrs(e.id,i),o==null||o(c.build()),!0}}}function ea(e){return{name:"indentBlock",run:n=>(o,r)=>{const l=(n==null?void 0:n.id)??(o.selection.kind==="caret"?o.selection.blockId:o.selection.kind==="text"?o.selection.focus.blockId:o.selection.kind==="blocks"&&o.selection.blockIds[0]?o.selection.blockIds[0]:void 0);if(!l||!St(o.doc,l))return!1;const i=Ar(o.doc,l);if(!i||!e.registries.schema.get(i.type).nestable||Dn(o.doc,i.id)>=Lr)return!1;const a=i.id,d=i.children.length,f=et();return f.moveBlock(l,a,d),un(o,f,e),f.setSelection(st(l,0)),r==null||r(f.build()),!0}}}function Zl(e){return{name:"outdentBlock",run:n=>(o,r)=>{const l=(n==null?void 0:n.id)??(o.selection.kind==="caret"?o.selection.blockId:o.selection.kind==="text"?o.selection.focus.blockId:o.selection.kind==="blocks"&&o.selection.blockIds[0]?o.selection.blockIds[0]:void 0);if(!l||!St(o.doc,l))return!1;const i=Bt(o.doc,l);if(i===null)return!1;const c=Bt(o.doc,i),a=mo(o.doc,i),d=a.indexOf(i),f=d===-1?a.length:d+1,u=et();return u.moveBlock(l,c,f),un(o,u,e),u.setSelection(st(l,0)),r==null||r(u.build()),!0}}}function ta(e,n){if(e.type!==n.type)return!1;const o=e.attrs?Object.keys(e.attrs):[],r=n.attrs?Object.keys(n.attrs):[];return o.length!==r.length?!1:o.every(l=>e.attrs[l]===n.attrs[l])}function Xl(e,n){return e.length!==n.length?!1:e.every(o=>n.some(r=>ta(o,r)))}function na(e){return{name:"toggleMark",run:n=>(o,r)=>{const l=St(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type)||e.registries.schema.isMarkDisallowed(l.type,n.markType))return!1;const s=Ae(l.content),i=Math.max(0,Math.min(n.from,s.length)),c=Math.max(i,Math.min(n.to,s.length));if(i>=c)return!1;const a=[];let d=0;for(const k of l.content){if(k.type!=="text")continue;const x=(k.marks??[]).map(ee=>({...ee})),D=d,U=d+k.text.length,F=[D,U];i>D&&i<U&&F.push(i),c>D&&c<U&&F.push(c),F.sort((ee,$)=>ee-$);for(let ee=0;ee<F.length-1;ee++){const $=F[ee],V=F[ee+1];$>=V||a.push({text:k.text.slice($-D,V-D),marks:x.map(re=>({...re}))})}d=U}let f=!0;d=0;for(const k of a){const x=d,D=d+k.text.length;if(D>i&&x<c&&!k.marks.some(U=>U.type===n.markType)){f=!1;break}d=D}const u=["bold","italic","underline","strikethrough","color","bgColor","link"];d=0;for(const k of a){const x=d,D=d+k.text.length;D>i&&x<c&&(f?k.marks=k.marks.filter(U=>U.type!==n.markType):n.markType==="code"?(k.marks=k.marks.filter(U=>!u.includes(U.type)),k.marks.some(U=>U.type==="code")||k.marks.push({type:"code"})):u.includes(n.markType)?!k.marks.some(U=>U.type==="code")&&!k.marks.some(U=>U.type===n.markType)&&k.marks.push({type:n.markType}):k.marks.some(U=>U.type===n.markType)||k.marks.push({type:n.markType})),d=D}const h=[];for(const k of a){if(k.text.length===0)continue;const x=h[h.length-1];x&&Xl(x.marks,k.marks)?x.text+=k.text:h.push({text:k.text,marks:[...k.marks]})}const p=h.map(k=>({type:"text",text:k.text,marks:k.marks.length>0?k.marks:void 0})),m=et();return m.setText(n.id,p),m.setMeta({addToHistory:!0}),m.setSelection(o.selection),r==null||r(m.build()),!0}}}function jl(e){return{name:"setInlineMark",run:n=>(o,r)=>{const l=St(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type))return!1;const s=Ae(l.content),i=Math.max(0,Math.min(n.from,s.length)),c=Math.max(i,Math.min(n.to,s.length));if(i>=c)return!1;const a=[];let d=0;for(const p of l.content){if(p.type!=="text")continue;const m=(p.marks??[]).map(U=>({...U})),k=d,x=d+p.text.length,D=[k,x];i>k&&i<x&&D.push(i),c>k&&c<x&&D.push(c),D.sort((U,F)=>U-F);for(let U=0;U<D.length-1;U++){const F=D[U],ee=D[U+1];F>=ee||a.push({text:p.text.slice(F-k,ee-k),marks:[...m]})}d=x}d=0;for(const p of a){const m=d,k=d+p.text.length;if(k>i&&m<c){const x=p.marks.some(D=>D.type==="code");if(n.attrs!==null&&x){d=k;continue}n.attrs===null?p.marks=p.marks.filter(D=>D.type!==n.markType):(p.marks=p.marks.filter(D=>D.type!==n.markType),p.marks.push({type:n.markType,attrs:n.attrs}))}d=k}const f=[];for(const p of a){if(p.text.length===0)continue;const m=f[f.length-1];m&&Xl(m.marks,p.marks)?m.text+=p.text:f.push({text:p.text,marks:[...p.marks]})}const u=f.map(p=>({type:"text",text:p.text,marks:p.marks.length>0?p.marks:void 0})),h=et();return h.setText(n.id,u),h.setMeta({addToHistory:!0}),h.setSelection(o.selection),r==null||r(h.build()),!0}}}function oa(e){return{name:"setLink",run:n=>(o,r)=>{const l=St(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type))return!1;const s=Ae(l.content),i=Math.max(0,Math.min(n.from,s.length)),c=Math.max(i,Math.min(n.to,s.length));if(i>=c&&!n.text)return!1;const[a,d]=Wt(l.content,i),[,f]=Wt(d,c-i),h={type:"text",text:n.text??s.slice(i,c),marks:[{type:"link",attrs:{href:n.href}}]},p=[...a,h,...f],m=et();return m.setText(n.id,p),m.setMeta({addToHistory:!0}),r&&r(m.build()),!0}}}function ra(e){return{name:"unsetLink",run:n=>(o,r)=>{var u;const l=St(o.doc,n.id);if(!l||!e.registries.schema.hasInlineMarks(l.type))return!1;const s=Ae(l.content),i=Math.max(0,Math.min(n.from,s.length)),c=Math.max(i,Math.min(n.to,s.length));if(i>=c)return!1;let a=!1,d=0;for(const h of l.content){if(h.type!=="text")continue;const p=d+h.text.length;if(p>i&&d<c&&((u=h.marks)!=null&&u.some(m=>m.type==="link"))){a=!0;break}d=p}return a?jl(e).run({id:n.id,markType:"link",attrs:null,from:i,to:c})(o,r):!1}}}function Ql(e){const n={registries:e};return[tr(n),Or(n),Oc(n),Dc(),$c(),Dr(n),Yl(n),Pc(n),Hc(n),Vc(),Uc(),zc(),Kc(),Wc(),Fc(),Gc(n),nr(n),qc(n),Yc(n),Zc(n),Xc(n),jc(n),Qc(n),Jc(),ea(n),Zl(n),na(n),jl(n),oa(n),ra(n)]}const la=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform)?"Cmd":"Ctrl",ia={Esc:"Escape",Del:"Delete",Space:" ",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown"};function Jl(e){const n=[];e.ctrlKey&&n.push("Ctrl"),e.metaKey&&n.push("Cmd"),e.altKey&&n.push("Alt"),e.shiftKey&&n.push("Shift");let o=e.key;return o==="Meta"||o==="Control"?"":(o.length===1&&(o=o.toUpperCase()),o=ia[o]??o,n.push(o),n.join("-"))}function ei(e,n){return e.replace(/\bMod\b/g,la).toLowerCase()===n.toLowerCase()}class ti{constructor(){wt(this,"bindings",[])}register(n){for(const o of n)this.bindings.push(o);this.bindings.sort((o,r)=>(o.priority??0)-(r.priority??0))}resolve(n){return this.bindings.find(o=>ei(o.key,n))}}class ni{constructor(){wt(this,"rules",[])}register(n){this.rules.push(n)}get all(){return this.rules}}class oi{constructor(){wt(this,"commands",new Map)}register(n){if(this.commands.has(n.id))throw new Error(`BlockEditor: duplicate slash command "${n.id}"`);this.commands.set(n.id,n)}get all(){return[...this.commands.values()]}search(n){const o=n.trim().toLowerCase();return o?this.all.filter(r=>(r.title+" "+(r.keywords??[]).join(" ")).toLowerCase().includes(o)):this.all}}class ri{constructor(){wt(this,"toMarkdown",new Map);wt(this,"toHTML",new Map)}register(n,o){o.toMarkdown&&this.toMarkdown.set(n,o.toMarkdown),o.toHTML&&this.toHTML.set(n,o.toHTML)}markdownFor(n){var o;return(o=this.toMarkdown.get(n.type))==null?void 0:o(n)}htmlFor(n){var o;return(o=this.toHTML.get(n.type))==null?void 0:o(n)}}class li{constructor(){wt(this,"fromMarkdown",[])}register(n){n.fromMarkdown&&this.fromMarkdown.push(n.fromMarkdown)}parseMarkdownLine(n){for(const o of this.fromMarkdown){const r=o(n);if(r)return r}return null}}function sa(e){var n;return((n=e.schema)==null?void 0:n.type)??null}class ca{constructor(){wt(this,"map",new Map)}register(n,o){if(this.map.has(n))throw new Error(`BlockEditor: duplicate renderer for "${n}"`);this.map.set(n,o)}get(n){return this.map.get(n)}}class aa{constructor(){wt(this,"map",new Map)}register(n,o){const r=this.map.get(n)??[];this.map.set(n,[...r,...o])}get(n){return this.map.get(n)??[]}}const da=Mr({type:"__fallback__",content:"text",nestable:!1});function ii(e){const n=new Map,o=r=>{if(r.uses)for(const l of r.uses)o(l);n.set(r.name,r)};for(const r of e)o(r);return[...n.values()]}function si(e,n={}){const o=ii(e),r=new Map,l=new ca,s=new ql,i=new ti,c=new ni,a=new oi,d=new aa,f=new ri,u=new li,h=[],p=[];for(const x of o){let D;if(x.schema){D=x.schema;const U=Mr(D);r.set(U.type,U)}if(x.renderer&&D&&l.register(D.type,x.renderer),x.commands)for(const U of x.commands)p.push(U);if(x.keymap&&i.register(x.keymap),x.inputRules)for(const U of x.inputRules)c.register(U);if(x.slashCommands)for(const U of x.slashCommands)a.register(U);if(x.toolbar&&D&&d.register(D.type,x.toolbar),x.serialize&&D&&f.register(D.type,x.serialize),x.deserialize&&u.register(x.deserialize),x.plugins)for(const U of x.plugins)h.push(U)}const m=n.defaultBlockType??"paragraph";return{schema:new Pl(r,da),renderers:l,commands:s,keymap:i,inputRules:c,slash:a,toolbar:d,serializers:f,deserializers:u,plugins:h,extensionCommands:p,defaultBlockType:m}}class ci{constructor(n=500){wt(this,"undoStack",[]);wt(this,"redoStack",[]);wt(this,"limit");wt(this,"manualGroupStack",[]);wt(this,"groupCounter",0);this.limit=n}beginGroup(){const n=`g-${++this.groupCounter}`;return this.manualGroupStack.push(n),n}endGroup(){this.manualGroupStack.pop();const n=this.undoStack[this.undoStack.length-1];n&&n.open&&(n.open=!1)}get currentGroup(){const n=this.manualGroupStack;return n.length>0?n[n.length-1]:null}record(n,o,r){if(n.meta.addToHistory===!1||n.steps.length===0)return;const l={original:n.steps,inverse:Wl(n.steps,r),selectionBefore:o},s=this.currentGroup??n.meta.historyGroup??null,i=this.undoStack[this.undoStack.length-1];if(s!==null&&i&&i.open&&i.group===s)i.trs.push(l),i.selectionAfter=n.selectionAfter??o;else{const c={trs:[l],selectionAfter:n.selectionAfter??o,group:s,open:s!==null};this.undoStack.push(c),this.undoStack.length>this.limit&&this.undoStack.shift()}this.redoStack.length=0}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}reset(){this.undoStack.length=0,this.redoStack.length=0}undo(){const n=this.undoStack.pop();if(!n)return null;const o=[];for(let l=n.trs.length-1;l>=0;l--)o.push(...n.trs[l].inverse);const r=n.trs[0].selectionBefore;return this.redoStack.push({...n,open:!1}),et().setMeta({addToHistory:!1,source:"undo"}).setSelection(r).appendSteps(o).build()}redo(){const n=this.redoStack.pop();if(!n)return null;const o=[];for(const l of n.trs)o.push(...l.original);const r=n.selectionAfter;return this.undoStack.push({...n,open:!1}),et().setMeta({addToHistory:!1,source:"redo"}).setSelection(r).appendSteps(o).build()}}class ai{constructor(n){wt(this,"registries");wt(this,"state");wt(this,"listeners",new Set);wt(this,"_history");wt(this,"commands");wt(this,"editable");wt(this,"focusBlockId",null);wt(this,"history");this.registries=si(n.extensions,{defaultBlockType:n.defaultBlockType});for(const f of Ql(this.registries))this.registries.commands.register(f);for(const f of this.registries.extensionCommands)this.registries.commands.has(f.name)?this.registries.commands.override(f):this.registries.commands.register(f);const{doc:o}=Nr(n.initialDocument??{blocks:[]}),r=o.root.length===0?this.seedEmptyDocument(o.id):o,l={},s=r.root[0]??null,i=n.initialSelection??(s?st(s,0):{kind:"blocks",blockIds:[]}),c=Ir(r,i,l);for(const f of this.registries.plugins)f.init&&(l[f.name]=f.init(c));this.state=c,this._history=new ci(n.historyLimit);const a=this._history;this.history={canUndo:()=>a.canUndo(),canRedo:()=>a.canRedo(),beginGroup:()=>a.beginGroup(),endGroup:()=>a.endGroup()},this.editable=n.editable??!0,this.registries.commands.register({name:"undo",run:()=>(f,u)=>{if(!u)return this._history.canUndo();const h=this._history.undo();return h?(u(h),!0):!1}}),this.registries.commands.register({name:"redo",run:()=>(f,u)=>{if(!u)return this._history.canRedo();const h=this._history.redo();return h?(u(h),!0):!1}});const d=(f,u)=>{const h=this.registries.commands.get(f);return h?h.run(u)(this.state,p=>this.dispatch(p)):!1};this.commands=this.registries.commands.createProxy(d)}getState(){return this.state}toData(){return Vl(this.state.doc)}toMarkdown(){return ka(this.state.doc)}setDocFromMarkdown(n){this.adoptDoc(Ta(n))}setDocument(n){this.adoptDoc(Nr(n).doc)}adoptDoc(n){const o=n.root.length===0?this.seedEmptyDocument(n.id):n,r=o.root[0]??null,l=r?st(r,0):{kind:"blocks",blockIds:[]},s={},i=Ir(o,l,s);for(const c of this.registries.plugins)c.init&&(s[c.name]=c.init(i));this.state=i,this._history.reset(),this.notify({state:i,changed:new Set(In(o)),removed:new Set})}dispatch(n){const o=this.state,r=Fl(o,n,this.registries.plugins);this.state=r.state,this._history.record(n,o.selection,o.doc),this.notify(r)}undo(){const n=this._history.undo();return n?(this.dispatch(n),!0):!1}redo(){const n=this._history.redo();return n?(this.dispatch(n),!0):!1}canUndo(){return this._history.canUndo()}canRedo(){return this._history.canRedo()}subscribe(n){return this.listeners.add(n),()=>this.listeners.delete(n)}notify(n){for(const o of this.listeners)o(n)}eventContext(){return{state:this.state,dispatch:n=>this.dispatch(n),focusBlockId:()=>this.focusBlockId}}handleKeyDown(n){var r;const o=this.eventContext();for(const l of this.registries.plugins)if((r=l.onKeyDown)!=null&&r.call(l,n,o))return!0;return!1}handleInput(n){var r;const o=this.eventContext();for(const l of this.registries.plugins)if((r=l.onInput)!=null&&r.call(l,n,o))return!0;return!1}handleCompositionStart(n){var r;const o=this.eventContext();for(const l of this.registries.plugins)(r=l.onCompositionStart)==null||r.call(l,n,o)}handleCompositionEnd(n){var r;const o=this.eventContext();for(const l of this.registries.plugins)(r=l.onCompositionEnd)==null||r.call(l,n,o)}destroy(){var n;for(const o of this.registries.plugins)(n=o.onDestroy)==null||n.call(o);this.listeners.clear()}seedEmptyDocument(n){const o=fo(),r=this.registries.defaultBlockType,l={id:o,type:r,attrs:this.registries.schema.defaultAttrsFor(r),content:[],children:[]};return{id:n,root:[o],blocks:new Map([[o,l]]),parent:new Map([[o,null]])}}}const ua=/([\\`*_[\]])/g;function fa(e){return e.replace(ua,"\\$1")}function Lo(e,n){var o;return!!((o=e.marks)!=null&&o.some(r=>r.type===n))}function di(e){var o;let n="";for(const r of e){if(r.type!=="text")continue;const l=r.text;if(l.length===0)continue;const s=r.marks??[];let i=Lo(r,"code")?`\`${l}\``:fa(l);Lo(r,"bold")&&(i=`**${i}**`),Lo(r,"italic")&&(i=`*${i}*`),Lo(r,"strikethrough")&&(i=`~~${i}~~`),Lo(r,"underline")&&(i=`++${i}++`);const c=s.find(d=>d.type==="link"),a=typeof((o=c==null?void 0:c.attrs)==null?void 0:o.href)=="string"?c.attrs.href:void 0;a&&(i=`[${i}](${a})`),n+=i}return n}function Oo(e){const n=[];let o=0,r="";const l=()=>{r.length>0&&(n.push({type:"text",text:r}),r="")};for(;o<e.length;){const s=e[o];if(s==="\\"&&o+1<e.length){r+=e[o+1],o+=2;continue}if(s==="["){const c=e.indexOf("]",o+1);if(c!==-1&&e.charAt(c+1)==="("){const a=e.indexOf(")",c+2);if(a!==-1){const d=e.slice(o+1,c),f=e.slice(c+2,a);if(f.length>0){l(),n.push({type:"link",text:d,href:f}),o=a+1;continue}}}}if(s==="`"){const c=e.indexOf("`",o+1);if(c!==-1){l(),n.push({type:"code",text:e.slice(o+1,c)}),o=c+1;continue}}const i=e.startsWith("***",o)?"***":e.startsWith("___",o)?"___":null;if(i){const c=e.indexOf(i,o+3);if(c!==-1){l(),n.push({type:"italic",text:`**${e.slice(o+3,c)}**`}),o=c+3;continue}}if(e.startsWith("**",o)||e.startsWith("__",o)){const c=e.charAt(o+1),a=e.indexOf(c+c,o+2);if(a!==-1){l(),n.push({type:"bold",text:e.slice(o+2,a)}),o=a+2;continue}}if(e.startsWith("~~",o)){const c=e.indexOf("~~",o+2);if(c!==-1){l(),n.push({type:"strikethrough",text:e.slice(o+2,c)}),o=c+2;continue}}if(e.startsWith("++",o)){const c=e.indexOf("++",o+2);if(c!==-1){l(),n.push({type:"underline",text:e.slice(o+2,c)}),o=c+2;continue}}if((s==="*"||s==="_")&&!(e.charAt(o+1)===s&&o+1<e.length)){const c=e.indexOf(s,o+1);if(c!==-1){l(),n.push({type:"italic",text:e.slice(o+1,c)}),o=c+1;continue}}r+=s,o+=1}return l(),n}function ma(e,n){if(e===void 0&&n===void 0)return!0;if(e===void 0||n===void 0)return!1;const o=Object.keys(e),r=Object.keys(n);return o.length!==r.length?!1:o.every(l=>e[l]===n[l])}function pa(e,n){return e.length!==n.length?!1:e.every((o,r)=>o.type===n[r].type&&ma(o.attrs,n[r].attrs))}function eo(e){const n=[],o=(l,s)=>{if(l.length===0&&s.length===0)return;const i=n[n.length-1];if(i&&pa(i.marks??[],s)){n[n.length-1]={...i,text:i.text+l};return}n.push({type:"text",text:l,marks:s.length>0?[...s]:void 0})},r=(l,s)=>{for(const i of l)i.type==="text"?o(i.text,s):i.type==="link"?o(i.text,[...s,{type:"link",attrs:{href:i.href??""}}]):i.type==="code"?o(i.text,[...s,{type:"code"}]):i.type==="bold"?r(Oo(i.text),[...s,{type:"bold"}]):i.type==="italic"?r(Oo(i.text),[...s,{type:"italic"}]):i.type==="strikethrough"?r(Oo(i.text),[...s,{type:"strikethrough"}]):i.type==="underline"&&r(Oo(i.text),[...s,{type:"underline"}])};return r(Oo(e),[]),n}function ha(e){return e.content.reduce((n,o)=>o.type==="text"?n+o.text:n,"")}function ga(e){const n=typeof e.rows=="number"?e.rows:0,o=typeof e.cols=="number"?e.cols:0,r=Array.isArray(e.cells)&&e.cells.length>0?e.cells:[],l=e.headerRow===!0;if(n===0||o===0)return[];const s=(f,u)=>{const h=r[f],p=h==null?void 0:h[u];return!p||p.covered?"":ba(di(p.content??[]))},i=Array.from({length:o},(f,u)=>s(0,u)),c=Array.from({length:o},()=>"---"),a=[],d=l?1:0;for(let f=d;f<n;f++)a.push(`| ${Array.from({length:o},(u,h)=>s(f,h)).join(" | ")} |`);return[`| ${i.join(" | ")} |`,`| ${c.join(" | ")} |`,...a]}function ba(e){return e.replace(/\\/g,"\\\\").replace(/\|/g,"\\|").replace(/\r?\n/g,"<br>")}function ui(e){return e==="bulletList"||e==="orderedList"||e==="todoList"}function fi(e,n,o){var d,f,u,h;const r=e.blocks.get(n);if(!r)return[];const l=Dn(e,n),s=" ".repeat(l*2),i=p=>di(p.content);let c=[];switch(r.type){case"heading":{const p=typeof((d=r.attrs)==null?void 0:d.level)=="number"?r.attrs.level:1,m=Math.max(1,Math.min(6,p));c=[`${s}${"#".repeat(m)} ${i(r)}`];break}case"quote":{const p=i(r);p.length>0&&(c=p.split(`
|
|
2
|
+
`).map(m=>`${s}> ${m}`));break}case"codeBlock":{const p=typeof((f=r.attrs)==null?void 0:f.language)=="string"&&r.attrs.language?r.attrs.language:"",m=ha(r),k=m.includes("```")?"````":"```";c=[`${s}${k}${p}`,...m.split(`
|
|
3
|
+
`).map(x=>`${s}${x}`),`${s}${k}`];break}case"bulletList":{c=[`${s}- ${i(r)}`];break}case"orderedList":{const p=typeof((u=r.attrs)==null?void 0:u.startNumber)=="number"?r.attrs.startNumber:1;c=[`${s}${p}. ${i(r)}`];break}case"todoList":{const p=((h=r.attrs)==null?void 0:h.checked)===!0;c=[`${s}- ${p?"[x]":"[ ]"} ${i(r)}`];break}case"divider":{c=[`${s}---`];break}case"image":{const p=r.attrs??{},m=typeof p.src=="string"?p.src:"";if(!m)break;const k=typeof p.alt=="string"?p.alt:"",x=typeof p.title=="string"?p.title:"",D=typeof p.caption=="string"?p.caption:"",U=x?``:``;c=D?[`${s}${U}`,`${s}*${D}*`]:[`${s}${U}`];break}case"table":{c=ga(r.attrs??{});break}case"tableOfContents":{c=[];break}default:{const p=i(r);p.length>0&&(c=[`${s}${p}`]);break}}const a=[];c.length>0&&a.push({lines:c,level:l,type:r.type});for(const p of r.children)a.push(...fi(e,p));return a}function ka(e){const n=[];for(const l of e.root)n.push(...fi(e,l));const o=[];for(let l=0;l<n.length;l++){const s=n[l];if(l>0){const i=n[l-1];!ya(i,s)&&o.push("")}for(const i of s.lines)o.push(i)}const r=[];for(const l of o)l===""&&(r.length===0||r[r.length-1]==="")||r.push(l);return r.join(`
|
|
4
|
+
`)}function ya(e,n){return e.level!==n.level?!0:ui(e.type)&&ui(n.type)&&e.type===n.type}function wa(e){const n=/^(#{1,6})\s+(.*)$/.exec(e);if(n)return{type:"heading",attrs:{level:n[1].length},content:eo(n[2])};const o=/^>\s?(.*)$/.exec(e);if(o)return{type:"quote",content:eo(o[1]??"")};const r=/^[-*+]\s+\[([ xX])\]\s+(.*)$/.exec(e);if(r)return{type:"todoList",attrs:{checked:r[1].toLowerCase()==="x"},content:eo(r[2])};const l=/^(\d+)\.\s+(.*)$/.exec(e);if(l)return{type:"orderedList",attrs:{startNumber:Number(l[1])},content:eo(l[2])};const s=/^[-*+]\s+(.*)$/.exec(e);if(s)return{type:"bulletList",content:eo(s[1])};if(/^-{3,}$/.test(e)||/^\*{3,}$/.test(e)||/^_{3,}$/.test(e))return{type:"divider"};const i=/^!\[([^\]]*)\]\((\S+?)(?:\s+"([^"]*)")?\)$/.exec(e.trim());if(i){const c={src:i[2]??"",alt:i[1]??""};return i[3]&&(c.title=i[3]),{type:"image",attrs:c}}return e.trim().length===0?null:{type:"paragraph",content:eo(e)}}function Ea(e){const n=e.replace(/\r\n/g,`
|
|
5
5
|
`).split(`
|
|
6
|
-
`),o=[];let r=[],l=0;const
|
|
7
|
-
`).replace(/\\\|/g,"|").replace(/\\\\/g,"\\")}function
|
|
8
|
-
`)}]}});continue}if(
|
|
9
|
-
`},...L]}}}else n.push({indent:h.indent,block:h.block})}}const r=new Map,l=new Map,i=[],c=[],s=new Set(["paragraph","heading","bulletList","orderedList","todoList"]),a=10,d=(f,p,m)=>{if(r.set(p,m),l.set(p,f),f===null){i.push(p);return}const h=r.get(f);if(!h){i.push(p),l.set(p,null);return}r.set(f,{...h,children:[...h.children,p]})};for(const f of n){const p=fo(),m=s.has(f.block.type);let h=Math.floor(f.indent/2);for(h<0&&(h=0),h>a&&(h=a);c.length>0&&c[c.length-1].indent>=h;)c.pop();const y=c.length>0?c[c.length-1].id:null,N={...f.block.attrs??{}},L={id:p,type:f.block.type,attrs:N,content:f.block.content??[],children:[]};d(y,p,L),m&&c.push({indent:h,id:p})}const u=10;for(const[f,p]of r){let m=0,h=l.get(f);const y=new Set;for(;h!=null&&!y.has(h);)y.add(h),m++,h=l.get(h);if(m=Math.min(u,m),(typeof p.attrs.indent=="number"?p.attrs.indent:0)===m)continue;const{indent:L,...S}=p.attrs,G=m>0?{...S,indent:m}:S;r.set(f,{...p,attrs:G})}return{id:"doc_"+Math.random().toString(36).slice(2,10),root:i,blocks:r,parent:l}}const mi=Symbol("block-editor-mobile"),$r=Symbol("block-editor-fixed-toolbar-bridge"),Lo=Symbol("block-editor-fixed-toolbar-bottom"),Pr=Symbol("block-editor"),pi=Symbol("block-editor-editable"),hi=Symbol("block-editor-image-upload");function cn(){const e=t.inject(Pr);if(!e)throw new Error("useEditor(): must be called within a <BlockEditor> component tree");return e}function Ea(){return t.inject(hi,null)}function Yn(){return t.inject(pi)??t.ref(!0)}function va(e,n){const o=Jl(n);if(!o)return!1;const r=e.registries.keymap.resolve(o);if(!r)return!1;const l=e.commands[r.command];return l?l(r.args)===!0:!1}const Ca=e=>`[data-block-id="${CSS.escape(e)}"]`;function Oo(e,n){const o=Ca(n),r=e.querySelector(`${o}[contenteditable], ${o} [contenteditable]`);return r||e.querySelector(o)}function Ta(e){const n=window.getSelection();if(!n||n.rangeCount===0)return 0;const o=n.getRangeAt(0),r=o.cloneRange();return r.selectNodeContents(e),r.setEnd(o.endContainer,o.endOffset),r.toString().length}function gi(e,n){const o=window.getSelection();if(!o||o.rangeCount===0)return null;const r=o.getRangeAt(0).endContainer,l=or(r,e);if(!l)return null;const i=l.dataset.blockId;if(!i)return null;const c=Ta(l),s=n.blocks.get(i);if(!s)return null;const a=Ae(s.content).length,d=Math.min(c,a);if(!o.isCollapsed&&o.anchorNode===o.focusNode&&or(o.anchorNode,e)===l){const f=Math.min(o.anchorOffset,a);return{kind:"text",anchor:{blockId:i,offset:f},focus:{blockId:i,offset:d}}}return et(i,d)}function or(e,n){let o=e;for(;o&&o!==n;){if(o.nodeType===Node.ELEMENT_NODE){const r=o;if(r.dataset&&r.dataset.blockId)return r}o=o.parentNode}return null}function _a(e,n,o){const r=document.createRange();r.selectNodeContents(e);try{r.setEnd(n,o)}catch{return 0}return r.toString().length}function bi(e,n,o){const r=ki(e,n),l=ki(e,o);if(!r||!l)return null;try{const i=document.createRange();return i.setStart(r.node,r.offset),i.setEnd(l.node,l.offset),i}catch{return null}}function ki(e,n){let o=0;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let l=null;for(;r.nextNode();){const i=r.currentNode;l=i;const c=(i.nodeValue??"").length;if(o+c>=n)return{node:i,offset:Math.max(0,n-o)};o+=c}return l?{node:l,offset:(l.nodeValue??"").length}:{node:e,offset:0}}function rr(e,n,o,r){let l=null;const i=document;if(typeof i.caretRangeFromPoint=="function")l=i.caretRangeFromPoint(e,n);else if(typeof i.caretPositionFromPoint=="function"){const c=i.caretPositionFromPoint(e,n);c&&(l=document.createRange(),l.setStart(c.offsetNode,c.offset),l.collapse(!0))}if(l){const c=or(l.startContainer,o);if(c){const s=c.dataset.blockId;if(s){const a=r.blocks.get(s);if(a){const d=Ae(a.content).length,u=Math.min(_a(c,l.startContainer,l.startOffset),d);return{blockEl:c,blockId:s,offset:u}}}}}return xa(e,n,o,r)}function xa(e,n,o,r){const l=document.elementFromPoint(e,n),i=l?or(l,o):null;if(!i)return null;const c=i.dataset.blockId;if(!c)return null;const s=r.blocks.get(c);if(!s)return null;const a=i.matches("[contenteditable]")?i:i.querySelector("[contenteditable]");if(!a)return null;const d=Ae(s.content).length;let u=null,f=0;const p=document.createTreeWalker(a,NodeFilter.SHOW_TEXT);let m;for(;m=p.nextNode();){const h=m,y=(h.nodeValue??"").length;if(y===0)continue;const N=document.createRange();N.setStart(h,0),N.setEnd(h,y);const L=N.getBoundingClientRect();if(L.width<=0&&L.height<=0)continue;const S=Math.max(L.left,Math.min(e,L.right)),G=Math.max(L.top,Math.min(n,L.bottom)),K=Math.hypot(e-S,n-G),F=L.width>0?Math.round((e-L.left)/L.width*y):0,Y=f+Math.max(0,Math.min(y,F));(!u||K<u.dist)&&(u={offset:Y,dist:K}),f+=y}return u?{blockEl:i,blockId:c,offset:Math.min(u.offset,d)}:{blockEl:i,blockId:c,offset:0}}function Hr(e,n){const o=document.createRange(),r=window.getSelection();if(!r)return;let l=0,i=!1;const c=s=>{var a;if(!i)if(s.nodeType===Node.TEXT_NODE){const d=((a=s.textContent)==null?void 0:a.length)??0;l+d>=n&&(o.setStart(s,Math.max(0,n-l)),o.collapse(!0),i=!0),l+=d}else for(const d of s.childNodes)c(d)};c(e),i||(o.selectNodeContents(e),o.collapse(!1)),r.removeAllRanges(),r.addRange(o)}function yi(e,n){if(ho(n)){const r=Oo(e,n.blockId);if(!r)return;r.focus(),Hr(r,n.offset);return}if(qn(n)&&n.anchor.blockId===n.focus.blockId){const r=Oo(e,n.focus.blockId);if(!r)return;if(r.focus(),n.anchor.offset===n.focus.offset)Hr(r,n.focus.offset);else{const l=Math.min(n.anchor.offset,n.focus.offset),i=Math.max(n.anchor.offset,n.focus.offset),c=bi(r,l,i),s=window.getSelection();c&&s?(s.removeAllRanges(),s.addRange(c)):Hr(r,n.focus.offset)}return}const o=window.getSelection();o&&o.rangeCount>0&&o.removeAllRanges()}function Pt(e){return e.kind==="text"&&!(e.anchor.blockId===e.focus.blockId&&e.anchor.offset===e.focus.offset)&&e.anchor.blockId!==e.focus.blockId}function Vr(e,n,o){if(o.anchor.blockId===o.focus.blockId)return[];const r=In(n),l=r.indexOf(o.anchor.blockId),i=r.indexOf(o.focus.blockId);if(l===-1||i===-1)return[];const[c,s]=l<=i?[o.anchor.blockId,o.focus.blockId,l<i]:[o.focus.blockId,o.anchor.blockId,l>i],a=r.indexOf(c),d=r.indexOf(s);if(a===-1||d===-1)return[];const u=[];for(let f=a;f<=d;f++){const p=r[f],m=n.blocks.get(p);if(!m)continue;const h=Oo(e,p);if(!h)continue;const y=Ae(m.content).length;let N=0,L=y;if(f===a){const G=c===o.anchor.blockId?o.anchor.offset:o.focus.offset;N=Math.min(G,y)}if(f===d){const G=s===o.anchor.blockId?o.anchor.offset:o.focus.offset;L=Math.min(G,y)}const S=bi(h,N,Math.max(N,L));if(S)for(const G of S.getClientRects())G.width>0&&G.height>0&&u.push(G)}return u}function Ma(e){var i;const{registry:n,blockId:o,text:r,editor:l}=e;for(const c of n.all){const s=c.pattern.exec(r);if(!s)continue;const a=(i=c.args)==null?void 0:i.call(c,s),d=a&&typeof a=="object"?a:{},u={...d};u.id==="__currentBlock__"&&(u.id=o);const f=typeof d.__stripPrefix=="number"?d.__stripPrefix:0,p=l.commands[c.command];if(p){l.history.beginGroup();try{if(f>0){const m=r.slice(f),h=l.commands.setText;h&&h({id:o,content:Wn(m)})}p(u)}finally{l.history.endGroup()}return!0}}return!1}function Na(e){return e.includes("/")?e.startsWith("/")||/^\s*\/\S*/.test(e):!1}const Sa=["http:","https:","mailto:","tel:"],Aa=["javascript:","vbscript:","data:","file:"];function $n(e){const n=e.trim();if(!n)return null;const o=n.toLowerCase();for(const i of Aa)if(o.startsWith(i))return null;const r=n.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);if(r){const i=r[1].toLowerCase()+":";return Sa.includes(i)?n:null}const l=n[0];return l==="/"||l==="."||l==="#"||n.startsWith("//")||Ur(n)?n:null}function Ur(e){const n=e.trim();return!n||n.length<4?!1:/^https?:\/\//i.test(n)||/^mailto:/i.test(n)?!0:/\s/.test(n)?!1:!!/^[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s]*)?$/.test(n)}function to(e){const n=e.trim();return n?/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n)?n:n.startsWith("@")||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?n.startsWith("mailto:")?n:`mailto:${n.replace(/^@/,"")}`:Ur(n)&&!n.startsWith("/")?`https://${n}`:n:""}const Do=/(^|\s)((?:https?:\/\/|www\.)[^\s<]+|[\w-]+(?:\.[\w-]+)+\.[a-zA-Z]{2,}(?::\d+)?(?:\/[^\s<]*)?)/g;function lr(e){var r,l;let n=!1;const o=[];for(const i of e){if(i.type!=="text"){o.push(i);continue}const c=(r=i.marks)==null?void 0:r.some(m=>m.type==="link"),s=(l=i.marks)==null?void 0:l.some(m=>m.type==="code");if(c||s){o.push(i);continue}const a=i.text,d=i.marks??[];if(Do.lastIndex=0,!Do.exec(a)){o.push(i);continue}n=!0;let f=0;Do.lastIndex=0;let p;for(;(p=Do.exec(a))!==null;){const m=p[0],h=p[2],y=p.index+m.length-h.length,N=y+h.length;if(y>f){const G=a.slice(f,y);G.length>0&&o.push({type:"text",text:G,marks:d.length>0?[...d]:void 0})}const L=to(h),S=$n(L);if(S){const G={type:"link",attrs:{href:S}};o.push({type:"text",text:h,marks:[...d,G]})}else o.push({type:"text",text:h,marks:d.length>0?[...d]:void 0});f=N}if(f<a.length){const m=a.slice(f);m.length>0&&o.push({type:"text",text:m,marks:d.length>0?[...d]:void 0})}Do.lastIndex=0}return n?o:e}const Ia={bold:["b","strong"],italic:["i","em"],underline:["u"],strikethrough:["s","strike","del"],code:["code"],link:["a"]},wi={};for(const[e,n]of Object.entries(Ia))for(const o of n)wi[o]=e;const Ba="b,strong,i,em,u,s,strike,del,code,a[href],span.be-color-gray,span.be-color-brown,span.be-color-orange,span.be-color-yellow,span.be-color-green,span.be-color-blue,span.be-color-purple,span.be-color-pink,span.be-color-red,span.be-bg-gray,span.be-bg-brown,span.be-bg-orange,span.be-bg-yellow,span.be-bg-green,span.be-bg-blue,span.be-bg-purple,span.be-bg-pink,span.be-bg-red";function Ra(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function La(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Ei(e){return e.some(n=>n.type==="text"&&n.marks&&n.marks.length>0)}function Zn(e){return e.length===0?"":e.map(n=>{var u,f,p;if(n.type!=="text")return"";let o=Ra(n.text);const r=n.marks??[],l=r.find(m=>m.type==="color"),i=(u=l==null?void 0:l.attrs)==null?void 0:u.color;typeof i=="string"&&(o=`<span class="be-color-${i}">${o}</span>`);const c=r.find(m=>m.type==="bgColor"),s=(f=c==null?void 0:c.attrs)==null?void 0:f.bgColor;typeof s=="string"&&(o=`<span class="be-bg-${s}">${o}</span>`),r.some(m=>m.type==="strikethrough")&&(o=`<s>${o}</s>`),r.some(m=>m.type==="underline")&&(o=`<u>${o}</u>`),r.some(m=>m.type==="italic")&&(o=`<i>${o}</i>`),r.some(m=>m.type==="bold")&&(o=`<b>${o}</b>`),r.some(m=>m.type==="code")&&(o=`<code>${o}</code>`);const a=r.find(m=>m.type==="link"),d=(p=a==null?void 0:a.attrs)==null?void 0:p.href;if(typeof d=="string"){const m=$n(d);m&&(o=`<a href="${La(m)}" target="_blank" rel="noopener noreferrer">${o}</a>`)}return o}).join("")}function Oa(e){const n=[],o=e.className;if(typeof o=="string"){const r=o.match(/be-color-(\w+)/);r&&n.push({type:"color",attrs:{color:r[1]}});const l=o.match(/be-bg-(\w+)/);l&&n.push({type:"bgColor",attrs:{bgColor:l[1]}})}return n}function an(e){const n=[];function o(r,l){if(r.nodeType===Node.TEXT_NODE){const d=r.textContent??"";d.length>0&&n.push({type:"text",text:d,marks:l.length>0?[...l]:void 0});return}if(r.nodeType!==Node.ELEMENT_NODE)return;const i=r,c=i.tagName.toLowerCase();if(c==="br")return;const s=wi[c];let a=l;if(s==="link"){const d=i.getAttribute("href")??"",u=$n(d);u?a=[...l,{type:"link",attrs:{href:u}}]:a=l}else if(s)a=[...l,{type:s}];else if(c==="span"){const d=Oa(i);d.length>0&&(a=[...l,...d])}for(const d of i.childNodes)o(d,a)}return o(e,[]),Pa(n)}function Da(e,n){if(e.type!==n.type)return!1;const o=e.attrs?Object.keys(e.attrs):[],r=n.attrs?Object.keys(n.attrs):[];return o.length!==r.length?!1:o.every(l=>e.attrs[l]===n.attrs[l])}function $a(e,n){return!e&&!n?!0:!e||!n||e.length!==n.length?!1:e.every(o=>n.some(r=>Da(o,r)))}function Pa(e){const n=[];for(const o of e){const r=n[n.length-1];r&&$a(r.marks,o.marks)?n[n.length-1]={type:"text",text:r.text+o.text,marks:r.marks}:n.push({...o})}return n}function Ha(e){return e.attrs?Object.entries(e.attrs).sort((n,o)=>n[0].localeCompare(o[0])).map(([n,o])=>`${n}=${String(o)}`).join(";"):""}function vi(e){return e.map(n=>n.type==="text"?`${n.text}\0${(n.marks??[]).map(o=>`${o.type}:${Ha(o)}`).sort().join(",")}`:"").join("")}const zr=["paragraph","heading","heading1","heading2","heading3","heading4","heading5","heading6","bulletList","orderedList","todoList","quote","codeBlock"],$o=["todoList"],Po=["orderedList"],Fr=["left","center","right"],Kr=["top","middle","bottom"],Wr=["gray","brown","orange","yellow","green","blue","purple","pink","red"],Gr=["bold","italic","underline","strikethrough","color","bgColor","link"],Va=["bold","italic","underline","strikethrough","code","link","color","bgColor"];function no(){return{content:[],rowspan:1,colspan:1,covered:!1}}function go(e,n){const o=n==="codeBlock",r=n==="quote",l=[];for(const i of e){if(i.type!=="text"){l.push({...i});continue}if(o){l.push({type:"text",text:i.text});continue}let c=i.marks?i.marks.filter(s=>Va.includes(s.type)):void 0;c&&c.some(s=>s.type==="code")&&(c=c.filter(s=>s.type==="code"||!Gr.includes(s.type))),r&&c&&(c=c.filter(s=>s.type!=="italic")),c&&(c=c.filter(s=>{var d;if(s.type!=="link")return!0;const a=(d=s.attrs)==null?void 0:d.href;return typeof a!="string"?!1:$n(a)!==null})),c&&c.length===0&&(c=void 0),l.push(c?{...i,marks:c}:{type:"text",text:i.text})}return l}function Tn(e){return{content:e.content.map(n=>({...n})),rowspan:e.rowspan,colspan:e.colspan,covered:e.covered,cellType:e.cellType,align:e.align,verticalAlign:e.verticalAlign,bgColor:e.bgColor,checked:e.checked,startNumber:e.startNumber}}function Pn(e,n,o,r,l){var u,f,p;let i=Math.max(0,Math.min(n,r)),c=Math.min(e.rows-1,Math.max(n,r)),s=Math.max(0,Math.min(o,l)),a=Math.min(e.cols-1,Math.max(o,l)),d=!0;for(;d;){d=!1;for(let m=i;m<=c;m++)for(let h=s;h<=a;h++){const y=(u=e.cells[m])==null?void 0:u[h];if(!y)continue;let N=m,L=h;if(y.covered){let F=!1;for(let Y=m;Y>=0&&!F;Y--)for(let ae=h;ae>=0&&!F;ae--){const ne=(f=e.cells[Y])==null?void 0:f[ae];!ne||ne.covered||Y+Math.max(1,ne.rowspan)>m&&ae+Math.max(1,ne.colspan)>h&&(N=Y,L=ae,F=!0)}if(!F)continue}const S=(p=e.cells[N])==null?void 0:p[L];if(!S||S.covered)continue;const G=N+Math.max(1,S.rowspan)-1,K=L+Math.max(1,S.colspan)-1;i>N&&(i=N,d=!0),c<G&&(c=G,d=!0),s>L&&(s=L,d=!0),a<K&&(a=K,d=!0)}}return{r1:i,c1:s,r2:c,c2:a}}function Ci(e,n,o,r,l){var d;const i=Math.max(0,Math.min(n,r)),c=Math.min(e.rows-1,Math.max(n,r)),s=Math.max(0,Math.min(o,l)),a=Math.min(e.cols-1,Math.max(o,l));for(let u=i;u<=c;u++)for(let f=s;f<=a;f++){const p=(d=e.cells[u])==null?void 0:d[f];if(!(!p||p.covered)&&(p.rowspan>1||p.colspan>1))return!0}return!1}function Ua(e,n,o,r,l){var u;const i=Math.max(0,Math.min(n,r)),c=Math.min(e.rows-1,Math.max(n,r)),s=Math.max(0,Math.min(o,l)),a=Math.min(e.cols-1,Math.max(o,l));let d=0;for(let f=i;f<=c;f++)for(let p=s;p<=a;p++){const m=(u=e.cells[f])==null?void 0:u[p];m&&!m.covered&&(d+=1)}return d}function bo(e){return{content:e.content,rowspan:e.rowspan,colspan:e.colspan,covered:e.covered,cellType:e.cellType,align:e.align,verticalAlign:e.verticalAlign,bgColor:e.bgColor,checked:e.checked,startNumber:e.startNumber}}function za(e,n){const o=[];for(let r=0;r<e;r++){const l=[];for(let i=0;i<n;i++)l.push(no());o.push(l)}return o}function Ho(e){const n=e.rows,o=e.cols,r=typeof n=="number"&&Number.isInteger(n)&&n>=1?n:1,l=typeof o=="number"&&Number.isInteger(o)&&o>=1?o:1;let i=[];const c=e.colWidths;if(Array.isArray(c))for(const u of c)i.push(typeof u=="number"&&Number.isFinite(u)&&u>=0?u:0);for(;i.length<l;)i.push(0);i.length>l&&(i=i.slice(0,l));const s=typeof e.headerRow=="boolean"?e.headerRow:!1;let a=[];const d=e.cells;if(Array.isArray(d))for(let u=0;u<r;u++){const f=d[u],p=[];if(Array.isArray(f))for(let m=0;m<l;m++){const h=f[m];p.push(Fa(h))}else for(let m=0;m<l;m++)p.push(no());a.push(p)}for(;a.length<r;){const u=[];for(let f=0;f<l;f++)u.push(no());a.push(u)}return a.length>r&&(a=a.slice(0,r)),a=Hn(a,r,l),{rows:r,cols:l,cells:a,colWidths:i,headerRow:s}}function Fa(e){if(!e||typeof e!="object")return no();const n=e,o=Array.isArray(n.content)?n.content:[],r=typeof n.cellType=="string"?n.cellType:void 0,l=r&&zr.includes(r)?r:void 0,i=go(o,l),c=typeof n.rowspan=="number"&&Number.isInteger(n.rowspan)&&n.rowspan>=1?n.rowspan:1,s=typeof n.colspan=="number"&&Number.isInteger(n.colspan)&&n.colspan>=1?n.colspan:1,a=typeof n.covered=="boolean"?n.covered:!1,d=typeof n.align=="string"?n.align:void 0,u=d&&Fr.includes(d)?d:void 0,f=typeof n.verticalAlign=="string"?n.verticalAlign:void 0,p=f&&Kr.includes(f)?f:void 0,m=typeof n.bgColor=="string"?n.bgColor:void 0,h=m&&Wr.includes(m)?m:void 0,y=typeof n.checked=="boolean"?n.checked:!1,N=l&&$o.includes(l)?y:void 0,L=typeof n.startNumber=="number"&&Number.isInteger(n.startNumber)&&n.startNumber>=1?n.startNumber:void 0,S=l&&Po.includes(l)?L:void 0;return{content:i,rowspan:c,colspan:s,covered:a,cellType:l,align:u,verticalAlign:p,bgColor:h,checked:N,startNumber:S}}function Hn(e,n,o){const r=e.map(l=>l.map(Tn));for(let l=0;l<n;l++)for(let i=0;i<o;i++){const c=r[l][i];if(c.covered)continue;const s=Math.max(1,Math.min(c.rowspan,n-l)),a=Math.max(1,Math.min(c.colspan,o-i));if(c.rowspan=s,c.colspan=a,!(s===1&&a===1))for(let d=l;d<l+s;d++)for(let u=i;u<i+a;u++)d===l&&u===i||(r[d][u]={content:[],rowspan:1,colspan:1,covered:!0})}return r.map(l=>l.map(bo))}function Ti(e,n){var f,p;const{rows:o,cols:r,cells:l,colWidths:i,headerRow:c}=e,s=Math.max(0,Math.min(n,o)),a=l.map(m=>m.map(Tn)),d=[];for(let m=0;m<r;m++){if(s>0){const h=(f=a[s-1])==null?void 0:f[m];if(h&&!h.covered&&s-1+h.rowspan>s){d.push({content:[],rowspan:1,colspan:1,covered:!0});continue}}d.push(no())}if(a.splice(s,0,d),s>0)for(let m=0;m<r;m++){const h=(p=a[s-1])==null?void 0:p[m];h&&!h.covered&&s-1+h.rowspan>s&&(h.rowspan=h.rowspan+1)}const u=Hn(a,o+1,r);return{rows:o+1,cols:r,cells:u,colWidths:[...i],headerRow:c}}function Ka(e,n){var u;const{rows:o,cols:r,colWidths:l,headerRow:i}=e;if(o<=1)return e;const c=Math.max(0,Math.min(n,o-1)),s=e.cells.map(f=>f.map(Tn));for(let f=0;f<r;f++)for(let p=0;p<c;p++){const m=(u=s[p])==null?void 0:u[f];if(!m||m.covered)continue;p+m.rowspan>c&&(m.rowspan=Math.max(1,m.rowspan-1))}s.splice(c,1);let a=i;i&&c===0&&(a=!1);const d=Hn(s,o-1,r);return{rows:o-1,cols:r,cells:d,colWidths:[...l],headerRow:a}}function Wa(e,n){const{rows:o,cols:r,cells:l,colWidths:i,headerRow:c}=e,s=Math.max(0,Math.min(n,r)),a=l.map(m=>m.map(Tn));for(let m=0;m<o;m++){let h=!1;if(s>0){const y=a[m][s-1];y&&!y.covered&&s-1+y.colspan>s&&(y.colspan=y.colspan+1,h=!0)}a[m].splice(s,0,h?{content:[],rowspan:1,colspan:1,covered:!0}:no())}const d=[...i],u=d.filter(m=>m>0),f=u.length>0?Math.round(u.reduce((m,h)=>m+h,0)/u.length):120;d.splice(s,0,f);const p=Hn(a,o,r+1);return{rows:o,cols:r+1,cells:p,colWidths:d,headerRow:c}}function Ga(e,n){const{rows:o,cols:r,cells:l,headerRow:i}=e;if(r<=1)return e;const c=Math.max(0,Math.min(n,r-1)),s=l.map(u=>u.map(Tn));for(let u=0;u<o;u++){for(let f=0;f<c;f++){const p=s[u][f];if(!p||p.covered)continue;f+p.colspan>c&&(p.colspan=Math.max(1,p.colspan-1))}s[u].splice(c,1)}const a=[...e.colWidths];a.splice(c,1);const d=Hn(s,o,r-1);return{rows:o,cols:r-1,cells:d,colWidths:a,headerRow:i}}function Vo(e,n,o,r){var s;if(n<0||n>=e.rows||o<0||o>=e.cols)return e;const l=(s=e.cells[n])==null?void 0:s[o];if(!l||l.covered)return e;const i=go(r,l.cellType),c=e.cells.map((a,d)=>a.map((u,f)=>d===n&&f===o?bo({...Tn(u),content:i}):u));return{...e,cells:c}}function Uo(e,n,o,r){var c;if(n<0||n>=e.rows||o<0||o>=e.cols)return e;const l=(c=e.cells[n])==null?void 0:c[o];if(!l||l.covered)return e;const i=e.cells.map((s,a)=>s.map((d,u)=>{if(a!==n||u!==o)return d;const f=Tn(d);return r.cellType!==void 0&&(f.cellType=r.cellType==="paragraph"?void 0:zr.includes(r.cellType)?r.cellType:void 0,f.content=go(f.content,f.cellType),(!f.cellType||!$o.includes(f.cellType))&&(f.checked=void 0),(!f.cellType||!Po.includes(f.cellType))&&(f.startNumber=void 0)),r.align!==void 0&&(f.align=r.align==="left"?void 0:Fr.includes(r.align)?r.align:void 0),r.verticalAlign!==void 0&&(f.verticalAlign=r.verticalAlign==="middle"?void 0:Kr.includes(r.verticalAlign)?r.verticalAlign:void 0),r.bgColor!==void 0&&(f.bgColor=r.bgColor==="default"?void 0:Wr.includes(r.bgColor)?r.bgColor:void 0),r.checked!==void 0&&(f.checked=f.cellType&&$o.includes(f.cellType)?r.checked:void 0),r.startNumber!==void 0&&(r.startNumber===null?f.startNumber=void 0:f.startNumber=f.cellType&&Po.includes(f.cellType)&&typeof r.startNumber=="number"&&Number.isInteger(r.startNumber)&&r.startNumber>=1?r.startNumber:void 0),bo(f)}));return{...e,cells:i}}function oo(e,n,o){const r=new Set(n.map(i=>`${i.row}-${i.col}`)),l=e.cells.map((i,c)=>i.map((s,a)=>{if(!r.has(`${c}-${a}`)||s.covered)return s;const d=Tn(s);return o.cellType!==void 0&&(d.cellType=o.cellType==="paragraph"?void 0:zr.includes(o.cellType)?o.cellType:void 0,d.content=go(d.content,d.cellType),(!d.cellType||!$o.includes(d.cellType))&&(d.checked=void 0),(!d.cellType||!Po.includes(d.cellType))&&(d.startNumber=void 0)),o.align!==void 0&&(d.align=o.align==="left"?void 0:Fr.includes(o.align)?o.align:void 0),o.verticalAlign!==void 0&&(d.verticalAlign=o.verticalAlign==="middle"?void 0:Kr.includes(o.verticalAlign)?o.verticalAlign:void 0),o.bgColor!==void 0&&(d.bgColor=o.bgColor==="default"?void 0:Wr.includes(o.bgColor)?o.bgColor:void 0),o.checked!==void 0&&(d.checked=d.cellType&&$o.includes(d.cellType)?o.checked:void 0),o.startNumber!==void 0&&(o.startNumber===null?d.startNumber=void 0:d.startNumber=d.cellType&&Po.includes(d.cellType)&&typeof o.startNumber=="number"&&Number.isInteger(o.startNumber)&&o.startNumber>=1?o.startNumber:void 0),bo(d)}));return{...e,cells:l}}function _i(e,n,o,r){const l=new Set(n.map(c=>`${c.row}-${c.col}`)),i=e.cells.map((c,s)=>c.map((a,d)=>{if(!l.has(`${s}-${d}`)||a.covered||a.cellType==="codeBlock"||a.cellType==="quote"&&o==="italic")return a;const u=Tn(a);return u.content=u.content.map(f=>{if(f.type!=="text")return f;const p=f.marks?[...f.marks]:[],m=p.some(y=>y.type==="code");if(o==="code"&&r!==null){const y=p.filter(N=>N.type==="code"||!Gr.includes(N.type));return y.some(N=>N.type==="code")||y.push({type:"code"}),{...f,marks:y.length>0?y:void 0}}if(r!==null&&Gr.includes(o)&&m)return f;const h=p.filter(y=>y.type!==o);return r!==null&&h.push(r?{type:o,attrs:r}:{type:o}),{...f,marks:h.length>0?h:void 0}}),bo(u)}));return{...e,cells:i}}function qa(e,n,o){var i,c;new Set(n.map(s=>`${s.row}-${s.col}`));const r=n.filter(s=>{var d;const a=(d=e.cells[s.row])==null?void 0:d[s.col];return!(!a||a.covered||a.cellType==="codeBlock"||a.cellType==="quote"&&o==="italic")});if(r.length===0)return e;let l=!0;for(const s of r){const a=(i=e.cells[s.row])==null?void 0:i[s.col];if(!(!a||a.covered)&&a.content.length!==0){for(const d of a.content){if(d.type!=="text")continue;if(!(((c=d.marks)==null?void 0:c.some(f=>f.type===o))??!1)){l=!1;break}}if(!l)break}}return _i(e,r,o,l?null:{})}function Ya(e,n,o,r,l){var F,Y,ae;const i=Math.max(0,Math.min(n,r)),c=Math.min(e.rows-1,Math.max(n,r)),s=Math.max(0,Math.min(o,l)),a=Math.min(e.cols-1,Math.max(o,l));if(i===c&&s===a)return e;const d=e.cells.map(ne=>ne.map(Tn));for(let ne=i;ne<=c;ne++)for(let te=s;te<=a;te++)d[ne][te]={content:[],rowspan:1,colspan:1,covered:!1};let u=i,f=s;for(;u>=0&&((Y=(F=e.cells[u])==null?void 0:F[f])!=null&&Y.covered);){if(f>0){f-=1;continue}u-=1,f=e.cols-1}const p=u>=0?(ae=e.cells[u])==null?void 0:ae[f]:void 0,m=p?p.content.map(ne=>({...ne})):[],h=p==null?void 0:p.cellType,y=p==null?void 0:p.align,N=p==null?void 0:p.verticalAlign,L=p==null?void 0:p.bgColor,S=p==null?void 0:p.checked,G=p==null?void 0:p.startNumber;d[i][s]={content:go(m,h),rowspan:c-i+1,colspan:a-s+1,covered:!1,cellType:h,align:y,verticalAlign:N,bgColor:L,checked:S,startNumber:G};const K=Hn(d,e.rows,e.cols);return{...e,cells:K}}function xi(e,n,o){var a;if(n<0||n>=e.rows||o<0||o>=e.cols)return e;const r=(a=e.cells[n])==null?void 0:a[o];if(!r||r.covered)return e;const l=n+r.rowspan-1,i=o+r.colspan-1,c=e.cells.map(d=>d.map(Tn));for(let d=n;d<=l;d++)for(let u=o;u<=i;u++)c[d][u]={content:d===n&&u===o?[...r.content]:[],rowspan:1,colspan:1,covered:!1};const s=Hn(c,e.rows,e.cols);return{...e,cells:s}}function Za(e,n,o,r,l){var u;const i=Math.max(0,Math.min(n,r)),c=Math.min(e.rows-1,Math.max(n,r)),s=Math.max(0,Math.min(o,l)),a=Math.min(e.cols-1,Math.max(o,l));let d=e;for(let f=c;f>=i;f--)for(let p=a;p>=s;p--){const m=(u=d.cells[f])==null?void 0:u[p];!m||m.covered||m.rowspan===1&&m.colspan===1||(d=xi(d,f,p))}return d}function Xa(e){return{...e,headerRow:!e.headerRow}}function Mi(e,n,o){if(n<0||n>=e.cols)return e;const r=Math.max(0,Math.round(o)),l=[...e.colWidths];for(;l.length<e.cols;)l.push(0);return l[n]=r,{...e,colWidths:l}}function ir(e){let n="";for(const o of e.content)o.type==="text"&&(n+=o.text);return n}function Ni(e){return e.replace(/\\/g,"\\\\").replace(/\|/g,"\\|").replace(/\r?\n/g,"<br>")}function ja(e){var i,c;const n=[];e.colWidths;const o=[],r=[];for(let s=0;s<e.cols;s++){const a=(i=e.cells[0])==null?void 0:i[s],d=a&&!a.covered?ir(a):"";o.push(Ni(d)),r.push(e.headerRow?"---":"-")}const l=e.headerRow?1:0;e.headerRow?(n.push(`| ${o.join(" | ")} |`),n.push(`| ${r.join(" | ")} |`)):(n.push(`| ${o.join(" | ")} |`),n.push(`| ${r.join(" | ")} |`));for(let s=l;s<e.rows;s++){const a=[];for(let d=0;d<e.cols;d++){const u=(c=e.cells[s])==null?void 0:c[d],f=u&&!u.covered?ir(u):"";a.push(Ni(f))}n.push(`| ${a.join(" | ")} |`)}return n.join(`
|
|
10
|
-
`)}function
|
|
11
|
-
`));for(const p of Array.from(a.childNodes))r.push(p);l=0}continue}if(d==="img"){const u=nd(a);u&&(i(),o.push({type:"image",attrs:{src:u.src,alt:u.alt,title:u.title},content:[]}),l=0);continue}if(d==="table"){const u=Ja(a);u&&(i(),o.push({type:"table",attrs:u,content:[]}),l=0);continue}if((c=a.querySelector)!=null&&c.call(a,"img")){i(),zo(a.childNodes,n,o),l=0;continue}r.push(s),l=0}}i()}function cd(e,n,o){const r=[[]];for(const l of e.childNodes)l.nodeType===Node.ELEMENT_NODE&&l.tagName.toLowerCase()==="br"?r.push([]):r[r.length-1].push(l);for(const l of r){const i=n.createElement("div");for(const s of l)i.appendChild(s.cloneNode(!0));const c=an(i);o.push({type:"paragraph",attrs:{},content:c})}}const lo=new Map,cr=new Set;function Li(e,n){for(const o of cr)o(e,n)}function Xn(e){return lo.get(e)??null}function _n(e,n){if(n===null){if(lo.has(e)){const o=lo.get(e);if(o!=null&&o.tempPreviewUrl&&URL.revokeObjectURL(o.tempPreviewUrl),o!=null&&o.controller)try{o.controller.abort()}catch{}lo.delete(e),Li(e,null)}}else lo.set(e,n),Li(e,n)}function Oi(e){return cr.add(e),()=>{cr.delete(e)}}const ad=Oi;function dd(){for(const[,e]of lo)if(e!=null&&e.tempPreviewUrl&&URL.revokeObjectURL(e.tempPreviewUrl),e!=null&&e.controller)try{e.controller.abort()}catch{}lo.clear();for(const e of cr)e("",null)}const ud=dd,ar=new Set;function fd(){for(const e of ar)try{URL.revokeObjectURL(e)}catch{}ar.clear()}function Xr(e){const n=URL.createObjectURL(e);return ar.add(n),n}function md(e){for(const n of e)_n(n,null)}function pd(e){md(e)}let jr=null;function hd(e){jr=e}const gd=hd;function Di(e,n,o,r){if(!jr){r.onError("Upload handler not registered");return}jr(e,n,o,r)}function bd(e,n){return new Promise((o,r)=>{const l=Date.now(),i=500+Math.min(2500,Math.round(e.size/2e3));let c=!1;const s=()=>{if(c)return;const a=Date.now()-l,d=Math.min(1,a/i),u=1-Math.pow(1-d,2);if(n==null||n(u),d<1)requestAnimationFrame(s);else{const f=Xr(e);if(typeof document>"u"){o({url:f});return}const p=document.createElement("img");let m=!1;const h=(y,N)=>{m||(m=!0,o({url:f,width:y,height:N}))};p.onload=()=>h(p.naturalWidth||void 0,p.naturalHeight||void 0),p.onerror=()=>h(),p.src=f,setTimeout(()=>h(),5e3)}};requestAnimationFrame(s),e.type.startsWith("image/")||(c=!0,setTimeout(()=>r(new Error("Not an image file")),30))})}function kd(e,n){return new Promise(o=>{const r=Xr(n),l=new AbortController;_n(e,{status:"pending",progress:0,file:n,tempPreviewUrl:r,controller:l});let i,c;if(typeof document<"u"){const s=document.createElement("img");let a=!1;const d=()=>{a||(a=!0,i=s.naturalWidth||void 0,c=s.naturalHeight||void 0)};s.onload=d,s.onerror=d,s.src=r,setTimeout(d,4e3)}try{Di(n.name,n,l,{onProgress:s=>{const a=Xn(e);if(!a)return;const d=Math.max(0,Math.min(1,Number.isFinite(s)?s:0));_n(e,{...a,progress:d})},onSuccess:s=>{const a=Xn(e);if(a!=null&&a.tempPreviewUrl&&a.tempPreviewUrl!==s.url){try{URL.revokeObjectURL(a.tempPreviewUrl)}catch{}ar.delete(a.tempPreviewUrl)}_n(e,null),o({ok:!0,value:{url:s.url,width:s.width??i,height:s.height??c,alt:s.alt,title:s.title,fileId:s.fileId}})},onError:s=>{const a=Xn(e);_n(e,{status:"error",progress:0,error:s,file:(a==null?void 0:a.file)??n,tempPreviewUrl:a==null?void 0:a.tempPreviewUrl}),o({ok:!1,error:s})}})}catch(s){const a=s instanceof Error?s.message:String(s);_n(e,{status:"error",progress:0,error:a,file:n,tempPreviewUrl:r}),o({ok:!1,error:a})}})}async function Qr(e,n){if(!e)return null;try{if(e.startsWith("data:"))return yd(e,n);const o=await fetch(e);if(!o.ok)return null;const r=await o.blob(),l=$i(r.type,e),i=n?Pi(n,l):`image-${Date.now()}${l}`;return new File([r],i,{type:r.type||"image/png"})}catch{return null}}function yd(e,n){const o=e.match(/^data:([^;,]+)?(;base64)?,(.*)$/);if(!o)return null;const[,r,l,i]=o,c=r||"image/png",s=!!l;let a;if(s){const p=atob(i);a=new Uint8Array(p.length);for(let m=0;m<p.length;m++)a[m]=p.charCodeAt(m)}else{const p=decodeURIComponent(i);a=new TextEncoder().encode(p)}const d=$i(c,e),u=n?Pi(n,d):`image-${Date.now()}${d}`,f=new Blob([a],{type:c});return new File([f],u,{type:c})}function $i(e,n){if(e.includes("png"))return".png";if(e.includes("jpeg")||e.includes("jpg"))return".jpg";if(e.includes("gif"))return".gif";if(e.includes("webp"))return".webp";if(e.includes("svg"))return".svg";if(e.includes("bmp"))return".bmp";const o=n.match(/\.(png|jpe?g|gif|webp|svg|bmp)$/i);return o?`.${o[1].toLowerCase()}`:".png"}function Pi(e,n){return e.toLowerCase().endsWith(n.toLowerCase())?e:e+n}const wd=["data-block-id","data-empty","data-placeholder","contenteditable"],Vn=t.defineComponent({__name:"BlockContent",props:{block:{},placeholder:{}},emits:["slashTrigger","inputChanged","linkClick","focusIn"],setup(e,{emit:n}){const o=e,r=n,l=cn(),i=Yn(),c=t.ref(null),s=t.shallowRef(!1);function a(){return Ae(o.block.content).length===0}const d=t.ref(a());t.onMounted(()=>{const B=c.value;if(!B)return;const $=Ae(o.block.content);Ei(o.block.content)?B.innerHTML=Zn(o.block.content):B.textContent=$,d.value=$.length===0});function u(B){const $=window.getSelection();if(!$||$.rangeCount===0)return null;const M=$.getRangeAt(0);if(!B.contains(M.commonAncestorContainer))return null;const A=document.createRange();A.selectNodeContents(B),A.setEnd(M.startContainer,M.startOffset);const w=A.toString().length;A.setEnd(M.endContainer,M.endOffset);const C=A.toString().length;return{from:Math.min(w,C),to:Math.max(w,C)}}function f(B,$){const M=document.createTreeWalker(B,NodeFilter.SHOW_TEXT);let A=Math.max(0,$),w=null;for(;M.nextNode();){const C=M.currentNode;w=C;const x=(C.nodeValue??"").length;if(A<=x)return{node:C,offset:A};A-=x}return w?{node:w,offset:(w.nodeValue??"").length}:{node:B,offset:0}}function p(B,$,M){const A=window.getSelection();if(!A)return;const w=f(B,$),C=f(B,Math.max($,M));try{const x=document.createRange();$<=M?(x.setStart(w.node,w.offset),x.setEnd(C.node,C.offset)):(x.setStart(C.node,C.offset),x.setEnd(w.node,w.offset)),A.removeAllRanges(),A.addRange(x)}catch{try{const x=document.createRange();x.setStart(C.node,C.offset),x.collapse(!0),A.removeAllRanges(),A.addRange(x)}catch{}}}t.watch(()=>o.block,B=>{if(s.value)return;const $=c.value;if(!$)return;const M=u($),A=M&&M.from!==M.to,w=document.activeElement===$,C=Ae(B.content),x=C.length===0;let z=!1;if(x)$.childNodes.length>0&&($.textContent="",z=!0);else{const U=Ei(B.content),fe=!!$.querySelector(Ba);if(!U&&!fe)$.textContent!==C&&($.textContent=C,z=!0);else{const oe=vi(an($)),ue=vi(B.content);oe!==ue&&($.innerHTML=Zn(B.content),z=!0)}}d.value=x,z&&M&&(w||A)&&p($,M.from,M.to)});function m(B){B.key==="Enter"&&!B.shiftKey&&!B.isComposing&&B.preventDefault()}function h(B){var z,U;if(!i.value)return;const $=c.value;if(!$)return;const M=an($),A=Ae(M);if(d.value=A.length===0,r("inputChanged",o.block.id,A),s.value||Ma({editor:l,registry:l.registries.inputRules,blockId:o.block.id,text:A}))return;if(Na(A)){const fe=A.match(/\/([^/]*)$/),oe=A.lastIndexOf("/"),ue=fe&&fe[1]!==void 0?fe[1]:oe>=0?A.slice(oe+1):"";r("slashTrigger",$,o.block.id,ue)}let C=M;l.registries.schema.get(o.block.type).inlineMarks&&B.data&&/\s/.test(B.data)&&(C=lr(M)),(U=(z=l.commands).setText)==null||U.call(z,{id:o.block.id,content:C})}function y(B){s.value=!0}function N(B){var x,z;if(s.value=!1,!i.value)return;const $=c.value;if(!$)return;const M=an($),A=Ae(M);d.value=A.length===0,r("inputChanged",o.block.id,A);const C=l.registries.schema.get(o.block.type).inlineMarks?lr(M):M;(z=(x=l.commands).setText)==null||z.call(x,{id:o.block.id,content:C})}function L(){const B=c.value;if(!B)return null;const $=window.getSelection();if(!$||$.rangeCount===0)return null;const M=$.getRangeAt(0);if(!B.contains(M.commonAncestorContainer))return null;const A=Ae(o.block.content),w=document.createRange();w.selectNodeContents(B),w.setEnd(M.startContainer,M.startOffset);const C=Math.min(w.toString().length,A.length);w.setEnd(M.endContainer,M.endOffset);const x=Math.min(w.toString().length,A.length);return[Math.min(C,x),Math.max(C,x)]}function S(B){var U,fe;const $=L();if(!$)return;const[M,A]=$;if(M===A)return;const[,w]=Ut(o.block.content,M),[C]=Ut(w,A-M),x=Ae(C),z=Zn(C);B.preventDefault(),(U=B.clipboardData)==null||U.setData("text/plain",x),(fe=B.clipboardData)==null||fe.setData("text/html",z)}function G(B){var oe,ue,xe,pe;if(!i.value){B.preventDefault();return}const $=L();if(!$)return;const[M,A]=$;if(M===A)return;const[w,C]=Ut(o.block.content,M),[x,z]=Ut(C,A-M),U=Ae(x),fe=Zn(x);B.preventDefault(),(oe=B.clipboardData)==null||oe.setData("text/plain",U),(ue=B.clipboardData)==null||ue.setData("text/html",fe),(pe=(xe=l.commands).setText)==null||pe.call(xe,{id:o.block.id,content:[...w,...z],selectionAfter:et(o.block.id,M)})}const K=Ea();function F(B){const $=[],M=new Set;if(B.items&&B.items.length>0)for(let A=0;A<B.items.length;A++){const w=B.items[A];if(w.kind!=="file")continue;const C=w.getAsFile();if(!C||!C.type.startsWith("image/"))continue;const x=`${C.name||""}:${C.size}:${C.type}`;M.has(x)||(M.add(x),$.push(C))}if(B.files&&B.files.length>0)for(let A=0;A<B.files.length;A++){const w=B.files[A];if(!w.type.startsWith("image/"))continue;const C=`${w.name||""}:${w.size}:${w.type}`;M.has(C)||(M.add(C),$.push(w))}return $}async function Y(B){var ct,St,At,Et,qt,bt,vt,nt,Pe,mt,de,at,Ke,_e,Rt,ot,It,P,k,W,ye,Te,$e,Ct,Qt,Lt,Ye,$t,pn,hn,Qn,gn;if(!i.value){B.preventDefault();return}const $=B.clipboardData;if(!$)return;if(K){const Me=F($);if(Me.length>0){B.preventDefault();let Se=o.block.id;for(let ze=0;ze<Me.length;ze++){const Oe=Me[ze],Fe=await K(Oe,{relativeToBlockId:Se,convertIfEmpty:ze===0,position:"after"});Fe&&(Se=Fe)}return}}const M=$.getData("text/html"),A=$.getData("text/plain"),w=od(M||null,A||null);if(w.length===0)return;const C=w.some(Me=>Me.type==="image"),x=L(),z=Ae(o.block.content).length,U=x?x[0]:z,fe=x?x[1]:z,[oe]=Ut(o.block.content,U),[,ue]=Ut(o.block.content,fe),xe=l.registries.schema.get(o.block.type),pe=Me=>xe.inlineMarks?Me:Me.map(Se=>({type:"text",text:Se.text}));if(!C){if(w.length===1){const ze=pe(w[0].content);if(xe.inlineMarks&&U<fe&&ze.length===1&&ze[0].type==="text"&&!ze[0].marks){const zt=ze[0].text;if(Ur(zt)){const ln=to(zt),Ft=$n(ln);if(Ft){(St=(ct=l.commands).setLink)==null||St.call(ct,{id:o.block.id,href:Ft,from:U,to:fe});return}}}const Oe=[...oe,...ze,...ue],Fe=xe.inlineMarks?lr(Oe):Oe,kt=Ae(oe).length,dt=Ae(ze).length,Ot=kt+dt;(Et=(At=l.commands).setText)==null||Et.call(At,{id:o.block.id,content:Fe,selectionAfter:et(o.block.id,Ot)});return}const Me=[...oe,...pe(w[0].content)];(bt=(qt=l.commands).setText)==null||bt.call(qt,{id:o.block.id,content:Me});let Se=o.block.id;for(let ze=1;ze<w.length;ze++){const Oe=w[ze],Fe=ze===w.length-1,kt=pe(Oe.content),dt=Fe?[...kt,...ue]:kt,Ot=l.registries.schema.coerceAttrsFor(Oe.type,Oe.attrs);(nt=(vt=l.commands).insertBlock)==null||nt.call(vt,{after:Se,type:Oe.type,attrs:Ot,content:dt});const zt=l.getState();if(zt.selection.kind==="caret"&&(Se=zt.selection.blockId),Fe){const ln=Ae(kt).length,Ft=ue.length>0?ln:Ae(dt).length;(mt=(Pe=l.commands).setSelection)==null||mt.call(Pe,{selection:et(Se,Ft)})}}return}if(!K){const Me=w.filter(Se=>Se.type!=="image");if(Me.length===0)return;if(w.splice(0,w.length,...Me),w.length===1){const Se=pe(w[0].content),ze=[...oe,...Se,...ue];(at=(de=l.commands).setText)==null||at.call(de,{id:o.block.id,content:ze,selectionAfter:et(o.block.id,Ae(oe).length+Ae(Se).length)})}return}let qe=-1;for(let Me=w.length-1;Me>=0;Me--)if(w[Me].type!=="image"){qe=Me;break}let Ce=o.block.id;const je=w[0];if(je.type!=="image"){const Se=qe===0?[...oe,...pe(je.content),...ue]:[...oe,...pe(je.content)];(_e=(Ke=l.commands).setText)==null||_e.call(Ke,{id:o.block.id,content:Se}),Ce=o.block.id}else{const Me=oe.length===0&&ue.length===0,Se=je.attrs.src,ze=je.attrs.alt??"";if(Me){const Oe=await Qr(Se,ze||void 0);if(Oe){const Fe=await K(Oe,{relativeToBlockId:Ce,position:"after",convertIfEmpty:!0});Fe&&(Ce=Fe)}else{const Fe=l.registries.schema.coerceAttrsFor(je.type,je.attrs);(ot=(Rt=l.commands).replaceBlock)==null||ot.call(Rt,{id:o.block.id,type:je.type,attrs:Fe}),Ce=o.block.id}}else{(P=(It=l.commands).setText)==null||P.call(It,{id:o.block.id,content:oe});const Oe=await Qr(Se,ze||void 0);if(Oe){const Fe=await K(Oe,{relativeToBlockId:Ce,position:"after",convertIfEmpty:!1});Fe&&(Ce=Fe)}else{const Fe=l.registries.schema.coerceAttrsFor(je.type,je.attrs);(W=(k=l.commands).insertBlock)==null||W.call(k,{after:Ce,type:je.type,attrs:Fe,content:[]});const kt=l.getState();kt.selection.kind==="caret"&&(Ce=kt.selection.blockId)}}}for(let Me=1;Me<w.length;Me++){const Se=w[Me],ze=Me===qe;if(Se.type==="image"){const Oe=Se.attrs.src,Fe=Se.attrs.alt??"",kt=await Qr(Oe,Fe||void 0);if(kt){const dt=await K(kt,{relativeToBlockId:Ce,position:"after",convertIfEmpty:!1});dt&&(Ce=dt)}else{const dt=l.registries.schema.coerceAttrsFor(Se.type,Se.attrs);(Te=(ye=l.commands).insertBlock)==null||Te.call(ye,{after:Ce,type:Se.type,attrs:dt,content:[]});const Ot=l.getState();Ot.selection.kind==="caret"&&(Ce=Ot.selection.blockId)}}else{const Oe=pe(Se.content),Fe=ze?[...Oe,...ue]:Oe,kt=l.registries.schema.coerceAttrsFor(Se.type,Se.attrs);(Ct=($e=l.commands).insertBlock)==null||Ct.call($e,{after:Ce,type:Se.type,attrs:kt,content:Fe});const dt=l.getState();if(dt.selection.kind==="caret"&&(Ce=dt.selection.blockId),ze){const Ot=Ae(Oe).length,zt=ue.length>0?Ot:Ae(Fe).length;(Lt=(Qt=l.commands).setSelection)==null||Lt.call(Qt,{selection:et(Ce,zt)})}}}if(qe===-1&&ue.length>0){($t=(Ye=l.commands).insertBlock)==null||$t.call(Ye,{after:Ce,type:"paragraph",attrs:{},content:ue});const Me=l.getState();Me.selection.kind==="caret"&&(Ce=Me.selection.blockId,(hn=(pn=l.commands).setSelection)==null||hn.call(pn,{selection:et(Ce,Ae(ue).length)}))}else qe===-1&&(oe.length>0||ue.length>0)&&((gn=(Qn=l.commands).insertBlock)==null||gn.call(Qn,{after:Ce,type:"paragraph",attrs:{},content:[]}))}function ae(){r("focusIn",o.block.id)}function ne(){}function te(B){return document.createTreeWalker(B,NodeFilter.SHOW_TEXT).nextNode()}function X(B){var x;const $=B.target;if(!$)return;const M=$.closest("a");if(!M||!((x=c.value)!=null&&x.contains(M)))return;B.preventDefault();const A=window.getSelection();let w=0;if(A&&A.rangeCount>0&&!!M.contains(A.getRangeAt(0).commonAncestorContainer)){const z=A.getRangeAt(0),U=document.createRange();U.selectNodeContents(c.value),U.setEnd(z.startContainer,z.startOffset),w=U.toString().length}else{const z=te(M);if(z){const U=document.createRange();U.selectNodeContents(c.value),U.setEnd(z,0),w=U.toString().length}}r("linkClick",o.block.id,w)}return(B,$)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"el",ref:c,class:"block-content","data-block-id":e.block.id,"data-empty":d.value,"data-placeholder":e.placeholder,contenteditable:t.unref(i),spellcheck:"false",onInput:h,onCompositionstart:y,onCompositionend:N,onFocus:ae,onBlur:ne,onKeydown:m,onClick:X,onPaste:t.withModifiers(Y,["prevent"]),onCopy:S,onCut:G},null,40,wd))}});function Hi(e){return e==="zh-CN"||e===null||e===void 0||e===""?"zh-CN":"en-US"}function Vi(e){return e==="dark"?"dark":"light"}const Ed={"zh-CN":{"editor.placeholder":"输入文字,或按 '/' 获取命令…","handle.plus.title":"点击添加块","handle.plus.ariaLabel":"Insert block below","handle.grip.title":"拖拽移动 / 点击设置","handle.grip.ariaLabel":"Drag to move block, click to open settings","ui.scrollUp":"向上滚动","ui.scrollDown":"向下滚动","ui.scrollLeft":"向左","ui.scrollRight":"向右","plus.category.basic":"基本区块","plus.category.list":"列表","plus.category.other":"其他","plus.noMatch":"未找到匹配的命令","plus.searchPlaceholder":"搜索命令…","slash.paragraph.title":"正文","slash.paragraph.description":"普通文本段落。","slash.heading1.title":"一级标题","slash.heading1.description":"用于文章的主标题。","slash.heading2.title":"二级标题","slash.heading2.description":"用于主要章节的标题。","slash.heading3.title":"三级标题","slash.heading3.description":"用于子章节的标题。","slash.heading4.title":"四级标题","slash.heading4.description":"用于更细分层的标题。","slash.heading5.title":"五级标题","slash.heading5.description":"用于较小层级的标题。","slash.heading6.title":"六级标题","slash.heading6.description":"用于最小层级的标题。","slash.bulletList.title":"项目符号列表","slash.bulletList.description":"创建一个无序列表。","slash.orderedList.title":"编号列表","slash.orderedList.description":"创建一个带编号的有序列表。","slash.todoList.title":"待办列表","slash.todoList.description":"用复选框追踪待办任务。","slash.quote.title":"引用","slash.quote.description":"引用一段话。","slash.codeBlock.title":"代码块","slash.codeBlock.description":"插入一段代码块。","codeBlock.title":"代码块","slash.divider.title":"分隔符","slash.divider.description":"插入一条水平分隔线。","slash.image.title":"图片","slash.image.description":"插入一张图片(从本地上传或选择文件)。","slash.table3x3.title":"表格(3×3)","slash.table3x3.description":"插入一个 3 行 3 列的表格。","slash.table2x2.title":"表格(2×2)","slash.table2x2.description":"插入一个 2 行 2 列的表格。","slash.table4x4.title":"表格(4×4)","slash.table4x4.description":"插入一个 4 行 4 列的表格。","bsm.section.turnInto":"转换为","bsm.section.alignIndent":"对齐与缩进","bsm.section.align":"对齐","bsm.section.indent":"缩进","bsm.section.action":"操作","bsm.section.textColor":"文字颜色","bsm.section.bgColor":"背景颜色","bsm.indent.decrease":"减少缩进","bsm.indent.increase":"增加缩进","turnInto.paragraph":"正文","turnInto.h1":"一级标题","turnInto.h2":"二级标题","turnInto.h3":"三级标题","turnInto.h4":"四级标题","turnInto.h5":"五级标题","turnInto.h6":"六级标题","turnInto.bullet":"项目符号","turnInto.ordered":"编号列表","turnInto.todo":"待办","turnInto.quote":"引用","turnInto.code":"代码块","align.left":"左对齐","align.center":"居中","align.right":"右对齐","align.justify":"两端对齐","verticalAlign.top":"顶端对齐","verticalAlign.middle":"垂直居中","verticalAlign.bottom":"底端对齐","hoverToolbar.verticalAlignBtnTitle":"垂直对齐","action.duplicate":"复制","action.copy":"拷贝","action.cut":"剪切","action.moveUp":"上移","action.moveDown":"下移","action.delete":"删除","ol.continue":"继续之前的编号","ol.startNew":"开始新列表(从1开始)","ol.modify":"修改编号值…","numberPicker.title":"修改编号值","numberPicker.inputLabel":"编号值","numberPicker.confirm":"确定","codeLang.title":"设置代码类型","codeLang.inputLabel":"代码类型","codeLang.placeholder":"请输入代码类型","codeLang.confirm":"确定","codeLang.custom":"自定义…","codeLang.cancel":"取消","codeLang.plain":"纯文本","hoverToolbar.label":"格式化","hoverToolbar.typeBtnTitle":"切换块类型","hoverToolbar.alignBtnTitle":"对齐方式","hoverToolbar.colorBtnTitle":"颜色","hoverToolbar.textColor":"文字颜色","hoverToolbar.bgColor":"背景颜色","hoverToolbar.copySelection":"复制选中文本","hoverToolbar.deleteBlock":"删除块","mark.bold":"加粗","mark.italic":"斜体","mark.underline":"下划线","mark.strikethrough":"删除线","mark.inlineCode":"行内代码","mark.link":"链接","link.popoverLabel":"链接","link.open":"打开链接","link.copy":"复制链接","link.edit":"编辑链接","link.remove":"移除链接","link.save":"保存","link.cancel":"取消","link.urlPlaceholder":"输入链接地址…","link.textPlaceholder":"链接文本…","link.emptyUrl":"(空链接)","link.invalidUrl":"请输入有效的链接地址","hoverToolbar.linkBtnTitle":"链接","color.default":"默认","color.gray":"灰色","color.brown":"棕色","color.orange":"橙色","color.yellow":"黄色","color.green":"绿色","color.blue":"蓝色","color.purple":"紫色","color.pink":"粉色","color.red":"红色","color.none":"无","image.uploading":"正在上传图片…","image.uploadFailed":"上传失败","image.loadFailed":"图片加载失败","image.retry":"重试","image.replace":"替换图片","image.remove":"删除图片","image.resize":"拖拽调整尺寸","image.emptyTitle":"点击上传图片","image.emptySub":"或拖入图片文件到此处","image.captionPlaceholder":"添加图片说明…","turnInto.image":"图片","table.title":"表格","table.cellPlaceholder":"输入内容…","table.resizeCol":"拖拽调整列宽","table.rowActions":"行操作","table.colActions":"列操作","table.selectRow":"选择此行","table.selectCol":"选择此列","table.selectAll":"选择整个表格","table.insertRowAbove":"在上方插入行","table.insertRowBelow":"在下方插入行","table.insertColLeft":"在左侧插入列","table.insertColRight":"在右侧插入列","table.removeRow":"删除此行","table.removeCol":"删除此列","table.deleteRow":"删除行","table.deleteCol":"删除列","table.toggleHeader":"切换表头行","table.mergeCells":"合并单元格","table.splitCell":"拆分单元格","table.deleteTable":"删除表格","turnInto.table":"表格","toc.title":"目录","toc.empty":"暂无标题","slash.tableOfContents.title":"目录","slash.tableOfContents.description":"插入文档目录。"},"en-US":{"editor.placeholder":"Type '/' for commands...","handle.plus.title":"Insert block below","handle.plus.ariaLabel":"Insert block below","handle.grip.title":"Drag to move / click for settings","handle.grip.ariaLabel":"Drag to move block, click to open settings","ui.scrollUp":"Scroll up","ui.scrollDown":"Scroll down","ui.scrollLeft":"Scroll left","ui.scrollRight":"Scroll right","plus.category.basic":"Basic blocks","plus.category.list":"Lists","plus.category.other":"Other","plus.noMatch":"No matching commands","plus.searchPlaceholder":"Search commands...","slash.paragraph.title":"Paragraph","slash.paragraph.description":"Plain text paragraph.","slash.heading1.title":"Heading 1","slash.heading1.description":"Main title for the document.","slash.heading2.title":"Heading 2","slash.heading2.description":"Title for major sections.","slash.heading3.title":"Heading 3","slash.heading3.description":"Title for sub-sections.","slash.heading4.title":"Heading 4","slash.heading4.description":"Title for finer hierarchy levels.","slash.heading5.title":"Heading 5","slash.heading5.description":"Title for smaller hierarchy levels.","slash.heading6.title":"Heading 6","slash.heading6.description":"Title for the smallest hierarchy level.","slash.bulletList.title":"Bullet list","slash.bulletList.description":"Create an unordered list.","slash.orderedList.title":"Numbered list","slash.orderedList.description":"Create a numbered ordered list.","slash.todoList.title":"To-do list","slash.todoList.description":"Track tasks with checkboxes.","slash.quote.title":"Quote","slash.quote.description":"Quote a passage of text.","slash.codeBlock.title":"Code block","slash.codeBlock.description":"Insert a code block.","codeBlock.title":"Code block","slash.divider.title":"Divider","slash.divider.description":"Insert a horizontal divider line.","slash.image.title":"Image","slash.image.description":"Insert an image (upload or choose a file).","slash.table3x3.title":"Table (3×3)","slash.table3x3.description":"Insert a 3-row 3-column table.","slash.table2x2.title":"Table (2×2)","slash.table2x2.description":"Insert a 2-row 2-column table.","slash.table4x4.title":"Table (4×4)","slash.table4x4.description":"Insert a 4-row 4-column table.","bsm.section.turnInto":"Turn into","bsm.section.alignIndent":"Align & Indent","bsm.section.align":"Align","bsm.section.indent":"Indent","bsm.section.action":"Actions","bsm.section.textColor":"Text color","bsm.section.bgColor":"Background color","bsm.indent.decrease":"Decrease indent","bsm.indent.increase":"Increase indent","turnInto.paragraph":"Paragraph","turnInto.h1":"Heading 1","turnInto.h2":"Heading 2","turnInto.h3":"Heading 3","turnInto.h4":"Heading 4","turnInto.h5":"Heading 5","turnInto.h6":"Heading 6","turnInto.bullet":"Bullet list","turnInto.ordered":"Numbered list","turnInto.todo":"To-do","turnInto.quote":"Quote","turnInto.code":"Code block","align.left":"Align left","align.center":"Center","align.right":"Align right","align.justify":"Justify","verticalAlign.top":"Align top","verticalAlign.middle":"Vertical center","verticalAlign.bottom":"Align bottom","hoverToolbar.verticalAlignBtnTitle":"Vertical align","action.duplicate":"Duplicate","action.copy":"Copy","action.cut":"Cut","action.moveUp":"Move up","action.moveDown":"Move down","action.delete":"Delete","ol.continue":"Continue previous numbering","ol.startNew":"Start a new list (from 1)","ol.modify":"Modify starting number...","numberPicker.title":"Modify number value","numberPicker.inputLabel":"Number value","numberPicker.confirm":"Confirm","codeLang.title":"Set code language","codeLang.inputLabel":"Code language","codeLang.placeholder":"Enter code language","codeLang.confirm":"Confirm","codeLang.custom":"Custom…","codeLang.cancel":"Cancel","codeLang.plain":"Plain text","hoverToolbar.label":"Formatting","hoverToolbar.typeBtnTitle":"Switch block type","hoverToolbar.alignBtnTitle":"Alignment","hoverToolbar.colorBtnTitle":"Color","hoverToolbar.textColor":"Text color","hoverToolbar.bgColor":"Background color","hoverToolbar.copySelection":"Copy selection","hoverToolbar.deleteBlock":"Delete block","mark.bold":"Bold","mark.italic":"Italic","mark.underline":"Underline","mark.strikethrough":"Strikethrough","mark.inlineCode":"Inline code","mark.link":"Link","link.popoverLabel":"Link","link.open":"Open link","link.copy":"Copy link","link.edit":"Edit link","link.remove":"Remove link","link.save":"Save","link.cancel":"Cancel","link.urlPlaceholder":"Enter URL...","link.textPlaceholder":"Link text...","link.emptyUrl":"(empty link)","link.invalidUrl":"Please enter a valid URL","hoverToolbar.linkBtnTitle":"Link","hoverToolbar.linkPrompt":"Enter URL:","color.default":"Default","color.gray":"Gray","color.brown":"Brown","color.orange":"Orange","color.yellow":"Yellow","color.green":"Green","color.blue":"Blue","color.purple":"Purple","color.pink":"Pink","color.red":"Red","color.none":"None","image.uploading":"Uploading image...","image.uploadFailed":"Upload failed","image.loadFailed":"Failed to load image","image.retry":"Retry","image.replace":"Replace image","image.remove":"Remove image","image.resize":"Drag to resize","image.emptyTitle":"Click to upload an image","image.emptySub":"or drag an image file here","image.captionPlaceholder":"Add a caption...","turnInto.image":"Image","table.title":"Table","table.cellPlaceholder":"Type here...","table.resizeCol":"Drag to resize column","table.rowActions":"Row actions","table.colActions":"Column actions","table.selectRow":"Select row","table.selectCol":"Select column","table.selectAll":"Select entire table","table.insertRowAbove":"Insert row above","table.insertRowBelow":"Insert row below","table.insertColLeft":"Insert column left","table.insertColRight":"Insert column right","table.removeRow":"Delete row","table.removeCol":"Delete column","table.deleteRow":"Delete row","table.deleteCol":"Delete column","table.toggleHeader":"Toggle header row","table.mergeCells":"Merge cells","table.splitCell":"Split cell","table.deleteTable":"Delete table","turnInto.table":"Table","toc.title":"Table of Contents","toc.empty":"No headings","slash.tableOfContents.title":"Table of Contents","slash.tableOfContents.description":"Insert a table of contents."}},Ui=Symbol("be-locale"),zi=Symbol("be-theme");function vd(e,n){t.provide(Ui,e),t.provide(zi,n)}function Zt(){const e=t.inject(Ui,t.ref("zh-CN")),n=t.inject(zi,t.ref("light"));return{get locale(){return e.value},get theme(){return n.value},t(o){const l=Ed[e.value][o];return typeof l=="string"?l:o}}}const Cd=["title","aria-label","onKeydown"],Td=["title","aria-label","onKeydown"],_d=4,xd=300,Md=t.defineComponent({__name:"BlockHandle",props:{blockId:{},visible:{type:Boolean}},emits:["openPlusMenu","openSettingsMenu","gripPointerDown","gripPointerUp"],setup(e,{expose:n,emit:o}){const r=e,l=o,{t:i}=Zt(),c=Yn(),s=t.ref(null),a=t.ref(null),d=t.ref(null),u=t.ref(!1),f=t.ref(!1),p=t.ref(null);let m=null;const h=t.computed(()=>p.value===null?void 0:{top:`${p.value}px`});function y(){var A;const B=(A=s.value)==null?void 0:A.parentElement;if(!B)return null;const $=B.querySelector(".block-host-content");if(!$)return null;const M=$.firstElementChild;return M instanceof HTMLElement?M:$}function N(){var w;const B=(w=s.value)==null?void 0:w.parentElement,$=y();if(!B||!$)return;const M=B.getBoundingClientRect(),A=$.getBoundingClientRect();p.value=A.top-M.top+A.height/2}function L(){const B=y();B&&(S(),m=new ResizeObserver(()=>N()),m.observe(B))}function S(){m==null||m.disconnect(),m=null}t.watch(()=>r.visible,B=>{B?t.nextTick().then(()=>{N(),L()}):S()}),t.onMounted(N),t.onBeforeUnmount(S);function G(){c.value&&a.value&&l("openPlusMenu",a.value)}let K=0,F=0,Y=0,ae=!1;function ne(B){c.value&&(Y=Date.now(),K=B.clientX,F=B.clientY,ae=!0,f.value=!1,l("gripPointerDown",r.blockId,K,F,{thresholdPx:_d}))}function te(B){f.value=B}function X(){c.value&&(f.value||ae&&Date.now()-Y>xd||(ae=!1,d.value&&l("openSettingsMenu",d.value)))}return n({isOpen:u,insertBtn:a,gripBtn:d,setLocalDragging:te}),(B,$)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"handleEl",ref:s,class:t.normalizeClass(["block-handle",{visible:e.visible,dragging:f.value}]),style:t.normalizeStyle(h.value)},[t.createElementVNode("div",{ref_key:"insertBtn",ref:a,class:"handle-btn handle-insert",role:"button",tabindex:"0",title:t.unref(i)("handle.plus.title"),"aria-label":t.unref(i)("handle.plus.ariaLabel"),onMousedown:t.withModifiers(G,["prevent","stop"]),onKeydown:[t.withKeys(t.withModifiers(G,["prevent","stop"]),["enter"]),t.withKeys(t.withModifiers(G,["prevent","stop"]),["space"])]},[...$[0]||($[0]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[t.createElementVNode("path",{d:"M8 3.5V12.5M3.5 8H12.5",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])],40,Cd),t.createElementVNode("div",{ref_key:"gripBtn",ref:d,class:"handle-btn handle-grip",role:"button",tabindex:"0",title:t.unref(i)("handle.grip.title"),"aria-label":t.unref(i)("handle.grip.ariaLabel"),onMousedown:t.withModifiers(ne,["prevent","stop"]),onClick:t.withModifiers(X,["stop"]),onKeydown:[t.withKeys(t.withModifiers(X,["prevent","stop"]),["enter"]),t.withKeys(t.withModifiers(X,["prevent","stop"]),["space"])]},[...$[1]||($[1]=[t.createStaticVNode('<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="5" cy="4" r="1.3" fill="currentColor"></circle><circle cx="11" cy="4" r="1.3" fill="currentColor"></circle><circle cx="5" cy="8" r="1.3" fill="currentColor"></circle><circle cx="11" cy="8" r="1.3" fill="currentColor"></circle><circle cx="5" cy="12" r="1.3" fill="currentColor"></circle><circle cx="11" cy="12" r="1.3" fill="currentColor"></circle></svg>',1)])],40,Td)],6))}}),Nd=["data-block-id","data-block-type"],Sd={class:"block-host-content"},Fi=t.defineComponent({__name:"BlockHost",props:{block:{},placeholder:{},hoveredBlockId:{},focusedBlockId:{},hasTextSelection:{type:Boolean},draggingBlockId:{},dropTargetBlockId:{},dropPosition:{},menuOpenBlockId:{}},emits:["openSettingsMenu","openPlusMenu","slashTrigger","inputChanged","hoverChange","gripPointerDown","gripPointerUp","linkClick","focusIn"],setup(e,{expose:n,emit:o}){const r=e,l=o,i=cn(),c=Yn(),s=t.ref(null),a=t.ref(null),d=t.computed(()=>!c.value||r.hasTextSelection?!1:r.hoveredBlockId===r.block.id||r.hoveredBlockId===null&&r.focusedBlockId===r.block.id),u=t.computed(()=>r.draggingBlockId===r.block.id),f=t.computed(()=>r.menuOpenBlockId===r.block.id),p=t.computed(()=>r.dropTargetBlockId===r.block.id),m=t.computed(()=>r.dropPosition??"after");function h(X,B,$,M){l("gripPointerDown",X,B,$,M)}function y(X){l("gripPointerUp",X)}function N(X){var B,$;($=(B=a.value)==null?void 0:B.setLocalDragging)==null||$.call(B,X)}function L(){l("hoverChange",r.block.id)}function S(){l("hoverChange",null)}function G(X){l("openPlusMenu",r.block.id,X)}function K(X){l("openSettingsMenu",r.block.id,X)}function F(X,B,$){l("slashTrigger",X,r.block.id,$)}function Y(X,B){l("inputChanged",X,B)}function ae(X,B){l("linkClick",X,B)}function ne(X){l("focusIn",X)}const te=t.computed(()=>{const X=i.registries.renderers.get(r.block.type);return X!=null&&X.component?X.component:Vn});return n({setHandleDragging:N}),(X,B)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"hostEl",ref:s,class:t.normalizeClass(["block-host",{"block-dragging":u.value,"block-menu-active":f.value,"block-drop-target":p.value,"block-drop-before":p.value&&m.value==="before","block-drop-after":p.value&&m.value==="after","block-drop-into":p.value&&m.value==="into","block-host-readonly":!t.unref(c),"block-focused":e.focusedBlockId===e.block.id}]),"data-block-id":e.block.id,"data-block-type":e.block.type,onMouseenter:L,onMouseleave:S},[t.unref(c)?(t.openBlock(),t.createBlock(Md,{key:0,ref_key:"handleRef",ref:a,"block-id":e.block.id,visible:d.value,onOpenPlusMenu:G,onOpenSettingsMenu:K,onGripPointerDown:h,onGripPointerUp:y},null,8,["block-id","visible"])):t.createCommentVNode("",!0),t.createElementVNode("div",Sd,[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(te.value),{block:e.block,placeholder:e.placeholder,onSlashTrigger:F,onInputChanged:Y,onLinkClick:ae,onFocusIn:ne},null,40,["block","placeholder"]))])],42,Nd))}}),Ki=t.defineComponent({__name:"BlockList",props:{items:{},blocksMap:{},firstBlockPlaceholder:{},isNested:{type:Boolean},hoveredBlockId:{},focusedBlockId:{},hasTextSelection:{type:Boolean},draggingBlockId:{},dropTargetBlockId:{},dropPosition:{},menuOpenBlockId:{}},emits:["openSettingsMenu","openPlusMenu","slashTrigger","inputChanged","hoverChange","gripPointerDown","gripPointerUp","linkClick","focusIn"],setup(e,{expose:n,emit:o}){const r=e,l=o,i=new Map;function c(F,Y){Y?i.set(F,Y):i.delete(F)}function s(F,Y){var ae,ne;(ne=(ae=i.get(F))==null?void 0:ae.setHandleDragging)==null||ne.call(ae,Y)}function a(F){const Y=[];for(const ae of F.children){const ne=r.blocksMap.get(ae);ne&&Y.push({id:ae,block:ne})}return Y}const d=t.computed(()=>!r.isNested&&!r.dropTargetBlockId&&r.dropPosition==="first"&&!!r.draggingBlockId),u=t.computed(()=>!r.isNested&&!r.dropTargetBlockId&&r.dropPosition==="last"&&!!r.draggingBlockId);function f(F,Y){l("openSettingsMenu",F,Y)}function p(F,Y){l("openPlusMenu",F,Y)}function m(F,Y,ae){l("slashTrigger",F,Y,ae)}function h(F,Y){l("inputChanged",F,Y)}function y(F){l("hoverChange",F)}function N(){r.isNested||l("hoverChange",null)}function L(F,Y,ae,ne){l("gripPointerDown",F,Y,ae,ne)}function S(F){l("gripPointerUp",F)}function G(F,Y){l("linkClick",F,Y)}function K(F){l("focusIn",F)}return n({setBlockHandleDragging:s}),(F,Y)=>{const ae=t.resolveComponent("BlockList",!0);return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["block-list",{"block-children":e.isNested,"drop-indicator-first":d.value,"drop-indicator-last":u.value}]),onMouseleave:N},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.items,(ne,te)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:ne.id},[t.createVNode(Fi,{ref_for:!0,ref:X=>c(ne.id,X),block:ne.block,placeholder:!e.isNested&&te===0?e.firstBlockPlaceholder:void 0,"hovered-block-id":e.hoveredBlockId,"focused-block-id":e.focusedBlockId,"has-text-selection":e.hasTextSelection,"dragging-block-id":e.draggingBlockId,"drop-target-block-id":e.dropTargetBlockId,"drop-position":e.dropPosition,"menu-open-block-id":e.menuOpenBlockId,onOpenSettingsMenu:f,onOpenPlusMenu:p,onSlashTrigger:m,onInputChanged:h,onHoverChange:y,onGripPointerDown:L,onGripPointerUp:S,onLinkClick:G,onFocusIn:K},null,8,["block","placeholder","hovered-block-id","focused-block-id","has-text-selection","dragging-block-id","drop-target-block-id","drop-position","menu-open-block-id"]),ne.block.children.length>0?(t.openBlock(),t.createBlock(ae,{key:"__nested_"+ne.id,"is-nested":"",items:a(ne.block),"hovered-block-id":e.hoveredBlockId,"focused-block-id":e.focusedBlockId,"has-text-selection":e.hasTextSelection,"dragging-block-id":e.draggingBlockId,"drop-target-block-id":e.dropTargetBlockId,"drop-position":e.dropPosition,"menu-open-block-id":e.menuOpenBlockId,"blocks-map":e.blocksMap,onOpenSettingsMenu:Y[0]||(Y[0]=(X,B)=>l("openSettingsMenu",X,B)),onOpenPlusMenu:Y[1]||(Y[1]=(X,B)=>l("openPlusMenu",X,B)),onSlashTrigger:Y[2]||(Y[2]=(X,B,$)=>l("slashTrigger",X,B,$)),onInputChanged:Y[3]||(Y[3]=(X,B)=>l("inputChanged",X,B)),onHoverChange:Y[4]||(Y[4]=X=>l("hoverChange",X)),onGripPointerDown:Y[5]||(Y[5]=(X,B,$,M)=>l("gripPointerDown",X,B,$,M)),onGripPointerUp:Y[6]||(Y[6]=X=>l("gripPointerUp",X)),onLinkClick:Y[7]||(Y[7]=(X,B)=>l("linkClick",X,B)),onFocusIn:Y[8]||(Y[8]=X=>l("focusIn",X))},null,8,["items","hovered-block-id","focused-block-id","has-text-selection","dragging-block-id","drop-target-block-id","drop-position","menu-open-block-id","blocks-map"])):t.createCommentVNode("",!0)],64))),128))],34)}}});function Wi(e,n,o,r=6,l="auto",i=0,c=0){const s=n instanceof HTMLElement?n.getBoundingClientRect():n,a=document.documentElement.clientHeight,d=Ad(),u=Math.max(0,a-s.bottom-r-i),f=Math.max(0,s.top-r-c),p=u>=o.height+r,m=f>=o.height+r,h=l==="down"?!1:l==="up"?!0:!p&&(m||f>u);let y,N,L;const S=s.bottom+r,G=s.top-r;h?(y=Math.max(r+c,G-o.height),N=G,L=Math.max(120,f)):(y=S,N=y+o.height,L=Math.max(120,u));const K=d-o.width-r,F=Math.max(r,Math.min(K,s.left));return{top:y,left:F,above:h,availableHeight:L,bottom:N,topBaseline:S}}function Gi(e,n,o,r=8){const l=document.documentElement.clientHeight,i=document.documentElement.clientWidth,c=n.left+(n.width-o.width)/2,s=Math.max(r,Math.min(i-o.width-r,c)),a=l-n.bottom-r,d=n.top-r,u=a>=o.height,f=d>=o.height,p=!u&&(f||d>a),m=n.bottom+r,h=n.top-r,y=p?Math.max(r,h-o.height):m,N=p?h:y+o.height,L=p?Math.max(120,d):Math.max(120,a);return{top:y,left:s,above:p,availableHeight:L,bottom:N,topBaseline:m}}function qi(e,n,o,r=8){const l=document.documentElement.clientHeight,i=document.documentElement.clientWidth,c=n.left+(n.width-o.width)/2,s=Math.max(r,Math.min(i-o.width-r,c)),a=n.top-r,d=l-n.bottom-r,u=a>=o.height,f=d>=o.height,p=u||!f&&a>d||a>=d,m=n.bottom+r,h=n.top-r,y=p?Math.max(r,h-o.height):m,N=p?h:y+o.height,L=p?Math.max(120,a):Math.max(120,d);return{top:y,left:s,above:p,availableHeight:L,bottom:N,topBaseline:m}}function Ad(){return document.documentElement.clientWidth}function dr(e,n){let o=0;function r(d){const u=e.value;if(!u)return;d.preventDefault();const f=d.deltaMode===WheelEvent.DOM_DELTA_LINE?d.deltaY*22:d.deltaY;u.scrollTop+=f,n()}function l(d){d.touches.length===1&&(o=d.touches[0].clientY)}function i(d){if(d.touches.length!==1)return;const u=e.value;if(!u)return;const f=d.touches[0].clientY;u.scrollTop-=f-o,o=f,d.preventDefault(),n()}function c(d){d&&(d.addEventListener("wheel",r,{passive:!1}),d.addEventListener("touchstart",l,{passive:!0}),d.addEventListener("touchmove",i,{passive:!1}))}function s(d){d&&(d.removeEventListener("wheel",r),d.removeEventListener("touchstart",l),d.removeEventListener("touchmove",i))}let a=null;t.watch(e,(d,u,f)=>{s(a),a=d,c(d),f(()=>{s(d),a===d&&(a=null)})},{immediate:!0}),t.onBeforeUnmount(()=>{s(a),a=null})}function Yi(e,n,o,r){function l(f){const p=e.value;if(!p||!f)return!1;if(f instanceof Node&&p.contains(f))return!0;if(r){const m=r(),h=Array.isArray(m)?m:[m];for(const y of h)if(y&&f instanceof Node&&y.contains(f))return!0}return!1}function i(f){n()&&(l(f.target)||o())}function c(f){n()&&(l(f.target)||o())}function s(){n()&&o()}function a(f){f&&f.addEventListener("mouseleave",s)}function d(f){f&&f.removeEventListener("mouseleave",s)}let u=null;t.watch(e,(f,p,m)=>{d(u),u=f,a(f),m(()=>{d(f),u===f&&(u=null)})},{immediate:!0}),t.onMounted(()=>{window.addEventListener("mousedown",i,!0),window.addEventListener("touchstart",i,!0),window.addEventListener("wheel",c,!0)}),t.onBeforeUnmount(()=>{window.removeEventListener("mousedown",i,!0),window.removeEventListener("touchstart",i,!0),window.removeEventListener("wheel",c,!0),d(u),u=null})}const Id=["innerHTML"],dn=t.defineComponent({__name:"SafeHtml",props:{html:{default:""}},setup(e){return(n,o)=>(t.openBlock(),t.createElementBlock("span",{innerHTML:e.html},null,8,Id))}}),Bd=["aria-label"],Rd={key:0,class:"slash-menu-empty"},Ld={key:0,class:"slash-menu-group-label"},Od=["aria-selected","onMousedown","onMouseenter"],Dd={class:"slash-menu-text"},$d={class:"slash-menu-title"},Pd={key:0,class:"slash-menu-desc"},Hd=["aria-label"],Jr=300,Vd=80,Zi=24,Ud=t.defineComponent({__name:"PlusMenu",props:{visible:{type:Boolean},anchorEl:{},blockId:{},query:{},rootEl:{},mode:{default:"slash"}},emits:["close","commit"],setup(e,{expose:n,emit:o}){const r=e,l=o,{t:i}=Zt(),c=t.computed(()=>({basic:i("plus.category.basic"),list:i("plus.category.list"),other:i("plus.category.other")})),s=cn(),a=t.inject(Lo,t.ref(!1)),d=t.ref(null),u=t.ref(null),f=t.ref(0),p=t.ref({top:0,left:0,availableHeight:360,above:!1,bottom:0,topBaseline:0}),m=t.ref(!1),h=t.ref(!1),y=t.ref(!1),N=t.ref(!1);let L=null;t.watch(()=>r.visible,w=>{w?(L&&(clearTimeout(L),L=null),N.value=!0):L=setTimeout(()=>{N.value=!1,L=null},300)},{immediate:!0});function S(w){return typeof w=="string"?w:"•"}const G=t.computed(()=>{const w=r.query.trim().toLowerCase(),C=s.registries.slash.all;return w?C.filter(x=>(i(x.title)+" "+(x.keywords??[]).join(" ")).toLowerCase().includes(w)):C}),K=t.computed(()=>{const w=[],C=new Map;for(const z of G.value){const U=z.category??"other";C.has(U)||C.set(U,[]),C.get(U).push(z)}const x=["basic","list","other"];for(const z of x){const U=C.get(z);U&&U.length>0&&w.push({category:z,label:c.value[z]??z,items:U})}for(const[z,U]of C)x.includes(z)||w.push({category:z,label:c.value[z]??z,items:U});return w});function F(w){return G.value.findIndex(C=>C.id===w)}t.watch([G,()=>r.visible],()=>{f.value=0,t.nextTick(()=>{u.value&&(u.value.scrollTop=0),Y()})});function Y(){const w=u.value;w&&(h.value=w.scrollTop>1,y.value=w.scrollTop+w.clientHeight<w.scrollHeight-1)}function ae(){const w=u.value;w&&(w.scrollTop-=w.clientHeight*.8)}function ne(){const w=u.value;w&&(w.scrollTop+=w.clientHeight*.8)}dr(u,Y),t.watch(()=>r.visible,w=>{w&&(m.value=!1,p.value={top:0,left:0,availableHeight:360,above:!1,bottom:0,topBaseline:0})}),t.watch([()=>r.visible,()=>r.anchorEl,d,G,h,y],async()=>{if(!r.visible||!r.anchorEl||!r.rootEl)return;await t.nextTick();const w=d.value;if(!w)return;const C=w.getBoundingClientRect(),x=!!r.anchorEl.closest(".fixed-toolbar"),z=x?a.value?"up":"down":"auto",U=x?10:0,fe=Wi(r.rootEl,r.anchorEl,{width:Jr,height:C.height},6,z,U,U);p.value=fe,m.value=!0,t.nextTick(Y)},{flush:"post"});const te=t.computed(()=>{if(!r.rootEl)return{display:"none"};if(!m.value)return{visibility:"hidden",top:"0px",left:"0px",width:`${Jr}px`,"--scroll-max-height":"100vh"};const w=p.value.above,C=p.value.left,x=(h.value?Zi:0)+(y.value?Zi:0),z=p.value.availableHeight-x,U={left:`${C}px`,width:`${Jr}px`,maxHeight:`${p.value.availableHeight}px`,"--scroll-max-height":`${Math.max(Vd,z)}px`};if(w){const fe=document.documentElement.clientHeight;U.bottom=`${Math.max(0,fe-p.value.bottom)}px`,U.top="auto"}else U.top=`${p.value.top}px`,U.bottom="auto";return U});function X(w){if(G.value.length===0)return;const C=G.value.length;f.value=((f.value+w)%C+C)%C,B()}function B(){var x;const w=(x=u.value)==null?void 0:x.querySelectorAll(".slash-menu-item"),C=w==null?void 0:w[f.value];C&&C.scrollIntoView({block:"nearest"}),t.nextTick(Y)}function $(w){switch(w.key){case"ArrowDown":return w.preventDefault(),X(1),!0;case"ArrowUp":return w.preventDefault(),X(-1),!0;case"PageDown":return w.preventDefault(),X(5),!0;case"PageUp":return w.preventDefault(),X(-5),!0;case"Home":return w.preventDefault(),f.value=0,B(),!0;case"End":return w.preventDefault(),f.value=Math.max(0,G.value.length-1),B(),!0;case"Enter":return w.preventDefault(),M(),!0;case"Escape":return w.preventDefault(),l("close"),!0;default:return!1}}function M(){const w=G.value[f.value];w&&l("commit",w,r.mode),l("close")}function A(w){const C=G.value.indexOf(w);C>=0&&(f.value=C),M()}return n({onKeyDown:$}),Yi(d,()=>r.visible,()=>l("close"),()=>r.anchorEl),t.onMounted(()=>{window.addEventListener("resize",Y)}),t.onBeforeUnmount(()=>{window.removeEventListener("resize",Y)}),(w,C)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[N.value&&e.rootEl?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"menuEl",ref:d,class:t.normalizeClass(["plus-menu slash-menu",{"menu-closing":!e.visible}]),style:t.normalizeStyle(te.value),role:"listbox"},[h.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(i)("ui.scrollUp"),onMousedown:t.withModifiers(ae,["prevent"])},[...C[0]||(C[0]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Bd)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:u,class:"slash-menu-scroll",onScroll:Y},[G.value.length===0?(t.openBlock(),t.createElementBlock("div",Rd,t.toDisplayString(t.unref(i)("plus.noMatch")),1)):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(K.value,x=>(t.openBlock(),t.createElementBlock("div",{key:x.category,class:"slash-menu-group"},[x.label?(t.openBlock(),t.createElementBlock("div",Ld,t.toDisplayString(x.label),1)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(x.items,z=>(t.openBlock(),t.createElementBlock("div",{key:z.id,class:t.normalizeClass(["slash-menu-item",{active:F(z.id)===f.value}]),"aria-selected":F(z.id)===f.value,role:"option",onMousedown:t.withModifiers(U=>A(z),["prevent"]),onMouseenter:U=>f.value=F(z.id)},[t.createVNode(dn,{class:"slash-menu-icon",html:S(z.icon)},null,8,["html"]),t.createElementVNode("div",Dd,[t.createElementVNode("div",$d,t.toDisplayString(t.unref(i)(z.title)),1),z.description?(t.openBlock(),t.createElementBlock("div",Pd,t.toDisplayString(t.unref(i)(z.description)),1)):t.createCommentVNode("",!0)])],42,Od))),128))]))),128))],544),y.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(i)("ui.scrollDown"),onMousedown:t.withModifiers(ne,["prevent"])},[...C[1]||(C[1]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Hd)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)]))}}),zd=["left","center","right","justify"],Fd=10,Xt={align:{default:"left",validate:e=>zd.includes(e)},color:{default:"default",validate:e=>typeof e=="string"&&e.length>0},bgColor:{default:"default",validate:e=>typeof e=="string"&&e.length>0},indent:{default:0,validate:e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=Fd}},Kd={align:Xt.align,color:Xt.color,bgColor:Xt.bgColor},Wd={indent:Xt.indent};function xn(e){const n=[],o=e.align;typeof o=="string"&&o!=="left"&&n.push(`be-align-${o}`);const r=e.color;typeof r=="string"&&r!=="default"&&n.push(`be-color-${r}`);const l=e.bgColor;typeof l=="string"&&l!=="default"&&n.push(`be-bg-${l}`);const i=e.indent;return typeof i=="number"&&i>0&&n.push(`be-indent-${i}`),n}const Xi=[{key:"default",label:"Default",cssValue:"var(--be-fg)",opacity:1},{key:"gray",label:"Gray",cssValue:"var(--be-color-gray)",opacity:1},{key:"brown",label:"Brown",cssValue:"var(--be-color-brown)",opacity:1},{key:"orange",label:"Orange",cssValue:"var(--be-color-orange)",opacity:1},{key:"yellow",label:"Yellow",cssValue:"var(--be-color-yellow)",opacity:1},{key:"green",label:"Green",cssValue:"var(--be-color-green)",opacity:1},{key:"blue",label:"Blue",cssValue:"var(--be-color-blue)",opacity:1},{key:"purple",label:"Purple",cssValue:"var(--be-color-purple)",opacity:1},{key:"pink",label:"Pink",cssValue:"var(--be-color-pink)",opacity:1},{key:"red",label:"Red",cssValue:"var(--be-color-red)",opacity:1}],ji=[{key:"default",label:"None",cssValue:"transparent",opacity:0},{key:"gray",label:"Gray",cssValue:"var(--be-swatch-bg-gray)",opacity:.15,displayCssValue:"var(--be-swatch-display-bg-gray)"},{key:"brown",label:"Brown",cssValue:"var(--be-swatch-bg-brown)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-brown)"},{key:"orange",label:"Orange",cssValue:"var(--be-swatch-bg-orange)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-orange)"},{key:"yellow",label:"Yellow",cssValue:"var(--be-swatch-bg-yellow)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-yellow)"},{key:"green",label:"Green",cssValue:"var(--be-swatch-bg-green)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-green)"},{key:"blue",label:"Blue",cssValue:"var(--be-swatch-bg-blue)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-blue)"},{key:"purple",label:"Purple",cssValue:"var(--be-swatch-bg-purple)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-purple)"},{key:"pink",label:"Pink",cssValue:"var(--be-swatch-bg-pink)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-pink)"},{key:"red",label:"Red",cssValue:"var(--be-swatch-bg-red)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-red)"}],el='<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="M426.666667 939.050667a32 32 0 1 1 0-64h53.333333V160H235.093333V170.666667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667A32 32 0 0 1 171.093333 170.666667V128a32 32 0 0 1 32-32H820.693333a32 32 0 0 1 31.701334 27.648l0.298666 4.352v42.666667a32 32 0 1 1-64 0l-0.042666-10.666667H544v715.050667H597.333333a32 32 0 0 1 31.701334 27.648l0.298666 4.352a32 32 0 0 1-32 32h-170.666666z" fill="currentColor"/></svg>',ko="M544 170.922667a32 32 0 0 1 32 32v618.666666a32 32 0 1 1-64 0V544H192v277.674667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667a32 32 0 0 1-32-32v-618.666667a32 32 0 0 1 64 0v276.992H512V202.922667a32 32 0 0 1 27.648-31.701334l4.352-0.298666z",tl=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} M848.512 366.933333A32 32 0 0 1 896 394.965333v426.666667a32 32 0 1 1-64 0v-372.565333l-80.554667 44.416a32 32 0 0 1-41.130666-8.96l-2.346667-3.626667a32 32 0 0 1 12.586667-43.477333l128-70.485334z" fill="currentColor"/></svg>`,nl=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} M786.133333 362.666667a152.661333 152.661333 0 0 1 107.946667 260.693333l-166.058667 165.973333h178.773334a32 32 0 0 1 31.744 27.648l0.256 4.352a32 32 0 0 1-32 32h-256a32 32 0 0 1-22.613334-54.613333l220.672-220.672A88.661333 88.661333 0 0 0 786.133333 426.666667h-7.338666a96 96 0 0 0-96 96v20.565333a32 32 0 0 1-64 0v-20.565333a160 160 0 0 1 160-160h7.338666z" fill="currentColor"/></svg>`,ol=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} m362.410667 192a32 32 0 0 1 22.613333 54.656L809.813333 536.746667l1.792 0.341333a160.085333 160.085333 0 0 1 126.506667 148.053333l0.256 8.490667a160 160 0 0 1-310.912 53.248 32 32 0 0 1 60.373333-21.333333 96 96 0 1 0 90.538667-127.914667h-42.666667a32 32 0 0 1-22.613333-54.613333l116.010667-116.053334h-178.773334a32 32 0 0 1-31.701333-27.648l-0.256-4.352a32 32 0 0 1 32-32h256z" fill="currentColor"/></svg>`,rl=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} m244.309333 193.493333a32 32 0 0 1 20.992 40.106667l-93.738666 299.776h116.48v-96a32 32 0 0 1 64 0v96h10.666666a32 32 0 0 1 31.744 27.648l0.298667 4.352a32 32 0 0 1-32 32H896v53.333333a32 32 0 1 1-64 0v-53.333333h-160a32 32 0 0 1-30.506667-41.557334l106.666667-341.333333a32 32 0 0 1 40.106667-20.992z" fill="currentColor"/></svg>`,ll=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} m363.477333 192.426666a32 32 0 1 1 0 64h-145.706666l-28.245334 113.450667 5.12-1.493333a160.042667 160.042667 0 0 1 100.949334 6.4l9.472 4.266666a160 160 0 1 1-189.610667 249.856 32 32 0 0 1 48-42.325333 96 96 0 1 0 0-126.976c-22.186667 25.130667-63.146667 3.584-55.04-28.928l53.333333-214.016a32 32 0 0 1 31.061334-24.234667h170.666666z" fill="currentColor"/></svg>`,il=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} m292.522667 153.173333a32 32 0 0 1 12.586666 43.52l-93.141333 168.874667a159.957333 159.957333 0 0 1 102.4 19.712 158.848 158.848 0 0 1 58.581333 217.685333 160.426667 160.426667 0 0 1-218.453333 58.24 158.890667 158.890667 0 0 1-62.762667-209.962667l157.312-285.44a32 32 0 0 1 43.52-12.586666z m-141.226667 322.517333a94.890667 94.890667 0 0 0 35.072 130.048 96.426667 96.426667 0 0 0 131.242667-34.901333 94.848 94.848 0 0 0-35.114667-130.048 96.426667 96.426667 0 0 0-131.242667 34.901333z" fill="currentColor"/></svg>`,sl='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="3" cy="4" r="1.1" fill="currentColor" stroke="none"/><circle cx="3" cy="8" r="1.1" fill="currentColor" stroke="none"/><circle cx="3" cy="12" r="1.1" fill="currentColor" stroke="none"/><line x1="6.5" y1="4" x2="13.5" y2="4"/><line x1="6.5" y1="8" x2="13.5" y2="8"/><line x1="6.5" y1="12" x2="13.5" y2="12"/></svg>',cl='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.3 3.7L3.1 2.8L3.1 5.8" stroke-width="1.1"/><line x1="6.5" y1="4" x2="13.5" y2="4" stroke-width="1.3"/><path d="M1.8 7.4C1.8 6.6 4.2 6.6 4.2 7.4C4.2 8.2 1.8 9.5 1.8 9.5L4.2 9.5" stroke-width="1.1"/><line x1="6.5" y1="8" x2="13.5" y2="8" stroke-width="1.3"/><path d="M4.2 11.2C4.2 10.5 3 10.5 1.8 11.5C1.8 12 3 12 3 12C3 12 4.2 12 4.2 13C4.2 13.5 3 13.5 1.8 12.8" stroke-width="1.1"/><line x1="6.5" y1="12" x2="13.5" y2="12" stroke-width="1.3"/></svg>',al='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="2.5" width="11" height="11" rx="2.5"/><path d="M5.5 8L7 9.8L10.8 5.8"/></svg>',dl='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="3" width="2" height="10" rx="1" fill="currentColor" stroke="none"/><line x1="6.5" y1="5" x2="13" y2="5"/><line x1="6.5" y1="8" x2="13" y2="8"/><line x1="6.5" y1="11" x2="10" y2="11"/></svg>',ul='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 4L2 8L5 12"/><path d="M11 4L14 8L11 12"/><line x1="10" y1="3" x2="6" y2="13"/></svg>',Gd='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="2" y1="8" x2="14" y2="8"/></svg>',qd='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 3.5h10M2 8h10M2 12.5h10"/><path d="M14.5 3.5v.01M14.5 8v.01M14.5 12.5v.01"/></svg>',Yd='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="3" width="12" height="10" rx="1.5"/><circle cx="5.5" cy="6.5" r="1.1" fill="currentColor" stroke="none"/><path d="M13 11.5L10 8.5L7 11.5L5 9.5L3 11.5"/></svg>',Zd='<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M12 3a9 9 0 0 1 9 9" opacity="0.25"/><path d="M12 3a9 9 0 0 0-9 9" class="be-spinner-arc"/></g></svg>',Xd='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8a5 5 0 0 1 8.5-3.5M13 3v3h-3"/><path d="M13 8a5 5 0 0 1-8.5 3.5M3 13v-3h3"/></svg>',jd='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4L12 12"/><path d="M12 4L4 12"/></svg>',Qd='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 5H12M9 2L12 5L9 8"/><path d="M14 11H4M7 8L4 11L7 14"/></svg>',Jd='<svg viewBox="0 0 1024 1024" width="32" height="32" aria-hidden="true"><path d="M768.35456 416a256 256 0 1 0-512 0 192 192 0 1 0 0 384v64a256 256 0 0 1-58.88-505.216 320.128 320.128 0 0 1 629.76 0A256.128 256.128 0 0 1 768.35456 864v-64a192 192 0 0 0 0-384z m-512 384h128v64H256.35456v-64z m384 0h128v64h-128v-64z" fill="currentColor"/><path d="M539.04256 589.184v333.056a32.448 32.448 0 0 1-32 32.192 32.448 32.448 0 0 1-32-32.192V589.184l-36.096 36.096a32.192 32.192 0 0 1-45.056-0.192 31.616 31.616 0 0 1-0.192-45.056l90.88-90.88a31.36 31.36 0 0 1 22.528-9.152 30.08 30.08 0 0 1 22.4 9.088l90.88 90.944a32.192 32.192 0 0 1-0.192 45.056 31.616 31.616 0 0 1-45.056 0.192l-36.096-36.096z" fill="currentColor"/></svg>',eu=["aria-label"],tu={class:"bsm-group"},nu={class:"bsm-icon-grid"},ou=["title","onMousedown","onMouseenter"],ru={key:1,class:"bsm-group"},lu={class:"bsm-collapse-title"},iu={class:"bsm-collapse-body"},su={class:"bsm-row"},cu=["disabled","title","onMousedown"],au={viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},du={class:"bsm-row"},uu=["disabled","title"],fu=["disabled","title"],mu={key:2,class:"bsm-group"},pu={class:"bsm-collapse-title"},hu={class:"bsm-collapse-body"},gu={class:"bsm-row"},bu=["disabled","title"],ku=["disabled","title"],yu={key:3,class:"bsm-group bsm-colors"},wu={class:"bsm-collapse-title"},Eu={class:"bsm-collapse-body"},vu={class:"bsm-swatches"},Cu=["title","disabled","onMousedown"],Tu={key:4,class:"bsm-group bsm-colors"},_u={class:"bsm-collapse-title"},xu={class:"bsm-collapse-body"},Mu={class:"bsm-swatches"},Nu=["title","disabled","onMousedown"],Su={class:"bsm-group"},Au=["onMousedown","onMouseenter"],Iu={class:"bsm-title"},Bu={key:1,class:"bsm-shortcut"},Ru=["aria-label"],fl=260,Lu=80,Qi=24,Ou='<svg viewBox="0 0 16 16" width="14" height="14"><rect x="5" y="5" width="8" height="8" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.2"/><path d="M3 10.5V3.5C3 2.67 3.67 2 4.5 2H10" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/></svg>',Du='<svg viewBox="0 0 16 16" width="14" height="14"><rect x="5" y="5" width="8" height="8" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.2"/><path d="M3 10.5V3.5C3 2.67 3.67 2 4.5 2H10" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/></svg>',$u='<svg viewBox="0 0 16 16" width="14" height="14"><circle cx="4.5" cy="11.5" r="1.8" fill="none" stroke="currentColor" stroke-width="1.2"/><circle cx="11.5" cy="11.5" r="1.8" fill="none" stroke="currentColor" stroke-width="1.2"/><line x1="6" y1="10" x2="13" y2="3" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/><line x1="10" y1="10" x2="3" y2="3" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/></svg>',Pu='<svg viewBox="0 0 16 16" width="14" height="14"><path d="M8 12V4M4 8L8 4L12 8" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg>',Hu='<svg viewBox="0 0 16 16" width="14" height="14"><path d="M8 4V12M4 8L8 12L12 8" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg>',Vu='<svg viewBox="0 0 16 16" width="14" height="14"><path d="M3.5 4.5H12.5M6.5 4.5V3C6.5 2.45 6.95 2 7.5 2H8.5C9.05 2 9.5 2.45 9.5 3V4.5M5 4.5L5.5 13C5.55 13.55 6 14 6.55 14H9.45C10 14 10.45 13.55 10.5 13L11 4.5" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></svg>',Uu='<svg viewBox="0 0 1024 1024" width="14" height="14" aria-hidden="true"><path d="M597.333333 451.669333l55.168-55.168a42.666667 42.666667 0 0 1 60.330667 60.330667L657.664 512l55.168 55.168a42.666667 42.666667 0 0 1-60.330667 60.330667L597.333333 572.330667l-55.168 55.168a42.666667 42.666667 0 0 1-60.330666-60.330667L537.002667 512l-55.168-55.168a42.666667 42.666667 0 0 1 60.330666-60.330667L597.333333 451.669333zM874.581333 832H376.32c-47.402667 0-106.730667-25.941333-138.752-60.672l-163.178667-176.938667c-42.325333-45.866667-42.346667-118.869333 0-164.778666l163.2-176.938667C269.525333 218.026667 329.045333 192 376.32 192h498.24A106.666667 106.666667 0 0 1 981.333333 298.837333v426.325334A106.752 106.752 0 0 1 874.581333 832z m0-85.333333C886.4 746.666667 896 737.088 896 725.162667V298.837333c0-11.946667-9.514667-21.504-21.418667-21.504H376.32c-23.466667 0-60.224 16.064-76.010667 33.194667l-163.2 176.917333c-12.181333 13.226667-12.16 35.882667 0 49.109334l163.2 176.917333C316.16 730.666667 352.746667 746.666667 376.32 746.666667h498.24z" fill="currentColor"/></svg>',Ji='<svg viewBox="0 0 1024 1024" width="14" height="14" aria-hidden="true"><path d="M672.01024 896l-320 0c-17.67424 0-32.01024-14.336-32.01024-32.01024l0-352.01024-128 0c-12.94336 0-24.61696-7.80288-29.57312-19.7632s-2.21184-25.72288 6.94272-34.87744l320-320c12.4928-12.4928 32.768-12.4928 45.2608 0l320 320c9.15456 9.15456 11.89888 22.91712 6.94272 34.87744s-16.62976 19.7632-29.57312 19.7632l-128 0 0 352.01024c0 17.67424-14.336 32.01024-32.01024 32.01024zM384 832l256 0 0-352.01024c0-17.67424 14.336-32.01024 32.01024-32.01024l82.7392 0-242.74944-242.74944-242.74944 242.74944 82.7392 0c17.67424 0 32.01024 14.336 32.01024 32.01024l0 352.01024z" fill="currentColor"/></svg>',zu='<svg viewBox="0 0 1024 1024" width="14" height="14" aria-hidden="true"><path d="M512.00988746 141.21142578c10.45623779 0 19.24145531 3.50024414 26.37542748 10.71331811l259.5421145 259.55200196C805.03668189 418.58105492 808.63085938 427.33660865 808.63085938 437.84228516c0 10.60949731-3.53485132 19.46887183-10.56994606 26.46936011-7.02026391 7.00543237-15.88952661 10.60949731-26.50891137 10.60949731-10.44140625 0-19.22167969-3.60900903-26.35565185-10.71331811L549.09863305 267.79370094V845.7097168c0 10.19915748-3.62384057 18.94976782-10.89624071 26.16284179-7.23284888 7.31195068-15.97357177 10.91601563-26.2122798 10.91601563-10.23376465 0-18.959656-3.60900903-26.22216796-10.91601563-7.24273705-7.21307397-10.87646508-15.96862769-10.87646508-26.16284179V267.79370094l-196.10760522 196.41906761C271.65484619 471.31213355 262.87951684 474.92114258 252.41833496 474.92114258c-10.61938477 0-19.45898438-3.60900903-26.4990232-10.60949731C218.86444068 457.31115699 215.36914062 448.45178247 215.36914062 437.84228516c0-10.50567651 3.55462623-19.26123023 10.69354248-26.36553931l259.53717042-259.55200196C492.7288816 144.71166992 501.52398658 141.21142578 511.97033691 141.21142578h0.03955055z" fill="currentColor"/></svg>',Fu='<svg viewBox="0 0 1024 1024" width="14" height="14" aria-hidden="true"><path d="M511.99011254 141.21142578c10.23376465 0 18.95471191 3.60900903 26.2122798 10.81713891 7.25262451 7.20812988 10.86657691 15.96862769 10.86657763 26.2666626v577.89129615l196.1619873-196.43884254c7.099365-7.00543237 15.90435815-10.61444068 26.34082031-10.61444139 10.61938477 0 19.43426538 3.50518822 26.51385474 10.51062059 7.04498291 7.10430908 10.54522705 15.96862769 10.54522706 26.57318092 0 10.40679908-3.54473877 19.16235352-10.69354248 26.37542748l-259.55694604 259.48278761C531.23156714 879.28833008 522.44635033 882.78857422 512.00988746 882.78857422c-10.45623779 0-19.24145531-3.50024414-26.3704834-10.71331811l-259.55200195-259.48278761C218.94848656 605.37939453 215.36914062 596.62384009 215.36914062 586.21704102c0-10.60949731 3.52496314-19.46887183 10.56994606-26.57318092C232.99395776 552.63842773 241.82861328 549.12829614 252.44799805 549.12829614c10.42163062 0 19.2167356 3.60900903 26.36553931 10.61444068l196.1125493 196.43884253V178.29522729c0-10.30297828 3.60900903-19.05853271 10.88635255-26.2666626C493.05517555 144.81549073 501.80084252 141.21142578 512.02966309 141.21142578h-0.03955055z" fill="currentColor"/></svg>',Ku='<svg viewBox="0 0 100 100" width="14" height="14" aria-hidden="true"><path fill="currentColor" d="M 75,28.5 L 71,32 C 67,26.8 61.5,22.5 53.5,22.5 C 38,22.5 24.5,34.5 24.5,50 C 24.5,65.5 38,77.5 53.5,77.5 C 61.5,77.5 67,73.2 71,68 L 75,71.5 C 70,77.8 62.5,83 53.5,83 C 34.5,83 19,68.5 19,50 C 19,31.5 34.5,17 53.5,17 C 62.5,17 70,22.2 75,28.5 Z"/></svg>',Wu='<svg viewBox="0 0 100 100" width="14" height="14" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M 22,17 H 49 C 68,17 79,30.5 79,50 C 79,69.5 68,83 49,83 H 22 Z M 27.5,22.5 H 48.5 C 64.5,22.5 73.5,33.5 73.5,50 C 73.5,66.5 64.5,77.5 48.5,77.5 H 27.5 Z"/></svg>',Gu='<svg viewBox="0 0 100 100" width="14" height="14" aria-hidden="true"><path fill="currentColor" d="M 20,17 L 26.5,17 L 50,46.2 L 73.5,17 L 80,17 L 53.8,50 L 80,83 L 73.5,83 L 50,53.8 L 26.5,83 L 20,83 L 46.2,50 Z"/></svg>',qu='<svg viewBox="0 0 1024 1024" width="14" height="14" aria-hidden="true"><path d="M768 597.333333h-85.333333V426.666667h85.333333c94.250667 0 170.666667-76.416 170.666667-170.666667S862.250667 85.333333 768 85.333333c-94.261333 0-170.666667 76.416-170.666667 170.666667v85.333333H426.666667v-85.333333c0-94.250667-76.416-170.666667-170.666667-170.666667S85.333333 161.749333 85.333333 256s76.416 170.666667 170.666667 170.666667h85.333333v170.666666h-85.333333c-94.250667 0-170.666667 76.416-170.666667 170.666667s76.416 170.666667 170.666667 170.666667c94.261333 0 170.666667-76.416 170.666667-170.666667v-85.333333h170.666666v85.12l-0.010666 0.213333c0 94.250667 76.416 170.666667 170.666666 170.666667s170.666667-76.416 170.666667-170.666667S862.250667 597.354667 768 597.333333z m0-426.666666a85.333333 85.333333 0 0 1 0 170.666666h-85.333333v-85.333333a85.333333 85.333333 0 0 1 85.333333-85.333333z m-597.333333 85.333333a85.333333 85.333333 0 0 1 170.666666 0v85.333333h-85.333333c-47.125333 0-85.333333-38.218667-85.333333-85.333333z m85.333333 597.333333a85.333333 85.333333 0 0 1 0-170.666666h85.333333v85.333333a85.333333 85.333333 0 0 1-85.333333 85.333333z m170.666667-256V426.666667h170.666666v170.666666H426.666667z m341.333333 256a85.333333 85.333333 0 0 1-85.333333-85.333333v-85.333333h85.322666A85.333333 85.333333 0 0 1 768 853.333333z" fill="currentColor"/></svg>',Yu='<svg viewBox="0 0 100 100" width="14" height="14" aria-hidden="true"><rect x="8" y="8" width="84" height="84" rx="16" fill="none" stroke="currentColor" stroke-width="4.8" stroke-linecap="round" stroke-linejoin="round"/><path fill="currentColor" d="M 43.5,32 C 40.3,30.3 36.3,29.5 31.5,29.5 C 20.5,29.5 14,38.2 14,50 C 14,61.8 20.5,70.5 31.5,70.5 C 36.3,70.5 40.3,69.7 43.5,68 L 43.5,60.5 C 40.5,62.8 36.5,64 32,64 C 23.7,64 20,58 20,50 C 20,42 23.7,36 32,36 C 36.5,36 40.5,37.2 43.5,39.5 Z M 50,32 H 56 V 41.5 H 59.5 V 47.5 H 56 V 62 C 56,64.2 57,65 59,65 H 60 V 70.5 C 58.5,70.8 56.7,71 54.5,71 C 50,71 48,68.5 48,63 V 47.5 H 44.5 V 41.5 H 48 V 32 Z M 62.5,41.5 H 68 V 47 C 70,43.2 73,41.5 76.5,41.5 V 47.5 C 74,47.5 71,49 68.5,52.5 V 70.5 H 62.5 V 41.5 Z M 79.5,32 H 85.5 V 70.5 H 79.5 Z"/></svg>',Zu=t.defineComponent({__name:"BlockSettingsMenu",props:{visible:{type:Boolean},anchorEl:{},blockId:{},rootEl:{}},emits:["close"],setup(e,{expose:n,emit:o}){const r=e,l=o,{t:i}=Zt(),c=cn(),s=t.inject(Lo,t.ref(!1)),a=t.ref(null),d=t.ref(null),u=t.ref("paragraph"),f=t.ref({top:0,left:0,availableHeight:520,above:!1,bottom:0,topBaseline:0}),p=t.ref(!1),m=t.ref(!1),h=t.ref(!1),y=t.reactive({alignIndent:!1,indent:!1,textColor:!1,bgColor:!1}),N=t.ref(!1);let L=null;t.watch(()=>r.visible,P=>{P?(L&&(clearTimeout(L),L=null),N.value=!0):L=setTimeout(()=>{N.value=!1,L=null},300)},{immediate:!0});const S=t.shallowRef(c.getState());let G=null;const K=t.computed(()=>r.blockId!=null?S.value.doc.blocks.get(r.blockId):void 0),F=t.ref(void 0),Y=t.computed(()=>{var k;const P=(k=K.value)==null?void 0:k.attrs.align;return typeof P=="string"?P:"left"}),ae=t.computed(()=>{const P=F.value;return P?!("align"in c.registries.schema.get(P).attrs):!0}),ne=t.computed(()=>F.value==="image"||F.value==="table"),te=t.computed(()=>F.value==="divider"||F.value==="tableOfContents"),X=t.computed(()=>F.value==="divider"||F.value==="table"||F.value==="tableOfContents"),B=t.computed(()=>{const P=F.value;if(!P)return!0;const k=c.registries.schema.get(P);return!("color"in k.attrs)||!("bgColor"in k.attrs)}),$=t.computed(()=>{const P=K.value;return P?On(S.value.doc,P.id):0});function M(P){return["paragraph","heading","orderedList","bulletList","todoList"].includes(P)}const A=t.computed(()=>!!F.value),w=t.computed(()=>{const P=K.value;if(!P)return!0;const k=S.value.doc,W=Ar(k,P.id);return!W||!M(W.type)||On(k,W.id)>=10}),C=t.computed(()=>$.value<=0),x=t.computed(()=>{var k;const P=(k=K.value)==null?void 0:k.attrs.color;return typeof P=="string"?P:"default"}),z=t.computed(()=>{var k;const P=(k=K.value)==null?void 0:k.attrs.bgColor;return typeof P=="string"?P:"default"}),U=t.computed(()=>[{id:"paragraph",iconHtml:el,title:i("turnInto.paragraph"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"paragraph"}))}},{id:"h1",iconHtml:tl,title:i("turnInto.h1"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"heading",attrs:{level:1}}))}},{id:"h2",iconHtml:nl,title:i("turnInto.h2"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"heading",attrs:{level:2}}))}},{id:"h3",iconHtml:ol,title:i("turnInto.h3"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"heading",attrs:{level:3}}))}},{id:"h4",iconHtml:rl,title:i("turnInto.h4"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"heading",attrs:{level:4}}))}},{id:"h5",iconHtml:ll,title:i("turnInto.h5"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"heading",attrs:{level:5}}))}},{id:"h6",iconHtml:il,title:i("turnInto.h6"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"heading",attrs:{level:6}}))}},{id:"bullet",iconHtml:sl,title:i("turnInto.bullet"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"bulletList"}))}},{id:"ordered",iconHtml:cl,title:i("turnInto.ordered"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"orderedList"}))}},{id:"todo",iconHtml:al,title:i("turnInto.todo"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"todoList",attrs:{checked:!1}}))}},{id:"quote",iconHtml:dl,title:i("turnInto.quote"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"quote"}))}},{id:"code",iconHtml:ul,title:i("turnInto.code"),kind:"turnInto",run:()=>{var P,k;return void((k=(P=c.commands).convertBlock)==null?void 0:k.call(P,{id:r.blockId,type:"codeBlock",attrs:{language:"plain"}}))}}]);function fe(P){const k=K.value;if(!k)return!1;switch(P){case"paragraph":return k.type==="paragraph";case"h1":return k.type==="heading"&&Number(k.attrs.level)===1;case"h2":return k.type==="heading"&&Number(k.attrs.level)===2;case"h3":return k.type==="heading"&&Number(k.attrs.level)===3;case"h4":return k.type==="heading"&&Number(k.attrs.level)===4;case"h5":return k.type==="heading"&&Number(k.attrs.level)===5;case"h6":return k.type==="heading"&&Number(k.attrs.level)===6;case"bullet":return k.type==="bulletList";case"ordered":return k.type==="orderedList";case"todo":return k.type==="todoList";case"quote":return k.type==="quote";case"code":return k.type==="codeBlock";default:return!1}}function oe(P){return fe(P)}t.watch(()=>r.visible,P=>{var W;if(!P)return;F.value=r.blockId!=null?(W=S.value.doc.blocks.get(r.blockId))==null?void 0:W.type:void 0;const k=U.value.find(ye=>fe(ye.id));u.value=k?k.id:"paragraph",y.alignIndent=!1,y.indent=!1,y.textColor=!1,y.bgColor=!1},{immediate:!0});const ue=t.computed(()=>{const P=[{id:"align-left",value:"left",title:i("align.left"),run:()=>xe("left")},{id:"align-center",value:"center",title:i("align.center"),run:()=>xe("center")},{id:"align-right",value:"right",title:i("align.right"),run:()=>xe("right")}];return ne.value||P.push({id:"align-justify",value:"justify",title:i("align.justify"),run:()=>xe("justify")}),P});function xe(P){var k,W;(W=(k=c.commands).setBlockAlign)==null||W.call(k,{id:r.blockId,align:P})}function pe(){var P,k;(k=(P=c.commands).indentBlock)==null||k.call(P,{id:r.blockId})}function qe(){var P,k;(k=(P=c.commands).outdentBlock)==null||k.call(P,{id:r.blockId})}const Ce=Xi,je=ji;function ct(P){var k,W;(W=(k=c.commands).setBlockColor)==null||W.call(k,{id:r.blockId,color:P})}function St(P){var k,W;(W=(k=c.commands).setBlockBgColor)==null||W.call(k,{id:r.blockId,bgColor:P})}async function At(){var $e,Ct;const P=K.value;if(!P)return;const k=Ae(P.content),ye=`<meta charset="utf-8"><!-- blockeditor:${JSON.stringify({id:P.id,type:P.type,attrs:P.attrs,text:k}).replace(/--/g,"\\-\\-")} -->${Et(k)}`;let Te=!1;try{if(($e=navigator.clipboard)!=null&&$e.write&&typeof ClipboardItem<"u"){const Qt=new ClipboardItem({"text/plain":new Blob([k],{type:"text/plain"}),"text/html":new Blob([ye],{type:"text/html"})});await navigator.clipboard.write([Qt]),Te=!0}}catch{Te=!1}if(!Te)try{(Ct=navigator.clipboard)!=null&&Ct.writeText&&(await navigator.clipboard.writeText(k),Te=!0)}catch{Te=!1}Te||(Te=qt(k))}function Et(P){return P.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function qt(P){const k=document.createElement("textarea");k.value=P,k.setAttribute("readonly",""),k.style.position="fixed",k.style.top="-9999px",k.style.left="-9999px",k.style.opacity="0",document.body.appendChild(k);const W=document.activeElement;k.focus(),k.select();try{return document.execCommand("copy")}catch{return!1}finally{if(document.body.removeChild(k),W&&typeof W.focus=="function")try{W.focus()}catch{}}}function bt(){At().then(()=>{var P,k;return(k=(P=c.commands).removeBlock)==null?void 0:k.call(P,{id:r.blockId})})}const vt=/Mac|iP(hone|[ao]d)/.test(navigator.platform)?qu:Yu;function nt(...P){return P.join("")}const Pe=t.computed(()=>[{id:"dup",iconHtml:Ou,title:i("action.duplicate"),shortcutHtml:nt(vt,Wu),run:()=>{var P,k;return void((k=(P=c.commands).duplicateBlock)==null?void 0:k.call(P,{id:r.blockId}))}},{id:"copy",iconHtml:Du,title:i("action.copy"),shortcutHtml:nt(vt,Ku),run:()=>void At()},{id:"cut",iconHtml:$u,title:i("action.cut"),shortcutHtml:nt(vt,Gu),run:()=>void bt()},{id:"up",iconHtml:Pu,title:i("action.moveUp"),shortcutHtml:nt(vt,Ji,zu),run:()=>{var P,k;return void((k=(P=c.commands).moveBlockUp)==null?void 0:k.call(P,{id:r.blockId}))}},{id:"down",iconHtml:Hu,title:i("action.moveDown"),shortcutHtml:nt(vt,Ji,Fu),run:()=>{var P,k;return void((k=(P=c.commands).moveBlockDown)==null?void 0:k.call(P,{id:r.blockId}))}},{id:"del",iconHtml:Vu,title:i("action.delete"),shortcutHtml:Uu,danger:!0,run:()=>{var P,k;return void((k=(P=c.commands).removeBlock)==null?void 0:k.call(P,{id:r.blockId}))}}]);t.watch(()=>r.visible,P=>{P&&(p.value=!1,f.value={top:0,left:0,availableHeight:520,above:!1,bottom:0,topBaseline:0})});function mt(){const P=r.anchorEl,k=r.rootEl,W=a.value;!r.visible||!P||!k||!W||t.nextTick().then(()=>{const ye=a.value;if(!ye)return;const Te=ye.getBoundingClientRect(),$e=!!P.closest(".fixed-toolbar"),Ct=$e?s.value?"up":"down":"auto",Qt=$e?10:0,Lt=Wi(k,P,{width:Math.max(Te.width,fl),height:Te.height},8,Ct,Qt,Qt);f.value=Lt,p.value=!0,t.nextTick(at)})}t.watch([()=>r.visible,()=>r.anchorEl,a,m,h],mt,{flush:"post"});function de(P){y[P]=!y[P],t.nextTick(mt)}function at(){const P=d.value;P&&(m.value=P.scrollTop>1,h.value=P.scrollTop+P.clientHeight<P.scrollHeight-1)}function Ke(){const P=d.value;P&&(P.scrollTop-=P.clientHeight*.8)}function _e(){const P=d.value;P&&(P.scrollTop+=P.clientHeight*.8)}dr(d,at);const Rt=t.computed(()=>{if(!r.rootEl)return{display:"none"};if(!p.value)return{visibility:"hidden",top:"0px",left:"0px",width:`${fl}px`,"--scroll-max-height":"100vh"};const P=f.value.above,k=f.value.left,W=(m.value?Qi:0)+(h.value?Qi:0),ye=f.value.availableHeight-W,Te={left:`${k}px`,width:`${fl}px`,maxHeight:`${f.value.availableHeight}px`,"--scroll-max-height":`${Math.max(Lu,ye)}px`};if(P){const $e=document.documentElement.clientHeight;Te.bottom=`${Math.max(0,$e-f.value.bottom)}px`,Te.top="auto"}else Te.top=`${f.value.top}px`,Te.bottom="auto";return Te});function ot(P){if(P.kind==="turnInto"&&oe(P.id)){const k=U.value.find(W=>W.id==="paragraph");if(k){u.value="paragraph",k.run(),l("close");return}}u.value=P.id,P.run(),l("close")}function It(P){const k=[...U.value,...Pe.value];if(k.length===0)return!1;const W=k.findIndex(Te=>Te.id===u.value),ye=Te=>(Te%k.length+k.length)%k.length;switch(P.key){case"ArrowDown":return P.preventDefault(),u.value=k[ye(W+1)].id,!0;case"ArrowUp":return P.preventDefault(),u.value=k[ye(W-1)].id,!0;case"Enter":return P.preventDefault(),ot(k[ye(W)]),!0;case"Escape":return P.preventDefault(),l("close"),!0;default:return!1}}return n({onKeyDown:It}),Yi(a,()=>r.visible,()=>l("close"),()=>r.anchorEl),t.onMounted(()=>{G=c.subscribe(P=>{S.value=P.state})}),t.onBeforeUnmount(()=>{G==null||G(),G=null}),(P,k)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[N.value&&e.rootEl?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"menuEl",ref:a,class:t.normalizeClass(["block-settings-menu",{"menu-closing":!e.visible}]),style:t.normalizeStyle(Rt.value),role:"menu"},[m.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(i)("ui.scrollUp"),onMousedown:t.withModifiers(Ke,["prevent"])},[...k[8]||(k[8]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,eu)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:d,class:"bsm-scroll",onScroll:at},[!ne.value&&!te.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",tu,[t.createElementVNode("div",nu,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(U.value,W=>(t.openBlock(),t.createElementBlock("button",{key:W.id,class:t.normalizeClass(["bsm-icon-cell",{active:oe(W.id)}]),title:W.title,role:"menuitem",onMousedown:t.withModifiers(ye=>ot(W),["prevent"]),onMouseenter:ye=>u.value=W.id},[t.createVNode(dn,{class:"bsm-icon-svg",html:W.iconHtml},null,8,["html"])],42,ou))),128))])]),k[9]||(k[9]=t.createElementVNode("div",{class:"bsm-sep"},null,-1))],64)):t.createCommentVNode("",!0),X.value?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",ru,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-collapse-header",{"bsm-disabled":ae.value&&!A.value,expanded:y.alignIndent}]),role:"menuitem",onMousedown:k[0]||(k[0]=t.withModifiers(W=>de("alignIndent"),["prevent"]))},[t.createElementVNode("span",lu,t.toDisplayString(t.unref(i)("bsm.section.alignIndent")),1),k[10]||(k[10]=t.createElementVNode("svg",{class:"bsm-collapse-chevron",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],34),t.withDirectives(t.createElementVNode("div",iu,[t.createElementVNode("div",su,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(ue.value,W=>(t.openBlock(),t.createElementBlock("button",{key:W.id,class:t.normalizeClass(["bsm-icon-btn",{active:!ae.value&&Y.value===W.value,"bsm-disabled":ae.value}]),disabled:ae.value,title:W.title,role:"menuitem",onMousedown:t.withModifiers(ye=>!ae.value&&ot(W),["prevent"])},[(t.openBlock(),t.createElementBlock("svg",au,[W.value==="left"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[k[11]||(k[11]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),k[12]||(k[12]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"10",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),k[13]||(k[13]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"12",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):W.value==="center"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[k[14]||(k[14]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),k[15]||(k[15]=t.createElementVNode("line",{x1:"4",y1:"8",x2:"12",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),k[16]||(k[16]=t.createElementVNode("line",{x1:"3",y1:"12",x2:"13",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):W.value==="right"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[k[17]||(k[17]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),k[18]||(k[18]=t.createElementVNode("line",{x1:"6",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),k[19]||(k[19]=t.createElementVNode("line",{x1:"4",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:3},[k[20]||(k[20]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),k[21]||(k[21]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),k[22]||(k[22]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64))]))],42,cu))),128))]),t.createElementVNode("div",du,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-icon-btn",{"bsm-disabled":C.value}]),disabled:C.value,title:t.unref(i)("bsm.indent.decrease"),role:"menuitem",onMousedown:k[1]||(k[1]=t.withModifiers(W=>!C.value&&ot({id:"outdent",run:qe}),["prevent"]))},[...k[23]||(k[23]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M906.666667 379.733333h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM906.666667 580.266667h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM117.333333 245.333333h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-789.333334C100.266667 181.333333 85.333333 196.266667 85.333333 213.333333s14.933333 32 32 32zM906.666667 778.666667h-789.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM285.866667 657.066667c14.933333 8.533333 34.133333 0 34.133333-17.066667V384c0-17.066667-19.2-27.733333-34.133333-17.066667l-192 128c-12.8 8.533333-12.8 27.733333 0 36.266667l192 125.866667z",fill:"currentColor"})],-1)])],42,uu),t.createElementVNode("button",{class:t.normalizeClass(["bsm-icon-btn",{"bsm-disabled":w.value}]),disabled:w.value,title:t.unref(i)("bsm.indent.increase"),role:"menuitem",onMousedown:k[2]||(k[2]=t.withModifiers(W=>!w.value&&ot({id:"indent",run:pe}),["prevent"]))},[...k[24]||(k[24]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M906.666667 379.733333h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM906.666667 580.266667h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM117.333333 245.333333h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-789.333334C100.266667 181.333333 85.333333 196.266667 85.333333 213.333333s14.933333 32 32 32zM906.666667 778.666667h-789.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM119.466667 657.066667A21.333333 21.333333 0 0 1 85.333333 640V384c0-17.066667 19.2-27.733333 34.133334-17.066667l192 128c12.8 8.533333 12.8 27.733333 0 36.266667l-192 125.866667z",fill:"currentColor"})],-1)])],42,fu)])],512),[[t.vShow,y.alignIndent]])])),X.value?(t.openBlock(),t.createElementBlock("div",mu,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-collapse-header",{"bsm-disabled":!A.value,expanded:y.indent}]),role:"menuitem",onMousedown:k[3]||(k[3]=t.withModifiers(W=>de("indent"),["prevent"]))},[t.createElementVNode("span",pu,t.toDisplayString(t.unref(i)("bsm.section.indent")),1),k[25]||(k[25]=t.createElementVNode("svg",{class:"bsm-collapse-chevron",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],34),t.withDirectives(t.createElementVNode("div",hu,[t.createElementVNode("div",gu,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-icon-btn",{"bsm-disabled":C.value}]),disabled:C.value,title:t.unref(i)("bsm.indent.decrease"),role:"menuitem",onMousedown:k[4]||(k[4]=t.withModifiers(W=>!C.value&&ot({id:"outdent",run:qe}),["prevent"]))},[...k[26]||(k[26]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M906.666667 379.733333h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM906.666667 580.266667h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM117.333333 245.333333h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-789.333334C100.266667 181.333333 85.333333 196.266667 85.333333 213.333333s14.933333 32 32 32zM906.666667 778.666667h-789.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM285.866667 657.066667c14.933333 8.533333 34.133333 0 34.133333-17.066667V384c0-17.066667-19.2-27.733333-34.133333-17.066667l-192 128c-12.8 8.533333-12.8 27.733333 0 36.266667l192 125.866667z",fill:"currentColor"})],-1)])],42,bu),t.createElementVNode("button",{class:t.normalizeClass(["bsm-icon-btn",{"bsm-disabled":w.value}]),disabled:w.value,title:t.unref(i)("bsm.indent.increase"),role:"menuitem",onMousedown:k[5]||(k[5]=t.withModifiers(W=>!w.value&&ot({id:"indent",run:pe}),["prevent"]))},[...k[27]||(k[27]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M906.666667 379.733333h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM906.666667 580.266667h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM117.333333 245.333333h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-789.333334C100.266667 181.333333 85.333333 196.266667 85.333333 213.333333s14.933333 32 32 32zM906.666667 778.666667h-789.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM119.466667 657.066667A21.333333 21.333333 0 0 1 85.333333 640V384c0-17.066667 19.2-27.733333 34.133334-17.066667l192 128c12.8 8.533333 12.8 27.733333 0 36.266667l-192 125.866667z",fill:"currentColor"})],-1)])],42,ku)])],512),[[t.vShow,y.indent]])])):t.createCommentVNode("",!0),!ne.value&&!te.value?(t.openBlock(),t.createElementBlock("div",yu,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-collapse-header",{"bsm-disabled":B.value,expanded:y.textColor}]),role:"menuitem",onMousedown:k[6]||(k[6]=t.withModifiers(W=>!B.value&&de("textColor"),["prevent"]))},[t.createElementVNode("span",wu,t.toDisplayString(t.unref(i)("bsm.section.textColor")),1),k[28]||(k[28]=t.createElementVNode("svg",{class:"bsm-collapse-chevron",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],34),t.withDirectives(t.createElementVNode("div",Eu,[t.createElementVNode("div",vu,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(Ce),W=>(t.openBlock(),t.createElementBlock("button",{key:"tc-"+W.key,class:t.normalizeClass(["bsm-swatch",{active:x.value===W.key,"bsm-disabled":B.value}]),title:t.unref(i)(W.key==="default"?"color.default":"color."+W.key),style:t.normalizeStyle({backgroundColor:W.displayCssValue??W.cssValue}),disabled:B.value,onMousedown:t.withModifiers(ye=>!B.value&&ot({id:`tc-${W.key}`,run:()=>ct(W.key)}),["prevent"])},null,46,Cu))),128))])],512),[[t.vShow,y.textColor]])])):t.createCommentVNode("",!0),!ne.value&&!te.value?(t.openBlock(),t.createElementBlock("div",Tu,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-collapse-header",{"bsm-disabled":B.value,expanded:y.bgColor}]),role:"menuitem",onMousedown:k[7]||(k[7]=t.withModifiers(W=>!B.value&&de("bgColor"),["prevent"]))},[t.createElementVNode("span",_u,t.toDisplayString(t.unref(i)("bsm.section.bgColor")),1),k[29]||(k[29]=t.createElementVNode("svg",{class:"bsm-collapse-chevron",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],34),t.withDirectives(t.createElementVNode("div",xu,[t.createElementVNode("div",Mu,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(je),W=>(t.openBlock(),t.createElementBlock("button",{key:"bc-"+W.key,class:t.normalizeClass(["bsm-swatch",[{active:z.value===W.key,"bsm-disabled":B.value},W.key==="default"?"bsm-swatch--none":""]]),title:t.unref(i)(W.key==="default"?"color.none":"color."+W.key),style:t.normalizeStyle({backgroundColor:W.displayCssValue??W.cssValue}),disabled:B.value,onMousedown:t.withModifiers(ye=>!B.value&&ot({id:`bc-${W.key}`,run:()=>St(W.key)}),["prevent"])},null,46,Nu))),128))])],512),[[t.vShow,y.bgColor]])])):t.createCommentVNode("",!0),k[30]||(k[30]=t.createElementVNode("div",{class:"bsm-sep"},null,-1)),t.createElementVNode("div",Su,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(Pe.value,W=>(t.openBlock(),t.createElementBlock("button",{key:W.id,class:t.normalizeClass(["bsm-item bsm-action",{danger:W.danger}]),role:"menuitem",onMousedown:t.withModifiers(ye=>ot(W),["prevent"]),onMouseenter:ye=>u.value=W.id},[t.createVNode(dn,{class:"bsm-action-icon",html:W.iconHtml},null,8,["html"]),t.createElementVNode("span",Iu,t.toDisplayString(W.title),1),W.shortcutHtml?(t.openBlock(),t.createBlock(dn,{key:0,class:"bsm-shortcut",html:W.shortcutHtml},null,8,["html"])):W.shortcut?(t.openBlock(),t.createElementBlock("span",Bu,t.toDisplayString(W.shortcut),1)):t.createCommentVNode("",!0)],42,Au))),128))])],544),h.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(i)("ui.scrollDown"),onMousedown:t.withModifiers(_e,["prevent"])},[...k[31]||(k[31]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Ru)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)]))}}),Xu=["aria-hidden"],ju=["aria-label"],Qu=["title","aria-label"],Ju={class:"ht-dropdown-wrap"},ef=["title","disabled"],tf={class:"ht-type-label"},nf=["aria-label"],of=["onMousedown"],rf={key:0,class:"ht-check",viewBox:"0 0 12 12",width:"14",height:"14","aria-hidden":"true"},lf=["aria-label"],sf={class:"ht-dropdown-wrap"},cf=["title","disabled"],af={viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},df=["aria-label"],uf=["onMousedown"],ff={viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},mf={key:0,class:"ht-check",viewBox:"0 0 12 12",width:"14",height:"14","aria-hidden":"true"},pf=["aria-label"],hf={key:0,class:"ht-dropdown-wrap"},gf=["title","disabled"],bf={viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},kf=["aria-label"],yf=["onMousedown"],wf={viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},Ef={key:0,class:"ht-check",viewBox:"0 0 12 12",width:"14",height:"14","aria-hidden":"true"},vf=["aria-label"],Cf=["title","disabled","onMousedown","onTouchstart"],Tf=["title","disabled"],_f={class:"ht-dropdown-wrap"},xf=["title","disabled"],Mf=["aria-label"],Nf={class:"ht-color-section"},Sf={class:"ht-color-label"},Af={class:"ht-swatches"},If=["title","onMousedown"],Bf={class:"ht-color-section"},Rf={class:"ht-color-label"},Lf={class:"ht-swatches"},Of=["title","onMousedown"],Df=["aria-label"],$f=["title","aria-label","disabled"],Pf={key:0,class:"ht-sep"},Hf=["title"],Vf=["title"],Uf=["title"],zf={key:0,class:"ht-sep"},Ff=["title"],Kf=["title","aria-label"],Wf=80,Gf=24,ml=36,qf=360,es=10,ts=200,Yf=t.defineComponent({__name:"HoverToolbar",props:{visible:{type:Boolean},selectionRect:{},blockId:{},blockType:{},blockAttrs:{},rootEl:{},tableMode:{type:Boolean},showDelete:{type:Boolean},deleteLabel:{},deleteIcon:{},showMerge:{type:Boolean},showSplit:{type:Boolean},showHeaderRow:{type:Boolean},headerRowActive:{type:Boolean},cellEditMode:{type:Boolean},tableActiveMarks:{},tableActiveColor:{},tableActiveBgColor:{},tableActiveVerticalAlign:{},mobile:{type:Boolean}},emits:["close","interacting","linkClick","delete","merge","split","tableHeaderRow","tableType","tableAlign","tableVerticalAlign","tableMark","tableTextColor","tableBgColor","tableCopy"],setup(e,{expose:n,emit:o}){const r=e,l=o,{t:i}=Zt(),c=cn(),s=t.inject(Lo,t.ref(!1)),a=t.ref(null),d=t.ref(null),u=t.ref(null),f=t.ref(null),p=t.ref(null),m=t.ref(null),h=t.ref(null),y=t.ref(null),N=t.ref(null),L=t.ref({top:0,left:0,above:!1}),S=t.ref(null),G=t.ref(!1),K=t.ref(null),F=t.ref(null),Y=t.ref(!1),ae=t.ref(!1),ne=t.ref(null),te=t.ref(!1),X=t.ref(!1),B=t.ref(!1),$=t.computed(()=>({maxHeight:K.value!==null?`${K.value}px`:void 0})),M=t.ref(null),A=t.computed(()=>{if(!r.mobile||!M.value)return;const R=M.value,b={position:"fixed",left:`${R.left}px`};return R.top!==void 0&&(b.top=`${R.top}px`),R.bottom!==void 0&&(b.bottom=`${R.bottom}px`),R.right!==void 0&&(b.right=`${R.right}px`),b}),w=t.shallowRef(null);t.watch(()=>r.blockId,R=>{w.value=R},{immediate:!0});const C=t.shallowRef(c.getState());let x=null;const z=t.computed(()=>C.value.doc.blocks.get(w.value??"")),U=t.computed(()=>{var b;if(r.cellEditMode||r.tableMode){const D=r.blockAttrs.align;return typeof D=="string"?D:"left"}const R=(b=z.value)==null?void 0:b.attrs.align;return typeof R=="string"?R:"left"}),fe=t.computed(()=>{if(r.tableMode){const R=r.tableActiveVerticalAlign;return typeof R=="string"?R:"middle"}if(r.cellEditMode){const R=r.blockAttrs.verticalAlign;return typeof R=="string"?R:"middle"}return"middle"}),oe=t.ref(""),ue=t.ref("");t.watch(()=>r.visible,R=>{R||(S.value=null)}),t.watch(()=>r.blockId,()=>{S.value=null});const xe=t.ref(new Set),pe=t.ref(0);function qe(){var R;if(!r.rootEl)return null;if(r.cellEditMode){const b=window.getSelection();if(!b||b.rangeCount===0)return null;const D=b.getRangeAt(0);return(R=D.commonAncestorContainer.nodeType===1?D.commonAncestorContainer:D.commonAncestorContainer.parentElement)==null?void 0:R.closest(".table-cell-inner")}return r.rootEl.querySelector(`[data-block-id="${r.blockId}"]`)}function Ce(){const R=new Set;if(!r.visible||!r.blockId||!r.rootEl){xe.value=R;return}if(r.tableMode&&r.tableActiveMarks){xe.value=new Set(r.tableActiveMarks);return}const b=qe();if(b){const I=window.getSelection();if(I&&I.rangeCount>0){const V=I.getRangeAt(0);if(!V.collapsed&&b.contains(V.commonAncestorContainer)){const q=[],j=document.createTreeWalker(b,NodeFilter.SHOW_TEXT);for(;j.nextNode();){const ie=j.currentNode;(ie.nodeValue??"").length!==0&&V.intersectsNode(ie)&&q.push(ie)}if(q.length>0){const ie={bold:["B","STRONG"],italic:["I","EM"],underline:["U"],strikethrough:["S","STRIKE","DEL"],code:["CODE"],link:["A"]};for(const[me,he]of Object.entries(ie))q.every(we=>{let Be=we.parentNode;for(;Be&&Be!==b;){if(Be.nodeType===Node.ELEMENT_NODE&&he.includes(Be.nodeName))return!0;Be=Be.parentNode}return!1})&&R.add(me);if(R.size>0){xe.value=R;return}}}}}const D=C.value,ce=r.blockId?D.doc.blocks.get(r.blockId):void 0;if(!ce){xe.value=R;return}const Ne=D.selection;let E=0,_=Ae(ce.content).length;if(Ne.kind==="text"&&Ne.anchor.blockId===r.blockId&&Ne.focus.blockId===r.blockId)E=Math.min(Ne.anchor.offset,Ne.focus.offset),_=Math.max(Ne.anchor.offset,Ne.focus.offset);else{const I=Fe();I&&(E=I.from,_=I.to)}if(E>=_){xe.value=R;return}const T=["bold","italic","underline","strikethrough","code","link"];for(const I of T){let V=!0,q=!1,j=0;for(const ie of ce.content){if(ie.type!=="text")continue;const me=j,he=j+ie.text.length;if(he>E&&me<_&&(q=!0,!ie.marks||!ie.marks.some(we=>we.type===I))){V=!1;break}j=he}q&&V&&R.add(I)}xe.value=R}const je=t.computed(()=>r.mobile&&!r.tableMode&&!r.cellEditMode&&!r.selectionRect),ct=t.computed(()=>je.value||r.blockType==="codeBlock"),St=t.computed(()=>r.tableMode||r.cellEditMode?je.value:!r.blockId),At=t.computed(()=>{if(r.tableMode||r.cellEditMode)return je.value?!0:r.blockType==="codeBlock";if(!r.blockId||r.blockType==="codeBlock")return!0;const R=r.blockType;return R?!("align"in c.registries.schema.get(R).attrs):!1});function Et(R){if(r.tableMode||r.cellEditMode)return!!(r.blockType==="codeBlock"||r.blockType==="quote"&&R==="italic"||R!=="code"&&xe.value.has("code"));if(ct.value)return!0;if(R==="italic"){const b=r.blockType;if(b&&c.registries.schema.isMarkDisallowed(b,"italic"))return!0}if(R==="link"){const b=c.getState().selection;return!!(b.kind==="text"&&Pt(b))}return!!(R!=="code"&&xe.value.has("code"))}const qt=t.computed(()=>[{id:"bold",title:i("mark.bold"),iconHtml:'<svg viewBox="0 0 1024 1024" width="15" height="15" aria-hidden="true"><path d="M214.857 889.143v-68.571h68.571V203.429H214.857v-68.571h411.429v1.257c96.114 10.629 171.429 87.383 171.429 181.6 0 58.971-29.486 111.086-75.109 144.457 72.069 39.291 120.823 113.234 120.823 198.4 0 119.291-95.634 216.594-217.12 227.543l-0.286.029H214.857z m388.572-388.571H352v320h251.429c95.086 0 171.429-72.091 171.429-160s-76.343-160-171.429-160z m0-297.143H352v228.571h251.429l5.211-0.091c67.52-2.515 120.503-53.235 120.503-114.195 0-62.537-55.749-114.285-125.714-114.285z" fill="currentColor"/></svg>'},{id:"italic",title:i("mark.italic"),iconHtml:'<svg viewBox="0 0 1024 1024" width="15" height="15" aria-hidden="true"><path d="M730.143 127.714v64.286h-112.329l-166.521 621.429h128.871v64.286H276.286v-64.286h108.45l166.5-621.429H426.286V127.714h303.857z" fill="currentColor"/></svg>'},{id:"underline",title:i("mark.underline"),iconHtml:'<svg viewBox="0 0 1024 1024" width="15" height="15" aria-hidden="true"><path d="M512 123.639a36.409 36.409 0 0 1 33.642 22.525l230.59 558.27a36.409 36.409 0 1 1-67.284 27.768L638.072 560.545H385.928l-70.876 171.656a36.409 36.409 0 1 1-67.332-27.768l230.59-558.27A36.409 36.409 0 0 1 512 123.639z m-95.974 364.089h191.948L512 255.439l-95.974 232.289zM769.289 827.544c19.418 0 38.836 14.564 38.836 38.836 0 19.418-14.564 33.982-29.127 33.982H259.565c-19.418 0-38.836-14.564-38.836-38.836 0-19.418 14.564-33.982 29.127-33.982h519.433z" fill="currentColor"/></svg>'},{id:"strikethrough",title:i("mark.strikethrough"),iconHtml:'<svg viewBox="0 0 1024 1024" width="15" height="15" aria-hidden="true"><path d="M182.044 490.667h659.911a34.133 34.133 0 0 1 4.642 67.948l-4.597 0.319h-135.395c40.05 37 60.803 81.601 60.803 133.575 0 128.569-147.092 211.171-307.382 192.512-101.717-11.833-173.352-52.565-210.944-122.971a34.133 34.133 0 0 1 60.211-32.176c25.942 48.606 77.46 77.915 158.606 87.381 124.837 14.473 231.242-45.283 231.242-124.746 0-53.339-36.636-96.802-116.736-131.345l-5.279-2.23H182.044a34.133 34.133 0 0 1-33.815-29.492L147.911 524.8a34.133 34.133 0 0 1 29.491-33.815l4.642-0.318z m68.767-176.447c6.918-128.796 128.432-203.343 287.812-184.82 99.579 11.56 175.81 47.923 226.737 109.636a34.133 34.133 0 1 1-52.657 43.463c-38.775-47.013-98.759-75.639-181.999-85.288-123.654-14.381-211.627 36.591-211.627 117.009 0 35.135 10.65 61.349 37.774 90.203l5.826 6.007c4.278 4.369 8.966 8.875 11.377 10.923l1.411 0.91H288.085l-1.092-1.729c-6.508-9.376-38.958-54.386-36.182-106.314z" fill="currentColor"/></svg>'},{id:"code",title:i("mark.inlineCode"),iconHtml:'<svg viewBox="0 0 1024 1024" width="15" height="15" aria-hidden="true"><path d="M197.802 747.664v-145.287a58.916 58.916 0 0 0-58.916-58.916h-19.619v-62.922h19.619a58.916 58.916 0 0 0 58.916-58.916V276.336a117.832 117.832 0 0 1 117.832-117.832h39.297v78.535h-39.356a39.297 39.297 0 0 0-39.238 39.297v161.017A78.594 78.594 0 0 1 222.37 512a78.594 78.594 0 0 1 53.967 74.646V747.664a39.238 39.238 0 0 0 39.238 39.238h39.356v78.594h-39.356a117.832 117.832 0 0 1-117.832-117.832z m628.456-145.287V747.664a117.832 117.832 0 0 1-117.832 117.832h-39.356v-78.594h39.356a39.238 39.238 0 0 0 39.238-39.238v-161.017A78.535 78.535 0 0 1 801.63 512a78.594 78.594 0 0 1-53.967-74.646V276.336a39.297 39.297 0 0 0-39.238-39.297h-39.356V158.504h39.356a117.832 117.832 0 0 1 117.832 117.832v145.287a58.916 58.916 0 0 0 58.916 58.916h19.56v62.922h-19.56a58.916 58.916 0 0 0-58.916 58.916z" fill="currentColor"/></svg>'}]),bt=t.computed(()=>{const R=r.blockType,b=r.blockAttrs,D=(Ne,E)=>R===Ne&&(E===void 0||Number(b.level)===E);return[{id:"text",label:i("turnInto.paragraph"),iconHtml:el,active:D("paragraph"),convertType:"paragraph"},{id:"h1",label:i("turnInto.h1"),iconHtml:tl,active:D("heading",1),convertType:"heading",convertAttrs:{level:1}},{id:"h2",label:i("turnInto.h2"),iconHtml:nl,active:D("heading",2),convertType:"heading",convertAttrs:{level:2}},{id:"h3",label:i("turnInto.h3"),iconHtml:ol,active:D("heading",3),convertType:"heading",convertAttrs:{level:3}},{id:"h4",label:i("turnInto.h4"),iconHtml:rl,active:D("heading",4),convertType:"heading",convertAttrs:{level:4}},{id:"h5",label:i("turnInto.h5"),iconHtml:ll,active:D("heading",5),convertType:"heading",convertAttrs:{level:5}},{id:"h6",label:i("turnInto.h6"),iconHtml:il,active:D("heading",6),convertType:"heading",convertAttrs:{level:6}},{id:"bullet",label:i("turnInto.bullet"),iconHtml:sl,active:D("bulletList"),convertType:"bulletList"},{id:"ordered",label:i("turnInto.ordered"),iconHtml:cl,active:D("orderedList"),convertType:"orderedList"},{id:"todo",label:i("turnInto.todo"),iconHtml:al,active:D("todoList"),convertType:"todoList",convertAttrs:{checked:!1}},{id:"quote",label:i("turnInto.quote"),iconHtml:dl,active:D("quote"),convertType:"quote"},{id:"code",label:i("turnInto.code"),iconHtml:ul,active:D("codeBlock"),convertType:"codeBlock",convertAttrs:{language:"plain"}}]}),vt=t.computed(()=>{const R=bt.value.find(b=>b.active);return R?R.label:i("turnInto.paragraph")}),nt=t.computed(()=>[{id:"left",label:i("align.left"),value:"left"},{id:"center",label:i("align.center"),value:"center"},{id:"right",label:i("align.right"),value:"right"},{id:"justify",label:i("align.justify"),value:"justify"}]),Pe=t.computed(()=>[{id:"top",label:i("verticalAlign.top"),value:"top"},{id:"middle",label:i("verticalAlign.middle"),value:"middle"},{id:"bottom",label:i("verticalAlign.bottom"),value:"bottom"}]),mt=Xi,de=ji;function at(){var T;const R=a.value,b=ne.value;if(!R||!b){te.value=!1;return}const D=b.scrollLeft;b.style.maxWidth="",b.offsetWidth;const ce=b.scrollWidth,Ne=r.mobile?Math.max(120,(((T=R.parentElement)==null?void 0:T.clientWidth)??R.clientWidth)-8):Math.max(200,document.documentElement.clientWidth-32),E=Gf*2,_=Ne-E;if(ce>_){te.value=!0,b.style.maxWidth=`${_}px`;const I=Math.max(0,b.scrollWidth-b.clientWidth);b.scrollLeft=Math.min(D,I),Ke()}else te.value=!1,b.style.maxWidth="",X.value=!1,B.value=!1}function Ke(){const R=ne.value;R&&(X.value=R.scrollLeft>0,B.value=R.scrollLeft+R.clientWidth<R.scrollWidth-1)}function _e(R){S.value=null;const b=ne.value;b&&(b.scrollLeft+=R*Wf,Ke())}let Rt=null,ot=0,It=0,P=!1,k=!1;function W(R){if(!P)return;const b=R.touches[0];if(!b)return;const D=Math.abs(b.clientX-ot),ce=Math.abs(b.clientY-It);(D>es||ce>es)&&(k||(S.value=null),k=!0)}function ye(R){if(!P)return;const b=Rt;Rt=null,P=!1;const D=k;k=!1,D||(R.cancelable&&R.preventDefault(),b&&b())}function Te(R,b){b.cancelable&&b.preventDefault(),_e(R)}function $e(R,b){const D=b.touches[0];D&&(ot=D.clientX,It=D.clientY),Rt=R,P=!0,k=!1}t.watch([()=>r.visible,()=>r.selectionRect,a,()=>r.mobile],async()=>{if(r.mobile){r.visible&&at();return}if(!r.visible||!r.selectionRect||!r.rootEl)return;const R=a.value;if(!R)return;at(),await t.nextTick();const b=R.getBoundingClientRect(),D=b.width,ce=Math.max(b.height,ml);L.value=r.tableMode?qi(r.rootEl,r.selectionRect,{width:D,height:ce}):Gi(r.rootEl,r.selectionRect,{width:D,height:ce})},{flush:"post",immediate:!0});const Ct=t.computed(()=>({top:"0px",left:"0px",width:"100vw",height:"100vh"})),Qt=t.computed(()=>{const R=a.value,b=(R==null?void 0:R.offsetWidth)??qf,D=document.documentElement.clientWidth,ce=8;let Ne=L.value.left;const E=Math.max(ce,D-b-ce);Ne=Math.max(ce,Math.min(E,Ne));const _={top:`${L.value.top}px`,left:`${Ne}px`};if(r.selectionRect){const I=r.selectionRect.left+r.selectionRect.width/2-Ne,V=Math.max(10,Math.min(b-10,I));_["--ht-arrow-x"]=`${V}px`}return _});async function Lt(R){S.value=S.value===R?null:R,S.value&&(await t.nextTick(),Ye())}function Ye(){const R=S.value;if(!R)return;const b=R==="type"?d.value:R==="align"?u.value:R==="verticalAlign"?f.value:p.value,D=R==="type"?m.value:R==="align"?h.value:R==="verticalAlign"?y.value:N.value;if(!b||!D)return;const ce=D.getBoundingClientRect(),Ne=window.innerHeight,E=6,_=Math.floor(Ne-ce.bottom-E),T=Math.floor(ce.top-E),I=b.scrollHeight;if(r.mobile){const ie=document.documentElement.clientHeight,me=10;if(s.value){G.value=!0,K.value=Math.max(120,T-me);const ge=ie-ce.top+E;if(R==="color"){const we=document.documentElement.clientWidth;M.value={left:8,bottom:ge,right:Math.max(8,we-ce.right)}}else M.value={left:Math.max(8,ce.left),bottom:ge}}else{G.value=!1,K.value=Math.max(120,_-me);const ge=ce.bottom+E;if(R==="color"){const we=document.documentElement.clientWidth;M.value={left:8,top:ge,right:Math.max(8,we-ce.right)}}else M.value={left:Math.max(8,ce.left),top:ge}}t.nextTick($t);return}M.value=null;let V=!1;if(r.rootEl&&a.value){const ie=r.rootEl.getBoundingClientRect(),me=a.value.getBoundingClientRect();ie.bottom-me.bottom<ts&&T>ts&&(V=!0)}let q=!1,j;V?(q=!0,j=T):I<=_?(q=!1,j=_):T>_?(q=!0,j=T):(q=!1,j=_),G.value=q,K.value=Math.max(120,Math.min(j,360)),t.nextTick($t)}function $t(){const R=F.value;if(!R){Y.value=!1,ae.value=!1;return}Y.value=R.scrollTop>1,ae.value=R.scrollTop+R.clientHeight<R.scrollHeight-1}function pn(){const R=F.value;R&&(R.scrollTop-=R.clientHeight*.8)}function hn(){const R=F.value;R&&(R.scrollTop+=R.clientHeight*.8)}dr(F,$t);function Qn(R){var D,ce,Ne,E,_;if(l("interacting"),r.tableMode||r.cellEditMode){R.convertType==="heading"&&((D=R.convertAttrs)!=null&&D.level)?l("tableType",`heading${R.convertAttrs.level}`):l("tableType",R.convertType),S.value=null,r.tableMode&&l("close");return}const b=kt();if(b){for(const T of b.ranges)(Ne=(ce=c.commands).convertBlock)==null||Ne.call(ce,{id:T.id,type:R.convertType,attrs:R.convertAttrs??{}});S.value=null,l("close");return}w.value&&((_=(E=c.commands).convertBlock)==null||_.call(E,{id:w.value,type:R.convertType,attrs:R.convertAttrs??{}}),S.value=null,l("close"))}function gn(R){var D,ce,Ne,E;if(l("interacting"),r.tableMode||r.cellEditMode){l("tableAlign",R),S.value=null;return}const b=kt();if(b){for(const _ of b.ranges)(ce=(D=c.commands).setBlockAlign)==null||ce.call(D,{id:_.id,align:R});S.value=null;return}w.value&&((E=(Ne=c.commands).setBlockAlign)==null||E.call(Ne,{id:w.value,align:R}),S.value=null)}function Me(R){if(r.tableMode||r.cellEditMode){l("tableVerticalAlign",R),S.value=null;return}S.value=null}function Se(R){var ce,Ne,E,_;if(l("interacting"),r.tableMode){l("tableTextColor",R==="default"?null:R),S.value=null;return}if(r.cellEditMode){const T=window.getSelection();if(T&&T.rangeCount>0&&!T.isCollapsed){const I=T.getRangeAt(0);if(R==="default"){const V=I.extractContents();V.querySelectorAll('span[class*="be-color-"]').forEach(q=>{const j=q.className.replace(/be-color-\w+/g,"").trim();if(j)q.className=j;else{for(;q.firstChild;)q.parentNode.insertBefore(q.firstChild,q);q.parentNode.removeChild(q)}}),I.insertNode(V)}else{const V=document.createElement("span");V.className=`be-color-${R}`,V.appendChild(I.extractContents()),I.insertNode(V),T.removeAllRanges();const q=document.createRange();q.selectNodeContents(V),T.addRange(q)}}S.value=null,Oe();return}const b=kt();if(b){for(const T of b.ranges)(Ne=(ce=c.commands).setInlineMark)==null||Ne.call(ce,{id:T.id,markType:"color",attrs:R==="default"?null:{color:R},from:T.from,to:T.to});return}if(!w.value)return;const D=Fe();D&&((_=(E=c.commands).setInlineMark)==null||_.call(E,{id:w.value,markType:"color",attrs:R==="default"?null:{color:R},from:D.from,to:D.to}),t.nextTick(()=>{var me;const T=window.getSelection(),I=(me=r.rootEl)==null?void 0:me.querySelector(`[data-block-id="${r.blockId}"]`),V=T&&T.rangeCount>0?T.getRangeAt(0):null,q=!!I,j=!!(V&&I&&I.contains(V.commonAncestorContainer)),ie=!!(V&&!V.collapsed&&j);if(!q){l("close");return}if(!ie&&!j){l("close");return}Oe(),Ce()}))}function ze(R){var ce,Ne,E,_;if(l("interacting"),r.tableMode){l("tableBgColor",R==="default"?null:R),S.value=null;return}if(r.cellEditMode){const T=window.getSelection();if(T&&T.rangeCount>0&&!T.isCollapsed){const I=T.getRangeAt(0);if(R==="default"){const V=I.extractContents();V.querySelectorAll('span[class*="be-bg-"]').forEach(q=>{const j=q.className.replace(/be-bg-\w+/g,"").trim();if(j)q.className=j;else{for(;q.firstChild;)q.parentNode.insertBefore(q.firstChild,q);q.parentNode.removeChild(q)}}),I.insertNode(V)}else{const V=document.createElement("span");V.className=`be-bg-${R}`,V.appendChild(I.extractContents()),I.insertNode(V),T.removeAllRanges();const q=document.createRange();q.selectNodeContents(V),T.addRange(q)}}S.value=null,Oe();return}const b=kt();if(b){for(const T of b.ranges)(Ne=(ce=c.commands).setInlineMark)==null||Ne.call(ce,{id:T.id,markType:"bgColor",attrs:R==="default"?null:{bgColor:R},from:T.from,to:T.to});return}if(!w.value)return;const D=Fe();D&&((_=(E=c.commands).setInlineMark)==null||_.call(E,{id:w.value,markType:"bgColor",attrs:R==="default"?null:{bgColor:R},from:D.from,to:D.to}),t.nextTick(()=>{var me;const T=window.getSelection(),I=(me=r.rootEl)==null?void 0:me.querySelector(`[data-block-id="${r.blockId}"]`),V=T&&T.rangeCount>0?T.getRangeAt(0):null,q=!!I,j=!!(V&&I&&I.contains(V.commonAncestorContainer)),ie=!!(V&&!V.collapsed&&j);if(!q){l("close");return}if(!ie&&!j){l("close");return}Oe(),Ce()}))}function Oe(){if(r.tableMode){oe.value=r.tableActiveColor??"",ue.value=r.tableActiveBgColor??"";return}if(r.visible&&r.blockId&&r.rootEl){const I=qe(),V=window.getSelection();if(I&&V&&V.rangeCount>0){const q=V.getRangeAt(0);if(!q.collapsed&&I.contains(q.commonAncestorContainer)){const j=new Set,ie=new Set,me=[],he=document.createTreeWalker(I,NodeFilter.SHOW_TEXT);for(;he.nextNode();){const ge=he.currentNode;(ge.nodeValue??"").length!==0&&q.intersectsNode(ge)&&me.push(ge)}for(const ge of me){let we=ge.parentNode;for(;we&&we!==I;){if(we.nodeType===Node.ELEMENT_NODE){const Be=we.className;if(typeof Be=="string"){const De=Be.match(/be-color-(\w+)/);De&&j.add(De[1]);const rt=Be.match(/be-bg-(\w+)/);rt&&ie.add(rt[1])}}we=we.parentNode}}if(j.size>0||ie.size>0){oe.value=j.size===1?[...j][0]:"",ue.value=ie.size===1?[...ie][0]:"";return}}}}const R=C.value,b=r.blockId?R.doc.blocks.get(r.blockId):void 0;if(!b){oe.value="",ue.value="";return}const D=R.selection;let ce,Ne;if(D.kind==="text"&&D.anchor.blockId===r.blockId&&D.focus.blockId===r.blockId)ce=Math.min(D.anchor.offset,D.focus.offset),Ne=Math.max(D.anchor.offset,D.focus.offset);else{const I=Fe();ce=I?I.from:0,Ne=I?I.to:Ae(b.content).length}if(ce>=Ne){oe.value="",ue.value="";return}const E=new Set,_=new Set;let T=0;for(const I of b.content){if(I.type!=="text")continue;const V=T,q=T+I.text.length;if(q>ce&&V<Ne&&I.marks)for(const j of I.marks)j.type==="color"&&j.attrs&&typeof j.attrs.color=="string"&&E.add(j.attrs.color),j.type==="bgColor"&&j.attrs&&typeof j.attrs.bgColor=="string"&&_.add(j.attrs.bgColor);T=q}oe.value=E.size===1?[...E][0]:"",ue.value=_.size===1?[..._][0]:""}function Fe(){if(!r.blockId||!r.rootEl)return null;const R=r.rootEl.querySelector(`[data-block-id="${r.blockId}"]`);if(!R)return null;const b=window.getSelection();if(!b||b.rangeCount===0)return null;const D=b.getRangeAt(0);if(D.collapsed||!R.contains(D.commonAncestorContainer))return null;const ce=document.createRange();ce.selectNodeContents(R),ce.setEnd(D.startContainer,D.startOffset);const Ne=ce.toString().length;ce.setEnd(D.endContainer,D.endOffset);const E=ce.toString().length;return{from:Math.min(Ne,E),to:Math.max(Ne,E)}}function kt(){const R=C.value.selection;if(R.kind!=="text"||!Pt(R))return null;const b=C.value.doc,D=In(b),ce=D.indexOf(R.anchor.blockId),Ne=D.indexOf(R.focus.blockId);if(ce===-1||Ne===-1)return null;const[E,_]=ce<=Ne?[R.anchor,R.focus]:[R.focus,R.anchor],T=D.indexOf(E.blockId),I=D.indexOf(_.blockId);if(T===-1||I===-1||T>I)return null;const V=[];for(let q=T;q<=I;q++){const j=D[q],ie=b.blocks.get(j);if(!ie)continue;const me=Ae(ie.content).length;let he=0,ge=me;q===T&&(he=Math.min(E.offset,me)),q===I&&(ge=Math.min(_.offset,me)),V.push({id:j,from:he,to:ge})}return{ranges:V}}function dt(){const R=C.value.selection;if(R.kind!=="text"||!Pt(R))return null;const b=kt();if(!b)return null;const D=C.value.doc,ce=[],Ne=[];for(const E of b.ranges){const _=D.blocks.get(E.id);if(!_)continue;const[,T]=Ut(_.content,E.from),[I]=Ut(T,E.to-E.from);ce.push(Ae(I)),Ne.push(Zn(I))}return{text:ce.join(`
|
|
12
|
-
`),html:Ne.join("<br>")}}function Ot(R){var ce,Ne,E,_;if(l("interacting"),r.tableMode){l("tableMark",R);return}if(r.cellEditMode){const I={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikeThrough",code:"insertHTML"}[R];if(I==="insertHTML"){const V=window.getSelection();if(V&&V.rangeCount>0&&!V.isCollapsed){const q=V.getRangeAt(0),j=document.createElement("code");try{j.appendChild(q.extractContents()),q.insertNode(j),V.removeAllRanges();const ie=document.createRange();ie.selectNodeContents(j),V.addRange(ie)}catch{}}}else I&&document.execCommand(I);Ce();return}const b=kt();if(b){for(const T of b.ranges)(Ne=(ce=c.commands).toggleMark)==null||Ne.call(ce,{id:T.id,markType:R,from:T.from,to:T.to});return}if(!w.value)return;const D=Fe();D&&((_=(E=c.commands).toggleMark)==null||_.call(E,{id:w.value,markType:R,from:D.from,to:D.to}),t.nextTick(()=>{var me;pe.value++;const T=window.getSelection(),I=(me=r.rootEl)==null?void 0:me.querySelector(`[data-block-id="${r.blockId}"]`),V=T&&T.rangeCount>0?T.getRangeAt(0):null,q=!!I,j=!!(V&&I&&I.contains(V.commonAncestorContainer)),ie=!!(V&&!V.collapsed&&j);if(!q){l("close");return}if(!ie&&!j){l("close");return}Ce(),Oe()}))}function zt(){if(l("interacting"),S.value=null,r.cellEditMode){l("linkClick",w.value??"",0,0);return}if(w.value){const R=Fe();R&&l("linkClick",w.value,R.from,R.to)}}function ln(){var ce,Ne;if(r.tableMode){l("tableCopy"),l("close");return}const R=dt();if(R){(ce=navigator.clipboard)==null||ce.writeText(R.text),l("close");return}const b=window.getSelection(),D=b?b.toString():"";D&&((Ne=navigator.clipboard)==null||Ne.writeText(D)),l("close")}n({});async function Ft(){if(r.mobile){r.visible&&at(),S.value&&Ye(),$t(),Ce(),Oe();return}if(r.visible&&r.selectionRect&&r.rootEl&&a.value){at(),await t.nextTick();const R=a.value.getBoundingClientRect();L.value=r.tableMode?qi(r.rootEl,r.selectionRect,{width:R.width,height:Math.max(R.height,ml)}):Gi(r.rootEl,r.selectionRect,{width:R.width,height:Math.max(R.height,ml)})}S.value&&Ye(),$t(),Ce(),Oe()}function bn(R){if(!S.value)return;const b=[d.value,u.value,f.value,p.value],D=[m.value,h.value,y.value,N.value];for(const ce of b)if(ce&&ce.contains(R))return;for(const ce of D)if(ce&&ce.contains(R))return;S.value=null}function Rn(R){if(!r.visible)return;const b=a.value;if(b&&b.contains(R.target)){R.preventDefault();return}bn(R.target)}function kn(R){if(!r.visible||!R.touches[0])return;const D=R.target,ce=a.value;if(ce&&ce.contains(D)){const Ne=ne.value;if(Ne&&Ne.contains(D))return;R.preventDefault();return}bn(D)}t.watch(()=>r.visible,R=>{R&&t.nextTick(()=>{Ce(),Oe()})}),t.onMounted(()=>{window.addEventListener("scroll",Ft,!0),window.addEventListener("resize",Ft),window.addEventListener("mousedown",Rn,!0),window.addEventListener("touchstart",kn,!0),document.addEventListener("selectionchange",Kt),x=c.subscribe(()=>{t.nextTick(()=>{const R=c.getState();C.value=R,pe.value++,Ce(),Oe()})})}),t.onBeforeUnmount(()=>{window.removeEventListener("scroll",Ft,!0),window.removeEventListener("resize",Ft),window.removeEventListener("mousedown",Rn,!0),window.removeEventListener("touchstart",kn,!0),document.removeEventListener("selectionchange",Kt),x==null||x(),x=null});function Kt(){r.visible&&yn===null&&(yn=requestAnimationFrame(()=>{yn=null,r.visible&&(Ce(),Oe())}))}let yn=null;return(R,b)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:e.mobile},[t.createElementVNode("div",{class:t.normalizeClass(["hover-toolbar-shell",{visible:e.visible,"mobile-shell":e.mobile,"mobile-visible":e.mobile&&e.visible}]),style:t.normalizeStyle(e.mobile?void 0:Ct.value),"aria-hidden":!e.visible},[t.createElementVNode("div",{ref_key:"toolbarEl",ref:a,class:t.normalizeClass(["hover-toolbar",{above:L.value.above,below:!L.value.above,"ht-overflow":te.value,"mobile-mode":e.mobile}]),style:t.normalizeStyle(e.mobile?void 0:Qt.value),role:"toolbar","aria-label":t.unref(i)("hoverToolbar.label")},[te.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:t.normalizeClass(["ht-nav-btn ht-nav-left",{disabled:!X.value}]),title:t.unref(i)("ui.scrollLeft"),"aria-label":t.unref(i)("ui.scrollLeft"),onMousedown:b[0]||(b[0]=t.withModifiers(D=>_e(-1),["prevent","stop"])),onTouchstart:b[1]||(b[1]=t.withModifiers(()=>{},["stop"])),onTouchend:b[2]||(b[2]=t.withModifiers(D=>Te(-1,D),["stop"])),onClick:b[3]||(b[3]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[39]||(b[39]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M7.5 3L4.5 6L7.5 9",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],42,Qu)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"htContentEl",ref:ne,class:t.normalizeClass(["ht-content",{"dropdown-open":!e.mobile&&!!S.value}]),onScroll:Ke,onTouchmovePassive:W,onTouchend:t.withModifiers(ye,["stop"])},[t.createElementVNode("div",Ju,[t.createElementVNode("button",{ref_key:"typeBtnEl",ref:m,class:t.normalizeClass(["ht-btn ht-type-btn",{open:S.value==="type",disabled:St.value}]),title:t.unref(i)("hoverToolbar.typeBtnTitle"),disabled:St.value,onMousedown:b[4]||(b[4]=t.withModifiers(D=>!St.value&&Lt("type"),["prevent","stop"])),onTouchstart:b[5]||(b[5]=t.withModifiers(D=>{$e(()=>{St.value||Lt("type")},D)},["stop"])),onClick:b[6]||(b[6]=t.withModifiers(()=>{},["prevent","stop"]))},[t.createElementVNode("span",tf,t.toDisplayString(vt.value),1),b[40]||(b[40]=t.createElementVNode("svg",{class:"ht-caret",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],42,ef),(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:!e.mobile},[S.value==="type"?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"typeDropdownEl",ref:d,class:t.normalizeClass(["ht-dropdown",[e.mobile?"ht-dropdown-mobile":"",{above:G.value}]]),style:t.normalizeStyle([$.value,A.value])},[Y.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(i)("ui.scrollUp"),onMousedown:t.withModifiers(pn,["prevent"])},[...b[41]||(b[41]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,nf)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:F,class:"ht-dropdown-scroll",onScroll:$t},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(bt.value,D=>(t.openBlock(),t.createElementBlock("button",{key:D.id,class:t.normalizeClass(["ht-dropdown-item",{active:D.active}]),onMousedown:t.withModifiers(ce=>Qn(D),["prevent","stop"])},[t.createVNode(dn,{class:"ht-dropdown-icon",html:D.iconHtml},null,8,["html"]),t.createElementVNode("span",null,t.toDisplayString(D.label),1),D.active?(t.openBlock(),t.createElementBlock("svg",rf,[...b[42]||(b[42]=[t.createElementVNode("path",{d:"M2.5 6L5 8.5L9.5 4",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):t.createCommentVNode("",!0)],42,of))),128))],544),ae.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(i)("ui.scrollDown"),onMousedown:t.withModifiers(hn,["prevent"])},[...b[43]||(b[43]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,lf)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)],8,["disabled"]))]),t.createElementVNode("div",sf,[t.createElementVNode("button",{ref_key:"alignBtnEl",ref:h,class:t.normalizeClass(["ht-btn ht-icon-only",{open:S.value==="align",disabled:At.value}]),title:t.unref(i)("hoverToolbar.alignBtnTitle"),disabled:At.value,onMousedown:b[7]||(b[7]=t.withModifiers(D=>!At.value&&Lt("align"),["prevent","stop"])),onTouchstart:b[8]||(b[8]=t.withModifiers(D=>{$e(()=>{At.value||Lt("align")},D)},["stop"])),onClick:b[9]||(b[9]=t.withModifiers(()=>{},["prevent","stop"]))},[(t.openBlock(),t.createElementBlock("svg",af,[U.value==="left"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[b[44]||(b[44]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[45]||(b[45]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"10",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[46]||(b[46]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"12",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):U.value==="center"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[b[47]||(b[47]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[48]||(b[48]=t.createElementVNode("line",{x1:"4",y1:"8",x2:"12",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[49]||(b[49]=t.createElementVNode("line",{x1:"3",y1:"12",x2:"13",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):U.value==="right"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[b[50]||(b[50]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[51]||(b[51]=t.createElementVNode("line",{x1:"6",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[52]||(b[52]=t.createElementVNode("line",{x1:"4",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:3},[b[53]||(b[53]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[54]||(b[54]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[55]||(b[55]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64))]))],42,cf),(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:!e.mobile},[S.value==="align"?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"alignDropdownEl",ref:u,class:t.normalizeClass(["ht-dropdown",[e.mobile?"ht-dropdown-mobile":"",{above:G.value}]]),style:t.normalizeStyle([$.value,A.value])},[Y.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(i)("ui.scrollUp"),onMousedown:t.withModifiers(pn,["prevent"])},[...b[56]||(b[56]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,df)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:F,class:"ht-dropdown-scroll",onScroll:$t},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(nt.value,D=>(t.openBlock(),t.createElementBlock("button",{key:D.id,class:t.normalizeClass(["ht-dropdown-item ht-align-item",{active:U.value===D.value}]),onMousedown:t.withModifiers(ce=>gn(D.value),["prevent","stop"])},[(t.openBlock(),t.createElementBlock("svg",ff,[D.value==="left"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[b[57]||(b[57]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[58]||(b[58]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"10",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[59]||(b[59]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"12",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):D.value==="center"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[b[60]||(b[60]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[61]||(b[61]=t.createElementVNode("line",{x1:"4",y1:"8",x2:"12",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[62]||(b[62]=t.createElementVNode("line",{x1:"3",y1:"12",x2:"13",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):D.value==="right"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[b[63]||(b[63]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[64]||(b[64]=t.createElementVNode("line",{x1:"6",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[65]||(b[65]=t.createElementVNode("line",{x1:"4",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:3},[b[66]||(b[66]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[67]||(b[67]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[68]||(b[68]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64))])),t.createElementVNode("span",null,t.toDisplayString(D.label),1),U.value===D.value?(t.openBlock(),t.createElementBlock("svg",mf,[...b[69]||(b[69]=[t.createElementVNode("path",{d:"M2.5 6L5 8.5L9.5 4",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):t.createCommentVNode("",!0)],42,uf))),128))],544),ae.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(i)("ui.scrollDown"),onMousedown:t.withModifiers(hn,["prevent"])},[...b[70]||(b[70]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,pf)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)],8,["disabled"]))]),e.tableMode||e.cellEditMode?(t.openBlock(),t.createElementBlock("div",hf,[t.createElementVNode("button",{ref_key:"verticalAlignBtnEl",ref:y,class:t.normalizeClass(["ht-btn ht-icon-only",{open:S.value==="verticalAlign",disabled:At.value}]),title:t.unref(i)("hoverToolbar.verticalAlignBtnTitle"),disabled:At.value,onMousedown:b[10]||(b[10]=t.withModifiers(D=>!At.value&&Lt("verticalAlign"),["prevent","stop"])),onTouchstart:b[11]||(b[11]=t.withModifiers(D=>{$e(()=>{At.value||Lt("verticalAlign")},D)},["stop"])),onClick:b[12]||(b[12]=t.withModifiers(()=>{},["prevent","stop"]))},[(t.openBlock(),t.createElementBlock("svg",bf,[fe.value==="top"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[b[71]||(b[71]=t.createElementVNode("line",{x1:"2",y1:"3",x2:"14",y2:"3",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[72]||(b[72]=t.createElementVNode("line",{x1:"4",y1:"7",x2:"12",y2:"7",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[73]||(b[73]=t.createElementVNode("line",{x1:"5",y1:"11",x2:"11",y2:"11",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):fe.value==="bottom"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[b[74]||(b[74]=t.createElementVNode("line",{x1:"5",y1:"5",x2:"11",y2:"5",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[75]||(b[75]=t.createElementVNode("line",{x1:"4",y1:"9",x2:"12",y2:"9",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[76]||(b[76]=t.createElementVNode("line",{x1:"2",y1:"13",x2:"14",y2:"13",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[b[77]||(b[77]=t.createElementVNode("line",{x1:"5",y1:"3",x2:"11",y2:"3",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[78]||(b[78]=t.createElementVNode("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[79]||(b[79]=t.createElementVNode("line",{x1:"5",y1:"13",x2:"11",y2:"13",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64))]))],42,gf),(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:!e.mobile},[S.value==="verticalAlign"?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"verticalAlignDropdownEl",ref:f,class:t.normalizeClass(["ht-dropdown",[e.mobile?"ht-dropdown-mobile":"",{above:G.value}]]),style:t.normalizeStyle([$.value,A.value])},[Y.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(i)("ui.scrollUp"),onMousedown:t.withModifiers(pn,["prevent"])},[...b[80]||(b[80]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,kf)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:F,class:"ht-dropdown-scroll",onScroll:$t},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(Pe.value,D=>(t.openBlock(),t.createElementBlock("button",{key:D.id,class:t.normalizeClass(["ht-dropdown-item ht-align-item",{active:fe.value===D.value}]),onMousedown:t.withModifiers(ce=>Me(D.value),["prevent","stop"])},[(t.openBlock(),t.createElementBlock("svg",wf,[D.value==="top"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[b[81]||(b[81]=t.createElementVNode("line",{x1:"2",y1:"3",x2:"14",y2:"3",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[82]||(b[82]=t.createElementVNode("line",{x1:"4",y1:"7",x2:"12",y2:"7",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[83]||(b[83]=t.createElementVNode("line",{x1:"5",y1:"11",x2:"11",y2:"11",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):D.value==="bottom"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[b[84]||(b[84]=t.createElementVNode("line",{x1:"5",y1:"5",x2:"11",y2:"5",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[85]||(b[85]=t.createElementVNode("line",{x1:"4",y1:"9",x2:"12",y2:"9",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[86]||(b[86]=t.createElementVNode("line",{x1:"2",y1:"13",x2:"14",y2:"13",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[b[87]||(b[87]=t.createElementVNode("line",{x1:"5",y1:"3",x2:"11",y2:"3",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[88]||(b[88]=t.createElementVNode("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[89]||(b[89]=t.createElementVNode("line",{x1:"5",y1:"13",x2:"11",y2:"13",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64))])),t.createElementVNode("span",null,t.toDisplayString(D.label),1),fe.value===D.value?(t.openBlock(),t.createElementBlock("svg",Ef,[...b[90]||(b[90]=[t.createElementVNode("path",{d:"M2.5 6L5 8.5L9.5 4",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):t.createCommentVNode("",!0)],42,yf))),128))],544),ae.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(i)("ui.scrollDown"),onMousedown:t.withModifiers(hn,["prevent"])},[...b[91]||(b[91]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,vf)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)],8,["disabled"]))])):t.createCommentVNode("",!0),b[100]||(b[100]=t.createElementVNode("div",{class:"ht-sep"},null,-1)),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(qt.value,D=>(t.openBlock(),t.createElementBlock("button",{key:D.id,class:t.normalizeClass(["ht-btn ht-icon-only",{active:xe.value.has(D.id),disabled:Et(D.id)}]),title:D.title,disabled:Et(D.id),onMousedown:t.withModifiers(ce=>!Et(D.id)&&Ot(D.id),["prevent","stop"]),onTouchstart:t.withModifiers(ce=>{$e(()=>{Et(D.id)||Ot(D.id)},ce)},["stop"]),onClick:b[13]||(b[13]=t.withModifiers(()=>{},["prevent","stop"]))},[t.createVNode(dn,{html:D.iconHtml},null,8,["html"])],42,Cf))),128)),e.tableMode?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("button",{key:1,class:t.normalizeClass(["ht-btn ht-icon-only",{active:xe.value.has("link"),disabled:Et("link")}]),title:t.unref(i)("hoverToolbar.linkBtnTitle"),disabled:Et("link"),onMousedown:b[14]||(b[14]=t.withModifiers(D=>!Et("link")&&zt(),["prevent","stop"])),onTouchstart:b[15]||(b[15]=t.withModifiers(D=>{$e(()=>{Et("link")||zt()},D)},["stop"])),onClick:b[16]||(b[16]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[92]||(b[92]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M394.666667 298.666667a32 32 0 0 1 4.693333 63.658666l-4.693333 0.341334H298.666667a149.333333 149.333333 0 0 0-8.789334 298.410666L298.666667 661.333333h96a32 32 0 0 1 4.693333 63.658667L394.666667 725.333333H298.666667a213.333333 213.333333 0 0 1-10.666667-426.410666L298.666667 298.666667h96zM725.333333 298.666667a213.333333 213.333333 0 0 1 10.666667 426.410666L725.333333 725.333333h-96a32 32 0 0 1-4.693333-63.658666l4.693333-0.341334H725.333333a149.333333 149.333333 0 0 0 8.789334-298.410666L725.333333 362.666667h-96a32 32 0 0 1-4.693333-63.658667L629.333333 298.666667H725.333333zM298.666667 480h426.666666a32 32 0 0 1 4.352 63.701333L725.333333 544H298.666667a32 32 0 0 1-4.352-63.701333L298.666667 480h426.666666H298.666667z",fill:"currentColor"})],-1)])],42,Tf)),b[101]||(b[101]=t.createElementVNode("div",{class:"ht-sep"},null,-1)),t.createElementVNode("div",_f,[t.createElementVNode("button",{ref_key:"colorBtnEl",ref:N,class:t.normalizeClass(["ht-btn ht-icon-only",{open:S.value==="color",disabled:Et("color")}]),title:t.unref(i)("hoverToolbar.colorBtnTitle"),disabled:Et("color"),onMousedown:b[17]||(b[17]=t.withModifiers(D=>!Et("color")&&Lt("color"),["prevent","stop"])),onTouchstart:b[18]||(b[18]=t.withModifiers(D=>{$e(()=>{Et("color")||Lt("color")},D)},["stop"])),onClick:b[19]||(b[19]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[93]||(b[93]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M163.797333 249.941333c125.44-167.082667 385.28-215.68 570.197334-100.693333 182.613333 113.493333 249.770667 331.818667 174.933333 536.618667-70.613333 193.408-256.682667 269.994667-390.784 172.714666-50.218667-36.437333-69.717333-82.133333-79.104-156.330666l-4.522667-42.112-1.92-16.981334c-5.248-39.850667-13.269333-57.685333-30.08-67.072-22.826667-12.714667-38.058667-13.013333-68.053333-1.408l-14.976 6.229334-7.637333 3.328c-43.264 18.773333-72.021333 25.386667-108.416 17.749333l-8.533334-2.005333-6.997333-2.005334c-118.997333-36.864-136.618667-198.272-24.106667-348.032z m41.984 286.549334l5.248 1.578666 5.717334 1.28c18.730667 3.712 34.730667 0.64 61.312-10.325333l25.685333-10.965333c51.285333-21.034667 84.693333-23.04 129.962667 2.133333 39.125333 21.845333 54.4 55.381333 62.165333 113.493333l2.261333 19.584 2.346667 22.698667 2.005333 18.005333c7.338667 58.069333 20.693333 89.173333 53.248 112.810667 97.066667 70.4 236.117333 13.184 293.12-142.890667 64.682667-177.152 7.424-363.264-148.650666-460.330666-156.8-97.450667-379.690667-55.722667-485.248 84.778666-88.533333 117.888-77.653333 225.28-9.173334 248.149334z m478.933334-85.077334a53.333333 53.333333 0 1 1 102.997333-27.605333 53.333333 53.333333 0 0 1-102.997333 27.605333z m21.077333 148.821334a53.333333 53.333333 0 1 1 103.04-27.605334 53.333333 53.333333 0 0 1-103.04 27.605334zM600.32 323.285333a53.333333 53.333333 0 1 1 103.04-27.605333 53.333333 53.333333 0 0 1-103.04 27.605333z m-1.194667 383.914667a53.333333 53.333333 0 1 1 102.997334-27.605333 53.333333 53.333333 0 0 1-102.997334 27.605333z m-149.205333-425.386667a53.333333 53.333333 0 1 1 103.04-27.562666 53.333333 53.333333 0 0 1-103.04 27.562666z",fill:"currentColor"})],-1)])],42,xf),(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:!e.mobile},[S.value==="color"?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"colorDropdownEl",ref:p,class:t.normalizeClass(["ht-dropdown ht-color-dropdown",[e.mobile?"ht-dropdown-mobile":"",{above:G.value}]]),style:t.normalizeStyle([$.value,A.value])},[Y.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(i)("ui.scrollUp"),onMousedown:t.withModifiers(pn,["prevent"])},[...b[94]||(b[94]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Mf)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:F,class:"ht-dropdown-scroll",onScroll:$t},[t.createElementVNode("div",Nf,[t.createElementVNode("div",Sf,t.toDisplayString(t.unref(i)("hoverToolbar.textColor")),1),t.createElementVNode("div",Af,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(mt),D=>(t.openBlock(),t.createElementBlock("button",{key:"tc-"+D.key,class:t.normalizeClass(["ht-swatch",{active:oe.value===D.key}]),title:t.unref(i)(D.key==="default"?"color.default":"color."+D.key),style:t.normalizeStyle({backgroundColor:D.displayCssValue??D.cssValue}),onMousedown:t.withModifiers(ce=>Se(D.key),["prevent","stop"])},null,46,If))),128))])]),t.createElementVNode("div",Bf,[t.createElementVNode("div",Rf,t.toDisplayString(t.unref(i)("hoverToolbar.bgColor")),1),t.createElementVNode("div",Lf,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(de),D=>(t.openBlock(),t.createElementBlock("button",{key:"bc-"+D.key,class:t.normalizeClass(["ht-swatch",[{active:ue.value===D.key},D.key==="default"?"ht-swatch--none":""]]),title:t.unref(i)(D.key==="default"?"color.none":"color."+D.key),style:t.normalizeStyle({backgroundColor:D.displayCssValue??D.cssValue}),onMousedown:t.withModifiers(ce=>ze(D.key),["prevent","stop"])},null,46,Of))),128))])])],544),ae.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(i)("ui.scrollDown"),onMousedown:t.withModifiers(hn,["prevent"])},[...b[95]||(b[95]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Df)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)],8,["disabled"]))]),b[102]||(b[102]=t.createElementVNode("div",{class:"ht-sep"},null,-1)),t.createElementVNode("button",{class:t.normalizeClass(["ht-btn ht-icon-only",{disabled:je.value}]),title:t.unref(i)("hoverToolbar.copySelection"),"aria-label":t.unref(i)("hoverToolbar.copySelection"),disabled:je.value,onMousedown:b[20]||(b[20]=t.withModifiers(D=>!je.value&&ln(),["prevent","stop"])),onTouchstart:b[21]||(b[21]=t.withModifiers(D=>{$e(()=>{je.value||ln()},D)},["stop"])),onClick:b[22]||(b[22]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[96]||(b[96]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1.5",fill:"none",stroke:"currentColor","stroke-width":"1.3"}),t.createElementVNode("path",{d:"M3 10.5V3.5C3 2.67 3.67 2 4.5 2H10",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"})],-1)])],42,$f),e.tableMode?(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[e.showMerge||e.showSplit||e.showHeaderRow||e.showDelete?(t.openBlock(),t.createElementBlock("div",Pf)):t.createCommentVNode("",!0),e.showMerge?(t.openBlock(),t.createElementBlock("button",{key:1,class:"ht-btn ht-icon-only",title:t.unref(i)("table.mergeCells"),onMousedown:b[23]||(b[23]=t.withModifiers(D=>l("merge"),["prevent","stop"])),onTouchstart:b[24]||(b[24]=t.withModifiers(D=>$e(()=>l("merge"),D),["stop"])),onClick:b[25]||(b[25]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[97]||(b[97]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15",fill:"currentColor","aria-hidden":"true"},[t.createElementVNode("path",{d:"M266.666667 128A138.666667 138.666667 0 0 0 128 266.666667v490.666666A138.666667 138.666667 0 0 0 266.666667 896h490.666666A138.666667 138.666667 0 0 0 896 757.333333V266.666667A138.666667 138.666667 0 0 0 757.333333 128H266.666667zM192 266.666667c0-41.216 33.450667-74.666667 74.666667-74.666667H469.333333v128H192V266.666667z m341.333333 437.333333h298.666667v53.333333a74.666667 74.666667 0 0 1-74.666667 74.666667H533.333333v-128z m298.666667-384h-298.666667v-128h224c41.216 0 74.666667 33.450667 74.666667 74.666667V320z m-362.666667 384v128H266.666667a74.666667 74.666667 0 0 1-74.666667-74.666667V704H469.333333zM192 384h640v256h-640V384z"})],-1)])],40,Hf)):t.createCommentVNode("",!0),e.showSplit?(t.openBlock(),t.createElementBlock("button",{key:2,class:"ht-btn ht-icon-only",title:t.unref(i)("table.splitCell"),onMousedown:b[26]||(b[26]=t.withModifiers(D=>l("split"),["prevent","stop"])),onTouchstart:b[27]||(b[27]=t.withModifiers(D=>$e(()=>l("split"),D),["stop"])),onClick:b[28]||(b[28]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[98]||(b[98]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15",fill:"currentColor","aria-hidden":"true"},[t.createElementVNode("path",{d:"M533.333333 426.666667H469.333333v170.666666h64v-170.666666z"}),t.createElementVNode("path",{d:"M128 266.666667A138.666667 138.666667 0 0 1 266.666667 128h490.666666A138.666667 138.666667 0 0 1 896 266.666667v490.666666A138.666667 138.666667 0 0 1 757.333333 896H266.666667A138.666667 138.666667 0 0 1 128 757.333333V266.666667zM266.666667 192A74.666667 74.666667 0 0 0 192 266.666667V320H469.333333v-128H266.666667z m565.333333 512h-298.666667v128h224a74.666667 74.666667 0 0 0 74.666667-74.666667V704z m0-437.333333a74.666667 74.666667 0 0 0-74.666667-74.666667H533.333333v128h298.666667V266.666667zM192 704v53.333333c0 41.216 33.450667 74.666667 74.666667 74.666667H469.333333v-128H192z m0-64h640V384h-640v256z"})],-1)])],40,Vf)):t.createCommentVNode("",!0),e.showHeaderRow?(t.openBlock(),t.createElementBlock("button",{key:3,class:t.normalizeClass(["ht-btn ht-icon-only",{active:e.headerRowActive}]),title:t.unref(i)("table.toggleHeader"),onMousedown:b[29]||(b[29]=t.withModifiers(D=>l("tableHeaderRow"),["prevent","stop"])),onTouchstart:b[30]||(b[30]=t.withModifiers(D=>$e(()=>l("tableHeaderRow"),D),["stop"])),onClick:b[31]||(b[31]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[99]||(b[99]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[t.createElementVNode("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1"}),t.createElementVNode("path",{d:"M2 6h12"}),t.createElementVNode("path",{d:"M5 2v4"})],-1)])],42,Uf)):t.createCommentVNode("",!0),e.showDelete?(t.openBlock(),t.createElementBlock(t.Fragment,{key:4},[e.showMerge||e.showSplit||e.showHeaderRow?(t.openBlock(),t.createElementBlock("div",zf)):t.createCommentVNode("",!0),t.createElementVNode("button",{class:"ht-btn ht-danger ht-icon-only",title:e.deleteLabel||t.unref(i)("hoverToolbar.deleteBlock"),onMousedown:b[32]||(b[32]=t.withModifiers(D=>l("delete"),["prevent","stop"])),onTouchstart:b[33]||(b[33]=t.withModifiers(D=>$e(()=>l("delete"),D),["stop"])),onClick:b[34]||(b[34]=t.withModifiers(()=>{},["prevent","stop"]))},[t.createVNode(dn,{html:e.deleteIcon||"<svg viewBox='0 0 1024 1024' width='15' height='15' fill='currentColor' aria-hidden='true'><path d='M128 266.666667A138.666667 138.666667 0 0 1 266.666667 128h490.666666A138.666667 138.666667 0 0 1 896 266.666667v246.272a276.096 276.096 0 0 0-64-30.250667V426.666667h-170.666667v56.021333a276.096 276.096 0 0 0-64 30.250667V426.666667h-170.666666v170.666666h86.272a276.096 276.096 0 0 0-30.250667 64H426.666667v170.666667h56.021333c7.381333 22.784 17.578667 44.245333 30.250667 64H266.666667A138.666667 138.666667 0 0 1 128 757.333333V266.666667zM266.666667 192A74.666667 74.666667 0 0 0 192 266.666667V362.666667h170.666667v-170.666667H266.666667zM192 426.666667v170.666666h170.666667v-170.666666h-170.666667z m469.333333-64h170.666667V266.666667a74.666667 74.666667 0 0 0-74.666667-74.666667H661.333333v170.666667z m-64-170.666667h-170.666666v170.666667h170.666666v-170.666667z m-405.333333 469.333333v96c0 41.216 33.450667 74.666667 74.666667 74.666667H362.666667v-170.666667h-170.666667z'/><path d='M981.333333 746.666667a234.666667 234.666667 0 1 1-469.333333 0 234.666667 234.666667 0 0 1 469.333333 0z m-234.666666-30.165334l-70.229334-70.272a21.333333 21.333333 0 0 0-30.208 30.208l70.272 70.229334-70.272 70.229333a21.333333 21.333333 0 0 0 30.208 30.208l70.229334-70.272 70.229333 70.272a21.333333 21.333333 0 0 0 30.208-30.208L776.832 746.666667l70.272-70.229334a21.333333 21.333333 0 0 0-30.208-30.208L746.666667 716.501333z'/></svg>"},null,8,["html"])],40,Ff)],64)):t.createCommentVNode("",!0)],64)):t.createCommentVNode("",!0)],34),te.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:t.normalizeClass(["ht-nav-btn ht-nav-right",{disabled:!B.value}]),title:t.unref(i)("ui.scrollRight"),"aria-label":t.unref(i)("ui.scrollRight"),onMousedown:b[35]||(b[35]=t.withModifiers(D=>_e(1),["prevent","stop"])),onTouchstart:b[36]||(b[36]=t.withModifiers(()=>{},["stop"])),onTouchend:b[37]||(b[37]=t.withModifiers(D=>Te(1,D),["stop"])),onClick:b[38]||(b[38]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[103]||(b[103]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],42,Kf)):t.createCommentVNode("",!0)],14,ju)],14,Xu)],8,["disabled"]))}}),Zf=["aria-label"],Xf={class:"tt-left"},jf=["disabled","title","aria-label"],Qf=["disabled","title","aria-label"],Jf={key:0,class:"tt-sep"},em=t.defineComponent({__name:"FixedToolbar",props:{rootEl:{},focusBlockId:{},hoverVisible:{type:Boolean},hoverSelectionRect:{},hoverBlockId:{},hoverBlockType:{},hoverBlockAttrs:{},plusMenuVisible:{type:Boolean},settingsMenuVisible:{type:Boolean},position:{}},emits:["openPlusMenu","openSettingsMenu","linkClick","hoverClose","toolbarInteracting"],setup(e,{emit:n}){const o=e,r=n,{t:l}=Zt(),i=Yn(),c=cn(),s=t.inject(mi,t.ref(!1)),a=t.computed(()=>o.position==="top"?!1:o.position==="bottom"?!0:s.value);t.provide(Lo,a);const d=t.inject($r,t.ref(null)),u=t.ref(null);let f=null;t.watch([d,()=>o.hoverVisible,()=>o.hoverSelectionRect],()=>{const S=d.value;if(!(S&&S.visible))if(o.hoverVisible){if(f&&(clearTimeout(f),f=null),o.hoverSelectionRect===null)return;u.value={visible:!0,selectionRect:o.hoverSelectionRect,blockId:o.hoverBlockId,blockType:o.hoverBlockType,blockAttrs:o.hoverBlockAttrs,rootEl:o.rootEl,onClose:()=>r("hoverClose"),onLinkClick:(G,K,F)=>r("linkClick",G,K,F)}}else u.value&&!f&&(f=setTimeout(()=>{u.value=null,f=null},1500))},{immediate:!0,flush:"sync"});const p=t.computed(()=>{const S=d.value;if(S&&S.visible)return S;if(o.hoverVisible)return{visible:!0,selectionRect:o.hoverSelectionRect,blockId:o.hoverBlockId,blockType:o.hoverBlockType,blockAttrs:o.hoverBlockAttrs,rootEl:o.rootEl,onClose:()=>r("hoverClose"),onLinkClick:(K,F,Y)=>r("linkClick",K,F,Y)};if(u.value)return{...u.value,visible:!0};const G=o.focusBlockId;if(G){const K=c.getState().doc.blocks.get(G);return{visible:!0,selectionRect:null,blockId:G,blockType:(K==null?void 0:K.type)??null,blockAttrs:(K==null?void 0:K.attrs)??{},rootEl:o.rootEl,onClose:()=>r("hoverClose"),onLinkClick:(F,Y,ae)=>r("linkClick",F,Y,ae)}}return{visible:!1,selectionRect:null,blockId:null,blockType:null,blockAttrs:{},rootEl:o.rootEl}}),m=t.computed(()=>{const S=d.value;return S&&S.visible?S.blockId:o.hoverVisible&&o.hoverBlockId?o.hoverBlockId:o.focusBlockId}),h=t.ref(null),y=t.ref(null);function N(){const S=m.value,G=h.value;!S||!G||r("openPlusMenu",S,G)}function L(){const S=m.value,G=y.value;!S||!G||r("openSettingsMenu",S,G)}return t.watch(()=>o.focusBlockId,(S,G)=>{if(S!==G&&u.value){const K=u.value;S!==null&&K.blockId!==S&&(u.value=null)}}),(S,G)=>t.unref(i)?(t.openBlock(),t.createElementBlock("div",{key:0,ref:"toolbarRoot",class:t.normalizeClass(["fixed-toolbar",{"fixed-toolbar--bottom":a.value}]),role:"toolbar","aria-label":t.unref(l)("hoverToolbar.label"),onMousedownCapture:G[3]||(G[3]=K=>S.$emit("toolbarInteracting"))},[t.createElementVNode("div",Xf,[t.createElementVNode("button",{ref_key:"plusBtnEl",ref:h,class:t.normalizeClass(["tt-btn tt-plus",{disabled:!m.value,active:e.plusMenuVisible}]),disabled:!m.value,title:t.unref(l)("handle.plus.title"),"aria-label":t.unref(l)("handle.plus.ariaLabel"),onMousedown:t.withModifiers(N,["prevent","stop"]),onTouchstart:G[0]||(G[0]=t.withModifiers(()=>{},["stop"]))},[...G[4]||(G[4]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"18",height:"18","aria-hidden":"true"},[t.createElementVNode("path",{d:"M8 3.5V12.5M3.5 8H12.5",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round"})],-1)])],42,jf),t.createElementVNode("button",{ref_key:"handleBtnEl",ref:y,class:t.normalizeClass(["tt-btn tt-handle",{disabled:!m.value,active:e.settingsMenuVisible}]),disabled:!m.value,title:t.unref(l)("handle.grip.title"),"aria-label":t.unref(l)("handle.grip.ariaLabel"),onMousedown:t.withModifiers(L,["prevent","stop"]),onTouchstart:G[1]||(G[1]=t.withModifiers(()=>{},["stop"]))},[...G[5]||(G[5]=[t.createStaticVNode('<svg viewBox="0 0 16 16" width="18" height="18" aria-hidden="true"><circle cx="5" cy="4" r="1.3" fill="currentColor"></circle><circle cx="11" cy="4" r="1.3" fill="currentColor"></circle><circle cx="5" cy="8" r="1.3" fill="currentColor"></circle><circle cx="11" cy="8" r="1.3" fill="currentColor"></circle><circle cx="5" cy="12" r="1.3" fill="currentColor"></circle><circle cx="11" cy="12" r="1.3" fill="currentColor"></circle></svg>',1)])],42,Qf)]),p.value.visible?(t.openBlock(),t.createElementBlock("div",Jf)):t.createCommentVNode("",!0),t.createVNode(Yf,t.mergeProps({mobile:""},p.value,{onInteracting:G[2]||(G[2]=K=>r("toolbarInteracting"))}),null,16)],42,Zf)):t.createCommentVNode("",!0)}}),tm={class:"olm-label"},nm={class:"olm-label"},om={class:"olm-label"},ur=6,ns=t.defineComponent({__name:"OrderedListMenu",props:{visible:{type:Boolean},blockId:{},anchor:{},rootEl:{},canContinue:{type:Boolean},canStartNew:{type:Boolean},currentNumber:{}},emits:["continue","startNew","modify","close"],setup(e,{emit:n}){const o=e,r=n,{t:l}=Zt(),i=t.ref(null),c=t.ref({top:0,left:0,above:!1});t.watch([()=>o.visible,()=>o.anchor,i],async()=>{if(!o.visible||!o.anchor)return;await t.nextTick();const f=i.value;if(!f)return;const p=o.anchor.getBoundingClientRect(),m=f.getBoundingClientRect(),y=window.innerHeight-p.bottom-ur,N=p.top-ur,L=Math.max(m.height,10);let S=!1;y>=L?S=!1:N>=L?S=!0:S=N>y,c.value={top:S?p.top-(m.height+ur):p.bottom+ur,left:p.left,above:S}},{flush:"post",immediate:!0});const s=t.computed(()=>({top:`${c.value.top}px`,left:`${c.value.left}px`}));function a(){o.canContinue&&r("continue")}function d(){o.canStartNew&&r("startNew")}function u(){r("modify",o.currentNumber)}return(f,p)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[e.visible&&e.anchor&&e.rootEl?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"menuEl",ref:i,class:t.normalizeClass(["ordered-list-menu",{above:c.value.above}]),style:t.normalizeStyle(s.value),role:"menu",onMousedown:p[0]||(p[0]=t.withModifiers(()=>{},["prevent","stop"]))},[t.createElementVNode("button",{class:t.normalizeClass(["olm-item",{disabled:!e.canContinue}]),role:"menuitem",onClick:a},[p[1]||(p[1]=t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true",fill:"currentColor"},[t.createElementVNode("path",{d:"M2.27072 1012.662857c0 6.253714 5.046857 11.337143 11.337143 11.337143h226.267428a11.337143 11.337143 0 0 0 11.337143-11.337143v-52.114286a11.337143 11.337143 0 0 0-11.337143-11.337142H120.067291L181.031863 885.028571c14.701714-15.323429 26.770286-29.257143 36.205714-41.801142l0.036572-0.109715c9.508571-13.019429 16.859429-25.965714 21.796571-38.875428a110.445714 110.445714 0 0 0 7.570286-39.862857c0-20.955429-5.193143-39.789714-15.872-56.027429a101.302857 101.302857 0 0 0-43.081143-37.156571C169.621577 662.454857 148.849006 658.285714 125.809006 658.285714a136.777143 136.777143 0 0 0-56.137143 11.812572c-17.554286 7.68-32.548571 18.797714-44.8 33.426285a111.542857 111.542857 0 0 0-24.649143 51.309715 11.337143 11.337143 0 0 0 7.753143 13.056l53.833143 16.786285a11.300571 11.300571 0 0 0 14.189714-7.570285c4.315429-14.299429 10.898286-24.137143 19.163429-30.537143l0.182857-0.146286c8.411429-6.729143 18.358857-10.203429 30.464-10.203428 11.52 0 19.931429 3.291429 26.258285 9.216l0.146286 0.109714c6.253714 5.668571 9.801143 13.531429 9.801143 25.124571 0 6.656-1.499429 13.275429-4.754286 20.004572-3.291429 6.838857-9.508571 15.798857-19.163428 26.989714-9.508571 10.971429-23.222857 25.929143-41.289143 44.909714L5.379291 958.171429a11.337143 11.337143 0 0 0-3.108571 7.826285v46.665143zM512.003291 0v109.714286h329.142858a182.857143 182.857143 0 0 1 182.857142 182.857143v438.857142a182.857143 182.857143 0 0 1-182.857142 182.857143H402.289006a36.571429 36.571429 0 1 1 0-73.142857h438.857143a109.714286 109.714286 0 0 0 109.714285-109.714286V292.571429a109.714286 109.714286 0 0 0-109.714285-109.714286h-329.142858v109.714286L292.57472 146.285714l219.428571-146.285714zM108.913006 365.714286a11.483429 11.483429 0 0 1-11.52-11.483429V76.361143H42.791863a11.483429 11.483429 0 0 1-11.52-11.483429V11.483429C31.235291 5.156571 36.391863 0 42.791863 0h128.621714C177.703863 0 182.860434 5.12 182.860434 11.483429v342.747428c0 6.326857-5.12 11.483429-11.483428 11.483429H108.913006z"})],-1)),t.createElementVNode("span",tm,t.toDisplayString(t.unref(l)("ol.continue")),1)],2),t.createElementVNode("button",{class:t.normalizeClass(["olm-item",{disabled:!e.canStartNew}]),role:"menuitem",onClick:d},[p[2]||(p[2]=t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true",fill:"currentColor"},[t.createElementVNode("path",{d:"M128 324.288V162.112l-17.088 17.088c-17.024 17.088-42.624 8.512-59.712-8.512C34.112 153.6 42.688 128 59.712 119.488L128 76.8c25.6-17.088 51.2-17.088 68.288 8.512 8.512 8.576 8.512 17.088 8.512 25.6v204.8c0 25.6-17.088 42.688-34.112 42.688C153.6 358.4 128 341.312 128 324.288zM170.688 469.312c-25.6 0-42.688 25.6-42.688 42.688v213.312H59.712c-8.512 0-17.024 8.576-17.024 25.6v8.576L153.6 955.712c8.512 8.576 17.088 17.088 25.6 8.576l8.512-8.576 110.976-196.224c8.512-8.576 0-25.6-8.576-25.6h-76.8V512c0-17.088-17.024-42.688-42.624-42.688zM426.688 810.688c-25.6 0-42.688 17.024-42.688 42.624s17.088 42.688 42.688 42.688h512c25.6 0 42.624-17.088 42.624-42.688s-17.024-42.624-42.624-42.624h-512zM384 512c0-25.6 17.088-42.688 42.688-42.688h512c25.6 0 42.624 17.088 42.624 42.688s-17.024 42.688-42.624 42.688h-512C401.088 554.688 384 537.6 384 512zM426.688 128c-25.6 0-42.688 17.088-42.688 42.688s17.088 42.624 42.688 42.624h512c25.6 0 42.624-17.024 42.624-42.624S964.288 128 938.688 128h-512z"})],-1)),t.createElementVNode("span",nm,t.toDisplayString(t.unref(l)("ol.startNew")),1)],2),t.createElementVNode("button",{class:"olm-item",role:"menuitem",onClick:u},[p[3]||(p[3]=t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true",fill:"currentColor"},[t.createElementVNode("path",{d:"M45.421714 279.771429c0 4.388571 3.547429 7.936 7.899429 7.936H96.182857c4.388571 0 7.899429-3.547429 7.899429-7.899429V44.470857A7.899429 7.899429 0 0 0 96.182857 36.571429H7.899429A7.899429 7.899429 0 0 0 0 44.470857v36.644572c0 4.388571 3.547429 7.899429 7.899429 7.899428h37.522285V279.771429z m-32.182857 326.729142a7.899429 7.899429 0 0 1-7.899428-7.899428v-32.548572c0-2.011429 0.804571-3.986286 2.194285-5.449142l63.707429-66.633143c12.617143-13.238857 22.162286-23.661714 28.781714-31.305143 6.765714-7.789714 11.081143-14.043429 13.385143-18.797714a31.817143 31.817143 0 0 0 3.291429-13.933715c0-8.045714-2.450286-13.568-6.838858-17.554285l-0.109714-0.073143c-4.388571-4.096-10.24-6.4-18.285714-6.4a32.731429 32.731429 0 0 0-21.211429 7.131428l-0.146285 0.073143c-5.741714 4.461714-10.349714 11.337143-13.348572 21.321143a7.899429 7.899429 0 0 1-9.874286 5.229714l-37.558857-11.702857a7.899429 7.899429 0 0 1-5.376-9.106286c2.742857-13.641143 8.484571-25.6 17.188572-35.730285a84.114286 84.114286 0 0 1 31.195428-23.296c12.397714-5.485714 25.453714-8.228571 39.131429-8.228572 16.091429 0 30.537143 2.889143 43.154286 8.96a69.595429 69.595429 0 0 1 41.069714 64.950857c0 9.435429-1.755429 18.688-5.229714 27.794286a118.198857 118.198857 0 0 1-15.213715 27.062857l-0.036571 0.109715c-6.582857 8.740571-14.994286 18.468571-25.234286 29.110857L87.515429 554.422857h83.492571c4.388571 0 7.899429 3.510857 7.899429 7.899429v36.315428c0 4.388571-3.547429 7.899429-7.899429 7.899429H13.238857z m38.217143 354.486858a94.939429 94.939429 0 0 1-31.963429-22.052572l-0.109714-0.109714a79.030857 79.030857 0 0 1-18.212571-34.706286 7.899429 7.899429 0 0 1 5.010285-9.325714l37.558858-13.275429c4.096-1.462857 8.594286 0.731429 10.057142 4.827429 3.328 9.508571 8.265143 16.237714 14.482286 20.845714 6.326857 4.388571 13.824 6.729143 22.857143 6.729143 7.460571 0 13.421714-1.389714 18.176-3.84l0.073143-0.073143a27.721143 27.721143 0 0 0 11.593143-10.569143 33.938286 33.938286 0 0 0 4.242285-17.408 30.573714 30.573714 0 0 0-4.132571-16.64l-0.182857-0.292571A25.673143 25.673143 0 0 0 109.714286 854.637714a41.691429 41.691429 0 0 0-18.870857-3.913143 59.465143 59.465143 0 0 0-15.213715 2.194286 33.28 33.28 0 0 0-5.229714 2.048 7.862857 7.862857 0 0 1-10.642286-3.657143l-9.801143-20.553143a7.899429 7.899429 0 0 1 1.206858-8.594285l49.371428-56.393143H22.089143a7.899429 7.899429 0 0 1-7.862857-7.899429v-36.315428c0-4.388571 3.510857-7.899429 7.862857-7.899429h144.164571c4.388571 0 7.899429 3.547429 7.899429 7.899429v33.792a7.899429 7.899429 0 0 1-1.901714 5.12L132.388571 807.131429a76.909714 76.909714 0 0 1 14.043429 6.070857c11.739429 6.582857 20.992 15.725714 27.611429 27.318857 6.656 11.702857 9.874286 25.197714 9.874285 40.228571 0 16.530286-4.022857 31.634286-12.178285 45.165715a86.930286 86.930286 0 0 1-33.28 31.268571 97.755429 97.755429 0 0 1-47.323429 11.373714c-13.787429 0-26.989714-2.486857-39.497143-7.497143l-0.182857-0.073142zM292.571429 841.142857a36.571429 36.571429 0 1 0 0 73.142857h694.857142a36.571429 36.571429 0 1 0 0-73.142857H292.571429zM986.185143 138.605714a52.516571 52.516571 0 0 0-3.254857-10.532571 112.64 112.64 0 0 0-19.712-28.818286c-8.484571-9.216-16.237714-15.652571-23.222857-19.309714a72.045714 72.045714 0 0 0-11.702858-4.534857A55.515429 55.515429 0 0 0 914.285714 73.179429a43.776 43.776 0 0 0-29.184 9.764571c-3.657143 2.998857-8.228571 7.094857-13.714285 12.288-5.485714 5.193143-10.24 9.618286-14.262858 13.275429l93.366858 93.769142c2.340571-2.011429 4.827429-4.315429 7.497142-7.021714 2.304-2.340571 5.083429-5.010286 8.228572-8.009143 3.145143-2.998857 6.729143-6.509714 10.715428-10.532571 3.657143-4.022857 6.326857-8.192 8.009143-12.544A36.205714 36.205714 0 0 0 987.428571 151.149714c0-4.352-0.402286-8.521143-1.243428-12.544zM352.073143 614.509714c-7.314286 7.533714-11.958857 12.288-13.970286 14.262857a82.578286 82.578286 0 0 0-10.715428 12.8c-2.523429 3.876571-4.754286 8.118857-6.765715 12.8a111.798857 111.798857 0 0 0-6.473143 16.566858c-2.669714 8.009143-5.412571 16.786286-8.228571 26.331428-2.852571 9.508571-5.485714 18.688-8.009143 27.574857a169.764571 169.764571 0 0 0-4.754286 20.297143c-1.316571 8.704-0.475429 14.884571 2.523429 18.541714 2.998857 3.657143 8.996571 5.010286 17.956571 4.022858 4.352-0.658286 10.898286-2.194286 19.748572-4.498286a686.957714 686.957714 0 0 0 56.137143-18.066286c8.996571-3.328 15.798857-6.217143 20.48-8.521143 4.644571-2.011429 9.142857-4.681143 13.458285-8.045714a215.954286 215.954286 0 0 0 23.954286-21.577143c6.985143-6.985143 15.798857-15.945143 26.441143-26.806857 10.678857-10.861714 22.674286-22.820571 35.949714-35.84l39.936-40.594286 363.300572-363.885714-93.330286-94.244571-363.300571 363.849142-40.448 40.594286-36.425143 36.608c-10.971429 11.044571-20.114286 20.297143-27.428572 27.830857z"})],-1)),t.createElementVNode("span",om,t.toDisplayString(t.unref(l)("ol.modify")),1)])],38)):t.createCommentVNode("",!0)]))}}),rm=["aria-label"],lm=["aria-label"],im={class:"np-ok",type:"submit"},fr=6,os=t.defineComponent({__name:"NumberPicker",props:{visible:{type:Boolean},initialValue:{},anchor:{},rootEl:{}},emits:["confirm","close"],setup(e,{emit:n}){const o=e,r=n,{t:l}=Zt(),i=t.ref(null),c=t.ref(o.initialValue),s=t.ref({top:0,left:0});t.watch([()=>o.visible,()=>o.anchor,()=>o.initialValue],async()=>{if(!o.visible||!o.anchor)return;c.value=o.initialValue,await t.nextTick();const u=o.anchor.getBoundingClientRect(),f=window.innerHeight,p=52;let m=!1;f-u.bottom-fr<p&&u.top-fr>p&&(m=!0),s.value={top:m?u.top-(p+fr):u.bottom+fr,left:u.left},t.nextTick(()=>{var h,y;(h=i.value)==null||h.focus(),(y=i.value)==null||y.select()})},{flush:"post",immediate:!0});const a=t.computed(()=>({top:`${s.value.top}px`,left:`${s.value.left}px`}));function d(){let u=c.value;Number.isFinite(u)||(u=o.initialValue),u=Math.max(1,Math.floor(u)),r("confirm",u)}return(u,f)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[e.visible&&e.anchor&&e.rootEl?(t.openBlock(),t.createElementBlock("div",{key:0,class:"number-picker",style:t.normalizeStyle(a.value),role:"dialog","aria-label":t.unref(l)("numberPicker.title"),onMousedown:f[2]||(f[2]=t.withModifiers(()=>{},["stop"])),onTouchstart:f[3]||(f[3]=t.withModifiers(()=>{},["stop"]))},[t.createElementVNode("form",{class:"np-form",onSubmit:t.withModifiers(d,["prevent"])},[t.withDirectives(t.createElementVNode("input",{ref_key:"inputEl",ref:i,"onUpdate:modelValue":f[0]||(f[0]=p=>c.value=p),type:"number",class:"np-input",min:"1",step:"1","aria-label":t.unref(l)("numberPicker.inputLabel"),onKeydown:f[1]||(f[1]=t.withKeys(p=>r("close"),["escape"]))},null,40,lm),[[t.vModelText,c.value,void 0,{number:!0}]]),t.createElementVNode("button",im,t.toDisplayString(t.unref(l)("numberPicker.confirm")),1)],32)],44,rm)):t.createCommentVNode("",!0)]))}}),sm=["aria-label"],cm={key:0,class:"clp-custom"},am=["placeholder","aria-label"],dm={class:"clp-actions"},um={class:"clp-ok",type:"submit"},fm=["aria-label"],mm=["onClick"],pm={class:"clp-item-name"},hm={key:0,class:"clp-item-check","aria-hidden":"true"},gm={class:"clp-item-name"},bm=["aria-label"],io=6,rs=200,km=120,ym=360,wm=t.defineComponent({__name:"CodeLangPicker",props:{visible:{type:Boolean},initialValue:{},anchor:{},rootEl:{}},emits:["confirm","close"],setup(e,{emit:n}){const o=e,r=n,{t:l}=Zt(),i=["plain","javascript","typescript","python","java","c","cpp","csharp","go","rust","ruby","php","swift","kotlin","html","css","json","xml","yaml","markdown","lua","bash","shell","powershell","cmd","bat","sql","dart"],c=t.ref(null),s=t.ref(null),a=t.ref(null),d=t.ref(!1),u=t.ref(""),f=t.ref(o.initialValue),p=t.ref({top:0,left:0,above:!1,maxHeight:360}),m=t.ref(!1),h=t.ref(!1);function y(te){return te==="plain"?l("codeLang.plain"):te}function N(){if(!o.visible||!o.anchor||!o.rootEl)return;const te=c.value;if(!te)return;const X=o.anchor.getBoundingClientRect(),B=window.innerHeight,$=Math.floor(B-X.bottom-io),M=Math.floor(X.top-io),A=te.scrollHeight;let w=!1;o.rootEl.getBoundingClientRect().bottom-X.bottom<rs&&M>rs&&(w=!0);let z,U;w?(z=!0,U=M):A<=$?(z=!1,U=$):M>$?(z=!0,U=M):(z=!1,U=$);const fe=Math.max(km,Math.min(U,ym)),oe=document.documentElement.clientWidth,ue=Math.max(te.clientWidth,200),xe=Math.max(io,Math.min(oe-ue-io,X.left)),pe=z?Math.max(io,X.top-io-Math.min(A,fe)):X.bottom+io;p.value={top:pe,left:xe,above:z,maxHeight:fe},t.nextTick(L)}t.watch([()=>o.visible,()=>o.anchor,()=>o.initialValue],async()=>{o.visible&&(d.value=!1,f.value=o.initialValue??"plain",u.value=f.value==="plain"?"":f.value,await t.nextTick(),N())},{flush:"post",immediate:!0});function L(){const te=a.value;te&&(m.value=te.scrollTop>1,h.value=te.scrollTop+te.clientHeight<te.scrollHeight-1)}function S(){const te=a.value;te&&(te.scrollTop-=te.clientHeight*.8)}function G(){const te=a.value;te&&(te.scrollTop+=te.clientHeight*.8)}dr(a,L);function K(){d.value=!0,u.value=f.value==="plain"?"":f.value,t.nextTick(()=>{var te,X;(te=s.value)==null||te.focus(),(X=s.value)==null||X.select(),N()})}function F(){d.value=!1,t.nextTick(N)}function Y(){const te=u.value.replace(/[^a-zA-Z]/g,"").slice(0,20);te!==u.value&&(u.value=te)}function ae(){const te=(u.value??"").replace(/[^a-zA-Z]/g,"").slice(0,20);r("confirm",te.length===0?"plain":te)}const ne=t.computed(()=>({top:`${p.value.top}px`,left:`${p.value.left}px`,maxHeight:`${p.value.maxHeight}px`}));return(te,X)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[e.visible&&e.anchor&&e.rootEl?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"menuEl",ref:c,class:t.normalizeClass(["code-lang-picker",{above:p.value.above}]),style:t.normalizeStyle(ne.value),role:"menu","aria-label":t.unref(l)("codeLang.title"),onMousedown:X[1]||(X[1]=t.withModifiers(()=>{},["stop"])),onTouchstart:X[2]||(X[2]=t.withModifiers(()=>{},["stop"])),onWheel:X[3]||(X[3]=t.withModifiers(()=>{},["prevent"])),onTouchmove:X[4]||(X[4]=t.withModifiers(()=>{},["prevent"]))},[d.value?(t.openBlock(),t.createElementBlock("div",cm,[t.createElementVNode("form",{class:"clp-form",onSubmit:t.withModifiers(ae,["prevent"])},[t.withDirectives(t.createElementVNode("input",{ref_key:"inputEl",ref:s,"onUpdate:modelValue":X[0]||(X[0]=B=>u.value=B),type:"text",class:"clp-input",maxlength:"20",placeholder:t.unref(l)("codeLang.placeholder"),"aria-label":t.unref(l)("codeLang.inputLabel"),autocomplete:"off",spellcheck:"false",onInput:Y,onKeydown:t.withKeys(F,["escape"])},null,40,am),[[t.vModelText,u.value]]),t.createElementVNode("div",dm,[t.createElementVNode("button",um,t.toDisplayString(t.unref(l)("codeLang.confirm")),1),t.createElementVNode("button",{class:"clp-cancel",type:"button",onClick:F},t.toDisplayString(t.unref(l)("codeLang.cancel")),1)])],32)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[m.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(l)("ui.scrollUp"),onMousedown:t.withModifiers(S,["prevent"])},[...X[5]||(X[5]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,fm)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:a,class:"clp-list",onScroll:L},[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(i,B=>t.createElementVNode("button",{key:B,class:t.normalizeClass(["clp-item",{active:B===f.value}]),role:"menuitem",onClick:$=>r("confirm",B)},[t.createElementVNode("span",pm,t.toDisplayString(y(B)),1),B===f.value?(t.openBlock(),t.createElementBlock("span",hm,"✓")):t.createCommentVNode("",!0)],10,mm)),64)),t.createElementVNode("button",{class:"clp-item clp-item-custom",role:"menuitem",onClick:K},[t.createElementVNode("span",gm,t.toDisplayString(t.unref(l)("codeLang.custom")),1)])],544),h.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(l)("ui.scrollDown"),onMousedown:t.withModifiers(G,["prevent"])},[...X[6]||(X[6]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,bm)):t.createCommentVNode("",!0)],64))],46,sm)):t.createCommentVNode("",!0)]))}}),Em=["aria-label"],vm={key:0,class:"link-popover-view"},Cm=["href","title"],Tm={class:"link-popover-actions"},_m=["title","aria-label"],xm=["title","aria-label"],Mm=["title","aria-label"],Nm=["title","aria-label"],Sm={key:1,class:"link-popover-edit"},Am=["placeholder"],Im={key:0,class:"link-popover-error",role:"alert"},Bm=["placeholder"],Rm={class:"link-popover-edit-actions"},Lm=["title"],Om=["title"],ls=t.defineComponent({__name:"LinkPopover",props:{visible:{type:Boolean},anchorRect:{},blockId:{},from:{},to:{},href:{},text:{},initialMode:{},showTextInput:{type:Boolean},onSaveLink:{type:Function},onRemoveLinkMark:{type:Function},readonly:{type:Boolean}},emits:["close"],setup(e,{expose:n,emit:o}){const r=e,l=o,{t:i}=Zt(),c=cn(),s=t.ref(null),a=t.ref(null),d=t.ref(!1),u=t.ref(!1),f=t.ref("view"),p=t.ref(""),m=t.ref(""),h=t.ref({top:0,left:0}),y=t.ref(""),N=t.computed(()=>r.showTextInput??!1),L=t.computed(()=>f.value==="edit"?p.value:r.href),S=t.computed(()=>{const M=to(L.value);return $n(M)??"#"}),G=t.computed(()=>{const M=L.value;return M?M.length>60?M.slice(0,57)+"...":M:i("link.emptyUrl")}),K=t.computed(()=>({top:`${h.value.top}px`,left:`${h.value.left}px`,visibility:u.value?"visible":"hidden"}));async function F(){if(!r.visible||!r.anchorRect||!s.value)return;await t.nextTick();const A=s.value.getBoundingClientRect(),w=8,C=document.documentElement.clientWidth,z=document.documentElement.clientHeight-r.anchorRect.bottom-w,U=r.anchorRect.top-w,oe=z<A.height+w&&U>z?Math.max(w,r.anchorRect.top-A.height-w):r.anchorRect.bottom+w,ue=r.anchorRect.left+(r.anchorRect.width-A.width)/2,xe=Math.max(w,C-A.width-w),pe=Math.max(w,Math.min(xe,ue));h.value={top:oe,left:pe},u.value=!0}t.watch(()=>r.visible,M=>{M?(d.value=!0,f.value=r.readonly?"view":r.initialMode??(r.href?"view":"edit"),p.value=r.href,m.value=r.text,u.value=!1,t.nextTick(()=>{var A,w;F(),f.value==="edit"&&((A=a.value)==null||A.focus(),(w=a.value)==null||w.select())})):(u.value=!1,setTimeout(()=>{r.visible||(d.value=!1)},200))},{immediate:!0}),t.watch(()=>r.anchorRect,()=>{r.visible&&F()});function Y(){r.readonly||(f.value="edit",p.value=r.href,m.value=r.text,y.value="",t.nextTick(()=>{var M,A;(M=a.value)==null||M.focus(),(A=a.value)==null||A.select()}))}function ae(){const M=p.value;if(!M.trim()){y.value="";return}const A=to(M);$n(A)?y.value="":y.value=i("link.invalidUrl")}function ne(){var C,x,z;if(!r.blockId&&!r.onSaveLink)return;const M=to(p.value),A=$n(M);if(!A){y.value=i("link.invalidUrl"),(C=a.value)==null||C.focus();return}y.value="";const w=N.value&&m.value!==r.text;r.onSaveLink?r.onSaveLink(A,w?m.value:void 0):(z=(x=c.commands).setLink)==null||z.call(x,{id:r.blockId,href:A,from:r.from,to:r.to,text:w?m.value:void 0}),r.href?(f.value="view",t.nextTick(()=>{F()})):l("close")}function te(){r.href?(f.value="view",p.value=r.href,m.value=r.text):l("close")}function X(){var M,A;!r.blockId&&!r.onRemoveLinkMark||(r.onRemoveLinkMark?r.onRemoveLinkMark():(A=(M=c.commands).unsetLink)==null||A.call(M,{id:r.blockId,from:r.from,to:r.to}),l("close"))}function B(){var A;const M=to(r.href);M&&((A=navigator.clipboard)==null||A.writeText(M))}function $(){const M=to(r.href),A=$n(M);A&&A!=="#"&&window.open(A,"_blank","noopener,noreferrer")}return t.onBeforeUnmount(()=>{d.value=!1}),n({isEditing:()=>f.value==="edit",save:ne,cancel:te}),(M,A)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[d.value?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"popoverEl",ref:s,class:t.normalizeClass(["link-popover",{visible:u.value}]),style:t.normalizeStyle(K.value),role:"dialog","aria-label":t.unref(i)("link.popoverLabel"),onMousedown:A[2]||(A[2]=t.withModifiers(()=>{},["stop"])),onTouchstart:A[3]||(A[3]=t.withModifiers(()=>{},["stop"]))},[f.value==="view"?(t.openBlock(),t.createElementBlock("div",vm,[t.createElementVNode("a",{href:S.value,target:"_blank",rel:"noopener noreferrer",class:"link-popover-url",title:L.value,onClick:$},t.toDisplayString(G.value),9,Cm),t.createElementVNode("div",Tm,[t.createElementVNode("button",{class:"link-popover-btn",title:t.unref(i)("link.open"),"aria-label":t.unref(i)("link.open"),onMousedown:t.withModifiers($,["prevent","stop"])},[...A[4]||(A[4]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},[t.createElementVNode("path",{d:"M6 3H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h7a2 2 0 0 0 2-2v-2",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round","stroke-linejoin":"round"}),t.createElementVNode("path",{d:"M9 3h4v4M13 3L7 9",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,_m),t.createElementVNode("button",{class:"link-popover-btn",title:t.unref(i)("link.copy"),"aria-label":t.unref(i)("link.copy"),onMousedown:t.withModifiers(B,["prevent","stop"])},[...A[5]||(A[5]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},[t.createElementVNode("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1.5",fill:"none",stroke:"currentColor","stroke-width":"1.3"}),t.createElementVNode("path",{d:"M3 10.5V3.5C3 2.67 3.67 2 4.5 2H10",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"})],-1)])],40,xm),e.readonly?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("button",{key:0,class:"link-popover-btn",title:t.unref(i)("link.edit"),"aria-label":t.unref(i)("link.edit"),onMousedown:t.withModifiers(Y,["prevent","stop"])},[...A[6]||(A[6]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},[t.createElementVNode("path",{d:"M11.5 2.5l2 2L6 12l-2.5.5L4 10l7.5-7.5z",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Mm)),e.readonly?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("button",{key:1,class:"link-popover-btn link-popover-danger",title:t.unref(i)("link.remove"),"aria-label":t.unref(i)("link.remove"),onMousedown:t.withModifiers(X,["prevent","stop"])},[...A[7]||(A[7]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"14",height:"14","aria-hidden":"true"},[t.createElementVNode("path",{d:"M394.666667 213.333333a32 32 0 0 1 4.693333 63.658667l-4.693333 0.341333H298.666667a149.333333 149.333333 0 0 0-8.789334 298.410667L298.666667 576h96a32 32 0 0 1 4.693333 63.658667L394.666667 640H298.666667a213.333333 213.333333 0 0 1-10.666667-426.410667L298.666667 213.333333h96zM725.333333 213.333333a213.333333 213.333333 0 0 1 189.013334 312.405334 277.162667 277.162667 0 0 0-55.210667-32.64 149.333333 149.333333 0 0 0-125.013333-215.466667L725.333333 277.290667h-96a32 32 0 0 1-4.693333-63.658667L629.333333 213.333333H725.333333zM298.666667 394.666667h426.666666a32 32 0 0 1 4.352 63.701333L725.333333 458.666667H298.666667a32 32 0 0 1-4.352-63.701334L298.666667 394.666667z m682.666666 352a234.666667 234.666667 0 1 1-469.333333 0 234.666667 234.666667 0 0 1 469.333333 0z m-304.896-100.437334a21.333333 21.333333 0 0 0-30.208 30.208l70.272 70.229334-70.272 70.229333a21.333333 21.333333 0 0 0 30.208 30.208l70.229334-70.272 70.229333 70.272a21.333333 21.333333 0 0 0 30.208-30.208L776.832 746.666667l70.272-70.229334a21.333333 21.333333 0 0 0-30.208-30.208L746.666667 716.501333l-70.229334-70.272z",fill:"currentColor"})],-1)])],40,Nm))])])):(t.openBlock(),t.createElementBlock("div",Sm,[t.withDirectives(t.createElementVNode("input",{ref_key:"urlInputEl",ref:a,"onUpdate:modelValue":A[0]||(A[0]=w=>p.value=w),class:t.normalizeClass(["link-popover-input",{"link-popover-input-error":y.value}]),type:"text",placeholder:t.unref(i)("link.urlPlaceholder"),onKeydown:[t.withKeys(ne,["enter"]),t.withKeys(te,["escape"])],onInput:ae},null,42,Am),[[t.vModelText,p.value]]),y.value?(t.openBlock(),t.createElementBlock("div",Im,t.toDisplayString(y.value),1)):t.createCommentVNode("",!0),N.value?t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:1,"onUpdate:modelValue":A[1]||(A[1]=w=>m.value=w),class:"link-popover-input",type:"text",placeholder:t.unref(i)("link.textPlaceholder"),onKeydown:[t.withKeys(ne,["enter"]),t.withKeys(te,["escape"])]},null,40,Bm)),[[t.vModelText,m.value]]):t.createCommentVNode("",!0),t.createElementVNode("div",Rm,[t.createElementVNode("button",{class:"link-popover-btn link-popover-save",title:t.unref(i)("link.save"),onMousedown:t.withModifiers(ne,["prevent","stop"])},t.toDisplayString(t.unref(i)("link.save")),41,Lm),t.createElementVNode("button",{class:"link-popover-btn link-popover-cancel",title:t.unref(i)("link.cancel"),onMousedown:t.withModifiers(te,["prevent","stop"])},t.toDisplayString(t.unref(i)("link.cancel")),41,Om)])]))],46,Em)):t.createCommentVNode("",!0)]))}}),Dm={default:null,validate:e=>e==null?!0:Number.isInteger(e)&&e>=1};function is(e,n){const o=mo(e,n),r=rn(e,n);if(r<0)return 1;const l=e.blocks.get(n);if(!l)return 1;const i=l.attrs.startNumber;if(typeof i=="number")return i;let c=null,s=0;for(let a=r-1;a>=0;a--){const d=e.blocks.get(o[a]);if(!d||d.type!=="orderedList")break;const u=d.attrs.startNumber;if(typeof u=="number"){c=u;break}s++}return c!==null?c+s+1:1+s}const $m=t.defineComponent({name:"OrderedListBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){const n=cn(),o=Yn(),r=t.ref(null),l=t.useAttrs(),i={...typeof l.onLinkClick=="function"?{onLinkClick:l.onLinkClick}:{},...typeof l.onSlashTrigger=="function"?{onSlashTrigger:l.onSlashTrigger}:{},...typeof l.onInputChanged=="function"?{onInputChanged:l.onInputChanged}:{}},c=t.ref(0),s=n.subscribe(()=>{c.value++});return t.onBeforeUnmount(s),()=>{c.value;const a=n.getState().doc,d=is(a,e.block.id),u=t.h("div",{ref:r,class:"ol-marker","data-ol-number":String(d),onMousedown:y=>{y.preventDefault(),y.stopPropagation()},onClick:y=>{if(y.stopPropagation(),!o.value)return;const N=new CustomEvent("ordered-list-marker-click",{bubbles:!0,detail:{blockId:e.block.id,anchor:r.value}});y.currentTarget.dispatchEvent(N)}},[`${d}.`]),f=xn(e.block.attrs),p=f.filter(y=>y.startsWith("be-indent-")),m=f.filter(y=>!y.startsWith("be-indent-")),h=t.h(Vn,{block:e.block,placeholder:e.placeholder,class:["block-ordered-list-content",...m],...i});return t.h("div",{class:["block-ordered-list-wrapper",...p],"data-block-type":"orderedList"},[u,h])}}}),Pm={name:"orderedList",schema:{type:"orderedList",content:"text",nestable:!0,listLike:!0,attrs:{...Xt,startNumber:Dm}},renderer:{component:$m},slashCommands:[{id:"ordered-list",title:"slash.orderedList.title",keywords:["list","numbered","ordered","有序列表","编号列表","ol","1"],description:"slash.orderedList.description",icon:cl,command:"convertBlock",category:"list",args:()=>({id:"__currentBlock__",type:"orderedList"})}],inputRules:[{name:"ordered-1-dot",pattern:/^1\. $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"orderedList",__stripPrefix:3})}]},Hm=t.defineComponent({name:"ParagraphBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){return()=>t.h(Vn,{block:e.block,placeholder:e.placeholder,class:["block-paragraph",...xn(e.block.attrs)]})}}),ss={name:"paragraph",schema:{type:"paragraph",content:"text",nestable:!0,attrs:{...Xt}},renderer:{component:Hm},slashCommands:[{id:"paragraph",title:"slash.paragraph.title",keywords:["text","paragraph","normal","正文","段落"],description:"slash.paragraph.description",icon:el,command:"convertBlock",category:"basic",args:e=>({id:"__currentBlock__",type:"paragraph"})}],inputRules:[{name:"paragraph-noop",pattern:/^$/,command:"setText",args:e=>({id:"__currentBlock__",content:[]})}]},Vm=t.defineComponent({name:"HeadingBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){return()=>{const n=e.block.attrs.level??1;return t.h(Vn,{block:e.block,placeholder:e.placeholder,class:["block-heading",`block-heading-h${n}`,...xn(e.block.attrs)]})}}});function yo(e){const n="#".repeat(e);return{name:`heading-h${e}`,pattern:new RegExp(`^${n} $`),command:"convertBlock",args:()=>({id:"__currentBlock__",type:"heading",attrs:{level:e},__stripPrefix:e+1})}}const wo=(e,n,o,r,l,i)=>({id:e,title:o,keywords:i,description:r,icon:l,command:"convertBlock",category:"basic",args:()=>({id:"__currentBlock__",type:"heading",attrs:{level:n}})}),cs={name:"heading",schema:{type:"heading",content:"text",nestable:!0,attrs:{level:{default:1,validate:e=>typeof e=="number"&&e>=1&&e<=6},...Xt}},renderer:{component:Vm},slashCommands:[wo("heading-1",1,"slash.heading1.title","slash.heading1.description",tl,["h1","标题1","大标题","title"]),wo("heading-2",2,"slash.heading2.title","slash.heading2.description",nl,["h2","标题2","小标题"]),wo("heading-3",3,"slash.heading3.title","slash.heading3.description",ol,["h3","标题3","section"]),wo("heading-4",4,"slash.heading4.title","slash.heading4.description",rl,["h4","标题4"]),wo("heading-5",5,"slash.heading5.title","slash.heading5.description",ll,["h5","标题5"]),wo("heading-6",6,"slash.heading6.title","slash.heading6.description",il,["h6","标题6"])],inputRules:[yo(1),yo(2),yo(3),yo(4),yo(5),yo(6)]},as={name:"default-keymap",keymap:[{key:"Enter",command:"enter"},{key:"Backspace",command:"backspace"},{key:"Delete",command:"backspace"},{key:"Tab",command:"indentBlock"},{key:"Shift-Tab",command:"outdentBlock"},{key:"Mod-a",command:"selectAll"},{key:"ArrowUp",command:"moveToPreviousBlock"},{key:"ArrowDown",command:"moveToNextBlock"}]},ds={name:"history-keymap",keymap:[{key:"Mod-z",command:"undo"},{key:"Mod-Shift-z",command:"redo"},{key:"Mod-y",command:"redo"}]},Um=t.defineComponent({name:"BulletListBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){return()=>t.h(Vn,{block:e.block,placeholder:e.placeholder,class:["block-bullet-list",...xn(e.block.attrs)]})}}),zm={name:"bulletList",schema:{type:"bulletList",content:"text",nestable:!0,listLike:!0,attrs:{...Xt}},renderer:{component:Um},slashCommands:[{id:"bullet-list",title:"slash.bulletList.title",keywords:["list","bullet","unordered","项目符号","无序列表","ul","-","*"],description:"slash.bulletList.description",icon:sl,command:"convertBlock",category:"list",args:()=>({id:"__currentBlock__",type:"bulletList"})}],inputRules:[{name:"bullet-dash",pattern:/^- $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"bulletList",__stripPrefix:2})},{name:"bullet-star",pattern:/^\* $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"bulletList",__stripPrefix:2})}]},Fm=t.defineComponent({name:"TodoListBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){const n=cn(),o=t.useAttrs(),r={...typeof o.onLinkClick=="function"?{onLinkClick:o.onLinkClick}:{},...typeof o.onSlashTrigger=="function"?{onSlashTrigger:o.onSlashTrigger}:{},...typeof o.onInputChanged=="function"?{onInputChanged:o.onInputChanged}:{}};function l(i){var s,a;const c=i.target;(a=(s=n.commands).setAttrs)==null||a.call(s,{id:e.block.id,attrs:{...e.block.attrs,checked:c.checked}})}return()=>{const i=!!e.block.attrs.checked,c=xn(e.block.attrs),s=c.filter(u=>u.startsWith("be-indent-")),a=c.filter(u=>!u.startsWith("be-indent-")),d=["block-todo-list",i?"todo-checked":"todo-unchecked",...a];return t.h("div",{class:["block-todo-wrapper",...s]},[t.h("input",{type:"checkbox",class:"block-todo-checkbox",checked:i,onchange:l}),t.h(Vn,{block:e.block,placeholder:e.placeholder,class:d,...r})])}}}),Km={name:"todoList",schema:{type:"todoList",content:"text",nestable:!0,listLike:!0,attrs:{...Xt,checked:{default:!1,validate:e=>typeof e=="boolean"}}},renderer:{component:Fm},slashCommands:[{id:"todo-list",title:"slash.todoList.title",keywords:["todo","task","checkbox","待办","任务","复选框","[]","[ ]"],description:"slash.todoList.description",icon:al,command:"convertBlock",category:"list",args:()=>({id:"__currentBlock__",type:"todoList",attrs:{checked:!1}})}],inputRules:[{name:"todo-empty",pattern:/^\[\] $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"todoList",attrs:{checked:!1},__stripPrefix:3})},{name:"todo-space-bracket",pattern:/^\[ \] $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"todoList",attrs:{checked:!1},__stripPrefix:4})}]},Wm=t.defineComponent({name:"QuoteBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){return()=>t.h(Vn,{block:e.block,placeholder:e.placeholder,class:["block-quote",...xn(e.block.attrs)]})}}),Gm={name:"quote",schema:{type:"quote",content:"text",nestable:!1,disallowedMarks:["italic"],attrs:{...Kd,indent:Xt.indent}},renderer:{component:Wm},slashCommands:[{id:"quote",title:"slash.quote.title",keywords:["quote","blockquote","引用",">","引言"],description:"slash.quote.description",icon:dl,command:"convertBlock",category:"other",args:()=>({id:"__currentBlock__",type:"quote"})}],inputRules:[{name:"quote-gt",pattern:/^> $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"quote",__stripPrefix:2})}]};function qm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function us(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(n=>{const o=e[n],r=typeof o;(r==="object"||r==="function")&&!Object.isFrozen(o)&&us(o)}),e}class fs{constructor(n){n.data===void 0&&(n.data={}),this.data=n.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function ms(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function jn(e,...n){const o=Object.create(null);for(const r in e)o[r]=e[r];return n.forEach(function(r){for(const l in r)o[l]=r[l]}),o}const Ym="</span>",ps=e=>!!e.scope,Zm=(e,{prefix:n})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const o=e.split(".");return[`${n}${o.shift()}`,...o.map((r,l)=>`${r}${"_".repeat(l+1)}`)].join(" ")}return`${n}${e}`};class Xm{constructor(n,o){this.buffer="",this.classPrefix=o.classPrefix,n.walk(this)}addText(n){this.buffer+=ms(n)}openNode(n){if(!ps(n))return;const o=Zm(n.scope,{prefix:this.classPrefix});this.span(o)}closeNode(n){ps(n)&&(this.buffer+=Ym)}value(){return this.buffer}span(n){this.buffer+=`<span class="${n}">`}}const hs=(e={})=>{const n={children:[]};return Object.assign(n,e),n};class pl{constructor(){this.rootNode=hs(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(n){this.top.children.push(n)}openNode(n){const o=hs({scope:n});this.add(o),this.stack.push(o)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(n){return this.constructor._walk(n,this.rootNode)}static _walk(n,o){return typeof o=="string"?n.addText(o):o.children&&(n.openNode(o),o.children.forEach(r=>this._walk(n,r)),n.closeNode(o)),n}static _collapse(n){typeof n!="string"&&n.children&&(n.children.every(o=>typeof o=="string")?n.children=[n.children.join("")]:n.children.forEach(o=>{pl._collapse(o)}))}}class jm extends pl{constructor(n){super(),this.options=n}addText(n){n!==""&&this.add(n)}startScope(n){this.openNode(n)}endScope(){this.closeNode()}__addSublanguage(n,o){const r=n.root;o&&(r.scope=`language:${o}`),this.add(r)}toHTML(){return new Xm(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function Fo(e){return e?typeof e=="string"?e:e.source:null}function gs(e){return so("(?=",e,")")}function Qm(e){return so("(?:",e,")*")}function Jm(e){return so("(?:",e,")?")}function so(...e){return e.map(o=>Fo(o)).join("")}function ep(e){const n=e[e.length-1];return typeof n=="object"&&n.constructor===Object?(e.splice(e.length-1,1),n):{}}function hl(...e){return"("+(ep(e).capture?"":"?:")+e.map(r=>Fo(r)).join("|")+")"}function bs(e){return new RegExp(e.toString()+"|").exec("").length-1}function tp(e,n){const o=e&&e.exec(n);return o&&o.index===0}const np=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function gl(e,{joinWith:n}){let o=0;return e.map(r=>{o+=1;const l=o;let i=Fo(r),c="";for(;i.length>0;){const s=np.exec(i);if(!s){c+=i;break}c+=i.substring(0,s.index),i=i.substring(s.index+s[0].length),s[0][0]==="\\"&&s[1]?c+="\\"+String(Number(s[1])+l):(c+=s[0],s[0]==="("&&o++)}return c}).map(r=>`(${r})`).join(n)}const op=/\b\B/,ks="[a-zA-Z]\\w*",bl="[a-zA-Z_]\\w*",ys="\\b\\d+(\\.\\d+)?",ws="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Es="\\b(0b[01]+)",rp="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",lp=(e={})=>{const n=/^#![ ]*\//;return e.binary&&(e.begin=so(n,/.*\b/,e.binary,/\b.*/)),jn({scope:"meta",begin:n,end:/$/,relevance:0,"on:begin":(o,r)=>{o.index!==0&&r.ignoreMatch()}},e)},Ko={begin:"\\\\[\\s\\S]",relevance:0},ip={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Ko]},sp={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Ko]},cp={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/},mr=function(e,n,o={}){const r=jn({scope:"comment",begin:e,end:n,contains:[]},o);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});const l=hl("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:so(/[ ]+/,"(",l,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},ap=mr("//","$"),dp=mr("/\\*","\\*/"),up=mr("#","$"),fp={scope:"number",begin:ys,relevance:0},mp={scope:"number",begin:ws,relevance:0},pp={scope:"number",begin:Es,relevance:0},hp={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Ko,{begin:/\[/,end:/\]/,relevance:0,contains:[Ko]}]},gp={scope:"title",begin:ks,relevance:0},bp={scope:"title",begin:bl,relevance:0},kp={begin:"\\.\\s*"+bl,relevance:0};var pr=Object.freeze({__proto__:null,APOS_STRING_MODE:ip,BACKSLASH_ESCAPE:Ko,BINARY_NUMBER_MODE:pp,BINARY_NUMBER_RE:Es,COMMENT:mr,C_BLOCK_COMMENT_MODE:dp,C_LINE_COMMENT_MODE:ap,C_NUMBER_MODE:mp,C_NUMBER_RE:ws,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(n,o)=>{o.data._beginMatch=n[1]},"on:end":(n,o)=>{o.data._beginMatch!==n[1]&&o.ignoreMatch()}})},HASH_COMMENT_MODE:up,IDENT_RE:ks,MATCH_NOTHING_RE:op,METHOD_GUARD:kp,NUMBER_MODE:fp,NUMBER_RE:ys,PHRASAL_WORDS_MODE:cp,QUOTE_STRING_MODE:sp,REGEXP_MODE:hp,RE_STARTERS_RE:rp,SHEBANG:lp,TITLE_MODE:gp,UNDERSCORE_IDENT_RE:bl,UNDERSCORE_TITLE_MODE:bp});function yp(e,n){e.input[e.index-1]==="."&&n.ignoreMatch()}function wp(e,n){e.className!==void 0&&(e.scope=e.className,delete e.className)}function Ep(e,n){n&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=yp,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function vp(e,n){Array.isArray(e.illegal)&&(e.illegal=hl(...e.illegal))}function Cp(e,n){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 Tp(e,n){e.relevance===void 0&&(e.relevance=1)}const _p=(e,n)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const o=Object.assign({},e);Object.keys(e).forEach(r=>{delete e[r]}),e.keywords=o.keywords,e.begin=so(o.beforeMatch,gs(o.begin)),e.starts={relevance:0,contains:[Object.assign(o,{endsParent:!0})]},e.relevance=0,delete o.beforeMatch},xp=["of","and","for","in","not","or","if","then","parent","list","value"],Mp="keyword";function vs(e,n,o=Mp){const r=Object.create(null);return typeof e=="string"?l(o,e.split(" ")):Array.isArray(e)?l(o,e):Object.keys(e).forEach(function(i){Object.assign(r,vs(e[i],n,i))}),r;function l(i,c){n&&(c=c.map(s=>s.toLowerCase())),c.forEach(function(s){const a=s.split("|");r[a[0]]=[i,Np(a[0],a[1])]})}}function Np(e,n){return n?Number(n):Sp(e)?0:1}function Sp(e){return xp.includes(e.toLowerCase())}const Cs={},co=e=>{console.error(e)},Ts=(e,...n)=>{console.log(`WARN: ${e}`,...n)},Eo=(e,n)=>{Cs[`${e}/${n}`]||(console.log(`Deprecated as of ${e}. ${n}`),Cs[`${e}/${n}`]=!0)},hr=new Error;function _s(e,n,{key:o}){let r=0;const l=e[o],i={},c={};for(let s=1;s<=n.length;s++)c[s+r]=l[s],i[s+r]=!0,r+=bs(n[s-1]);e[o]=c,e[o]._emit=i,e[o]._multi=!0}function Ap(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw co("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),hr;if(typeof e.beginScope!="object"||e.beginScope===null)throw co("beginScope must be object"),hr;_s(e,e.begin,{key:"beginScope"}),e.begin=gl(e.begin,{joinWith:""})}}function Ip(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw co("skip, excludeEnd, returnEnd not compatible with endScope: {}"),hr;if(typeof e.endScope!="object"||e.endScope===null)throw co("endScope must be object"),hr;_s(e,e.end,{key:"endScope"}),e.end=gl(e.end,{joinWith:""})}}function Bp(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function Rp(e){Bp(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),Ap(e),Ip(e)}function Lp(e){function n(c,s){return new RegExp(Fo(c),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(s?"g":""))}class o{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(s,a){a.position=this.position++,this.matchIndexes[this.matchAt]=a,this.regexes.push([a,s]),this.matchAt+=bs(s)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const s=this.regexes.map(a=>a[1]);this.matcherRe=n(gl(s,{joinWith:"|"}),!0),this.lastIndex=0}exec(s){this.matcherRe.lastIndex=this.lastIndex;const a=this.matcherRe.exec(s);if(!a)return null;const d=a.findIndex((f,p)=>p>0&&f!==void 0),u=this.matchIndexes[d];return a.splice(0,d),Object.assign(a,u)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(s){if(this.multiRegexes[s])return this.multiRegexes[s];const a=new o;return this.rules.slice(s).forEach(([d,u])=>a.addRule(d,u)),a.compile(),this.multiRegexes[s]=a,a}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(s,a){this.rules.push([s,a]),a.type==="begin"&&this.count++}exec(s){const a=this.getMatcher(this.regexIndex);a.lastIndex=this.lastIndex;let d=a.exec(s);if(this.resumingScanAtSamePosition()&&!(d&&d.index===this.lastIndex)){const u=this.getMatcher(0);u.lastIndex=this.lastIndex+1,d=u.exec(s)}return d&&(this.regexIndex+=d.position+1,this.regexIndex===this.count&&this.considerAll()),d}}function l(c){const s=new r;return c.contains.forEach(a=>s.addRule(a.begin,{rule:a,type:"begin"})),c.terminatorEnd&&s.addRule(c.terminatorEnd,{type:"end"}),c.illegal&&s.addRule(c.illegal,{type:"illegal"}),s}function i(c,s){const a=c;if(c.isCompiled)return a;[wp,Cp,Rp,_p].forEach(u=>u(c,s)),e.compilerExtensions.forEach(u=>u(c,s)),c.__beforeBegin=null,[Ep,vp,Tp].forEach(u=>u(c,s)),c.isCompiled=!0;let d=null;return typeof c.keywords=="object"&&c.keywords.$pattern&&(c.keywords=Object.assign({},c.keywords),d=c.keywords.$pattern,delete c.keywords.$pattern),d=d||/\w+/,c.keywords&&(c.keywords=vs(c.keywords,e.case_insensitive)),a.keywordPatternRe=n(d,!0),s&&(c.begin||(c.begin=/\B|\b/),a.beginRe=n(a.begin),!c.end&&!c.endsWithParent&&(c.end=/\B|\b/),c.end&&(a.endRe=n(a.end)),a.terminatorEnd=Fo(a.end)||"",c.endsWithParent&&s.terminatorEnd&&(a.terminatorEnd+=(c.end?"|":"")+s.terminatorEnd)),c.illegal&&(a.illegalRe=n(c.illegal)),c.contains||(c.contains=[]),c.contains=[].concat(...c.contains.map(function(u){return Op(u==="self"?c:u)})),c.contains.forEach(function(u){i(u,a)}),c.starts&&i(c.starts,s),a.matcher=l(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=jn(e.classNameAliases||{}),i(e)}function xs(e){return e?e.endsWithParent||xs(e.starts):!1}function Op(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(n){return jn(e,{variants:null},n)})),e.cachedVariants?e.cachedVariants:xs(e)?jn(e,{starts:e.starts?jn(e.starts):null}):Object.isFrozen(e)?jn(e):e}var Dp="11.11.0";class $p extends Error{constructor(n,o){super(n),this.name="HTMLInjectionError",this.html=o}}const kl=ms,Ms=jn,Ns=Symbol("nomatch"),Pp=7,Ss=function(e){const n=Object.create(null),o=Object.create(null),r=[];let l=!0;const i="Could not find the language '{}', did you forget to load/include a language module?",c={disableAutodetect:!0,name:"Plain text",contains:[]};let s={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:jm};function a(C){return s.noHighlightRe.test(C)}function d(C){let x=C.className+" ";x+=C.parentNode?C.parentNode.className:"";const z=s.languageDetectRe.exec(x);if(z){const U=ne(z[1]);return U||(Ts(i.replace("{}",z[1])),Ts("Falling back to no-highlight mode for this block.",C)),U?z[1]:"no-highlight"}return x.split(/\s+/).find(U=>a(U)||ne(U))}function u(C,x,z){let U="",fe="";typeof x=="object"?(U=C,z=x.ignoreIllegals,fe=x.language):(Eo("10.7.0","highlight(lang, code, ...args) has been deprecated."),Eo("10.7.0",`Please use highlight(code, options) instead.
|
|
13
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),
|
|
14
|
-
`,1;if(It>1e5&&It>W.index*3)throw new Error("potential infinite loop, way more iterations than matches");return _e+=ye,ye.length}const nt=ne(C);if(!nt)throw co(i.replace("{}",C)),new Error('Unknown language: "'+C+'"');const Pe=Lp(nt);let mt="",de=U||Pe;const at={},Ke=new s.__emitter(s);qt();let _e="",Rt=0,ot=0,It=0,P=!1;try{if(nt.__emitTokens)nt.__emitTokens(x,Ke);else{for(de.matcher.considerAll();;){It++,P?P=!1:de.matcher.considerAll(),de.matcher.lastIndex=ot;const k=de.matcher.exec(x);if(!k)break;const W=x.substring(ot,k.index),ye=vt(W,k);ot=k.index+ye}vt(x.substring(ot))}return Ke.finalize(),mt=Ke.toHTML(),{language:C,value:mt,relevance:Rt,illegal:!1,_emitter:Ke,_top:de}}catch(k){if(k.message&&k.message.includes("Illegal"))return{language:C,value:kl(x),illegal:!0,relevance:0,_illegalBy:{message:k.message,index:ot,context:x.slice(ot-100,ot+100),mode:k.mode,resultSoFar:mt},_emitter:Ke};if(l)return{language:C,value:kl(x),illegal:!1,relevance:0,errorRaised:k,_emitter:Ke,_top:de};throw k}}function p(C){const x={value:kl(C),illegal:!1,relevance:0,_top:c,_emitter:new s.__emitter(s)};return x._emitter.addText(C),x}function m(C,x){x=x||s.languages||Object.keys(n);const z=p(C),U=x.filter(ne).filter(X).map(pe=>f(pe,C,!1));U.unshift(z);const fe=U.sort((pe,qe)=>{if(pe.relevance!==qe.relevance)return qe.relevance-pe.relevance;if(pe.language&&qe.language){if(ne(pe.language).supersetOf===qe.language)return 1;if(ne(qe.language).supersetOf===pe.language)return-1}return 0}),[oe,ue]=fe,xe=oe;return xe.secondBest=ue,xe}function h(C,x,z){const U=x&&o[x]||z;C.classList.add("hljs"),C.classList.add(`language-${U}`)}function y(C){let x=null;const z=d(C);if(a(z))return;if(A("before:highlightElement",{el:C,language:z}),C.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",C);return}if(C.children.length>0&&(s.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(C)),s.throwUnescapedHTML))throw new $p("One of your code blocks includes unescaped HTML.",C.innerHTML);x=C;const U=x.textContent,fe=z?u(U,{language:z,ignoreIllegals:!0}):m(U);C.innerHTML=fe.value,C.dataset.highlighted="yes",h(C,z,fe.language),C.result={language:fe.language,re:fe.relevance,relevance:fe.relevance},fe.secondBest&&(C.secondBest={language:fe.secondBest.language,relevance:fe.secondBest.relevance}),A("after:highlightElement",{el:C,result:fe,text:U})}function N(C){s=Ms(s,C)}const L=()=>{K(),Eo("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function S(){K(),Eo("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let G=!1;function K(){function C(){K()}if(document.readyState==="loading"){G||window.addEventListener("DOMContentLoaded",C,!1),G=!0;return}document.querySelectorAll(s.cssSelector).forEach(y)}function F(C,x){let z=null;try{z=x(e)}catch(U){if(co("Language definition for '{}' could not be registered.".replace("{}",C)),l)co(U);else throw U;z=c}z.name||(z.name=C),n[C]=z,z.rawDefinition=x.bind(null,e),z.aliases&&te(z.aliases,{languageName:C})}function Y(C){delete n[C];for(const x of Object.keys(o))o[x]===C&&delete o[x]}function ae(){return Object.keys(n)}function ne(C){return C=(C||"").toLowerCase(),n[C]||n[o[C]]}function te(C,{languageName:x}){typeof C=="string"&&(C=[C]),C.forEach(z=>{o[z.toLowerCase()]=x})}function X(C){const x=ne(C);return x&&!x.disableAutodetect}function B(C){C["before:highlightBlock"]&&!C["before:highlightElement"]&&(C["before:highlightElement"]=x=>{C["before:highlightBlock"](Object.assign({block:x.el},x))}),C["after:highlightBlock"]&&!C["after:highlightElement"]&&(C["after:highlightElement"]=x=>{C["after:highlightBlock"](Object.assign({block:x.el},x))})}function $(C){B(C),r.push(C)}function M(C){const x=r.indexOf(C);x!==-1&&r.splice(x,1)}function A(C,x){const z=C;r.forEach(function(U){U[z]&&U[z](x)})}function w(C){return Eo("10.7.0","highlightBlock will be removed entirely in v12.0"),Eo("10.7.0","Please use highlightElement now."),y(C)}Object.assign(e,{highlight:u,highlightAuto:m,highlightAll:K,highlightElement:y,highlightBlock:w,configure:N,initHighlighting:L,initHighlightingOnLoad:S,registerLanguage:F,unregisterLanguage:Y,listLanguages:ae,getLanguage:ne,registerAliases:te,autoDetection:X,inherit:Ms,addPlugin:$,removePlugin:M}),e.debugMode=function(){l=!1},e.safeMode=function(){l=!0},e.versionString=Dp,e.regex={concat:so,lookahead:gs,either:hl,optional:Jm,anyNumberOfTimes:Qm};for(const C in pr)typeof pr[C]=="object"&&us(pr[C]);return Object.assign(e,pr),e},vo=Ss({});vo.newInstance=()=>Ss({});var Hp=vo;vo.HighlightJS=vo,vo.default=vo;const As=qm(Hp),Is="[A-Za-z$_][0-9A-Za-z$_]*",Vp=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Up=["true","false","null","undefined","NaN","Infinity"],Bs=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Rs=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Ls=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],zp=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Fp=[].concat(Ls,Bs,Rs);function Kp(e){const n=e.regex,o=(z,{after:U})=>{const fe="</"+z[0].slice(1);return z.input.indexOf(fe,U)!==-1},r=Is,l={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(z,U)=>{const fe=z[0].length+z.index,oe=z.input[fe];if(oe==="<"||oe===","){U.ignoreMatch();return}oe===">"&&(o(z,{after:fe})||U.ignoreMatch());let ue;const xe=z.input.substring(fe);if(ue=xe.match(/^\s*=/)){U.ignoreMatch();return}if((ue=xe.match(/^\s+extends\s+/))&&ue.index===0){U.ignoreMatch();return}}},s={$pattern:Is,keyword:Vp,literal:Up,built_in:Fp,"variable.language":zp},a="[0-9](_?[0-9])*",d=`\\.(${a})`,u="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${u})((${d})|\\.)?|(${d}))[eE][+-]?(${a})\\b`},{begin:`\\b(${u})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:s,contains:[]},m={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"css"}},y={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},N={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,p]},S={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},G=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,m,h,y,N,{match:/\$\d+/},f];p.contains=G.concat({begin:/\{/,end:/\}/,keywords:s,contains:["self"].concat(G)});const K=[].concat(S,p.contains),F=K.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:["self"].concat(K)}]),Y={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:F},ae={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,n.concat(r,"(",n.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},ne={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Bs,...Rs]}},te={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},X={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[Y],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function $(z){return n.concat("(?!",z.join("|"),")")}const M={match:n.concat(/\b/,$([...Ls,"super","import"].map(z=>`${z}\\s*\\(`)),r,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},A={begin:n.concat(/\./,n.lookahead(n.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},w={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},Y]},C="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",x={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(C)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[Y]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:s,exports:{PARAMS_CONTAINS:F,CLASS_REFERENCE:ne},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),te,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,m,h,y,N,S,{match:/\$\d+/},f,ne,{scope:"attr",match:r+n.lookahead(":"),relevance:0},x,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[S,e.REGEXP_MODE,{className:"function",begin:C,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:F}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:l.begin,end:l.end},{match:i},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},X,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[Y,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},A,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[Y]},M,B,ae,w,{match:/\$[(.]/}]}}const gr="[A-Za-z$_][0-9A-Za-z$_]*",Os=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Ds=["true","false","null","undefined","NaN","Infinity"],$s=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Ps=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Hs=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Vs=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Us=[].concat(Hs,$s,Ps);function Wp(e){const n=e.regex,o=(z,{after:U})=>{const fe="</"+z[0].slice(1);return z.input.indexOf(fe,U)!==-1},r=gr,l={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(z,U)=>{const fe=z[0].length+z.index,oe=z.input[fe];if(oe==="<"||oe===","){U.ignoreMatch();return}oe===">"&&(o(z,{after:fe})||U.ignoreMatch());let ue;const xe=z.input.substring(fe);if(ue=xe.match(/^\s*=/)){U.ignoreMatch();return}if((ue=xe.match(/^\s+extends\s+/))&&ue.index===0){U.ignoreMatch();return}}},s={$pattern:gr,keyword:Os,literal:Ds,built_in:Us,"variable.language":Vs},a="[0-9](_?[0-9])*",d=`\\.(${a})`,u="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${u})((${d})|\\.)?|(${d}))[eE][+-]?(${a})\\b`},{begin:`\\b(${u})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:s,contains:[]},m={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"css"}},y={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},N={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,p]},S={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},G=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,m,h,y,N,{match:/\$\d+/},f];p.contains=G.concat({begin:/\{/,end:/\}/,keywords:s,contains:["self"].concat(G)});const K=[].concat(S,p.contains),F=K.concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:["self"].concat(K)}]),Y={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:F},ae={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,n.concat(r,"(",n.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},ne={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...$s,...Ps]}},te={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},X={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[Y],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function $(z){return n.concat("(?!",z.join("|"),")")}const M={match:n.concat(/\b/,$([...Hs,"super","import"].map(z=>`${z}\\s*\\(`)),r,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},A={begin:n.concat(/\./,n.lookahead(n.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},w={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},Y]},C="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",x={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(C)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[Y]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:s,exports:{PARAMS_CONTAINS:F,CLASS_REFERENCE:ne},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),te,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,m,h,y,N,S,{match:/\$\d+/},f,ne,{scope:"attr",match:r+n.lookahead(":"),relevance:0},x,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[S,e.REGEXP_MODE,{className:"function",begin:C,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:F}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:l.begin,end:l.end},{match:i},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},X,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[Y,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},A,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[Y]},M,B,ae,w,{match:/\$[(.]/}]}}function Gp(e){const n=e.regex,o=Wp(e),r=gr,l=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},c={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:l},contains:[o.exports.CLASS_REFERENCE]},s={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},a=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],d={$pattern:gr,keyword:Os.concat(a),literal:Ds,built_in:Us.concat(l),"variable.language":Vs},u={className:"meta",begin:"@"+r},f=(y,N,L)=>{const S=y.contains.findIndex(G=>G.label===N);if(S===-1)throw new Error("can not find mode to replace");y.contains.splice(S,1,L)};Object.assign(o.keywords,d),o.exports.PARAMS_CONTAINS.push(u);const p=o.contains.find(y=>y.scope==="attr"),m=Object.assign({},p,{match:n.concat(r,n.lookahead(/\s*\?:/))});o.exports.PARAMS_CONTAINS.push([o.exports.CLASS_REFERENCE,p,m]),o.contains=o.contains.concat([u,i,c,m]),f(o,"shebang",e.SHEBANG()),f(o,"use_strict",s);const h=o.contains.find(y=>y.label==="func.def");return h.relevance=0,Object.assign(o,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),o}function qp(e){const n=e.regex,o=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],s={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},a={className:"meta",begin:/^(>>>|\.\.\.) /},d={className:"subst",begin:/\{/,end:/\}/,keywords:s,illegal:/#/},u={begin:/\{\{/,relevance:0},f={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,u,d]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,u,d]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,u,d]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,u,d]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},p="[0-9](_?[0-9])*",m=`(\\b(${p}))?\\.(${p})|\\b(${p})\\.`,h=`\\b|${r.join("|")}`,y={className:"number",relevance:0,variants:[{begin:`(\\b(${p})|(${m}))[eE][+-]?(${p})[jJ]?(?=${h})`},{begin:`(${m})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${h})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${h})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${h})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${h})`},{begin:`\\b(${p})[jJ](?=${h})`}]},N={className:"comment",begin:n.lookahead(/# type:/),end:/$/,keywords:s,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},L={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:["self",a,y,f,e.HASH_COMMENT_MODE]}]};return d.contains=[f,y,a],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:s,illegal:/(<\/|\?)|=>/,contains:[a,y,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},f,N,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,o],scope:{1:"keyword",3:"title.function"},contains:[L]},{variants:[{match:[/\bclass/,/\s+/,o,/\s*/,/\(\s*/,o,/\s*\)/]},{match:[/\bclass/,/\s+/,o]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[y,L,f]}]}}var Co="[0-9](_*[0-9])*",br=`\\.(${Co})`,kr="[0-9a-fA-F](_*[0-9a-fA-F])*",zs={className:"number",variants:[{begin:`(\\b(${Co})((${br})|\\.)?|(${br}))[eE][+-]?(${Co})[fFdD]?\\b`},{begin:`\\b(${Co})((${br})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${br})[fFdD]?\\b`},{begin:`\\b(${Co})[fFdD]\\b`},{begin:`\\b0[xX]((${kr})\\.?|(${kr})?\\.(${kr}))[pP][+-]?(${Co})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${kr})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Fs(e,n,o){return o===-1?"":e.replace(n,r=>Fs(e,n,o-1))}function Yp(e){const n=e.regex,o="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=o+Fs("(?:<"+o+"~~~(?:\\s*,\\s*"+o+"~~~)*>)?",/~~~/g,2),a={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},d={className:"meta",begin:"@"+o,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},u={className:"params",begin:/\(/,end:/\)/,keywords:a,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:a,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,o],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[n.concat(/(?!else)/,o),/\s+/,o,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,o],className:{1:"keyword",3:"title.class"},contains:[u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:a,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:a,relevance:0,contains:[d,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,zs,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},zs,d]}}function Zp(e){const n=e.regex,o=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",l="[a-zA-Z_]\\w*::",c="("+r+"|"+n.optional(l)+"[a-zA-Z_]\\w*"+n.optional("<[^<>]+>")+")",s={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},u={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},o,e.C_BLOCK_COMMENT_MODE]},p={className:"title",begin:n.optional(l)+e.IDENT_RE,relevance:0},m=n.optional(l)+e.IDENT_RE+"\\s*\\(",N={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},L=[f,s,o,e.C_BLOCK_COMMENT_MODE,u,d],S={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:N,contains:L.concat([{begin:/\(/,end:/\)/,keywords:N,contains:L.concat(["self"]),relevance:0}]),relevance:0},G={begin:"("+c+"[\\*&\\s]+)+"+m,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:N,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:N,relevance:0},{begin:m,returnBegin:!0,contains:[e.inherit(p,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:N,relevance:0,contains:[o,e.C_BLOCK_COMMENT_MODE,d,u,s,{begin:/\(/,end:/\)/,keywords:N,relevance:0,contains:["self",o,e.C_BLOCK_COMMENT_MODE,d,u,s]}]},s,o,e.C_BLOCK_COMMENT_MODE,f]};return{name:"C",aliases:["h"],keywords:N,disableAutodetect:!0,illegal:"</",contains:[].concat(S,G,L,[f,{begin:e.IDENT_RE+"::",keywords:N},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:f,strings:d,keywords:N}}}function Xp(e){const n=e.regex,o=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",l="[a-zA-Z_]\\w*::",c="(?!struct)("+r+"|"+n.optional(l)+"[a-zA-Z_]\\w*"+n.optional("<[^<>]+>")+")",s={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},u={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},o,e.C_BLOCK_COMMENT_MODE]},p={className:"title",begin:n.optional(l)+e.IDENT_RE,relevance:0},m=n.optional(l)+e.IDENT_RE+"\\s*\\(",h=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],y=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],N=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],L=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],K={type:y,keyword:h,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:N},F={className:"function.dispatch",relevance:0,keywords:{_hint:L},begin:n.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,n.lookahead(/(<[^<>]+>|)\s*\(/))},Y=[F,f,s,o,e.C_BLOCK_COMMENT_MODE,u,d],ae={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:K,contains:Y.concat([{begin:/\(/,end:/\)/,keywords:K,contains:Y.concat(["self"]),relevance:0}]),relevance:0},ne={className:"function",begin:"("+c+"[\\*&\\s]+)+"+m,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:K,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:K,relevance:0},{begin:m,returnBegin:!0,contains:[p],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[d,u]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:K,relevance:0,contains:[o,e.C_BLOCK_COMMENT_MODE,d,u,s,{begin:/\(/,end:/\)/,keywords:K,relevance:0,contains:["self",o,e.C_BLOCK_COMMENT_MODE,d,u,s]}]},s,o,e.C_BLOCK_COMMENT_MODE,f]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:K,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(ae,ne,F,Y,[f,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:K,contains:["self",s]},{begin:e.IDENT_RE+"::",keywords:K},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function jp(e){const n=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],o=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],l=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],i=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],c={keyword:l.concat(i),built_in:n,literal:r},s=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),a={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},d={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},u={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},f=e.inherit(u,{illegal:/\n/}),p={className:"subst",begin:/\{/,end:/\}/,keywords:c},m=e.inherit(p,{illegal:/\n/}),h={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,m]},y={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},p]},N=e.inherit(y,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},m]});p.contains=[y,h,u,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.C_BLOCK_COMMENT_MODE],m.contains=[N,h,f,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const L={variants:[d,y,h,u,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},S={begin:"<",end:">",contains:[{beginKeywords:"in out"},s]},G=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",K={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:c,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},L,a,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},s,S,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[s,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[s,S,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+G+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:c,contains:[{beginKeywords:o.join(" "),relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,S],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,relevance:0,contains:[L,a,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},K]}}function Qp(e){const i={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:i,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:i,illegal:/["']/}]}]}}function Jp(e){const n=e.regex,o=/(r#)?/,r=n.concat(o,e.UNDERSCORE_IDENT_RE),l=n.concat(o,e.IDENT_RE),i={className:"title.function.invoke",relevance:0,begin:n.concat(/\b/,/(?!let|for|while|if|else|match\b)/,l,n.lookahead(/\s*\(/))},c="([ui](8|16|32|64|128|size)|f(32|64))?",s=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],a=["true","false","Some","None","Ok","Err"],d=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],u=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:u,keyword:s,literal:a,built_in:d},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\(\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*/},{className:"number",variants:[{begin:"\\b0b([01_]+)"+c},{begin:"\\b0o([0-7_]+)"+c},{begin:"\\b0x([A-Fa-f0-9_]+)"+c},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+c}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:d,type:u}},{className:"punctuation",begin:"->"},i]}}function eh(e){const n=e.regex,o="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=n.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),l=n.concat(r,/(::\w+)*/),c={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},s={className:"doctag",begin:"@[A-Za-z]+"},a={begin:"#<",end:">"},d=[e.COMMENT("#","$",{contains:[s]}),e.COMMENT("^=begin","^=end",{contains:[s],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],u={className:"subst",begin:/#\{/,end:/\}/,keywords:c},f={className:"string",contains:[e.BACKSLASH_ESCAPE,u],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:n.concat(/<<[-~]?'?/,n.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,u]})]}]},p="[1-9](_?[0-9])*|0",m="[0-9](_?[0-9])*",h={className:"number",relevance:0,variants:[{begin:`\\b(${p})(\\.(${m}))?([eE][+-]?(${m})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},y={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:c}]},Y=[f,{variants:[{match:[/class\s+/,l,/\s+<\s+/,l]},{match:[/\b(class|module)\s+/,l]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:c},{match:[/(include|extend)\s+/,l],scope:{2:"title.class"},keywords:c},{relevance:0,match:[l,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,o],scope:{1:"keyword",3:"title.function"},contains:[y]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[f,{begin:o}],relevance:0},h,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:c},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,u],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(a,d),relevance:0}].concat(a,d);u.contains=Y,y.contains=Y;const X=[{begin:/^\s*=>/,starts:{end:"$",contains:Y}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:c,contains:Y}}];return d.unshift(a),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:c,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(X).concat(d).concat(Y)}}function th(e){const n=e.regex,o=/(?![A-Za-z0-9])(?![$])/,r=n.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,o),l=n.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,o),i=n.concat(/[A-Z]+/,o),c={scope:"variable",match:"\\$+"+r},s={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},a={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},d=e.inherit(e.APOS_STRING_MODE,{illegal:null}),u=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(a)}),f={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(a),"on:begin":(A,w)=>{w.data._beginMatch=A[1]||A[2]},"on:end":(A,w)=>{w.data._beginMatch!==A[1]&&w.ignoreMatch()}},p=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),m=`[
|
|
15
|
-
]`,h={scope:"string",variants:[u,d,f,p]},y={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},N=["false","null","true"],L=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],S=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],K={keyword:L,literal:(A=>{const w=[];return A.forEach(C=>{w.push(C),C.toLowerCase()===C?w.push(C.toUpperCase()):w.push(C.toLowerCase())}),w})(N),built_in:S},F=A=>A.map(w=>w.replace(/\|\d+$/,"")),Y={variants:[{match:[/new/,n.concat(m,"+"),n.concat("(?!",F(S).join("\\b|"),"\\b)"),l],scope:{1:"keyword",4:"title.class"}}]},ae=n.concat(r,"\\b(?!\\()"),ne={variants:[{match:[n.concat(/::/,n.lookahead(/(?!class\b)/)),ae],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[l,n.concat(/::/,n.lookahead(/(?!class\b)/)),ae],scope:{1:"title.class",3:"variable.constant"}},{match:[l,n.concat("::",n.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[l,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},te={scope:"attr",match:n.concat(r,n.lookahead(":"),n.lookahead(/(?!::)/))},X={relevance:0,begin:/\(/,end:/\)/,keywords:K,contains:[te,c,ne,e.C_BLOCK_COMMENT_MODE,h,y,Y]},B={relevance:0,match:[/\b/,n.concat("(?!fn\\b|function\\b|",F(L).join("\\b|"),"|",F(S).join("\\b|"),"\\b)"),r,n.concat(m,"*"),n.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[X]};X.contains.push(B);const $=[te,ne,e.C_BLOCK_COMMENT_MODE,h,y,Y],M={begin:n.concat(/#\[\s*\\?/,n.either(l,i)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:N,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:N,keyword:["new","array"]},contains:["self",...$]},...$,{scope:"meta",variants:[{match:l},{match:i}]}]};return{case_insensitive:!1,keywords:K,contains:[M,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},s,{scope:"variable.language",match:/\$this\b/},c,B,ne,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},Y,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:K,contains:["self",M,c,ne,e.C_BLOCK_COMMENT_MODE,h,y]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},h,y]}}function Ks(e){return e?typeof e=="string"?e:e.source:null}function Wo(e){return ft("(?=",e,")")}function ft(...e){return e.map(o=>Ks(o)).join("")}function nh(e){const n=e[e.length-1];return typeof n=="object"&&n.constructor===Object?(e.splice(e.length-1,1),n):{}}function jt(...e){return"("+(nh(e).capture?"":"?:")+e.map(r=>Ks(r)).join("|")+")"}const yl=e=>ft(/\b/,e,/\w$/.test(e)?/\b/:/\B/),oh=["Protocol","Type"].map(yl),Ws=["init","self"].map(yl),rh=["Any","Self"],wl=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],Gs=["false","nil","true"],lh=["assignment","associativity","higherThan","left","lowerThan","none","right"],ih=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],qs=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],Ys=jt(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),Zs=jt(Ys,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),El=ft(Ys,Zs,"*"),Xs=jt(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),yr=jt(Xs,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),Bn=ft(Xs,yr,"*"),wr=ft(/[A-Z]/,yr,"*"),sh=["attached","autoclosure",ft(/convention\(/,jt("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",ft(/objc\(/,Bn,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],ch=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function ah(e){const n={match:/\s+/,relevance:0},o=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,o],l={match:[/\./,jt(...oh,...Ws)],className:{2:"keyword"}},i={match:ft(/\./,jt(...wl)),relevance:0},c=wl.filter(Pe=>typeof Pe=="string").concat(["_|0"]),s=wl.filter(Pe=>typeof Pe!="string").concat(rh).map(yl),a={variants:[{className:"keyword",match:jt(...s,...Ws)}]},d={$pattern:jt(/\b\w+/,/#\w+/),keyword:c.concat(ih),literal:Gs},u=[l,i,a],f={match:ft(/\./,jt(...qs)),relevance:0},p={className:"built_in",match:ft(/\b/,jt(...qs),/(?=\()/)},m=[f,p],h={match:/->/,relevance:0},y={className:"operator",relevance:0,variants:[{match:El},{match:`\\.(\\.|${Zs})+`}]},N=[h,y],L="([0-9]_*)+",S="([0-9a-fA-F]_*)+",G={className:"number",relevance:0,variants:[{match:`\\b(${L})(\\.(${L}))?([eE][+-]?(${L}))?\\b`},{match:`\\b0x(${S})(\\.(${S}))?([pP][+-]?(${L}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},K=(Pe="")=>({className:"subst",variants:[{match:ft(/\\/,Pe,/[0\\tnr"']/)},{match:ft(/\\/,Pe,/u\{[0-9a-fA-F]{1,8}\}/)}]}),F=(Pe="")=>({className:"subst",match:ft(/\\/,Pe,/[\t ]*(?:[\r\n]|\r\n)/)}),Y=(Pe="")=>({className:"subst",label:"interpol",begin:ft(/\\/,Pe,/\(/),end:/\)/}),ae=(Pe="")=>({begin:ft(Pe,/"""/),end:ft(/"""/,Pe),contains:[K(Pe),F(Pe),Y(Pe)]}),ne=(Pe="")=>({begin:ft(Pe,/"/),end:ft(/"/,Pe),contains:[K(Pe),Y(Pe)]}),te={className:"string",variants:[ae(),ae("#"),ae("##"),ae("###"),ne(),ne("#"),ne("##"),ne("###")]},X=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],B={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:X},$=Pe=>{const mt=ft(Pe,/\//),de=ft(/\//,Pe);return{begin:mt,end:de,contains:[...X,{scope:"comment",begin:`#(?!.*${de})`,end:/$/}]}},M={scope:"regexp",variants:[$("###"),$("##"),$("#"),B]},A={match:ft(/`/,Bn,/`/)},w={className:"variable",match:/\$\d+/},C={className:"variable",match:`\\$${yr}+`},x=[A,w,C],z={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:ch,contains:[...N,G,te]}]}},U={scope:"keyword",match:ft(/@/,jt(...sh),Wo(jt(/\(/,/\s+/)))},fe={scope:"meta",match:ft(/@/,Bn)},oe=[z,U,fe],ue={match:Wo(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:ft(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,yr,"+")},{className:"type",match:wr,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:ft(/\s+&\s+/,Wo(wr)),relevance:0}]},xe={begin:/</,end:/>/,keywords:d,contains:[...r,...u,...oe,h,ue]};ue.contains.push(xe);const pe={match:ft(Bn,/\s*:/),keywords:"_|0",relevance:0},qe={begin:/\(/,end:/\)/,relevance:0,keywords:d,contains:["self",pe,...r,M,...u,...m,...N,G,te,...x,...oe,ue]},Ce={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,ue]},je={begin:jt(Wo(ft(Bn,/\s*:/)),Wo(ft(Bn,/\s+/,Bn,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:Bn}]},ct={begin:/\(/,end:/\)/,keywords:d,contains:[je,...r,...u,...N,G,te,...oe,ue,qe],endsParent:!0,illegal:/["']/},St={match:[/(func|macro)/,/\s+/,jt(A.match,Bn,El)],className:{1:"keyword",3:"title.function"},contains:[Ce,ct,n],illegal:[/\[/,/%/]},At={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Ce,ct,n],illegal:/\[|%/},Et={match:[/operator/,/\s+/,El],className:{1:"keyword",3:"title"}},qt={begin:[/precedencegroup/,/\s+/,wr],className:{1:"keyword",3:"title"},contains:[ue],keywords:[...lh,...Gs],end:/}/},bt={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},vt={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},nt={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,Bn,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:d,contains:[Ce,...u,{begin:/:/,end:/\{/,keywords:d,contains:[{scope:"title.class.inherited",match:wr},...u],relevance:0}]};for(const Pe of te.variants){const mt=Pe.contains.find(at=>at.label==="interpol");mt.keywords=d;const de=[...u,...m,...N,G,te,...x];mt.contains=[...de,{begin:/\(/,end:/\)/,contains:["self",...de]}]}return{name:"Swift",keywords:d,contains:[...r,St,At,bt,vt,nt,Et,qt,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},M,...u,...m,...N,G,te,...x,...oe,ue,qe]}}var To="[0-9](_*[0-9])*",Er=`\\.(${To})`,vr="[0-9a-fA-F](_*[0-9a-fA-F])*",dh={className:"number",variants:[{begin:`(\\b(${To})((${Er})|\\.)?|(${Er}))[eE][+-]?(${To})[fFdD]?\\b`},{begin:`\\b(${To})((${Er})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Er})[fFdD]?\\b`},{begin:`\\b(${To})[fFdD]\\b`},{begin:`\\b0[xX]((${vr})\\.?|(${vr})?\\.(${vr}))[pP][+-]?(${To})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${vr})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function uh(e){const n={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},o={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},l={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},i={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},c={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[i,l]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,i,l]}]};l.contains.push(c);const s={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},a={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(c,{className:"string"}),"self"]}]},d=dh,u=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),f={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},p=f;return p.variants[1].contains=[f],f.variants[1].contains=[p],{name:"Kotlin",aliases:["kt","kts"],keywords:n,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,u,o,r,s,a,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:n,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:n,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[f,e.C_LINE_COMMENT_MODE,u],relevance:0},e.C_LINE_COMMENT_MODE,u,s,a,c,e.C_NUMBER_MODE]},u]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},s,a]},c,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
|
|
16
|
-
`},d]}}function fh(e){const n=e.regex,o=n.concat(/[\p{L}_]/u,n.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,l={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},c=e.inherit(i,{begin:/\(/,end:/\)/}),s=e.inherit(e.APOS_STRING_MODE,{className:"string"}),a=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),d={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[l]},{begin:/'/,end:/'/,contains:[l]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,a,s,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,c,a,s]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},l,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[a]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[d],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[d],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:n.concat(/</,n.lookahead(n.concat(o,n.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:o,relevance:0,starts:d}]},{className:"tag",begin:n.concat(/<\//,n.lookahead(n.concat(o,/>/))),contains:[{className:"name",begin:o,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}const mh=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),ph=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],hh=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],gh=[...ph,...hh],bh=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),kh=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),yh=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),wh=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function Eh(e){const n=e.regex,o=mh(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},l="and or not only",i=/@-?\w[\w]*(-\w+)*/,c="[a-zA-Z-][a-zA-Z0-9_-]*",s=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[o.BLOCK_COMMENT,r,o.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+c,relevance:0},o.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+kh.join("|")+")"},{begin:":(:)?("+yh.join("|")+")"}]},o.CSS_VARIABLE,{className:"attribute",begin:"\\b("+wh.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[o.BLOCK_COMMENT,o.HEXCOLOR,o.IMPORTANT,o.CSS_NUMBER_MODE,...s,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...s,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},o.FUNCTION_DISPATCH]},{begin:n.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:l,attribute:bh.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...s,o.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+gh.join("|")+")\\b"}]}}function vh(e){const n={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},o={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],l={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[n,o,e.QUOTE_STRING_MODE,l,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function Ch(e){const n="true false yes no null",o="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},l={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},c={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,l]},s=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),p={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},m={end:",",endsWithParent:!0,excludeEnd:!0,keywords:n,relevance:0},h={begin:/\{/,end:/\}/,contains:[m],illegal:"\\n",relevance:0},y={begin:"\\[",end:"\\]",contains:[m],illegal:"\\n",relevance:0},N=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+o},{className:"type",begin:"!<"+o+">"},{className:"type",begin:"!"+o},{className:"type",begin:"!!"+o},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},p,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},h,y,i,c],L=[...N];return L.pop(),L.push(s),m.contains=L,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:N}}function Th(e){const n=e.regex,o={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},l={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},c={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},s=/[A-Za-z][A-Za-z0-9+.-]*/,a={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:n.concat(/\[.+?\]\(/,s,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},d={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},u={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},f=e.inherit(d,{contains:[]}),p=e.inherit(u,{contains:[]});d.contains.push(p),u.contains.push(f);let m=[o,a];return[d,u,f,p].forEach(L=>{L.contains=L.contains.concat(m)}),m=m.concat(d,u),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:m},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:m}]}]},o,i,d,u,{className:"quote",begin:"^>\\s+",contains:m,end:"$"},l,r,a,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function _h(e){const n="\\[=*\\[",o="\\]=*\\]",r={begin:n,end:o,contains:["self"]},l=[e.COMMENT("--(?!"+n+")","$"),e.COMMENT("--"+n,o,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:l.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:l}].concat(l)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:n,end:o,contains:[r],relevance:5}])}}function xh(e){const n=e.regex,o={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[o]}]};Object.assign(o,{className:"variable",variants:[{begin:n.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const l={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},i=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),c={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},s={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,o,l]};l.contains.push(s);const a={match:/\\"/},d={className:"string",begin:/'/,end:/'/},u={match:/\\'/},f={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,o]},p=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],m=e.SHEBANG({binary:`(${p.join("|")})`,relevance:10}),h={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},y=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],N=["true","false"],L={match:/(\/[a-z._-]+)+/},S=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],G=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],K=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],F=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:y,literal:N,built_in:[...S,...G,"set","shopt",...K,...F]},contains:[m,e.SHEBANG(),h,f,i,c,L,s,a,d,u,o]}}function Mh(e){const n=["string","char","byte","int","long","bool","decimal","single","double","DateTime","xml","array","hashtable","void"],o="Add|Clear|Close|Copy|Enter|Exit|Find|Format|Get|Hide|Join|Lock|Move|New|Open|Optimize|Pop|Push|Redo|Remove|Rename|Reset|Resize|Search|Select|Set|Show|Skip|Split|Step|Switch|Undo|Unlock|Watch|Backup|Checkpoint|Compare|Compress|Convert|ConvertFrom|ConvertTo|Dismount|Edit|Expand|Export|Group|Import|Initialize|Limit|Merge|Mount|Out|Publish|Restore|Save|Sync|Unpublish|Update|Approve|Assert|Build|Complete|Confirm|Deny|Deploy|Disable|Enable|Install|Invoke|Register|Request|Restart|Resume|Start|Stop|Submit|Suspend|Uninstall|Unregister|Wait|Debug|Measure|Ping|Repair|Resolve|Test|Trace|Connect|Disconnect|Read|Receive|Send|Write|Block|Grant|Protect|Revoke|Unblock|Unprotect|Use|ForEach|Sort|Tee|Where",r="-and|-as|-band|-bnot|-bor|-bxor|-casesensitive|-ccontains|-ceq|-cge|-cgt|-cle|-clike|-clt|-cmatch|-cne|-cnotcontains|-cnotlike|-cnotmatch|-contains|-creplace|-csplit|-eq|-exact|-f|-file|-ge|-gt|-icontains|-ieq|-ige|-igt|-ile|-ilike|-ilt|-imatch|-in|-ine|-inotcontains|-inotlike|-inotmatch|-ireplace|-is|-isnot|-isplit|-join|-le|-like|-lt|-match|-ne|-not|-notcontains|-notin|-notlike|-notmatch|-or|-regex|-replace|-shl|-shr|-split|-wildcard|-xor",l={$pattern:/-?[A-z\.\-]+\b/,keyword:"if else foreach return do while until elseif begin for trap data dynamicparam end break throw param continue finally in switch exit filter try process catch hidden static parameter",built_in:"ac asnp cat cd CFS chdir clc clear clhy cli clp cls clv cnsn compare copy cp cpi cpp curl cvpa dbp del diff dir dnsn ebp echo|0 epal epcsv epsn erase etsn exsn fc fhx fl ft fw gal gbp gc gcb gci gcm gcs gdr gerr ghy gi gin gjb gl gm gmo gp gps gpv group gsn gsnp gsv gtz gu gv gwmi h history icm iex ihy ii ipal ipcsv ipmo ipsn irm ise iwmi iwr kill lp ls man md measure mi mount move mp mv nal ndr ni nmo npssc nsn nv ogv oh popd ps pushd pwd r rbp rcjb rcsn rd rdr ren ri rjb rm rmdir rmo rni rnp rp rsn rsnp rujb rv rvpa rwmi sajb sal saps sasv sbp sc scb select set shcm si sl sleep sls sort sp spjb spps spsv start stz sujb sv swmi tee trcm type wget where wjb write"},i=/\w[\w\d]*((-)[\w\d]+)*/,c={begin:"`[\\s\\S]",relevance:0},s={className:"variable",variants:[{begin:/\$\B/},{className:"keyword",begin:/\$this/},{begin:/\$[\w\d][\w\d_:]*/}]},a={className:"literal",begin:/\$(null|true|false)\b/},d={className:"string",variants:[{begin:/"/,end:/"/},{begin:/@"/,end:/^"@/}],contains:[c,s,{className:"variable",begin:/\$[A-z]/,end:/[^A-z]/}]},u={className:"string",variants:[{begin:/'/,end:/'/},{begin:/@'/,end:/^'@/}]},f={className:"doctag",variants:[{begin:/\.(synopsis|description|example|inputs|outputs|notes|link|component|role|functionality)/},{begin:/\.(parameter|forwardhelptargetname|forwardhelpcategory|remotehelprunspace|externalhelp)\s+\S+/}]},p=e.inherit(e.COMMENT(null,null),{variants:[{begin:/#/,end:/$/},{begin:/<#/,end:/#>/}],contains:[f]}),m={className:"built_in",variants:[{begin:"(".concat(o,")+(-)[\\w\\d]+")}]},h={className:"class",beginKeywords:"class enum",end:/\s*[{]/,excludeEnd:!0,relevance:0,contains:[e.TITLE_MODE]},y={className:"function",begin:/function\s+/,end:/\s*\{|$/,excludeEnd:!0,returnBegin:!0,relevance:0,contains:[{begin:"function",relevance:0,className:"keyword"},{className:"title",begin:i,relevance:0},{begin:/\(/,end:/\)/,className:"params",relevance:0,contains:[s]}]},N={begin:/using\s/,end:/$/,returnBegin:!0,contains:[d,u,{className:"keyword",begin:/(using|assembly|command|module|namespace|type)/}]},L={variants:[{className:"operator",begin:"(".concat(r,")\\b")},{className:"literal",begin:/(-){1,2}[\w\d-]+/,relevance:0}]},S={className:"selector-tag",begin:/@\B/,relevance:0},G={className:"function",begin:/\[.*\]\s*[\w]+[ ]??\(/,end:/$/,returnBegin:!0,relevance:0,contains:[{className:"keyword",begin:"(".concat(l.keyword.toString().replace(/\s/g,"|"),")\\b"),endsParent:!0,relevance:0},e.inherit(e.TITLE_MODE,{endsParent:!0})]},K=[G,p,c,e.NUMBER_MODE,d,u,m,s,a,S],F={begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0,relevance:0,contains:[].concat("self",K,{begin:"("+n.join("|")+")",className:"built_in",relevance:0},{className:"type",begin:/[\.\w\d]+/,relevance:0})};return G.contains.unshift(F),{name:"PowerShell",aliases:["pwsh","ps","ps1"],case_insensitive:!0,keywords:l,contains:K.concat(h,y,N,L,F)}}function Nh(e){const n=e.COMMENT(/^\s*@?rem\b/,/$/,{relevance:10});return{name:"Batch file (DOS)",aliases:["bat","cmd"],case_insensitive:!0,illegal:/\/\*/,keywords:{keyword:["if","else","goto","for","in","do","call","exit","not","exist","errorlevel","defined","equ","neq","lss","leq","gtr","geq"],built_in:["prn","nul","lpt3","lpt2","lpt1","con","com4","com3","com2","com1","aux","shift","cd","dir","echo","setlocal","endlocal","set","pause","copy","append","assoc","at","attrib","break","cacls","cd","chcp","chdir","chkdsk","chkntfs","cls","cmd","color","comp","compact","convert","date","dir","diskcomp","diskcopy","doskey","erase","fs","find","findstr","format","ftype","graftabl","help","keyb","label","md","mkdir","mode","more","move","path","pause","print","popd","pushd","promt","rd","recover","rem","rename","replace","restore","rmdir","shift","sort","start","subst","time","title","tree","type","ver","verify","vol","ping","net","ipconfig","taskkill","xcopy","ren","del"]},contains:[{className:"variable",begin:/%%[^ ]|%[^ ]+?%|![^ ]+?!/},{className:"function",begin:{begin:"^\\s*[A-Za-z._?][A-Za-z0-9_$#@~.?]*(:|\\s+label)"}.begin,end:"goto:eof",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),n]},{className:"number",begin:"\\b\\d+",relevance:0},n]}}function Sh(e){const n=e.regex,o=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},l={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],c=["double precision","large object","with timezone","without timezone"],s=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],a=["add","asc","collation","desc","final","first","last","view"],d=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],u=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],f=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],p=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],m=u,h=[...d,...a].filter(F=>!u.includes(F)),y={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},N={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},L={match:n.concat(/\b/,n.either(...m),/\s*\(/),relevance:0,keywords:{built_in:m}};function S(F){return n.concat(/\b/,n.either(...F.map(Y=>Y.replace(/\s+/,"\\s+"))),/\b/)}const G={scope:"keyword",match:S(p),relevance:0};function K(F,{exceptions:Y,when:ae}={}){const ne=ae;return Y=Y||[],F.map(te=>te.match(/\|\d+$/)||Y.includes(te)?te:ne(te)?`${te}|0`:te)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:K(h,{when:F=>F.length<3}),literal:i,type:s,built_in:f},contains:[{scope:"type",match:S(c)},G,L,y,r,l,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,o,N]}}function Ah(e){const n={className:"subst",variants:[{begin:"\\$[A-Za-z0-9_]+"}]},o={className:"subst",variants:[{begin:/\$\{/,end:/\}/}],keywords:"true false null this is new super"},r={className:"number",relevance:0,variants:[{match:/\b[0-9][0-9_]*(\.[0-9][0-9_]*)?([eE][+-]?[0-9][0-9_]*)?\b/},{match:/\b0[xX][0-9A-Fa-f][0-9A-Fa-f_]*\b/}]},l={className:"string",variants:[{begin:"r'''",end:"'''"},{begin:'r"""',end:'"""'},{begin:"r'",end:"'",illegal:"\\n"},{begin:'r"',end:'"',illegal:"\\n"},{begin:"'''",end:"'''",contains:[e.BACKSLASH_ESCAPE,n,o]},{begin:'"""',end:'"""',contains:[e.BACKSLASH_ESCAPE,n,o]},{begin:"'",end:"'",illegal:"\\n",contains:[e.BACKSLASH_ESCAPE,n,o]},{begin:'"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE,n,o]}]};o.contains=[r,l];const i=["Comparable","DateTime","Duration","Function","Iterable","Iterator","List","Map","Match","Object","Pattern","RegExp","Set","Stopwatch","String","StringBuffer","StringSink","Symbol","Type","Uri","bool","double","int","num","Element","ElementList"],c=i.map(d=>`${d}?`);return{name:"Dart",keywords:{keyword:["abstract","as","assert","async","await","base","break","case","catch","class","const","continue","covariant","default","deferred","do","dynamic","else","enum","export","extends","extension","external","factory","false","final","finally","for","Function","get","hide","if","implements","import","in","interface","is","late","library","mixin","new","null","on","operator","part","required","rethrow","return","sealed","set","show","static","super","switch","sync","this","throw","true","try","typedef","var","void","when","while","with","yield"],built_in:i.concat(c).concat(["Never","Null","dynamic","print","document","querySelector","querySelectorAll","window"]),$pattern:/[A-Za-z][A-Za-z0-9_]*\??/},contains:[l,e.COMMENT(/\/\*\*(?!\/)/,/\*\//,{subLanguage:"markdown",relevance:0}),e.COMMENT(/\/{3,} ?/,/$/,{contains:[{subLanguage:"markdown",begin:".",end:"$",relevance:0}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"class",beginKeywords:"class interface",end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},r,{className:"meta",begin:"@[A-Za-z]+"},{begin:"=>"}]}}const Ih=[["javascript",Kp],["typescript",Gp],["python",qp],["java",Yp],["c",Zp],["cpp",Xp],["csharp",jp],["go",Qp],["rust",Jp],["ruby",eh],["php",th],["swift",ah],["kotlin",uh],["xml",fh],["css",Eh],["json",vh],["yaml",Ch],["markdown",Th],["lua",_h],["bash",xh],["powershell",Mh],["dos",Nh],["sql",Sh],["dart",Ah]];for(const[e,n]of Ih)As.registerLanguage(e,n);const Bh={javascript:"javascript",typescript:"typescript",python:"python",java:"java",c:"c",cpp:"cpp",csharp:"csharp",go:"go",rust:"rust",ruby:"ruby",php:"php",swift:"swift",kotlin:"kotlin",html:"xml",css:"css",json:"json",xml:"xml",yaml:"yaml",markdown:"markdown",lua:"lua",bash:"bash",shell:"bash",powershell:"powershell",cmd:"dos",bat:"dos",sql:"sql",dart:"dart"};function js(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Rh(e,n){const o=Bh[n];if(!o||e.length===0)return js(e);try{return As.highlight(e,{language:o,ignoreIllegals:!0}).value}catch{return js(e)}}const Lh=t.defineComponent({name:"CodeBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){const n=t.ref(null),o=Zt(),r=Yn(),l=t.computed(()=>Rh(Ae(e.block.content),e.block.attrs.language??"plain"));return()=>{const i=e.block.attrs.language??"plain",c=t.h("div",{ref:n,class:"block-code-lang",onMousedown:d=>{d.preventDefault(),d.stopPropagation()},onClick:d=>{if(d.stopPropagation(),!r.value)return;const u=new CustomEvent("code-lang-click",{bubbles:!0,detail:{blockId:e.block.id,anchor:n.value}});d.currentTarget.dispatchEvent(u)}},i.toUpperCase()),s=t.h("div",{class:"block-code-title"},o.t("codeBlock.title")),a=t.h("pre",{class:"block-code-highlight","aria-hidden":"true"},[t.h("code",{class:"hljs",innerHTML:l.value})]);return t.h("div",{class:["block-code-wrapper","block-focus-root",...xn(e.block.attrs)],"data-lang":i},[s,c,a,t.h(Vn,{block:e.block,placeholder:e.placeholder,class:"block-code"})])}}}),Oh={name:"codeBlock",schema:{type:"codeBlock",content:"text",nestable:!1,isolating:!0,inlineMarks:!1,attrs:{...Wd,language:{default:"plain",validate:e=>typeof e=="string"&&e.length>0}}},renderer:{component:Lh},slashCommands:[{id:"code-block",title:"slash.codeBlock.title",keywords:["code","fence","pre","代码","代码块","```","codeblock"],description:"slash.codeBlock.description",icon:ul,command:"convertBlock",category:"other",args:()=>({id:"__currentBlock__",type:"codeBlock",attrs:{language:"plain"}})}],inputRules:[{name:"code-fence",pattern:/^``` ?$/,command:"convertBlock",args:e=>(e==null||e.input,{id:"__currentBlock__",type:"codeBlock",attrs:{language:"plain"},__stripPrefix:3})}]},Dh={align:Xt.align,indent:Xt.indent,src:{default:"",validate:e=>typeof e=="string"},alt:{default:"",validate:e=>typeof e=="string"},title:{default:"",validate:e=>typeof e=="string"},width:{default:0,validate:e=>typeof e=="number"&&Number.isFinite(e)&&e>=0},height:{default:0,validate:e=>typeof e=="number"&&Number.isFinite(e)&&e>=0},caption:{default:"",validate:e=>typeof e=="string"},fileId:{default:0,validate:e=>typeof e=="number"&&Number.isFinite(e)&&Number.isInteger(e)&&e>=0}},$h=t.defineComponent({name:"ImageBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){e.placeholder;const n=cn(),o=Yn(),r=Zt(),l=e.block.id,i=t.ref(Xn(l)),c=Oi((B,$)=>{B===l&&(i.value=$)});t.onBeforeUnmount(()=>{c()});const s=t.ref(null),a=t.ref(null),d=t.ref(!1);let u=0,f=0,p=0,m=1;function h(){var M,A;const B=a.value;if(!B)return;s.value={w:B.naturalWidth,h:B.naturalHeight};const $=e.block.attrs;(!$.width||$.width===0)&&(!$.height||$.height===0)&&((A=(M=n.commands).setAttrs)==null||A.call(M,{id:l,attrs:{...$,width:B.naturalWidth,height:B.naturalHeight}}))}function y(B){var x,z,U;B.preventDefault(),B.stopPropagation();const $=e.block.attrs,M=(x=a.value)==null?void 0:x.closest(".block-image-container"),A=M?M.clientWidth-8:0;let w=$.width||((z=s.value)==null?void 0:z.w)||200,C=$.height||((U=s.value)==null?void 0:U.h)||150;if(C>N){const fe=w/Math.max(1,C);C=N,w=Math.round(C*fe)}if(A>0&&w>A){const fe=w/Math.max(1,C);w=A,C=Math.round(w/fe)}u=w,f=C,p=B.clientX,m=u/Math.max(1,f),d.value=!0,document.addEventListener("mousemove",L,!0),document.addEventListener("mouseup",S,!0),document.addEventListener("selectstart",G,!0)}const N=600;function L(B){var C,x,z;if(!d.value)return;const $=B.clientX-p;let M=Math.max(40,Math.round(u+$)),A=Math.max(40,Math.round(M/m));A>N&&(A=N,M=Math.max(40,Math.round(A*m)));const w=(C=a.value)==null?void 0:C.closest(".block-image-container");if(w){const U=w.clientWidth-8;M>U&&(M=Math.max(40,U),A=Math.max(40,Math.round(M/m)))}(z=(x=n.commands).setAttrs)==null||z.call(x,{id:l,attrs:{...e.block.attrs,width:M,height:A}})}function S(){d.value=!1,document.removeEventListener("mousemove",L,!0),document.removeEventListener("mouseup",S,!0),document.removeEventListener("selectstart",G,!0)}function G(B){B.preventDefault()}const K=t.ref(null);function F(){if(!K.value){const B=document.createElement("input");B.type="file",B.accept="image/*",B.multiple=!1,K.value=B,B.addEventListener("change",()=>{var M;const $=(M=B.files)==null?void 0:M[0];$&&Y($),B.value=""})}K.value.click()}function Y(B){const $=Xr(B),M=new AbortController;_n(l,{status:"pending",progress:0,file:B,tempPreviewUrl:$,controller:M}),Di(B.name,B,M,{onProgress:A=>{const w=Xn(l);w&&_n(l,{...w,progress:Math.max(0,Math.min(1,A))})},onSuccess:A=>{var z,U;const w=Xn(l);if(w!=null&&w.tempPreviewUrl&&w.tempPreviewUrl!==A.url)try{URL.revokeObjectURL(w.tempPreviewUrl)}catch{}const C={...e.block.attrs,src:A.url},x={...C,width:A.width??C.width,height:A.height??C.height,alt:A.alt??C.alt,title:A.title??C.title,fileId:A.fileId??C.fileId};(U=(z=n.commands).setAttrs)==null||U.call(z,{id:l,attrs:x}),_n(l,null)},onError:A=>{const w=Xn(l);w&&_n(l,{...w,status:"error",progress:0,error:A})}})}function ae(){const B=Xn(l);!B||!B.file||Y(B.file)}function ne(){var B,$;($=(B=n.commands).removeBlock)==null||$.call(B,{id:l})}function te(){const B=i.value;return B!=null&&B.tempPreviewUrl?B.tempPreviewUrl:e.block.attrs.src??""}function X(B){var $,M;B.stopPropagation(),o.value&&((M=($=n.commands).selectBlock)==null||M.call($,{id:l}))}return()=>{const B=e.block.attrs,$=te(),M=i.value,A=B.width,w=B.height;let C=A;A>0&&w>N&&(C=Math.max(1,Math.round(A*N/w)));const x={},z=(M==null?void 0:M.status)==="error";A&&A>0&&!z&&(x.width=`${C}px`);const U=[],fe=!!M&&M.status!=="success",oe=n.getState().selection,ue=oe.kind==="blocks"&&oe.blockIds.includes(l);if(o.value&&U.push(t.h("div",{class:["image-block-toolbar",{"image-block-toolbar-visible":fe||ue}]},[t.h("button",{class:"image-block-btn",title:r.t("image.replace"),onClick:Ce=>{Ce.stopPropagation(),F()}},[t.h(dn,{html:Qd})]),t.h("button",{class:"image-block-btn",title:r.t("image.remove"),onClick:Ce=>{Ce.stopPropagation(),ne()}},[t.h(dn,{html:jd})])])),(M==null?void 0:M.status)==="pending"){const Ce=Math.round(M.progress*100);U.push(t.h("div",{class:"image-block-upload-overlay"},[t.h(dn,{html:Zd,class:"image-block-spinner"}),t.h("div",{class:"image-block-upload-label"},r.t("image.uploading")),t.h("div",{class:"image-block-progress-track"},[t.h("div",{class:"image-block-progress-bar",style:{width:`${Ce}%`}})]),t.h("div",{class:"image-block-progress-pct"},`${Ce}%`)]))}if((M==null?void 0:M.status)==="error"&&U.push(t.h("div",{class:"image-block-error-overlay"},[t.h("div",{class:"image-block-error-icon"},"!"),t.h("div",{class:"image-block-error-title"},r.t("image.uploadFailed")),t.h("div",{class:"image-block-error-msg"},M.error??""),t.h("button",{class:"image-block-retry-btn",onClick:Ce=>{Ce.stopPropagation(),ae()}},[t.h(dn,{html:Xd})," ",r.t("image.retry")])])),!$&&(!M||M.status==="success")&&U.push(t.h("div",{class:"image-block-empty",onClick:Ce=>{Ce.stopPropagation(),o.value&&F()}},[t.h(dn,{html:Jd,class:"image-block-empty-icon"}),t.h("div",{class:"image-block-empty-title"},r.t("image.emptyTitle")),t.h("div",{class:"image-block-empty-sub"},r.t("image.emptySub"))])),$&&(M==null?void 0:M.status)!=="error"){const Ce={};A&&A>0&&(Ce.width=`${C}px`);const je=[t.h("img",{ref:a,class:"image-block-img",src:$,alt:B.alt||"",title:B.title||"",style:Ce,draggable:!1,onLoad:h,onError:()=>{(!M||M.status!=="pending"&&M.status!=="error")&&_n(l,{status:"error",progress:0,error:r.t("image.loadFailed"),tempPreviewUrl:void 0})}})];s.value&&o.value&&je.push(t.h("div",{class:"image-block-resize-handle",onMousedown:y,title:r.t("image.resize")})),U.push(t.h("div",{class:"image-block-main"},je))}const xe=B.caption||"";!((M==null?void 0:M.status)==="error")&&(xe||$)&&U.push(t.h("div",{class:"image-block-caption",contenteditable:o.value?"true":"false","data-placeholder":r.t("image.captionPlaceholder"),onBlur:Ce=>{var ct,St;const je=Ce.currentTarget.textContent??"";je!==xe&&((St=(ct=n.commands).setAttrs)==null||St.call(ct,{id:l,attrs:{...e.block.attrs,caption:je}}))},onInput:()=>{},onMousedown:Ce=>{Ce.stopPropagation()},onClick:Ce=>{Ce.stopPropagation()}},xe));const qe=["block-image-wrapper"];return(M==null?void 0:M.status)==="error"&&qe.push("image-block-wrapper-error"),(M==null?void 0:M.status)==="pending"&&!$&&!M.tempPreviewUrl&&qe.push("image-block-wrapper-loading"),t.h("div",{class:["block-image-container","block-focus-root",...xn(B)]},[t.h("div",{class:qe,style:x,onClick:X},U)])}}}),Qs={name:"image",schema:{type:"image",content:"none",nestable:!1,attrs:{...Dh},empty:e=>{const n=e.attrs.src;return typeof n!="string"||n.length===0}},renderer:{component:$h,editable:!1},slashCommands:[{id:"image",title:"slash.image.title",keywords:["image","picture","photo","img","图片","图像","照片"],description:"slash.image.description",icon:Yd,command:"convertBlock",category:"other",args:()=>({id:"__currentBlock__",type:"image",attrs:{}})}],serialize:{toHTML:e=>{const n=e.attrs,o=n.src;if(!o)return"";const r=n.alt||"",l=n.title||"",i=n.width,c=n.height,s=n.caption||"",a=[];i&&i>0&&a.push(`width:${i}px`),c&&c>0&&a.push(`height:${c}px`);const d=a.length?` style="${a.join(";")}"`:"",u=l?` title="${vl(l)}"`:"",f=`<img src="${vl(o)}" alt="${vl(r)}"${u}${d}>`;return s?`<figure>${f}<figcaption>${Ph(s)}</figcaption></figure>`:f},toMarkdown:e=>{const n=e.attrs,o=n.src;if(!o)return"";const r=n.alt||"",l=n.title||"",i=n.caption||"",c=l?``:``;return i?`${c}
|
|
17
|
-
*${i}*`:c}}};function vl(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Ph(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}const Cr='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="3" width="12" height="10" rx="1"/><path d="M2 7h12M2 10h12M6 3v10M10 3v10"/></svg>',Hh='<svg viewBox="0 0 1024 1024" width="14" height="14" fill="currentColor" aria-hidden="true"><path d="M160 85.333333a32 32 0 0 0-32 32v42.666667A138.666667 138.666667 0 0 0 266.666667 298.666667h490.666666A138.666667 138.666667 0 0 0 896 160v-42.666667a32 32 0 0 0-64 0v42.666667a74.666667 74.666667 0 0 1-74.666667 74.666667H661.333333V117.333333a32 32 0 0 0-64 0V234.666667h-170.666666V117.333333a32 32 0 0 0-64 0V234.666667H266.666667A74.666667 74.666667 0 0 1 192 160v-42.666667A32 32 0 0 0 160 85.333333zM160 938.666667a32 32 0 0 1-32-32v-42.666667A138.666667 138.666667 0 0 1 266.666667 725.333333h490.666666A138.666667 138.666667 0 0 1 896 864v42.666667a32 32 0 0 1-64 0v-42.666667a74.666667 74.666667 0 0 0-74.666667-74.666667H661.333333v117.333334a32 32 0 0 1-64 0V789.333333h-170.666666v117.333334a32 32 0 0 1-64 0V789.333333H266.666667a74.666667 74.666667 0 0 0-74.666667 74.666667v42.666667a32 32 0 0 1-32 32zM512 557.226667l62.72 62.72a32 32 0 1 0 45.226667-45.226667L557.226667 512l62.72-62.72a32 32 0 1 0-45.226667-45.226667L512 466.773333l-62.72-62.72a32 32 0 1 0-45.226667 45.226667L466.773333 512l-62.72 62.72a32 32 0 1 0 45.226667 45.226667L512 557.226667z"/><path d="M372.352 544c0.981333-1.109333 2.005333-2.176 3.072-3.242667L404.181333 512l-28.757333-28.757333a78.72 78.72 0 0 1-3.072-3.242667H117.333333a32 32 0 0 0 0 64h255.018667zM662.314667 544h244.352a32 32 0 0 0 0-64h-244.352a77.909333 77.909333 0 0 1-3.072 3.242667l-28.757334 28.757333 28.757334 28.757333 3.072 3.242667z"/></svg>',Vh='<svg viewBox="0 0 1024 1024" width="14" height="14" fill="currentColor" aria-hidden="true"><path d="M938.666667 160a32 32 0 0 0-32-32h-42.666667A138.666667 138.666667 0 0 0 725.333333 266.666667v490.666666A138.666667 138.666667 0 0 0 864 896h42.666667a32 32 0 0 0 0-64h-42.666667a74.666667 74.666667 0 0 1-74.666667-74.666667V661.333333h117.333334a32 32 0 0 0 0-64H789.333333v-170.666666h117.333334a32 32 0 0 0 0-64H789.333333V266.666667c0-41.216 33.450667-74.666667 74.666667-74.666667h42.666667a32 32 0 0 0 32-32zM85.333333 160A32 32 0 0 1 117.333333 128h42.666667A138.666667 138.666667 0 0 1 298.666667 266.666667v490.666666A138.666667 138.666667 0 0 1 160 896h-42.666667a32 32 0 0 1 0-64h42.666667a74.666667 74.666667 0 0 0 74.666667-74.666667V661.333333H117.333333a32 32 0 0 1 0-64H234.666667v-170.666666H117.333333a32 32 0 0 1 0-64H234.666667V266.666667A74.666667 74.666667 0 0 0 160 192h-42.666667A32 32 0 0 1 85.333333 160zM466.773333 512l-62.72 62.72a32 32 0 1 0 45.226667 45.226667L512 557.226667l62.72 62.72a32 32 0 1 0 45.226667-45.226667L557.226667 512l62.72-62.72a32 32 0 1 0-45.226667-45.226667L512 466.773333l-62.72-62.72a32 32 0 1 0-45.226667 45.226667L466.773333 512z"/><path d="M480 372.352c1.109333 0.981333 2.176 2.005333 3.242667 3.072l28.757333 28.757333 28.757333-28.757333c1.066667-1.066667 2.133333-2.090667 3.242667-3.072V117.333333a32 32 0 0 0-64 0v255.018667zM480 662.314667v244.352a32 32 0 0 0 64 0v-244.352a77.909333 77.909333 0 0 1-3.242667-3.072L512 630.485333l-28.757333 28.757334-3.242667 3.072z"/></svg>',Js='<svg viewBox="0 0 1024 1024" width="14" height="14" fill="currentColor" aria-hidden="true"><path d="M128 266.666667A138.666667 138.666667 0 0 1 266.666667 128h490.666666A138.666667 138.666667 0 0 1 896 266.666667v246.272a276.096 276.096 0 0 0-64-30.250667V426.666667h-170.666667v56.021333a276.096 276.096 0 0 0-64 30.250667V426.666667h-170.666666v170.666666h86.272a276.096 276.096 0 0 0-30.250667 64H426.666667v170.666667h56.021333c7.381333 22.784 17.578667 44.245333 30.250667 64H266.666667A138.666667 138.666667 0 0 1 128 757.333333V266.666667zM266.666667 192A74.666667 74.666667 0 0 0 192 266.666667V362.666667h170.666667v-170.666667H266.666667zM192 426.666667v170.666666h170.666667v-170.666666h-170.666667z m469.333333-64h170.666667V266.666667a74.666667 74.666667 0 0 0-74.666667-74.666667H661.333333v170.666667z m-64-170.666667h-170.666666v170.666667h170.666666v-170.666667z m-405.333333 469.333333v96c0 41.216 33.450667 74.666667 74.666667 74.666667H362.666667v-170.666667h-170.666667z"/><path d="M981.333333 746.666667a234.666667 234.666667 0 1 1-469.333333 0 234.666667 234.666667 0 0 1 469.333333 0z m-234.666666-30.165334l-70.229334-70.272a21.333333 21.333333 0 0 0-30.208 30.208l70.272 70.229334-70.272 70.229333a21.333333 21.333333 0 0 0 30.208 30.208l70.229334-70.272 70.229333 70.272a21.333333 21.333333 0 0 0 30.208-30.208L776.832 746.666667l70.272-70.229334a21.333333 21.333333 0 0 0-30.208-30.208L746.666667 716.501333z"/></svg>',Uh={indent:Xt.indent,rows:{default:3,validate:e=>typeof e=="number"&&Number.isInteger(e)&&e>=1},cols:{default:3,validate:e=>typeof e=="number"&&Number.isInteger(e)&&e>=1},cells:{default:[],validate:ed},colWidths:{default:[],validate:e=>Array.isArray(e)},headerRow:{default:!1,validate:e=>typeof e=="boolean"}},zh=t.defineComponent({name:"TableBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e,{expose:n}){e.placeholder;const o=cn(),r=Yn(),l=Zt(),i=e.block.id,c=t.inject($r,null),s=t.computed(()=>ro(e.block.attrs)),a=new Map,d=t.ref(null),u=t.ref(null),f=t.ref(null);let p=0;const m=500;function h(){return Date.now()-p<m}function y(E){var I;const _=E.target;!!(_&&(_.nodeType===1?_.closest(".hover-toolbar"):(I=_.parentElement)!=null&&I.closest(".hover-toolbar")))&&(p=Date.now())}function N(){p=Date.now()}const L=t.ref(null);let S=0,G=0;const K=t.ref({kind:"none"}),F=t.ref(null);let Y=!1;const ae=t.ref(null);let ne=null,te=null,X=!1,B=!1;const $=t.reactive({blockType:"paragraph",blockAttrs:{align:"left"},marks:new Set,textColor:"",bgColor:"",verticalAlign:"middle",showDelete:!1,deleteLabel:"",deleteIcon:Js,showMerge:!1,showSplit:!1,showHeaderRow:!1,headerRowActive:!1}),M=t.ref(null),A=t.reactive({visible:!1,selectionRect:null}),w=t.reactive({visible:!1,anchorRect:null,href:"",text:"",initialMode:"edit",showTextInput:!1});let C=null,x=null,z=!1;const U=t.reactive({visible:!1,row:-1,col:-1,anchor:null,canContinue:!1,canStartNew:!1,currentNumber:1});function fe(){U.visible=!1,U.anchor=null,U.row=-1,U.col=-1}const oe=t.reactive({visible:!1,row:-1,col:-1,anchor:null,initialValue:1});function ue(){oe.visible=!1,oe.anchor=null,oe.row=-1,oe.col=-1}function xe(E,_,T){var he,ge;if(!r.value)return;const I=(he=s.value.cells[E])==null?void 0:he[_];if(!I||I.covered||I.cellType!=="orderedList")return;const V=qr(s.value,E,_),q=typeof I.startNumber=="number";let j=!1;for(let we=E-1;we>=0;we--){const Be=(ge=s.value.cells[we])==null?void 0:ge[_];if(!(!Be||Be.covered)){j=Be.cellType==="orderedList";break}}const ie=q&&j,me=V!==1;ct(),A.visible=!1,A.selectionRect=null,ue(),U.visible=!0,U.row=E,U.col=_,U.anchor=T,U.canContinue=ie,U.canStartNew=me,U.currentNumber=V}function pe(){var _,T;if(U.row<0||U.col<0)return;const E=Uo(s.value,U.row,U.col,{startNumber:null});(T=(_=o.commands).setAttrs)==null||T.call(_,{id:i,attrs:E}),fe()}function qe(){var _,T;if(U.row<0||U.col<0)return;const E=Uo(s.value,U.row,U.col,{startNumber:1});(T=(_=o.commands).setAttrs)==null||T.call(_,{id:i,attrs:E}),fe()}function Ce(){if(U.row<0||U.col<0)return;const E=U.anchor,_=U.row,T=U.col,I=U.currentNumber;fe(),E&&(oe.visible=!0,oe.initialValue=I,oe.anchor=E,oe.row=_,oe.col=T)}function je(E){var T,I;if(oe.row<0||oe.col<0){ue();return}const _=Uo(s.value,oe.row,oe.col,{startNumber:E});(I=(T=o.commands).setAttrs)==null||I.call(T,{id:i,attrs:_}),ue()}function ct(){if(!w.visible)return;if(w.visible=!1,C=null,x=null,A.visible=!1,A.selectionRect=null,z){z=!1;return}const E=f.value;if(E){const _=a.get(`${E.row}-${E.col}`);_&&P(E.row,E.col,_),f.value=null}}function St(){const E=window.getSelection();if(!E||E.rangeCount===0)return null;const T=E.getRangeAt(0).commonAncestorContainer,I=T.nodeType===1?T:T.parentElement;return I?I.closest("a"):null}function At(){const E=window.getSelection();if(!E||E.rangeCount===0)return;const _=E.getRangeAt(0),T=_.getBoundingClientRect();if(T.width===0&&T.height===0)return;C=_.cloneRange();const I=St(),V=(I==null?void 0:I.getAttribute("href"))??"",q=E.toString();w.anchorRect=T,w.href=V,w.text=q,w.initialMode=V?"view":"edit",w.showTextInput=!q&&!V,w.visible=!0,A.visible=!1}function Et(E){const _=E.getAttribute("href")||"",T=E.textContent||"",I=E.getBoundingClientRect();w.anchorRect=I,w.href=_,w.text=T,w.initialMode="view",w.showTextInput=!1,w.visible=!0,z=!0,x=E,A.visible=!1,A.selectionRect=null}function qt(E){const _=E.closest(".table-cell-inner");if(!_)return;const T=_.closest(".table-cell");if(!T)return;const I=Number(T.getAttribute("data-row")),V=Number(T.getAttribute("data-col"));!Number.isFinite(I)||!Number.isFinite(V)||P(I,V,_)}function bt(E,_){if(x&&x.isConnected){x.setAttribute("href",E),x.setAttribute("target","_blank"),x.setAttribute("rel","noopener noreferrer"),_!==void 0&&_!==x.textContent&&(x.textContent=_),qt(x);return}const T=window.getSelection();if(!T)return;if(C){const V=f.value,q=V?a.get(`${V.row}-${V.col}`):null;q&&q.isConnected&&(T.removeAllRanges(),T.addRange(C))}const I=St();if(I)I.setAttribute("href",E),I.setAttribute("target","_blank"),I.setAttribute("rel","noopener noreferrer"),_!==void 0&&_!==I.textContent&&(I.textContent=_);else{if(T.rangeCount===0)return;const V=T.getRangeAt(0),q=document.createElement("a");q.setAttribute("href",E),q.setAttribute("target","_blank"),q.setAttribute("rel","noopener noreferrer");try{q.appendChild(V.extractContents()),V.insertNode(q),T.removeAllRanges();const j=document.createRange();j.selectNodeContents(q),T.addRange(j),C=j.cloneRange()}catch{}}nt()}function vt(){if(x&&x.isConnected){const I=x,V=I.parentElement;if(V){for(;I.firstChild;)V.insertBefore(I.firstChild,I);V.removeChild(I)}qt(I);return}const E=window.getSelection();if(!E)return;if(C){const I=f.value,V=I?a.get(`${I.row}-${I.col}`):null;V&&V.isConnected&&(E.removeAllRanges(),E.addRange(C))}const _=St();if(!_)return;const T=_.parentElement;if(T){for(;_.firstChild;)T.insertBefore(_.firstChild,_);T.removeChild(_);try{E.removeAllRanges(),C&&C.startContainer!==_&&E.addRange(C)}catch{}nt()}}function nt(){const E=f.value;if(!E)return;const _=a.get(`${E.row}-${E.col}`);_&&P(E.row,E.col,_)}let Pe=!1;function mt(){var q,j;if(!r.value){A.visible=!1,A.selectionRect=null;return}if(A.visible&&h())return;if(!f.value){const ie=window.getSelection();if(!ie||ie.rangeCount===0||ie.isCollapsed){A.visible=!1,A.selectionRect=null;return}const me=ie.getRangeAt(0);if(!((q=me.commonAncestorContainer.nodeType===1?me.commonAncestorContainer:me.commonAncestorContainer.parentElement)==null?void 0:q.closest(".table-cell-inner"))){A.visible=!1,A.selectionRect=null;return}return}const _=window.getSelection();if(!_||_.rangeCount===0||_.isCollapsed){A.visible=!1,A.selectionRect=null;return}const T=_.getRangeAt(0);if(!((j=T.commonAncestorContainer.nodeType===1?T.commonAncestorContainer:T.commonAncestorContainer.parentElement)==null?void 0:j.closest(".table-cell-inner"))){A.visible=!1,A.selectionRect=null;return}const V=T.getBoundingClientRect();if(V.width===0&&V.height===0){A.visible=!1,A.selectionRect=null;return}Pe||(A.visible=!0,A.selectionRect=V,ne&&(clearTimeout(ne),ne=null),ae.value=null)}function de(){Pe&&(Pe=!1,mt())}function at(E){const _=Oe.value;if(!_)return E;const T=_.getBoundingClientRect();return new DOMRect(T.left+E.left-_.scrollLeft,T.top+E.top,E.width,E.height)}function Ke(E){r.value&&(ne&&(clearTimeout(ne),ne=null),te&&(clearTimeout(te),te=null),A.visible=!1,A.selectionRect=null,X=!1,ae.value=at(E))}function _e(E=150){te&&(clearTimeout(te),te=null),X=!1,ne=setTimeout(()=>{ae.value=null,ne=null},E)}function Rt(){const E=M.value;E&&E.focus()}function ot(E){var T,I;const _=E.target;if(_.closest("a")&&_.closest(".table-cell-inner")){E.preventDefault();return}_.closest(".table-cell, .table-wrapper, table, .table-row-strip, .table-col-strip, .table-insert-dot, .table-corner-handle")||(E.stopPropagation(),K.value={kind:"none"},u.value=null,_e(0),(I=(T=o.commands).selectBlock)==null||I.call(T,{id:i}))}function It(E,_){if(E.length!==_.length)return!1;for(let T=0;T<E.length;T++){const I=E[T],V=_[T];if(I.type!==V.type||"text"in I&&I.text!==V.text)return!1;const q=I.marks??[],j=V.marks??[];if(q.length!==j.length)return!1;for(let ie=0;ie<q.length;ie++){const me=q[ie],he=j[ie];if(me.type!==he.type)return!1;const ge=me.attrs??{},we=he.attrs??{},Be=Object.keys(ge),De=Object.keys(we);if(Be.length!==De.length)return!1;for(const rt of Be)if(ge[rt]!==we[rt])return!1}}return!0}function P(E,_,T){var me,he,ge;const I=an(T),V=lr(I),q=s.value,j=(me=q.cells[E])==null?void 0:me[_];if(j&&It(j.content,V))return;const ie=Vo(q,E,_,V);if((ge=(he=o.commands).setAttrs)==null||ge.call(he,{id:i,attrs:ie}),V!==I){const we=Zn(V);T.innerHTML!==we&&(T.innerHTML=we)}}function k(E,_,T,I){var q,j,ie;if(A.visible&&h())return;const V=I==null?void 0:I.relatedTarget;if(!(V!=null&&V.closest(".link-popover"))&&!(V!=null&&V.closest(".hover-toolbar"))){if(A.visible){const me=window.getSelection();if(me&&me.rangeCount>0&&!me.isCollapsed){const he=me.getRangeAt(0);if((q=he.commonAncestorContainer.nodeType===1?he.commonAncestorContainer:he.commonAncestorContainer.parentElement)==null?void 0:q.closest(".table-cell-inner"))return}}((j=f.value)==null?void 0:j.row)===E&&((ie=f.value)==null?void 0:ie.col)===_&&(f.value=null),A.visible=!1,A.selectionRect=null,ct(),P(E,_,T)}}function W(E){var I;if(A.visible&&h()){u.value&&(u.value=null),K.value.kind!=="none"&&(K.value={kind:"none"},_e(0)),fe(),ue();return}const _=E.currentTarget,T=E.relatedTarget;if(!(T&&_.contains(T))&&!(T!=null&&T.closest(".link-popover"))&&!(T!=null&&T.closest(".hover-toolbar"))){if(A.visible){const V=window.getSelection();if(V&&V.rangeCount>0&&!V.isCollapsed){const q=V.getRangeAt(0);if((I=q.commonAncestorContainer.nodeType===1?q.commonAncestorContainer:q.commonAncestorContainer.parentElement)==null?void 0:I.closest(".table-cell-inner")){u.value&&(u.value=null),K.value.kind!=="none"&&(K.value={kind:"none"},_e(0)),fe(),ue();return}}}u.value&&(u.value=null),K.value.kind!=="none"&&(K.value={kind:"none"},_e(0)),f.value&&(f.value=null),ct(),fe(),ue()}}function ye(E,_,T,I){var V,q,j,ie,me,he,ge,we,Be,De,rt,Wt,Jt;if(I.key==="Enter"&&!I.shiftKey&&!I.ctrlKey&&!I.metaKey){const Mt=(V=s.value.cells[E])==null?void 0:V[_];if((Mt==null?void 0:Mt.cellType)==="codeBlock"){I.preventDefault(),I.stopPropagation();const He=window.getSelection();let yt=((q=T.textContent)==null?void 0:q.length)??0;if(He&&He.rangeCount>0){const it=He.getRangeAt(0);if(T.contains(it.startContainer)){const xt=document.createRange();xt.selectNodeContents(T);try{xt.setEnd(it.startContainer,it.startOffset),yt=xt.toString().length}catch{yt=((j=T.textContent)==null?void 0:j.length)??0}}}if(He&&He.rangeCount>0){const it=He.getRangeAt(0);if(T.contains(it.commonAncestorContainer)){it.collapsed||it.deleteContents();const xt=document.createTextNode(`
|
|
18
|
-
`);it.insertNode(xt),it.setStartAfter(xt),it.collapse(!0),He.removeAllRanges(),He.addRange(it)}}P(E,_,T);const Gt=yt+1;t.nextTick(()=>{const it=a.get(`${E}-${_}`);if(!it)return;it.focus();const xt=window.getSelection();if(!xt)return;const ut=document.createRange();let en=0,Ht=!1;const un=Vt=>{var Yt;if(!Ht)if(Vt.nodeType===Node.TEXT_NODE){const fn=((Yt=Vt.textContent)==null?void 0:Yt.length)??0;en+fn>=Gt&&(ut.setStart(Vt,Math.max(0,Gt-en)),ut.collapse(!0),Ht=!0),en+=fn}else for(const fn of Vt.childNodes)un(fn)};un(it),Ht||(ut.selectNodeContents(it),ut.collapse(!1)),xt.removeAllRanges(),xt.addRange(ut)});return}I.preventDefault(),I.stopPropagation(),P(E,_,T),f.value=null,A.visible=!1,A.selectionRect=null,ct(),T.blur(),K.value={kind:"cell",rect:{r1:E,c1:_,r2:E,c2:_}},u.value={anchor:{row:E,col:_},focus:{row:E,col:_}},Rt(),t.nextTick(()=>{const He=gn(E,_,E,_);He&&Ke(He)});return}if(I.key==="Tab"){I.preventDefault(),I.stopPropagation(),ct();const Mt=Fh(s.value,E,_,I.shiftKey);if(!Mt){if(Kh(s.value,E,_)&&!I.shiftKey){const Ht=an(T),un=s.value,Vt=Vo(un,E,_,Ht),Yt=Ti(Vt,Vt.rows);(me=(ie=o.commands).setAttrs)==null||me.call(ie,{id:i,attrs:Yt}),t.nextTick(()=>{const fn=`${Yt.rows-1}-0`,Dt=a.get(fn);Dt==null||Dt.focus(),Cl(Dt)});return}return}const{r:He,c:yt}=Mt,Gt=an(T),it=s.value,xt=(he=it.cells[E])==null?void 0:he[_];let ut=it;xt&&(It(xt.content,Gt)||(ut=Vo(it,E,_,Gt))),ut!==it&&((we=(ge=o.commands).setAttrs)==null||we.call(ge,{id:i,attrs:ut})),t.nextTick(()=>{const en=`${He}-${yt}`,Ht=a.get(en);Ht==null||Ht.focus(),I.shiftKey?ec(Ht):Cl(Ht)});return}if(I.key==="Backspace"){const Mt=(Be=s.value.cells[E])==null?void 0:Be[_],He=Mt==null?void 0:Mt.cellType;if(He&&He!=="paragraph"){const yt=window.getSelection();let Gt=((De=T.textContent)==null?void 0:De.length)??0;if(yt&&yt.rangeCount>0){const it=yt.getRangeAt(0);if(T.contains(it.startContainer)){const xt=document.createRange();xt.selectNodeContents(T);try{xt.setEnd(it.startContainer,it.startOffset),Gt=xt.toString().length}catch{Gt=((rt=T.textContent)==null?void 0:rt.length)??0}}}if(Gt===0&&(!T.textContent||T.textContent.trim()===""||(He==="bulletList"||He==="orderedList"||He==="todoList"))){I.preventDefault(),I.stopPropagation(),ct(),fe(),ue();const ut=an(T),en=s.value,Ht=Vo(en,E,_,ut),un=Uo(Ht,E,_,{cellType:"paragraph"});(Jt=(Wt=o.commands).setAttrs)==null||Jt.call(Wt,{id:i,attrs:un}),t.nextTick(()=>{const Vt=a.get(`${E}-${_}`);Vt&&(Vt.focus(),ec(Vt))});return}}}I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),P(E,_,T),f.value=null,A.visible=!1,A.selectionRect=null,ct(),T.blur())}function Te(E,_,T){f.value={row:E,col:_},u.value&&(u.value=null),K.value.kind!=="none"&&(K.value={kind:"none"},_e(0))}function $e(E){const _=E.target;if(!_)return null;const T=_.closest(".table-cell");if(!T)return null;const I=Number(T.getAttribute("data-row")??T.dataset.row),V=Number(T.getAttribute("data-col")??T.dataset.col);return!Number.isFinite(I)||!Number.isFinite(V)?null:{r:I,c:V,el:T}}function Ct(E){if(!r.value)return;const _=E.target;if(!_)return;const T=_.closest(".table-cell-inner");if(!T)return;const I=T.closest(".table-cell");if(!I)return;const V=Number(I.getAttribute("data-row")),q=Number(I.getAttribute("data-col"));!Number.isFinite(V)||!Number.isFinite(q)||ye(V,q,T,E)}function Qt(E){var he,ge;const _=E.target;if(_.closest(".table-row-strip, .table-col-strip, .table-insert-dot, .table-corner-handle, .table-col-resizer")||_.tagName==="INPUT"&&_.classList.contains("table-cell-todo-checkbox")||_.classList.contains("table-cell-ol-marker"))return;const T=_.closest("a");if(T&&T.closest(".table-cell-inner")){E.preventDefault(),E.stopPropagation(),Et(T);return}w.visible&&ct();const I=$e(E);if(!I||E.button!==0)return;const V=f.value;if(V&&V.row===I.r&&V.col===I.c){Pe=!0,document.addEventListener("mouseup",de,{once:!0,capture:!0});return}E.preventDefault(),E.stopPropagation();const{r:q,c:j}=I,ie=document.activeElement;ie&&ie.closest(".table-cell-inner")&&ie.blur(),f.value=null,(ge=(he=o.commands).selectBlock)==null||ge.call(he,{id:i}),Rt(),B=ae.value!==null,B&&(X=!0,ne&&(clearTimeout(ne),ne=null),te&&(clearTimeout(te),te=null)),K.value={kind:"none"},Y=!0;const me={row:q,col:j};F.value={start:me,current:me},u.value={anchor:me,focus:me},document.addEventListener("mouseup",$t,!0)}function Lt(E){if(!Y||!F.value)return;const _=$e(E);if(!_)return;const{r:T,c:I}=_,V=F.value.current;if(T===V.row&&I===V.col)return;F.value={...F.value,current:{row:T,col:I}};const q=F.value.start;u.value={anchor:q,focus:{row:T,col:I}}}function Ye(E){if(!r.value)return;const _=E.target;if(_.tagName==="INPUT"&&_.classList.contains("table-cell-todo-checkbox")||_.classList.contains("table-cell-ol-marker"))return;const T=$e(E);if(!T)return;const{r:I,c:V}=T,q=f.value;q&&q.row===I&&q.col===V||(E.preventDefault(),E.stopPropagation(),te&&(clearTimeout(te),te=null),X=!1,Y=!1,F.value=null,u.value=null,K.value={kind:"none"},_e(0),document.removeEventListener("mouseup",$t,!0),f.value={row:I,col:V},t.nextTick(()=>{const j=`${I}-${V}`,ie=a.get(j);ie&&(ie.focus(),Cl(ie))}))}function $t(E){if(Y&&F.value){const _=F.value.start,T=F.value.current,I=Math.min(_.row,T.row),V=Math.min(_.col,T.col),q=Math.max(_.row,T.row),j=Math.max(_.col,T.col),ie=Pn(s.value,I,V,q,j),{r1:me,c1:he,r2:ge,c2:we}=ie;if(K.value={kind:"cell",rect:{r1:me,c1:he,r2:ge,c2:we}},u.value={anchor:{row:me,col:he},focus:{row:ge,col:we}},me!==ge||he!==we)t.nextTick(()=>{const De=gn(me,he,ge,we);De&&Ke(De)});else if(B){const De=gn(me,he,ge,we);De&&Ke(De)}else te&&clearTimeout(te),te=setTimeout(()=>{te=null;const De=gn(me,he,ge,we);De&&Ke(De)},250)}Y=!1,F.value=null,document.removeEventListener("mouseup",$t,!0)}function pn(E){if(K.value.kind==="row"&&K.value.row===E){K.value={kind:"none"},u.value=null,_e(0);return}ae.value!==null&&(X=!0);const _=s.value,T=_.cols,I=E,V=0,q=E,j=Math.max(0,T-1),ie=T>0?Pn(_,I,V,q,j):{r1:I,c1:V,r2:q,c2:j};K.value={kind:"row",row:E},u.value=T>0?{anchor:{row:ie.r1,col:ie.c1},focus:{row:ie.r2,col:ie.c2}}:null,f.value=null;const me=document.activeElement;me&&me.closest(".table-cell-inner")&&me.blur(),Rt(),t.nextTick(()=>{const he=Fe.value,ge=he.rowTops[ie.r1]??0,we=he.rowTops[ie.r2]??0,Be=he.rowHeights[ie.r2]??32,De=we+Be-ge,rt=he.colWidths.length>0?he.colWidths.reduce((Mt,He)=>Mt+He,0):_.colWidths.reduce((Mt,He)=>Mt+He,0),Wt=he.colLefts[0]??0,Jt=new DOMRect(Wt,ge,rt,De);Ke(Jt)})}function hn(E){if(K.value.kind==="col"&&K.value.col===E){K.value={kind:"none"},u.value=null,_e(0);return}ae.value!==null&&(X=!0);const _=s.value,T=_.rows,I=0,V=E,q=Math.max(0,T-1),j=E,ie=T>0?Pn(_,I,V,q,j):{r1:I,c1:V,r2:q,c2:j};K.value={kind:"col",col:E},u.value=T>0?{anchor:{row:ie.r1,col:ie.c1},focus:{row:ie.r2,col:ie.c2}}:null,f.value=null;const me=document.activeElement;me&&me.closest(".table-cell-inner")&&me.blur(),Rt(),t.nextTick(()=>{const he=Fe.value,ge=he.colLefts[ie.c1]??0,we=he.colLefts[ie.c2]??0,Be=he.colWidths[ie.c2]??80,De=we+Be-ge,rt=he.rowTops[0]??0,Wt=T>0?(he.rowTops[T-1]??0)+(he.rowHeights[T-1]??32)-rt:32,Jt=new DOMRect(ge,rt,De,Wt);Ke(Jt)})}function Qn(){if(K.value.kind==="all"){K.value={kind:"none"},u.value=null,_e(0);return}ae.value!==null&&(X=!0);const E=s.value;if(E.rows===0||E.cols===0)return;K.value={kind:"all"};const _=Pn(E,0,0,E.rows-1,E.cols-1);u.value={anchor:{row:_.r1,col:_.c1},focus:{row:_.r2,col:_.c2}},f.value=null;const T=document.activeElement;T&&T.closest(".table-cell-inner")&&T.blur(),Rt(),t.nextTick(()=>{const I=Fe.value,V=I.rowTops[0]??0,q=I.colLefts[0]??0,j=I.colWidths.length>0?I.colWidths.reduce((ge,we)=>ge+we,0):E.colWidths.reduce((ge,we)=>ge+we,0),ie=I.rowTops[E.rows-1]??0,me=I.rowHeights[E.rows-1]??32,he=new DOMRect(q,V,j,ie+me-V);Ke(he)})}function gn(E,_,T,I){const V=Fe.value,q=V.rowTops[E]??0,j=V.rowTops[T]??0,ie=V.rowHeights[T]??32,me=j+ie,he=V.colLefts[_]??0,ge=V.colLefts[I]??0,we=V.colWidths[I]??80,Be=ge+we;return new DOMRect(he,q,Be-he,me-q)}t.onBeforeUnmount(()=>{document.removeEventListener("mouseup",$t,!0),document.removeEventListener("mouseup",de,!0),document.removeEventListener("mousemove",zt,!0),document.removeEventListener("mouseup",ln,!0),document.removeEventListener("keydown",Me,!0),document.removeEventListener("selectionchange",mt),document.removeEventListener("mousedown",Se,!0),window.removeEventListener("scroll",ze,!0),document.removeEventListener("touchmove",ze,!0),document.removeEventListener("mousedown",y,!0),document.removeEventListener("mouseup",N,!0),te&&(clearTimeout(te),te=null)});function Me(E){var V,q;if(!r.value)return;const _=K.value;if(_.kind==="none")return;const T=document.activeElement;if(T!=null&&T.closest(".table-cell-inner"))return;if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),K.value={kind:"none"},u.value=null,_e(0);return}if(E.key==="Delete"||E.key==="Backspace"){if(E.preventDefault(),E.stopPropagation(),_.kind==="row")ce("tableRemoveRow",{row:_.row});else if(_.kind==="col")ce("tableRemoveCol",{col:_.col});else if(_.kind==="all")ce("tableDelete");else if(_.kind==="cell"){const{r1:j,c1:ie,r2:me,c2:he}=_.rect,ge=[];let we=s.value;for(let Be=j;Be<=me;Be++)for(let De=ie;De<=he;De++)we=Vo(we,Be,De,ge);(q=(V=o.commands).setAttrs)==null||q.call(V,{id:i,attrs:we})}}}function Se(E){if(!w.visible&&!U.visible&&!oe.visible)return;const _=E.target;_.closest(".link-popover")||_.closest(".ordered-list-menu")||_.closest(".number-picker")||M.value&&M.value.contains(_)||(w.visible&&ct(),U.visible&&fe(),oe.visible&&ue())}function ze(){if(w.visible&&ct(),U.visible&&fe(),oe.visible&&ue(),ae.value!==null&&u.value){const E=Go(u.value);if(E){const _=Pn(s.value,E.r1,E.c1,E.r2,E.c2),T=gn(_.r1,_.c1,_.r2,_.c2);T&&(ae.value=at(T))}}}t.onMounted(()=>{document.addEventListener("keydown",Me,!0),document.addEventListener("selectionchange",mt),document.addEventListener("mousedown",Se,!0),document.addEventListener("mousedown",y,!0),document.addEventListener("mouseup",N,!0),window.addEventListener("scroll",ze,!0),document.addEventListener("touchmove",ze,{passive:!0,capture:!0})});const Oe=t.ref(null),Fe=t.ref({rowTops:[],rowHeights:[],colLefts:[],colWidths:[],wrapperOffsetLeft:0,wrapperOffsetTop:0,tableTotalWidth:0,tableTotalHeight:0});function kt(){const E=d.value,_=Oe.value,T=M.value;if(!E||!_||!T)return;const I=s.value.rows,V=s.value.cols,q=_.getBoundingClientRect(),j=T.getBoundingClientRect(),ie=Math.round(q.left-j.left),me=Math.round(q.top-j.top),he=Array.from(E.querySelectorAll("tr")),ge=[],we=[];for(const He of he){const yt=He.getBoundingClientRect();ge.push(Math.round(yt.top-q.top)),we.push(Math.round(yt.height))}for(;ge.length<I;){const He=ge.length>0?ge[ge.length-1]+we[we.length-1]:0;ge.push(He),we.push(we.length>0?we[we.length-1]:32)}const Be=_.scrollLeft,De=[],rt=[],Wt=Array.from(E.querySelectorAll("colgroup > col"));if(Wt.length>0)for(const He of Wt){const yt=He.getBoundingClientRect();De.push(Math.round(yt.left-q.left+Be)),rt.push(Math.round(yt.width))}for(;De.length<V;){const He=De.length>0?De[De.length-1]+rt[rt.length-1]:0;De.push(He),rt.push(rt.length>0?rt[rt.length-1]:80)}const Jt=rt.reduce((He,yt)=>He+yt,0),Mt=we.reduce((He,yt)=>He+yt,0);Fe.value={rowTops:ge,rowHeights:we,colLefts:De,colWidths:rt,wrapperOffsetLeft:ie,wrapperOffsetTop:me,tableTotalWidth:Jt,tableTotalHeight:Mt},R()}t.watchEffect(()=>{var E,_;s.value.rows,s.value.cols,s.value.headerRow,(E=f.value)==null||E.row,(_=f.value)==null||_.col,t.nextTick(()=>{L.value===null&&kt()})});let dt=null;t.onMounted(()=>{var _;dt=new ResizeObserver(()=>{L.value===null&&(kt(),R())}),Oe.value&&dt.observe(Oe.value),d.value&&dt.observe(d.value);const E=(_=M.value)==null?void 0:_.closest(".block-editor");E&&dt.observe(E),Oe.value&&Oe.value.addEventListener("scroll",b,{passive:!0}),R()}),t.onBeforeUnmount(()=>{var E;dt==null||dt.disconnect(),Oe.value&&Oe.value.removeEventListener("scroll",b),Kt&&cancelAnimationFrame(Kt),yn&&clearTimeout(yn),c&&((E=c.value)==null?void 0:E.blockId)===i&&(c.value=null)});function Ot(E,_){if(!r.value)return;_.preventDefault(),_.stopPropagation(),L.value=E,G=Fe.value.colWidths[E]??80,S=_.clientX,document.addEventListener("mousemove",zt,!0),document.addEventListener("mouseup",ln,!0),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}function zt(E){var q,j;if(L.value===null)return;const _=E.clientX-S;let T=Math.max(40,Math.round(G+_));const I=Oe.value;if(I){const ie=I.clientWidth-4,me=s.value.colWidths.reduce((ge,we,Be)=>Be===L.value?ge:ge+we,0);if(me+T<=ie){const ge=Math.max(40,ie-me);T=Math.min(T,ge)}}const V=Mi(s.value,L.value,T);(j=(q=o.commands).setAttrs)==null||j.call(q,{id:i,attrs:V})}function ln(){L.value=null,document.removeEventListener("mousemove",zt,!0),document.removeEventListener("mouseup",ln,!0),document.body.style.cursor="",document.body.style.userSelect="",t.nextTick(()=>{kt(),R()})}const Ft=t.ref(0),bn=t.ref(0),Rn=t.ref(0),kn=t.ref(!1);let Kt=0,yn;function R(){const E=Oe.value;E&&(Ft.value=E.scrollLeft,bn.value=E.clientWidth,Rn.value=E.scrollWidth)}function b(){kn.value||(kn.value=!0),Kt&&cancelAnimationFrame(Kt),Kt=requestAnimationFrame(()=>{Kt=0,R()}),yn&&clearTimeout(yn),yn=setTimeout(()=>{kn.value=!1,R()},130)}const D=t.computed(()=>{if(!r.value)return[];const E=Fe.value,_=s.value.cols,T=E.colLefts,I=E.colWidths;if(_===0||T.length<_||I.length<_)return[];const V=Ft.value,q=bn.value,j=Rn.value;if(q<=0)return[];const ie=V<=0,me=V+q>=j-1,he=j<=q+1,ge=6,we=[];for(let Be=0;Be<=_;Be++){const rt=(Be===0?T[0]??0:Be===_?(T[_-1]??0)+(I[_-1]??0):T[Be]??0)-V;let Wt=rt>=-1&&rt<=q+1;if(Be===0&&(ie||he)&&(Wt=!0),Be===_&&(me||he)&&(Wt=!0),!Wt)continue;const Jt=Math.max(ge,Math.min(rt,q-ge))+(Be>0?2:-2);we.push({c:Be,left:Jt})}return we});function ce(E,_){var I,V;const T={id:i,..._};(V=(I=o.commands)[E])==null||V.call(I,T)}function Ne(){f.value=null,u.value=null,K.value.kind!=="none"&&(K.value={kind:"none"}),_e(0),fe(),ue()}return n({clearInnerFocus:Ne}),()=>{var Xe,wt,vn,Cn,Jn,Xo,_o,ic,sc,cc,ac;const E=s.value,_=E.rows,T=E.cols,I=Go(u.value),V=I?Pn(E,I.r1,I.c1,I.r2,I.c2):null,q=Fe.value,j=K.value,ie=[],me=t.h("div",{class:"table-toolbar"},[t.h("div",{class:"table-toolbar-title"},[t.h(dn,{html:Cr,class:"table-toolbar-icon"}),t.h("span",l.t("table.title"))])]),he=[];for(let Z=0;Z<T;Z++){const Ee=E.colWidths[Z]??0,ve={};Ee&&Ee>0&&(ve.width=`${Ee}px`),he.push(t.h("col",{"data-col":Z,style:ve}))}const ge=t.h("colgroup",{},he),we=[],Be=[],De=E.headerRow?0:-1;for(let Z=0;Z<_;Z++){const Ee=[];for(let ve=0;ve<T;ve++){const be=(Xe=E.cells[Z])==null?void 0:Xe[ve];if(!be||be.covered)continue;const Qe=`${Z}-${ve}`,Sn=De===0&&Z===0,xo=!!V&&Wh(Z,ve,V),Mo=j.kind==="row"&&j.row===Z,No=j.kind==="col"&&j.col===ve,jo=j.kind==="all",mg=xo||Mo||No||jo;let Nl=Zn(be.content);be.cellType==="codeBlock"&&Nl.endsWith(`
|
|
19
|
-
`)&&(Nl+="<br>");const ao=["table-cell"];Sn&&ao.push("table-cell-header"),
|
|
20
|
-
`);ve&&((Qe=navigator.clipboard)==null||Qe.writeText(ve))},We={visible:!!Ht,selectionRect:Ht,blockId:i,blockType:$.blockType,blockAttrs:$.blockAttrs,rootEl:document.querySelector(".block-editor"),tableMode:!0,tableActiveMarks:$.marks,tableActiveColor:$.textColor,tableActiveBgColor:$.bgColor,tableActiveVerticalAlign:$.verticalAlign,showDelete:$.showDelete,deleteLabel:$.deleteLabel,deleteIcon:$.deleteIcon,showMerge:$.showMerge,showSplit:$.showSplit,showHeaderRow:$.showHeaderRow,headerRowActive:$.headerRowActive,onDelete:xl,onMerge:Mn,onSplit:Ml,onTableHeaderRow:_r,onClose:zn,onTableType:st,onTableAlign:Ge,onTableVerticalAlign:Ze,onTableMark:Ve,onTableTextColor:lt,onTableBgColor:Ie,onTableCopy:pt};c&&(We.visible?c.value=We:((_o=c.value)==null?void 0:_o.blockId)===i&&!((ic=c.value)!=null&&ic.cellEditMode)&&(c.value=null));const Ue=f.value,tt=Ue?(sc=s.value.cells[Ue.row])==null?void 0:sc[Ue.col]:void 0,ht=tt==null?void 0:tt.cellType;let Tt="paragraph";const Nt={};ht==="heading"||ht==="heading1"?(Tt="heading",Nt.level=1):ht==="heading2"?(Tt="heading",Nt.level=2):ht==="heading3"?(Tt="heading",Nt.level=3):ht==="heading4"?(Tt="heading",Nt.level=4):ht==="heading5"?(Tt="heading",Nt.level=5):ht==="heading6"?(Tt="heading",Nt.level=6):ht==="bulletList"?Tt="bulletList":ht==="orderedList"?Tt="orderedList":ht==="todoList"?Tt="todoList":ht==="quote"?Tt="quote":ht==="codeBlock"&&(Tt="codeBlock"),typeof(tt==null?void 0:tt.align)=="string"&&(Nt.align=tt.align),typeof(tt==null?void 0:tt.verticalAlign)=="string"&&(Nt.verticalAlign=tt.verticalAlign);const Ln={visible:A.visible&&!!A.selectionRect,selectionRect:A.selectionRect,blockId:i,blockType:Tt,blockAttrs:Nt,rootEl:document.querySelector(".block-editor"),cellEditMode:!0,onClose:()=>{A.visible=!1,A.selectionRect=null},onTableType:Z=>{var ve,be;if(!Ue)return;const Ee=oo(s.value,[{row:Ue.row,col:Ue.col}],{cellType:Z});(be=(ve=o.commands).setAttrs)==null||be.call(ve,{id:i,attrs:Ee})},onTableAlign:Z=>{var ve,be;if(!Ue)return;const Ee=oo(s.value,[{row:Ue.row,col:Ue.col}],{align:Z});(be=(ve=o.commands).setAttrs)==null||be.call(ve,{id:i,attrs:Ee})},onTableVerticalAlign:Z=>{var ve,be;if(!Ue)return;const Ee=oo(s.value,[{row:Ue.row,col:Ue.col}],{verticalAlign:Z});(be=(ve=o.commands).setAttrs)==null||be.call(ve,{id:i,attrs:Ee})},onLinkClick:()=>{At()}};return c&&(Ln.visible?c.value=Ln:((cc=c.value)==null?void 0:cc.blockId)===i&&((ac=c.value)!=null&&ac.cellEditMode)&&(c.value=null)),ie.push(t.h(ls,{visible:w.visible,anchorRect:w.anchorRect,blockId:null,from:0,to:0,href:w.href,text:w.text,initialMode:w.initialMode,showTextInput:w.showTextInput,readonly:!r.value,onSaveLink:(Z,Ee)=>{bt(Z,Ee),w.href=Z,Ee!==void 0&&(w.text=Ee)},onRemoveLinkMark:()=>{vt()},onClose:()=>{ct()}})),ie.push(t.h(ns,{visible:U.visible,blockId:null,anchor:U.anchor,rootEl:document.querySelector(".block-editor"),canContinue:U.canContinue,canStartNew:U.canStartNew,currentNumber:U.currentNumber,onContinue:pe,onStartNew:qe,onModify:Ce,onClose:fe})),ie.push(t.h(os,{visible:oe.visible,initialValue:oe.initialValue,anchor:oe.anchor,rootEl:document.querySelector(".block-editor"),onConfirm:je,onClose:ue})),t.h("div",{class:["block-table-container","block-focus-root",...xn(e.block.attrs)],ref:M,tabindex:"-1",onClick:ot,onMousedown:Qt,onMouseover:Lt,onDblclick:Ye,onFocusout:W,onKeydown:Ct},ie)}}});function Fh(e,n,o,r){var c;const l=[];for(let s=0;s<e.rows;s++)for(let a=0;a<e.cols;a++){const d=(c=e.cells[s])==null?void 0:c[a];d&&!d.covered&&l.push({r:s,c:a})}const i=l.findIndex(s=>s.r===n&&s.c===o);return i===-1?null:r?i===0?null:l[i-1]??null:i===l.length-1?null:l[i+1]??null}function Kh(e,n,o){var l;let r=null;for(let i=0;i<e.rows;i++)for(let c=0;c<e.cols;c++){const s=(l=e.cells[i])==null?void 0:l[c];s&&!s.covered&&(r={r:i,c})}return r!==null&&r.r===n&&r.c===o}function Cl(e){if(!e)return;e.focus();const n=document.createRange();n.selectNodeContents(e),n.collapse(!1);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(n)}function ec(e){if(!e)return;e.focus();const n=document.createRange();n.selectNodeContents(e),n.collapse(!0);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(n)}function Go(e){if(!e)return null;const n=e.anchor,o=e.focus,r=Math.min(n.row,o.row),l=Math.max(n.row,o.row),i=Math.min(n.col,o.col),c=Math.max(n.col,o.col);return{r1:r,c1:i,r2:l,c2:c}}function Wh(e,n,o){return e>=o.r1&&e<=o.r2&&n>=o.c1&&n<=o.c2}function qo(e,n){return null}function Un(e,n,o,r){const l=e.doc.blocks.get(n);if(!l||l.type!=="table")return!1;const i=Ho(l.attrs),c=r(i),s=Je();return s.setAttrs(n,c),o==null||o(s.build()),!0}function Gh(){return{name:"tableInsertRow",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs);qo(n,e.id);const i=e.beforeRow??l.rows;return Un(n,e.id,o,c=>Ti(c,i))}}}function qh(){return{name:"tableRemoveRow",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs);qo(n,e.id);const i=e.row??l.rows-1;return Un(n,e.id,o,c=>Ka(c,i))}}}function Yh(){return{name:"tableInsertCol",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs);qo(n,e.id);const i=e.beforeCol??l.cols;return Un(n,e.id,o,c=>Wa(c,i))}}}function Zh(){return{name:"tableRemoveCol",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs);qo(n,e.id);const i=e.col??l.cols-1;return Un(n,e.id,o,c=>Ga(c,i))}}}function Xh(){return{name:"tableToggleHeaderRow",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);return!r||r.type!=="table"?!1:Un(n,e.id,o,Xa)}}}function jh(){return{name:"tableMergeCells",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs);qo(n,e.id);const i=e.r1??0,c=e.c1??0;let s=e.r2??0,a=e.c2??0;if(i===s&&c===a&&(s+1<l.rows&&(s=i+1),a+1<l.cols&&(a=c+1),i===s&&c===a))return!1;const d=Pn(l,i,c,s,a);return d.r1===d.r2&&d.c1===d.c2?!1:Un(n,e.id,o,u=>Ya(u,d.r1,d.c1,d.r2,d.c2))}}}function Qh(){return{name:"tableSplitCell",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);return!r||r.type!=="table"?!1:Un(n,e.id,o,l=>xi(l,e.row,e.col))}}}function Jh(){return{name:"tableSplitCellsInRect",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs),i=Pn(l,e.r1,e.c1,e.r2,e.c2);return Ci(l,i.r1,i.c1,i.r2,i.c2)?Un(n,e.id,o,c=>Za(c,i.r1,i.c1,i.r2,i.c2)):!1}}}function eg(){return{name:"tableSetColWidth",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);return!r||r.type!=="table"?!1:Un(n,e.id,o,l=>Mi(l,e.col,e.width))}}}function tg(){return{name:"tableDelete",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=Je();return l.removeBlock(e.id),o==null||o(l.build()),!0}}}function ng(){return{name:"insertTable",run:e=>(n,o)=>{const r=e.rows??3,l=e.cols??3,i=Math.max(1,Math.min(50,Number.isInteger(r)?r:3)),c=Math.max(1,Math.min(20,Number.isInteger(l)?l:3)),s=za(i,c),d={rows:i,cols:c,cells:Hn(s,i,c),colWidths:new Array(c).fill(120),headerRow:!0};let u=null,f=n.doc.root.length,p=null;if(e.replaceCurrent){const F=n.selection,Y=F.kind==="caret"?F.blockId:F.kind==="text"?F.focus.blockId:F.blockIds[0]??null;Y&&(p=Y)}if(p&&(n.doc.blocks.get(p)?(u=Bt(n.doc,p),f=rn(n.doc,p)):p=null),!p)if(e.after){if(!n.doc.blocks.get(e.after))return!1;u=Bt(n.doc,e.after),f=rn(n.doc,e.after)+1}else{const F=n.selection,Y=F.kind==="caret"?F.blockId:F.kind==="text"?F.focus.blockId:F.blockIds[0]??null;Y&&(u=Bt(n.doc,Y),f=rn(n.doc,Y)+1)}const m=Je();p&&m.removeBlock(p);const h=u===null?0:On(n.doc,u)+1,y=h>0?{...d,indent:h}:d,N=m.insertBlock({parent:u,index:f,type:"table",attrs:y,content:[]}),L=Jo(n.doc,m.peek()),S=po(L.doc,N),G=Dn(L.doc,N),K=S??G;return K?m.setSelection(et(K.id,0)):m.setSelection(et(N,0)),o==null||o(m.build()),!0}}}const tc={name:"table",schema:{type:"table",content:"none",nestable:!1,isolating:!0,inlineMarks:!1,attrs:{...Uh},empty:e=>{var o;const n=Ho(e.attrs);for(let r=0;r<n.rows;r++)for(let l=0;l<n.cols;l++){const i=(o=n.cells[r])==null?void 0:o[l];if(!(!i||i.covered)){for(const c of i.content)if(c.type==="text"&&c.text.length>0)return!1}}return!0}},renderer:{component:zh,editable:!1},commands:[Gh(),qh(),Yh(),Zh(),Xh(),jh(),Qh(),Jh(),eg(),tg(),ng()],slashCommands:[{id:"table-3x3",title:"slash.table3x3.title",keywords:["table","grid","spreadsheet","表格","数据表","网格"],description:"slash.table3x3.description",icon:Cr,command:"insertTable",category:"other",args:()=>({rows:3,cols:3,replaceCurrent:!0})},{id:"table-2x2",title:"slash.table2x2.title",keywords:["table","grid","表格","2行2列"],description:"slash.table2x2.description",icon:Cr,command:"insertTable",category:"other",args:()=>({rows:2,cols:2,replaceCurrent:!0})},{id:"table-4x4",title:"slash.table4x4.title",keywords:["table","grid","表格","4行4列"],description:"slash.table4x4.description",icon:Cr,command:"insertTable",category:"other",args:()=>({rows:4,cols:4,replaceCurrent:!0})}],serialize:{toHTML:e=>{if(e.type!=="table")return"";const n=Ho(e.attrs);return Qa(n)},toMarkdown:e=>{if(e.type!=="table")return"";const n=Ho(e.attrs);return ja(n)}}},og=t.defineComponent({name:"DividerBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){return e.placeholder,()=>t.h("div",{class:["block-divider","block-focus-root",...xn(e.block.attrs)],"data-block-divider":!0})}}),nc={name:"divider",schema:{type:"divider",content:"none",nestable:!1,inlineMarks:!1,attrs:{indent:Xt.indent},empty:()=>!1},renderer:{component:og,editable:!1},slashCommands:[{id:"divider",title:"slash.divider.title",keywords:["divider","separator","hr","horizontal","line","分隔符","分割线","水平线","横线"],description:"slash.divider.description",icon:Gd,command:"convertBlock",category:"basic",args:()=>({id:"__currentBlock__",type:"divider"})}],inputRules:[{name:"divider-md-thematic-break",pattern:/^(?:-{3,}|\*{3,}|_{3,})\s*$/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"divider"})}],serialize:{toHTML:()=>"<hr/>",toMarkdown:()=>"---"},deserialize:{fromMarkdown:e=>{const n=e.trim();return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)?{type:"divider"}:null}}};function rg(e){const n=[];for(const o of e.root){const r=e.blocks.get(o);if(!r||r.type!=="heading")continue;const l=Ae(r.content).trim();if(l.length===0)continue;const i=typeof r.attrs.level=="number"?r.attrs.level:1;n.push({id:o,level:Math.max(1,Math.min(6,Math.floor(i))),text:l})}return n}const lg=t.defineComponent({name:"TableOfContentsBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){e.block,e.placeholder;const n=cn(),o=Zt(),r=t.ref(null),l=t.ref(0),i=t.computed(()=>(l.value,rg(n.getState().doc)));let c=null;t.onMounted(()=>{c=n.subscribe(()=>{l.value++})}),t.onBeforeUnmount(()=>{c==null||c()});function s(a){var d,u;(u=(d=n.commands).setSelection)==null||u.call(d,{selection:et(a,0)}),t.nextTick(()=>{var m,h;const f=(h=(m=r.value)==null?void 0:m.closest)==null?void 0:h.call(m,".block-editor"),p=f?Oo(f,a):null;p==null||p.scrollIntoView({block:"center",behavior:"smooth"})})}return()=>{const a=i.value,d=[t.h("div",{class:"toc-title"},o.t("toc.title"))];if(a.length===0)d.push(t.h("div",{class:"toc-empty"},o.t("toc.empty")));else for(const u of a)d.push(t.h("button",{type:"button",class:["toc-item",`toc-level-${u.level}`],style:{paddingLeft:`${(u.level-1)*16}px`},"data-toc-target":u.id,onClick:()=>s(u.id)},u.text));return t.h("div",{ref:r,class:["block-table-of-contents","block-focus-root",...xn(e.block.attrs)]},d)}}}),oc={name:"tableOfContents",schema:{type:"tableOfContents",content:"none",nestable:!1,inlineMarks:!1,attrs:{indent:Xt.indent},empty:()=>!1},renderer:{component:lg,editable:!1},slashCommands:[{id:"tableOfContents",title:"slash.tableOfContents.title",keywords:["toc","contents","table of contents","outline","目录","标题","大纲"],description:"slash.tableOfContents.description",icon:qd,command:"convertBlock",category:"basic",args:()=>({id:"__currentBlock__",type:"tableOfContents"})}],serialize:{toHTML:()=>"",toMarkdown:()=>""}},rc=[ss,cs,zm,Pm,Km,Gm,Oh,Qs,tc,nc,oc,as,ds],ig={class:"editor-content"},sg={key:0,class:"cross-block-selection-overlay","aria-hidden":"true"},cg=200,ag=.25,dg=.75,ug=400,fg=t.defineComponent({__name:"BlockEditor",props:{extensions:{default:()=>rc},modelValue:{default:()=>({blocks:[]})},editable:{type:Boolean,default:!0},placeholder:{default:""},theme:{default:"light"},locale:{default:"zh-CN"},uploadImage:{type:Function,default:void 0},width:{default:void 0},height:{default:void 0},toolbarPosition:{default:"auto"}},emits:["update:modelValue","cleanup:image-file"],setup(e,{expose:n,emit:o}){const r=e,l=r.placeholder!=="",i=o,c=t.computed(()=>Hi(r.locale)),s=t.computed(()=>Vi(r.theme)),a=t.ref(c.value),d=t.ref(s.value);vd(a,d),t.watch([c,s],([g,v])=>{a.value=g,d.value=v});const u=Zt(),f=t.computed(()=>`theme-${s.value}`),p=t.computed(()=>{const g={};return g.width=r.width!==void 0?typeof r.width=="number"?`${r.width}px`:r.width:"100%",g.height=r.height!==void 0?typeof r.height=="number"?`${r.height}px`:r.height:"100%",g});t.watch(s,g=>{if(typeof document>"u")return;const v=document.body;v.classList.toggle("theme-dark",g==="dark"),v.classList.toggle("theme-light",g==="light")},{immediate:!0});const m=t.computed(()=>l?r.placeholder??"":u.t("editor.placeholder")),h=new ai({extensions:r.extensions,initialDocument:r.modelValue,editable:r.editable}),y=t.ref(r.editable);t.provide(pi,y),t.provide(Pr,h);const N=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null,L=t.ref(!!(N!=null&&N.matches));function S(){L.value=!!(N!=null&&N.matches)}const G=t.ref(null);t.provide(mi,L),t.provide($r,G);const K=t.computed(()=>r.toolbarPosition==="top"?"top":r.toolbarPosition==="bottom"||L.value?"bottom":"top");t.provide(Lo,t.computed(()=>K.value==="bottom")),t.watch(()=>r.editable,g=>{var v,O;y.value=g,h.editable=g,g||(x.visible=!1,x.selectionRect=null,x.blockId=null,x.blockType=null,x.blockAttrs={},wn(),Mn(),zn(),qe(),De(),he(),mt(null,{clearNativeSelection:!0}),(O=(v=h.commands).clearSelection)==null||O.call(v))}),gd((g,v,O,H)=>{const{onProgress:ee,onSuccess:Q,onError:le}=H,re=r.uploadImage;typeof re=="function"?re(g,v,O,J=>{const ke=Number.isFinite(J)?Math.max(0,Math.min(1,J/100)):0;ee(ke)}).then(J=>{Q({url:J.url,width:J.width,height:J.height,alt:J.alt,title:J.title,fileId:J.fileId})}).catch(J=>{O.signal.aborted||le(J instanceof Error?J.message:String(J))}):bd(v,ee).then(J=>Q({url:J.url,width:J.width,height:J.height}),J=>le(J instanceof Error?J.message:String(J)))});const F=t.ref(0),Y=ad(()=>{F.value++}),ae=async(g,v={})=>{var J,ke,Re,Le,st,Ge,Ze,Ve,lt,Ie,pt,We,Ue,tt,ht,Tt,Nt,Ln;const{relativeToBlockId:O=null,position:H="after",convertIfEmpty:ee=!0}=v;F.value;let Q=null,le=O??null;if(!le){const Xe=h.getState().selection;Xe.kind==="caret"?le=Xe.blockId:Xe.kind==="text"&&(le=Xe.anchor.blockId)}if(le||(le=ne.value.doc.root[0]??null),H==="replace"&&le){const Xe=h.registries.schema.get("image");Xe&&((ke=(J=h.commands).replaceBlock)==null||ke.call(J,{id:le,type:"image",attrs:Gn(Xe)}),Q=le)}if(!Q&&le&&ee&&H!=="before"){const wt=h.getState().doc.blocks.get(le);if(wt&&wt.type==="paragraph"&&Ae(wt.content).length===0){const vn=h.registries.schema.get("image");vn&&((Le=(Re=h.commands).replaceBlock)==null||Le.call(Re,{id:le,type:"image",attrs:Gn(vn)}),Q=le)}}if(!Q&&le&&H==="before"){const Xe=h.registries.schema.get("image");if(Xe){(Ge=(st=h.commands).insertBlock)==null||Ge.call(st,{before:le,type:"image",attrs:Gn(Xe)});const wt=h.getState().selection;wt.kind==="caret"?Q=wt.blockId:wt.kind==="text"&&(Q=wt.anchor.blockId)}}if(!Q&&le){const Xe=h.registries.schema.get("image");if(Xe){(Ve=(Ze=h.commands).insertBlock)==null||Ve.call(Ze,{after:le,type:"image",attrs:Gn(Xe)});const wt=h.getState().selection;wt.kind==="caret"?Q=wt.blockId:wt.kind==="text"&&(Q=wt.anchor.blockId)}}if(!Q){const Xe=h.registries.schema.get("image");if(!Xe)return null;const wt=h.getState().doc,vn=wt.root[wt.root.length-1]??null;vn?(Ie=(lt=h.commands).insertBlock)==null||Ie.call(lt,{after:vn,type:"image",attrs:Gn(Xe)}):(We=(pt=h.commands).insertBlock)==null||We.call(pt,{after:null,type:"image",attrs:Gn(Xe)});const Cn=h.getState().selection;Cn.kind==="caret"?Q=Cn.blockId:Cn.kind==="text"&&(Q=Cn.anchor.blockId)}if(!Q)return null;if(typeof g=="string"){const Xe=g;try{const wt=await new Promise(Cn=>{if(typeof document>"u")return Cn({});const Jn=document.createElement("img");let Xo=!1;const _o=()=>{Xo||(Xo=!0,Cn({width:Jn.naturalWidth||void 0,height:Jn.naturalHeight||void 0}))};Jn.onload=_o,Jn.onerror=_o,Jn.src=Xe,setTimeout(_o,4e3)}),vn={src:Xe,width:wt.width,height:wt.height};(tt=(Ue=h.commands).setAttrs)==null||tt.call(Ue,{id:Q,attrs:vn})}catch{(Tt=(ht=h.commands).setAttrs)==null||Tt.call(ht,{id:Q,attrs:{src:Xe}})}return Q}const re=await kd(Q,g);if(re.ok){const Xe=re.value,wt={src:Xe.url,alt:Xe.alt,title:Xe.title,width:Xe.width,height:Xe.height,fileId:Xe.fileId};(Ln=(Nt=h.commands).setAttrs)==null||Ln.call(Nt,{id:Q,attrs:wt})}return Q};t.provide(hi,ae);const ne=t.shallowRef(h.getState());let te=h.getState().selection,X=!1,B=!1;const $=t.computed(()=>{const g=ne.value.doc,v=[];for(const O of g.root){const H=g.blocks.get(O);H&&v.push({id:O,block:H})}return v}),M=t.reactive({visible:!1,anchorEl:null,blockId:"",query:"",mode:"slash"}),A=t.ref(null),w=t.reactive({visible:!1,anchorEl:null,blockId:null}),C=t.ref(null),x=t.reactive({visible:!1,selectionRect:null,blockId:null,blockType:null,blockAttrs:{}});let z=!1,U=null;function fe(){z=!0,U&&clearTimeout(U),U=setTimeout(()=>{z=!1,U=null,Mt()},500)}const oe=t.reactive({visible:!1,blockId:null,anchor:null,canContinue:!1,canStartNew:!1,currentNumber:1}),ue=t.reactive({visible:!1,initialValue:1,anchor:null,blockId:null}),xe=t.reactive({visible:!1,initialValue:"plain",anchor:null,blockId:null}),pe=t.reactive({visible:!1,anchorRect:null,blockId:null,from:0,to:0,href:"",text:"",initialMode:"view",showTextInput:!1});function qe(){pe.visible=!1}t.watch(()=>pe.visible,g=>{g&&(x.visible=!1)});function Ce(g,v){var ee,Q;const O=h.getState().doc.blocks.get(g);if(!O)return null;let H=0;for(const le of O.content){if(le.type!=="text")continue;const re=H,J=H+le.text.length;if(v>=re&&v<=J){const ke=(ee=le.marks)==null?void 0:ee.find(Re=>Re.type==="link");if(ke&&typeof((Q=ke.attrs)==null?void 0:Q.href)=="string")return{from:re,to:J,href:ke.attrs.href,text:le.text};if(v<J)return null}H=J}return null}function je(g,v,O){var Re,Le,st;const H=h.getState().doc.blocks.get(g);if(!H)return;let ee="",Q="",le=0;for(const Ge of H.content){if(Ge.type!=="text")continue;const Ze=le,Ve=le+Ge.text.length;if(Ve>v&&Ze<O){const lt=(Re=Ge.marks)==null?void 0:Re.find(Ie=>Ie.type==="link");if(lt&&typeof((Le=lt.attrs)==null?void 0:Le.href)=="string"){ee=lt.attrs.href,Q=Ge.text;break}}le=Ve}let re=null;const J=(st=Ye.value)==null?void 0:st.querySelector(`[data-block-id="${g}"]`);if(J){const Ge=window.getSelection();if(Ge&&Ge.rangeCount>0){const Ze=Ge.getRangeAt(0);J.contains(Ze.commonAncestorContainer)&&(re=Ze.getBoundingClientRect())}re||(re=J.getBoundingClientRect())}const ke=v<O;De(),he(),wn(),Mn(),zn(),pe.blockId=g,pe.from=v,pe.to=O,pe.href=ee,pe.text=Q,pe.anchorRect=re,pe.initialMode=ee||!y.value?"view":"edit",pe.showTextInput=!ke&&!ee,pe.visible=!0}function ct(){var v;if(!y.value)return;hn();const g=h.getState().selection;if(g.kind==="caret"){const O=Ce(g.blockId,g.offset);if(O){pe.blockId=g.blockId,pe.from=O.from,pe.to=O.to,pe.href=O.href,pe.text=O.text;const H=(v=Ye.value)==null?void 0:v.querySelector(`[data-block-id="${g.blockId}"]`),ee=H==null?void 0:H.querySelector("a");pe.anchorRect=(ee==null?void 0:ee.getBoundingClientRect())??(H==null?void 0:H.getBoundingClientRect())??null,pe.initialMode="view",pe.showTextInput=!1,pe.visible=!0}}else g.kind==="text"&&!Pt(g)&&je(g.focus.blockId,g.anchor.offset,g.focus.offset)}function St(g,v,O){je(g,v,O)}function At(g,v){var Q;const O=Ce(g,v);if(!O)return;const H=(Q=Ye.value)==null?void 0:Q.querySelector(`[data-block-id="${g}"]`),ee=H==null?void 0:H.querySelector("a");pe.blockId=g,pe.from=O.from,pe.to=O.to,pe.href=O.href,pe.text=O.text,pe.anchorRect=(ee==null?void 0:ee.getBoundingClientRect())??(H==null?void 0:H.getBoundingClientRect())??null,pe.initialMode="view",pe.showTextInput=!1,pe.visible=!0}function Et(g){mt(g)}const qt=t.ref(null),bt=t.ref(null),vt=t.ref(null);let nt=!1,Pe=!1;function mt(g,v={}){const{clearNativeSelection:O=!1}=v;if(O)try{const H=window.getSelection();H&&H.removeAllRanges()}catch{}bt.value=g}let de=null,at=0,Ke=null;const _e=t.ref([]);function Rt(g){qt.value=g}function ot(){const g=Ye.value;if(!g){_e.value=[];return}const v=h.getState().selection;if(v.kind!=="text"||!Pt(v)){_e.value=[];return}_e.value=Vr(g,h.getState().doc,v)}function It(g){g.preventDefault()}function P(g){var le,re;const v=Ye.value;if(!v||!de)return;const O=rr(g.clientX,g.clientY,v,h.getState().doc);if(!O)return;const H=de.start;if(O.blockId===H.blockId){if(de.crossBlock){de.crossBlock=!1,_e.value=[],document.removeEventListener("selectstart",It,!0);const J=window.getSelection();J&&J.removeAllRanges()}return}if(!de.crossBlock){de.crossBlock=!0,document.addEventListener("selectstart",It,!0);const J=window.getSelection();J&&J.removeAllRanges()}const ee={blockId:O.blockId,offset:O.offset},Q=Br(H,ee);X=!0,(re=(le=h.commands).setSelection)==null||re.call(le,{selection:Q}),X=!1,ot()}function k(g){de&&(Ke=g,!at&&(at=requestAnimationFrame(()=>{at=0,Ke&&P(Ke)})))}function W(){if(!de)return;de=null,at&&(cancelAnimationFrame(at),at=0),Ke=null,document.removeEventListener("mousemove",k,!0),document.removeEventListener("mouseup",W,!0),document.removeEventListener("selectstart",It,!0),ot();const g=h.getState().selection;g.kind==="text"&&Pt(g)&&Gt(g)}const ye=new Set(["image","divider","table","toc","tableOfContents","codeBlock"]),Te=new Map;let $e=h.getState().doc.blocks;{const g=h.getState().doc;for(const v of g.root){const O=g.blocks.get(v);if(!O||O.type!=="image")continue;const H=O.attrs.fileId;typeof H=="number"&&Number.isFinite(H)&&H>0&&Te.set(H,(Te.get(H)??0)+1)}}let Ct=!1;const Qt=h.subscribe(g=>{if(ne.value=g.state,g.removed.size>0&&pd(g.removed),g.changed.size>0||g.removed.size>0){const ee=new Map;for(const le of g.state.doc.root){const re=g.state.doc.blocks.get(le);if(!re||re.type!=="image")continue;const J=re.attrs.fileId;typeof J=="number"&&Number.isFinite(J)&&J>0&&ee.set(J,(ee.get(J)??0)+1)}const Q=new Set;for(const le of g.changed){const re=le?$e.get(le):void 0;if(re&&re.type==="image"){const J=re.attrs.fileId;typeof J=="number"&&Number.isFinite(J)&&J>0&&Q.add(J)}}for(const le of g.removed){const re=le?$e.get(le):void 0;if(re&&re.type==="image"){const J=re.attrs.fileId;typeof J=="number"&&Number.isFinite(J)&&J>0&&Q.add(J)}}for(const le of ee.keys())Q.add(le);for(const le of Q){const re=ee.get(le)??0,J=Te.get(le)??0;Te.set(le,re),re===0&&J>0&&i("cleanup:image-file",le)}$e=g.state.doc.blocks,Ct=!0,i("update:modelValue",h.toData()),Promise.resolve().then(()=>{Ct=!1})}const v=g.state.selection;let H=v.kind==="caret"?v.blockId:v.kind==="text"?v.focus.blockId:v.kind==="blocks"?v.blockIds[0]??null:null;if(bt.value!==null&&H!==bt.value){const ee=g.state.doc.blocks.get(bt.value);ee&&ye.has(ee.type)&&(v.kind!=="blocks"||v.blockIds.length===0)&&(H=bt.value)}z||mt(H),!X&&v!==te&&(B?B=!1:t.nextTick(()=>{const ee=Ye.value;ee&&yi(ee,v)})),v.kind==="text"&&Pt(v)?t.nextTick(()=>{ot(),!de&&!nt&&Gt(v)}):_e.value.length>0&&(_e.value=[]),te=v});function Lt(g,v){if(Object.is(g,v))return!0;if(typeof g!=typeof v||g===null||v===null||typeof g!="object"||Array.isArray(g)!==Array.isArray(v))return!1;if(Array.isArray(g)){if(g.length!==v.length)return!1;for(let ee=0;ee<g.length;ee++)if(!Lt(g[ee],v[ee]))return!1;return!0}const O=Object.keys(g),H=Object.keys(v);if(O.length!==H.length)return!1;for(const ee of O)if(!Object.prototype.hasOwnProperty.call(v,ee)||!Lt(g[ee],v[ee]))return!1;return!0}t.watch(()=>r.modelValue,g=>{if(Ct||g===void 0)return;const v=h.toData();Lt(v,g)||h.setDocument(g)},{deep:!0});const Ye=t.ref(null),$t=t.ref(null),pn=()=>$t.value;function hn(){const g=Ye.value;if(!g)return;const v=gi(g,h.getState().doc);if(!v)return;const O={steps:[],selectionAfter:v,meta:{addToHistory:!1}};X=!0,h.dispatch(O),X=!1}function Qn(g){var Q,le,re,J,ke,Re,Le,st,Ge,Ze,Ve,lt;if(M.visible&&((Q=A.value)!=null&&Q.onKeyDown(g))||w.visible&&((le=C.value)!=null&&le.onKeyDown(g)))return;if(!y.value){const Ie=g.key,pt=g.ctrlKey||g.metaKey,We=Ie.length===1&&!pt&&!g.altKey&&!g.isComposing,Ue=Ie==="Enter"||Ie==="Backspace"||Ie==="Delete",tt=Ie.toLowerCase();if(We||Ue||pt&&(tt==="x"||tt==="v"||tt==="z"||tt==="y"||tt==="d")){g.preventDefault();return}if(pt&&tt==="a"){g.preventDefault(),(J=(re=h.commands).selectAll)==null||J.call(re);return}if(pt&&tt==="c"){const Tt=h.getState().selection;if(Tt.kind==="text"&&Pt(Tt)){const Nt=fn(Tt);if(Nt){g.preventDefault();const Ln=window.ClipboardItem;if(Ln){const Xe=new Ln({"text/plain":new Blob([Nt.text],{type:"text/plain"}),"text/html":new Blob([Nt.html],{type:"text/html"})});navigator.clipboard.write([Xe]).catch(()=>{navigator.clipboard.writeText(Nt.text).catch(()=>{})})}else navigator.clipboard.writeText(Nt.text).catch(()=>{})}}return}return}if((g.metaKey||g.ctrlKey)&&g.key.toLowerCase()==="k"&&!g.isComposing){g.preventDefault(),ct();return}const v=g.target;if(v&&v.classList.contains("image-block-caption")||v&&v.closest(".table-cell-inner"))return;const O=h.getState().selection;O.kind==="text"&&Pt(O)||hn();const H=h.getState().selection;if(H.kind==="text"&&Pt(H)&&!g.isComposing){const Ie=g.key,pt=Ie.length===1&&!g.ctrlKey&&!g.metaKey&&!g.altKey;if(pt||Ie==="Enter"||Ie==="Tab"){if(g.preventDefault(),(Re=(ke=h.commands).backspace)==null||Re.call(ke),pt){const We=h.getState().selection;if(We.kind==="caret"){const Ue=h.getState().doc.blocks.get(We.blockId);if(Ue){const[tt,ht]=Ut(Ue.content,We.offset),Tt=[...tt,{type:"text",text:Ie},...ht];(st=(Le=h.commands).setText)==null||st.call(Le,{id:We.blockId,content:Tt,selectionAfter:et(We.blockId,We.offset+1)})}}}return}if((g.ctrlKey||g.metaKey)&&(Ie==="c"||Ie==="C"||Ie==="x"||Ie==="X")){const We=fn(H);if(We){g.preventDefault();const Ue=window.ClipboardItem;if(Ue){const tt=new Ue({"text/plain":new Blob([We.text],{type:"text/plain"}),"text/html":new Blob([We.html],{type:"text/html"})});navigator.clipboard.write([tt]).catch(()=>{navigator.clipboard.writeText(We.text).catch(()=>{})})}else navigator.clipboard.writeText(We.text).catch(()=>{});(Ie==="x"||Ie==="X")&&((Ze=(Ge=h.commands).backspace)==null||Ze.call(Ge))}return}if(Ie==="ArrowLeft"||Ie==="ArrowUp"||Ie==="ArrowRight"||Ie==="ArrowDown"){g.preventDefault();const We=In(h.getState().doc),Ue=We.indexOf(H.anchor.blockId),tt=We.indexOf(H.focus.blockId),[ht,Tt]=Ue<=tt?[H.anchor,H.focus]:[H.focus,H.anchor],Nt=Ie==="ArrowLeft"||Ie==="ArrowUp"?ht:Tt;_e.value=[],(lt=(Ve=h.commands).setSelection)==null||lt.call(Ve,{selection:et(Nt.blockId,Nt.offset)});return}}if((g.key==="ArrowUp"||g.key==="ArrowDown")&&!g.shiftKey&&!g.isComposing){const Ie=h.getState().selection;if(Ie.kind==="caret"||Ie.kind==="text"){const pt=Ie.kind==="caret"?Ie.blockId:Ie.focus.blockId,We=Ie.kind==="caret"?Ie.offset:Ie.focus.offset,Ue=h.getState().doc.blocks.get(pt);if(Ue&&h.registries.schema.get(Ue.type).isolating){const ht=Ae(Ue.content),Tt=ht.slice(0,We),Nt=ht.slice(We),Ln=Tt.lastIndexOf(`
|
|
21
|
-
`)+1,
|
|
22
|
-
`),
|
|
23
|
-
`},...
|
|
24
|
-
`);if(
|
|
25
|
-
`)){const Ze=J.lastChild;Ze&&Ze.nodeType===Node.ELEMENT_NODE&&Ze.tagName==="BR"&&J.removeChild(Ze),J.appendChild(document.createElement("br"))}B=!0}else J.textContent=le}else J&&(J.textContent=le);const Re={steps:[{op:"setText",id:g,content:Q}],selectionAfter:et(g,v+1),meta:{source:"input",addToHistory:!0}};h.dispatch(Re)}const Me=t.ref(null),Se=t.ref("after");let ze="idle",Oe=0,Fe=0,kt=4,dt=null,Ot=null,zt=0,ln=0,Ft=null,bn=null,Rn=null,kn=null;function Kt(){kn!==null&&(clearTimeout(kn),kn=null),Rn=null}function yn(){var g;Ft&&(Ft.classList.remove("block-being-dragged"),Ft=null),Ot&&(Ot.remove(),Ot=null),bn!==null&&((g=pn())==null||g.setBlockHandleDragging(bn,!1)),bn=null,dt=null,ze="idle",vt.value=null,Me.value=null,Se.value="after",Kt()}function R(){document.removeEventListener("mousemove",Ne,!0),document.removeEventListener("mouseup",E,!0),document.removeEventListener("selectstart",ce,!0)}function b(g,v,O,H){y.value&&(ze!=="idle"&&(R(),yn()),ze="pending",dt=g,Oe=v,Fe=O,kt=H.thresholdPx,document.addEventListener("selectstart",ce,!0),document.addEventListener("mousemove",Ne,!0),document.addEventListener("mouseup",E,!0))}function D(g){}function ce(g){g.preventDefault()}function Ne(g){if(ze==="pending"){const Ve=g.clientX-Oe,lt=g.clientY-Fe;if(Math.sqrt(Ve*Ve+lt*lt)<=kt)return;_()}if(ze!=="active")return;try{const Ve=window.getSelection();Ve&&Ve.rangeCount>0&&Ve.removeAllRanges()}catch{}Ot&&(Ot.style.left=`${g.clientX+zt}px`,Ot.style.top=`${g.clientY+ln}px`);const v=bn;if(!v)return;const O=Array.from(document.querySelectorAll(".block-host"));if(O.length<=1){Me.value=null;return}const H=O[0].getBoundingClientRect(),ee=O[O.length-1].getBoundingClientRect();if(g.clientY<H.top+H.height/2){Kt(),Me.value=null,Se.value="first";return}if(g.clientY>ee.bottom-ee.height/2){Kt(),Me.value=null,Se.value="last";return}const Q=document.elementFromPoint(g.clientX,g.clientY);if(!Q){Kt(),Me.value=null;return}const le=Q.closest(".block-host");if(!le){Kt(),Me.value=null;return}const re=le.dataset.blockId;if(!re||re===v){Kt(),Me.value=null;return}const J=le.getBoundingClientRect(),ke=J.height===0?0:(g.clientY-J.top)/J.height;let Re=!1;const Le=h.getState().doc,st=Le.blocks.get(re);if(st){const Ve=h.registries.schema.get(st.type);if(Ve!=null&&Ve.nestable){let lt=re;for(Re=!0;lt!==null;){if(lt===v){Re=!1;break}lt=Bt(Le,lt)}}}if(ke>ag&&ke<dg&&Re){Me.value=re;const Ve=ke<.5;Rn!==re&&(Kt(),Rn=re,kn=setTimeout(()=>{Rn===re&&(Me.value=re,Se.value="into")},cg)),Se.value!=="into"&&(Se.value=Ve?"before":"after")}else Kt(),Me.value=re,Se.value=ke<.5?"before":"after"}function E(g){if(R(),ze==="pending"){ze="idle",dt=null;return}const v=bn,O=Me.value,H=Se.value;yn(),v&&(H==="into"&&!O||!O&&H!=="first"&&H!=="last"||T(v,O,H))}function _(){var ke,Re;const g=dt;if(!g)return;const v=Oe,O=Fe;try{const Le=window.getSelection();Le&&Le.removeAllRanges()}catch{}de&&(de=null,at&&(cancelAnimationFrame(at),at=0),Ke=null,document.removeEventListener("mousemove",k,!0),document.removeEventListener("mouseup",W,!0),document.removeEventListener("selectstart",It,!0),_e.value=[]),mt(null);const H=document.querySelector(`.block-host[data-block-id="${g}"]`);if(!H){R(),ze="idle",dt=null;return}H.classList.add("block-being-dragged"),Ft=H;const ee=H.querySelector(".block-host-content");if(!ee){H.classList.remove("block-being-dragged"),Ft=null,R(),ze="idle",dt=null;return}const Q=ee.getBoundingClientRect(),le=((ke=ee.firstElementChild)==null?void 0:ke.getBoundingClientRect())??Q;zt=le.left-v,ln=le.top-O;const re=document.createElement("div");re.className="drag-ghost";const J=ee.firstElementChild;J&&re.appendChild(J.cloneNode(!0)),re.style.width=`${le.width}px`,re.style.left=`${v+zt}px`,re.style.top=`${O+ln}px`,document.body.appendChild(re),Ot=re,vt.value=g,bn=g,Me.value=null,Se.value="after",(Re=pn())==null||Re.setBlockHandleDragging(g,!0),ze="active"}function T(g,v,O){var Le,st,Ge;vt.value=null;const H=h.getState().doc;if(!H.blocks.get(g))return;if(v){let Ze=v;for(;Ze!==null;){if(Ze===g)return;Ze=Bt(H,Ze)}}const Q=Bt(H,g),le=rn(H,g);if(le===-1)return;let re=null,J;if(O==="first")re=null,J=0;else if(O==="last")re=null,J=H.root.length;else if(O==="into"&&v){const Ze=H.blocks.get(v);if(!Ze)return;const Ve=h.registries.schema.get(Ze.type);if(!(Ve!=null&&Ve.nestable))return;let lt=v;for(;lt!==null;){if(lt===g)return;lt=Bt(H,lt)}re=v,J=0}else if((O==="before"||O==="after")&&v){const Ze=Bt(H,v),Ve=rn(H,v);if(Ve===-1)return;re=Ze,J=O==="before"?Ve:Ve+1}else return;Q===re&&le<J&&J--,J=Math.max(0,J);const Re=re===null?H.root:(Le=H.blocks.get(re))==null?void 0:Le.children;Re&&(J=Math.min(J,Re.length)),(Ge=(st=h.commands).moveBlock)==null||Ge.call(st,{id:g,toParent:re,toIndex:J})}const I=t.ref(!1);function V(g){const v=[];if(!g||!g.types||!Array.from(g.types).includes("Files"))return v;const O=new Set;if(g.items&&g.items.length>0)for(let H=0;H<g.items.length;H++){const ee=g.items[H];if(ee.kind!=="file")continue;const Q=ee.getAsFile();if(!Q||!Q.type.startsWith("image/"))continue;const le=`${Q.name||""}:${Q.size}:${Q.type}`;O.has(le)||(O.add(le),v.push(Q))}if(g.files&&g.files.length>0)for(let H=0;H<g.files.length;H++){const ee=g.files[H];if(!ee.type.startsWith("image/"))continue;const Q=`${ee.name||""}:${ee.size}:${ee.type}`;O.has(Q)||(O.add(Q),v.push(ee))}return v}function q(g){if(vt.value)return;const v=g.dataTransfer;if(!v||V(v).length===0)return;I.value||(I.value=!0);const H=Array.from(document.querySelectorAll(".block-host"));if(H.length===0){Me.value=null,Se.value="last";return}const ee=H[0].getBoundingClientRect(),Q=H[H.length-1].getBoundingClientRect(),le=g.clientY;if(le<ee.top+ee.height/2){Me.value=null,Se.value="first";return}if(le>Q.bottom-Q.height/2){Me.value=null,Se.value="last";return}const re=document.elementFromPoint(g.clientX,g.clientY);if(!re){Me.value=null,Se.value="last";return}const J=re.closest(".block-host");if(!J){Me.value=null,Se.value="last";return}const ke=J.getBoundingClientRect(),Re=J.dataset.blockId;if(!Re){Me.value=null,Se.value="last";return}Me.value=Re,Se.value=le<ke.top+ke.height/2?"before":"after"}function j(g){const v=g.relatedTarget,O=Ye.value;O&&v&&O.contains(v)||I.value&&(I.value=!1,Me.value=null,Se.value="after")}async function ie(g){if(vt.value)return;const v=g.dataTransfer;if(!v)return;const O=V(v);if(O.length===0)return;const H=Me.value,ee=Se.value;I.value=!1,Me.value=null,Se.value="after";let Q=H,le=ee==="before"?"before":"after";const re=h.getState().doc;ee==="first"?(Q=re.root[0]??null,le="before"):ee==="last"&&(Q=re.root[re.root.length-1]??null,le="after");let J=Q;for(let ke=0;ke<O.length;ke++){const Re=O[ke],Le=await ae(Re,{relativeToBlockId:J,position:ke===0?le:"after",convertIfEmpty:ke===0});Le&&(J=Le)}}function me(g,v){De(),he(),w.visible=!0,w.anchorEl=v,w.blockId=g}function he(){w.visible=!1,w.anchorEl=null}function ge(g,v){var J,ke;if(!y.value)return;he(),De();const O=h.getState().doc.blocks.get(g);if(!O)return;const H=h.registries.schema.get(O.type);if((H==null?void 0:H.content)==="text"&&Ae(O.content).length===0){M.visible=!0,M.anchorEl=v,M.blockId=g,M.query="",M.mode="slash",M.sourceBlockId=void 0;return}(ke=(J=h.commands).insertBlock)==null||ke.call(J,{type:h.registries.defaultBlockType,after:g,content:[]});const le=h.getState().selection,re=le.kind==="caret"?le.blockId:g;M.visible=!0,M.anchorEl=v,M.blockId=re,M.query="",M.mode="insert",M.sourceBlockId=g}function we(g,v,O){y.value&&(he(),M.visible=!0,M.anchorEl=g,M.blockId=v,M.query=O,M.mode="slash",M.sourceBlockId=void 0)}function Be(g,v){if(!M.visible)return;if(g!==M.blockId){De();return}const O=v.match(/\/([^/]*)$/);if(!O){De();return}M.query=O[1]??""}function De(){M.visible=!1,M.anchorEl=null,M.query="",M.sourceBlockId=void 0}t.watch(()=>x.visible,g=>{g&&(M.visible||De(),w.visible||he())});function rt(g,v){var Q,le,re,J;const O=M.blockId,H=Wt(O),ee=Jt(H);h.history.beginGroup();try{H!==ee&&((le=(Q=h.commands).setText)==null||le.call(Q,{id:O,content:Wn(ee)}));const ke=h.registries.slash.all.find(Re=>Re.id===g.id);if(ke){const Re=typeof ke.args=="function"?ke.args(null):ke.args,Le=Re&&typeof Re=="object"?{...Re}:{};Le.id==="__currentBlock__"&&(Le.id=O),Le.after==="__currentBlock__"&&(Le.after=O);const st=h.commands[ke.command];st==null||st(Le),(J=(re=h.commands).setSelection)==null||J.call(re,{selection:{kind:"caret",blockId:O,offset:0}}),g.id==="image"&&t.nextTick(()=>{const Ge=document.createElement("input");Ge.type="file",Ge.accept="image/*",Ge.multiple=!1,Ge.addEventListener("change",()=>{var Ve;const Ze=(Ve=Ge.files)==null?void 0:Ve[0];Ze&&ae(Ze,{relativeToBlockId:O,position:"replace",convertIfEmpty:!0})}),Ge.click()})}}finally{h.history.endGroup()}De()}function Wt(g){const v=Ye.value;if(!v)return"";const O=v.querySelector(`.block-content[data-block-id="${g}"]`);return(O==null?void 0:O.textContent)??""}function Jt(g){const v=g.lastIndexOf("/");return v<0?g:g.slice(0,v)}function Mt(){var Ge,Ze,Ve,lt,Ie;const g=Ye.value;if(g){const pt=window.getSelection();let We=null;if(pt&&pt.rangeCount>0){const Ue=pt.focusNode,tt=(Ue==null?void 0:Ue.nodeType)===1?Ue.closest(".block-content"):(Ge=Ue==null?void 0:Ue.parentElement)==null?void 0:Ge.closest(".block-content");if(tt&&g.contains(tt)){const ht=tt.getAttribute("data-block-id");ht&&(We=ht)}}if(We!==null&&bt.value!==null&&We!==bt.value){const Ue=h.getState().doc.blocks.get(bt.value);Ue&&ye.has(Ue.type)&&(We=null)}We!==null&&!z&&mt(We)}if(!y.value){x.visible=!1,x.selectionRect=null,x.blockId=null,x.blockType=null,x.blockAttrs={};return}const v=Ye.value;if(!v)return;const O=h.getState().selection;if(O.kind==="text"&&Pt(O)&&!de)return;if(Io(O)&&O.blockIds.length>0){const pt=window.getSelection();if(pt&&pt.rangeCount>0&&pt.getRangeAt(0).collapsed){const We=gi(v,h.getState().doc);We&&We.kind==="caret"&&(X=!0,(Ve=(Ze=h.commands).setSelection)==null||Ve.call(Ze,{selection:We}),X=!1)}}const H=window.getSelection();if(!H||H.rangeCount===0){z||(x.visible=!1,x.selectionRect=null,x.blockId=null,x.blockType=null,x.blockAttrs={});return}const ee=H.getRangeAt(0);if(ee.collapsed){z||(x.visible=!1,x.selectionRect=null,x.blockId=null);return}if(!v.contains(ee.commonAncestorContainer)){z||(x.visible=!1,x.selectionRect=null,x.blockId=null);return}if(nt)return;const Q=H.anchorNode;if((Q==null?void 0:Q.nodeType)===1?Q.closest(".table-cell-inner"):(lt=Q==null?void 0:Q.parentElement)==null?void 0:lt.closest(".table-cell-inner")){z||(x.visible=!1,x.selectionRect=null,x.blockId=null,x.blockType=null,x.blockAttrs={});return}const re=(Q==null?void 0:Q.nodeType)===1?Q.closest(".block-content"):(Ie=Q==null?void 0:Q.parentElement)==null?void 0:Ie.closest(".block-content");if(!re){z||(x.visible=!1,x.selectionRect=null,x.blockId=null);return}const J=re.getAttribute("data-block-id");if(!J){z||(x.visible=!1,x.selectionRect=null,x.blockId=null);return}const Re=h.getState().doc.blocks.get(J),Le=ee.getBoundingClientRect(),st=Le.width===0&&Le.height===0?re.getBoundingClientRect():Le;x.visible=!0,x.selectionRect=st,x.blockId=J,x.blockType=(Re==null?void 0:Re.type)??null,x.blockAttrs=(Re==null?void 0:Re.attrs)??{}}function He(){const g=h.getState().selection;if(g.kind==="text"&&Pt(g)){if(ot(),x.visible){const ee=Ye.value;if(ee){const Q=Vr(ee,h.getState().doc,g);Q.length>0&&(x.selectionRect=yt(Q))}}return}if(!x.visible)return;const v=window.getSelection();if(!v||v.rangeCount===0)return;const O=v.getRangeAt(0);if(O.collapsed)return;const H=O.getBoundingClientRect();H.width===0&&H.height===0||(x.selectionRect=H)}function yt(g){if(g.length===0)return new DOMRect(0,0,0,0);let v=1/0,O=1/0,H=-1/0,ee=-1/0;for(const Q of g)v=Math.min(v,Q.left),O=Math.min(O,Q.top),H=Math.max(H,Q.right),ee=Math.max(ee,Q.bottom);return new DOMRect(v,O,H-v,ee-O)}function Gt(g){if(!y.value)return;const v=Ye.value;if(!v)return;const O=Vr(v,h.getState().doc,g);if(O.length===0)return;const H=yt(O),Q=h.getState().doc.blocks.get(g.focus.blockId);x.visible=!0,x.selectionRect=H,x.blockId=g.focus.blockId,x.blockType=(Q==null?void 0:Q.type)??null,x.blockAttrs=(Q==null?void 0:Q.attrs)??{}}function it(g){var ee,Q;const v=Ye.value;if(!v||L.value||!v.contains(g.target))return;const O=g.target;if(O&&O.closest(".block-handle"))return;nt=!0,x.visible=!1;const H=h.getState().selection;if(H.kind==="text"&&Pt(H)&&(_e.value=[]),g.button===0&&!g.shiftKey){const le=g.target;if(le&&(le.closest(".table-cell-inner, .block-table-container, .block-table-of-contents")||le.closest(".block-focus-root")&&!le.closest('[contenteditable="true"]'))){Pe=!0;try{const J=window.getSelection();J&&J.removeAllRanges()}catch{}return}else Pe=!1;const re=rr(g.clientX,g.clientY,v,h.getState().doc);re&&(H.kind==="text"&&Pt(H)&&(X=!0,(Q=(ee=h.commands).setSelection)==null||Q.call(ee,{selection:et(re.blockId,re.offset)}),X=!1),de={start:{blockId:re.blockId,offset:re.offset},crossBlock:!1},document.addEventListener("mousemove",k,!0),document.addEventListener("mouseup",W,!0))}}function xt(){if(!nt)return;if(L.value){nt=!1;return}if(nt=!1,Pe){Pe=!1;return}const g=h.getState().selection;g.kind==="text"&&Pt(g)||Mt()}let ut=null,en=!1;function Ht(g){if(!L.value)return;const v=Ye.value;if(!v||!v.contains(g.target))return;const O=g.target;if(!O||!O.closest(".block-content")||O.closest(".block-handle, .tt-btn, .ht-btn, a[href]"))return;const ee=g.touches[0];ee&&(en=!1,ut={longPressTimer:window.setTimeout(()=>{ut&&Vt(v,ut.startTouch)},ug),startTouch:ee},document.addEventListener("touchmove",un,{passive:!1,capture:!0}),document.addEventListener("touchend",Yt,!0),document.addEventListener("touchcancel",Yt,!0))}function un(g){var re,J;if(!ut)return;en=!0;const v=Ye.value;if(!v)return;if(!de){const ke=g.touches[0];if(!ke)return;const Re=ke.clientX-ut.startTouch.clientX,Le=ke.clientY-ut.startTouch.clientY;if(Math.hypot(Re,Le)>10){ut.longPressTimer&&clearTimeout(ut.longPressTimer),ut=null;return}return}const O=g.touches[0];if(!O)return;const H=rr(O.clientX,O.clientY,v,h.getState().doc);if(!H)return;const ee=de.start;if(H.blockId===ee.blockId){if(de.crossBlock){de.crossBlock=!1,_e.value=[],document.removeEventListener("selectstart",It,!0);const ke=window.getSelection();ke&&ke.removeAllRanges()}return}if(g.preventDefault(),!de.crossBlock){de.crossBlock=!0,document.addEventListener("selectstart",It,!0);const ke=window.getSelection();ke&&ke.removeAllRanges()}const Q={blockId:H.blockId,offset:H.offset},le=Br(ee,Q);X=!0,(J=(re=h.commands).setSelection)==null||J.call(re,{selection:le}),X=!1,ot()}function Vt(g,v){const O=rr(v.clientX,v.clientY,g,h.getState().doc);if(!O){ut=null;return}x.visible=!1;const H=h.getState().selection;H.kind==="text"&&Pt(H)&&(_e.value=[]),de={start:{blockId:O.blockId,offset:O.offset},crossBlock:!1}}function Yt(){if(ut&&(ut.longPressTimer&&clearTimeout(ut.longPressTimer),ut=null),!de){document.removeEventListener("touchmove",un,!0),document.removeEventListener("touchend",Yt,!0),document.removeEventListener("touchcancel",Yt,!0);return}if(de=null,document.removeEventListener("touchmove",un,!0),document.removeEventListener("touchend",Yt,!0),document.removeEventListener("touchcancel",Yt,!0),document.removeEventListener("selectstart",It,!0),!en)return;ot();const g=h.getState().selection;g.kind==="text"&&Pt(g)&&Gt(g)}function fn(g){const v=h.getState().doc,O=In(v),H=O.indexOf(g.anchor.blockId),ee=O.indexOf(g.focus.blockId);if(H===-1||ee===-1)return null;const[Q,le]=H<=ee?[g.anchor,g.focus]:[g.focus,g.anchor],re=O.indexOf(Q.blockId),J=O.indexOf(le.blockId);if(re===-1||J===-1)return null;const ke=[],Re=[];for(let Le=re;Le<=J;Le++){const st=O[Le],Ge=v.blocks.get(st);if(!Ge)continue;const Ze=Ae(Ge.content).length;let Ve=0,lt=Ze;Le===re&&(Ve=Math.min(Q.offset,Ze)),Le===J&&(lt=Math.min(le.offset,Ze)),Ve>lt&&([Ve,lt]=[lt,Ve]);const[,Ie]=Ut(Ge.content,Ve),[pt]=Ut(Ie,lt-Ve);ke.push(Ae(pt)),Re.push(Zn(pt))}return{text:ke.join(`
|
|
26
|
-
`),html:Re.join("<br>")}}function Dt(g){var H,ee;const v=h.getState().selection;if(v.kind!=="text"||!Pt(v))return;const O=fn(v);O&&(g.preventDefault(),(H=g.clipboardData)==null||H.setData("text/plain",O.text),(ee=g.clipboardData)==null||ee.setData("text/html",O.html))}function lc(g){var H,ee,Q,le;if(!y.value){g.preventDefault();return}const v=h.getState().selection;if(v.kind!=="text"||!Pt(v))return;const O=fn(v);O&&(g.preventDefault(),(H=g.clipboardData)==null||H.setData("text/plain",O.text),(ee=g.clipboardData)==null||ee.setData("text/html",O.html),(le=(Q=h.commands).backspace)==null||le.call(Q))}function Tr(g){if(!y.value)return;const v=g.detail;if(!(v!=null&&v.blockId)||!(v!=null&&v.anchor))return;const O=v.blockId,H=h.getState().doc,ee=H.blocks.get(O),Q=Dn(H,O),re=typeof(ee==null?void 0:ee.attrs).startNumber=="number"&&!!Q&&Q.type==="orderedList",J=is(H,O),ke=J!==1;De(),he(),Mn(),qe(),x.visible=!1,oe.visible=!0,oe.blockId=O,oe.anchor=v.anchor,oe.canContinue=re,oe.canStartNew=ke,oe.currentNumber=J}function wn(){oe.visible=!1,oe.anchor=null,oe.blockId=null}function Tl(){var g,v;oe.blockId&&((v=(g=h.commands).setStartNumber)==null||v.call(g,{id:oe.blockId,startNumber:null}),wn())}function _l(){var g,v;oe.blockId&&((v=(g=h.commands).setStartNumber)==null||v.call(g,{id:oe.blockId,startNumber:1}),wn())}function xl(g){if(!oe.blockId)return;const v=oe.anchor,O=oe.blockId;wn(),v&&(ue.visible=!0,ue.initialValue=g,ue.anchor=v,ue.blockId=O)}function Mn(){ue.visible=!1,ue.anchor=null,ue.blockId=null}function Ml(g){var v,O;if(!ue.blockId){Mn();return}(O=(v=h.commands).setStartNumber)==null||O.call(v,{id:ue.blockId,startNumber:g}),Mn(),wn()}function _r(g){if(!y.value)return;const v=g.detail;if(!(v!=null&&v.blockId)||!(v!=null&&v.anchor))return;const O=v.blockId,ee=h.getState().doc.blocks.get(O);if(!ee)return;const Q=ee.attrs.language??"plain";De(),he(),Mn(),wn(),qe(),x.visible=!1,xe.visible=!0,xe.blockId=O,xe.anchor=v.anchor,xe.initialValue=Q}function zn(){xe.visible=!1,xe.anchor=null,xe.blockId=null}function Fn(g){var v,O;if(!xe.blockId){zn();return}(O=(v=h.commands).setAttrs)==null||O.call(v,{id:xe.blockId,attrs:{language:g}}),zn()}function Yo(g){var re,J,ke,Re,Le;const v=g.target,O=document.querySelector(".ordered-list-menu"),H=document.querySelector(".number-picker"),ee=document.querySelector(".code-lang-picker"),Q=document.querySelector(".link-popover");if(O&&O.contains(v)||H&&H.contains(v)||ee&&ee.contains(v)||Q&&Q.contains(v)||v instanceof Node&&((re=v.closest)!=null&&re.call(v,".ol-marker"))||v instanceof Node&&((J=v.closest)!=null&&J.call(v,".block-code-lang"))||v instanceof Node&&((ke=v.closest)!=null&&ke.call(v,"a[href]")))return;wn(),Mn(),zn(),qe();const le=h.getState().selection;if(le.kind==="blocks"&&le.blockIds.length>0){const st=Ye.value;if(st&&st.contains(v)){const Ge=v.nodeType===1?v:v.parentElement??null;if(Ge&&(Ge.closest("[contenteditable]")||Ge.closest(".block-image-wrapper, .block-image-container, .block-table-container, .block-code-wrapper, .block-divider, .block-todo-checkbox, .block-ordered-list-wrapper, .block-video, .block-file, .block-embed, .block-callout")))return}(Le=(Re=h.commands).clearSelection)==null||Le.call(Re)}}function En(g){const v=g.target;v instanceof Element&&(v.closest(".code-lang-picker")||v.closest(".ordered-list-menu")||v.closest(".number-picker")||v.closest(".link-popover"))||(oe.visible&&wn(),ue.visible&&Mn(),xe.visible&&zn(),pe.visible&&qe())}function Zo(g){var O,H;if(g.key!=="Escape")return;const v=h.getState().selection;v.kind==="blocks"&&v.blockIds.length>0&&(g.preventDefault(),(H=(O=h.commands).clearSelection)==null||H.call(O))}function tn(g){const v=g.target;if(!v||v.closest(".block-handle")||v.closest('[contenteditable="true"]'))return;const O=v.closest(".block-focus-root");if(!O)return;const H=O.closest(".block-host");if(!H)return;const ee=Ye.value;if(!ee||!ee.contains(H))return;const Q=H.getAttribute("data-block-id");Q&&mt(Q,{clearNativeSelection:!0})}function Nn(g){g.target===Ye.value&&mt(null,{clearNativeSelection:!0})}return t.onMounted(()=>{t.nextTick(()=>{const g=Ye.value;if(!g)return;const v=h.getState().selection;yi(g,v),g.addEventListener("ordered-list-marker-click",Tr),g.addEventListener("code-lang-click",_r),g.addEventListener("click",tn),g.addEventListener("click",Nn)}),document.addEventListener("selectionchange",Mt),document.addEventListener("mousedown",it,!0),document.addEventListener("mouseup",xt,!0),document.addEventListener("mousedown",Yo,!0),document.addEventListener("touchstart",Yo,!0),window.addEventListener("scroll",He,!0),window.addEventListener("resize",He),window.addEventListener("scroll",En,!0),document.addEventListener("touchmove",En,{passive:!0,capture:!0}),document.addEventListener("keydown",Zo,!0),N==null||N.addEventListener("change",S),document.addEventListener("touchstart",Ht,{passive:!1,capture:!0})}),t.onBeforeUnmount(()=>{const g=Ye.value;g&&(g.removeEventListener("ordered-list-marker-click",Tr),g.removeEventListener("code-lang-click",_r),g.removeEventListener("click",tn),g.removeEventListener("click",Nn)),document.removeEventListener("selectionchange",Mt),document.removeEventListener("mousedown",it,!0),document.removeEventListener("mouseup",xt,!0),document.removeEventListener("mousedown",Yo,!0),document.removeEventListener("touchstart",Yo,!0),window.removeEventListener("scroll",He,!0),window.removeEventListener("resize",He),window.removeEventListener("scroll",En,!0),document.removeEventListener("touchmove",En,!0),document.removeEventListener("keydown",Zo,!0),N==null||N.removeEventListener("change",S),document.removeEventListener("touchstart",Ht,!0),document.removeEventListener("touchmove",un,!0),document.removeEventListener("touchend",Yt,!0),document.removeEventListener("touchcancel",Yt,!0),Qt(),h.destroy(),Y(),ud(),fd()}),n({editor:h}),(g,v)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"rootEl",ref:Ye,class:t.normalizeClass(["block-editor",[f.value,{"block-editor-dragging":vt.value!==null,"is-mobile":L.value}]]),style:t.normalizeStyle(p.value),contenteditable:!1,onKeydown:Qn,onCopy:Dt,onCut:lc,onDragover:t.withModifiers(q,["prevent"]),onDragleave:j,onDrop:t.withModifiers(ie,["prevent"])},[t.createVNode(em,{"root-el":Ye.value,"focus-block-id":bt.value,"hover-visible":x.visible,"hover-selection-rect":x.selectionRect,"hover-block-id":x.blockId,"hover-block-type":x.blockType,"hover-block-attrs":x.blockAttrs,"plus-menu-visible":M.visible,"settings-menu-visible":w.visible,position:K.value,onToolbarInteracting:fe,onOpenPlusMenu:ge,onOpenSettingsMenu:me,onLinkClick:St,onHoverClose:v[0]||(v[0]=O=>x.visible=!1)},null,8,["root-el","focus-block-id","hover-visible","hover-selection-rect","hover-block-id","hover-block-type","hover-block-attrs","plus-menu-visible","settings-menu-visible","position"]),t.createElementVNode("div",ig,[t.createVNode(Ki,{ref_key:"blockListRef",ref:$t,items:$.value,"blocks-map":ne.value.doc.blocks,"first-block-placeholder":m.value,"hovered-block-id":qt.value,"focused-block-id":bt.value,"has-text-selection":x.visible,"dragging-block-id":vt.value,"drop-target-block-id":Me.value,"drop-position":Se.value,"menu-open-block-id":w.visible?w.blockId:null,onOpenSettingsMenu:me,onOpenPlusMenu:ge,onSlashTrigger:we,onInputChanged:Be,onHoverChange:Rt,onGripPointerDown:b,onGripPointerUp:D,onLinkClick:At,onFocusIn:Et},null,8,["items","blocks-map","first-block-placeholder","hovered-block-id","focused-block-id","has-text-selection","dragging-block-id","drop-target-block-id","drop-position","menu-open-block-id"])]),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[_e.value.length>0?(t.openBlock(),t.createElementBlock("div",sg,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(_e.value,(O,H)=>(t.openBlock(),t.createElementBlock("div",{key:H,class:"cross-block-selection-rect",style:t.normalizeStyle({left:O.left+"px",top:O.top+"px",width:O.width+"px",height:O.height+"px"})},null,4))),128))])):t.createCommentVNode("",!0)])),t.createVNode(Ud,{ref_key:"plusMenuRef",ref:A,visible:M.visible,"anchor-el":M.anchorEl,"block-id":M.blockId,query:M.query,"root-el":Ye.value,mode:M.mode,onClose:De,onCommit:rt},null,8,["visible","anchor-el","block-id","query","root-el","mode"]),t.createVNode(Zu,{ref_key:"settingsMenuRef",ref:C,visible:w.visible,"anchor-el":w.anchorEl,"block-id":w.blockId,"root-el":Ye.value,onClose:he},null,8,["visible","anchor-el","block-id","root-el"]),t.createVNode(ns,{visible:oe.visible,"block-id":oe.blockId,anchor:oe.anchor,"root-el":Ye.value,"can-continue":oe.canContinue,"can-start-new":oe.canStartNew,"current-number":oe.currentNumber,onContinue:Tl,onStartNew:_l,onModify:xl,onClose:wn},null,8,["visible","block-id","anchor","root-el","can-continue","can-start-new","current-number"]),t.createVNode(os,{visible:ue.visible,"initial-value":ue.initialValue,anchor:ue.anchor,"root-el":Ye.value,onConfirm:Ml,onClose:Mn},null,8,["visible","initial-value","anchor","root-el"]),t.createVNode(wm,{visible:xe.visible,"initial-value":xe.initialValue,anchor:xe.anchor,"root-el":Ye.value,onConfirm:Fn,onClose:zn},null,8,["visible","initial-value","anchor","root-el"]),t.createVNode(ls,{visible:pe.visible,"anchor-rect":pe.anchorRect,"block-id":pe.blockId,from:pe.from,to:pe.to,href:pe.href,text:pe.text,"initial-mode":pe.initialMode,"show-text-input":pe.showTextInput,readonly:!y.value,onClose:qe},null,8,["visible","anchor-rect","block-id","from","to","href","text","initial-mode","show-text-input","readonly"])],38))}});se.BlockContent=Vn,se.BlockEditor=fg,se.BlockHost=Fi,se.BlockList=Ki,se.BuiltinExtensions=rc,se.CommandRegistry=ql,se.DeserializerRegistry=li,se.DividerExtension=nc,se.Editor=ai,se.HeadingExtension=cs,se.HistoryExtension=ds,se.HistoryManager=ci,se.ImageExtension=Qs,se.InputRuleRegistry=ni,se.KeymapExtension=as,se.KeymapRegistry=ti,se.ParagraphExtension=ss,se.SchemaRegistry=Pl,se.SerializerRegistry=ri,se.SlashCommandRegistry=oi,se.TableExtension=tc,se.TableOfContentsExtension=oc,se.TransactionBuilder=Kl,se.applySteps=Jo,se.applyTransaction=Fl,se.asBlockId=kc,se.blockAfter=po,se.blockBefore=Dn,se.blocksSelection=Nc,se.buildRegistries=si,se.canContain=Ll,se.caretSelection=et,se.coerceAttrs=Rl,se.collectIndentSyncPatches=zl,se.createBlockId=fo,se.createPrimitiveCommands=Ql,se.createState=Ir,se.createTransaction=Je,se.defaultAttrs=Gn,se.defineSchema=Mr,se.depthOf=On,se.docFromData=Nr,se.docToData=Vl,se.editorKey=Pr,se.extensionBlockType=oa,se.flatten=In,se.flattenExtensions=ii,se.focusOffset=Sc,se.getBlock=_t,se.hasText=Ol,se.indexOf=rn,se.inlineFromString=Wn,se.inlineText=Ae,se.invertSteps=Wl,se.isBlockId=uo,se.isBlocks=Io,se.isCaret=ho,se.isCollapsed=Rr,se.isEmpty=$l,se.isIsolating=Dl,se.isText=qn,se.isTextRun=gc,se.keyMatches=ei,se.keyNameFromEvent=Jl,se.lastDescendant=Ul,se.nextSibling=Ec,se.normalizeLocale=Hi,se.normalizeTheme=Vi,se.orderedAnchors=Ac,se.parentOf=Bt,se.prevSibling=Ar,se.primaryBlock=Gl,se.requireBlock=on,se.siblingList=mo,se.splitInline=Ut,se.textSelection=Br,se.useEditor=cn,se.useI18n=Zt,se.withAttrs=Cc,se.withContent=vc,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})});
|
|
6
|
+
`),o=[];let r=[],l=0;const s=()=>{r.length>0&&o.push({kind:"lines",lines:r}),r=[]};for(;l<n.length;){const i=n[l]??"",c=/^(\s*)(```+|~~~+)\s*(\S*)\s*$/.exec(i);if(c){s();const a=c[2][0],d=c[3]??"",f=[];for(l+=1;l<n.length;){const u=n[l];if(new RegExp(`^\\s*${a}{3,}\\s*$`).test(u))break;f.push(u),l+=1}o.push({kind:"fence",lang:d,body:f}),l+=1;continue}if(i.includes("|")&&l+1<n.length&&/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)+\|?\s*$/.test(n[l+1]??"")){s();const a=[i,n[l+1]];for(l+=2;l<n.length&&(n[l]??"").includes("|");)a.push(n[l]),l+=1;o.push({kind:"table",lines:a});continue}r.push(i),l+=1}return s(),o}function va(e){const n=c=>c.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(d=>d.trim()),o=n(e[0]??""),r=e.slice(2).map(c=>n(c)),l=Math.max(o.length,...r.map(c=>c.length)),s=r.length+1,i=[];for(let c=0;c<s;c++){const a=[],d=c===0?o:r[c-1]??[];for(let f=0;f<l;f++)a.push({content:eo(Ca(d[f]??"")),covered:!1});i.push(a)}return{type:"table",attrs:{cells:i,rows:s,cols:l,headerRow:!0,colWidths:[]}}}function Ca(e){return e.replace(/<br>/gi,`
|
|
7
|
+
`).replace(/\\\|/g,"|").replace(/\\\\/g,"\\")}function Ta(e){const n=[],o=Ea(e);for(const u of o){if(u.kind==="fence"){n.push({indent:0,block:{type:"codeBlock",attrs:u.lang?{language:u.lang}:void 0,content:[{type:"text",text:u.body.join(`
|
|
8
|
+
`)}]}});continue}if(u.kind==="table"){n.push({indent:0,block:va(u.lines)});continue}const h=[];let p=!1;for(const m of u.lines){if(m.trim().length===0){p=!0;continue}const k=m.length-m.trimStart().length,x=wa(m.trim());if(!x){p=!1;continue}h.push({indent:k,block:x,blankBefore:p}),p=!1}for(const m of h){const k=n[n.length-1];if(k&&!m.blankBefore&&k.indent===m.indent&&k.block.type===m.block.type&&(m.block.type==="quote"||m.block.type==="paragraph")){const x=k.block.content??[],D=m.block.content??[];n[n.length-1]={indent:k.indent,block:{type:k.block.type,...k.block.attrs?{attrs:k.block.attrs}:{},content:[...x,{type:"text",text:`
|
|
9
|
+
`},...D]}}}else n.push({indent:m.indent,block:m.block})}}const r=new Map,l=new Map,s=[],i=[],c=new Set(["paragraph","heading","bulletList","orderedList","todoList"]),a=10,d=(u,h,p)=>{if(r.set(h,p),l.set(h,u),u===null){s.push(h);return}const m=r.get(u);if(!m){s.push(h),l.set(h,null);return}r.set(u,{...m,children:[...m.children,h]})};for(const u of n){const h=fo(),p=c.has(u.block.type);let m=Math.floor(u.indent/2);for(m<0&&(m=0),m>a&&(m=a);i.length>0&&i[i.length-1].indent>=m;)i.pop();const k=i.length>0?i[i.length-1].id:null,x={...u.block.attrs??{}},D={id:h,type:u.block.type,attrs:x,content:u.block.content??[],children:[]};d(k,h,D),p&&i.push({indent:m,id:h})}const f=10;for(const[u,h]of r){let p=0,m=l.get(u);const k=new Set;for(;m!=null&&!k.has(m);)k.add(m),p++,m=l.get(m);if(p=Math.min(f,p),(typeof h.attrs.indent=="number"?h.attrs.indent:0)===p)continue;const{indent:D,...U}=h.attrs,F=p>0?{...U,indent:p}:U;r.set(u,{...h,attrs:F})}return{id:"doc_"+Math.random().toString(36).slice(2,10),root:s,blocks:r,parent:l}}const mi=Symbol("block-editor-mobile"),$r=Symbol("block-editor-fixed-toolbar-bridge"),Do=Symbol("block-editor-fixed-toolbar-bottom"),Pr=Symbol("block-editor"),pi=Symbol("block-editor-editable"),hi=Symbol("block-editor-image-upload");function fn(){const e=t.inject(Pr);if(!e)throw new Error("useEditor(): must be called within a <BlockEditor> component tree");return e}function _a(){return t.inject(hi,null)}function Yn(){return t.inject(pi)??t.ref(!0)}function xa(e,n){const o=Jl(n);if(!o)return!1;const r=e.registries.keymap.resolve(o);if(!r)return!1;const l=e.commands[r.command];return l?l(r.args)===!0:!1}const Ma=e=>`[data-block-id="${CSS.escape(e)}"]`;function $o(e,n){const o=Ma(n),r=e.querySelector(`${o}[contenteditable], ${o} [contenteditable]`);return r||e.querySelector(o)}function Na(e){const n=window.getSelection();if(!n||n.rangeCount===0)return 0;const o=n.getRangeAt(0),r=o.cloneRange();return r.selectNodeContents(e),r.setEnd(o.endContainer,o.endOffset),r.toString().length}function gi(e,n){const o=window.getSelection();if(!o||o.rangeCount===0)return null;const r=o.getRangeAt(0).endContainer,l=or(r,e);if(!l)return null;const s=l.dataset.blockId;if(!s)return null;const i=Na(l),c=n.blocks.get(s);if(!c)return null;const a=Ae(c.content).length,d=Math.min(i,a);if(!o.isCollapsed&&o.anchorNode===o.focusNode&&or(o.anchorNode,e)===l){const u=Math.min(o.anchorOffset,a);return{kind:"text",anchor:{blockId:s,offset:u},focus:{blockId:s,offset:d}}}return st(s,d)}function or(e,n){let o=e;for(;o&&o!==n;){if(o.nodeType===Node.ELEMENT_NODE){const r=o;if(r.dataset&&r.dataset.blockId)return r}o=o.parentNode}return null}function Sa(e,n,o){const r=document.createRange();r.selectNodeContents(e);try{r.setEnd(n,o)}catch{return 0}return r.toString().length}function bi(e,n,o){const r=ki(e,n),l=ki(e,o);if(!r||!l)return null;try{const s=document.createRange();return s.setStart(r.node,r.offset),s.setEnd(l.node,l.offset),s}catch{return null}}function ki(e,n){let o=0;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let l=null;for(;r.nextNode();){const s=r.currentNode;l=s;const i=(s.nodeValue??"").length;if(o+i>=n)return{node:s,offset:Math.max(0,n-o)};o+=i}return l?{node:l,offset:(l.nodeValue??"").length}:{node:e,offset:0}}function rr(e,n,o,r){let l=null;const s=document;if(typeof s.caretRangeFromPoint=="function")l=s.caretRangeFromPoint(e,n);else if(typeof s.caretPositionFromPoint=="function"){const i=s.caretPositionFromPoint(e,n);i&&(l=document.createRange(),l.setStart(i.offsetNode,i.offset),l.collapse(!0))}if(l){const i=or(l.startContainer,o);if(i){const c=i.dataset.blockId;if(c){const a=r.blocks.get(c);if(a){const d=Ae(a.content).length,f=Math.min(Sa(i,l.startContainer,l.startOffset),d);return{blockEl:i,blockId:c,offset:f}}}}}return Aa(e,n,o,r)}function Aa(e,n,o,r){const l=document.elementFromPoint(e,n),s=l?or(l,o):null;if(!s)return null;const i=s.dataset.blockId;if(!i)return null;const c=r.blocks.get(i);if(!c)return null;const a=s.matches("[contenteditable]")?s:s.querySelector("[contenteditable]");if(!a)return null;const d=Ae(c.content).length;let f=null,u=0;const h=document.createTreeWalker(a,NodeFilter.SHOW_TEXT);let p;for(;p=h.nextNode();){const m=p,k=(m.nodeValue??"").length;if(k===0)continue;const x=document.createRange();x.setStart(m,0),x.setEnd(m,k);const D=x.getBoundingClientRect();if(D.width<=0&&D.height<=0)continue;const U=Math.max(D.left,Math.min(e,D.right)),F=Math.max(D.top,Math.min(n,D.bottom)),ee=Math.hypot(e-U,n-F),$=D.width>0?Math.round((e-D.left)/D.width*k):0,V=u+Math.max(0,Math.min(k,$));(!f||ee<f.dist)&&(f={offset:V,dist:ee}),u+=k}return f?{blockEl:s,blockId:i,offset:Math.min(f.offset,d)}:{blockEl:s,blockId:i,offset:0}}function Hr(e,n){const o=document.createRange(),r=window.getSelection();if(!r)return;let l=0,s=!1;const i=c=>{var a;if(!s)if(c.nodeType===Node.TEXT_NODE){const d=((a=c.textContent)==null?void 0:a.length)??0;l+d>=n&&(o.setStart(c,Math.max(0,n-l)),o.collapse(!0),s=!0),l+=d}else for(const d of c.childNodes)i(d)};i(e),s||(o.selectNodeContents(e),o.collapse(!1)),r.removeAllRanges(),r.addRange(o)}function yi(e,n){if(ho(n)){const r=$o(e,n.blockId);if(!r)return;r.focus(),Hr(r,n.offset);return}if(qn(n)&&n.anchor.blockId===n.focus.blockId){const r=$o(e,n.focus.blockId);if(!r)return;if(r.focus(),n.anchor.offset===n.focus.offset)Hr(r,n.focus.offset);else{const l=Math.min(n.anchor.offset,n.focus.offset),s=Math.max(n.anchor.offset,n.focus.offset),i=bi(r,l,s),c=window.getSelection();i&&c?(c.removeAllRanges(),c.addRange(i)):Hr(r,n.focus.offset)}return}const o=window.getSelection();o&&o.rangeCount>0&&o.removeAllRanges()}function Ht(e){return e.kind==="text"&&!(e.anchor.blockId===e.focus.blockId&&e.anchor.offset===e.focus.offset)&&e.anchor.blockId!==e.focus.blockId}function Vr(e,n,o){if(o.anchor.blockId===o.focus.blockId)return[];const r=In(n),l=r.indexOf(o.anchor.blockId),s=r.indexOf(o.focus.blockId);if(l===-1||s===-1)return[];const[i,c]=l<=s?[o.anchor.blockId,o.focus.blockId,l<s]:[o.focus.blockId,o.anchor.blockId,l>s],a=r.indexOf(i),d=r.indexOf(c);if(a===-1||d===-1)return[];const f=[];for(let u=a;u<=d;u++){const h=r[u],p=n.blocks.get(h);if(!p)continue;const m=$o(e,h);if(!m)continue;const k=Ae(p.content).length;let x=0,D=k;if(u===a){const F=i===o.anchor.blockId?o.anchor.offset:o.focus.offset;x=Math.min(F,k)}if(u===d){const F=c===o.anchor.blockId?o.anchor.offset:o.focus.offset;D=Math.min(F,k)}const U=bi(m,x,Math.max(x,D));if(U)for(const F of U.getClientRects())F.width>0&&F.height>0&&f.push(F)}return f}function Ia(e){var s;const{registry:n,blockId:o,text:r,editor:l}=e;for(const i of n.all){const c=i.pattern.exec(r);if(!c)continue;const a=(s=i.args)==null?void 0:s.call(i,c),d=a&&typeof a=="object"?a:{},f={...d};f.id==="__currentBlock__"&&(f.id=o);const u=typeof d.__stripPrefix=="number"?d.__stripPrefix:0,h=l.commands[i.command];if(h){l.history.beginGroup();try{if(u>0){const p=r.slice(u),m=l.commands.setText;m&&m({id:o,content:Wn(p)})}h(f)}finally{l.history.endGroup()}return!0}}return!1}function Ba(e){return e.includes("/")?e.startsWith("/")||/^\s*\/\S*/.test(e):!1}const Ra=["http:","https:","mailto:","tel:"],La=["javascript:","vbscript:","data:","file:"];function Pn(e){const n=e.trim();if(!n)return null;const o=n.toLowerCase();for(const s of La)if(o.startsWith(s))return null;const r=n.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);if(r){const s=r[1].toLowerCase()+":";return Ra.includes(s)?n:null}const l=n[0];return l==="/"||l==="."||l==="#"||n.startsWith("//")||Ur(n)?n:null}function Ur(e){const n=e.trim();return!n||n.length<4?!1:/^https?:\/\//i.test(n)||/^mailto:/i.test(n)?!0:/\s/.test(n)?!1:!!/^[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s]*)?$/.test(n)}function to(e){const n=e.trim();return n?/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n)?n:n.startsWith("@")||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?n.startsWith("mailto:")?n:`mailto:${n.replace(/^@/,"")}`:Ur(n)&&!n.startsWith("/")?`https://${n}`:n:""}const Po=/(^|\s)((?:https?:\/\/|www\.)[^\s<]+|[\w-]+(?:\.[\w-]+)+\.[a-zA-Z]{2,}(?::\d+)?(?:\/[^\s<]*)?)/g;function lr(e){var r,l;let n=!1;const o=[];for(const s of e){if(s.type!=="text"){o.push(s);continue}const i=(r=s.marks)==null?void 0:r.some(p=>p.type==="link"),c=(l=s.marks)==null?void 0:l.some(p=>p.type==="code");if(i||c){o.push(s);continue}const a=s.text,d=s.marks??[];if(Po.lastIndex=0,!Po.exec(a)){o.push(s);continue}n=!0;let u=0;Po.lastIndex=0;let h;for(;(h=Po.exec(a))!==null;){const p=h[0],m=h[2],k=h.index+p.length-m.length,x=k+m.length;if(k>u){const F=a.slice(u,k);F.length>0&&o.push({type:"text",text:F,marks:d.length>0?[...d]:void 0})}const D=to(m),U=Pn(D);if(U){const F={type:"link",attrs:{href:U}};o.push({type:"text",text:m,marks:[...d,F]})}else o.push({type:"text",text:m,marks:d.length>0?[...d]:void 0});u=x}if(u<a.length){const p=a.slice(u);p.length>0&&o.push({type:"text",text:p,marks:d.length>0?[...d]:void 0})}Po.lastIndex=0}return n?o:e}const Oa={bold:["b","strong"],italic:["i","em"],underline:["u"],strikethrough:["s","strike","del"],code:["code"],link:["a"]},wi={};for(const[e,n]of Object.entries(Oa))for(const o of n)wi[o]=e;const Da="b,strong,i,em,u,s,strike,del,code,a[href],span.be-color-gray,span.be-color-brown,span.be-color-orange,span.be-color-yellow,span.be-color-green,span.be-color-blue,span.be-color-purple,span.be-color-pink,span.be-color-red,span.be-bg-gray,span.be-bg-brown,span.be-bg-orange,span.be-bg-yellow,span.be-bg-green,span.be-bg-blue,span.be-bg-purple,span.be-bg-pink,span.be-bg-red";function $a(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Pa(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Ei(e){return e.some(n=>n.type==="text"&&n.marks&&n.marks.length>0)}function Zn(e){return e.length===0?"":e.map(n=>{var f,u,h;if(n.type!=="text")return"";let o=$a(n.text);const r=n.marks??[],l=r.find(p=>p.type==="color"),s=(f=l==null?void 0:l.attrs)==null?void 0:f.color;typeof s=="string"&&(o=`<span class="be-color-${s}">${o}</span>`);const i=r.find(p=>p.type==="bgColor"),c=(u=i==null?void 0:i.attrs)==null?void 0:u.bgColor;typeof c=="string"&&(o=`<span class="be-bg-${c}">${o}</span>`),r.some(p=>p.type==="strikethrough")&&(o=`<s>${o}</s>`),r.some(p=>p.type==="underline")&&(o=`<u>${o}</u>`),r.some(p=>p.type==="italic")&&(o=`<i>${o}</i>`),r.some(p=>p.type==="bold")&&(o=`<b>${o}</b>`),r.some(p=>p.type==="code")&&(o=`<code>${o}</code>`);const a=r.find(p=>p.type==="link"),d=(h=a==null?void 0:a.attrs)==null?void 0:h.href;if(typeof d=="string"){const p=Pn(d);p&&(o=`<a href="${Pa(p)}" target="_blank" rel="noopener noreferrer">${o}</a>`)}return o}).join("")}function Ha(e){const n=[],o=e.className;if(typeof o=="string"){const r=o.match(/be-color-(\w+)/);r&&n.push({type:"color",attrs:{color:r[1]}});const l=o.match(/be-bg-(\w+)/);l&&n.push({type:"bgColor",attrs:{bgColor:l[1]}})}return n}function mn(e){const n=[];function o(r,l){if(r.nodeType===Node.TEXT_NODE){const d=r.textContent??"";d.length>0&&n.push({type:"text",text:d,marks:l.length>0?[...l]:void 0});return}if(r.nodeType!==Node.ELEMENT_NODE)return;const s=r,i=s.tagName.toLowerCase();if(i==="br")return;const c=wi[i];let a=l;if(c==="link"){const d=s.getAttribute("href")??"",f=Pn(d);f?a=[...l,{type:"link",attrs:{href:f}}]:a=l}else if(c)a=[...l,{type:c}];else if(i==="span"){const d=Ha(s);d.length>0&&(a=[...l,...d])}for(const d of s.childNodes)o(d,a)}return o(e,[]),za(n)}function Va(e,n){if(e.type!==n.type)return!1;const o=e.attrs?Object.keys(e.attrs):[],r=n.attrs?Object.keys(n.attrs):[];return o.length!==r.length?!1:o.every(l=>e.attrs[l]===n.attrs[l])}function Ua(e,n){return!e&&!n?!0:!e||!n||e.length!==n.length?!1:e.every(o=>n.some(r=>Va(o,r)))}function za(e){const n=[];for(const o of e){const r=n[n.length-1];r&&Ua(r.marks,o.marks)?n[n.length-1]={type:"text",text:r.text+o.text,marks:r.marks}:n.push({...o})}return n}function Fa(e){return e.attrs?Object.entries(e.attrs).sort((n,o)=>n[0].localeCompare(o[0])).map(([n,o])=>`${n}=${String(o)}`).join(";"):""}function vi(e){return e.map(n=>n.type==="text"?`${n.text}\0${(n.marks??[]).map(o=>`${o.type}:${Fa(o)}`).sort().join(",")}`:"").join("")}const zr=["paragraph","heading","heading1","heading2","heading3","heading4","heading5","heading6","bulletList","orderedList","todoList","quote","codeBlock"],Ho=["todoList"],Vo=["orderedList"],Fr=["left","center","right"],Kr=["top","middle","bottom"],Wr=["gray","brown","orange","yellow","green","blue","purple","pink","red"],Gr=["bold","italic","underline","strikethrough","color","bgColor","link"],Ka=["bold","italic","underline","strikethrough","code","link","color","bgColor"];function no(){return{content:[],rowspan:1,colspan:1,covered:!1}}function go(e,n){const o=n==="codeBlock",r=n==="quote",l=[];for(const s of e){if(s.type!=="text"){l.push({...s});continue}if(o){l.push({type:"text",text:s.text});continue}let i=s.marks?s.marks.filter(c=>Ka.includes(c.type)):void 0;i&&i.some(c=>c.type==="code")&&(i=i.filter(c=>c.type==="code"||!Gr.includes(c.type))),r&&i&&(i=i.filter(c=>c.type!=="italic")),i&&(i=i.filter(c=>{var d;if(c.type!=="link")return!0;const a=(d=c.attrs)==null?void 0:d.href;return typeof a!="string"?!1:Pn(a)!==null})),i&&i.length===0&&(i=void 0),l.push(i?{...s,marks:i}:{type:"text",text:s.text})}return l}function yn(e){return{content:e.content.map(n=>({...n})),rowspan:e.rowspan,colspan:e.colspan,covered:e.covered,cellType:e.cellType,align:e.align,verticalAlign:e.verticalAlign,bgColor:e.bgColor,checked:e.checked,startNumber:e.startNumber}}function Hn(e,n,o,r,l){var f,u,h;let s=Math.max(0,Math.min(n,r)),i=Math.min(e.rows-1,Math.max(n,r)),c=Math.max(0,Math.min(o,l)),a=Math.min(e.cols-1,Math.max(o,l)),d=!0;for(;d;){d=!1;for(let p=s;p<=i;p++)for(let m=c;m<=a;m++){const k=(f=e.cells[p])==null?void 0:f[m];if(!k)continue;let x=p,D=m;if(k.covered){let $=!1;for(let V=p;V>=0&&!$;V--)for(let re=m;re>=0&&!$;re--){const G=(u=e.cells[V])==null?void 0:u[re];!G||G.covered||V+Math.max(1,G.rowspan)>p&&re+Math.max(1,G.colspan)>m&&(x=V,D=re,$=!0)}if(!$)continue}const U=(h=e.cells[x])==null?void 0:h[D];if(!U||U.covered)continue;const F=x+Math.max(1,U.rowspan)-1,ee=D+Math.max(1,U.colspan)-1;s>x&&(s=x,d=!0),i<F&&(i=F,d=!0),c>D&&(c=D,d=!0),a<ee&&(a=ee,d=!0)}}return{r1:s,c1:c,r2:i,c2:a}}function Ci(e,n,o,r,l){var d;const s=Math.max(0,Math.min(n,r)),i=Math.min(e.rows-1,Math.max(n,r)),c=Math.max(0,Math.min(o,l)),a=Math.min(e.cols-1,Math.max(o,l));for(let f=s;f<=i;f++)for(let u=c;u<=a;u++){const h=(d=e.cells[f])==null?void 0:d[u];if(!(!h||h.covered)&&(h.rowspan>1||h.colspan>1))return!0}return!1}function Wa(e,n,o,r,l){var f;const s=Math.max(0,Math.min(n,r)),i=Math.min(e.rows-1,Math.max(n,r)),c=Math.max(0,Math.min(o,l)),a=Math.min(e.cols-1,Math.max(o,l));let d=0;for(let u=s;u<=i;u++)for(let h=c;h<=a;h++){const p=(f=e.cells[u])==null?void 0:f[h];p&&!p.covered&&(d+=1)}return d}function bo(e){return{content:e.content,rowspan:e.rowspan,colspan:e.colspan,covered:e.covered,cellType:e.cellType,align:e.align,verticalAlign:e.verticalAlign,bgColor:e.bgColor,checked:e.checked,startNumber:e.startNumber}}function Ga(e,n){const o=[];for(let r=0;r<e;r++){const l=[];for(let s=0;s<n;s++)l.push(no());o.push(l)}return o}function Uo(e){const n=e.rows,o=e.cols,r=typeof n=="number"&&Number.isInteger(n)&&n>=1?n:1,l=typeof o=="number"&&Number.isInteger(o)&&o>=1?o:1;let s=[];const i=e.colWidths;if(Array.isArray(i))for(const f of i)s.push(typeof f=="number"&&Number.isFinite(f)&&f>=0?f:0);for(;s.length<l;)s.push(0);s.length>l&&(s=s.slice(0,l));const c=typeof e.headerRow=="boolean"?e.headerRow:!1;let a=[];const d=e.cells;if(Array.isArray(d))for(let f=0;f<r;f++){const u=d[f],h=[];if(Array.isArray(u))for(let p=0;p<l;p++){const m=u[p];h.push(qa(m))}else for(let p=0;p<l;p++)h.push(no());a.push(h)}for(;a.length<r;){const f=[];for(let u=0;u<l;u++)f.push(no());a.push(f)}return a.length>r&&(a=a.slice(0,r)),a=Vn(a,r,l),{rows:r,cols:l,cells:a,colWidths:s,headerRow:c}}function qa(e){if(!e||typeof e!="object")return no();const n=e,o=Array.isArray(n.content)?n.content:[],r=typeof n.cellType=="string"?n.cellType:void 0,l=r&&zr.includes(r)?r:void 0,s=go(o,l),i=typeof n.rowspan=="number"&&Number.isInteger(n.rowspan)&&n.rowspan>=1?n.rowspan:1,c=typeof n.colspan=="number"&&Number.isInteger(n.colspan)&&n.colspan>=1?n.colspan:1,a=typeof n.covered=="boolean"?n.covered:!1,d=typeof n.align=="string"?n.align:void 0,f=d&&Fr.includes(d)?d:void 0,u=typeof n.verticalAlign=="string"?n.verticalAlign:void 0,h=u&&Kr.includes(u)?u:void 0,p=typeof n.bgColor=="string"?n.bgColor:void 0,m=p&&Wr.includes(p)?p:void 0,k=typeof n.checked=="boolean"?n.checked:!1,x=l&&Ho.includes(l)?k:void 0,D=typeof n.startNumber=="number"&&Number.isInteger(n.startNumber)&&n.startNumber>=1?n.startNumber:void 0,U=l&&Vo.includes(l)?D:void 0;return{content:s,rowspan:i,colspan:c,covered:a,cellType:l,align:f,verticalAlign:h,bgColor:m,checked:x,startNumber:U}}function Vn(e,n,o){const r=e.map(l=>l.map(yn));for(let l=0;l<n;l++)for(let s=0;s<o;s++){const i=r[l][s];if(i.covered)continue;const c=Math.max(1,Math.min(i.rowspan,n-l)),a=Math.max(1,Math.min(i.colspan,o-s));if(i.rowspan=c,i.colspan=a,!(c===1&&a===1))for(let d=l;d<l+c;d++)for(let f=s;f<s+a;f++)d===l&&f===s||(r[d][f]={content:[],rowspan:1,colspan:1,covered:!0})}return r.map(l=>l.map(bo))}function Ti(e,n){var u,h;const{rows:o,cols:r,cells:l,colWidths:s,headerRow:i}=e,c=Math.max(0,Math.min(n,o)),a=l.map(p=>p.map(yn)),d=[];for(let p=0;p<r;p++){if(c>0){const m=(u=a[c-1])==null?void 0:u[p];if(m&&!m.covered&&c-1+m.rowspan>c){d.push({content:[],rowspan:1,colspan:1,covered:!0});continue}}d.push(no())}if(a.splice(c,0,d),c>0)for(let p=0;p<r;p++){const m=(h=a[c-1])==null?void 0:h[p];m&&!m.covered&&c-1+m.rowspan>c&&(m.rowspan=m.rowspan+1)}const f=Vn(a,o+1,r);return{rows:o+1,cols:r,cells:f,colWidths:[...s],headerRow:i}}function Ya(e,n){var f;const{rows:o,cols:r,colWidths:l,headerRow:s}=e;if(o<=1)return e;const i=Math.max(0,Math.min(n,o-1)),c=e.cells.map(u=>u.map(yn));for(let u=0;u<r;u++)for(let h=0;h<i;h++){const p=(f=c[h])==null?void 0:f[u];if(!p||p.covered)continue;h+p.rowspan>i&&(p.rowspan=Math.max(1,p.rowspan-1))}c.splice(i,1);let a=s;s&&i===0&&(a=!1);const d=Vn(c,o-1,r);return{rows:o-1,cols:r,cells:d,colWidths:[...l],headerRow:a}}function Za(e,n){const{rows:o,cols:r,cells:l,colWidths:s,headerRow:i}=e,c=Math.max(0,Math.min(n,r)),a=l.map(p=>p.map(yn));for(let p=0;p<o;p++){let m=!1;if(c>0){const k=a[p][c-1];k&&!k.covered&&c-1+k.colspan>c&&(k.colspan=k.colspan+1,m=!0)}a[p].splice(c,0,m?{content:[],rowspan:1,colspan:1,covered:!0}:no())}const d=[...s],f=d.filter(p=>p>0),u=f.length>0?Math.round(f.reduce((p,m)=>p+m,0)/f.length):120;d.splice(c,0,u);const h=Vn(a,o,r+1);return{rows:o,cols:r+1,cells:h,colWidths:d,headerRow:i}}function Xa(e,n){const{rows:o,cols:r,cells:l,headerRow:s}=e;if(r<=1)return e;const i=Math.max(0,Math.min(n,r-1)),c=l.map(f=>f.map(yn));for(let f=0;f<o;f++){for(let u=0;u<i;u++){const h=c[f][u];if(!h||h.covered)continue;u+h.colspan>i&&(h.colspan=Math.max(1,h.colspan-1))}c[f].splice(i,1)}const a=[...e.colWidths];a.splice(i,1);const d=Vn(c,o,r-1);return{rows:o,cols:r-1,cells:d,colWidths:a,headerRow:s}}function zo(e,n,o,r){var c;if(n<0||n>=e.rows||o<0||o>=e.cols)return e;const l=(c=e.cells[n])==null?void 0:c[o];if(!l||l.covered)return e;const s=go(r,l.cellType),i=e.cells.map((a,d)=>a.map((f,u)=>d===n&&u===o?bo({...yn(f),content:s}):f));return{...e,cells:i}}function Fo(e,n,o,r){var i;if(n<0||n>=e.rows||o<0||o>=e.cols)return e;const l=(i=e.cells[n])==null?void 0:i[o];if(!l||l.covered)return e;const s=e.cells.map((c,a)=>c.map((d,f)=>{if(a!==n||f!==o)return d;const u=yn(d);return r.cellType!==void 0&&(u.cellType=r.cellType==="paragraph"?void 0:zr.includes(r.cellType)?r.cellType:void 0,u.content=go(u.content,u.cellType),(!u.cellType||!Ho.includes(u.cellType))&&(u.checked=void 0),(!u.cellType||!Vo.includes(u.cellType))&&(u.startNumber=void 0)),r.align!==void 0&&(u.align=r.align==="left"?void 0:Fr.includes(r.align)?r.align:void 0),r.verticalAlign!==void 0&&(u.verticalAlign=r.verticalAlign==="middle"?void 0:Kr.includes(r.verticalAlign)?r.verticalAlign:void 0),r.bgColor!==void 0&&(u.bgColor=r.bgColor==="default"?void 0:Wr.includes(r.bgColor)?r.bgColor:void 0),r.checked!==void 0&&(u.checked=u.cellType&&Ho.includes(u.cellType)?r.checked:void 0),r.startNumber!==void 0&&(r.startNumber===null?u.startNumber=void 0:u.startNumber=u.cellType&&Vo.includes(u.cellType)&&typeof r.startNumber=="number"&&Number.isInteger(r.startNumber)&&r.startNumber>=1?r.startNumber:void 0),bo(u)}));return{...e,cells:s}}function oo(e,n,o){const r=new Set(n.map(s=>`${s.row}-${s.col}`)),l=e.cells.map((s,i)=>s.map((c,a)=>{if(!r.has(`${i}-${a}`)||c.covered)return c;const d=yn(c);return o.cellType!==void 0&&(d.cellType=o.cellType==="paragraph"?void 0:zr.includes(o.cellType)?o.cellType:void 0,d.content=go(d.content,d.cellType),(!d.cellType||!Ho.includes(d.cellType))&&(d.checked=void 0),(!d.cellType||!Vo.includes(d.cellType))&&(d.startNumber=void 0)),o.align!==void 0&&(d.align=o.align==="left"?void 0:Fr.includes(o.align)?o.align:void 0),o.verticalAlign!==void 0&&(d.verticalAlign=o.verticalAlign==="middle"?void 0:Kr.includes(o.verticalAlign)?o.verticalAlign:void 0),o.bgColor!==void 0&&(d.bgColor=o.bgColor==="default"?void 0:Wr.includes(o.bgColor)?o.bgColor:void 0),o.checked!==void 0&&(d.checked=d.cellType&&Ho.includes(d.cellType)?o.checked:void 0),o.startNumber!==void 0&&(o.startNumber===null?d.startNumber=void 0:d.startNumber=d.cellType&&Vo.includes(d.cellType)&&typeof o.startNumber=="number"&&Number.isInteger(o.startNumber)&&o.startNumber>=1?o.startNumber:void 0),bo(d)}));return{...e,cells:l}}function _i(e,n,o,r){const l=new Set(n.map(i=>`${i.row}-${i.col}`)),s=e.cells.map((i,c)=>i.map((a,d)=>{if(!l.has(`${c}-${d}`)||a.covered||a.cellType==="codeBlock"||a.cellType==="quote"&&o==="italic")return a;const f=yn(a);return f.content=f.content.map(u=>{if(u.type!=="text")return u;const h=u.marks?[...u.marks]:[],p=h.some(k=>k.type==="code");if(o==="code"&&r!==null){const k=h.filter(x=>x.type==="code"||!Gr.includes(x.type));return k.some(x=>x.type==="code")||k.push({type:"code"}),{...u,marks:k.length>0?k:void 0}}if(r!==null&&Gr.includes(o)&&p)return u;const m=h.filter(k=>k.type!==o);return r!==null&&m.push(r?{type:o,attrs:r}:{type:o}),{...u,marks:m.length>0?m:void 0}}),bo(f)}));return{...e,cells:s}}function ja(e,n,o){var s,i;new Set(n.map(c=>`${c.row}-${c.col}`));const r=n.filter(c=>{var d;const a=(d=e.cells[c.row])==null?void 0:d[c.col];return!(!a||a.covered||a.cellType==="codeBlock"||a.cellType==="quote"&&o==="italic")});if(r.length===0)return e;let l=!0;for(const c of r){const a=(s=e.cells[c.row])==null?void 0:s[c.col];if(!(!a||a.covered)&&a.content.length!==0){for(const d of a.content){if(d.type!=="text")continue;if(!(((i=d.marks)==null?void 0:i.some(u=>u.type===o))??!1)){l=!1;break}}if(!l)break}}return _i(e,r,o,l?null:{})}function Qa(e,n,o,r,l){var $,V,re;const s=Math.max(0,Math.min(n,r)),i=Math.min(e.rows-1,Math.max(n,r)),c=Math.max(0,Math.min(o,l)),a=Math.min(e.cols-1,Math.max(o,l));if(s===i&&c===a)return e;const d=e.cells.map(G=>G.map(yn));for(let G=s;G<=i;G++)for(let ne=c;ne<=a;ne++)d[G][ne]={content:[],rowspan:1,colspan:1,covered:!1};let f=s,u=c;for(;f>=0&&((V=($=e.cells[f])==null?void 0:$[u])!=null&&V.covered);){if(u>0){u-=1;continue}f-=1,u=e.cols-1}const h=f>=0?(re=e.cells[f])==null?void 0:re[u]:void 0,p=h?h.content.map(G=>({...G})):[],m=h==null?void 0:h.cellType,k=h==null?void 0:h.align,x=h==null?void 0:h.verticalAlign,D=h==null?void 0:h.bgColor,U=h==null?void 0:h.checked,F=h==null?void 0:h.startNumber;d[s][c]={content:go(p,m),rowspan:i-s+1,colspan:a-c+1,covered:!1,cellType:m,align:k,verticalAlign:x,bgColor:D,checked:U,startNumber:F};const ee=Vn(d,e.rows,e.cols);return{...e,cells:ee}}function xi(e,n,o){var a;if(n<0||n>=e.rows||o<0||o>=e.cols)return e;const r=(a=e.cells[n])==null?void 0:a[o];if(!r||r.covered)return e;const l=n+r.rowspan-1,s=o+r.colspan-1,i=e.cells.map(d=>d.map(yn));for(let d=n;d<=l;d++)for(let f=o;f<=s;f++)i[d][f]={content:d===n&&f===o?[...r.content]:[],rowspan:1,colspan:1,covered:!1};const c=Vn(i,e.rows,e.cols);return{...e,cells:c}}function Ja(e,n,o,r,l){var f;const s=Math.max(0,Math.min(n,r)),i=Math.min(e.rows-1,Math.max(n,r)),c=Math.max(0,Math.min(o,l)),a=Math.min(e.cols-1,Math.max(o,l));let d=e;for(let u=i;u>=s;u--)for(let h=a;h>=c;h--){const p=(f=d.cells[u])==null?void 0:f[h];!p||p.covered||p.rowspan===1&&p.colspan===1||(d=xi(d,u,h))}return d}function ed(e){return{...e,headerRow:!e.headerRow}}function Mi(e,n,o){if(n<0||n>=e.cols)return e;const r=Math.max(0,Math.round(o)),l=[...e.colWidths];for(;l.length<e.cols;)l.push(0);return l[n]=r,{...e,colWidths:l}}function ir(e){let n="";for(const o of e.content)o.type==="text"&&(n+=o.text);return n}function Ni(e){return e.replace(/\\/g,"\\\\").replace(/\|/g,"\\|").replace(/\r?\n/g,"<br>")}function td(e){var s,i;const n=[];e.colWidths;const o=[],r=[];for(let c=0;c<e.cols;c++){const a=(s=e.cells[0])==null?void 0:s[c],d=a&&!a.covered?ir(a):"";o.push(Ni(d)),r.push(e.headerRow?"---":"-")}const l=e.headerRow?1:0;e.headerRow?(n.push(`| ${o.join(" | ")} |`),n.push(`| ${r.join(" | ")} |`)):(n.push(`| ${o.join(" | ")} |`),n.push(`| ${r.join(" | ")} |`));for(let c=l;c<e.rows;c++){const a=[];for(let d=0;d<e.cols;d++){const f=(i=e.cells[c])==null?void 0:i[d],u=f&&!f.covered?ir(f):"";a.push(Ni(u))}n.push(`| ${a.join(" | ")} |`)}return n.join(`
|
|
10
|
+
`)}function nd(e){var l,s;const n=["<table>"],o=[];for(let i=0;i<e.cols;i++){const c=e.colWidths[i]??0;o.push(c>0?`<col style="width:${c}px">`:"<col>")}o.length>0&&n.push(`<colgroup>${o.join("")}</colgroup>`);const r=e.headerRow?1:0;if(e.headerRow){n.push("<thead><tr>");for(let i=0;i<e.cols;i++){const c=(l=e.cells[0])==null?void 0:l[i];if(!c||c.covered)continue;const a=c.rowspan>1?` rowspan="${c.rowspan}"`:"",d=c.colspan>1?` colspan="${c.colspan}"`:"";n.push(`<th${a}${d}>${Si(ir(c))}</th>`)}n.push("</tr></thead>")}n.push("<tbody>");for(let i=r;i<e.rows;i++){n.push("<tr>");for(let c=0;c<e.cols;c++){const a=(s=e.cells[i])==null?void 0:s[c];if(!a||a.covered)continue;const d=a.rowspan>1?` rowspan="${a.rowspan}"`:"",f=a.colspan>1?` colspan="${a.colspan}"`:"";n.push(`<td${d}${f}>${Si(ir(a))}</td>`)}n.push("</tr>")}return n.push("</tbody></table>"),n.join("")}function Si(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function od(e){var f;const n=Array.from(e.querySelectorAll("tr"));if(n.length===0)return null;let o=0;const r=[];for(const u of n){const h=Array.from(u.children).filter(m=>m.tagName==="TH"||m.tagName==="TD");let p=0;for(const m of h)p+=m.colSpan||1;p>o&&(o=p),r.push(h)}o=Math.max(1,o);const l=n.length,s=[];for(let u=0;u<l;u++){const h=[];for(let p=0;p<o;p++)h.push(no());s.push(h)}for(let u=0;u<l;u++){const h=r[u]??[];let p=0;for(const m of h){for(;p<o&&s[u][p].covered;)p++;if(p>=o)break;const k=Math.max(1,Math.min(m.rowSpan||1,l-u)),x=Math.max(1,Math.min(m.colSpan||1,o-p)),D=go(mn(m));s[u][p]={content:D,rowspan:k,colspan:x,covered:!1};for(let U=u;U<u+k;U++)for(let F=p;F<p+x;F++)U===u&&F===p||U<l&&F<o&&(s[U][F]={content:[],rowspan:1,colspan:1,covered:!0});p+=x}}const i=e.querySelectorAll("thead tr").length>0||((f=r[0])==null?void 0:f.every(u=>u.tagName==="TH"))===!0,c=[];for(let u=0;u<o;u++)c.push(0);const a=s.map(u=>u.map(bo)),d=Vn(a,l,o);return{rows:l,cols:o,cells:d,colWidths:c,headerRow:i}}function rd(e){if(!e||typeof e!="object")return!1;const n=e;return!(typeof n.rows!="number"||!Number.isInteger(n.rows)||n.rows<1||typeof n.cols!="number"||!Number.isInteger(n.cols)||n.cols<1)}function ro(e){return Uo(e)}function qr(e,n,o){var l,s;const r=(l=e.cells[n])==null?void 0:l[o];if(!r||r.covered)return 1;if(typeof r.startNumber=="number")return r.startNumber;for(let i=n-1;i>=0;i--){const c=(s=e.cells[i])==null?void 0:s[o];if(!(!c||c.covered)){if(c.cellType!=="orderedList")break;return qr(e,i,o)+1}}return 1}const Ai=new Set(["p","h1","h2","h3","h4","h5","h6","li","pre","blockquote","hr","tr","table-row","table"]),ld=/^(?:-{3,}|\*{3,}|_{3,})\s*$/,Yr={h1:1,h2:2,h3:3,h4:4,h5:5,h6:6},Ii=new Set(["meta","style","script","head","title","link","object","embed"]);function id(e){const n=(e.getAttribute("src")??"").trim();return!n||/^cid:/i.test(n)||/^(javascript|vbscript|data:text\/)/i.test(n)||n.length>1e7?null:{src:n,alt:(e.getAttribute("alt")??"").trim(),title:(e.getAttribute("title")??"").trim()}}function sr(e){return Ai.has(e)||e in Yr}function sd(e,n){if(e){const o=cd(e);if(o.length>0)return o}if(e){const o=ud(e);if(o.length>0)return o}return n?dd(n):[]}function cd(e){const n=e.match(/<!--\s*blockeditor:(.+?)\s*-->/);if(!n)return[];try{const o=JSON.parse(n[1]),r=o.type,l=o.attrs,s=o.text;if(!r)return[];const i=[];return s&&s.length>0?i.push({type:r,attrs:l??{},content:Wn(s)}):i.push({type:r,attrs:l??{},content:[]}),i}catch{return[]}}function Zr(e){let n=0;for(const o of e)o.type==="text"&&(n+=o.text.length);return n}function ad(e){if(e.length===0)return e;const n=[...e];for(;n.length>0;){const o=n[0];if(o.type!=="text")break;const r=o.text.replace(/^[\s\r\n]+/,"");if(r===o.text)break;if(r.length===0)n.shift();else{n[0]={...o,text:r};break}}for(;n.length>0;){const o=n[n.length-1];if(o.type!=="text")break;const r=o.text.replace(/[\s\r\n]+$/,"");if(r===o.text)break;if(r.length===0)n.pop();else{n[n.length-1]={...o,text:r};break}}return n}function Bi(e){for(let n=0;n<e.length;n++){const o=e[n];o.type==="codeBlock"||o.type==="image"||o.type==="table"||o.type==="divider"||(e[n]={...o,content:ad(o.content)})}}function dd(e){const n=e.split(/\r?\n/),o=[];for(const r of n)ld.test(r)?o.push({type:"divider",attrs:{},content:[]}):o.push({type:"paragraph",attrs:{},content:Wn(r)});return Bi(o),Ri(o),o}function Ri(e){const n=new Set(["image","table","divider","codeBlock"]),o=[];let r=!1;for(const l of e)!n.has(l.type)&&Zr(l.content)===0?(r||o.push(l),r=!0):(o.push(l),r=!1);for(;o.length>1&&!n.has(o[0].type)&&Zr(o[0].content)===0;)o.shift();for(;o.length>1&&!n.has(o[o.length-1].type)&&Zr(o[o.length-1].content)===0;)o.pop();e.length=0;for(const l of o)e.push(l)}function ud(e){const n=new DOMParser().parseFromString(e,"text/html"),o=[];let r=n.body;for(;r.nodeType===Node.ELEMENT_NODE;){const l=r,s=Array.from(l.childNodes),i=s.filter(u=>u.nodeType===Node.ELEMENT_NODE&&!Ii.has(u.tagName.toLowerCase())),c=i.some(u=>sr(u.tagName.toLowerCase())||u.tagName.toLowerCase()==="br"),a=s.some(u=>u.nodeType===Node.TEXT_NODE&&(u.textContent??"").length>0),d=i.some(u=>!sr(u.tagName.toLowerCase())&&u.tagName.toLowerCase()!=="div");if(c||a||d||i.length!==1)break;const f=i[0];if(f&&(f.tagName.toLowerCase()==="div"||f.tagName.toLowerCase()==="span"))r=f;else break}if(Ko(r.childNodes,n,o),Bi(o),Ri(o),o.length===0){const l=n.body.textContent??"";l.length>0&&o.push({type:"paragraph",attrs:{},content:Wn(l)})}return o}function Ko(e,n,o){var i;let r=[],l=0;function s(c=!1){if(r.length===0&&!c){l=0;return}const a=n.createElement("div");for(const f of r)a.appendChild(f.cloneNode(!0));const d=mn(a);o.push({type:"paragraph",attrs:{},content:d}),r=[],l=0}for(const c of e){if(c.nodeType===Node.COMMENT_NODE)continue;if(c.nodeType===Node.TEXT_NODE){const f=c.textContent??"";if(f.length>0&&f.trim().length===0)continue;r.push(c),l=0;continue}if(c.nodeType!==Node.ELEMENT_NODE)continue;const a=c,d=a.tagName.toLowerCase();if(!Ii.has(d)){if(d==="br"){l+=1;const f=r.length>0;s(!1),f||(l>=2||o.length>0)&&o.push({type:"paragraph",attrs:{},content:[]});continue}if(d==="pre"){s();const f=(a.textContent??"").replace(/^\n+|\n+$/g,"");o.push({type:"codeBlock",attrs:{language:"plain"},content:Wn(f)}),l=0;continue}if(d==="hr"){s(),o.push({type:"divider",attrs:{},content:[]}),l=0;continue}if(d in Yr){s(),o.push({type:"heading",attrs:{level:Yr[d]},content:mn(a)}),l=0;continue}if(d==="blockquote"){s(),Ko(a.childNodes,n,o),l=0;continue}if(d==="li"){s();const f=a.parentElement,u=(f==null?void 0:f.tagName.toLowerCase())??"",h=mn(a);u==="ol"?o.push({type:"orderedList",attrs:{},content:h}):u==="ul"?o.push({type:"bulletList",attrs:{},content:h}):o.push({type:"paragraph",attrs:{},content:h}),l=0;continue}if(Ai.has(d)){s();const f=Array.from(a.children).some(h=>sr(h.tagName.toLowerCase())),u=!!a.querySelector("img");f||u?Ko(a.childNodes,n,o):a.querySelector("br")?fd(a,n,o):o.push({type:"paragraph",attrs:{},content:mn(a)}),l=0;continue}if(d==="div"||d==="span"){const f=Array.from(a.children).some(h=>{const p=h.tagName.toLowerCase();return sr(p)||p==="div"}),u=!!a.querySelector("img");if(f||u)s(),Ko(a.childNodes,n,o),l=0;else{d==="div"&&r.length>0&&r.push(n.createTextNode(`
|
|
11
|
+
`));for(const h of Array.from(a.childNodes))r.push(h);l=0}continue}if(d==="img"){const f=id(a);f&&(s(),o.push({type:"image",attrs:{src:f.src,alt:f.alt,title:f.title},content:[]}),l=0);continue}if(d==="table"){const f=od(a);f&&(s(),o.push({type:"table",attrs:f,content:[]}),l=0);continue}if((i=a.querySelector)!=null&&i.call(a,"img")){s(),Ko(a.childNodes,n,o),l=0;continue}r.push(c),l=0}}s()}function fd(e,n,o){const r=[[]];for(const l of e.childNodes)l.nodeType===Node.ELEMENT_NODE&&l.tagName.toLowerCase()==="br"?r.push([]):r[r.length-1].push(l);for(const l of r){const s=n.createElement("div");for(const c of l)s.appendChild(c.cloneNode(!0));const i=mn(s);o.push({type:"paragraph",attrs:{},content:i})}}const lo=new Map,cr=new Set;function Li(e,n){for(const o of cr)o(e,n)}function Xn(e){return lo.get(e)??null}function wn(e,n){if(n===null){if(lo.has(e)){const o=lo.get(e);if(o!=null&&o.tempPreviewUrl&&URL.revokeObjectURL(o.tempPreviewUrl),o!=null&&o.controller)try{o.controller.abort()}catch{}lo.delete(e),Li(e,null)}}else lo.set(e,n),Li(e,n)}function Oi(e){return cr.add(e),()=>{cr.delete(e)}}const md=Oi;function pd(){for(const[,e]of lo)if(e!=null&&e.tempPreviewUrl&&URL.revokeObjectURL(e.tempPreviewUrl),e!=null&&e.controller)try{e.controller.abort()}catch{}lo.clear();for(const e of cr)e("",null)}const hd=pd,ar=new Set;function gd(){for(const e of ar)try{URL.revokeObjectURL(e)}catch{}ar.clear()}function Xr(e){const n=URL.createObjectURL(e);return ar.add(n),n}function bd(e){for(const n of e)wn(n,null)}function kd(e){bd(e)}let jr=null;function yd(e){jr=e}const wd=yd;function Di(e,n,o,r){if(!jr){r.onError("Upload handler not registered");return}jr(e,n,o,r)}function Ed(e,n){return new Promise((o,r)=>{const l=Date.now(),s=500+Math.min(2500,Math.round(e.size/2e3));let i=!1;const c=()=>{if(i)return;const a=Date.now()-l,d=Math.min(1,a/s),f=1-Math.pow(1-d,2);if(n==null||n(f),d<1)requestAnimationFrame(c);else{const u=Xr(e);if(typeof document>"u"){o({url:u});return}const h=document.createElement("img");let p=!1;const m=(k,x)=>{p||(p=!0,o({url:u,width:k,height:x}))};h.onload=()=>m(h.naturalWidth||void 0,h.naturalHeight||void 0),h.onerror=()=>m(),h.src=u,setTimeout(()=>m(),5e3)}};requestAnimationFrame(c),e.type.startsWith("image/")||(i=!0,setTimeout(()=>r(new Error("Not an image file")),30))})}function vd(e,n){return new Promise(o=>{const r=Xr(n),l=new AbortController;wn(e,{status:"pending",progress:0,file:n,tempPreviewUrl:r,controller:l});let s,i;if(typeof document<"u"){const c=document.createElement("img");let a=!1;const d=()=>{a||(a=!0,s=c.naturalWidth||void 0,i=c.naturalHeight||void 0)};c.onload=d,c.onerror=d,c.src=r,setTimeout(d,4e3)}try{Di(n.name,n,l,{onProgress:c=>{const a=Xn(e);if(!a)return;const d=Math.max(0,Math.min(1,Number.isFinite(c)?c:0));wn(e,{...a,progress:d})},onSuccess:c=>{const a=Xn(e);if(a!=null&&a.tempPreviewUrl&&a.tempPreviewUrl!==c.url){try{URL.revokeObjectURL(a.tempPreviewUrl)}catch{}ar.delete(a.tempPreviewUrl)}wn(e,null),o({ok:!0,value:{url:c.url,width:c.width??s,height:c.height??i,alt:c.alt,title:c.title,fileId:c.fileId}})},onError:c=>{const a=Xn(e);wn(e,{status:"error",progress:0,error:c,file:(a==null?void 0:a.file)??n,tempPreviewUrl:a==null?void 0:a.tempPreviewUrl}),o({ok:!1,error:c})}})}catch(c){const a=c instanceof Error?c.message:String(c);wn(e,{status:"error",progress:0,error:a,file:n,tempPreviewUrl:r}),o({ok:!1,error:a})}})}async function Qr(e,n){if(!e)return null;try{if(e.startsWith("data:"))return Cd(e,n);const o=await fetch(e);if(!o.ok)return null;const r=await o.blob(),l=$i(r.type,e),s=n?Pi(n,l):`image-${Date.now()}${l}`;return new File([r],s,{type:r.type||"image/png"})}catch{return null}}function Cd(e,n){const o=e.match(/^data:([^;,]+)?(;base64)?,(.*)$/);if(!o)return null;const[,r,l,s]=o,i=r||"image/png",c=!!l;let a;if(c){const h=atob(s);a=new Uint8Array(h.length);for(let p=0;p<h.length;p++)a[p]=h.charCodeAt(p)}else{const h=decodeURIComponent(s);a=new TextEncoder().encode(h)}const d=$i(i,e),f=n?Pi(n,d):`image-${Date.now()}${d}`,u=new Blob([a],{type:i});return new File([u],f,{type:i})}function $i(e,n){if(e.includes("png"))return".png";if(e.includes("jpeg")||e.includes("jpg"))return".jpg";if(e.includes("gif"))return".gif";if(e.includes("webp"))return".webp";if(e.includes("svg"))return".svg";if(e.includes("bmp"))return".bmp";const o=n.match(/\.(png|jpe?g|gif|webp|svg|bmp)$/i);return o?`.${o[1].toLowerCase()}`:".png"}function Pi(e,n){return e.toLowerCase().endsWith(n.toLowerCase())?e:e+n}const Td=["data-block-id","data-empty","data-placeholder","contenteditable"],Un=t.defineComponent({__name:"BlockContent",props:{block:{},placeholder:{}},emits:["slashTrigger","inputChanged","linkClick","focusIn"],setup(e,{emit:n}){const o=e,r=n,l=fn(),s=Yn(),i=t.ref(null),c=t.shallowRef(!1);function a(){return Ae(o.block.content).length===0}const d=t.ref(a());t.onMounted(()=>{const S=i.value;if(!S)return;const K=Ae(o.block.content);Ei(o.block.content)?S.innerHTML=Zn(o.block.content):S.textContent=K,d.value=K.length===0});function f(S){const K=window.getSelection();if(!K||K.rangeCount===0)return null;const _=K.getRangeAt(0);if(!S.contains(_.commonAncestorContainer))return null;const O=document.createRange();O.selectNodeContents(S),O.setEnd(_.startContainer,_.startOffset);const M=O.toString().length;O.setEnd(_.endContainer,_.endOffset);const E=O.toString().length;return{from:Math.min(M,E),to:Math.max(M,E)}}function u(S,K){const _=document.createTreeWalker(S,NodeFilter.SHOW_TEXT);let O=Math.max(0,K),M=null;for(;_.nextNode();){const E=_.currentNode;M=E;const N=(E.nodeValue??"").length;if(O<=N)return{node:E,offset:O};O-=N}return M?{node:M,offset:(M.nodeValue??"").length}:{node:S,offset:0}}function h(S,K,_){const O=window.getSelection();if(!O)return;const M=u(S,K),E=u(S,Math.max(K,_));try{const N=document.createRange();K<=_?(N.setStart(M.node,M.offset),N.setEnd(E.node,E.offset)):(N.setStart(E.node,E.offset),N.setEnd(M.node,M.offset)),O.removeAllRanges(),O.addRange(N)}catch{try{const N=document.createRange();N.setStart(E.node,E.offset),N.collapse(!0),O.removeAllRanges(),O.addRange(N)}catch{}}}t.watch(()=>o.block,S=>{if(c.value)return;const K=i.value;if(!K)return;const _=f(K),O=_&&_.from!==_.to,M=document.activeElement===K,E=Ae(S.content),N=E.length===0;let A=!1;if(N)K.childNodes.length>0&&(K.textContent="",A=!0);else{const W=Ei(S.content),me=!!K.querySelector(Da);if(!W&&!me)K.textContent!==E&&(K.textContent=E,A=!0);else{const le=vi(mn(K)),he=vi(S.content);le!==he&&(K.innerHTML=Zn(S.content),A=!0)}}d.value=N,A&&_&&(M||O)&&h(K,_.from,_.to)});function p(S){S.key==="Enter"&&!S.shiftKey&&!S.isComposing&&S.preventDefault()}function m(S){var A,W;if(!s.value)return;const K=i.value;if(!K)return;const _=mn(K),O=Ae(_);if(d.value=O.length===0,r("inputChanged",o.block.id,O),c.value||Ia({editor:l,registry:l.registries.inputRules,blockId:o.block.id,text:O}))return;if(Ba(O)){const me=O.match(/\/([^/]*)$/),le=O.lastIndexOf("/"),he=me&&me[1]!==void 0?me[1]:le>=0?O.slice(le+1):"";r("slashTrigger",K,o.block.id,he)}let E=_;l.registries.schema.get(o.block.type).inlineMarks&&S.data&&/\s/.test(S.data)&&(E=lr(_)),(W=(A=l.commands).setText)==null||W.call(A,{id:o.block.id,content:E})}function k(S){c.value=!0}function x(S){var N,A;if(c.value=!1,!s.value)return;const K=i.value;if(!K)return;const _=mn(K),O=Ae(_);d.value=O.length===0,r("inputChanged",o.block.id,O);const E=l.registries.schema.get(o.block.type).inlineMarks?lr(_):_;(A=(N=l.commands).setText)==null||A.call(N,{id:o.block.id,content:E})}function D(){const S=i.value;if(!S)return null;const K=window.getSelection();if(!K||K.rangeCount===0)return null;const _=K.getRangeAt(0);if(!S.contains(_.commonAncestorContainer))return null;const O=Ae(o.block.content),M=document.createRange();M.selectNodeContents(S),M.setEnd(_.startContainer,_.startOffset);const E=Math.min(M.toString().length,O.length);M.setEnd(_.endContainer,_.endOffset);const N=Math.min(M.toString().length,O.length);return[Math.min(E,N),Math.max(E,N)]}function U(S){var W,me;const K=D();if(!K)return;const[_,O]=K;if(_===O)return;const[,M]=Wt(o.block.content,_),[E]=Wt(M,O-_),N=Ae(E),A=Zn(E);S.preventDefault(),(W=S.clipboardData)==null||W.setData("text/plain",N),(me=S.clipboardData)==null||me.setData("text/html",A)}function F(S){var le,he,ae,ie;if(!s.value){S.preventDefault();return}const K=D();if(!K)return;const[_,O]=K;if(_===O)return;const[M,E]=Wt(o.block.content,_),[N,A]=Wt(E,O-_),W=Ae(N),me=Zn(N);S.preventDefault(),(le=S.clipboardData)==null||le.setData("text/plain",W),(he=S.clipboardData)==null||he.setData("text/html",me),(ie=(ae=l.commands).setText)==null||ie.call(ae,{id:o.block.id,content:[...M,...A],selectionAfter:st(o.block.id,_)})}const ee=_a();function $(S){const K=[],_=new Set;if(S.items&&S.items.length>0)for(let O=0;O<S.items.length;O++){const M=S.items[O];if(M.kind!=="file")continue;const E=M.getAsFile();if(!E||!E.type.startsWith("image/"))continue;const N=`${E.name||""}:${E.size}:${E.type}`;_.has(N)||(_.add(N),K.push(E))}if(S.files&&S.files.length>0)for(let O=0;O<S.files.length;O++){const M=S.files[O];if(!M.type.startsWith("image/"))continue;const E=`${M.name||""}:${M.size}:${M.type}`;_.has(E)||(_.add(E),K.push(M))}return K}async function V(S){var Mt,Zt,Gt,Rt,tt,yt,vt,Ze,Ve,Ct,fe,Tt,Xe,Re,qt,rt,Et,P,w,z,we,ve,nt,lt,on,cn,He,vn,Xt,bn,Cn,Tn;if(!s.value){S.preventDefault();return}const K=S.clipboardData;if(!K)return;if(ee){const Me=$(K);if(Me.length>0){S.preventDefault();let Ie=o.block.id;for(let Ge=0;Ge<Me.length;Ge++){const ct=Me[Ge],Ke=await ee(ct,{relativeToBlockId:Ie,convertIfEmpty:Ge===0,position:"after"});Ke&&(Ie=Ke)}return}}const _=K.getData("text/html"),O=K.getData("text/plain"),M=sd(_||null,O||null);if(M.length===0)return;const E=M.some(Me=>Me.type==="image"),N=D(),A=Ae(o.block.content).length,W=N?N[0]:A,me=N?N[1]:A,[le]=Wt(o.block.content,W),[,he]=Wt(o.block.content,me),ae=l.registries.schema.get(o.block.type),ie=Me=>ae.inlineMarks?Me:Me.map(Ie=>({type:"text",text:Ie.text}));if(!E){if(M.length===1){const Ge=ie(M[0].content);if(ae.inlineMarks&&W<me&&Ge.length===1&&Ge[0].type==="text"&&!Ge[0].marks){const At=Ge[0].text;if(Ur(At)){const an=to(At),Lt=Pn(an);if(Lt){(Zt=(Mt=l.commands).setLink)==null||Zt.call(Mt,{id:o.block.id,href:Lt,from:W,to:me});return}}}const ct=[...le,...Ge,...he],Ke=ae.inlineMarks?lr(ct):ct,_t=Ae(le).length,ft=Ae(Ge).length,ht=_t+ft;(Rt=(Gt=l.commands).setText)==null||Rt.call(Gt,{id:o.block.id,content:Ke,selectionAfter:st(o.block.id,ht)});return}const Me=[...le,...ie(M[0].content)];(yt=(tt=l.commands).setText)==null||yt.call(tt,{id:o.block.id,content:Me});let Ie=o.block.id;for(let Ge=1;Ge<M.length;Ge++){const ct=M[Ge],Ke=Ge===M.length-1,_t=ie(ct.content),ft=Ke?[..._t,...he]:_t,ht=l.registries.schema.coerceAttrsFor(ct.type,ct.attrs);(Ze=(vt=l.commands).insertBlock)==null||Ze.call(vt,{after:Ie,type:ct.type,attrs:ht,content:ft});const At=l.getState();if(At.selection.kind==="caret"&&(Ie=At.selection.blockId),Ke){const an=Ae(_t).length,Lt=he.length>0?an:Ae(ft).length;(Ct=(Ve=l.commands).setSelection)==null||Ct.call(Ve,{selection:st(Ie,Lt)})}}return}if(!ee){const Me=M.filter(Ie=>Ie.type!=="image");if(Me.length===0)return;if(M.splice(0,M.length,...Me),M.length===1){const Ie=ie(M[0].content),Ge=[...le,...Ie,...he];(Tt=(fe=l.commands).setText)==null||Tt.call(fe,{id:o.block.id,content:Ge,selectionAfter:st(o.block.id,Ae(le).length+Ae(Ie).length)})}return}let Se=-1;for(let Me=M.length-1;Me>=0;Me--)if(M[Me].type!=="image"){Se=Me;break}let Te=o.block.id;const We=M[0];if(We.type!=="image"){const Ie=Se===0?[...le,...ie(We.content),...he]:[...le,...ie(We.content)];(Re=(Xe=l.commands).setText)==null||Re.call(Xe,{id:o.block.id,content:Ie}),Te=o.block.id}else{const Me=le.length===0&&he.length===0,Ie=We.attrs.src,Ge=We.attrs.alt??"";if(Me){const ct=await Qr(Ie,Ge||void 0);if(ct){const Ke=await ee(ct,{relativeToBlockId:Te,position:"after",convertIfEmpty:!0});Ke&&(Te=Ke)}else{const Ke=l.registries.schema.coerceAttrsFor(We.type,We.attrs);(rt=(qt=l.commands).replaceBlock)==null||rt.call(qt,{id:o.block.id,type:We.type,attrs:Ke}),Te=o.block.id}}else{(P=(Et=l.commands).setText)==null||P.call(Et,{id:o.block.id,content:le});const ct=await Qr(Ie,Ge||void 0);if(ct){const Ke=await ee(ct,{relativeToBlockId:Te,position:"after",convertIfEmpty:!1});Ke&&(Te=Ke)}else{const Ke=l.registries.schema.coerceAttrsFor(We.type,We.attrs);(z=(w=l.commands).insertBlock)==null||z.call(w,{after:Te,type:We.type,attrs:Ke,content:[]});const _t=l.getState();_t.selection.kind==="caret"&&(Te=_t.selection.blockId)}}}for(let Me=1;Me<M.length;Me++){const Ie=M[Me],Ge=Me===Se;if(Ie.type==="image"){const ct=Ie.attrs.src,Ke=Ie.attrs.alt??"",_t=await Qr(ct,Ke||void 0);if(_t){const ft=await ee(_t,{relativeToBlockId:Te,position:"after",convertIfEmpty:!1});ft&&(Te=ft)}else{const ft=l.registries.schema.coerceAttrsFor(Ie.type,Ie.attrs);(ve=(we=l.commands).insertBlock)==null||ve.call(we,{after:Te,type:Ie.type,attrs:ft,content:[]});const ht=l.getState();ht.selection.kind==="caret"&&(Te=ht.selection.blockId)}}else{const ct=ie(Ie.content),Ke=Ge?[...ct,...he]:ct,_t=l.registries.schema.coerceAttrsFor(Ie.type,Ie.attrs);(lt=(nt=l.commands).insertBlock)==null||lt.call(nt,{after:Te,type:Ie.type,attrs:_t,content:Ke});const ft=l.getState();if(ft.selection.kind==="caret"&&(Te=ft.selection.blockId),Ge){const ht=Ae(ct).length,At=he.length>0?ht:Ae(Ke).length;(cn=(on=l.commands).setSelection)==null||cn.call(on,{selection:st(Te,At)})}}}if(Se===-1&&he.length>0){(vn=(He=l.commands).insertBlock)==null||vn.call(He,{after:Te,type:"paragraph",attrs:{},content:he});const Me=l.getState();Me.selection.kind==="caret"&&(Te=Me.selection.blockId,(bn=(Xt=l.commands).setSelection)==null||bn.call(Xt,{selection:st(Te,Ae(he).length)}))}else Se===-1&&(le.length>0||he.length>0)&&((Tn=(Cn=l.commands).insertBlock)==null||Tn.call(Cn,{after:Te,type:"paragraph",attrs:{},content:[]}))}function re(){r("focusIn",o.block.id)}function G(){}function ne(S){return document.createTreeWalker(S,NodeFilter.SHOW_TEXT).nextNode()}function Z(S){var N;const K=S.target;if(!K)return;const _=K.closest("a");if(!_||!((N=i.value)!=null&&N.contains(_)))return;S.preventDefault();const O=window.getSelection();let M=0;if(O&&O.rangeCount>0&&!!_.contains(O.getRangeAt(0).commonAncestorContainer)){const A=O.getRangeAt(0),W=document.createRange();W.selectNodeContents(i.value),W.setEnd(A.startContainer,A.startOffset),M=W.toString().length}else{const A=ne(_);if(A){const W=document.createRange();W.selectNodeContents(i.value),W.setEnd(A,0),M=W.toString().length}}r("linkClick",o.block.id,M)}return(S,K)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"el",ref:i,class:"block-content","data-block-id":e.block.id,"data-empty":d.value,"data-placeholder":e.placeholder,contenteditable:t.unref(s),spellcheck:"false",onInput:m,onCompositionstart:k,onCompositionend:x,onFocus:re,onBlur:G,onKeydown:p,onClick:Z,onPaste:t.withModifiers(V,["prevent"]),onCopy:U,onCut:F},null,40,Td))}});function Hi(e){return e==="zh-CN"||e===null||e===void 0||e===""?"zh-CN":"en-US"}function Vi(e){return e==="dark"?"dark":"light"}const _d={"zh-CN":{"editor.placeholder":"输入文字,或按 '/' 获取命令…","handle.plus.title":"点击添加块","handle.plus.ariaLabel":"Insert block below","handle.grip.title":"拖拽移动 / 点击设置","handle.grip.ariaLabel":"Drag to move block, click to open settings","ui.scrollUp":"向上滚动","ui.scrollDown":"向下滚动","ui.scrollLeft":"向左","ui.scrollRight":"向右","plus.category.basic":"基本区块","plus.category.list":"列表","plus.category.other":"其他","plus.noMatch":"未找到匹配的命令","plus.searchPlaceholder":"搜索命令…","slash.paragraph.title":"正文","slash.paragraph.description":"普通文本段落。","slash.heading1.title":"一级标题","slash.heading1.description":"用于文章的主标题。","slash.heading2.title":"二级标题","slash.heading2.description":"用于主要章节的标题。","slash.heading3.title":"三级标题","slash.heading3.description":"用于子章节的标题。","slash.heading4.title":"四级标题","slash.heading4.description":"用于更细分层的标题。","slash.heading5.title":"五级标题","slash.heading5.description":"用于较小层级的标题。","slash.heading6.title":"六级标题","slash.heading6.description":"用于最小层级的标题。","slash.bulletList.title":"项目符号列表","slash.bulletList.description":"创建一个无序列表。","slash.orderedList.title":"编号列表","slash.orderedList.description":"创建一个带编号的有序列表。","slash.todoList.title":"待办列表","slash.todoList.description":"用复选框追踪待办任务。","slash.quote.title":"引用","slash.quote.description":"引用一段话。","slash.codeBlock.title":"代码块","slash.codeBlock.description":"插入一段代码块。","codeBlock.title":"代码块","slash.divider.title":"分隔符","slash.divider.description":"插入一条水平分隔线。","slash.image.title":"图片","slash.image.description":"插入一张图片(从本地上传或选择文件)。","slash.table3x3.title":"表格(3×3)","slash.table3x3.description":"插入一个 3 行 3 列的表格。","slash.table2x2.title":"表格(2×2)","slash.table2x2.description":"插入一个 2 行 2 列的表格。","slash.table4x4.title":"表格(4×4)","slash.table4x4.description":"插入一个 4 行 4 列的表格。","bsm.section.turnInto":"转换为","bsm.section.alignIndent":"对齐与缩进","bsm.section.align":"对齐","bsm.section.indent":"缩进","bsm.section.action":"操作","bsm.section.textColor":"文字颜色","bsm.section.bgColor":"背景颜色","bsm.indent.decrease":"减少缩进","bsm.indent.increase":"增加缩进","turnInto.paragraph":"正文","turnInto.h1":"一级标题","turnInto.h2":"二级标题","turnInto.h3":"三级标题","turnInto.h4":"四级标题","turnInto.h5":"五级标题","turnInto.h6":"六级标题","turnInto.bullet":"项目符号","turnInto.ordered":"编号列表","turnInto.todo":"待办","turnInto.quote":"引用","turnInto.code":"代码块","align.left":"左对齐","align.center":"居中","align.right":"右对齐","align.justify":"两端对齐","verticalAlign.top":"顶端对齐","verticalAlign.middle":"垂直居中","verticalAlign.bottom":"底端对齐","hoverToolbar.verticalAlignBtnTitle":"垂直对齐","action.duplicate":"复制","action.copy":"拷贝","action.cut":"剪切","action.moveUp":"上移","action.moveDown":"下移","action.delete":"删除","ol.continue":"继续之前的编号","ol.startNew":"开始新列表(从1开始)","ol.modify":"修改编号值…","numberPicker.title":"修改编号值","numberPicker.inputLabel":"编号值","numberPicker.confirm":"确定","codeLang.title":"设置代码类型","codeLang.inputLabel":"代码类型","codeLang.placeholder":"请输入代码类型","codeLang.confirm":"确定","codeLang.custom":"自定义…","codeLang.cancel":"取消","codeLang.plain":"纯文本","hoverToolbar.label":"格式化","hoverToolbar.typeBtnTitle":"切换块类型","hoverToolbar.alignBtnTitle":"对齐方式","hoverToolbar.colorBtnTitle":"颜色","hoverToolbar.textColor":"文字颜色","hoverToolbar.bgColor":"背景颜色","hoverToolbar.copySelection":"复制选中文本","hoverToolbar.deleteBlock":"删除块","mark.bold":"加粗","mark.italic":"斜体","mark.underline":"下划线","mark.strikethrough":"删除线","mark.inlineCode":"行内代码","mark.link":"链接","link.popoverLabel":"链接","link.open":"打开链接","link.copy":"复制链接","link.edit":"编辑链接","link.remove":"移除链接","link.save":"保存","link.cancel":"取消","link.urlPlaceholder":"输入链接地址…","link.textPlaceholder":"链接文本…","link.emptyUrl":"(空链接)","link.invalidUrl":"请输入有效的链接地址","hoverToolbar.linkBtnTitle":"链接","color.default":"默认","color.gray":"灰色","color.brown":"棕色","color.orange":"橙色","color.yellow":"黄色","color.green":"绿色","color.blue":"蓝色","color.purple":"紫色","color.pink":"粉色","color.red":"红色","color.none":"无","image.uploading":"正在上传图片…","image.uploadFailed":"上传失败","image.loadFailed":"图片加载失败","image.retry":"重试","image.replace":"替换图片","image.remove":"删除图片","image.resize":"拖拽调整尺寸","image.emptyTitle":"点击上传图片","image.emptySub":"或拖入图片文件到此处","image.captionPlaceholder":"添加图片说明…","turnInto.image":"图片","table.title":"表格","table.cellPlaceholder":"输入内容…","table.resizeCol":"拖拽调整列宽","table.rowActions":"行操作","table.colActions":"列操作","table.selectRow":"选择此行","table.selectCol":"选择此列","table.selectAll":"选择整个表格","table.insertRowAbove":"在上方插入行","table.insertRowBelow":"在下方插入行","table.insertColLeft":"在左侧插入列","table.insertColRight":"在右侧插入列","table.removeRow":"删除此行","table.removeCol":"删除此列","table.deleteRow":"删除行","table.deleteCol":"删除列","table.toggleHeader":"切换表头行","table.mergeCells":"合并单元格","table.splitCell":"拆分单元格","table.deleteTable":"删除表格","turnInto.table":"表格","toc.title":"目录","toc.empty":"暂无标题","slash.tableOfContents.title":"目录","slash.tableOfContents.description":"插入文档目录。"},"en-US":{"editor.placeholder":"Type '/' for commands...","handle.plus.title":"Insert block below","handle.plus.ariaLabel":"Insert block below","handle.grip.title":"Drag to move / click for settings","handle.grip.ariaLabel":"Drag to move block, click to open settings","ui.scrollUp":"Scroll up","ui.scrollDown":"Scroll down","ui.scrollLeft":"Scroll left","ui.scrollRight":"Scroll right","plus.category.basic":"Basic blocks","plus.category.list":"Lists","plus.category.other":"Other","plus.noMatch":"No matching commands","plus.searchPlaceholder":"Search commands...","slash.paragraph.title":"Paragraph","slash.paragraph.description":"Plain text paragraph.","slash.heading1.title":"Heading 1","slash.heading1.description":"Main title for the document.","slash.heading2.title":"Heading 2","slash.heading2.description":"Title for major sections.","slash.heading3.title":"Heading 3","slash.heading3.description":"Title for sub-sections.","slash.heading4.title":"Heading 4","slash.heading4.description":"Title for finer hierarchy levels.","slash.heading5.title":"Heading 5","slash.heading5.description":"Title for smaller hierarchy levels.","slash.heading6.title":"Heading 6","slash.heading6.description":"Title for the smallest hierarchy level.","slash.bulletList.title":"Bullet list","slash.bulletList.description":"Create an unordered list.","slash.orderedList.title":"Numbered list","slash.orderedList.description":"Create a numbered ordered list.","slash.todoList.title":"To-do list","slash.todoList.description":"Track tasks with checkboxes.","slash.quote.title":"Quote","slash.quote.description":"Quote a passage of text.","slash.codeBlock.title":"Code block","slash.codeBlock.description":"Insert a code block.","codeBlock.title":"Code block","slash.divider.title":"Divider","slash.divider.description":"Insert a horizontal divider line.","slash.image.title":"Image","slash.image.description":"Insert an image (upload or choose a file).","slash.table3x3.title":"Table (3×3)","slash.table3x3.description":"Insert a 3-row 3-column table.","slash.table2x2.title":"Table (2×2)","slash.table2x2.description":"Insert a 2-row 2-column table.","slash.table4x4.title":"Table (4×4)","slash.table4x4.description":"Insert a 4-row 4-column table.","bsm.section.turnInto":"Turn into","bsm.section.alignIndent":"Align & Indent","bsm.section.align":"Align","bsm.section.indent":"Indent","bsm.section.action":"Actions","bsm.section.textColor":"Text color","bsm.section.bgColor":"Background color","bsm.indent.decrease":"Decrease indent","bsm.indent.increase":"Increase indent","turnInto.paragraph":"Paragraph","turnInto.h1":"Heading 1","turnInto.h2":"Heading 2","turnInto.h3":"Heading 3","turnInto.h4":"Heading 4","turnInto.h5":"Heading 5","turnInto.h6":"Heading 6","turnInto.bullet":"Bullet list","turnInto.ordered":"Numbered list","turnInto.todo":"To-do","turnInto.quote":"Quote","turnInto.code":"Code block","align.left":"Align left","align.center":"Center","align.right":"Align right","align.justify":"Justify","verticalAlign.top":"Align top","verticalAlign.middle":"Vertical center","verticalAlign.bottom":"Align bottom","hoverToolbar.verticalAlignBtnTitle":"Vertical align","action.duplicate":"Duplicate","action.copy":"Copy","action.cut":"Cut","action.moveUp":"Move up","action.moveDown":"Move down","action.delete":"Delete","ol.continue":"Continue previous numbering","ol.startNew":"Start a new list (from 1)","ol.modify":"Modify starting number...","numberPicker.title":"Modify number value","numberPicker.inputLabel":"Number value","numberPicker.confirm":"Confirm","codeLang.title":"Set code language","codeLang.inputLabel":"Code language","codeLang.placeholder":"Enter code language","codeLang.confirm":"Confirm","codeLang.custom":"Custom…","codeLang.cancel":"Cancel","codeLang.plain":"Plain text","hoverToolbar.label":"Formatting","hoverToolbar.typeBtnTitle":"Switch block type","hoverToolbar.alignBtnTitle":"Alignment","hoverToolbar.colorBtnTitle":"Color","hoverToolbar.textColor":"Text color","hoverToolbar.bgColor":"Background color","hoverToolbar.copySelection":"Copy selection","hoverToolbar.deleteBlock":"Delete block","mark.bold":"Bold","mark.italic":"Italic","mark.underline":"Underline","mark.strikethrough":"Strikethrough","mark.inlineCode":"Inline code","mark.link":"Link","link.popoverLabel":"Link","link.open":"Open link","link.copy":"Copy link","link.edit":"Edit link","link.remove":"Remove link","link.save":"Save","link.cancel":"Cancel","link.urlPlaceholder":"Enter URL...","link.textPlaceholder":"Link text...","link.emptyUrl":"(empty link)","link.invalidUrl":"Please enter a valid URL","hoverToolbar.linkBtnTitle":"Link","hoverToolbar.linkPrompt":"Enter URL:","color.default":"Default","color.gray":"Gray","color.brown":"Brown","color.orange":"Orange","color.yellow":"Yellow","color.green":"Green","color.blue":"Blue","color.purple":"Purple","color.pink":"Pink","color.red":"Red","color.none":"None","image.uploading":"Uploading image...","image.uploadFailed":"Upload failed","image.loadFailed":"Failed to load image","image.retry":"Retry","image.replace":"Replace image","image.remove":"Remove image","image.resize":"Drag to resize","image.emptyTitle":"Click to upload an image","image.emptySub":"or drag an image file here","image.captionPlaceholder":"Add a caption...","turnInto.image":"Image","table.title":"Table","table.cellPlaceholder":"Type here...","table.resizeCol":"Drag to resize column","table.rowActions":"Row actions","table.colActions":"Column actions","table.selectRow":"Select row","table.selectCol":"Select column","table.selectAll":"Select entire table","table.insertRowAbove":"Insert row above","table.insertRowBelow":"Insert row below","table.insertColLeft":"Insert column left","table.insertColRight":"Insert column right","table.removeRow":"Delete row","table.removeCol":"Delete column","table.deleteRow":"Delete row","table.deleteCol":"Delete column","table.toggleHeader":"Toggle header row","table.mergeCells":"Merge cells","table.splitCell":"Split cell","table.deleteTable":"Delete table","turnInto.table":"Table","toc.title":"Table of Contents","toc.empty":"No headings","slash.tableOfContents.title":"Table of Contents","slash.tableOfContents.description":"Insert a table of contents."}},Ui=Symbol("be-locale"),zi=Symbol("be-theme");function xd(e,n){t.provide(Ui,e),t.provide(zi,n)}function en(){const e=t.inject(Ui,t.ref("zh-CN")),n=t.inject(zi,t.ref("light"));return{get locale(){return e.value},get theme(){return n.value},t(o){const l=_d[e.value][o];return typeof l=="string"?l:o}}}const Md=["title","aria-label","onKeydown"],Nd=["title","aria-label","onKeydown"],Sd=4,Ad=300,Id=t.defineComponent({__name:"BlockHandle",props:{blockId:{},visible:{type:Boolean}},emits:["openPlusMenu","openSettingsMenu","gripPointerDown","gripPointerUp"],setup(e,{expose:n,emit:o}){const r=e,l=o,{t:s}=en(),i=Yn(),c=t.ref(null),a=t.ref(null),d=t.ref(null),f=t.ref(!1),u=t.ref(!1),h=t.ref(null);let p=null;const m=t.computed(()=>h.value===null?void 0:{top:`${h.value}px`});function k(){var O;const S=(O=c.value)==null?void 0:O.parentElement;if(!S)return null;const K=S.querySelector(".block-host-content");if(!K)return null;const _=K.firstElementChild;return _ instanceof HTMLElement?_:K}function x(){var M;const S=(M=c.value)==null?void 0:M.parentElement,K=k();if(!S||!K)return;const _=S.getBoundingClientRect(),O=K.getBoundingClientRect();h.value=O.top-_.top+O.height/2}function D(){const S=k();S&&(U(),p=new ResizeObserver(()=>x()),p.observe(S))}function U(){p==null||p.disconnect(),p=null}t.watch(()=>r.visible,S=>{S?t.nextTick().then(()=>{x(),D()}):U()}),t.onMounted(x),t.onBeforeUnmount(U);function F(){i.value&&a.value&&l("openPlusMenu",a.value)}let ee=0,$=0,V=0,re=!1;function G(S){i.value&&(V=Date.now(),ee=S.clientX,$=S.clientY,re=!0,u.value=!1,l("gripPointerDown",r.blockId,ee,$,{thresholdPx:Sd}))}function ne(S){u.value=S}function Z(){i.value&&(u.value||re&&Date.now()-V>Ad||(re=!1,d.value&&l("openSettingsMenu",d.value)))}return n({isOpen:f,insertBtn:a,gripBtn:d,setLocalDragging:ne}),(S,K)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"handleEl",ref:c,class:t.normalizeClass(["block-handle",{visible:e.visible,dragging:u.value}]),style:t.normalizeStyle(m.value)},[t.createElementVNode("div",{ref_key:"insertBtn",ref:a,class:"handle-btn handle-insert",role:"button",tabindex:"0",title:t.unref(s)("handle.plus.title"),"aria-label":t.unref(s)("handle.plus.ariaLabel"),onMousedown:t.withModifiers(F,["prevent","stop"]),onKeydown:[t.withKeys(t.withModifiers(F,["prevent","stop"]),["enter"]),t.withKeys(t.withModifiers(F,["prevent","stop"]),["space"])]},[...K[0]||(K[0]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[t.createElementVNode("path",{d:"M8 3.5V12.5M3.5 8H12.5",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])],40,Md),t.createElementVNode("div",{ref_key:"gripBtn",ref:d,class:"handle-btn handle-grip",role:"button",tabindex:"0",title:t.unref(s)("handle.grip.title"),"aria-label":t.unref(s)("handle.grip.ariaLabel"),onMousedown:t.withModifiers(G,["prevent","stop"]),onClick:t.withModifiers(Z,["stop"]),onKeydown:[t.withKeys(t.withModifiers(Z,["prevent","stop"]),["enter"]),t.withKeys(t.withModifiers(Z,["prevent","stop"]),["space"])]},[...K[1]||(K[1]=[t.createStaticVNode('<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><circle cx="5" cy="4" r="1.3" fill="currentColor"></circle><circle cx="11" cy="4" r="1.3" fill="currentColor"></circle><circle cx="5" cy="8" r="1.3" fill="currentColor"></circle><circle cx="11" cy="8" r="1.3" fill="currentColor"></circle><circle cx="5" cy="12" r="1.3" fill="currentColor"></circle><circle cx="11" cy="12" r="1.3" fill="currentColor"></circle></svg>',1)])],40,Nd)],6))}}),Bd=["data-block-id","data-block-type"],Rd={class:"block-host-content"},Fi=t.defineComponent({__name:"BlockHost",props:{block:{},placeholder:{},hoveredBlockId:{},focusedBlockId:{},hasTextSelection:{type:Boolean},draggingBlockId:{},dropTargetBlockId:{},dropPosition:{},menuOpenBlockId:{}},emits:["openSettingsMenu","openPlusMenu","slashTrigger","inputChanged","hoverChange","gripPointerDown","gripPointerUp","linkClick","focusIn"],setup(e,{expose:n,emit:o}){const r=e,l=o,s=fn(),i=Yn(),c=t.ref(null),a=t.ref(null),d=t.computed(()=>!i.value||r.hasTextSelection?!1:r.hoveredBlockId===r.block.id||r.hoveredBlockId===null&&r.focusedBlockId===r.block.id),f=t.computed(()=>r.draggingBlockId===r.block.id),u=t.computed(()=>r.menuOpenBlockId===r.block.id),h=t.computed(()=>r.dropTargetBlockId===r.block.id),p=t.computed(()=>r.dropPosition??"after");function m(Z,S,K,_){l("gripPointerDown",Z,S,K,_)}function k(Z){l("gripPointerUp",Z)}function x(Z){var S,K;(K=(S=a.value)==null?void 0:S.setLocalDragging)==null||K.call(S,Z)}function D(){l("hoverChange",r.block.id)}function U(){l("hoverChange",null)}function F(Z){l("openPlusMenu",r.block.id,Z)}function ee(Z){l("openSettingsMenu",r.block.id,Z)}function $(Z,S,K){l("slashTrigger",Z,r.block.id,K)}function V(Z,S){l("inputChanged",Z,S)}function re(Z,S){l("linkClick",Z,S)}function G(Z){l("focusIn",Z)}const ne=t.computed(()=>{const Z=s.registries.renderers.get(r.block.type);return Z!=null&&Z.component?Z.component:Un});return n({setHandleDragging:x}),(Z,S)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"hostEl",ref:c,class:t.normalizeClass(["block-host",{"block-dragging":f.value,"block-menu-active":u.value,"block-drop-target":h.value,"block-drop-before":h.value&&p.value==="before","block-drop-after":h.value&&p.value==="after","block-drop-into":h.value&&p.value==="into","block-host-readonly":!t.unref(i),"block-focused":e.focusedBlockId===e.block.id}]),"data-block-id":e.block.id,"data-block-type":e.block.type,onMouseenter:D,onMouseleave:U},[t.unref(i)?(t.openBlock(),t.createBlock(Id,{key:0,ref_key:"handleRef",ref:a,"block-id":e.block.id,visible:d.value,onOpenPlusMenu:F,onOpenSettingsMenu:ee,onGripPointerDown:m,onGripPointerUp:k},null,8,["block-id","visible"])):t.createCommentVNode("",!0),t.createElementVNode("div",Rd,[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(ne.value),{block:e.block,placeholder:e.placeholder,onSlashTrigger:$,onInputChanged:V,onLinkClick:re,onFocusIn:G},null,40,["block","placeholder"]))])],42,Bd))}}),Ki=t.defineComponent({__name:"BlockList",props:{items:{},blocksMap:{},firstBlockPlaceholder:{},isNested:{type:Boolean},hoveredBlockId:{},focusedBlockId:{},hasTextSelection:{type:Boolean},draggingBlockId:{},dropTargetBlockId:{},dropPosition:{},menuOpenBlockId:{}},emits:["openSettingsMenu","openPlusMenu","slashTrigger","inputChanged","hoverChange","gripPointerDown","gripPointerUp","linkClick","focusIn"],setup(e,{expose:n,emit:o}){const r=e,l=o,s=new Map;function i($,V){V?s.set($,V):s.delete($)}function c($,V){var re,G;(G=(re=s.get($))==null?void 0:re.setHandleDragging)==null||G.call(re,V)}function a($){const V=[];for(const re of $.children){const G=r.blocksMap.get(re);G&&V.push({id:re,block:G})}return V}const d=t.computed(()=>!r.isNested&&!r.dropTargetBlockId&&r.dropPosition==="first"&&!!r.draggingBlockId),f=t.computed(()=>!r.isNested&&!r.dropTargetBlockId&&r.dropPosition==="last"&&!!r.draggingBlockId);function u($,V){l("openSettingsMenu",$,V)}function h($,V){l("openPlusMenu",$,V)}function p($,V,re){l("slashTrigger",$,V,re)}function m($,V){l("inputChanged",$,V)}function k($){l("hoverChange",$)}function x(){r.isNested||l("hoverChange",null)}function D($,V,re,G){l("gripPointerDown",$,V,re,G)}function U($){l("gripPointerUp",$)}function F($,V){l("linkClick",$,V)}function ee($){l("focusIn",$)}return n({setBlockHandleDragging:c}),($,V)=>{const re=t.resolveComponent("BlockList",!0);return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["block-list",{"block-children":e.isNested,"drop-indicator-first":d.value,"drop-indicator-last":f.value}]),onMouseleave:x},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.items,(G,ne)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:G.id},[t.createVNode(Fi,{ref_for:!0,ref:Z=>i(G.id,Z),block:G.block,placeholder:!e.isNested&&ne===0?e.firstBlockPlaceholder:void 0,"hovered-block-id":e.hoveredBlockId,"focused-block-id":e.focusedBlockId,"has-text-selection":e.hasTextSelection,"dragging-block-id":e.draggingBlockId,"drop-target-block-id":e.dropTargetBlockId,"drop-position":e.dropPosition,"menu-open-block-id":e.menuOpenBlockId,onOpenSettingsMenu:u,onOpenPlusMenu:h,onSlashTrigger:p,onInputChanged:m,onHoverChange:k,onGripPointerDown:D,onGripPointerUp:U,onLinkClick:F,onFocusIn:ee},null,8,["block","placeholder","hovered-block-id","focused-block-id","has-text-selection","dragging-block-id","drop-target-block-id","drop-position","menu-open-block-id"]),G.block.children.length>0?(t.openBlock(),t.createBlock(re,{key:"__nested_"+G.id,"is-nested":"",items:a(G.block),"hovered-block-id":e.hoveredBlockId,"focused-block-id":e.focusedBlockId,"has-text-selection":e.hasTextSelection,"dragging-block-id":e.draggingBlockId,"drop-target-block-id":e.dropTargetBlockId,"drop-position":e.dropPosition,"menu-open-block-id":e.menuOpenBlockId,"blocks-map":e.blocksMap,onOpenSettingsMenu:V[0]||(V[0]=(Z,S)=>l("openSettingsMenu",Z,S)),onOpenPlusMenu:V[1]||(V[1]=(Z,S)=>l("openPlusMenu",Z,S)),onSlashTrigger:V[2]||(V[2]=(Z,S,K)=>l("slashTrigger",Z,S,K)),onInputChanged:V[3]||(V[3]=(Z,S)=>l("inputChanged",Z,S)),onHoverChange:V[4]||(V[4]=Z=>l("hoverChange",Z)),onGripPointerDown:V[5]||(V[5]=(Z,S,K,_)=>l("gripPointerDown",Z,S,K,_)),onGripPointerUp:V[6]||(V[6]=Z=>l("gripPointerUp",Z)),onLinkClick:V[7]||(V[7]=(Z,S)=>l("linkClick",Z,S)),onFocusIn:V[8]||(V[8]=Z=>l("focusIn",Z))},null,8,["items","hovered-block-id","focused-block-id","has-text-selection","dragging-block-id","drop-target-block-id","drop-position","menu-open-block-id","blocks-map"])):t.createCommentVNode("",!0)],64))),128))],34)}}});function Wi(e,n,o,r=6,l="auto",s=0,i=0){const c=n instanceof HTMLElement?n.getBoundingClientRect():n,a=document.documentElement.clientHeight,d=Ld(),f=Math.max(0,a-c.bottom-r-s),u=Math.max(0,c.top-r-i),h=f>=o.height+r,p=u>=o.height+r,m=l==="down"?!1:l==="up"?!0:!h&&(p||u>f);let k,x,D;const U=c.bottom+r,F=c.top-r;m?(k=Math.max(r+i,F-o.height),x=F,D=Math.max(120,u)):(k=U,x=k+o.height,D=Math.max(120,f));const ee=d-o.width-r,$=Math.max(r,Math.min(ee,c.left));return{top:k,left:$,above:m,availableHeight:D,bottom:x,topBaseline:U}}function Gi(e,n,o,r=8){const l=document.documentElement.clientHeight,s=document.documentElement.clientWidth,i=n.left+(n.width-o.width)/2,c=Math.max(r,Math.min(s-o.width-r,i)),a=l-n.bottom-r,d=n.top-r,f=a>=o.height,u=d>=o.height,h=!f&&(u||d>a),p=n.bottom+r,m=n.top-r,k=h?Math.max(r,m-o.height):p,x=h?m:k+o.height,D=h?Math.max(120,d):Math.max(120,a);return{top:k,left:c,above:h,availableHeight:D,bottom:x,topBaseline:p}}function qi(e,n,o,r=8){const l=document.documentElement.clientHeight,s=document.documentElement.clientWidth,i=n.left+(n.width-o.width)/2,c=Math.max(r,Math.min(s-o.width-r,i)),a=n.top-r,d=l-n.bottom-r,f=a>=o.height,u=d>=o.height,h=f||!u&&a>d||a>=d,p=n.bottom+r,m=n.top-r,k=h?Math.max(r,m-o.height):p,x=h?m:k+o.height,D=h?Math.max(120,a):Math.max(120,d);return{top:k,left:c,above:h,availableHeight:D,bottom:x,topBaseline:p}}function Ld(){return document.documentElement.clientWidth}function dr(e,n){let o=0;function r(d){const f=e.value;if(!f)return;d.preventDefault();const u=d.deltaMode===WheelEvent.DOM_DELTA_LINE?d.deltaY*22:d.deltaY;f.scrollTop+=u,n()}function l(d){d.touches.length===1&&(o=d.touches[0].clientY)}function s(d){if(d.touches.length!==1)return;const f=e.value;if(!f)return;const u=d.touches[0].clientY;f.scrollTop-=u-o,o=u,d.preventDefault(),n()}function i(d){d&&(d.addEventListener("wheel",r,{passive:!1}),d.addEventListener("touchstart",l,{passive:!0}),d.addEventListener("touchmove",s,{passive:!1}))}function c(d){d&&(d.removeEventListener("wheel",r),d.removeEventListener("touchstart",l),d.removeEventListener("touchmove",s))}let a=null;t.watch(e,(d,f,u)=>{c(a),a=d,i(d),u(()=>{c(d),a===d&&(a=null)})},{immediate:!0}),t.onBeforeUnmount(()=>{c(a),a=null})}function Yi(e,n,o,r){function l(u){const h=e.value;if(!h||!u)return!1;if(u instanceof Node&&h.contains(u))return!0;if(r){const p=r(),m=Array.isArray(p)?p:[p];for(const k of m)if(k&&u instanceof Node&&k.contains(u))return!0}return!1}function s(u){n()&&(l(u.target)||o())}function i(u){n()&&(l(u.target)||o())}function c(){n()&&o()}function a(u){u&&u.addEventListener("mouseleave",c)}function d(u){u&&u.removeEventListener("mouseleave",c)}let f=null;t.watch(e,(u,h,p)=>{d(f),f=u,a(u),p(()=>{d(u),f===u&&(f=null)})},{immediate:!0}),t.onMounted(()=>{window.addEventListener("mousedown",s,!0),window.addEventListener("touchstart",s,!0),window.addEventListener("wheel",i,!0)}),t.onBeforeUnmount(()=>{window.removeEventListener("mousedown",s,!0),window.removeEventListener("touchstart",s,!0),window.removeEventListener("wheel",i,!0),d(f),f=null})}const Od=["innerHTML"],pn=t.defineComponent({__name:"SafeHtml",props:{html:{default:""}},setup(e){return(n,o)=>(t.openBlock(),t.createElementBlock("span",{innerHTML:e.html},null,8,Od))}}),Dd=["aria-label"],$d={key:0,class:"slash-menu-empty"},Pd={key:0,class:"slash-menu-group-label"},Hd=["aria-selected","onMousedown","onMouseenter"],Vd={class:"slash-menu-text"},Ud={class:"slash-menu-title"},zd={key:0,class:"slash-menu-desc"},Fd=["aria-label"],Jr=300,Kd=80,Zi=24,Wd=t.defineComponent({__name:"PlusMenu",props:{visible:{type:Boolean},anchorEl:{},blockId:{},query:{},rootEl:{},mode:{default:"slash"}},emits:["close","commit"],setup(e,{expose:n,emit:o}){const r=e,l=o,{t:s}=en(),i=t.computed(()=>({basic:s("plus.category.basic"),list:s("plus.category.list"),other:s("plus.category.other")})),c=fn(),a=t.inject(Do,t.ref(!1)),d=t.ref(null),f=t.ref(null),u=t.ref(0),h=t.ref({top:0,left:0,availableHeight:360,above:!1,bottom:0,topBaseline:0}),p=t.ref(!1),m=t.ref(!1),k=t.ref(!1),x=t.ref(!1);let D=null;t.watch(()=>r.visible,M=>{M?(D&&(clearTimeout(D),D=null),x.value=!0):D=setTimeout(()=>{x.value=!1,D=null},300)},{immediate:!0});function U(M){return typeof M=="string"?M:"•"}const F=t.computed(()=>{const M=r.query.trim().toLowerCase(),E=c.registries.slash.all;return M?E.filter(N=>(s(N.title)+" "+(N.keywords??[]).join(" ")).toLowerCase().includes(M)):E}),ee=t.computed(()=>{const M=[],E=new Map;for(const A of F.value){const W=A.category??"other";E.has(W)||E.set(W,[]),E.get(W).push(A)}const N=["basic","list","other"];for(const A of N){const W=E.get(A);W&&W.length>0&&M.push({category:A,label:i.value[A]??A,items:W})}for(const[A,W]of E)N.includes(A)||M.push({category:A,label:i.value[A]??A,items:W});return M});function $(M){return F.value.findIndex(E=>E.id===M)}t.watch([F,()=>r.visible],()=>{u.value=0,t.nextTick(()=>{f.value&&(f.value.scrollTop=0),V()})});function V(){const M=f.value;M&&(m.value=M.scrollTop>1,k.value=M.scrollTop+M.clientHeight<M.scrollHeight-1)}function re(){const M=f.value;M&&(M.scrollTop-=M.clientHeight*.8)}function G(){const M=f.value;M&&(M.scrollTop+=M.clientHeight*.8)}dr(f,V),t.watch(()=>r.visible,M=>{M&&(p.value=!1,h.value={top:0,left:0,availableHeight:360,above:!1,bottom:0,topBaseline:0})}),t.watch([()=>r.visible,()=>r.anchorEl,d,F,m,k],async()=>{if(!r.visible||!r.anchorEl||!r.rootEl)return;await t.nextTick();const M=d.value;if(!M)return;const E=M.getBoundingClientRect(),N=!!r.anchorEl.closest(".fixed-toolbar"),A=N?a.value?"up":"down":"auto",W=N?10:0,me=Wi(r.rootEl,r.anchorEl,{width:Jr,height:E.height},6,A,W,W);h.value=me,p.value=!0,t.nextTick(V)},{flush:"post"});const ne=t.computed(()=>{if(!r.rootEl)return{display:"none"};if(!p.value)return{visibility:"hidden",top:"0px",left:"0px",width:`${Jr}px`,"--scroll-max-height":"100vh"};const M=h.value.above,E=h.value.left,N=(m.value?Zi:0)+(k.value?Zi:0),A=h.value.availableHeight-N,W={left:`${E}px`,width:`${Jr}px`,maxHeight:`${h.value.availableHeight}px`,"--scroll-max-height":`${Math.max(Kd,A)}px`};if(M){const me=document.documentElement.clientHeight;W.bottom=`${Math.max(0,me-h.value.bottom)}px`,W.top="auto"}else W.top=`${h.value.top}px`,W.bottom="auto";return W});function Z(M){if(F.value.length===0)return;const E=F.value.length;u.value=((u.value+M)%E+E)%E,S()}function S(){var N;const M=(N=f.value)==null?void 0:N.querySelectorAll(".slash-menu-item"),E=M==null?void 0:M[u.value];E&&E.scrollIntoView({block:"nearest"}),t.nextTick(V)}function K(M){switch(M.key){case"ArrowDown":return M.preventDefault(),Z(1),!0;case"ArrowUp":return M.preventDefault(),Z(-1),!0;case"PageDown":return M.preventDefault(),Z(5),!0;case"PageUp":return M.preventDefault(),Z(-5),!0;case"Home":return M.preventDefault(),u.value=0,S(),!0;case"End":return M.preventDefault(),u.value=Math.max(0,F.value.length-1),S(),!0;case"Enter":return M.preventDefault(),_(),!0;case"Escape":return M.preventDefault(),l("close"),!0;default:return!1}}function _(){const M=F.value[u.value];M&&l("commit",M,r.mode),l("close")}function O(M){const E=F.value.indexOf(M);E>=0&&(u.value=E),_()}return n({onKeyDown:K}),Yi(d,()=>r.visible,()=>l("close"),()=>r.anchorEl),t.onMounted(()=>{window.addEventListener("resize",V)}),t.onBeforeUnmount(()=>{window.removeEventListener("resize",V)}),(M,E)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[x.value&&e.rootEl?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"menuEl",ref:d,class:t.normalizeClass(["plus-menu slash-menu",{"menu-closing":!e.visible}]),style:t.normalizeStyle(ne.value),role:"listbox"},[m.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(s)("ui.scrollUp"),onMousedown:t.withModifiers(re,["prevent"])},[...E[0]||(E[0]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Dd)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:f,class:"slash-menu-scroll",onScroll:V},[F.value.length===0?(t.openBlock(),t.createElementBlock("div",$d,t.toDisplayString(t.unref(s)("plus.noMatch")),1)):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(ee.value,N=>(t.openBlock(),t.createElementBlock("div",{key:N.category,class:"slash-menu-group"},[N.label?(t.openBlock(),t.createElementBlock("div",Pd,t.toDisplayString(N.label),1)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(N.items,A=>(t.openBlock(),t.createElementBlock("div",{key:A.id,class:t.normalizeClass(["slash-menu-item",{active:$(A.id)===u.value}]),"aria-selected":$(A.id)===u.value,role:"option",onMousedown:t.withModifiers(W=>O(A),["prevent"]),onMouseenter:W=>u.value=$(A.id)},[t.createVNode(pn,{class:"slash-menu-icon",html:U(A.icon)},null,8,["html"]),t.createElementVNode("div",Vd,[t.createElementVNode("div",Ud,t.toDisplayString(t.unref(s)(A.title)),1),A.description?(t.openBlock(),t.createElementBlock("div",zd,t.toDisplayString(t.unref(s)(A.description)),1)):t.createCommentVNode("",!0)])],42,Hd))),128))]))),128))],544),k.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(s)("ui.scrollDown"),onMousedown:t.withModifiers(G,["prevent"])},[...E[1]||(E[1]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Fd)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)]))}}),Gd=["left","center","right","justify"],qd=10,tn={align:{default:"left",validate:e=>Gd.includes(e)},color:{default:"default",validate:e=>typeof e=="string"&&e.length>0},bgColor:{default:"default",validate:e=>typeof e=="string"&&e.length>0},indent:{default:0,validate:e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=qd}},Yd={align:tn.align,color:tn.color,bgColor:tn.bgColor},Zd={indent:tn.indent};function En(e){const n=[],o=e.align;typeof o=="string"&&o!=="left"&&n.push(`be-align-${o}`);const r=e.color;typeof r=="string"&&r!=="default"&&n.push(`be-color-${r}`);const l=e.bgColor;typeof l=="string"&&l!=="default"&&n.push(`be-bg-${l}`);const s=e.indent;return typeof s=="number"&&s>0&&n.push(`be-indent-${s}`),n}const Xi=[{key:"default",label:"Default",cssValue:"var(--be-fg)",opacity:1},{key:"gray",label:"Gray",cssValue:"var(--be-color-gray)",opacity:1},{key:"brown",label:"Brown",cssValue:"var(--be-color-brown)",opacity:1},{key:"orange",label:"Orange",cssValue:"var(--be-color-orange)",opacity:1},{key:"yellow",label:"Yellow",cssValue:"var(--be-color-yellow)",opacity:1},{key:"green",label:"Green",cssValue:"var(--be-color-green)",opacity:1},{key:"blue",label:"Blue",cssValue:"var(--be-color-blue)",opacity:1},{key:"purple",label:"Purple",cssValue:"var(--be-color-purple)",opacity:1},{key:"pink",label:"Pink",cssValue:"var(--be-color-pink)",opacity:1},{key:"red",label:"Red",cssValue:"var(--be-color-red)",opacity:1}],ji=[{key:"default",label:"None",cssValue:"transparent",opacity:0},{key:"gray",label:"Gray",cssValue:"var(--be-swatch-bg-gray)",opacity:.15,displayCssValue:"var(--be-swatch-display-bg-gray)"},{key:"brown",label:"Brown",cssValue:"var(--be-swatch-bg-brown)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-brown)"},{key:"orange",label:"Orange",cssValue:"var(--be-swatch-bg-orange)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-orange)"},{key:"yellow",label:"Yellow",cssValue:"var(--be-swatch-bg-yellow)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-yellow)"},{key:"green",label:"Green",cssValue:"var(--be-swatch-bg-green)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-green)"},{key:"blue",label:"Blue",cssValue:"var(--be-swatch-bg-blue)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-blue)"},{key:"purple",label:"Purple",cssValue:"var(--be-swatch-bg-purple)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-purple)"},{key:"pink",label:"Pink",cssValue:"var(--be-swatch-bg-pink)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-pink)"},{key:"red",label:"Red",cssValue:"var(--be-swatch-bg-red)",opacity:.18,displayCssValue:"var(--be-swatch-display-bg-red)"}],el='<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="M426.666667 939.050667a32 32 0 1 1 0-64h53.333333V160H235.093333V170.666667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667A32 32 0 0 1 171.093333 170.666667V128a32 32 0 0 1 32-32H820.693333a32 32 0 0 1 31.701334 27.648l0.298666 4.352v42.666667a32 32 0 1 1-64 0l-0.042666-10.666667H544v715.050667H597.333333a32 32 0 0 1 31.701334 27.648l0.298666 4.352a32 32 0 0 1-32 32h-170.666666z" fill="currentColor"/></svg>',ko="M544 170.922667a32 32 0 0 1 32 32v618.666666a32 32 0 1 1-64 0V544H192v277.674667a32 32 0 0 1-27.648 31.701333l-4.352 0.298667a32 32 0 0 1-32-32v-618.666667a32 32 0 0 1 64 0v276.992H512V202.922667a32 32 0 0 1 27.648-31.701334l4.352-0.298666z",tl=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} M848.512 366.933333A32 32 0 0 1 896 394.965333v426.666667a32 32 0 1 1-64 0v-372.565333l-80.554667 44.416a32 32 0 0 1-41.130666-8.96l-2.346667-3.626667a32 32 0 0 1 12.586667-43.477333l128-70.485334z" fill="currentColor"/></svg>`,nl=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} M786.133333 362.666667a152.661333 152.661333 0 0 1 107.946667 260.693333l-166.058667 165.973333h178.773334a32 32 0 0 1 31.744 27.648l0.256 4.352a32 32 0 0 1-32 32h-256a32 32 0 0 1-22.613334-54.613333l220.672-220.672A88.661333 88.661333 0 0 0 786.133333 426.666667h-7.338666a96 96 0 0 0-96 96v20.565333a32 32 0 0 1-64 0v-20.565333a160 160 0 0 1 160-160h7.338666z" fill="currentColor"/></svg>`,ol=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} m362.410667 192a32 32 0 0 1 22.613333 54.656L809.813333 536.746667l1.792 0.341333a160.085333 160.085333 0 0 1 126.506667 148.053333l0.256 8.490667a160 160 0 0 1-310.912 53.248 32 32 0 0 1 60.373333-21.333333 96 96 0 1 0 90.538667-127.914667h-42.666667a32 32 0 0 1-22.613333-54.613333l116.010667-116.053334h-178.773334a32 32 0 0 1-31.701333-27.648l-0.256-4.352a32 32 0 0 1 32-32h256z" fill="currentColor"/></svg>`,rl=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} m244.309333 193.493333a32 32 0 0 1 20.992 40.106667l-93.738666 299.776h116.48v-96a32 32 0 0 1 64 0v96h10.666666a32 32 0 0 1 31.744 27.648l0.298667 4.352a32 32 0 0 1-32 32H896v53.333333a32 32 0 1 1-64 0v-53.333333h-160a32 32 0 0 1-30.506667-41.557334l106.666667-341.333333a32 32 0 0 1 40.106667-20.992z" fill="currentColor"/></svg>`,ll=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} m363.477333 192.426666a32 32 0 1 1 0 64h-145.706666l-28.245334 113.450667 5.12-1.493333a160.042667 160.042667 0 0 1 100.949334 6.4l9.472 4.266666a160 160 0 1 1-189.610667 249.856 32 32 0 0 1 48-42.325333 96 96 0 1 0 0-126.976c-22.186667 25.130667-63.146667 3.584-55.04-28.928l53.333333-214.016a32 32 0 0 1 31.061334-24.234667h170.666666z" fill="currentColor"/></svg>`,il=`<svg viewBox="0 0 1024 1024" width="16" height="16" aria-hidden="true"><path d="${ko} m292.522667 153.173333a32 32 0 0 1 12.586666 43.52l-93.141333 168.874667a159.957333 159.957333 0 0 1 102.4 19.712 158.848 158.848 0 0 1 58.581333 217.685333 160.426667 160.426667 0 0 1-218.453333 58.24 158.890667 158.890667 0 0 1-62.762667-209.962667l157.312-285.44a32 32 0 0 1 43.52-12.586666z m-141.226667 322.517333a94.890667 94.890667 0 0 0 35.072 130.048 96.426667 96.426667 0 0 0 131.242667-34.901333 94.848 94.848 0 0 0-35.114667-130.048 96.426667 96.426667 0 0 0-131.242667 34.901333z" fill="currentColor"/></svg>`,sl='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="3" cy="4" r="1.1" fill="currentColor" stroke="none"/><circle cx="3" cy="8" r="1.1" fill="currentColor" stroke="none"/><circle cx="3" cy="12" r="1.1" fill="currentColor" stroke="none"/><line x1="6.5" y1="4" x2="13.5" y2="4"/><line x1="6.5" y1="8" x2="13.5" y2="8"/><line x1="6.5" y1="12" x2="13.5" y2="12"/></svg>',cl='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.3 3.7L3.1 2.8L3.1 5.8" stroke-width="1.1"/><line x1="6.5" y1="4" x2="13.5" y2="4" stroke-width="1.3"/><path d="M1.8 7.4C1.8 6.6 4.2 6.6 4.2 7.4C4.2 8.2 1.8 9.5 1.8 9.5L4.2 9.5" stroke-width="1.1"/><line x1="6.5" y1="8" x2="13.5" y2="8" stroke-width="1.3"/><path d="M4.2 11.2C4.2 10.5 3 10.5 1.8 11.5C1.8 12 3 12 3 12C3 12 4.2 12 4.2 13C4.2 13.5 3 13.5 1.8 12.8" stroke-width="1.1"/><line x1="6.5" y1="12" x2="13.5" y2="12" stroke-width="1.3"/></svg>',al='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="2.5" width="11" height="11" rx="2.5"/><path d="M5.5 8L7 9.8L10.8 5.8"/></svg>',dl='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2.5" y="3" width="2" height="10" rx="1" fill="currentColor" stroke="none"/><line x1="6.5" y1="5" x2="13" y2="5"/><line x1="6.5" y1="8" x2="13" y2="8"/><line x1="6.5" y1="11" x2="10" y2="11"/></svg>',ul='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 4L2 8L5 12"/><path d="M11 4L14 8L11 12"/><line x1="10" y1="3" x2="6" y2="13"/></svg>',Xd='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="2" y1="8" x2="14" y2="8"/></svg>',jd='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 3.5h10M2 8h10M2 12.5h10"/><path d="M14.5 3.5v.01M14.5 8v.01M14.5 12.5v.01"/></svg>',Qd='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="3" width="12" height="10" rx="1.5"/><circle cx="5.5" cy="6.5" r="1.1" fill="currentColor" stroke="none"/><path d="M13 11.5L10 8.5L7 11.5L5 9.5L3 11.5"/></svg>',Jd='<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M12 3a9 9 0 0 1 9 9" opacity="0.25"/><path d="M12 3a9 9 0 0 0-9 9" class="be-spinner-arc"/></g></svg>',eu='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8a5 5 0 0 1 8.5-3.5M13 3v3h-3"/><path d="M13 8a5 5 0 0 1-8.5 3.5M3 13v-3h3"/></svg>',tu='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 4L12 12"/><path d="M12 4L4 12"/></svg>',nu='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 5H12M9 2L12 5L9 8"/><path d="M14 11H4M7 8L4 11L7 14"/></svg>',ou='<svg viewBox="0 0 1024 1024" width="32" height="32" aria-hidden="true"><path d="M768.35456 416a256 256 0 1 0-512 0 192 192 0 1 0 0 384v64a256 256 0 0 1-58.88-505.216 320.128 320.128 0 0 1 629.76 0A256.128 256.128 0 0 1 768.35456 864v-64a192 192 0 0 0 0-384z m-512 384h128v64H256.35456v-64z m384 0h128v64h-128v-64z" fill="currentColor"/><path d="M539.04256 589.184v333.056a32.448 32.448 0 0 1-32 32.192 32.448 32.448 0 0 1-32-32.192V589.184l-36.096 36.096a32.192 32.192 0 0 1-45.056-0.192 31.616 31.616 0 0 1-0.192-45.056l90.88-90.88a31.36 31.36 0 0 1 22.528-9.152 30.08 30.08 0 0 1 22.4 9.088l90.88 90.944a32.192 32.192 0 0 1-0.192 45.056 31.616 31.616 0 0 1-45.056 0.192l-36.096-36.096z" fill="currentColor"/></svg>',ru=["aria-label"],lu={class:"bsm-group"},iu={class:"bsm-icon-grid"},su=["title","onMousedown","onMouseenter"],cu={key:1,class:"bsm-group"},au={class:"bsm-collapse-title"},du={class:"bsm-collapse-body"},uu={class:"bsm-row"},fu=["disabled","title","onMousedown"],mu={viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},pu={class:"bsm-row"},hu=["disabled","title"],gu=["disabled","title"],bu={key:2,class:"bsm-group"},ku={class:"bsm-collapse-title"},yu={class:"bsm-collapse-body"},wu={class:"bsm-row"},Eu=["disabled","title"],vu=["disabled","title"],Cu={key:3,class:"bsm-group bsm-colors"},Tu={class:"bsm-collapse-title"},_u={class:"bsm-collapse-body"},xu={class:"bsm-swatches"},Mu=["title","disabled","onMousedown"],Nu={key:4,class:"bsm-group bsm-colors"},Su={class:"bsm-collapse-title"},Au={class:"bsm-collapse-body"},Iu={class:"bsm-swatches"},Bu=["title","disabled","onMousedown"],Ru={class:"bsm-group"},Lu=["onMousedown","onMouseenter"],Ou={class:"bsm-title"},Du={key:1,class:"bsm-shortcut"},$u=["aria-label"],fl=260,Pu=80,Qi=24,Hu='<svg viewBox="0 0 16 16" width="14" height="14"><rect x="5" y="5" width="8" height="8" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.2"/><path d="M3 10.5V3.5C3 2.67 3.67 2 4.5 2H10" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/></svg>',Vu='<svg viewBox="0 0 16 16" width="14" height="14"><rect x="5" y="5" width="8" height="8" rx="1.5" fill="none" stroke="currentColor" stroke-width="1.2"/><path d="M3 10.5V3.5C3 2.67 3.67 2 4.5 2H10" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/></svg>',Uu='<svg viewBox="0 0 16 16" width="14" height="14"><circle cx="4.5" cy="11.5" r="1.8" fill="none" stroke="currentColor" stroke-width="1.2"/><circle cx="11.5" cy="11.5" r="1.8" fill="none" stroke="currentColor" stroke-width="1.2"/><line x1="6" y1="10" x2="13" y2="3" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/><line x1="10" y1="10" x2="3" y2="3" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/></svg>',zu='<svg viewBox="0 0 16 16" width="14" height="14"><path d="M8 12V4M4 8L8 4L12 8" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg>',Fu='<svg viewBox="0 0 16 16" width="14" height="14"><path d="M8 4V12M4 8L8 12L12 8" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg>',Ku='<svg viewBox="0 0 16 16" width="14" height="14"><path d="M3.5 4.5H12.5M6.5 4.5V3C6.5 2.45 6.95 2 7.5 2H8.5C9.05 2 9.5 2.45 9.5 3V4.5M5 4.5L5.5 13C5.55 13.55 6 14 6.55 14H9.45C10 14 10.45 13.55 10.5 13L11 4.5" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/></svg>',Wu='<svg viewBox="0 0 1024 1024" width="14" height="14" aria-hidden="true"><path d="M597.333333 451.669333l55.168-55.168a42.666667 42.666667 0 0 1 60.330667 60.330667L657.664 512l55.168 55.168a42.666667 42.666667 0 0 1-60.330667 60.330667L597.333333 572.330667l-55.168 55.168a42.666667 42.666667 0 0 1-60.330666-60.330667L537.002667 512l-55.168-55.168a42.666667 42.666667 0 0 1 60.330666-60.330667L597.333333 451.669333zM874.581333 832H376.32c-47.402667 0-106.730667-25.941333-138.752-60.672l-163.178667-176.938667c-42.325333-45.866667-42.346667-118.869333 0-164.778666l163.2-176.938667C269.525333 218.026667 329.045333 192 376.32 192h498.24A106.666667 106.666667 0 0 1 981.333333 298.837333v426.325334A106.752 106.752 0 0 1 874.581333 832z m0-85.333333C886.4 746.666667 896 737.088 896 725.162667V298.837333c0-11.946667-9.514667-21.504-21.418667-21.504H376.32c-23.466667 0-60.224 16.064-76.010667 33.194667l-163.2 176.917333c-12.181333 13.226667-12.16 35.882667 0 49.109334l163.2 176.917333C316.16 730.666667 352.746667 746.666667 376.32 746.666667h498.24z" fill="currentColor"/></svg>',Ji='<svg viewBox="0 0 1024 1024" width="14" height="14" aria-hidden="true"><path d="M672.01024 896l-320 0c-17.67424 0-32.01024-14.336-32.01024-32.01024l0-352.01024-128 0c-12.94336 0-24.61696-7.80288-29.57312-19.7632s-2.21184-25.72288 6.94272-34.87744l320-320c12.4928-12.4928 32.768-12.4928 45.2608 0l320 320c9.15456 9.15456 11.89888 22.91712 6.94272 34.87744s-16.62976 19.7632-29.57312 19.7632l-128 0 0 352.01024c0 17.67424-14.336 32.01024-32.01024 32.01024zM384 832l256 0 0-352.01024c0-17.67424 14.336-32.01024 32.01024-32.01024l82.7392 0-242.74944-242.74944-242.74944 242.74944 82.7392 0c17.67424 0 32.01024 14.336 32.01024 32.01024l0 352.01024z" fill="currentColor"/></svg>',Gu='<svg viewBox="0 0 1024 1024" width="14" height="14" aria-hidden="true"><path d="M512.00988746 141.21142578c10.45623779 0 19.24145531 3.50024414 26.37542748 10.71331811l259.5421145 259.55200196C805.03668189 418.58105492 808.63085938 427.33660865 808.63085938 437.84228516c0 10.60949731-3.53485132 19.46887183-10.56994606 26.46936011-7.02026391 7.00543237-15.88952661 10.60949731-26.50891137 10.60949731-10.44140625 0-19.22167969-3.60900903-26.35565185-10.71331811L549.09863305 267.79370094V845.7097168c0 10.19915748-3.62384057 18.94976782-10.89624071 26.16284179-7.23284888 7.31195068-15.97357177 10.91601563-26.2122798 10.91601563-10.23376465 0-18.959656-3.60900903-26.22216796-10.91601563-7.24273705-7.21307397-10.87646508-15.96862769-10.87646508-26.16284179V267.79370094l-196.10760522 196.41906761C271.65484619 471.31213355 262.87951684 474.92114258 252.41833496 474.92114258c-10.61938477 0-19.45898438-3.60900903-26.4990232-10.60949731C218.86444068 457.31115699 215.36914062 448.45178247 215.36914062 437.84228516c0-10.50567651 3.55462623-19.26123023 10.69354248-26.36553931l259.53717042-259.55200196C492.7288816 144.71166992 501.52398658 141.21142578 511.97033691 141.21142578h0.03955055z" fill="currentColor"/></svg>',qu='<svg viewBox="0 0 1024 1024" width="14" height="14" aria-hidden="true"><path d="M511.99011254 141.21142578c10.23376465 0 18.95471191 3.60900903 26.2122798 10.81713891 7.25262451 7.20812988 10.86657691 15.96862769 10.86657763 26.2666626v577.89129615l196.1619873-196.43884254c7.099365-7.00543237 15.90435815-10.61444068 26.34082031-10.61444139 10.61938477 0 19.43426538 3.50518822 26.51385474 10.51062059 7.04498291 7.10430908 10.54522705 15.96862769 10.54522706 26.57318092 0 10.40679908-3.54473877 19.16235352-10.69354248 26.37542748l-259.55694604 259.48278761C531.23156714 879.28833008 522.44635033 882.78857422 512.00988746 882.78857422c-10.45623779 0-19.24145531-3.50024414-26.3704834-10.71331811l-259.55200195-259.48278761C218.94848656 605.37939453 215.36914062 596.62384009 215.36914062 586.21704102c0-10.60949731 3.52496314-19.46887183 10.56994606-26.57318092C232.99395776 552.63842773 241.82861328 549.12829614 252.44799805 549.12829614c10.42163062 0 19.2167356 3.60900903 26.36553931 10.61444068l196.1125493 196.43884253V178.29522729c0-10.30297828 3.60900903-19.05853271 10.88635255-26.2666626C493.05517555 144.81549073 501.80084252 141.21142578 512.02966309 141.21142578h-0.03955055z" fill="currentColor"/></svg>',Yu='<svg viewBox="0 0 100 100" width="14" height="14" aria-hidden="true"><path fill="currentColor" d="M 75,28.5 L 71,32 C 67,26.8 61.5,22.5 53.5,22.5 C 38,22.5 24.5,34.5 24.5,50 C 24.5,65.5 38,77.5 53.5,77.5 C 61.5,77.5 67,73.2 71,68 L 75,71.5 C 70,77.8 62.5,83 53.5,83 C 34.5,83 19,68.5 19,50 C 19,31.5 34.5,17 53.5,17 C 62.5,17 70,22.2 75,28.5 Z"/></svg>',Zu='<svg viewBox="0 0 100 100" width="14" height="14" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M 22,17 H 49 C 68,17 79,30.5 79,50 C 79,69.5 68,83 49,83 H 22 Z M 27.5,22.5 H 48.5 C 64.5,22.5 73.5,33.5 73.5,50 C 73.5,66.5 64.5,77.5 48.5,77.5 H 27.5 Z"/></svg>',Xu='<svg viewBox="0 0 100 100" width="14" height="14" aria-hidden="true"><path fill="currentColor" d="M 20,17 L 26.5,17 L 50,46.2 L 73.5,17 L 80,17 L 53.8,50 L 80,83 L 73.5,83 L 50,53.8 L 26.5,83 L 20,83 L 46.2,50 Z"/></svg>',ju='<svg viewBox="0 0 1024 1024" width="14" height="14" aria-hidden="true"><path d="M768 597.333333h-85.333333V426.666667h85.333333c94.250667 0 170.666667-76.416 170.666667-170.666667S862.250667 85.333333 768 85.333333c-94.261333 0-170.666667 76.416-170.666667 170.666667v85.333333H426.666667v-85.333333c0-94.250667-76.416-170.666667-170.666667-170.666667S85.333333 161.749333 85.333333 256s76.416 170.666667 170.666667 170.666667h85.333333v170.666666h-85.333333c-94.250667 0-170.666667 76.416-170.666667 170.666667s76.416 170.666667 170.666667 170.666667c94.261333 0 170.666667-76.416 170.666667-170.666667v-85.333333h170.666666v85.12l-0.010666 0.213333c0 94.250667 76.416 170.666667 170.666666 170.666667s170.666667-76.416 170.666667-170.666667S862.250667 597.354667 768 597.333333z m0-426.666666a85.333333 85.333333 0 0 1 0 170.666666h-85.333333v-85.333333a85.333333 85.333333 0 0 1 85.333333-85.333333z m-597.333333 85.333333a85.333333 85.333333 0 0 1 170.666666 0v85.333333h-85.333333c-47.125333 0-85.333333-38.218667-85.333333-85.333333z m85.333333 597.333333a85.333333 85.333333 0 0 1 0-170.666666h85.333333v85.333333a85.333333 85.333333 0 0 1-85.333333 85.333333z m170.666667-256V426.666667h170.666666v170.666666H426.666667z m341.333333 256a85.333333 85.333333 0 0 1-85.333333-85.333333v-85.333333h85.322666A85.333333 85.333333 0 0 1 768 853.333333z" fill="currentColor"/></svg>',Qu='<svg viewBox="0 0 100 100" width="14" height="14" aria-hidden="true"><rect x="8" y="8" width="84" height="84" rx="16" fill="none" stroke="currentColor" stroke-width="4.8" stroke-linecap="round" stroke-linejoin="round"/><path fill="currentColor" d="M 43.5,32 C 40.3,30.3 36.3,29.5 31.5,29.5 C 20.5,29.5 14,38.2 14,50 C 14,61.8 20.5,70.5 31.5,70.5 C 36.3,70.5 40.3,69.7 43.5,68 L 43.5,60.5 C 40.5,62.8 36.5,64 32,64 C 23.7,64 20,58 20,50 C 20,42 23.7,36 32,36 C 36.5,36 40.5,37.2 43.5,39.5 Z M 50,32 H 56 V 41.5 H 59.5 V 47.5 H 56 V 62 C 56,64.2 57,65 59,65 H 60 V 70.5 C 58.5,70.8 56.7,71 54.5,71 C 50,71 48,68.5 48,63 V 47.5 H 44.5 V 41.5 H 48 V 32 Z M 62.5,41.5 H 68 V 47 C 70,43.2 73,41.5 76.5,41.5 V 47.5 C 74,47.5 71,49 68.5,52.5 V 70.5 H 62.5 V 41.5 Z M 79.5,32 H 85.5 V 70.5 H 79.5 Z"/></svg>',Ju=t.defineComponent({__name:"BlockSettingsMenu",props:{visible:{type:Boolean},anchorEl:{},blockId:{},rootEl:{}},emits:["close"],setup(e,{expose:n,emit:o}){const r=e,l=o,{t:s}=en(),i=fn(),c=t.inject(Do,t.ref(!1)),a=t.ref(null),d=t.ref(null),f=t.ref("paragraph"),u=t.ref({top:0,left:0,availableHeight:520,above:!1,bottom:0,topBaseline:0}),h=t.ref(!1),p=t.ref(!1),m=t.ref(!1),k=t.reactive({alignIndent:!1,indent:!1,textColor:!1,bgColor:!1}),x=t.ref(!1);let D=null;t.watch(()=>r.visible,P=>{P?(D&&(clearTimeout(D),D=null),x.value=!0):D=setTimeout(()=>{x.value=!1,D=null},300)},{immediate:!0});const U=t.shallowRef(i.getState());let F=null;const ee=t.computed(()=>r.blockId!=null?U.value.doc.blocks.get(r.blockId):void 0),$=t.ref(void 0),V=t.computed(()=>{var w;const P=(w=ee.value)==null?void 0:w.attrs.align;return typeof P=="string"?P:"left"}),re=t.computed(()=>{const P=$.value;return P?!("align"in i.registries.schema.get(P).attrs):!0}),G=t.computed(()=>$.value==="image"||$.value==="table"),ne=t.computed(()=>$.value==="divider"||$.value==="tableOfContents"),Z=t.computed(()=>$.value==="divider"||$.value==="table"||$.value==="tableOfContents"),S=t.computed(()=>{const P=$.value;if(!P)return!0;const w=i.registries.schema.get(P);return!("color"in w.attrs)||!("bgColor"in w.attrs)}),K=t.computed(()=>{const P=ee.value;return P?Dn(U.value.doc,P.id):0});function _(P){return["paragraph","heading","orderedList","bulletList","todoList"].includes(P)}const O=t.computed(()=>!!$.value),M=t.computed(()=>{const P=ee.value;if(!P)return!0;const w=U.value.doc,z=Ar(w,P.id);return!z||!_(z.type)||Dn(w,z.id)>=10}),E=t.computed(()=>K.value<=0),N=t.computed(()=>{var w;const P=(w=ee.value)==null?void 0:w.attrs.color;return typeof P=="string"?P:"default"}),A=t.computed(()=>{var w;const P=(w=ee.value)==null?void 0:w.attrs.bgColor;return typeof P=="string"?P:"default"}),W=t.computed(()=>[{id:"paragraph",iconHtml:el,title:s("turnInto.paragraph"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"paragraph"}))}},{id:"h1",iconHtml:tl,title:s("turnInto.h1"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"heading",attrs:{level:1}}))}},{id:"h2",iconHtml:nl,title:s("turnInto.h2"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"heading",attrs:{level:2}}))}},{id:"h3",iconHtml:ol,title:s("turnInto.h3"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"heading",attrs:{level:3}}))}},{id:"h4",iconHtml:rl,title:s("turnInto.h4"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"heading",attrs:{level:4}}))}},{id:"h5",iconHtml:ll,title:s("turnInto.h5"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"heading",attrs:{level:5}}))}},{id:"h6",iconHtml:il,title:s("turnInto.h6"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"heading",attrs:{level:6}}))}},{id:"bullet",iconHtml:sl,title:s("turnInto.bullet"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"bulletList"}))}},{id:"ordered",iconHtml:cl,title:s("turnInto.ordered"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"orderedList"}))}},{id:"todo",iconHtml:al,title:s("turnInto.todo"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"todoList",attrs:{checked:!1}}))}},{id:"quote",iconHtml:dl,title:s("turnInto.quote"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"quote"}))}},{id:"code",iconHtml:ul,title:s("turnInto.code"),kind:"turnInto",run:()=>{var P,w;return void((w=(P=i.commands).convertBlock)==null?void 0:w.call(P,{id:r.blockId,type:"codeBlock",attrs:{language:"plain"}}))}}]);function me(P){const w=ee.value;if(!w)return!1;switch(P){case"paragraph":return w.type==="paragraph";case"h1":return w.type==="heading"&&Number(w.attrs.level)===1;case"h2":return w.type==="heading"&&Number(w.attrs.level)===2;case"h3":return w.type==="heading"&&Number(w.attrs.level)===3;case"h4":return w.type==="heading"&&Number(w.attrs.level)===4;case"h5":return w.type==="heading"&&Number(w.attrs.level)===5;case"h6":return w.type==="heading"&&Number(w.attrs.level)===6;case"bullet":return w.type==="bulletList";case"ordered":return w.type==="orderedList";case"todo":return w.type==="todoList";case"quote":return w.type==="quote";case"code":return w.type==="codeBlock";default:return!1}}function le(P){return me(P)}t.watch(()=>r.visible,P=>{var z;if(!P)return;$.value=r.blockId!=null?(z=U.value.doc.blocks.get(r.blockId))==null?void 0:z.type:void 0;const w=W.value.find(we=>me(we.id));f.value=w?w.id:"paragraph",k.alignIndent=!1,k.indent=!1,k.textColor=!1,k.bgColor=!1},{immediate:!0});const he=t.computed(()=>{const P=[{id:"align-left",value:"left",title:s("align.left"),run:()=>ae("left")},{id:"align-center",value:"center",title:s("align.center"),run:()=>ae("center")},{id:"align-right",value:"right",title:s("align.right"),run:()=>ae("right")}];return G.value||P.push({id:"align-justify",value:"justify",title:s("align.justify"),run:()=>ae("justify")}),P});function ae(P){var w,z;(z=(w=i.commands).setBlockAlign)==null||z.call(w,{id:r.blockId,align:P})}function ie(){var P,w;(w=(P=i.commands).indentBlock)==null||w.call(P,{id:r.blockId})}function Se(){var P,w;(w=(P=i.commands).outdentBlock)==null||w.call(P,{id:r.blockId})}const Te=Xi,We=ji;function Mt(P){var w,z;(z=(w=i.commands).setBlockColor)==null||z.call(w,{id:r.blockId,color:P})}function Zt(P){var w,z;(z=(w=i.commands).setBlockBgColor)==null||z.call(w,{id:r.blockId,bgColor:P})}async function Gt(){var nt,lt;const P=ee.value;if(!P)return;const w=Ae(P.content),we=`<meta charset="utf-8"><!-- blockeditor:${JSON.stringify({id:P.id,type:P.type,attrs:P.attrs,text:w}).replace(/--/g,"\\-\\-")} -->${Rt(w)}`;let ve=!1;try{if((nt=navigator.clipboard)!=null&&nt.write&&typeof ClipboardItem<"u"){const on=new ClipboardItem({"text/plain":new Blob([w],{type:"text/plain"}),"text/html":new Blob([we],{type:"text/html"})});await navigator.clipboard.write([on]),ve=!0}}catch{ve=!1}if(!ve)try{(lt=navigator.clipboard)!=null&<.writeText&&(await navigator.clipboard.writeText(w),ve=!0)}catch{ve=!1}ve||(ve=tt(w))}function Rt(P){return P.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function tt(P){const w=document.createElement("textarea");w.value=P,w.setAttribute("readonly",""),w.style.position="fixed",w.style.top="-9999px",w.style.left="-9999px",w.style.opacity="0",document.body.appendChild(w);const z=document.activeElement;w.focus(),w.select();try{return document.execCommand("copy")}catch{return!1}finally{if(document.body.removeChild(w),z&&typeof z.focus=="function")try{z.focus()}catch{}}}function yt(){Gt().then(()=>{var P,w;return(w=(P=i.commands).removeBlock)==null?void 0:w.call(P,{id:r.blockId})})}const vt=/Mac|iP(hone|[ao]d)/.test(navigator.platform)?ju:Qu;function Ze(...P){return P.join("")}const Ve=t.computed(()=>[{id:"dup",iconHtml:Hu,title:s("action.duplicate"),shortcutHtml:Ze(vt,Zu),run:()=>{var P,w;return void((w=(P=i.commands).duplicateBlock)==null?void 0:w.call(P,{id:r.blockId}))}},{id:"copy",iconHtml:Vu,title:s("action.copy"),shortcutHtml:Ze(vt,Yu),run:()=>void Gt()},{id:"cut",iconHtml:Uu,title:s("action.cut"),shortcutHtml:Ze(vt,Xu),run:()=>void yt()},{id:"up",iconHtml:zu,title:s("action.moveUp"),shortcutHtml:Ze(vt,Ji,Gu),run:()=>{var P,w;return void((w=(P=i.commands).moveBlockUp)==null?void 0:w.call(P,{id:r.blockId}))}},{id:"down",iconHtml:Fu,title:s("action.moveDown"),shortcutHtml:Ze(vt,Ji,qu),run:()=>{var P,w;return void((w=(P=i.commands).moveBlockDown)==null?void 0:w.call(P,{id:r.blockId}))}},{id:"del",iconHtml:Ku,title:s("action.delete"),shortcutHtml:Wu,danger:!0,run:()=>{var P,w;return void((w=(P=i.commands).removeBlock)==null?void 0:w.call(P,{id:r.blockId}))}}]);t.watch(()=>r.visible,P=>{P&&(h.value=!1,u.value={top:0,left:0,availableHeight:520,above:!1,bottom:0,topBaseline:0})});function Ct(){const P=r.anchorEl,w=r.rootEl,z=a.value;!r.visible||!P||!w||!z||t.nextTick().then(()=>{const we=a.value;if(!we)return;const ve=we.getBoundingClientRect(),nt=!!P.closest(".fixed-toolbar"),lt=nt?c.value?"up":"down":"auto",on=nt?10:0,cn=Wi(w,P,{width:Math.max(ve.width,fl),height:ve.height},8,lt,on,on);u.value=cn,h.value=!0,t.nextTick(Tt)})}t.watch([()=>r.visible,()=>r.anchorEl,a,p,m],Ct,{flush:"post"});function fe(P){k[P]=!k[P],t.nextTick(Ct)}function Tt(){const P=d.value;P&&(p.value=P.scrollTop>1,m.value=P.scrollTop+P.clientHeight<P.scrollHeight-1)}function Xe(){const P=d.value;P&&(P.scrollTop-=P.clientHeight*.8)}function Re(){const P=d.value;P&&(P.scrollTop+=P.clientHeight*.8)}dr(d,Tt);const qt=t.computed(()=>{if(!r.rootEl)return{display:"none"};if(!h.value)return{visibility:"hidden",top:"0px",left:"0px",width:`${fl}px`,"--scroll-max-height":"100vh"};const P=u.value.above,w=u.value.left,z=(p.value?Qi:0)+(m.value?Qi:0),we=u.value.availableHeight-z,ve={left:`${w}px`,width:`${fl}px`,maxHeight:`${u.value.availableHeight}px`,"--scroll-max-height":`${Math.max(Pu,we)}px`};if(P){const nt=document.documentElement.clientHeight;ve.bottom=`${Math.max(0,nt-u.value.bottom)}px`,ve.top="auto"}else ve.top=`${u.value.top}px`,ve.bottom="auto";return ve});function rt(P){if(P.kind==="turnInto"&&le(P.id)){const w=W.value.find(z=>z.id==="paragraph");if(w){f.value="paragraph",w.run(),l("close");return}}f.value=P.id,P.run(),l("close")}function Et(P){const w=[...W.value,...Ve.value];if(w.length===0)return!1;const z=w.findIndex(ve=>ve.id===f.value),we=ve=>(ve%w.length+w.length)%w.length;switch(P.key){case"ArrowDown":return P.preventDefault(),f.value=w[we(z+1)].id,!0;case"ArrowUp":return P.preventDefault(),f.value=w[we(z-1)].id,!0;case"Enter":return P.preventDefault(),rt(w[we(z)]),!0;case"Escape":return P.preventDefault(),l("close"),!0;default:return!1}}return n({onKeyDown:Et}),Yi(a,()=>r.visible,()=>l("close"),()=>r.anchorEl),t.onMounted(()=>{F=i.subscribe(P=>{U.value=P.state})}),t.onBeforeUnmount(()=>{F==null||F(),F=null}),(P,w)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[x.value&&e.rootEl?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"menuEl",ref:a,class:t.normalizeClass(["block-settings-menu",{"menu-closing":!e.visible}]),style:t.normalizeStyle(qt.value),role:"menu"},[p.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(s)("ui.scrollUp"),onMousedown:t.withModifiers(Xe,["prevent"])},[...w[8]||(w[8]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,ru)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:d,class:"bsm-scroll",onScroll:Tt},[!G.value&&!ne.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",lu,[t.createElementVNode("div",iu,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(W.value,z=>(t.openBlock(),t.createElementBlock("button",{key:z.id,class:t.normalizeClass(["bsm-icon-cell",{active:le(z.id)}]),title:z.title,role:"menuitem",onMousedown:t.withModifiers(we=>rt(z),["prevent"]),onMouseenter:we=>f.value=z.id},[t.createVNode(pn,{class:"bsm-icon-svg",html:z.iconHtml},null,8,["html"])],42,su))),128))])]),w[9]||(w[9]=t.createElementVNode("div",{class:"bsm-sep"},null,-1))],64)):t.createCommentVNode("",!0),Z.value?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",cu,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-collapse-header",{"bsm-disabled":re.value&&!O.value,expanded:k.alignIndent}]),role:"menuitem",onMousedown:w[0]||(w[0]=t.withModifiers(z=>fe("alignIndent"),["prevent"]))},[t.createElementVNode("span",au,t.toDisplayString(t.unref(s)("bsm.section.alignIndent")),1),w[10]||(w[10]=t.createElementVNode("svg",{class:"bsm-collapse-chevron",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],34),t.withDirectives(t.createElementVNode("div",du,[t.createElementVNode("div",uu,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(he.value,z=>(t.openBlock(),t.createElementBlock("button",{key:z.id,class:t.normalizeClass(["bsm-icon-btn",{active:!re.value&&V.value===z.value,"bsm-disabled":re.value}]),disabled:re.value,title:z.title,role:"menuitem",onMousedown:t.withModifiers(we=>!re.value&&rt(z),["prevent"])},[(t.openBlock(),t.createElementBlock("svg",mu,[z.value==="left"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[w[11]||(w[11]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),w[12]||(w[12]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"10",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),w[13]||(w[13]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"12",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):z.value==="center"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[w[14]||(w[14]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),w[15]||(w[15]=t.createElementVNode("line",{x1:"4",y1:"8",x2:"12",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),w[16]||(w[16]=t.createElementVNode("line",{x1:"3",y1:"12",x2:"13",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):z.value==="right"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[w[17]||(w[17]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),w[18]||(w[18]=t.createElementVNode("line",{x1:"6",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),w[19]||(w[19]=t.createElementVNode("line",{x1:"4",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:3},[w[20]||(w[20]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),w[21]||(w[21]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),w[22]||(w[22]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64))]))],42,fu))),128))]),t.createElementVNode("div",pu,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-icon-btn",{"bsm-disabled":E.value}]),disabled:E.value,title:t.unref(s)("bsm.indent.decrease"),role:"menuitem",onMousedown:w[1]||(w[1]=t.withModifiers(z=>!E.value&&rt({id:"outdent",run:Se}),["prevent"]))},[...w[23]||(w[23]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M906.666667 379.733333h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM906.666667 580.266667h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM117.333333 245.333333h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-789.333334C100.266667 181.333333 85.333333 196.266667 85.333333 213.333333s14.933333 32 32 32zM906.666667 778.666667h-789.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM285.866667 657.066667c14.933333 8.533333 34.133333 0 34.133333-17.066667V384c0-17.066667-19.2-27.733333-34.133333-17.066667l-192 128c-12.8 8.533333-12.8 27.733333 0 36.266667l192 125.866667z",fill:"currentColor"})],-1)])],42,hu),t.createElementVNode("button",{class:t.normalizeClass(["bsm-icon-btn",{"bsm-disabled":M.value}]),disabled:M.value,title:t.unref(s)("bsm.indent.increase"),role:"menuitem",onMousedown:w[2]||(w[2]=t.withModifiers(z=>!M.value&&rt({id:"indent",run:ie}),["prevent"]))},[...w[24]||(w[24]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M906.666667 379.733333h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM906.666667 580.266667h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM117.333333 245.333333h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-789.333334C100.266667 181.333333 85.333333 196.266667 85.333333 213.333333s14.933333 32 32 32zM906.666667 778.666667h-789.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM119.466667 657.066667A21.333333 21.333333 0 0 1 85.333333 640V384c0-17.066667 19.2-27.733333 34.133334-17.066667l192 128c12.8 8.533333 12.8 27.733333 0 36.266667l-192 125.866667z",fill:"currentColor"})],-1)])],42,gu)])],512),[[t.vShow,k.alignIndent]])])),Z.value?(t.openBlock(),t.createElementBlock("div",bu,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-collapse-header",{"bsm-disabled":!O.value,expanded:k.indent}]),role:"menuitem",onMousedown:w[3]||(w[3]=t.withModifiers(z=>fe("indent"),["prevent"]))},[t.createElementVNode("span",ku,t.toDisplayString(t.unref(s)("bsm.section.indent")),1),w[25]||(w[25]=t.createElementVNode("svg",{class:"bsm-collapse-chevron",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],34),t.withDirectives(t.createElementVNode("div",yu,[t.createElementVNode("div",wu,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-icon-btn",{"bsm-disabled":E.value}]),disabled:E.value,title:t.unref(s)("bsm.indent.decrease"),role:"menuitem",onMousedown:w[4]||(w[4]=t.withModifiers(z=>!E.value&&rt({id:"outdent",run:Se}),["prevent"]))},[...w[26]||(w[26]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M906.666667 379.733333h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM906.666667 580.266667h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM117.333333 245.333333h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-789.333334C100.266667 181.333333 85.333333 196.266667 85.333333 213.333333s14.933333 32 32 32zM906.666667 778.666667h-789.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM285.866667 657.066667c14.933333 8.533333 34.133333 0 34.133333-17.066667V384c0-17.066667-19.2-27.733333-34.133333-17.066667l-192 128c-12.8 8.533333-12.8 27.733333 0 36.266667l192 125.866667z",fill:"currentColor"})],-1)])],42,Eu),t.createElementVNode("button",{class:t.normalizeClass(["bsm-icon-btn",{"bsm-disabled":M.value}]),disabled:M.value,title:t.unref(s)("bsm.indent.increase"),role:"menuitem",onMousedown:w[5]||(w[5]=t.withModifiers(z=>!M.value&&rt({id:"indent",run:ie}),["prevent"]))},[...w[27]||(w[27]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M906.666667 379.733333h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM906.666667 580.266667h-448c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h448c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM117.333333 245.333333h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32h-789.333334C100.266667 181.333333 85.333333 196.266667 85.333333 213.333333s14.933333 32 32 32zM906.666667 778.666667h-789.333334c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h789.333334c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32zM119.466667 657.066667A21.333333 21.333333 0 0 1 85.333333 640V384c0-17.066667 19.2-27.733333 34.133334-17.066667l192 128c12.8 8.533333 12.8 27.733333 0 36.266667l-192 125.866667z",fill:"currentColor"})],-1)])],42,vu)])],512),[[t.vShow,k.indent]])])):t.createCommentVNode("",!0),!G.value&&!ne.value?(t.openBlock(),t.createElementBlock("div",Cu,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-collapse-header",{"bsm-disabled":S.value,expanded:k.textColor}]),role:"menuitem",onMousedown:w[6]||(w[6]=t.withModifiers(z=>!S.value&&fe("textColor"),["prevent"]))},[t.createElementVNode("span",Tu,t.toDisplayString(t.unref(s)("bsm.section.textColor")),1),w[28]||(w[28]=t.createElementVNode("svg",{class:"bsm-collapse-chevron",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],34),t.withDirectives(t.createElementVNode("div",_u,[t.createElementVNode("div",xu,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(Te),z=>(t.openBlock(),t.createElementBlock("button",{key:"tc-"+z.key,class:t.normalizeClass(["bsm-swatch",{active:N.value===z.key,"bsm-disabled":S.value}]),title:t.unref(s)(z.key==="default"?"color.default":"color."+z.key),style:t.normalizeStyle({backgroundColor:z.displayCssValue??z.cssValue}),disabled:S.value,onMousedown:t.withModifiers(we=>!S.value&&rt({id:`tc-${z.key}`,run:()=>Mt(z.key)}),["prevent"])},null,46,Mu))),128))])],512),[[t.vShow,k.textColor]])])):t.createCommentVNode("",!0),!G.value&&!ne.value?(t.openBlock(),t.createElementBlock("div",Nu,[t.createElementVNode("button",{class:t.normalizeClass(["bsm-collapse-header",{"bsm-disabled":S.value,expanded:k.bgColor}]),role:"menuitem",onMousedown:w[7]||(w[7]=t.withModifiers(z=>!S.value&&fe("bgColor"),["prevent"]))},[t.createElementVNode("span",Su,t.toDisplayString(t.unref(s)("bsm.section.bgColor")),1),w[29]||(w[29]=t.createElementVNode("svg",{class:"bsm-collapse-chevron",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],34),t.withDirectives(t.createElementVNode("div",Au,[t.createElementVNode("div",Iu,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(We),z=>(t.openBlock(),t.createElementBlock("button",{key:"bc-"+z.key,class:t.normalizeClass(["bsm-swatch",[{active:A.value===z.key,"bsm-disabled":S.value},z.key==="default"?"bsm-swatch--none":""]]),title:t.unref(s)(z.key==="default"?"color.none":"color."+z.key),style:t.normalizeStyle({backgroundColor:z.displayCssValue??z.cssValue}),disabled:S.value,onMousedown:t.withModifiers(we=>!S.value&&rt({id:`bc-${z.key}`,run:()=>Zt(z.key)}),["prevent"])},null,46,Bu))),128))])],512),[[t.vShow,k.bgColor]])])):t.createCommentVNode("",!0),w[30]||(w[30]=t.createElementVNode("div",{class:"bsm-sep"},null,-1)),t.createElementVNode("div",Ru,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(Ve.value,z=>(t.openBlock(),t.createElementBlock("button",{key:z.id,class:t.normalizeClass(["bsm-item bsm-action",{danger:z.danger}]),role:"menuitem",onMousedown:t.withModifiers(we=>rt(z),["prevent"]),onMouseenter:we=>f.value=z.id},[t.createVNode(pn,{class:"bsm-action-icon",html:z.iconHtml},null,8,["html"]),t.createElementVNode("span",Ou,t.toDisplayString(z.title),1),z.shortcutHtml?(t.openBlock(),t.createBlock(pn,{key:0,class:"bsm-shortcut",html:z.shortcutHtml},null,8,["html"])):z.shortcut?(t.openBlock(),t.createElementBlock("span",Du,t.toDisplayString(z.shortcut),1)):t.createCommentVNode("",!0)],42,Lu))),128))])],544),m.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(s)("ui.scrollDown"),onMousedown:t.withModifiers(Re,["prevent"])},[...w[31]||(w[31]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,$u)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)]))}}),ef=["aria-hidden"],tf=["aria-label"],nf=["title","aria-label"],of={class:"ht-dropdown-wrap"},rf=["title","disabled"],lf={class:"ht-type-label"},sf=["aria-label"],cf=["onMousedown"],af={key:0,class:"ht-check",viewBox:"0 0 12 12",width:"14",height:"14","aria-hidden":"true"},df=["aria-label"],uf={class:"ht-dropdown-wrap"},ff=["title","disabled"],mf={viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},pf=["aria-label"],hf=["onMousedown"],gf={viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},bf={key:0,class:"ht-check",viewBox:"0 0 12 12",width:"14",height:"14","aria-hidden":"true"},kf=["aria-label"],yf={key:0,class:"ht-dropdown-wrap"},wf=["title","disabled"],Ef={viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},vf=["aria-label"],Cf=["onMousedown"],Tf={viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},_f={key:0,class:"ht-check",viewBox:"0 0 12 12",width:"14",height:"14","aria-hidden":"true"},xf=["aria-label"],Mf=["title","disabled","onMousedown","onTouchstart"],Nf=["title","disabled"],Sf={class:"ht-dropdown-wrap"},Af=["title","disabled"],If=["aria-label"],Bf={class:"ht-color-section"},Rf={class:"ht-color-label"},Lf={class:"ht-swatches"},Of=["title","onMousedown"],Df={class:"ht-color-section"},$f={class:"ht-color-label"},Pf={class:"ht-swatches"},Hf=["title","onMousedown"],Vf=["aria-label"],Uf=["title","aria-label","disabled"],zf={key:0,class:"ht-sep"},Ff=["title"],Kf=["title"],Wf=["title"],Gf={key:0,class:"ht-sep"},qf=["title"],Yf=["title","aria-label"],Zf=80,Xf=24,ml=36,jf=360,es=10,ts=200,Qf=t.defineComponent({__name:"HoverToolbar",props:{visible:{type:Boolean},selectionRect:{},blockId:{},blockType:{},blockAttrs:{},rootEl:{},tableMode:{type:Boolean},showDelete:{type:Boolean},deleteLabel:{},deleteIcon:{},showMerge:{type:Boolean},showSplit:{type:Boolean},showHeaderRow:{type:Boolean},headerRowActive:{type:Boolean},cellEditMode:{type:Boolean},tableActiveMarks:{},tableActiveColor:{},tableActiveBgColor:{},tableActiveVerticalAlign:{},mobile:{type:Boolean}},emits:["close","interacting","linkClick","delete","merge","split","tableHeaderRow","tableType","tableAlign","tableVerticalAlign","tableMark","tableTextColor","tableBgColor","tableCopy"],setup(e,{expose:n,emit:o}){const r=e,l=o;function s(){l("interacting")}const{t:i}=en(),c=fn(),a=t.inject(Do,t.ref(!1)),d=t.ref(null),f=t.ref(null),u=t.ref(null),h=t.ref(null),p=t.ref(null),m=t.ref(null),k=t.ref(null),x=t.ref(null),D=t.ref(null),U=t.ref({top:0,left:0,above:!1}),F=t.ref(null),ee=t.ref(!1),$=t.ref(null),V=t.ref(null),re=t.ref(!1),G=t.ref(!1),ne=t.ref(null),Z=t.ref(!1),S=t.ref(!1),K=t.ref(!1),_=t.computed(()=>({maxHeight:$.value!==null?`${$.value}px`:void 0})),O=t.ref(null),M=t.computed(()=>{if(!r.mobile||!O.value)return;const B=O.value,b={position:"fixed",left:`${B.left}px`};return B.top!==void 0&&(b.top=`${B.top}px`),B.bottom!==void 0&&(b.bottom=`${B.bottom}px`),B.right!==void 0&&(b.right=`${B.right}px`),b}),E=t.shallowRef(null);t.watch(()=>r.blockId,B=>{E.value=B},{immediate:!0});const N=t.shallowRef(c.getState());let A=null;const W=t.computed(()=>N.value.doc.blocks.get(E.value??"")),me=t.computed(()=>{var b;if(r.cellEditMode||r.tableMode){const L=r.blockAttrs.align;return typeof L=="string"?L:"left"}const B=(b=W.value)==null?void 0:b.attrs.align;return typeof B=="string"?B:"left"}),le=t.computed(()=>{if(r.tableMode){const B=r.tableActiveVerticalAlign;return typeof B=="string"?B:"middle"}if(r.cellEditMode){const B=r.blockAttrs.verticalAlign;return typeof B=="string"?B:"middle"}return"middle"}),he=t.ref(""),ae=t.ref("");t.watch(()=>r.visible,B=>{B||(F.value=null)}),t.watch(()=>r.blockId,()=>{F.value=null});const ie=t.ref(new Set),Se=t.ref(0);function Te(){var B;if(!r.rootEl)return null;if(r.cellEditMode){const b=window.getSelection();if(!b||b.rangeCount===0)return null;const L=b.getRangeAt(0);return(B=L.commonAncestorContainer.nodeType===1?L.commonAncestorContainer:L.commonAncestorContainer.parentElement)==null?void 0:B.closest(".table-cell-inner")}return r.rootEl.querySelector(`[data-block-id="${r.blockId}"]`)}function We(){const B=new Set;if(!r.visible||!r.blockId||!r.rootEl){ie.value=B;return}if(r.tableMode&&r.tableActiveMarks){ie.value=new Set(r.tableActiveMarks);return}const b=Te();if(b){const y=window.getSelection();if(y&&y.rangeCount>0){const v=y.getRangeAt(0);if(!v.collapsed&&b.contains(v.commonAncestorContainer)){const T=[],R=document.createTreeWalker(b,NodeFilter.SHOW_TEXT);for(;R.nextNode();){const q=R.currentNode;(q.nodeValue??"").length!==0&&v.intersectsNode(q)&&T.push(q)}if(T.length>0){const q={bold:["B","STRONG"],italic:["I","EM"],underline:["U"],strikethrough:["S","STRIKE","DEL"],code:["CODE"],link:["A"]};for(const[X,ce]of Object.entries(q))T.every(ke=>{let pe=ke.parentNode;for(;pe&&pe!==b;){if(pe.nodeType===Node.ELEMENT_NODE&&ce.includes(pe.nodeName))return!0;pe=pe.parentNode}return!1})&&B.add(X);if(B.size>0){ie.value=B;return}}}}}const L=N.value,de=r.blockId?L.doc.blocks.get(r.blockId):void 0;if(!de){ie.value=B;return}const _e=L.selection;let Oe=0,Be=Ae(de.content).length;if(_e.kind==="text"&&_e.anchor.blockId===r.blockId&&_e.focus.blockId===r.blockId)Oe=Math.min(_e.anchor.offset,_e.focus.offset),Be=Math.max(_e.anchor.offset,_e.focus.offset);else{const y=_t();y&&(Oe=y.from,Be=y.to)}if(Oe>=Be){ie.value=B;return}const be=["bold","italic","underline","strikethrough","code","link"];for(const y of be){let v=!0,T=!1,R=0;for(const q of de.content){if(q.type!=="text")continue;const X=R,ce=R+q.text.length;if(ce>Oe&&X<Be&&(T=!0,!q.marks||!q.marks.some(ke=>ke.type===y))){v=!1;break}R=ce}T&&v&&B.add(y)}ie.value=B}const Mt=t.computed(()=>r.mobile&&!r.tableMode&&!r.cellEditMode&&!r.selectionRect),Zt=t.computed(()=>Mt.value||r.blockType==="codeBlock"),Gt=t.computed(()=>r.tableMode||r.cellEditMode?Mt.value:!r.blockId),Rt=t.computed(()=>{if(r.tableMode||r.cellEditMode)return Mt.value?!0:r.blockType==="codeBlock";if(!r.blockId||r.blockType==="codeBlock")return!0;const B=r.blockType;return B?!("align"in c.registries.schema.get(B).attrs):!1});function tt(B){if(r.tableMode||r.cellEditMode)return!!(r.blockType==="codeBlock"||r.blockType==="quote"&&B==="italic"||B!=="code"&&ie.value.has("code"));if(Zt.value)return!0;if(B==="italic"){const b=r.blockType;if(b&&c.registries.schema.isMarkDisallowed(b,"italic"))return!0}if(B==="link"){const b=c.getState().selection;return!!(b.kind==="text"&&Ht(b))}return!!(B!=="code"&&ie.value.has("code"))}const yt=t.computed(()=>[{id:"bold",title:i("mark.bold"),iconHtml:'<svg viewBox="0 0 1024 1024" width="15" height="15" aria-hidden="true"><path d="M214.857 889.143v-68.571h68.571V203.429H214.857v-68.571h411.429v1.257c96.114 10.629 171.429 87.383 171.429 181.6 0 58.971-29.486 111.086-75.109 144.457 72.069 39.291 120.823 113.234 120.823 198.4 0 119.291-95.634 216.594-217.12 227.543l-0.286.029H214.857z m388.572-388.571H352v320h251.429c95.086 0 171.429-72.091 171.429-160s-76.343-160-171.429-160z m0-297.143H352v228.571h251.429l5.211-0.091c67.52-2.515 120.503-53.235 120.503-114.195 0-62.537-55.749-114.285-125.714-114.285z" fill="currentColor"/></svg>'},{id:"italic",title:i("mark.italic"),iconHtml:'<svg viewBox="0 0 1024 1024" width="15" height="15" aria-hidden="true"><path d="M730.143 127.714v64.286h-112.329l-166.521 621.429h128.871v64.286H276.286v-64.286h108.45l166.5-621.429H426.286V127.714h303.857z" fill="currentColor"/></svg>'},{id:"underline",title:i("mark.underline"),iconHtml:'<svg viewBox="0 0 1024 1024" width="15" height="15" aria-hidden="true"><path d="M512 123.639a36.409 36.409 0 0 1 33.642 22.525l230.59 558.27a36.409 36.409 0 1 1-67.284 27.768L638.072 560.545H385.928l-70.876 171.656a36.409 36.409 0 1 1-67.332-27.768l230.59-558.27A36.409 36.409 0 0 1 512 123.639z m-95.974 364.089h191.948L512 255.439l-95.974 232.289zM769.289 827.544c19.418 0 38.836 14.564 38.836 38.836 0 19.418-14.564 33.982-29.127 33.982H259.565c-19.418 0-38.836-14.564-38.836-38.836 0-19.418 14.564-33.982 29.127-33.982h519.433z" fill="currentColor"/></svg>'},{id:"strikethrough",title:i("mark.strikethrough"),iconHtml:'<svg viewBox="0 0 1024 1024" width="15" height="15" aria-hidden="true"><path d="M182.044 490.667h659.911a34.133 34.133 0 0 1 4.642 67.948l-4.597 0.319h-135.395c40.05 37 60.803 81.601 60.803 133.575 0 128.569-147.092 211.171-307.382 192.512-101.717-11.833-173.352-52.565-210.944-122.971a34.133 34.133 0 0 1 60.211-32.176c25.942 48.606 77.46 77.915 158.606 87.381 124.837 14.473 231.242-45.283 231.242-124.746 0-53.339-36.636-96.802-116.736-131.345l-5.279-2.23H182.044a34.133 34.133 0 0 1-33.815-29.492L147.911 524.8a34.133 34.133 0 0 1 29.491-33.815l4.642-0.318z m68.767-176.447c6.918-128.796 128.432-203.343 287.812-184.82 99.579 11.56 175.81 47.923 226.737 109.636a34.133 34.133 0 1 1-52.657 43.463c-38.775-47.013-98.759-75.639-181.999-85.288-123.654-14.381-211.627 36.591-211.627 117.009 0 35.135 10.65 61.349 37.774 90.203l5.826 6.007c4.278 4.369 8.966 8.875 11.377 10.923l1.411 0.91H288.085l-1.092-1.729c-6.508-9.376-38.958-54.386-36.182-106.314z" fill="currentColor"/></svg>'},{id:"code",title:i("mark.inlineCode"),iconHtml:'<svg viewBox="0 0 1024 1024" width="15" height="15" aria-hidden="true"><path d="M197.802 747.664v-145.287a58.916 58.916 0 0 0-58.916-58.916h-19.619v-62.922h19.619a58.916 58.916 0 0 0 58.916-58.916V276.336a117.832 117.832 0 0 1 117.832-117.832h39.297v78.535h-39.356a39.297 39.297 0 0 0-39.238 39.297v161.017A78.594 78.594 0 0 1 222.37 512a78.594 78.594 0 0 1 53.967 74.646V747.664a39.238 39.238 0 0 0 39.238 39.238h39.356v78.594h-39.356a117.832 117.832 0 0 1-117.832-117.832z m628.456-145.287V747.664a117.832 117.832 0 0 1-117.832 117.832h-39.356v-78.594h39.356a39.238 39.238 0 0 0 39.238-39.238v-161.017A78.535 78.535 0 0 1 801.63 512a78.594 78.594 0 0 1-53.967-74.646V276.336a39.297 39.297 0 0 0-39.238-39.297h-39.356V158.504h39.356a117.832 117.832 0 0 1 117.832 117.832v145.287a58.916 58.916 0 0 0 58.916 58.916h19.56v62.922h-19.56a58.916 58.916 0 0 0-58.916 58.916z" fill="currentColor"/></svg>'}]),vt=t.computed(()=>{const B=r.blockType,b=r.blockAttrs,L=(_e,Oe)=>B===_e&&(Oe===void 0||Number(b.level)===Oe);return[{id:"text",label:i("turnInto.paragraph"),iconHtml:el,active:L("paragraph"),convertType:"paragraph"},{id:"h1",label:i("turnInto.h1"),iconHtml:tl,active:L("heading",1),convertType:"heading",convertAttrs:{level:1}},{id:"h2",label:i("turnInto.h2"),iconHtml:nl,active:L("heading",2),convertType:"heading",convertAttrs:{level:2}},{id:"h3",label:i("turnInto.h3"),iconHtml:ol,active:L("heading",3),convertType:"heading",convertAttrs:{level:3}},{id:"h4",label:i("turnInto.h4"),iconHtml:rl,active:L("heading",4),convertType:"heading",convertAttrs:{level:4}},{id:"h5",label:i("turnInto.h5"),iconHtml:ll,active:L("heading",5),convertType:"heading",convertAttrs:{level:5}},{id:"h6",label:i("turnInto.h6"),iconHtml:il,active:L("heading",6),convertType:"heading",convertAttrs:{level:6}},{id:"bullet",label:i("turnInto.bullet"),iconHtml:sl,active:L("bulletList"),convertType:"bulletList"},{id:"ordered",label:i("turnInto.ordered"),iconHtml:cl,active:L("orderedList"),convertType:"orderedList"},{id:"todo",label:i("turnInto.todo"),iconHtml:al,active:L("todoList"),convertType:"todoList",convertAttrs:{checked:!1}},{id:"quote",label:i("turnInto.quote"),iconHtml:dl,active:L("quote"),convertType:"quote"},{id:"code",label:i("turnInto.code"),iconHtml:ul,active:L("codeBlock"),convertType:"codeBlock",convertAttrs:{language:"plain"}}]}),Ze=t.computed(()=>{const B=vt.value.find(b=>b.active);return B?B.label:i("turnInto.paragraph")}),Ve=t.computed(()=>[{id:"left",label:i("align.left"),value:"left"},{id:"center",label:i("align.center"),value:"center"},{id:"right",label:i("align.right"),value:"right"},{id:"justify",label:i("align.justify"),value:"justify"}]),Ct=t.computed(()=>[{id:"top",label:i("verticalAlign.top"),value:"top"},{id:"middle",label:i("verticalAlign.middle"),value:"middle"},{id:"bottom",label:i("verticalAlign.bottom"),value:"bottom"}]),fe=Xi,Tt=ji;function Xe(){var be;const B=d.value,b=ne.value;if(!B||!b){Z.value=!1;return}const L=b.scrollLeft;b.style.maxWidth="",b.offsetWidth;const de=b.scrollWidth,_e=r.mobile?Math.max(120,(((be=B.parentElement)==null?void 0:be.clientWidth)??B.clientWidth)-8):Math.max(200,document.documentElement.clientWidth-32),Oe=Xf*2,Be=_e-Oe;if(de>Be){Z.value=!0,b.style.maxWidth=`${Be}px`;const y=Math.max(0,b.scrollWidth-b.clientWidth);b.scrollLeft=Math.min(L,y),Re()}else Z.value=!1,b.style.maxWidth="",S.value=!1,K.value=!1}function Re(){const B=ne.value;B&&(S.value=B.scrollLeft>0,K.value=B.scrollLeft+B.clientWidth<B.scrollWidth-1)}function qt(B){F.value=null;const b=ne.value;b&&(b.scrollLeft+=B*Zf,Re())}let rt=null,Et=0,P=0,w=!1,z=!1;function we(B){if(!w)return;const b=B.touches[0];if(!b)return;const L=Math.abs(b.clientX-Et),de=Math.abs(b.clientY-P);(L>es||de>es)&&(z||(F.value=null),z=!0)}function ve(B){if(!w)return;const b=rt;rt=null,w=!1;const L=z;z=!1,L||(B.cancelable&&B.preventDefault(),b&&b())}function nt(B,b){b.cancelable&&b.preventDefault(),qt(B)}function lt(B,b){const L=b.touches[0];L&&(Et=L.clientX,P=L.clientY),rt=B,w=!0,z=!1}t.watch([()=>r.visible,()=>r.selectionRect,d,()=>r.mobile],async()=>{if(r.mobile){r.visible&&Xe();return}if(!r.visible||!r.selectionRect||!r.rootEl)return;const B=d.value;if(!B)return;Xe(),await t.nextTick();const b=B.getBoundingClientRect(),L=b.width,de=Math.max(b.height,ml);U.value=r.tableMode?qi(r.rootEl,r.selectionRect,{width:L,height:de}):Gi(r.rootEl,r.selectionRect,{width:L,height:de})},{flush:"post",immediate:!0});const on=t.computed(()=>({top:"0px",left:"0px",width:"100vw",height:"100vh"})),cn=t.computed(()=>{const B=d.value,b=(B==null?void 0:B.offsetWidth)??jf,L=document.documentElement.clientWidth,de=8;let _e=U.value.left;const Oe=Math.max(de,L-b-de);_e=Math.max(de,Math.min(Oe,_e));const Be={top:`${U.value.top}px`,left:`${_e}px`};if(r.selectionRect){const y=r.selectionRect.left+r.selectionRect.width/2-_e,v=Math.max(10,Math.min(b-10,y));Be["--ht-arrow-x"]=`${v}px`}return Be});async function He(B){F.value=F.value===B?null:B,F.value&&(await t.nextTick(),vn())}function vn(){const B=F.value;if(!B)return;const b=B==="type"?f.value:B==="align"?u.value:B==="verticalAlign"?h.value:p.value,L=B==="type"?m.value:B==="align"?k.value:B==="verticalAlign"?x.value:D.value;if(!b||!L)return;const de=L.getBoundingClientRect(),_e=window.innerHeight,Oe=6,Be=Math.floor(_e-de.bottom-Oe),be=Math.floor(de.top-Oe),y=b.scrollHeight;if(r.mobile){const q=document.documentElement.clientHeight,X=10;if(a.value){ee.value=!0,$.value=Math.max(120,be-X);const ue=q-de.top+Oe;if(B==="color"){const ke=document.documentElement.clientWidth;O.value={left:8,bottom:ue,right:Math.max(8,ke-de.right)}}else O.value={left:Math.max(8,de.left),bottom:ue}}else{ee.value=!1,$.value=Math.max(120,Be-X);const ue=de.bottom+Oe;if(B==="color"){const ke=document.documentElement.clientWidth;O.value={left:8,top:ue,right:Math.max(8,ke-de.right)}}else O.value={left:Math.max(8,de.left),top:ue}}t.nextTick(Xt);return}O.value=null;let v=!1;if(r.rootEl&&d.value){const q=r.rootEl.getBoundingClientRect(),X=d.value.getBoundingClientRect();q.bottom-X.bottom<ts&&be>ts&&(v=!0)}let T=!1,R;v?(T=!0,R=be):y<=Be?(T=!1,R=Be):be>Be?(T=!0,R=be):(T=!1,R=Be),ee.value=T,$.value=Math.max(120,Math.min(R,360)),t.nextTick(Xt)}function Xt(){const B=V.value;if(!B){re.value=!1,G.value=!1;return}re.value=B.scrollTop>1,G.value=B.scrollTop+B.clientHeight<B.scrollHeight-1}function bn(){const B=V.value;B&&(B.scrollTop-=B.clientHeight*.8)}function Cn(){const B=V.value;B&&(B.scrollTop+=B.clientHeight*.8)}dr(V,Xt);function Tn(B){var L,de,_e,Oe,Be;if(l("interacting"),r.tableMode||r.cellEditMode){B.convertType==="heading"&&((L=B.convertAttrs)!=null&&L.level)?l("tableType",`heading${B.convertAttrs.level}`):l("tableType",B.convertType),F.value=null,r.tableMode&&l("close");return}const b=ft();if(b){for(const be of b.ranges)(_e=(de=c.commands).convertBlock)==null||_e.call(de,{id:be.id,type:B.convertType,attrs:B.convertAttrs??{}});F.value=null,l("close");return}E.value&&((Be=(Oe=c.commands).convertBlock)==null||Be.call(Oe,{id:E.value,type:B.convertType,attrs:B.convertAttrs??{}}),F.value=null,l("close"))}function Me(B){var L,de,_e,Oe;if(l("interacting"),r.tableMode||r.cellEditMode){l("tableAlign",B),F.value=null;return}const b=ft();if(b){for(const Be of b.ranges)(de=(L=c.commands).setBlockAlign)==null||de.call(L,{id:Be.id,align:B});F.value=null;return}E.value&&((Oe=(_e=c.commands).setBlockAlign)==null||Oe.call(_e,{id:E.value,align:B}),F.value=null)}function Ie(B){if(r.tableMode||r.cellEditMode){l("tableVerticalAlign",B),F.value=null;return}F.value=null}function Ge(B){var de,_e,Oe,Be;if(l("interacting"),r.tableMode){l("tableTextColor",B==="default"?null:B),F.value=null;return}if(r.cellEditMode){const be=window.getSelection();if(be&&be.rangeCount>0&&!be.isCollapsed){const y=be.getRangeAt(0);if(B==="default"){const v=y.extractContents();v.querySelectorAll('span[class*="be-color-"]').forEach(T=>{const R=T.className.replace(/be-color-\w+/g,"").trim();if(R)T.className=R;else{for(;T.firstChild;)T.parentNode.insertBefore(T.firstChild,T);T.parentNode.removeChild(T)}}),y.insertNode(v)}else{const v=document.createElement("span");v.className=`be-color-${B}`,v.appendChild(y.extractContents()),y.insertNode(v),be.removeAllRanges();const T=document.createRange();T.selectNodeContents(v),be.addRange(T)}}F.value=null,Ke();return}const b=ft();if(b){for(const be of b.ranges)(_e=(de=c.commands).setInlineMark)==null||_e.call(de,{id:be.id,markType:"color",attrs:B==="default"?null:{color:B},from:be.from,to:be.to});return}if(!E.value)return;const L=_t();L&&((Be=(Oe=c.commands).setInlineMark)==null||Be.call(Oe,{id:E.value,markType:"color",attrs:B==="default"?null:{color:B},from:L.from,to:L.to}),t.nextTick(()=>{var X;const be=window.getSelection(),y=(X=r.rootEl)==null?void 0:X.querySelector(`[data-block-id="${r.blockId}"]`),v=be&&be.rangeCount>0?be.getRangeAt(0):null,T=!!y,R=!!(v&&y&&y.contains(v.commonAncestorContainer)),q=!!(v&&!v.collapsed&&R);if(!T){l("close");return}if(!q&&!R){l("close");return}Ke(),We()}))}function ct(B){var de,_e,Oe,Be;if(l("interacting"),r.tableMode){l("tableBgColor",B==="default"?null:B),F.value=null;return}if(r.cellEditMode){const be=window.getSelection();if(be&&be.rangeCount>0&&!be.isCollapsed){const y=be.getRangeAt(0);if(B==="default"){const v=y.extractContents();v.querySelectorAll('span[class*="be-bg-"]').forEach(T=>{const R=T.className.replace(/be-bg-\w+/g,"").trim();if(R)T.className=R;else{for(;T.firstChild;)T.parentNode.insertBefore(T.firstChild,T);T.parentNode.removeChild(T)}}),y.insertNode(v)}else{const v=document.createElement("span");v.className=`be-bg-${B}`,v.appendChild(y.extractContents()),y.insertNode(v),be.removeAllRanges();const T=document.createRange();T.selectNodeContents(v),be.addRange(T)}}F.value=null,Ke();return}const b=ft();if(b){for(const be of b.ranges)(_e=(de=c.commands).setInlineMark)==null||_e.call(de,{id:be.id,markType:"bgColor",attrs:B==="default"?null:{bgColor:B},from:be.from,to:be.to});return}if(!E.value)return;const L=_t();L&&((Be=(Oe=c.commands).setInlineMark)==null||Be.call(Oe,{id:E.value,markType:"bgColor",attrs:B==="default"?null:{bgColor:B},from:L.from,to:L.to}),t.nextTick(()=>{var X;const be=window.getSelection(),y=(X=r.rootEl)==null?void 0:X.querySelector(`[data-block-id="${r.blockId}"]`),v=be&&be.rangeCount>0?be.getRangeAt(0):null,T=!!y,R=!!(v&&y&&y.contains(v.commonAncestorContainer)),q=!!(v&&!v.collapsed&&R);if(!T){l("close");return}if(!q&&!R){l("close");return}Ke(),We()}))}function Ke(){if(r.tableMode){he.value=r.tableActiveColor??"",ae.value=r.tableActiveBgColor??"";return}if(r.visible&&r.blockId&&r.rootEl){const y=Te(),v=window.getSelection();if(y&&v&&v.rangeCount>0){const T=v.getRangeAt(0);if(!T.collapsed&&y.contains(T.commonAncestorContainer)){const R=new Set,q=new Set,X=[],ce=document.createTreeWalker(y,NodeFilter.SHOW_TEXT);for(;ce.nextNode();){const ue=ce.currentNode;(ue.nodeValue??"").length!==0&&T.intersectsNode(ue)&&X.push(ue)}for(const ue of X){let ke=ue.parentNode;for(;ke&&ke!==y;){if(ke.nodeType===Node.ELEMENT_NODE){const pe=ke.className;if(typeof pe=="string"){const xe=pe.match(/be-color-(\w+)/);xe&&R.add(xe[1]);const Ne=pe.match(/be-bg-(\w+)/);Ne&&q.add(Ne[1])}}ke=ke.parentNode}}if(R.size>0||q.size>0){he.value=R.size===1?[...R][0]:"",ae.value=q.size===1?[...q][0]:"";return}}}}const B=N.value,b=r.blockId?B.doc.blocks.get(r.blockId):void 0;if(!b){he.value="",ae.value="";return}const L=B.selection;let de,_e;if(L.kind==="text"&&L.anchor.blockId===r.blockId&&L.focus.blockId===r.blockId)de=Math.min(L.anchor.offset,L.focus.offset),_e=Math.max(L.anchor.offset,L.focus.offset);else{const y=_t();de=y?y.from:0,_e=y?y.to:Ae(b.content).length}if(de>=_e){he.value="",ae.value="";return}const Oe=new Set,Be=new Set;let be=0;for(const y of b.content){if(y.type!=="text")continue;const v=be,T=be+y.text.length;if(T>de&&v<_e&&y.marks)for(const R of y.marks)R.type==="color"&&R.attrs&&typeof R.attrs.color=="string"&&Oe.add(R.attrs.color),R.type==="bgColor"&&R.attrs&&typeof R.attrs.bgColor=="string"&&Be.add(R.attrs.bgColor);be=T}he.value=Oe.size===1?[...Oe][0]:"",ae.value=Be.size===1?[...Be][0]:""}function _t(){if(!r.blockId||!r.rootEl)return null;const B=r.rootEl.querySelector(`[data-block-id="${r.blockId}"]`);if(!B)return null;const b=window.getSelection();if(!b||b.rangeCount===0)return null;const L=b.getRangeAt(0);if(L.collapsed||!B.contains(L.commonAncestorContainer))return null;const de=document.createRange();de.selectNodeContents(B),de.setEnd(L.startContainer,L.startOffset);const _e=de.toString().length;de.setEnd(L.endContainer,L.endOffset);const Oe=de.toString().length;return{from:Math.min(_e,Oe),to:Math.max(_e,Oe)}}function ft(){const B=N.value.selection;if(B.kind!=="text"||!Ht(B))return null;const b=N.value.doc,L=In(b),de=L.indexOf(B.anchor.blockId),_e=L.indexOf(B.focus.blockId);if(de===-1||_e===-1)return null;const[Oe,Be]=de<=_e?[B.anchor,B.focus]:[B.focus,B.anchor],be=L.indexOf(Oe.blockId),y=L.indexOf(Be.blockId);if(be===-1||y===-1||be>y)return null;const v=[];for(let T=be;T<=y;T++){const R=L[T],q=b.blocks.get(R);if(!q)continue;const X=Ae(q.content).length;let ce=0,ue=X;T===be&&(ce=Math.min(Oe.offset,X)),T===y&&(ue=Math.min(Be.offset,X)),v.push({id:R,from:ce,to:ue})}return{ranges:v}}function ht(){const B=N.value.selection;if(B.kind!=="text"||!Ht(B))return null;const b=ft();if(!b)return null;const L=N.value.doc,de=[],_e=[];for(const Oe of b.ranges){const Be=L.blocks.get(Oe.id);if(!Be)continue;const[,be]=Wt(Be.content,Oe.from),[y]=Wt(be,Oe.to-Oe.from);de.push(Ae(y)),_e.push(Zn(y))}return{text:de.join(`
|
|
12
|
+
`),html:_e.join("<br>")}}function At(B){var de,_e,Oe,Be;if(l("interacting"),r.tableMode){l("tableMark",B);return}if(r.cellEditMode){const y={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikeThrough",code:"insertHTML"}[B];if(y==="insertHTML"){const v=window.getSelection();if(v&&v.rangeCount>0&&!v.isCollapsed){const T=v.getRangeAt(0),R=document.createElement("code");try{R.appendChild(T.extractContents()),T.insertNode(R),v.removeAllRanges();const q=document.createRange();q.selectNodeContents(R),v.addRange(q)}catch{}}}else y&&document.execCommand(y);We();return}const b=ft();if(b){for(const be of b.ranges)(_e=(de=c.commands).toggleMark)==null||_e.call(de,{id:be.id,markType:B,from:be.from,to:be.to});return}if(!E.value)return;const L=_t();L&&((Be=(Oe=c.commands).toggleMark)==null||Be.call(Oe,{id:E.value,markType:B,from:L.from,to:L.to}),t.nextTick(()=>{var X;Se.value++;const be=window.getSelection(),y=(X=r.rootEl)==null?void 0:X.querySelector(`[data-block-id="${r.blockId}"]`),v=be&&be.rangeCount>0?be.getRangeAt(0):null,T=!!y,R=!!(v&&y&&y.contains(v.commonAncestorContainer)),q=!!(v&&!v.collapsed&&R);if(!T){l("close");return}if(!q&&!R){l("close");return}We(),Ke()}))}function an(){if(l("interacting"),F.value=null,r.cellEditMode){l("linkClick",E.value??"",0,0);return}if(E.value){const B=_t();B&&l("linkClick",E.value,B.from,B.to)}}function Lt(){var de,_e;if(r.tableMode){l("tableCopy"),l("close");return}const B=ht();if(B){(de=navigator.clipboard)==null||de.writeText(B.text),l("close");return}const b=window.getSelection(),L=b?b.toString():"";L&&((_e=navigator.clipboard)==null||_e.writeText(L)),l("close")}n({});async function hn(){if(r.mobile){r.visible&&Xe(),F.value&&vn(),Xt(),We(),Ke();return}if(r.visible&&r.selectionRect&&r.rootEl&&d.value){Xe(),await t.nextTick();const B=d.value.getBoundingClientRect();U.value=r.tableMode?qi(r.rootEl,r.selectionRect,{width:B.width,height:Math.max(B.height,ml)}):Gi(r.rootEl,r.selectionRect,{width:B.width,height:Math.max(B.height,ml)})}F.value&&vn(),Xt(),We(),Ke()}function _n(B){if(!F.value)return;const b=[f.value,u.value,h.value,p.value],L=[m.value,k.value,x.value,D.value];for(const de of b)if(de&&de.contains(B))return;for(const de of L)if(de&&de.contains(B))return;F.value=null}function xn(B){if(!r.visible)return;const b=d.value;if(b&&b.contains(B.target)){B.preventDefault();return}_n(B.target)}function dn(B){if(!r.visible||!B.touches[0])return;const L=B.target,de=d.value;if(de&&de.contains(L)){const _e=ne.value;if(_e&&_e.contains(L))return;B.preventDefault();return}_n(L)}t.watch(()=>r.visible,B=>{B&&t.nextTick(()=>{We(),Ke()})}),t.onMounted(()=>{window.addEventListener("scroll",hn,!0),window.addEventListener("resize",hn),window.addEventListener("mousedown",xn,!0),window.addEventListener("touchstart",dn,!0),document.addEventListener("selectionchange",Qn),A=c.subscribe(()=>{t.nextTick(()=>{const B=c.getState();N.value=B,Se.value++,We(),Ke()})})}),t.onBeforeUnmount(()=>{window.removeEventListener("scroll",hn,!0),window.removeEventListener("resize",hn),window.removeEventListener("mousedown",xn,!0),window.removeEventListener("touchstart",dn,!0),document.removeEventListener("selectionchange",Qn),A==null||A(),A=null});function Qn(){r.visible&&Mn===null&&(Mn=requestAnimationFrame(()=>{Mn=null,r.visible&&(We(),Ke())}))}let Mn=null;return(B,b)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:e.mobile},[t.createElementVNode("div",{class:t.normalizeClass(["hover-toolbar-shell",{visible:e.visible,"mobile-shell":e.mobile,"mobile-visible":e.mobile&&e.visible}]),style:t.normalizeStyle(e.mobile?void 0:on.value),"aria-hidden":!e.visible,onMousedownCapture:t.withModifiers(s,["prevent"])},[t.createElementVNode("div",{ref_key:"toolbarEl",ref:d,class:t.normalizeClass(["hover-toolbar",{above:U.value.above,below:!U.value.above,"ht-overflow":Z.value,"mobile-mode":e.mobile}]),style:t.normalizeStyle(e.mobile?void 0:cn.value),role:"toolbar","aria-label":t.unref(i)("hoverToolbar.label")},[Z.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:t.normalizeClass(["ht-nav-btn ht-nav-left",{disabled:!S.value}]),title:t.unref(i)("ui.scrollLeft"),"aria-label":t.unref(i)("ui.scrollLeft"),onMousedown:b[0]||(b[0]=t.withModifiers(L=>qt(-1),["prevent","stop"])),onTouchstart:b[1]||(b[1]=t.withModifiers(()=>{},["stop"])),onTouchend:b[2]||(b[2]=t.withModifiers(L=>nt(-1,L),["stop"])),onClick:b[3]||(b[3]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[39]||(b[39]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M7.5 3L4.5 6L7.5 9",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],42,nf)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"htContentEl",ref:ne,class:t.normalizeClass(["ht-content",{"dropdown-open":!e.mobile&&!!F.value}]),onScroll:Re,onTouchmovePassive:we,onTouchend:t.withModifiers(ve,["stop"])},[t.createElementVNode("div",of,[t.createElementVNode("button",{ref_key:"typeBtnEl",ref:m,class:t.normalizeClass(["ht-btn ht-type-btn",{open:F.value==="type",disabled:Gt.value}]),title:t.unref(i)("hoverToolbar.typeBtnTitle"),disabled:Gt.value,onMousedown:b[4]||(b[4]=t.withModifiers(L=>!Gt.value&&He("type"),["prevent","stop"])),onTouchstart:b[5]||(b[5]=t.withModifiers(L=>{lt(()=>{Gt.value||He("type")},L)},["stop"])),onClick:b[6]||(b[6]=t.withModifiers(()=>{},["prevent","stop"]))},[t.createElementVNode("span",lf,t.toDisplayString(Ze.value),1),b[40]||(b[40]=t.createElementVNode("svg",{class:"ht-caret",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],42,rf),(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:!e.mobile},[F.value==="type"?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"typeDropdownEl",ref:f,class:t.normalizeClass(["ht-dropdown",[e.mobile?"ht-dropdown-mobile":"",{above:ee.value}]]),style:t.normalizeStyle([_.value,M.value])},[re.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(i)("ui.scrollUp"),onMousedown:t.withModifiers(bn,["prevent"])},[...b[41]||(b[41]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,sf)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:V,class:"ht-dropdown-scroll",onScroll:Xt},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(vt.value,L=>(t.openBlock(),t.createElementBlock("button",{key:L.id,class:t.normalizeClass(["ht-dropdown-item",{active:L.active}]),onMousedown:t.withModifiers(de=>Tn(L),["prevent","stop"])},[t.createVNode(pn,{class:"ht-dropdown-icon",html:L.iconHtml},null,8,["html"]),t.createElementVNode("span",null,t.toDisplayString(L.label),1),L.active?(t.openBlock(),t.createElementBlock("svg",af,[...b[42]||(b[42]=[t.createElementVNode("path",{d:"M2.5 6L5 8.5L9.5 4",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):t.createCommentVNode("",!0)],42,cf))),128))],544),G.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(i)("ui.scrollDown"),onMousedown:t.withModifiers(Cn,["prevent"])},[...b[43]||(b[43]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,df)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)],8,["disabled"]))]),t.createElementVNode("div",uf,[t.createElementVNode("button",{ref_key:"alignBtnEl",ref:k,class:t.normalizeClass(["ht-btn ht-icon-only",{open:F.value==="align",disabled:Rt.value}]),title:t.unref(i)("hoverToolbar.alignBtnTitle"),disabled:Rt.value,onMousedown:b[7]||(b[7]=t.withModifiers(L=>!Rt.value&&He("align"),["prevent","stop"])),onTouchstart:b[8]||(b[8]=t.withModifiers(L=>{lt(()=>{Rt.value||He("align")},L)},["stop"])),onClick:b[9]||(b[9]=t.withModifiers(()=>{},["prevent","stop"]))},[(t.openBlock(),t.createElementBlock("svg",mf,[me.value==="left"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[b[44]||(b[44]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[45]||(b[45]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"10",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[46]||(b[46]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"12",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):me.value==="center"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[b[47]||(b[47]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[48]||(b[48]=t.createElementVNode("line",{x1:"4",y1:"8",x2:"12",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[49]||(b[49]=t.createElementVNode("line",{x1:"3",y1:"12",x2:"13",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):me.value==="right"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[b[50]||(b[50]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[51]||(b[51]=t.createElementVNode("line",{x1:"6",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[52]||(b[52]=t.createElementVNode("line",{x1:"4",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:3},[b[53]||(b[53]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[54]||(b[54]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[55]||(b[55]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64))]))],42,ff),(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:!e.mobile},[F.value==="align"?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"alignDropdownEl",ref:u,class:t.normalizeClass(["ht-dropdown",[e.mobile?"ht-dropdown-mobile":"",{above:ee.value}]]),style:t.normalizeStyle([_.value,M.value])},[re.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(i)("ui.scrollUp"),onMousedown:t.withModifiers(bn,["prevent"])},[...b[56]||(b[56]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,pf)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:V,class:"ht-dropdown-scroll",onScroll:Xt},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(Ve.value,L=>(t.openBlock(),t.createElementBlock("button",{key:L.id,class:t.normalizeClass(["ht-dropdown-item ht-align-item",{active:me.value===L.value}]),onMousedown:t.withModifiers(de=>Me(L.value),["prevent","stop"])},[(t.openBlock(),t.createElementBlock("svg",gf,[L.value==="left"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[b[57]||(b[57]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[58]||(b[58]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"10",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[59]||(b[59]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"12",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):L.value==="center"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[b[60]||(b[60]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[61]||(b[61]=t.createElementVNode("line",{x1:"4",y1:"8",x2:"12",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[62]||(b[62]=t.createElementVNode("line",{x1:"3",y1:"12",x2:"13",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):L.value==="right"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[b[63]||(b[63]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[64]||(b[64]=t.createElementVNode("line",{x1:"6",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[65]||(b[65]=t.createElementVNode("line",{x1:"4",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:3},[b[66]||(b[66]=t.createElementVNode("line",{x1:"2",y1:"4",x2:"14",y2:"4",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[67]||(b[67]=t.createElementVNode("line",{x1:"2",y1:"8",x2:"14",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[68]||(b[68]=t.createElementVNode("line",{x1:"2",y1:"12",x2:"14",y2:"12",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64))])),t.createElementVNode("span",null,t.toDisplayString(L.label),1),me.value===L.value?(t.openBlock(),t.createElementBlock("svg",bf,[...b[69]||(b[69]=[t.createElementVNode("path",{d:"M2.5 6L5 8.5L9.5 4",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):t.createCommentVNode("",!0)],42,hf))),128))],544),G.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(i)("ui.scrollDown"),onMousedown:t.withModifiers(Cn,["prevent"])},[...b[70]||(b[70]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,kf)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)],8,["disabled"]))]),e.tableMode||e.cellEditMode?(t.openBlock(),t.createElementBlock("div",yf,[t.createElementVNode("button",{ref_key:"verticalAlignBtnEl",ref:x,class:t.normalizeClass(["ht-btn ht-icon-only",{open:F.value==="verticalAlign",disabled:Rt.value}]),title:t.unref(i)("hoverToolbar.verticalAlignBtnTitle"),disabled:Rt.value,onMousedown:b[10]||(b[10]=t.withModifiers(L=>!Rt.value&&He("verticalAlign"),["prevent","stop"])),onTouchstart:b[11]||(b[11]=t.withModifiers(L=>{lt(()=>{Rt.value||He("verticalAlign")},L)},["stop"])),onClick:b[12]||(b[12]=t.withModifiers(()=>{},["prevent","stop"]))},[(t.openBlock(),t.createElementBlock("svg",Ef,[le.value==="top"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[b[71]||(b[71]=t.createElementVNode("line",{x1:"2",y1:"3",x2:"14",y2:"3",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[72]||(b[72]=t.createElementVNode("line",{x1:"4",y1:"7",x2:"12",y2:"7",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[73]||(b[73]=t.createElementVNode("line",{x1:"5",y1:"11",x2:"11",y2:"11",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):le.value==="bottom"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[b[74]||(b[74]=t.createElementVNode("line",{x1:"5",y1:"5",x2:"11",y2:"5",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[75]||(b[75]=t.createElementVNode("line",{x1:"4",y1:"9",x2:"12",y2:"9",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[76]||(b[76]=t.createElementVNode("line",{x1:"2",y1:"13",x2:"14",y2:"13",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[b[77]||(b[77]=t.createElementVNode("line",{x1:"5",y1:"3",x2:"11",y2:"3",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[78]||(b[78]=t.createElementVNode("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[79]||(b[79]=t.createElementVNode("line",{x1:"5",y1:"13",x2:"11",y2:"13",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64))]))],42,wf),(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:!e.mobile},[F.value==="verticalAlign"?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"verticalAlignDropdownEl",ref:h,class:t.normalizeClass(["ht-dropdown",[e.mobile?"ht-dropdown-mobile":"",{above:ee.value}]]),style:t.normalizeStyle([_.value,M.value])},[re.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(i)("ui.scrollUp"),onMousedown:t.withModifiers(bn,["prevent"])},[...b[80]||(b[80]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,vf)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:V,class:"ht-dropdown-scroll",onScroll:Xt},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(Ct.value,L=>(t.openBlock(),t.createElementBlock("button",{key:L.id,class:t.normalizeClass(["ht-dropdown-item ht-align-item",{active:le.value===L.value}]),onMousedown:t.withModifiers(de=>Ie(L.value),["prevent","stop"])},[(t.openBlock(),t.createElementBlock("svg",Tf,[L.value==="top"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[b[81]||(b[81]=t.createElementVNode("line",{x1:"2",y1:"3",x2:"14",y2:"3",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[82]||(b[82]=t.createElementVNode("line",{x1:"4",y1:"7",x2:"12",y2:"7",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[83]||(b[83]=t.createElementVNode("line",{x1:"5",y1:"11",x2:"11",y2:"11",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):L.value==="bottom"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[b[84]||(b[84]=t.createElementVNode("line",{x1:"5",y1:"5",x2:"11",y2:"5",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[85]||(b[85]=t.createElementVNode("line",{x1:"4",y1:"9",x2:"12",y2:"9",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[86]||(b[86]=t.createElementVNode("line",{x1:"2",y1:"13",x2:"14",y2:"13",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[b[87]||(b[87]=t.createElementVNode("line",{x1:"5",y1:"3",x2:"11",y2:"3",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[88]||(b[88]=t.createElementVNode("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1)),b[89]||(b[89]=t.createElementVNode("line",{x1:"5",y1:"13",x2:"11",y2:"13",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"},null,-1))],64))])),t.createElementVNode("span",null,t.toDisplayString(L.label),1),le.value===L.value?(t.openBlock(),t.createElementBlock("svg",_f,[...b[90]||(b[90]=[t.createElementVNode("path",{d:"M2.5 6L5 8.5L9.5 4",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):t.createCommentVNode("",!0)],42,Cf))),128))],544),G.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(i)("ui.scrollDown"),onMousedown:t.withModifiers(Cn,["prevent"])},[...b[91]||(b[91]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,xf)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)],8,["disabled"]))])):t.createCommentVNode("",!0),b[100]||(b[100]=t.createElementVNode("div",{class:"ht-sep"},null,-1)),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(yt.value,L=>(t.openBlock(),t.createElementBlock("button",{key:L.id,class:t.normalizeClass(["ht-btn ht-icon-only",{active:ie.value.has(L.id),disabled:tt(L.id)}]),title:L.title,disabled:tt(L.id),onMousedown:t.withModifiers(de=>!tt(L.id)&&At(L.id),["prevent","stop"]),onTouchstart:t.withModifiers(de=>{lt(()=>{tt(L.id)||At(L.id)},de)},["stop"]),onClick:b[13]||(b[13]=t.withModifiers(()=>{},["prevent","stop"]))},[t.createVNode(pn,{html:L.iconHtml},null,8,["html"])],42,Mf))),128)),e.tableMode?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("button",{key:1,class:t.normalizeClass(["ht-btn ht-icon-only",{active:ie.value.has("link"),disabled:tt("link")}]),title:t.unref(i)("hoverToolbar.linkBtnTitle"),disabled:tt("link"),onMousedown:b[14]||(b[14]=t.withModifiers(L=>!tt("link")&&an(),["prevent","stop"])),onTouchstart:b[15]||(b[15]=t.withModifiers(L=>{lt(()=>{tt("link")||an()},L)},["stop"])),onClick:b[16]||(b[16]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[92]||(b[92]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M394.666667 298.666667a32 32 0 0 1 4.693333 63.658666l-4.693333 0.341334H298.666667a149.333333 149.333333 0 0 0-8.789334 298.410666L298.666667 661.333333h96a32 32 0 0 1 4.693333 63.658667L394.666667 725.333333H298.666667a213.333333 213.333333 0 0 1-10.666667-426.410666L298.666667 298.666667h96zM725.333333 298.666667a213.333333 213.333333 0 0 1 10.666667 426.410666L725.333333 725.333333h-96a32 32 0 0 1-4.693333-63.658666l4.693333-0.341334H725.333333a149.333333 149.333333 0 0 0 8.789334-298.410666L725.333333 362.666667h-96a32 32 0 0 1-4.693333-63.658667L629.333333 298.666667H725.333333zM298.666667 480h426.666666a32 32 0 0 1 4.352 63.701333L725.333333 544H298.666667a32 32 0 0 1-4.352-63.701333L298.666667 480h426.666666H298.666667z",fill:"currentColor"})],-1)])],42,Nf)),b[101]||(b[101]=t.createElementVNode("div",{class:"ht-sep"},null,-1)),t.createElementVNode("div",Sf,[t.createElementVNode("button",{ref_key:"colorBtnEl",ref:D,class:t.normalizeClass(["ht-btn ht-icon-only",{open:F.value==="color",disabled:tt("color")}]),title:t.unref(i)("hoverToolbar.colorBtnTitle"),disabled:tt("color"),onMousedown:b[17]||(b[17]=t.withModifiers(L=>!tt("color")&&He("color"),["prevent","stop"])),onTouchstart:b[18]||(b[18]=t.withModifiers(L=>{lt(()=>{tt("color")||He("color")},L)},["stop"])),onClick:b[19]||(b[19]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[93]||(b[93]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("path",{d:"M163.797333 249.941333c125.44-167.082667 385.28-215.68 570.197334-100.693333 182.613333 113.493333 249.770667 331.818667 174.933333 536.618667-70.613333 193.408-256.682667 269.994667-390.784 172.714666-50.218667-36.437333-69.717333-82.133333-79.104-156.330666l-4.522667-42.112-1.92-16.981334c-5.248-39.850667-13.269333-57.685333-30.08-67.072-22.826667-12.714667-38.058667-13.013333-68.053333-1.408l-14.976 6.229334-7.637333 3.328c-43.264 18.773333-72.021333 25.386667-108.416 17.749333l-8.533334-2.005333-6.997333-2.005334c-118.997333-36.864-136.618667-198.272-24.106667-348.032z m41.984 286.549334l5.248 1.578666 5.717334 1.28c18.730667 3.712 34.730667 0.64 61.312-10.325333l25.685333-10.965333c51.285333-21.034667 84.693333-23.04 129.962667 2.133333 39.125333 21.845333 54.4 55.381333 62.165333 113.493333l2.261333 19.584 2.346667 22.698667 2.005333 18.005333c7.338667 58.069333 20.693333 89.173333 53.248 112.810667 97.066667 70.4 236.117333 13.184 293.12-142.890667 64.682667-177.152 7.424-363.264-148.650666-460.330666-156.8-97.450667-379.690667-55.722667-485.248 84.778666-88.533333 117.888-77.653333 225.28-9.173334 248.149334z m478.933334-85.077334a53.333333 53.333333 0 1 1 102.997333-27.605333 53.333333 53.333333 0 0 1-102.997333 27.605333z m21.077333 148.821334a53.333333 53.333333 0 1 1 103.04-27.605334 53.333333 53.333333 0 0 1-103.04 27.605334zM600.32 323.285333a53.333333 53.333333 0 1 1 103.04-27.605333 53.333333 53.333333 0 0 1-103.04 27.605333z m-1.194667 383.914667a53.333333 53.333333 0 1 1 102.997334-27.605333 53.333333 53.333333 0 0 1-102.997334 27.605333z m-149.205333-425.386667a53.333333 53.333333 0 1 1 103.04-27.562666 53.333333 53.333333 0 0 1-103.04 27.562666z",fill:"currentColor"})],-1)])],42,Af),(t.openBlock(),t.createBlock(t.Teleport,{to:"body",disabled:!e.mobile},[F.value==="color"?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"colorDropdownEl",ref:p,class:t.normalizeClass(["ht-dropdown ht-color-dropdown",[e.mobile?"ht-dropdown-mobile":"",{above:ee.value}]]),style:t.normalizeStyle([_.value,M.value])},[re.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(i)("ui.scrollUp"),onMousedown:t.withModifiers(bn,["prevent"])},[...b[94]||(b[94]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,If)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:V,class:"ht-dropdown-scroll",onScroll:Xt},[t.createElementVNode("div",Bf,[t.createElementVNode("div",Rf,t.toDisplayString(t.unref(i)("hoverToolbar.textColor")),1),t.createElementVNode("div",Lf,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(fe),L=>(t.openBlock(),t.createElementBlock("button",{key:"tc-"+L.key,class:t.normalizeClass(["ht-swatch",{active:he.value===L.key}]),title:t.unref(i)(L.key==="default"?"color.default":"color."+L.key),style:t.normalizeStyle({backgroundColor:L.displayCssValue??L.cssValue}),onMousedown:t.withModifiers(de=>Ge(L.key),["prevent","stop"])},null,46,Of))),128))])]),t.createElementVNode("div",Df,[t.createElementVNode("div",$f,t.toDisplayString(t.unref(i)("hoverToolbar.bgColor")),1),t.createElementVNode("div",Pf,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(Tt),L=>(t.openBlock(),t.createElementBlock("button",{key:"bc-"+L.key,class:t.normalizeClass(["ht-swatch",[{active:ae.value===L.key},L.key==="default"?"ht-swatch--none":""]]),title:t.unref(i)(L.key==="default"?"color.none":"color."+L.key),style:t.normalizeStyle({backgroundColor:L.displayCssValue??L.cssValue}),onMousedown:t.withModifiers(de=>ct(L.key),["prevent","stop"])},null,46,Hf))),128))])])],544),G.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(i)("ui.scrollDown"),onMousedown:t.withModifiers(Cn,["prevent"])},[...b[95]||(b[95]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Vf)):t.createCommentVNode("",!0)],6)):t.createCommentVNode("",!0)],8,["disabled"]))]),b[102]||(b[102]=t.createElementVNode("div",{class:"ht-sep"},null,-1)),t.createElementVNode("button",{class:t.normalizeClass(["ht-btn ht-icon-only",{disabled:Mt.value}]),title:t.unref(i)("hoverToolbar.copySelection"),"aria-label":t.unref(i)("hoverToolbar.copySelection"),disabled:Mt.value,onMousedown:b[20]||(b[20]=t.withModifiers(L=>!Mt.value&&Lt(),["prevent","stop"])),onTouchstart:b[21]||(b[21]=t.withModifiers(L=>{lt(()=>{Mt.value||Lt()},L)},["stop"])),onClick:b[22]||(b[22]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[96]||(b[96]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},[t.createElementVNode("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1.5",fill:"none",stroke:"currentColor","stroke-width":"1.3"}),t.createElementVNode("path",{d:"M3 10.5V3.5C3 2.67 3.67 2 4.5 2H10",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"})],-1)])],42,Uf),e.tableMode?(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[e.showMerge||e.showSplit||e.showHeaderRow||e.showDelete?(t.openBlock(),t.createElementBlock("div",zf)):t.createCommentVNode("",!0),e.showMerge?(t.openBlock(),t.createElementBlock("button",{key:1,class:"ht-btn ht-icon-only",title:t.unref(i)("table.mergeCells"),onMousedown:b[23]||(b[23]=t.withModifiers(L=>l("merge"),["prevent","stop"])),onTouchstart:b[24]||(b[24]=t.withModifiers(L=>lt(()=>l("merge"),L),["stop"])),onClick:b[25]||(b[25]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[97]||(b[97]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15",fill:"currentColor","aria-hidden":"true"},[t.createElementVNode("path",{d:"M266.666667 128A138.666667 138.666667 0 0 0 128 266.666667v490.666666A138.666667 138.666667 0 0 0 266.666667 896h490.666666A138.666667 138.666667 0 0 0 896 757.333333V266.666667A138.666667 138.666667 0 0 0 757.333333 128H266.666667zM192 266.666667c0-41.216 33.450667-74.666667 74.666667-74.666667H469.333333v128H192V266.666667z m341.333333 437.333333h298.666667v53.333333a74.666667 74.666667 0 0 1-74.666667 74.666667H533.333333v-128z m298.666667-384h-298.666667v-128h224c41.216 0 74.666667 33.450667 74.666667 74.666667V320z m-362.666667 384v128H266.666667a74.666667 74.666667 0 0 1-74.666667-74.666667V704H469.333333zM192 384h640v256h-640V384z"})],-1)])],40,Ff)):t.createCommentVNode("",!0),e.showSplit?(t.openBlock(),t.createElementBlock("button",{key:2,class:"ht-btn ht-icon-only",title:t.unref(i)("table.splitCell"),onMousedown:b[26]||(b[26]=t.withModifiers(L=>l("split"),["prevent","stop"])),onTouchstart:b[27]||(b[27]=t.withModifiers(L=>lt(()=>l("split"),L),["stop"])),onClick:b[28]||(b[28]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[98]||(b[98]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15",fill:"currentColor","aria-hidden":"true"},[t.createElementVNode("path",{d:"M533.333333 426.666667H469.333333v170.666666h64v-170.666666z"}),t.createElementVNode("path",{d:"M128 266.666667A138.666667 138.666667 0 0 1 266.666667 128h490.666666A138.666667 138.666667 0 0 1 896 266.666667v490.666666A138.666667 138.666667 0 0 1 757.333333 896H266.666667A138.666667 138.666667 0 0 1 128 757.333333V266.666667zM266.666667 192A74.666667 74.666667 0 0 0 192 266.666667V320H469.333333v-128H266.666667z m565.333333 512h-298.666667v128h224a74.666667 74.666667 0 0 0 74.666667-74.666667V704z m0-437.333333a74.666667 74.666667 0 0 0-74.666667-74.666667H533.333333v128h298.666667V266.666667zM192 704v53.333333c0 41.216 33.450667 74.666667 74.666667 74.666667H469.333333v-128H192z m0-64h640V384h-640v256z"})],-1)])],40,Kf)):t.createCommentVNode("",!0),e.showHeaderRow?(t.openBlock(),t.createElementBlock("button",{key:3,class:t.normalizeClass(["ht-btn ht-icon-only",{active:e.headerRowActive}]),title:t.unref(i)("table.toggleHeader"),onMousedown:b[29]||(b[29]=t.withModifiers(L=>l("tableHeaderRow"),["prevent","stop"])),onTouchstart:b[30]||(b[30]=t.withModifiers(L=>lt(()=>l("tableHeaderRow"),L),["stop"])),onClick:b[31]||(b[31]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[99]||(b[99]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[t.createElementVNode("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1"}),t.createElementVNode("path",{d:"M2 6h12"}),t.createElementVNode("path",{d:"M5 2v4"})],-1)])],42,Wf)):t.createCommentVNode("",!0),e.showDelete?(t.openBlock(),t.createElementBlock(t.Fragment,{key:4},[e.showMerge||e.showSplit||e.showHeaderRow?(t.openBlock(),t.createElementBlock("div",Gf)):t.createCommentVNode("",!0),t.createElementVNode("button",{class:"ht-btn ht-danger ht-icon-only",title:e.deleteLabel||t.unref(i)("hoverToolbar.deleteBlock"),onMousedown:b[32]||(b[32]=t.withModifiers(L=>l("delete"),["prevent","stop"])),onTouchstart:b[33]||(b[33]=t.withModifiers(L=>lt(()=>l("delete"),L),["stop"])),onClick:b[34]||(b[34]=t.withModifiers(()=>{},["prevent","stop"]))},[t.createVNode(pn,{html:e.deleteIcon||"<svg viewBox='0 0 1024 1024' width='15' height='15' fill='currentColor' aria-hidden='true'><path d='M128 266.666667A138.666667 138.666667 0 0 1 266.666667 128h490.666666A138.666667 138.666667 0 0 1 896 266.666667v246.272a276.096 276.096 0 0 0-64-30.250667V426.666667h-170.666667v56.021333a276.096 276.096 0 0 0-64 30.250667V426.666667h-170.666666v170.666666h86.272a276.096 276.096 0 0 0-30.250667 64H426.666667v170.666667h56.021333c7.381333 22.784 17.578667 44.245333 30.250667 64H266.666667A138.666667 138.666667 0 0 1 128 757.333333V266.666667zM266.666667 192A74.666667 74.666667 0 0 0 192 266.666667V362.666667h170.666667v-170.666667H266.666667zM192 426.666667v170.666666h170.666667v-170.666666h-170.666667z m469.333333-64h170.666667V266.666667a74.666667 74.666667 0 0 0-74.666667-74.666667H661.333333v170.666667z m-64-170.666667h-170.666666v170.666667h170.666666v-170.666667z m-405.333333 469.333333v96c0 41.216 33.450667 74.666667 74.666667 74.666667H362.666667v-170.666667h-170.666667z'/><path d='M981.333333 746.666667a234.666667 234.666667 0 1 1-469.333333 0 234.666667 234.666667 0 0 1 469.333333 0z m-234.666666-30.165334l-70.229334-70.272a21.333333 21.333333 0 0 0-30.208 30.208l70.272 70.229334-70.272 70.229333a21.333333 21.333333 0 0 0 30.208 30.208l70.229334-70.272 70.229333 70.272a21.333333 21.333333 0 0 0 30.208-30.208L776.832 746.666667l70.272-70.229334a21.333333 21.333333 0 0 0-30.208-30.208L746.666667 716.501333z'/></svg>"},null,8,["html"])],40,qf)],64)):t.createCommentVNode("",!0)],64)):t.createCommentVNode("",!0)],34),Z.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:t.normalizeClass(["ht-nav-btn ht-nav-right",{disabled:!K.value}]),title:t.unref(i)("ui.scrollRight"),"aria-label":t.unref(i)("ui.scrollRight"),onMousedown:b[35]||(b[35]=t.withModifiers(L=>qt(1),["prevent","stop"])),onTouchstart:b[36]||(b[36]=t.withModifiers(()=>{},["stop"])),onTouchend:b[37]||(b[37]=t.withModifiers(L=>nt(1,L),["stop"])),onClick:b[38]||(b[38]=t.withModifiers(()=>{},["prevent","stop"]))},[...b[103]||(b[103]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M4.5 3L7.5 6L4.5 9",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],42,Yf)):t.createCommentVNode("",!0)],14,tf)],46,ef)],8,["disabled"]))}}),Jf=["aria-label"],em={class:"tt-left"},tm=["disabled","title","aria-label"],nm=["disabled","title","aria-label"],om={key:0,class:"tt-sep"},rm=t.defineComponent({__name:"FixedToolbar",props:{rootEl:{},focusBlockId:{},hoverVisible:{type:Boolean},hoverSelectionRect:{},hoverBlockId:{},hoverBlockType:{},hoverBlockAttrs:{},plusMenuVisible:{type:Boolean},settingsMenuVisible:{type:Boolean},position:{}},emits:["openPlusMenu","openSettingsMenu","linkClick","hoverClose","toolbarInteracting"],setup(e,{emit:n}){const o=e,r=n;function l($){r("toolbarInteracting")}const{t:s}=en(),i=Yn(),c=fn(),a=t.inject(mi,t.ref(!1)),d=t.computed(()=>o.position==="top"?!1:o.position==="bottom"?!0:a.value);t.provide(Do,d);const f=t.inject($r,t.ref(null)),u=t.ref(null),h=$=>{var G;if(!$)return null;const V=$.nodeType===1?$:$.parentElement;if(!V)return null;const re=V.closest(".block-content");return re&&(((G=o.rootEl)==null?void 0:G.contains(re))??!1)?re:null};let p=null;const m=()=>{if(!u.value){p=null;return}try{const $=window.getSelection();if($&&$.rangeCount>0){const V=$.getRangeAt(0);if(!V.collapsed&&[$.anchorNode,$.focusNode,V.startContainer,V.endContainer].some(G=>h(G)!==null)){p=setTimeout(m,1500);return}}}catch{}u.value=null,p=null};t.watch([f,()=>o.hoverVisible,()=>o.hoverSelectionRect,()=>o.hoverBlockId,()=>o.hoverBlockType,()=>o.hoverBlockAttrs],()=>{const $=f.value;if(!($&&$.visible))if(o.hoverVisible){if(p&&(clearTimeout(p),p=null),o.hoverSelectionRect===null||o.hoverBlockId===null||o.hoverBlockType===null)return;u.value={visible:!0,selectionRect:o.hoverSelectionRect,blockId:o.hoverBlockId,blockType:o.hoverBlockType,blockAttrs:o.hoverBlockAttrs,rootEl:o.rootEl,onClose:()=>r("hoverClose"),onLinkClick:(V,re,G)=>r("linkClick",V,re,G)}}else u.value&&!p&&(p=setTimeout(m,1500))},{immediate:!0,flush:"sync"});const k=t.computed(()=>{const $=f.value;if($&&$.visible)return $;if(o.hoverVisible)return{visible:!0,selectionRect:o.hoverSelectionRect,blockId:o.hoverBlockId,blockType:o.hoverBlockType,blockAttrs:o.hoverBlockAttrs,rootEl:o.rootEl,onClose:()=>r("hoverClose"),onLinkClick:(re,G,ne)=>r("linkClick",re,G,ne)};if(u.value)return{...u.value,visible:!0};const V=o.focusBlockId;if(V){const re=c.getState().doc.blocks.get(V);return{visible:!0,selectionRect:null,blockId:V,blockType:(re==null?void 0:re.type)??null,blockAttrs:(re==null?void 0:re.attrs)??{},rootEl:o.rootEl,onClose:()=>r("hoverClose"),onLinkClick:(G,ne,Z)=>r("linkClick",G,ne,Z)}}return{visible:!1,selectionRect:null,blockId:null,blockType:null,blockAttrs:{},rootEl:o.rootEl}}),x=t.computed(()=>{const $=f.value;return $&&$.visible?$.blockId:o.hoverVisible&&o.hoverBlockId?o.hoverBlockId:o.focusBlockId}),D=t.ref(null),U=t.ref(null);function F(){const $=x.value,V=D.value;!$||!V||r("openPlusMenu",$,V)}function ee(){const $=x.value,V=U.value;!$||!V||r("openSettingsMenu",$,V)}return t.watch(()=>o.focusBlockId,($,V)=>{if($!==V&&u.value){const re=u.value;$!==null&&re.blockId!==$&&(u.value=null)}}),($,V)=>t.unref(i)?(t.openBlock(),t.createElementBlock("div",{key:0,ref:"toolbarRoot",class:t.normalizeClass(["fixed-toolbar",{"fixed-toolbar--bottom":d.value}]),role:"toolbar","aria-label":t.unref(s)("hoverToolbar.label"),onMousedownCapture:t.withModifiers(l,["prevent"])},[t.createElementVNode("div",em,[t.createElementVNode("button",{ref_key:"plusBtnEl",ref:D,class:t.normalizeClass(["tt-btn tt-plus",{disabled:!x.value,active:e.plusMenuVisible}]),disabled:!x.value,title:t.unref(s)("handle.plus.title"),"aria-label":t.unref(s)("handle.plus.ariaLabel"),onMousedown:t.withModifiers(F,["prevent","stop"]),onTouchstart:V[0]||(V[0]=t.withModifiers(()=>{},["stop"]))},[...V[3]||(V[3]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"18",height:"18","aria-hidden":"true"},[t.createElementVNode("path",{d:"M8 3.5V12.5M3.5 8H12.5",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round"})],-1)])],42,tm),t.createElementVNode("button",{ref_key:"handleBtnEl",ref:U,class:t.normalizeClass(["tt-btn tt-handle",{disabled:!x.value,active:e.settingsMenuVisible}]),disabled:!x.value,title:t.unref(s)("handle.grip.title"),"aria-label":t.unref(s)("handle.grip.ariaLabel"),onMousedown:t.withModifiers(ee,["prevent","stop"]),onTouchstart:V[1]||(V[1]=t.withModifiers(()=>{},["stop"]))},[...V[4]||(V[4]=[t.createStaticVNode('<svg viewBox="0 0 16 16" width="18" height="18" aria-hidden="true"><circle cx="5" cy="4" r="1.3" fill="currentColor"></circle><circle cx="11" cy="4" r="1.3" fill="currentColor"></circle><circle cx="5" cy="8" r="1.3" fill="currentColor"></circle><circle cx="11" cy="8" r="1.3" fill="currentColor"></circle><circle cx="5" cy="12" r="1.3" fill="currentColor"></circle><circle cx="11" cy="12" r="1.3" fill="currentColor"></circle></svg>',1)])],42,nm)]),k.value.visible?(t.openBlock(),t.createElementBlock("div",om)):t.createCommentVNode("",!0),t.createVNode(Qf,t.mergeProps({mobile:""},k.value,{onInteracting:V[2]||(V[2]=re=>r("toolbarInteracting"))}),null,16)],42,Jf)):t.createCommentVNode("",!0)}}),lm={class:"olm-label"},im={class:"olm-label"},sm={class:"olm-label"},ur=6,ns=t.defineComponent({__name:"OrderedListMenu",props:{visible:{type:Boolean},blockId:{},anchor:{},rootEl:{},canContinue:{type:Boolean},canStartNew:{type:Boolean},currentNumber:{}},emits:["continue","startNew","modify","close"],setup(e,{emit:n}){const o=e,r=n,{t:l}=en(),s=t.ref(null),i=t.ref({top:0,left:0,above:!1});t.watch([()=>o.visible,()=>o.anchor,s],async()=>{if(!o.visible||!o.anchor)return;await t.nextTick();const u=s.value;if(!u)return;const h=o.anchor.getBoundingClientRect(),p=u.getBoundingClientRect(),k=window.innerHeight-h.bottom-ur,x=h.top-ur,D=Math.max(p.height,10);let U=!1;k>=D?U=!1:x>=D?U=!0:U=x>k,i.value={top:U?h.top-(p.height+ur):h.bottom+ur,left:h.left,above:U}},{flush:"post",immediate:!0});const c=t.computed(()=>({top:`${i.value.top}px`,left:`${i.value.left}px`}));function a(){o.canContinue&&r("continue")}function d(){o.canStartNew&&r("startNew")}function f(){r("modify",o.currentNumber)}return(u,h)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[e.visible&&e.anchor&&e.rootEl?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"menuEl",ref:s,class:t.normalizeClass(["ordered-list-menu",{above:i.value.above}]),style:t.normalizeStyle(c.value),role:"menu",onMousedown:h[0]||(h[0]=t.withModifiers(()=>{},["prevent","stop"]))},[t.createElementVNode("button",{class:t.normalizeClass(["olm-item",{disabled:!e.canContinue}]),role:"menuitem",onClick:a},[h[1]||(h[1]=t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true",fill:"currentColor"},[t.createElementVNode("path",{d:"M2.27072 1012.662857c0 6.253714 5.046857 11.337143 11.337143 11.337143h226.267428a11.337143 11.337143 0 0 0 11.337143-11.337143v-52.114286a11.337143 11.337143 0 0 0-11.337143-11.337142H120.067291L181.031863 885.028571c14.701714-15.323429 26.770286-29.257143 36.205714-41.801142l0.036572-0.109715c9.508571-13.019429 16.859429-25.965714 21.796571-38.875428a110.445714 110.445714 0 0 0 7.570286-39.862857c0-20.955429-5.193143-39.789714-15.872-56.027429a101.302857 101.302857 0 0 0-43.081143-37.156571C169.621577 662.454857 148.849006 658.285714 125.809006 658.285714a136.777143 136.777143 0 0 0-56.137143 11.812572c-17.554286 7.68-32.548571 18.797714-44.8 33.426285a111.542857 111.542857 0 0 0-24.649143 51.309715 11.337143 11.337143 0 0 0 7.753143 13.056l53.833143 16.786285a11.300571 11.300571 0 0 0 14.189714-7.570285c4.315429-14.299429 10.898286-24.137143 19.163429-30.537143l0.182857-0.146286c8.411429-6.729143 18.358857-10.203429 30.464-10.203428 11.52 0 19.931429 3.291429 26.258285 9.216l0.146286 0.109714c6.253714 5.668571 9.801143 13.531429 9.801143 25.124571 0 6.656-1.499429 13.275429-4.754286 20.004572-3.291429 6.838857-9.508571 15.798857-19.163428 26.989714-9.508571 10.971429-23.222857 25.929143-41.289143 44.909714L5.379291 958.171429a11.337143 11.337143 0 0 0-3.108571 7.826285v46.665143zM512.003291 0v109.714286h329.142858a182.857143 182.857143 0 0 1 182.857142 182.857143v438.857142a182.857143 182.857143 0 0 1-182.857142 182.857143H402.289006a36.571429 36.571429 0 1 1 0-73.142857h438.857143a109.714286 109.714286 0 0 0 109.714285-109.714286V292.571429a109.714286 109.714286 0 0 0-109.714285-109.714286h-329.142858v109.714286L292.57472 146.285714l219.428571-146.285714zM108.913006 365.714286a11.483429 11.483429 0 0 1-11.52-11.483429V76.361143H42.791863a11.483429 11.483429 0 0 1-11.52-11.483429V11.483429C31.235291 5.156571 36.391863 0 42.791863 0h128.621714C177.703863 0 182.860434 5.12 182.860434 11.483429v342.747428c0 6.326857-5.12 11.483429-11.483428 11.483429H108.913006z"})],-1)),t.createElementVNode("span",lm,t.toDisplayString(t.unref(l)("ol.continue")),1)],2),t.createElementVNode("button",{class:t.normalizeClass(["olm-item",{disabled:!e.canStartNew}]),role:"menuitem",onClick:d},[h[2]||(h[2]=t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true",fill:"currentColor"},[t.createElementVNode("path",{d:"M128 324.288V162.112l-17.088 17.088c-17.024 17.088-42.624 8.512-59.712-8.512C34.112 153.6 42.688 128 59.712 119.488L128 76.8c25.6-17.088 51.2-17.088 68.288 8.512 8.512 8.576 8.512 17.088 8.512 25.6v204.8c0 25.6-17.088 42.688-34.112 42.688C153.6 358.4 128 341.312 128 324.288zM170.688 469.312c-25.6 0-42.688 25.6-42.688 42.688v213.312H59.712c-8.512 0-17.024 8.576-17.024 25.6v8.576L153.6 955.712c8.512 8.576 17.088 17.088 25.6 8.576l8.512-8.576 110.976-196.224c8.512-8.576 0-25.6-8.576-25.6h-76.8V512c0-17.088-17.024-42.688-42.624-42.688zM426.688 810.688c-25.6 0-42.688 17.024-42.688 42.624s17.088 42.688 42.688 42.688h512c25.6 0 42.624-17.088 42.624-42.688s-17.024-42.624-42.624-42.624h-512zM384 512c0-25.6 17.088-42.688 42.688-42.688h512c25.6 0 42.624 17.088 42.624 42.688s-17.024 42.688-42.624 42.688h-512C401.088 554.688 384 537.6 384 512zM426.688 128c-25.6 0-42.688 17.088-42.688 42.688s17.088 42.624 42.688 42.624h512c25.6 0 42.624-17.024 42.624-42.624S964.288 128 938.688 128h-512z"})],-1)),t.createElementVNode("span",im,t.toDisplayString(t.unref(l)("ol.startNew")),1)],2),t.createElementVNode("button",{class:"olm-item",role:"menuitem",onClick:f},[h[3]||(h[3]=t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"15",height:"15","aria-hidden":"true",fill:"currentColor"},[t.createElementVNode("path",{d:"M45.421714 279.771429c0 4.388571 3.547429 7.936 7.899429 7.936H96.182857c4.388571 0 7.899429-3.547429 7.899429-7.899429V44.470857A7.899429 7.899429 0 0 0 96.182857 36.571429H7.899429A7.899429 7.899429 0 0 0 0 44.470857v36.644572c0 4.388571 3.547429 7.899429 7.899429 7.899428h37.522285V279.771429z m-32.182857 326.729142a7.899429 7.899429 0 0 1-7.899428-7.899428v-32.548572c0-2.011429 0.804571-3.986286 2.194285-5.449142l63.707429-66.633143c12.617143-13.238857 22.162286-23.661714 28.781714-31.305143 6.765714-7.789714 11.081143-14.043429 13.385143-18.797714a31.817143 31.817143 0 0 0 3.291429-13.933715c0-8.045714-2.450286-13.568-6.838858-17.554285l-0.109714-0.073143c-4.388571-4.096-10.24-6.4-18.285714-6.4a32.731429 32.731429 0 0 0-21.211429 7.131428l-0.146285 0.073143c-5.741714 4.461714-10.349714 11.337143-13.348572 21.321143a7.899429 7.899429 0 0 1-9.874286 5.229714l-37.558857-11.702857a7.899429 7.899429 0 0 1-5.376-9.106286c2.742857-13.641143 8.484571-25.6 17.188572-35.730285a84.114286 84.114286 0 0 1 31.195428-23.296c12.397714-5.485714 25.453714-8.228571 39.131429-8.228572 16.091429 0 30.537143 2.889143 43.154286 8.96a69.595429 69.595429 0 0 1 41.069714 64.950857c0 9.435429-1.755429 18.688-5.229714 27.794286a118.198857 118.198857 0 0 1-15.213715 27.062857l-0.036571 0.109715c-6.582857 8.740571-14.994286 18.468571-25.234286 29.110857L87.515429 554.422857h83.492571c4.388571 0 7.899429 3.510857 7.899429 7.899429v36.315428c0 4.388571-3.547429 7.899429-7.899429 7.899429H13.238857z m38.217143 354.486858a94.939429 94.939429 0 0 1-31.963429-22.052572l-0.109714-0.109714a79.030857 79.030857 0 0 1-18.212571-34.706286 7.899429 7.899429 0 0 1 5.010285-9.325714l37.558858-13.275429c4.096-1.462857 8.594286 0.731429 10.057142 4.827429 3.328 9.508571 8.265143 16.237714 14.482286 20.845714 6.326857 4.388571 13.824 6.729143 22.857143 6.729143 7.460571 0 13.421714-1.389714 18.176-3.84l0.073143-0.073143a27.721143 27.721143 0 0 0 11.593143-10.569143 33.938286 33.938286 0 0 0 4.242285-17.408 30.573714 30.573714 0 0 0-4.132571-16.64l-0.182857-0.292571A25.673143 25.673143 0 0 0 109.714286 854.637714a41.691429 41.691429 0 0 0-18.870857-3.913143 59.465143 59.465143 0 0 0-15.213715 2.194286 33.28 33.28 0 0 0-5.229714 2.048 7.862857 7.862857 0 0 1-10.642286-3.657143l-9.801143-20.553143a7.899429 7.899429 0 0 1 1.206858-8.594285l49.371428-56.393143H22.089143a7.899429 7.899429 0 0 1-7.862857-7.899429v-36.315428c0-4.388571 3.510857-7.899429 7.862857-7.899429h144.164571c4.388571 0 7.899429 3.547429 7.899429 7.899429v33.792a7.899429 7.899429 0 0 1-1.901714 5.12L132.388571 807.131429a76.909714 76.909714 0 0 1 14.043429 6.070857c11.739429 6.582857 20.992 15.725714 27.611429 27.318857 6.656 11.702857 9.874286 25.197714 9.874285 40.228571 0 16.530286-4.022857 31.634286-12.178285 45.165715a86.930286 86.930286 0 0 1-33.28 31.268571 97.755429 97.755429 0 0 1-47.323429 11.373714c-13.787429 0-26.989714-2.486857-39.497143-7.497143l-0.182857-0.073142zM292.571429 841.142857a36.571429 36.571429 0 1 0 0 73.142857h694.857142a36.571429 36.571429 0 1 0 0-73.142857H292.571429zM986.185143 138.605714a52.516571 52.516571 0 0 0-3.254857-10.532571 112.64 112.64 0 0 0-19.712-28.818286c-8.484571-9.216-16.237714-15.652571-23.222857-19.309714a72.045714 72.045714 0 0 0-11.702858-4.534857A55.515429 55.515429 0 0 0 914.285714 73.179429a43.776 43.776 0 0 0-29.184 9.764571c-3.657143 2.998857-8.228571 7.094857-13.714285 12.288-5.485714 5.193143-10.24 9.618286-14.262858 13.275429l93.366858 93.769142c2.340571-2.011429 4.827429-4.315429 7.497142-7.021714 2.304-2.340571 5.083429-5.010286 8.228572-8.009143 3.145143-2.998857 6.729143-6.509714 10.715428-10.532571 3.657143-4.022857 6.326857-8.192 8.009143-12.544A36.205714 36.205714 0 0 0 987.428571 151.149714c0-4.352-0.402286-8.521143-1.243428-12.544zM352.073143 614.509714c-7.314286 7.533714-11.958857 12.288-13.970286 14.262857a82.578286 82.578286 0 0 0-10.715428 12.8c-2.523429 3.876571-4.754286 8.118857-6.765715 12.8a111.798857 111.798857 0 0 0-6.473143 16.566858c-2.669714 8.009143-5.412571 16.786286-8.228571 26.331428-2.852571 9.508571-5.485714 18.688-8.009143 27.574857a169.764571 169.764571 0 0 0-4.754286 20.297143c-1.316571 8.704-0.475429 14.884571 2.523429 18.541714 2.998857 3.657143 8.996571 5.010286 17.956571 4.022858 4.352-0.658286 10.898286-2.194286 19.748572-4.498286a686.957714 686.957714 0 0 0 56.137143-18.066286c8.996571-3.328 15.798857-6.217143 20.48-8.521143 4.644571-2.011429 9.142857-4.681143 13.458285-8.045714a215.954286 215.954286 0 0 0 23.954286-21.577143c6.985143-6.985143 15.798857-15.945143 26.441143-26.806857 10.678857-10.861714 22.674286-22.820571 35.949714-35.84l39.936-40.594286 363.300572-363.885714-93.330286-94.244571-363.300571 363.849142-40.448 40.594286-36.425143 36.608c-10.971429 11.044571-20.114286 20.297143-27.428572 27.830857z"})],-1)),t.createElementVNode("span",sm,t.toDisplayString(t.unref(l)("ol.modify")),1)])],38)):t.createCommentVNode("",!0)]))}}),cm=["aria-label"],am=["aria-label"],dm={class:"np-ok",type:"submit"},fr=6,os=t.defineComponent({__name:"NumberPicker",props:{visible:{type:Boolean},initialValue:{},anchor:{},rootEl:{}},emits:["confirm","close"],setup(e,{emit:n}){const o=e,r=n,{t:l}=en(),s=t.ref(null),i=t.ref(o.initialValue),c=t.ref({top:0,left:0});t.watch([()=>o.visible,()=>o.anchor,()=>o.initialValue],async()=>{if(!o.visible||!o.anchor)return;i.value=o.initialValue,await t.nextTick();const f=o.anchor.getBoundingClientRect(),u=window.innerHeight,h=52;let p=!1;u-f.bottom-fr<h&&f.top-fr>h&&(p=!0),c.value={top:p?f.top-(h+fr):f.bottom+fr,left:f.left},t.nextTick(()=>{var m,k;(m=s.value)==null||m.focus(),(k=s.value)==null||k.select()})},{flush:"post",immediate:!0});const a=t.computed(()=>({top:`${c.value.top}px`,left:`${c.value.left}px`}));function d(){let f=i.value;Number.isFinite(f)||(f=o.initialValue),f=Math.max(1,Math.floor(f)),r("confirm",f)}return(f,u)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[e.visible&&e.anchor&&e.rootEl?(t.openBlock(),t.createElementBlock("div",{key:0,class:"number-picker",style:t.normalizeStyle(a.value),role:"dialog","aria-label":t.unref(l)("numberPicker.title"),onMousedown:u[2]||(u[2]=t.withModifiers(()=>{},["stop"])),onTouchstart:u[3]||(u[3]=t.withModifiers(()=>{},["stop"]))},[t.createElementVNode("form",{class:"np-form",onSubmit:t.withModifiers(d,["prevent"])},[t.withDirectives(t.createElementVNode("input",{ref_key:"inputEl",ref:s,"onUpdate:modelValue":u[0]||(u[0]=h=>i.value=h),type:"number",class:"np-input",min:"1",step:"1","aria-label":t.unref(l)("numberPicker.inputLabel"),onKeydown:u[1]||(u[1]=t.withKeys(h=>r("close"),["escape"]))},null,40,am),[[t.vModelText,i.value,void 0,{number:!0}]]),t.createElementVNode("button",dm,t.toDisplayString(t.unref(l)("numberPicker.confirm")),1)],32)],44,cm)):t.createCommentVNode("",!0)]))}}),um=["aria-label"],fm={key:0,class:"clp-custom"},mm=["placeholder","aria-label"],pm={class:"clp-actions"},hm={class:"clp-ok",type:"submit"},gm=["aria-label"],bm=["onClick"],km={class:"clp-item-name"},ym={key:0,class:"clp-item-check","aria-hidden":"true"},wm={class:"clp-item-name"},Em=["aria-label"],io=6,rs=200,vm=120,Cm=360,Tm=t.defineComponent({__name:"CodeLangPicker",props:{visible:{type:Boolean},initialValue:{},anchor:{},rootEl:{}},emits:["confirm","close"],setup(e,{emit:n}){const o=e,r=n,{t:l}=en(),s=["plain","javascript","typescript","python","java","c","cpp","csharp","go","rust","ruby","php","swift","kotlin","html","css","json","xml","yaml","markdown","lua","bash","shell","powershell","cmd","bat","sql","dart"],i=t.ref(null),c=t.ref(null),a=t.ref(null),d=t.ref(!1),f=t.ref(""),u=t.ref(o.initialValue),h=t.ref({top:0,left:0,above:!1,maxHeight:360}),p=t.ref(!1),m=t.ref(!1);function k(ne){return ne==="plain"?l("codeLang.plain"):ne}function x(){if(!o.visible||!o.anchor||!o.rootEl)return;const ne=i.value;if(!ne)return;const Z=o.anchor.getBoundingClientRect(),S=window.innerHeight,K=Math.floor(S-Z.bottom-io),_=Math.floor(Z.top-io),O=ne.scrollHeight;let M=!1;o.rootEl.getBoundingClientRect().bottom-Z.bottom<rs&&_>rs&&(M=!0);let A,W;M?(A=!0,W=_):O<=K?(A=!1,W=K):_>K?(A=!0,W=_):(A=!1,W=K);const me=Math.max(vm,Math.min(W,Cm)),le=document.documentElement.clientWidth,he=Math.max(ne.clientWidth,200),ae=Math.max(io,Math.min(le-he-io,Z.left)),ie=A?Math.max(io,Z.top-io-Math.min(O,me)):Z.bottom+io;h.value={top:ie,left:ae,above:A,maxHeight:me},t.nextTick(D)}t.watch([()=>o.visible,()=>o.anchor,()=>o.initialValue],async()=>{o.visible&&(d.value=!1,u.value=o.initialValue??"plain",f.value=u.value==="plain"?"":u.value,await t.nextTick(),x())},{flush:"post",immediate:!0});function D(){const ne=a.value;ne&&(p.value=ne.scrollTop>1,m.value=ne.scrollTop+ne.clientHeight<ne.scrollHeight-1)}function U(){const ne=a.value;ne&&(ne.scrollTop-=ne.clientHeight*.8)}function F(){const ne=a.value;ne&&(ne.scrollTop+=ne.clientHeight*.8)}dr(a,D);function ee(){d.value=!0,f.value=u.value==="plain"?"":u.value,t.nextTick(()=>{var ne,Z;(ne=c.value)==null||ne.focus(),(Z=c.value)==null||Z.select(),x()})}function $(){d.value=!1,t.nextTick(x)}function V(){const ne=f.value.replace(/[^a-zA-Z]/g,"").slice(0,20);ne!==f.value&&(f.value=ne)}function re(){const ne=(f.value??"").replace(/[^a-zA-Z]/g,"").slice(0,20);r("confirm",ne.length===0?"plain":ne)}const G=t.computed(()=>({top:`${h.value.top}px`,left:`${h.value.left}px`,maxHeight:`${h.value.maxHeight}px`}));return(ne,Z)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[e.visible&&e.anchor&&e.rootEl?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"menuEl",ref:i,class:t.normalizeClass(["code-lang-picker",{above:h.value.above}]),style:t.normalizeStyle(G.value),role:"menu","aria-label":t.unref(l)("codeLang.title"),onMousedown:Z[1]||(Z[1]=t.withModifiers(()=>{},["stop"])),onTouchstart:Z[2]||(Z[2]=t.withModifiers(()=>{},["stop"])),onWheel:Z[3]||(Z[3]=t.withModifiers(()=>{},["prevent"])),onTouchmove:Z[4]||(Z[4]=t.withModifiers(()=>{},["prevent"]))},[d.value?(t.openBlock(),t.createElementBlock("div",fm,[t.createElementVNode("form",{class:"clp-form",onSubmit:t.withModifiers(re,["prevent"])},[t.withDirectives(t.createElementVNode("input",{ref_key:"inputEl",ref:c,"onUpdate:modelValue":Z[0]||(Z[0]=S=>f.value=S),type:"text",class:"clp-input",maxlength:"20",placeholder:t.unref(l)("codeLang.placeholder"),"aria-label":t.unref(l)("codeLang.inputLabel"),autocomplete:"off",spellcheck:"false",onInput:V,onKeydown:t.withKeys($,["escape"])},null,40,mm),[[t.vModelText,f.value]]),t.createElementVNode("div",pm,[t.createElementVNode("button",hm,t.toDisplayString(t.unref(l)("codeLang.confirm")),1),t.createElementVNode("button",{class:"clp-cancel",type:"button",onClick:$},t.toDisplayString(t.unref(l)("codeLang.cancel")),1)])],32)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[p.value?(t.openBlock(),t.createElementBlock("button",{key:0,class:"menu-scroll-btn menu-scroll-up",type:"button","aria-label":t.unref(l)("ui.scrollUp"),onMousedown:t.withModifiers(U,["prevent"])},[...Z[5]||(Z[5]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 7.5L6 4.5L9 7.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,gm)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"scrollEl",ref:a,class:"clp-list",onScroll:D},[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(s,S=>t.createElementVNode("button",{key:S,class:t.normalizeClass(["clp-item",{active:S===u.value}]),role:"menuitem",onClick:K=>r("confirm",S)},[t.createElementVNode("span",km,t.toDisplayString(k(S)),1),S===u.value?(t.openBlock(),t.createElementBlock("span",ym,"✓")):t.createCommentVNode("",!0)],10,bm)),64)),t.createElementVNode("button",{class:"clp-item clp-item-custom",role:"menuitem",onClick:ee},[t.createElementVNode("span",wm,t.toDisplayString(t.unref(l)("codeLang.custom")),1)])],544),m.value?(t.openBlock(),t.createElementBlock("button",{key:1,class:"menu-scroll-btn menu-scroll-down",type:"button","aria-label":t.unref(l)("ui.scrollDown"),onMousedown:t.withModifiers(F,["prevent"])},[...Z[6]||(Z[6]=[t.createElementVNode("svg",{viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Em)):t.createCommentVNode("",!0)],64))],46,um)):t.createCommentVNode("",!0)]))}}),_m=["aria-label"],xm={key:0,class:"link-popover-view"},Mm=["href","title"],Nm={class:"link-popover-actions"},Sm=["title","aria-label"],Am=["title","aria-label"],Im=["title","aria-label"],Bm=["title","aria-label"],Rm={key:1,class:"link-popover-edit"},Lm=["placeholder"],Om={key:0,class:"link-popover-error",role:"alert"},Dm=["placeholder"],$m={class:"link-popover-edit-actions"},Pm=["title"],Hm=["title"],ls=t.defineComponent({__name:"LinkPopover",props:{visible:{type:Boolean},anchorRect:{},blockId:{},from:{},to:{},href:{},text:{},initialMode:{},showTextInput:{type:Boolean},onSaveLink:{type:Function},onRemoveLinkMark:{type:Function},readonly:{type:Boolean}},emits:["close"],setup(e,{expose:n,emit:o}){const r=e,l=o,{t:s}=en(),i=fn(),c=t.ref(null),a=t.ref(null),d=t.ref(!1),f=t.ref(!1),u=t.ref("view"),h=t.ref(""),p=t.ref(""),m=t.ref({top:0,left:0}),k=t.ref(""),x=t.computed(()=>r.showTextInput??!1),D=t.computed(()=>u.value==="edit"?h.value:r.href),U=t.computed(()=>{const _=to(D.value);return Pn(_)??"#"}),F=t.computed(()=>{const _=D.value;return _?_.length>60?_.slice(0,57)+"...":_:s("link.emptyUrl")}),ee=t.computed(()=>({top:`${m.value.top}px`,left:`${m.value.left}px`,visibility:f.value?"visible":"hidden"}));async function $(){if(!r.visible||!r.anchorRect||!c.value)return;await t.nextTick();const O=c.value.getBoundingClientRect(),M=8,E=document.documentElement.clientWidth,A=document.documentElement.clientHeight-r.anchorRect.bottom-M,W=r.anchorRect.top-M,le=A<O.height+M&&W>A?Math.max(M,r.anchorRect.top-O.height-M):r.anchorRect.bottom+M,he=r.anchorRect.left+(r.anchorRect.width-O.width)/2,ae=Math.max(M,E-O.width-M),ie=Math.max(M,Math.min(ae,he));m.value={top:le,left:ie},f.value=!0}t.watch(()=>r.visible,_=>{_?(d.value=!0,u.value=r.readonly?"view":r.initialMode??(r.href?"view":"edit"),h.value=r.href,p.value=r.text,f.value=!1,t.nextTick(()=>{var O,M;$(),u.value==="edit"&&((O=a.value)==null||O.focus(),(M=a.value)==null||M.select())})):(f.value=!1,setTimeout(()=>{r.visible||(d.value=!1)},200))},{immediate:!0}),t.watch(()=>r.anchorRect,()=>{r.visible&&$()});function V(){r.readonly||(u.value="edit",h.value=r.href,p.value=r.text,k.value="",t.nextTick(()=>{var _,O;(_=a.value)==null||_.focus(),(O=a.value)==null||O.select()}))}function re(){const _=h.value;if(!_.trim()){k.value="";return}const O=to(_);Pn(O)?k.value="":k.value=s("link.invalidUrl")}function G(){var E,N,A;if(!r.blockId&&!r.onSaveLink)return;const _=to(h.value),O=Pn(_);if(!O){k.value=s("link.invalidUrl"),(E=a.value)==null||E.focus();return}k.value="";const M=x.value&&p.value!==r.text;r.onSaveLink?r.onSaveLink(O,M?p.value:void 0):(A=(N=i.commands).setLink)==null||A.call(N,{id:r.blockId,href:O,from:r.from,to:r.to,text:M?p.value:void 0}),r.href?(u.value="view",t.nextTick(()=>{$()})):l("close")}function ne(){r.href?(u.value="view",h.value=r.href,p.value=r.text):l("close")}function Z(){var _,O;!r.blockId&&!r.onRemoveLinkMark||(r.onRemoveLinkMark?r.onRemoveLinkMark():(O=(_=i.commands).unsetLink)==null||O.call(_,{id:r.blockId,from:r.from,to:r.to}),l("close"))}function S(){var O;const _=to(r.href);_&&((O=navigator.clipboard)==null||O.writeText(_))}function K(){const _=to(r.href),O=Pn(_);O&&O!=="#"&&window.open(O,"_blank","noopener,noreferrer")}return t.onBeforeUnmount(()=>{d.value=!1}),n({isEditing:()=>u.value==="edit",save:G,cancel:ne}),(_,O)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[d.value?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"popoverEl",ref:c,class:t.normalizeClass(["link-popover",{visible:f.value}]),style:t.normalizeStyle(ee.value),role:"dialog","aria-label":t.unref(s)("link.popoverLabel"),onMousedown:O[2]||(O[2]=t.withModifiers(()=>{},["stop"])),onTouchstart:O[3]||(O[3]=t.withModifiers(()=>{},["stop"]))},[u.value==="view"?(t.openBlock(),t.createElementBlock("div",xm,[t.createElementVNode("a",{href:U.value,target:"_blank",rel:"noopener noreferrer",class:"link-popover-url",title:D.value,onClick:K},t.toDisplayString(F.value),9,Mm),t.createElementVNode("div",Nm,[t.createElementVNode("button",{class:"link-popover-btn",title:t.unref(s)("link.open"),"aria-label":t.unref(s)("link.open"),onMousedown:t.withModifiers(K,["prevent","stop"])},[...O[4]||(O[4]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},[t.createElementVNode("path",{d:"M6 3H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h7a2 2 0 0 0 2-2v-2",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round","stroke-linejoin":"round"}),t.createElementVNode("path",{d:"M9 3h4v4M13 3L7 9",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Sm),t.createElementVNode("button",{class:"link-popover-btn",title:t.unref(s)("link.copy"),"aria-label":t.unref(s)("link.copy"),onMousedown:t.withModifiers(S,["prevent","stop"])},[...O[5]||(O[5]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},[t.createElementVNode("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1.5",fill:"none",stroke:"currentColor","stroke-width":"1.3"}),t.createElementVNode("path",{d:"M3 10.5V3.5C3 2.67 3.67 2 4.5 2H10",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round"})],-1)])],40,Am),e.readonly?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("button",{key:0,class:"link-popover-btn",title:t.unref(s)("link.edit"),"aria-label":t.unref(s)("link.edit"),onMousedown:t.withModifiers(V,["prevent","stop"])},[...O[6]||(O[6]=[t.createElementVNode("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},[t.createElementVNode("path",{d:"M11.5 2.5l2 2L6 12l-2.5.5L4 10l7.5-7.5z",fill:"none",stroke:"currentColor","stroke-width":"1.3","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,Im)),e.readonly?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("button",{key:1,class:"link-popover-btn link-popover-danger",title:t.unref(s)("link.remove"),"aria-label":t.unref(s)("link.remove"),onMousedown:t.withModifiers(Z,["prevent","stop"])},[...O[7]||(O[7]=[t.createElementVNode("svg",{viewBox:"0 0 1024 1024",width:"14",height:"14","aria-hidden":"true"},[t.createElementVNode("path",{d:"M394.666667 213.333333a32 32 0 0 1 4.693333 63.658667l-4.693333 0.341333H298.666667a149.333333 149.333333 0 0 0-8.789334 298.410667L298.666667 576h96a32 32 0 0 1 4.693333 63.658667L394.666667 640H298.666667a213.333333 213.333333 0 0 1-10.666667-426.410667L298.666667 213.333333h96zM725.333333 213.333333a213.333333 213.333333 0 0 1 189.013334 312.405334 277.162667 277.162667 0 0 0-55.210667-32.64 149.333333 149.333333 0 0 0-125.013333-215.466667L725.333333 277.290667h-96a32 32 0 0 1-4.693333-63.658667L629.333333 213.333333H725.333333zM298.666667 394.666667h426.666666a32 32 0 0 1 4.352 63.701333L725.333333 458.666667H298.666667a32 32 0 0 1-4.352-63.701334L298.666667 394.666667z m682.666666 352a234.666667 234.666667 0 1 1-469.333333 0 234.666667 234.666667 0 0 1 469.333333 0z m-304.896-100.437334a21.333333 21.333333 0 0 0-30.208 30.208l70.272 70.229334-70.272 70.229333a21.333333 21.333333 0 0 0 30.208 30.208l70.229334-70.272 70.229333 70.272a21.333333 21.333333 0 0 0 30.208-30.208L776.832 746.666667l70.272-70.229334a21.333333 21.333333 0 0 0-30.208-30.208L746.666667 716.501333l-70.229334-70.272z",fill:"currentColor"})],-1)])],40,Bm))])])):(t.openBlock(),t.createElementBlock("div",Rm,[t.withDirectives(t.createElementVNode("input",{ref_key:"urlInputEl",ref:a,"onUpdate:modelValue":O[0]||(O[0]=M=>h.value=M),class:t.normalizeClass(["link-popover-input",{"link-popover-input-error":k.value}]),type:"text",placeholder:t.unref(s)("link.urlPlaceholder"),onKeydown:[t.withKeys(G,["enter"]),t.withKeys(ne,["escape"])],onInput:re},null,42,Lm),[[t.vModelText,h.value]]),k.value?(t.openBlock(),t.createElementBlock("div",Om,t.toDisplayString(k.value),1)):t.createCommentVNode("",!0),x.value?t.withDirectives((t.openBlock(),t.createElementBlock("input",{key:1,"onUpdate:modelValue":O[1]||(O[1]=M=>p.value=M),class:"link-popover-input",type:"text",placeholder:t.unref(s)("link.textPlaceholder"),onKeydown:[t.withKeys(G,["enter"]),t.withKeys(ne,["escape"])]},null,40,Dm)),[[t.vModelText,p.value]]):t.createCommentVNode("",!0),t.createElementVNode("div",$m,[t.createElementVNode("button",{class:"link-popover-btn link-popover-save",title:t.unref(s)("link.save"),onMousedown:t.withModifiers(G,["prevent","stop"])},t.toDisplayString(t.unref(s)("link.save")),41,Pm),t.createElementVNode("button",{class:"link-popover-btn link-popover-cancel",title:t.unref(s)("link.cancel"),onMousedown:t.withModifiers(ne,["prevent","stop"])},t.toDisplayString(t.unref(s)("link.cancel")),41,Hm)])]))],46,_m)):t.createCommentVNode("",!0)]))}}),Vm={default:null,validate:e=>e==null?!0:Number.isInteger(e)&&e>=1};function is(e,n){const o=mo(e,n),r=sn(e,n);if(r<0)return 1;const l=e.blocks.get(n);if(!l)return 1;const s=l.attrs.startNumber;if(typeof s=="number")return s;let i=null,c=0;for(let a=r-1;a>=0;a--){const d=e.blocks.get(o[a]);if(!d||d.type!=="orderedList")break;const f=d.attrs.startNumber;if(typeof f=="number"){i=f;break}c++}return i!==null?i+c+1:1+c}const Um=t.defineComponent({name:"OrderedListBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){const n=fn(),o=Yn(),r=t.ref(null),l=t.useAttrs(),s={...typeof l.onLinkClick=="function"?{onLinkClick:l.onLinkClick}:{},...typeof l.onSlashTrigger=="function"?{onSlashTrigger:l.onSlashTrigger}:{},...typeof l.onInputChanged=="function"?{onInputChanged:l.onInputChanged}:{}},i=t.ref(0),c=n.subscribe(()=>{i.value++});return t.onBeforeUnmount(c),()=>{i.value;const a=n.getState().doc,d=is(a,e.block.id),f=t.h("div",{ref:r,class:"ol-marker","data-ol-number":String(d),onMousedown:k=>{k.preventDefault(),k.stopPropagation()},onClick:k=>{if(k.stopPropagation(),!o.value)return;const x=new CustomEvent("ordered-list-marker-click",{bubbles:!0,detail:{blockId:e.block.id,anchor:r.value}});k.currentTarget.dispatchEvent(x)}},[`${d}.`]),u=En(e.block.attrs),h=u.filter(k=>k.startsWith("be-indent-")),p=u.filter(k=>!k.startsWith("be-indent-")),m=t.h(Un,{block:e.block,placeholder:e.placeholder,class:["block-ordered-list-content",...p],...s});return t.h("div",{class:["block-ordered-list-wrapper",...h],"data-block-type":"orderedList"},[f,m])}}}),zm={name:"orderedList",schema:{type:"orderedList",content:"text",nestable:!0,listLike:!0,attrs:{...tn,startNumber:Vm}},renderer:{component:Um},slashCommands:[{id:"ordered-list",title:"slash.orderedList.title",keywords:["list","numbered","ordered","有序列表","编号列表","ol","1"],description:"slash.orderedList.description",icon:cl,command:"convertBlock",category:"list",args:()=>({id:"__currentBlock__",type:"orderedList"})}],inputRules:[{name:"ordered-1-dot",pattern:/^1\. $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"orderedList",__stripPrefix:3})}]},Fm=t.defineComponent({name:"ParagraphBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){return()=>t.h(Un,{block:e.block,placeholder:e.placeholder,class:["block-paragraph",...En(e.block.attrs)]})}}),ss={name:"paragraph",schema:{type:"paragraph",content:"text",nestable:!0,attrs:{...tn}},renderer:{component:Fm},slashCommands:[{id:"paragraph",title:"slash.paragraph.title",keywords:["text","paragraph","normal","正文","段落"],description:"slash.paragraph.description",icon:el,command:"convertBlock",category:"basic",args:e=>({id:"__currentBlock__",type:"paragraph"})}],inputRules:[{name:"paragraph-noop",pattern:/^$/,command:"setText",args:e=>({id:"__currentBlock__",content:[]})}]},Km=t.defineComponent({name:"HeadingBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){return()=>{const n=e.block.attrs.level??1;return t.h(Un,{block:e.block,placeholder:e.placeholder,class:["block-heading",`block-heading-h${n}`,...En(e.block.attrs)]})}}});function yo(e){const n="#".repeat(e);return{name:`heading-h${e}`,pattern:new RegExp(`^${n} $`),command:"convertBlock",args:()=>({id:"__currentBlock__",type:"heading",attrs:{level:e},__stripPrefix:e+1})}}const wo=(e,n,o,r,l,s)=>({id:e,title:o,keywords:s,description:r,icon:l,command:"convertBlock",category:"basic",args:()=>({id:"__currentBlock__",type:"heading",attrs:{level:n}})}),cs={name:"heading",schema:{type:"heading",content:"text",nestable:!0,attrs:{level:{default:1,validate:e=>typeof e=="number"&&e>=1&&e<=6},...tn}},renderer:{component:Km},slashCommands:[wo("heading-1",1,"slash.heading1.title","slash.heading1.description",tl,["h1","标题1","大标题","title"]),wo("heading-2",2,"slash.heading2.title","slash.heading2.description",nl,["h2","标题2","小标题"]),wo("heading-3",3,"slash.heading3.title","slash.heading3.description",ol,["h3","标题3","section"]),wo("heading-4",4,"slash.heading4.title","slash.heading4.description",rl,["h4","标题4"]),wo("heading-5",5,"slash.heading5.title","slash.heading5.description",ll,["h5","标题5"]),wo("heading-6",6,"slash.heading6.title","slash.heading6.description",il,["h6","标题6"])],inputRules:[yo(1),yo(2),yo(3),yo(4),yo(5),yo(6)]},as={name:"default-keymap",keymap:[{key:"Enter",command:"enter"},{key:"Backspace",command:"backspace"},{key:"Delete",command:"backspace"},{key:"Tab",command:"indentBlock"},{key:"Shift-Tab",command:"outdentBlock"},{key:"Mod-a",command:"selectAll"},{key:"ArrowUp",command:"moveToPreviousBlock"},{key:"ArrowDown",command:"moveToNextBlock"}]},ds={name:"history-keymap",keymap:[{key:"Mod-z",command:"undo"},{key:"Mod-Shift-z",command:"redo"},{key:"Mod-y",command:"redo"}]},Wm=t.defineComponent({name:"BulletListBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){return()=>t.h(Un,{block:e.block,placeholder:e.placeholder,class:["block-bullet-list",...En(e.block.attrs)]})}}),Gm={name:"bulletList",schema:{type:"bulletList",content:"text",nestable:!0,listLike:!0,attrs:{...tn}},renderer:{component:Wm},slashCommands:[{id:"bullet-list",title:"slash.bulletList.title",keywords:["list","bullet","unordered","项目符号","无序列表","ul","-","*"],description:"slash.bulletList.description",icon:sl,command:"convertBlock",category:"list",args:()=>({id:"__currentBlock__",type:"bulletList"})}],inputRules:[{name:"bullet-dash",pattern:/^- $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"bulletList",__stripPrefix:2})},{name:"bullet-star",pattern:/^\* $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"bulletList",__stripPrefix:2})}]},qm=t.defineComponent({name:"TodoListBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){const n=fn(),o=t.useAttrs(),r={...typeof o.onLinkClick=="function"?{onLinkClick:o.onLinkClick}:{},...typeof o.onSlashTrigger=="function"?{onSlashTrigger:o.onSlashTrigger}:{},...typeof o.onInputChanged=="function"?{onInputChanged:o.onInputChanged}:{}};function l(s){var c,a;const i=s.target;(a=(c=n.commands).setAttrs)==null||a.call(c,{id:e.block.id,attrs:{...e.block.attrs,checked:i.checked}})}return()=>{const s=!!e.block.attrs.checked,i=En(e.block.attrs),c=i.filter(f=>f.startsWith("be-indent-")),a=i.filter(f=>!f.startsWith("be-indent-")),d=["block-todo-list",s?"todo-checked":"todo-unchecked",...a];return t.h("div",{class:["block-todo-wrapper",...c]},[t.h("input",{type:"checkbox",class:"block-todo-checkbox",checked:s,onchange:l}),t.h(Un,{block:e.block,placeholder:e.placeholder,class:d,...r})])}}}),Ym={name:"todoList",schema:{type:"todoList",content:"text",nestable:!0,listLike:!0,attrs:{...tn,checked:{default:!1,validate:e=>typeof e=="boolean"}}},renderer:{component:qm},slashCommands:[{id:"todo-list",title:"slash.todoList.title",keywords:["todo","task","checkbox","待办","任务","复选框","[]","[ ]"],description:"slash.todoList.description",icon:al,command:"convertBlock",category:"list",args:()=>({id:"__currentBlock__",type:"todoList",attrs:{checked:!1}})}],inputRules:[{name:"todo-empty",pattern:/^\[\] $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"todoList",attrs:{checked:!1},__stripPrefix:3})},{name:"todo-space-bracket",pattern:/^\[ \] $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"todoList",attrs:{checked:!1},__stripPrefix:4})}]},Zm=t.defineComponent({name:"QuoteBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){return()=>t.h(Un,{block:e.block,placeholder:e.placeholder,class:["block-quote",...En(e.block.attrs)]})}}),Xm={name:"quote",schema:{type:"quote",content:"text",nestable:!1,disallowedMarks:["italic"],attrs:{...Yd,indent:tn.indent}},renderer:{component:Zm},slashCommands:[{id:"quote",title:"slash.quote.title",keywords:["quote","blockquote","引用",">","引言"],description:"slash.quote.description",icon:dl,command:"convertBlock",category:"other",args:()=>({id:"__currentBlock__",type:"quote"})}],inputRules:[{name:"quote-gt",pattern:/^> $/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"quote",__stripPrefix:2})}]};function jm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function us(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(n=>{const o=e[n],r=typeof o;(r==="object"||r==="function")&&!Object.isFrozen(o)&&us(o)}),e}class fs{constructor(n){n.data===void 0&&(n.data={}),this.data=n.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function ms(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function jn(e,...n){const o=Object.create(null);for(const r in e)o[r]=e[r];return n.forEach(function(r){for(const l in r)o[l]=r[l]}),o}const Qm="</span>",ps=e=>!!e.scope,Jm=(e,{prefix:n})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const o=e.split(".");return[`${n}${o.shift()}`,...o.map((r,l)=>`${r}${"_".repeat(l+1)}`)].join(" ")}return`${n}${e}`};class ep{constructor(n,o){this.buffer="",this.classPrefix=o.classPrefix,n.walk(this)}addText(n){this.buffer+=ms(n)}openNode(n){if(!ps(n))return;const o=Jm(n.scope,{prefix:this.classPrefix});this.span(o)}closeNode(n){ps(n)&&(this.buffer+=Qm)}value(){return this.buffer}span(n){this.buffer+=`<span class="${n}">`}}const hs=(e={})=>{const n={children:[]};return Object.assign(n,e),n};class pl{constructor(){this.rootNode=hs(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(n){this.top.children.push(n)}openNode(n){const o=hs({scope:n});this.add(o),this.stack.push(o)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(n){return this.constructor._walk(n,this.rootNode)}static _walk(n,o){return typeof o=="string"?n.addText(o):o.children&&(n.openNode(o),o.children.forEach(r=>this._walk(n,r)),n.closeNode(o)),n}static _collapse(n){typeof n!="string"&&n.children&&(n.children.every(o=>typeof o=="string")?n.children=[n.children.join("")]:n.children.forEach(o=>{pl._collapse(o)}))}}class tp extends pl{constructor(n){super(),this.options=n}addText(n){n!==""&&this.add(n)}startScope(n){this.openNode(n)}endScope(){this.closeNode()}__addSublanguage(n,o){const r=n.root;o&&(r.scope=`language:${o}`),this.add(r)}toHTML(){return new ep(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function Wo(e){return e?typeof e=="string"?e:e.source:null}function gs(e){return so("(?=",e,")")}function np(e){return so("(?:",e,")*")}function op(e){return so("(?:",e,")?")}function so(...e){return e.map(o=>Wo(o)).join("")}function rp(e){const n=e[e.length-1];return typeof n=="object"&&n.constructor===Object?(e.splice(e.length-1,1),n):{}}function hl(...e){return"("+(rp(e).capture?"":"?:")+e.map(r=>Wo(r)).join("|")+")"}function bs(e){return new RegExp(e.toString()+"|").exec("").length-1}function lp(e,n){const o=e&&e.exec(n);return o&&o.index===0}const ip=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function gl(e,{joinWith:n}){let o=0;return e.map(r=>{o+=1;const l=o;let s=Wo(r),i="";for(;s.length>0;){const c=ip.exec(s);if(!c){i+=s;break}i+=s.substring(0,c.index),s=s.substring(c.index+c[0].length),c[0][0]==="\\"&&c[1]?i+="\\"+String(Number(c[1])+l):(i+=c[0],c[0]==="("&&o++)}return i}).map(r=>`(${r})`).join(n)}const sp=/\b\B/,ks="[a-zA-Z]\\w*",bl="[a-zA-Z_]\\w*",ys="\\b\\d+(\\.\\d+)?",ws="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Es="\\b(0b[01]+)",cp="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ap=(e={})=>{const n=/^#![ ]*\//;return e.binary&&(e.begin=so(n,/.*\b/,e.binary,/\b.*/)),jn({scope:"meta",begin:n,end:/$/,relevance:0,"on:begin":(o,r)=>{o.index!==0&&r.ignoreMatch()}},e)},Go={begin:"\\\\[\\s\\S]",relevance:0},dp={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Go]},up={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Go]},fp={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/},mr=function(e,n,o={}){const r=jn({scope:"comment",begin:e,end:n,contains:[]},o);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});const l=hl("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:so(/[ ]+/,"(",l,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),r},mp=mr("//","$"),pp=mr("/\\*","\\*/"),hp=mr("#","$"),gp={scope:"number",begin:ys,relevance:0},bp={scope:"number",begin:ws,relevance:0},kp={scope:"number",begin:Es,relevance:0},yp={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Go,{begin:/\[/,end:/\]/,relevance:0,contains:[Go]}]},wp={scope:"title",begin:ks,relevance:0},Ep={scope:"title",begin:bl,relevance:0},vp={begin:"\\.\\s*"+bl,relevance:0};var pr=Object.freeze({__proto__:null,APOS_STRING_MODE:dp,BACKSLASH_ESCAPE:Go,BINARY_NUMBER_MODE:kp,BINARY_NUMBER_RE:Es,COMMENT:mr,C_BLOCK_COMMENT_MODE:pp,C_LINE_COMMENT_MODE:mp,C_NUMBER_MODE:bp,C_NUMBER_RE:ws,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(n,o)=>{o.data._beginMatch=n[1]},"on:end":(n,o)=>{o.data._beginMatch!==n[1]&&o.ignoreMatch()}})},HASH_COMMENT_MODE:hp,IDENT_RE:ks,MATCH_NOTHING_RE:sp,METHOD_GUARD:vp,NUMBER_MODE:gp,NUMBER_RE:ys,PHRASAL_WORDS_MODE:fp,QUOTE_STRING_MODE:up,REGEXP_MODE:yp,RE_STARTERS_RE:cp,SHEBANG:ap,TITLE_MODE:wp,UNDERSCORE_IDENT_RE:bl,UNDERSCORE_TITLE_MODE:Ep});function Cp(e,n){e.input[e.index-1]==="."&&n.ignoreMatch()}function Tp(e,n){e.className!==void 0&&(e.scope=e.className,delete e.className)}function _p(e,n){n&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=Cp,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function xp(e,n){Array.isArray(e.illegal)&&(e.illegal=hl(...e.illegal))}function Mp(e,n){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 Np(e,n){e.relevance===void 0&&(e.relevance=1)}const Sp=(e,n)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const o=Object.assign({},e);Object.keys(e).forEach(r=>{delete e[r]}),e.keywords=o.keywords,e.begin=so(o.beforeMatch,gs(o.begin)),e.starts={relevance:0,contains:[Object.assign(o,{endsParent:!0})]},e.relevance=0,delete o.beforeMatch},Ap=["of","and","for","in","not","or","if","then","parent","list","value"],Ip="keyword";function vs(e,n,o=Ip){const r=Object.create(null);return typeof e=="string"?l(o,e.split(" ")):Array.isArray(e)?l(o,e):Object.keys(e).forEach(function(s){Object.assign(r,vs(e[s],n,s))}),r;function l(s,i){n&&(i=i.map(c=>c.toLowerCase())),i.forEach(function(c){const a=c.split("|");r[a[0]]=[s,Bp(a[0],a[1])]})}}function Bp(e,n){return n?Number(n):Rp(e)?0:1}function Rp(e){return Ap.includes(e.toLowerCase())}const Cs={},co=e=>{console.error(e)},Ts=(e,...n)=>{console.log(`WARN: ${e}`,...n)},Eo=(e,n)=>{Cs[`${e}/${n}`]||(console.log(`Deprecated as of ${e}. ${n}`),Cs[`${e}/${n}`]=!0)},hr=new Error;function _s(e,n,{key:o}){let r=0;const l=e[o],s={},i={};for(let c=1;c<=n.length;c++)i[c+r]=l[c],s[c+r]=!0,r+=bs(n[c-1]);e[o]=i,e[o]._emit=s,e[o]._multi=!0}function Lp(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw co("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),hr;if(typeof e.beginScope!="object"||e.beginScope===null)throw co("beginScope must be object"),hr;_s(e,e.begin,{key:"beginScope"}),e.begin=gl(e.begin,{joinWith:""})}}function Op(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw co("skip, excludeEnd, returnEnd not compatible with endScope: {}"),hr;if(typeof e.endScope!="object"||e.endScope===null)throw co("endScope must be object"),hr;_s(e,e.end,{key:"endScope"}),e.end=gl(e.end,{joinWith:""})}}function Dp(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function $p(e){Dp(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),Lp(e),Op(e)}function Pp(e){function n(i,c){return new RegExp(Wo(i),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(c?"g":""))}class o{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(c,a){a.position=this.position++,this.matchIndexes[this.matchAt]=a,this.regexes.push([a,c]),this.matchAt+=bs(c)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const c=this.regexes.map(a=>a[1]);this.matcherRe=n(gl(c,{joinWith:"|"}),!0),this.lastIndex=0}exec(c){this.matcherRe.lastIndex=this.lastIndex;const a=this.matcherRe.exec(c);if(!a)return null;const d=a.findIndex((u,h)=>h>0&&u!==void 0),f=this.matchIndexes[d];return a.splice(0,d),Object.assign(a,f)}}class r{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(c){if(this.multiRegexes[c])return this.multiRegexes[c];const a=new o;return this.rules.slice(c).forEach(([d,f])=>a.addRule(d,f)),a.compile(),this.multiRegexes[c]=a,a}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(c,a){this.rules.push([c,a]),a.type==="begin"&&this.count++}exec(c){const a=this.getMatcher(this.regexIndex);a.lastIndex=this.lastIndex;let d=a.exec(c);if(this.resumingScanAtSamePosition()&&!(d&&d.index===this.lastIndex)){const f=this.getMatcher(0);f.lastIndex=this.lastIndex+1,d=f.exec(c)}return d&&(this.regexIndex+=d.position+1,this.regexIndex===this.count&&this.considerAll()),d}}function l(i){const c=new r;return i.contains.forEach(a=>c.addRule(a.begin,{rule:a,type:"begin"})),i.terminatorEnd&&c.addRule(i.terminatorEnd,{type:"end"}),i.illegal&&c.addRule(i.illegal,{type:"illegal"}),c}function s(i,c){const a=i;if(i.isCompiled)return a;[Tp,Mp,$p,Sp].forEach(f=>f(i,c)),e.compilerExtensions.forEach(f=>f(i,c)),i.__beforeBegin=null,[_p,xp,Np].forEach(f=>f(i,c)),i.isCompiled=!0;let d=null;return typeof i.keywords=="object"&&i.keywords.$pattern&&(i.keywords=Object.assign({},i.keywords),d=i.keywords.$pattern,delete i.keywords.$pattern),d=d||/\w+/,i.keywords&&(i.keywords=vs(i.keywords,e.case_insensitive)),a.keywordPatternRe=n(d,!0),c&&(i.begin||(i.begin=/\B|\b/),a.beginRe=n(a.begin),!i.end&&!i.endsWithParent&&(i.end=/\B|\b/),i.end&&(a.endRe=n(a.end)),a.terminatorEnd=Wo(a.end)||"",i.endsWithParent&&c.terminatorEnd&&(a.terminatorEnd+=(i.end?"|":"")+c.terminatorEnd)),i.illegal&&(a.illegalRe=n(i.illegal)),i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map(function(f){return Hp(f==="self"?i:f)})),i.contains.forEach(function(f){s(f,a)}),i.starts&&s(i.starts,c),a.matcher=l(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=jn(e.classNameAliases||{}),s(e)}function xs(e){return e?e.endsWithParent||xs(e.starts):!1}function Hp(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(n){return jn(e,{variants:null},n)})),e.cachedVariants?e.cachedVariants:xs(e)?jn(e,{starts:e.starts?jn(e.starts):null}):Object.isFrozen(e)?jn(e):e}var Vp="11.11.0";class Up extends Error{constructor(n,o){super(n),this.name="HTMLInjectionError",this.html=o}}const kl=ms,Ms=jn,Ns=Symbol("nomatch"),zp=7,Ss=function(e){const n=Object.create(null),o=Object.create(null),r=[];let l=!0;const s="Could not find the language '{}', did you forget to load/include a language module?",i={disableAutodetect:!0,name:"Plain text",contains:[]};let c={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:tp};function a(E){return c.noHighlightRe.test(E)}function d(E){let N=E.className+" ";N+=E.parentNode?E.parentNode.className:"";const A=c.languageDetectRe.exec(N);if(A){const W=G(A[1]);return W||(Ts(s.replace("{}",A[1])),Ts("Falling back to no-highlight mode for this block.",E)),W?A[1]:"no-highlight"}return N.split(/\s+/).find(W=>a(W)||G(W))}function f(E,N,A){let W="",me="";typeof N=="object"?(W=E,A=N.ignoreIllegals,me=N.language):(Eo("10.7.0","highlight(lang, code, ...args) has been deprecated."),Eo("10.7.0",`Please use highlight(code, options) instead.
|
|
13
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),me=E,W=N),A===void 0&&(A=!0);const le={code:W,language:me};O("before:highlight",le);const he=le.result?le.result:u(le.language,le.code,A);return he.code=le.code,O("after:highlight",he),he}function u(E,N,A,W){const me=Object.create(null);function le(w,z){return w.keywords[z]}function he(){if(!fe.keywords){Xe.addText(Re);return}let w=0;fe.keywordPatternRe.lastIndex=0;let z=fe.keywordPatternRe.exec(Re),we="";for(;z;){we+=Re.substring(w,z.index);const ve=Ze.case_insensitive?z[0].toLowerCase():z[0],nt=le(fe,ve);if(nt){const[lt,on]=nt;if(Xe.addText(we),we="",me[ve]=(me[ve]||0)+1,me[ve]<=zp&&(qt+=on),lt.startsWith("_"))we+=z[0];else{const cn=Ze.classNameAliases[lt]||lt;Se(z[0],cn)}}else we+=z[0];w=fe.keywordPatternRe.lastIndex,z=fe.keywordPatternRe.exec(Re)}we+=Re.substring(w),Xe.addText(we)}function ae(){if(Re==="")return;let w=null;if(typeof fe.subLanguage=="string"){if(!n[fe.subLanguage]){Xe.addText(Re);return}w=u(fe.subLanguage,Re,!0,Tt[fe.subLanguage]),Tt[fe.subLanguage]=w._top}else w=p(Re,fe.subLanguage.length?fe.subLanguage:null);fe.relevance>0&&(qt+=w.relevance),Xe.__addSublanguage(w._emitter,w.language)}function ie(){fe.subLanguage!=null?ae():he(),Re=""}function Se(w,z){w!==""&&(Xe.startScope(z),Xe.addText(w),Xe.endScope())}function Te(w,z){let we=1;const ve=z.length-1;for(;we<=ve;){if(!w._emit[we]){we++;continue}const nt=Ze.classNameAliases[w[we]]||w[we],lt=z[we];nt?Se(lt,nt):(Re=lt,he(),Re=""),we++}}function We(w,z){return w.scope&&typeof w.scope=="string"&&Xe.openNode(Ze.classNameAliases[w.scope]||w.scope),w.beginScope&&(w.beginScope._wrap?(Se(Re,Ze.classNameAliases[w.beginScope._wrap]||w.beginScope._wrap),Re=""):w.beginScope._multi&&(Te(w.beginScope,z),Re="")),fe=Object.create(w,{parent:{value:fe}}),fe}function Mt(w,z,we){let ve=lp(w.endRe,we);if(ve){if(w["on:end"]){const nt=new fs(w);w["on:end"](z,nt),nt.isMatchIgnored&&(ve=!1)}if(ve){for(;w.endsParent&&w.parent;)w=w.parent;return w}}if(w.endsWithParent)return Mt(w.parent,z,we)}function Zt(w){return fe.matcher.regexIndex===0?(Re+=w[0],1):(P=!0,0)}function Gt(w){const z=w[0],we=w.rule,ve=new fs(we),nt=[we.__beforeBegin,we["on:begin"]];for(const lt of nt)if(lt&&(lt(w,ve),ve.isMatchIgnored))return Zt(z);return we.skip?Re+=z:(we.excludeBegin&&(Re+=z),ie(),!we.returnBegin&&!we.excludeBegin&&(Re=z)),We(we,w),we.returnBegin?0:z.length}function Rt(w){const z=w[0],we=N.substring(w.index),ve=Mt(fe,w,we);if(!ve)return Ns;const nt=fe;fe.endScope&&fe.endScope._wrap?(ie(),Se(z,fe.endScope._wrap)):fe.endScope&&fe.endScope._multi?(ie(),Te(fe.endScope,w)):nt.skip?Re+=z:(nt.returnEnd||nt.excludeEnd||(Re+=z),ie(),nt.excludeEnd&&(Re=z));do fe.scope&&Xe.closeNode(),!fe.skip&&!fe.subLanguage&&(qt+=fe.relevance),fe=fe.parent;while(fe!==ve.parent);return ve.starts&&We(ve.starts,w),nt.returnEnd?0:z.length}function tt(){const w=[];for(let z=fe;z!==Ze;z=z.parent)z.scope&&w.unshift(z.scope);w.forEach(z=>Xe.openNode(z))}let yt={};function vt(w,z){const we=z&&z[0];if(Re+=w,we==null)return ie(),0;if(yt.type==="begin"&&z.type==="end"&&yt.index===z.index&&we===""){if(Re+=N.slice(z.index,z.index+1),!l){const ve=new Error(`0 width match regex (${E})`);throw ve.languageName=E,ve.badRule=yt.rule,ve}return 1}if(yt=z,z.type==="begin")return Gt(z);if(z.type==="illegal"&&!A){const ve=new Error('Illegal lexeme "'+we+'" for mode "'+(fe.scope||"<unnamed>")+'"');throw ve.mode=fe,ve}else if(z.type==="end"){const ve=Rt(z);if(ve!==Ns)return ve}if(z.type==="illegal"&&we==="")return Re+=`
|
|
14
|
+
`,1;if(Et>1e5&&Et>z.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Re+=we,we.length}const Ze=G(E);if(!Ze)throw co(s.replace("{}",E)),new Error('Unknown language: "'+E+'"');const Ve=Pp(Ze);let Ct="",fe=W||Ve;const Tt={},Xe=new c.__emitter(c);tt();let Re="",qt=0,rt=0,Et=0,P=!1;try{if(Ze.__emitTokens)Ze.__emitTokens(N,Xe);else{for(fe.matcher.considerAll();;){Et++,P?P=!1:fe.matcher.considerAll(),fe.matcher.lastIndex=rt;const w=fe.matcher.exec(N);if(!w)break;const z=N.substring(rt,w.index),we=vt(z,w);rt=w.index+we}vt(N.substring(rt))}return Xe.finalize(),Ct=Xe.toHTML(),{language:E,value:Ct,relevance:qt,illegal:!1,_emitter:Xe,_top:fe}}catch(w){if(w.message&&w.message.includes("Illegal"))return{language:E,value:kl(N),illegal:!0,relevance:0,_illegalBy:{message:w.message,index:rt,context:N.slice(rt-100,rt+100),mode:w.mode,resultSoFar:Ct},_emitter:Xe};if(l)return{language:E,value:kl(N),illegal:!1,relevance:0,errorRaised:w,_emitter:Xe,_top:fe};throw w}}function h(E){const N={value:kl(E),illegal:!1,relevance:0,_top:i,_emitter:new c.__emitter(c)};return N._emitter.addText(E),N}function p(E,N){N=N||c.languages||Object.keys(n);const A=h(E),W=N.filter(G).filter(Z).map(ie=>u(ie,E,!1));W.unshift(A);const me=W.sort((ie,Se)=>{if(ie.relevance!==Se.relevance)return Se.relevance-ie.relevance;if(ie.language&&Se.language){if(G(ie.language).supersetOf===Se.language)return 1;if(G(Se.language).supersetOf===ie.language)return-1}return 0}),[le,he]=me,ae=le;return ae.secondBest=he,ae}function m(E,N,A){const W=N&&o[N]||A;E.classList.add("hljs"),E.classList.add(`language-${W}`)}function k(E){let N=null;const A=d(E);if(a(A))return;if(O("before:highlightElement",{el:E,language:A}),E.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",E);return}if(E.children.length>0&&(c.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(E)),c.throwUnescapedHTML))throw new Up("One of your code blocks includes unescaped HTML.",E.innerHTML);N=E;const W=N.textContent,me=A?f(W,{language:A,ignoreIllegals:!0}):p(W);E.innerHTML=me.value,E.dataset.highlighted="yes",m(E,A,me.language),E.result={language:me.language,re:me.relevance,relevance:me.relevance},me.secondBest&&(E.secondBest={language:me.secondBest.language,relevance:me.secondBest.relevance}),O("after:highlightElement",{el:E,result:me,text:W})}function x(E){c=Ms(c,E)}const D=()=>{ee(),Eo("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function U(){ee(),Eo("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let F=!1;function ee(){function E(){ee()}if(document.readyState==="loading"){F||window.addEventListener("DOMContentLoaded",E,!1),F=!0;return}document.querySelectorAll(c.cssSelector).forEach(k)}function $(E,N){let A=null;try{A=N(e)}catch(W){if(co("Language definition for '{}' could not be registered.".replace("{}",E)),l)co(W);else throw W;A=i}A.name||(A.name=E),n[E]=A,A.rawDefinition=N.bind(null,e),A.aliases&&ne(A.aliases,{languageName:E})}function V(E){delete n[E];for(const N of Object.keys(o))o[N]===E&&delete o[N]}function re(){return Object.keys(n)}function G(E){return E=(E||"").toLowerCase(),n[E]||n[o[E]]}function ne(E,{languageName:N}){typeof E=="string"&&(E=[E]),E.forEach(A=>{o[A.toLowerCase()]=N})}function Z(E){const N=G(E);return N&&!N.disableAutodetect}function S(E){E["before:highlightBlock"]&&!E["before:highlightElement"]&&(E["before:highlightElement"]=N=>{E["before:highlightBlock"](Object.assign({block:N.el},N))}),E["after:highlightBlock"]&&!E["after:highlightElement"]&&(E["after:highlightElement"]=N=>{E["after:highlightBlock"](Object.assign({block:N.el},N))})}function K(E){S(E),r.push(E)}function _(E){const N=r.indexOf(E);N!==-1&&r.splice(N,1)}function O(E,N){const A=E;r.forEach(function(W){W[A]&&W[A](N)})}function M(E){return Eo("10.7.0","highlightBlock will be removed entirely in v12.0"),Eo("10.7.0","Please use highlightElement now."),k(E)}Object.assign(e,{highlight:f,highlightAuto:p,highlightAll:ee,highlightElement:k,highlightBlock:M,configure:x,initHighlighting:D,initHighlightingOnLoad:U,registerLanguage:$,unregisterLanguage:V,listLanguages:re,getLanguage:G,registerAliases:ne,autoDetection:Z,inherit:Ms,addPlugin:K,removePlugin:_}),e.debugMode=function(){l=!1},e.safeMode=function(){l=!0},e.versionString=Vp,e.regex={concat:so,lookahead:gs,either:hl,optional:op,anyNumberOfTimes:np};for(const E in pr)typeof pr[E]=="object"&&us(pr[E]);return Object.assign(e,pr),e},vo=Ss({});vo.newInstance=()=>Ss({});var Fp=vo;vo.HighlightJS=vo,vo.default=vo;const As=jm(Fp),Is="[A-Za-z$_][0-9A-Za-z$_]*",Kp=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Wp=["true","false","null","undefined","NaN","Infinity"],Bs=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Rs=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Ls=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Gp=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],qp=[].concat(Ls,Bs,Rs);function Yp(e){const n=e.regex,o=(A,{after:W})=>{const me="</"+A[0].slice(1);return A.input.indexOf(me,W)!==-1},r=Is,l={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(A,W)=>{const me=A[0].length+A.index,le=A.input[me];if(le==="<"||le===","){W.ignoreMatch();return}le===">"&&(o(A,{after:me})||W.ignoreMatch());let he;const ae=A.input.substring(me);if(he=ae.match(/^\s*=/)){W.ignoreMatch();return}if((he=ae.match(/^\s+extends\s+/))&&he.index===0){W.ignoreMatch();return}}},c={$pattern:Is,keyword:Kp,literal:Wp,built_in:qp,"variable.language":Gp},a="[0-9](_?[0-9])*",d=`\\.(${a})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",u={className:"number",variants:[{begin:`(\\b(${f})((${d})|\\.)?|(${d}))[eE][+-]?(${a})\\b`},{begin:`\\b(${f})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},m={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},x={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,h]},U={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},F=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,k,x,{match:/\$\d+/},u];h.contains=F.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(F)});const ee=[].concat(U,h.contains),$=ee.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(ee)}]),V={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$},re={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,n.concat(r,"(",n.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},G={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Bs,...Rs]}},ne={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},Z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[V],illegal:/%/},S={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function K(A){return n.concat("(?!",A.join("|"),")")}const _={match:n.concat(/\b/,K([...Ls,"super","import"].map(A=>`${A}\\s*\\(`)),r,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},O={begin:n.concat(/\./,n.lookahead(n.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},M={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},V]},E="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",N={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(E)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[V]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:G},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),ne,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,k,x,U,{match:/\$\d+/},u,G,{scope:"attr",match:r+n.lookahead(":"),relevance:0},N,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[U,e.REGEXP_MODE,{className:"function",begin:E,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:l.begin,end:l.end},{match:s},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},Z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[V,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},O,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[V]},_,S,re,M,{match:/\$[(.]/}]}}const gr="[A-Za-z$_][0-9A-Za-z$_]*",Os=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Ds=["true","false","null","undefined","NaN","Infinity"],$s=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Ps=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Hs=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Vs=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Us=[].concat(Hs,$s,Ps);function Zp(e){const n=e.regex,o=(A,{after:W})=>{const me="</"+A[0].slice(1);return A.input.indexOf(me,W)!==-1},r=gr,l={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(A,W)=>{const me=A[0].length+A.index,le=A.input[me];if(le==="<"||le===","){W.ignoreMatch();return}le===">"&&(o(A,{after:me})||W.ignoreMatch());let he;const ae=A.input.substring(me);if(he=ae.match(/^\s*=/)){W.ignoreMatch();return}if((he=ae.match(/^\s+extends\s+/))&&he.index===0){W.ignoreMatch();return}}},c={$pattern:gr,keyword:Os,literal:Ds,built_in:Us,"variable.language":Vs},a="[0-9](_?[0-9])*",d=`\\.(${a})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",u={className:"number",variants:[{begin:`(\\b(${f})((${d})|\\.)?|(${d}))[eE][+-]?(${a})\\b`},{begin:`\\b(${f})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},m={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},x={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,h]},U={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},F=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,k,x,{match:/\$\d+/},u];h.contains=F.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(F)});const ee=[].concat(U,h.contains),$=ee.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(ee)}]),V={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$},re={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,n.concat(r,"(",n.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},G={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...$s,...Ps]}},ne={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},Z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[V],illegal:/%/},S={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function K(A){return n.concat("(?!",A.join("|"),")")}const _={match:n.concat(/\b/,K([...Hs,"super","import"].map(A=>`${A}\\s*\\(`)),r,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},O={begin:n.concat(/\./,n.lookahead(n.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},M={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},V]},E="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",N={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(E)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[V]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:$,CLASS_REFERENCE:G},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),ne,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,p,m,k,x,U,{match:/\$\d+/},u,G,{scope:"attr",match:r+n.lookahead(":"),relevance:0},N,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[U,e.REGEXP_MODE,{className:"function",begin:E,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:$}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:l.begin,end:l.end},{match:s},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},Z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[V,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},O,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[V]},_,S,re,M,{match:/\$[(.]/}]}}function Xp(e){const n=e.regex,o=Zp(e),r=gr,l=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],s={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},i={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:l},contains:[o.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},a=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],d={$pattern:gr,keyword:Os.concat(a),literal:Ds,built_in:Us.concat(l),"variable.language":Vs},f={className:"meta",begin:"@"+r},u=(k,x,D)=>{const U=k.contains.findIndex(F=>F.label===x);if(U===-1)throw new Error("can not find mode to replace");k.contains.splice(U,1,D)};Object.assign(o.keywords,d),o.exports.PARAMS_CONTAINS.push(f);const h=o.contains.find(k=>k.scope==="attr"),p=Object.assign({},h,{match:n.concat(r,n.lookahead(/\s*\?:/))});o.exports.PARAMS_CONTAINS.push([o.exports.CLASS_REFERENCE,h,p]),o.contains=o.contains.concat([f,s,i,p]),u(o,"shebang",e.SHEBANG()),u(o,"use_strict",c);const m=o.contains.find(k=>k.label==="func.def");return m.relevance=0,Object.assign(o,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),o}function jp(e){const n=e.regex,o=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},a={className:"meta",begin:/^(>>>|\.\.\.) /},d={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},f={begin:/\{\{/,relevance:0},u={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,f,d]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,f,d]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,f,d]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,f,d]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",p=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,m=`\\b|${r.join("|")}`,k={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${p}))[eE][+-]?(${h})[jJ]?(?=${m})`},{begin:`(${p})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${m})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${m})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${m})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${m})`},{begin:`\\b(${h})[jJ](?=${m})`}]},x={className:"comment",begin:n.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},D={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",a,k,u,e.HASH_COMMENT_MODE]}]};return d.contains=[u,k,a],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[a,k,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},u,x,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,o],scope:{1:"keyword",3:"title.function"},contains:[D]},{variants:[{match:[/\bclass/,/\s+/,o,/\s*/,/\(\s*/,o,/\s*\)/]},{match:[/\bclass/,/\s+/,o]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[k,D,u]}]}}var Co="[0-9](_*[0-9])*",br=`\\.(${Co})`,kr="[0-9a-fA-F](_*[0-9a-fA-F])*",zs={className:"number",variants:[{begin:`(\\b(${Co})((${br})|\\.)?|(${br}))[eE][+-]?(${Co})[fFdD]?\\b`},{begin:`\\b(${Co})((${br})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${br})[fFdD]?\\b`},{begin:`\\b(${Co})[fFdD]\\b`},{begin:`\\b0[xX]((${kr})\\.?|(${kr})?\\.(${kr}))[pP][+-]?(${Co})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${kr})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Fs(e,n,o){return o===-1?"":e.replace(n,r=>Fs(e,n,o-1))}function Qp(e){const n=e.regex,o="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=o+Fs("(?:<"+o+"~~~(?:\\s*,\\s*"+o+"~~~)*>)?",/~~~/g,2),a={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},d={className:"meta",begin:"@"+o,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},f={className:"params",begin:/\(/,end:/\)/,keywords:a,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:a,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,o],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[n.concat(/(?!else)/,o),/\s+/,o,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,o],className:{1:"keyword",3:"title.class"},contains:[f,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:a,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:a,relevance:0,contains:[d,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,zs,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},zs,d]}}function Jp(e){const n=e.regex,o=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",l="[a-zA-Z_]\\w*::",i="("+r+"|"+n.optional(l)+"[a-zA-Z_]\\w*"+n.optional("<[^<>]+>")+")",c={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},f={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},u={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},o,e.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:n.optional(l)+e.IDENT_RE,relevance:0},p=n.optional(l)+e.IDENT_RE+"\\s*\\(",x={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},D=[u,c,o,e.C_BLOCK_COMMENT_MODE,f,d],U={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:x,contains:D.concat([{begin:/\(/,end:/\)/,keywords:x,contains:D.concat(["self"]),relevance:0}]),relevance:0},F={begin:"("+i+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:x,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:x,relevance:0},{begin:p,returnBegin:!0,contains:[e.inherit(h,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:x,relevance:0,contains:[o,e.C_BLOCK_COMMENT_MODE,d,f,c,{begin:/\(/,end:/\)/,keywords:x,relevance:0,contains:["self",o,e.C_BLOCK_COMMENT_MODE,d,f,c]}]},c,o,e.C_BLOCK_COMMENT_MODE,u]};return{name:"C",aliases:["h"],keywords:x,disableAutodetect:!0,illegal:"</",contains:[].concat(U,F,D,[u,{begin:e.IDENT_RE+"::",keywords:x},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:u,strings:d,keywords:x}}}function eh(e){const n=e.regex,o=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",l="[a-zA-Z_]\\w*::",i="(?!struct)("+r+"|"+n.optional(l)+"[a-zA-Z_]\\w*"+n.optional("<[^<>]+>")+")",c={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},d={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},f={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},u={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(d,{className:"string"}),{className:"string",begin:/<.*?>/},o,e.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:n.optional(l)+e.IDENT_RE,relevance:0},p=n.optional(l)+e.IDENT_RE+"\\s*\\(",m=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],k=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],x=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],D=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],ee={type:k,keyword:m,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:x},$={className:"function.dispatch",relevance:0,keywords:{_hint:D},begin:n.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,n.lookahead(/(<[^<>]+>|)\s*\(/))},V=[$,u,c,o,e.C_BLOCK_COMMENT_MODE,f,d],re={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:ee,contains:V.concat([{begin:/\(/,end:/\)/,keywords:ee,contains:V.concat(["self"]),relevance:0}]),relevance:0},G={className:"function",begin:"("+i+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:ee,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:ee,relevance:0},{begin:p,returnBegin:!0,contains:[h],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[d,f]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:ee,relevance:0,contains:[o,e.C_BLOCK_COMMENT_MODE,d,f,c,{begin:/\(/,end:/\)/,keywords:ee,relevance:0,contains:["self",o,e.C_BLOCK_COMMENT_MODE,d,f,c]}]},c,o,e.C_BLOCK_COMMENT_MODE,u]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:ee,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(re,G,$,V,[u,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:ee,contains:["self",c]},{begin:e.IDENT_RE+"::",keywords:ee},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function th(e){const n=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],o=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],l=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],s=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],i={keyword:l.concat(s),built_in:n,literal:r},c=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),a={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},d={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},f={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},u=e.inherit(f,{illegal:/\n/}),h={className:"subst",begin:/\{/,end:/\}/,keywords:i},p=e.inherit(h,{illegal:/\n/}),m={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,p]},k={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},h]},x=e.inherit(k,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},p]});h.contains=[k,m,f,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.C_BLOCK_COMMENT_MODE],p.contains=[x,m,u,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const D={variants:[d,k,m,f,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},U={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},F=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",ee={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:i,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},D,a,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},c,U,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,U,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+F+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:i,contains:[{beginKeywords:o.join(" "),relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,U],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,relevance:0,contains:[D,a,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},ee]}}function nh(e){const s={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:s,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:s,illegal:/["']/}]}]}}function oh(e){const n=e.regex,o=/(r#)?/,r=n.concat(o,e.UNDERSCORE_IDENT_RE),l=n.concat(o,e.IDENT_RE),s={className:"title.function.invoke",relevance:0,begin:n.concat(/\b/,/(?!let|for|while|if|else|match\b)/,l,n.lookahead(/\s*\(/))},i="([ui](8|16|32|64|128|size)|f(32|64))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],a=["true","false","Some","None","Ok","Err"],d=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],f=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:f,keyword:c,literal:a,built_in:d},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\(\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*/},{className:"number",variants:[{begin:"\\b0b([01_]+)"+i},{begin:"\\b0o([0-7_]+)"+i},{begin:"\\b0x([A-Fa-f0-9_]+)"+i},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+i}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:d,type:f}},{className:"punctuation",begin:"->"},s]}}function rh(e){const n=e.regex,o="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=n.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),l=n.concat(r,/(::\w+)*/),i={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},c={className:"doctag",begin:"@[A-Za-z]+"},a={begin:"#<",end:">"},d=[e.COMMENT("#","$",{contains:[c]}),e.COMMENT("^=begin","^=end",{contains:[c],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],f={className:"subst",begin:/#\{/,end:/\}/,keywords:i},u={className:"string",contains:[e.BACKSLASH_ESCAPE,f],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:n.concat(/<<[-~]?'?/,n.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,f]})]}]},h="[1-9](_?[0-9])*|0",p="[0-9](_?[0-9])*",m={className:"number",relevance:0,variants:[{begin:`\\b(${h})(\\.(${p}))?([eE][+-]?(${p})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},k={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:i}]},V=[u,{variants:[{match:[/class\s+/,l,/\s+<\s+/,l]},{match:[/\b(class|module)\s+/,l]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:i},{match:[/(include|extend)\s+/,l],scope:{2:"title.class"},keywords:i},{relevance:0,match:[l,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,o],scope:{1:"keyword",3:"title.function"},contains:[k]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[u,{begin:o}],relevance:0},m,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:i},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,f],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(a,d),relevance:0}].concat(a,d);f.contains=V,k.contains=V;const Z=[{begin:/^\s*=>/,starts:{end:"$",contains:V}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:i,contains:V}}];return d.unshift(a),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:i,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(Z).concat(d).concat(V)}}function lh(e){const n=e.regex,o=/(?![A-Za-z0-9])(?![$])/,r=n.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,o),l=n.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,o),s=n.concat(/[A-Z]+/,o),i={scope:"variable",match:"\\$+"+r},c={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},a={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},d=e.inherit(e.APOS_STRING_MODE,{illegal:null}),f=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(a)}),u={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(a),"on:begin":(O,M)=>{M.data._beginMatch=O[1]||O[2]},"on:end":(O,M)=>{M.data._beginMatch!==O[1]&&M.ignoreMatch()}},h=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),p=`[
|
|
15
|
+
]`,m={scope:"string",variants:[f,d,u,h]},k={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},x=["false","null","true"],D=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],U=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],ee={keyword:D,literal:(O=>{const M=[];return O.forEach(E=>{M.push(E),E.toLowerCase()===E?M.push(E.toUpperCase()):M.push(E.toLowerCase())}),M})(x),built_in:U},$=O=>O.map(M=>M.replace(/\|\d+$/,"")),V={variants:[{match:[/new/,n.concat(p,"+"),n.concat("(?!",$(U).join("\\b|"),"\\b)"),l],scope:{1:"keyword",4:"title.class"}}]},re=n.concat(r,"\\b(?!\\()"),G={variants:[{match:[n.concat(/::/,n.lookahead(/(?!class\b)/)),re],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[l,n.concat(/::/,n.lookahead(/(?!class\b)/)),re],scope:{1:"title.class",3:"variable.constant"}},{match:[l,n.concat("::",n.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[l,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},ne={scope:"attr",match:n.concat(r,n.lookahead(":"),n.lookahead(/(?!::)/))},Z={relevance:0,begin:/\(/,end:/\)/,keywords:ee,contains:[ne,i,G,e.C_BLOCK_COMMENT_MODE,m,k,V]},S={relevance:0,match:[/\b/,n.concat("(?!fn\\b|function\\b|",$(D).join("\\b|"),"|",$(U).join("\\b|"),"\\b)"),r,n.concat(p,"*"),n.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[Z]};Z.contains.push(S);const K=[ne,G,e.C_BLOCK_COMMENT_MODE,m,k,V],_={begin:n.concat(/#\[\s*\\?/,n.either(l,s)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:x,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:x,keyword:["new","array"]},contains:["self",...K]},...K,{scope:"meta",variants:[{match:l},{match:s}]}]};return{case_insensitive:!1,keywords:ee,contains:[_,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},c,{scope:"variable.language",match:/\$this\b/},i,S,G,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},V,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:ee,contains:["self",_,i,G,e.C_BLOCK_COMMENT_MODE,m,k]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},m,k]}}function Ks(e){return e?typeof e=="string"?e:e.source:null}function qo(e){return kt("(?=",e,")")}function kt(...e){return e.map(o=>Ks(o)).join("")}function ih(e){const n=e[e.length-1];return typeof n=="object"&&n.constructor===Object?(e.splice(e.length-1,1),n):{}}function nn(...e){return"("+(ih(e).capture?"":"?:")+e.map(r=>Ks(r)).join("|")+")"}const yl=e=>kt(/\b/,e,/\w$/.test(e)?/\b/:/\B/),sh=["Protocol","Type"].map(yl),Ws=["init","self"].map(yl),ch=["Any","Self"],wl=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],Gs=["false","nil","true"],ah=["assignment","associativity","higherThan","left","lowerThan","none","right"],dh=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],qs=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],Ys=nn(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),Zs=nn(Ys,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),El=kt(Ys,Zs,"*"),Xs=nn(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),yr=nn(Xs,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),Bn=kt(Xs,yr,"*"),wr=kt(/[A-Z]/,yr,"*"),uh=["attached","autoclosure",kt(/convention\(/,nn("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",kt(/objc\(/,Bn,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],fh=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function mh(e){const n={match:/\s+/,relevance:0},o=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,o],l={match:[/\./,nn(...sh,...Ws)],className:{2:"keyword"}},s={match:kt(/\./,nn(...wl)),relevance:0},i=wl.filter(Ve=>typeof Ve=="string").concat(["_|0"]),c=wl.filter(Ve=>typeof Ve!="string").concat(ch).map(yl),a={variants:[{className:"keyword",match:nn(...c,...Ws)}]},d={$pattern:nn(/\b\w+/,/#\w+/),keyword:i.concat(dh),literal:Gs},f=[l,s,a],u={match:kt(/\./,nn(...qs)),relevance:0},h={className:"built_in",match:kt(/\b/,nn(...qs),/(?=\()/)},p=[u,h],m={match:/->/,relevance:0},k={className:"operator",relevance:0,variants:[{match:El},{match:`\\.(\\.|${Zs})+`}]},x=[m,k],D="([0-9]_*)+",U="([0-9a-fA-F]_*)+",F={className:"number",relevance:0,variants:[{match:`\\b(${D})(\\.(${D}))?([eE][+-]?(${D}))?\\b`},{match:`\\b0x(${U})(\\.(${U}))?([pP][+-]?(${D}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},ee=(Ve="")=>({className:"subst",variants:[{match:kt(/\\/,Ve,/[0\\tnr"']/)},{match:kt(/\\/,Ve,/u\{[0-9a-fA-F]{1,8}\}/)}]}),$=(Ve="")=>({className:"subst",match:kt(/\\/,Ve,/[\t ]*(?:[\r\n]|\r\n)/)}),V=(Ve="")=>({className:"subst",label:"interpol",begin:kt(/\\/,Ve,/\(/),end:/\)/}),re=(Ve="")=>({begin:kt(Ve,/"""/),end:kt(/"""/,Ve),contains:[ee(Ve),$(Ve),V(Ve)]}),G=(Ve="")=>({begin:kt(Ve,/"/),end:kt(/"/,Ve),contains:[ee(Ve),V(Ve)]}),ne={className:"string",variants:[re(),re("#"),re("##"),re("###"),G(),G("#"),G("##"),G("###")]},Z=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],S={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:Z},K=Ve=>{const Ct=kt(Ve,/\//),fe=kt(/\//,Ve);return{begin:Ct,end:fe,contains:[...Z,{scope:"comment",begin:`#(?!.*${fe})`,end:/$/}]}},_={scope:"regexp",variants:[K("###"),K("##"),K("#"),S]},O={match:kt(/`/,Bn,/`/)},M={className:"variable",match:/\$\d+/},E={className:"variable",match:`\\$${yr}+`},N=[O,M,E],A={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:fh,contains:[...x,F,ne]}]}},W={scope:"keyword",match:kt(/@/,nn(...uh),qo(nn(/\(/,/\s+/)))},me={scope:"meta",match:kt(/@/,Bn)},le=[A,W,me],he={match:qo(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:kt(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,yr,"+")},{className:"type",match:wr,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:kt(/\s+&\s+/,qo(wr)),relevance:0}]},ae={begin:/</,end:/>/,keywords:d,contains:[...r,...f,...le,m,he]};he.contains.push(ae);const ie={match:kt(Bn,/\s*:/),keywords:"_|0",relevance:0},Se={begin:/\(/,end:/\)/,relevance:0,keywords:d,contains:["self",ie,...r,_,...f,...p,...x,F,ne,...N,...le,he]},Te={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,he]},We={begin:nn(qo(kt(Bn,/\s*:/)),qo(kt(Bn,/\s+/,Bn,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:Bn}]},Mt={begin:/\(/,end:/\)/,keywords:d,contains:[We,...r,...f,...x,F,ne,...le,he,Se],endsParent:!0,illegal:/["']/},Zt={match:[/(func|macro)/,/\s+/,nn(O.match,Bn,El)],className:{1:"keyword",3:"title.function"},contains:[Te,Mt,n],illegal:[/\[/,/%/]},Gt={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Te,Mt,n],illegal:/\[|%/},Rt={match:[/operator/,/\s+/,El],className:{1:"keyword",3:"title"}},tt={begin:[/precedencegroup/,/\s+/,wr],className:{1:"keyword",3:"title"},contains:[he],keywords:[...ah,...Gs],end:/}/},yt={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},vt={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},Ze={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,Bn,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:d,contains:[Te,...f,{begin:/:/,end:/\{/,keywords:d,contains:[{scope:"title.class.inherited",match:wr},...f],relevance:0}]};for(const Ve of ne.variants){const Ct=Ve.contains.find(Tt=>Tt.label==="interpol");Ct.keywords=d;const fe=[...f,...p,...x,F,ne,...N];Ct.contains=[...fe,{begin:/\(/,end:/\)/,contains:["self",...fe]}]}return{name:"Swift",keywords:d,contains:[...r,Zt,Gt,yt,vt,Ze,Rt,tt,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},_,...f,...p,...x,F,ne,...N,...le,he,Se]}}var To="[0-9](_*[0-9])*",Er=`\\.(${To})`,vr="[0-9a-fA-F](_*[0-9a-fA-F])*",ph={className:"number",variants:[{begin:`(\\b(${To})((${Er})|\\.)?|(${Er}))[eE][+-]?(${To})[fFdD]?\\b`},{begin:`\\b(${To})((${Er})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Er})[fFdD]?\\b`},{begin:`\\b(${To})[fFdD]\\b`},{begin:`\\b0[xX]((${vr})\\.?|(${vr})?\\.(${vr}))[pP][+-]?(${To})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${vr})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function hh(e){const n={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},o={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},l={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},s={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},i={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[s,l]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,s,l]}]};l.contains.push(i);const c={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},a={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(i,{className:"string"}),"self"]}]},d=ph,f=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),u={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},h=u;return h.variants[1].contains=[u],u.variants[1].contains=[h],{name:"Kotlin",aliases:["kt","kts"],keywords:n,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,f,o,r,c,a,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:n,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:n,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[u,e.C_LINE_COMMENT_MODE,f],relevance:0},e.C_LINE_COMMENT_MODE,f,c,a,i,e.C_NUMBER_MODE]},f]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},c,a]},i,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
|
|
16
|
+
`},d]}}function gh(e){const n=e.regex,o=n.concat(/[\p{L}_]/u,n.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,l={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},i=e.inherit(s,{begin:/\(/,end:/\)/}),c=e.inherit(e.APOS_STRING_MODE,{className:"string"}),a=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),d={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[l]},{begin:/'/,end:/'/,contains:[l]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[s,a,c,i,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[s,i,a,c]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},l,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[a]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[d],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[d],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:n.concat(/</,n.lookahead(n.concat(o,n.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:o,relevance:0,starts:d}]},{className:"tag",begin:n.concat(/<\//,n.lookahead(n.concat(o,/>/))),contains:[{className:"name",begin:o,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}const bh=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),kh=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],yh=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],wh=[...kh,...yh],Eh=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),vh=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),Ch=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Th=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function _h(e){const n=e.regex,o=bh(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},l="and or not only",s=/@-?\w[\w]*(-\w+)*/,i="[a-zA-Z-][a-zA-Z0-9_-]*",c=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[o.BLOCK_COMMENT,r,o.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+i,relevance:0},o.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+vh.join("|")+")"},{begin:":(:)?("+Ch.join("|")+")"}]},o.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Th.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[o.BLOCK_COMMENT,o.HEXCOLOR,o.IMPORTANT,o.CSS_NUMBER_MODE,...c,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...c,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},o.FUNCTION_DISPATCH]},{begin:n.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:l,attribute:Eh.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,o.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+wh.join("|")+")\\b"}]}}function xh(e){const n={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},o={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],l={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[n,o,e.QUOTE_STRING_MODE,l,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function Mh(e){const n="true false yes no null",o="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},l={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},s={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},i={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,l]},c=e.inherit(i,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),h={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},p={end:",",endsWithParent:!0,excludeEnd:!0,keywords:n,relevance:0},m={begin:/\{/,end:/\}/,contains:[p],illegal:"\\n",relevance:0},k={begin:"\\[",end:"\\]",contains:[p],illegal:"\\n",relevance:0},x=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+o},{className:"type",begin:"!<"+o+">"},{className:"type",begin:"!"+o},{className:"type",begin:"!!"+o},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},h,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},m,k,s,i],D=[...x];return D.pop(),D.push(c),p.contains=D,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:x}}function Nh(e){const n=e.regex,o={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},l={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},i={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,a={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:n.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},d={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},f={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},u=e.inherit(d,{contains:[]}),h=e.inherit(f,{contains:[]});d.contains.push(h),f.contains.push(u);let p=[o,a];return[d,f,u,h].forEach(D=>{D.contains=D.contains.concat(p)}),p=p.concat(d,f),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:p},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:p}]}]},o,s,d,f,{className:"quote",begin:"^>\\s+",contains:p,end:"$"},l,r,a,i,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function Sh(e){const n="\\[=*\\[",o="\\]=*\\]",r={begin:n,end:o,contains:["self"]},l=[e.COMMENT("--(?!"+n+")","$"),e.COMMENT("--"+n,o,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:l.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:l}].concat(l)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:n,end:o,contains:[r],relevance:5}])}}function Ah(e){const n=e.regex,o={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[o]}]};Object.assign(o,{className:"variable",variants:[{begin:n.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const l={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},s=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),i={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,o,l]};l.contains.push(c);const a={match:/\\"/},d={className:"string",begin:/'/,end:/'/},f={match:/\\'/},u={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,o]},h=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],p=e.SHEBANG({binary:`(${h.join("|")})`,relevance:10}),m={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},k=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],x=["true","false"],D={match:/(\/[a-z._-]+)+/},U=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],F=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],ee=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],$=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:k,literal:x,built_in:[...U,...F,"set","shopt",...ee,...$]},contains:[p,e.SHEBANG(),m,u,s,i,D,c,a,d,f,o]}}function Ih(e){const n=["string","char","byte","int","long","bool","decimal","single","double","DateTime","xml","array","hashtable","void"],o="Add|Clear|Close|Copy|Enter|Exit|Find|Format|Get|Hide|Join|Lock|Move|New|Open|Optimize|Pop|Push|Redo|Remove|Rename|Reset|Resize|Search|Select|Set|Show|Skip|Split|Step|Switch|Undo|Unlock|Watch|Backup|Checkpoint|Compare|Compress|Convert|ConvertFrom|ConvertTo|Dismount|Edit|Expand|Export|Group|Import|Initialize|Limit|Merge|Mount|Out|Publish|Restore|Save|Sync|Unpublish|Update|Approve|Assert|Build|Complete|Confirm|Deny|Deploy|Disable|Enable|Install|Invoke|Register|Request|Restart|Resume|Start|Stop|Submit|Suspend|Uninstall|Unregister|Wait|Debug|Measure|Ping|Repair|Resolve|Test|Trace|Connect|Disconnect|Read|Receive|Send|Write|Block|Grant|Protect|Revoke|Unblock|Unprotect|Use|ForEach|Sort|Tee|Where",r="-and|-as|-band|-bnot|-bor|-bxor|-casesensitive|-ccontains|-ceq|-cge|-cgt|-cle|-clike|-clt|-cmatch|-cne|-cnotcontains|-cnotlike|-cnotmatch|-contains|-creplace|-csplit|-eq|-exact|-f|-file|-ge|-gt|-icontains|-ieq|-ige|-igt|-ile|-ilike|-ilt|-imatch|-in|-ine|-inotcontains|-inotlike|-inotmatch|-ireplace|-is|-isnot|-isplit|-join|-le|-like|-lt|-match|-ne|-not|-notcontains|-notin|-notlike|-notmatch|-or|-regex|-replace|-shl|-shr|-split|-wildcard|-xor",l={$pattern:/-?[A-z\.\-]+\b/,keyword:"if else foreach return do while until elseif begin for trap data dynamicparam end break throw param continue finally in switch exit filter try process catch hidden static parameter",built_in:"ac asnp cat cd CFS chdir clc clear clhy cli clp cls clv cnsn compare copy cp cpi cpp curl cvpa dbp del diff dir dnsn ebp echo|0 epal epcsv epsn erase etsn exsn fc fhx fl ft fw gal gbp gc gcb gci gcm gcs gdr gerr ghy gi gin gjb gl gm gmo gp gps gpv group gsn gsnp gsv gtz gu gv gwmi h history icm iex ihy ii ipal ipcsv ipmo ipsn irm ise iwmi iwr kill lp ls man md measure mi mount move mp mv nal ndr ni nmo npssc nsn nv ogv oh popd ps pushd pwd r rbp rcjb rcsn rd rdr ren ri rjb rm rmdir rmo rni rnp rp rsn rsnp rujb rv rvpa rwmi sajb sal saps sasv sbp sc scb select set shcm si sl sleep sls sort sp spjb spps spsv start stz sujb sv swmi tee trcm type wget where wjb write"},s=/\w[\w\d]*((-)[\w\d]+)*/,i={begin:"`[\\s\\S]",relevance:0},c={className:"variable",variants:[{begin:/\$\B/},{className:"keyword",begin:/\$this/},{begin:/\$[\w\d][\w\d_:]*/}]},a={className:"literal",begin:/\$(null|true|false)\b/},d={className:"string",variants:[{begin:/"/,end:/"/},{begin:/@"/,end:/^"@/}],contains:[i,c,{className:"variable",begin:/\$[A-z]/,end:/[^A-z]/}]},f={className:"string",variants:[{begin:/'/,end:/'/},{begin:/@'/,end:/^'@/}]},u={className:"doctag",variants:[{begin:/\.(synopsis|description|example|inputs|outputs|notes|link|component|role|functionality)/},{begin:/\.(parameter|forwardhelptargetname|forwardhelpcategory|remotehelprunspace|externalhelp)\s+\S+/}]},h=e.inherit(e.COMMENT(null,null),{variants:[{begin:/#/,end:/$/},{begin:/<#/,end:/#>/}],contains:[u]}),p={className:"built_in",variants:[{begin:"(".concat(o,")+(-)[\\w\\d]+")}]},m={className:"class",beginKeywords:"class enum",end:/\s*[{]/,excludeEnd:!0,relevance:0,contains:[e.TITLE_MODE]},k={className:"function",begin:/function\s+/,end:/\s*\{|$/,excludeEnd:!0,returnBegin:!0,relevance:0,contains:[{begin:"function",relevance:0,className:"keyword"},{className:"title",begin:s,relevance:0},{begin:/\(/,end:/\)/,className:"params",relevance:0,contains:[c]}]},x={begin:/using\s/,end:/$/,returnBegin:!0,contains:[d,f,{className:"keyword",begin:/(using|assembly|command|module|namespace|type)/}]},D={variants:[{className:"operator",begin:"(".concat(r,")\\b")},{className:"literal",begin:/(-){1,2}[\w\d-]+/,relevance:0}]},U={className:"selector-tag",begin:/@\B/,relevance:0},F={className:"function",begin:/\[.*\]\s*[\w]+[ ]??\(/,end:/$/,returnBegin:!0,relevance:0,contains:[{className:"keyword",begin:"(".concat(l.keyword.toString().replace(/\s/g,"|"),")\\b"),endsParent:!0,relevance:0},e.inherit(e.TITLE_MODE,{endsParent:!0})]},ee=[F,h,i,e.NUMBER_MODE,d,f,p,c,a,U],$={begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0,relevance:0,contains:[].concat("self",ee,{begin:"("+n.join("|")+")",className:"built_in",relevance:0},{className:"type",begin:/[\.\w\d]+/,relevance:0})};return F.contains.unshift($),{name:"PowerShell",aliases:["pwsh","ps","ps1"],case_insensitive:!0,keywords:l,contains:ee.concat(m,k,x,D,$)}}function Bh(e){const n=e.COMMENT(/^\s*@?rem\b/,/$/,{relevance:10});return{name:"Batch file (DOS)",aliases:["bat","cmd"],case_insensitive:!0,illegal:/\/\*/,keywords:{keyword:["if","else","goto","for","in","do","call","exit","not","exist","errorlevel","defined","equ","neq","lss","leq","gtr","geq"],built_in:["prn","nul","lpt3","lpt2","lpt1","con","com4","com3","com2","com1","aux","shift","cd","dir","echo","setlocal","endlocal","set","pause","copy","append","assoc","at","attrib","break","cacls","cd","chcp","chdir","chkdsk","chkntfs","cls","cmd","color","comp","compact","convert","date","dir","diskcomp","diskcopy","doskey","erase","fs","find","findstr","format","ftype","graftabl","help","keyb","label","md","mkdir","mode","more","move","path","pause","print","popd","pushd","promt","rd","recover","rem","rename","replace","restore","rmdir","shift","sort","start","subst","time","title","tree","type","ver","verify","vol","ping","net","ipconfig","taskkill","xcopy","ren","del"]},contains:[{className:"variable",begin:/%%[^ ]|%[^ ]+?%|![^ ]+?!/},{className:"function",begin:{begin:"^\\s*[A-Za-z._?][A-Za-z0-9_$#@~.?]*(:|\\s+label)"}.begin,end:"goto:eof",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),n]},{className:"number",begin:"\\b\\d+",relevance:0},n]}}function Rh(e){const n=e.regex,o=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},l={begin:/"/,end:/"/,contains:[{match:/""/}]},s=["true","false","unknown"],i=["double precision","large object","with timezone","without timezone"],c=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],a=["add","asc","collation","desc","final","first","last","view"],d=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],f=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],u=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],h=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],p=f,m=[...d,...a].filter($=>!f.includes($)),k={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},x={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},D={match:n.concat(/\b/,n.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function U($){return n.concat(/\b/,n.either(...$.map(V=>V.replace(/\s+/,"\\s+"))),/\b/)}const F={scope:"keyword",match:U(h),relevance:0};function ee($,{exceptions:V,when:re}={}){const G=re;return V=V||[],$.map(ne=>ne.match(/\|\d+$/)||V.includes(ne)?ne:G(ne)?`${ne}|0`:ne)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:ee(m,{when:$=>$.length<3}),literal:s,type:c,built_in:u},contains:[{scope:"type",match:U(i)},F,D,k,r,l,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,o,x]}}function Lh(e){const n={className:"subst",variants:[{begin:"\\$[A-Za-z0-9_]+"}]},o={className:"subst",variants:[{begin:/\$\{/,end:/\}/}],keywords:"true false null this is new super"},r={className:"number",relevance:0,variants:[{match:/\b[0-9][0-9_]*(\.[0-9][0-9_]*)?([eE][+-]?[0-9][0-9_]*)?\b/},{match:/\b0[xX][0-9A-Fa-f][0-9A-Fa-f_]*\b/}]},l={className:"string",variants:[{begin:"r'''",end:"'''"},{begin:'r"""',end:'"""'},{begin:"r'",end:"'",illegal:"\\n"},{begin:'r"',end:'"',illegal:"\\n"},{begin:"'''",end:"'''",contains:[e.BACKSLASH_ESCAPE,n,o]},{begin:'"""',end:'"""',contains:[e.BACKSLASH_ESCAPE,n,o]},{begin:"'",end:"'",illegal:"\\n",contains:[e.BACKSLASH_ESCAPE,n,o]},{begin:'"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE,n,o]}]};o.contains=[r,l];const s=["Comparable","DateTime","Duration","Function","Iterable","Iterator","List","Map","Match","Object","Pattern","RegExp","Set","Stopwatch","String","StringBuffer","StringSink","Symbol","Type","Uri","bool","double","int","num","Element","ElementList"],i=s.map(d=>`${d}?`);return{name:"Dart",keywords:{keyword:["abstract","as","assert","async","await","base","break","case","catch","class","const","continue","covariant","default","deferred","do","dynamic","else","enum","export","extends","extension","external","factory","false","final","finally","for","Function","get","hide","if","implements","import","in","interface","is","late","library","mixin","new","null","on","operator","part","required","rethrow","return","sealed","set","show","static","super","switch","sync","this","throw","true","try","typedef","var","void","when","while","with","yield"],built_in:s.concat(i).concat(["Never","Null","dynamic","print","document","querySelector","querySelectorAll","window"]),$pattern:/[A-Za-z][A-Za-z0-9_]*\??/},contains:[l,e.COMMENT(/\/\*\*(?!\/)/,/\*\//,{subLanguage:"markdown",relevance:0}),e.COMMENT(/\/{3,} ?/,/$/,{contains:[{subLanguage:"markdown",begin:".",end:"$",relevance:0}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"class",beginKeywords:"class interface",end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},r,{className:"meta",begin:"@[A-Za-z]+"},{begin:"=>"}]}}const Oh=[["javascript",Yp],["typescript",Xp],["python",jp],["java",Qp],["c",Jp],["cpp",eh],["csharp",th],["go",nh],["rust",oh],["ruby",rh],["php",lh],["swift",mh],["kotlin",hh],["xml",gh],["css",_h],["json",xh],["yaml",Mh],["markdown",Nh],["lua",Sh],["bash",Ah],["powershell",Ih],["dos",Bh],["sql",Rh],["dart",Lh]];for(const[e,n]of Oh)As.registerLanguage(e,n);const Dh={javascript:"javascript",typescript:"typescript",python:"python",java:"java",c:"c",cpp:"cpp",csharp:"csharp",go:"go",rust:"rust",ruby:"ruby",php:"php",swift:"swift",kotlin:"kotlin",html:"xml",css:"css",json:"json",xml:"xml",yaml:"yaml",markdown:"markdown",lua:"lua",bash:"bash",shell:"bash",powershell:"powershell",cmd:"dos",bat:"dos",sql:"sql",dart:"dart"};function js(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function $h(e,n){const o=Dh[n];if(!o||e.length===0)return js(e);try{return As.highlight(e,{language:o,ignoreIllegals:!0}).value}catch{return js(e)}}const Ph=t.defineComponent({name:"CodeBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){const n=t.ref(null),o=en(),r=Yn(),l=t.computed(()=>$h(Ae(e.block.content),e.block.attrs.language??"plain"));return()=>{const s=e.block.attrs.language??"plain",i=t.h("div",{ref:n,class:"block-code-lang",onMousedown:d=>{d.preventDefault(),d.stopPropagation()},onClick:d=>{if(d.stopPropagation(),!r.value)return;const f=new CustomEvent("code-lang-click",{bubbles:!0,detail:{blockId:e.block.id,anchor:n.value}});d.currentTarget.dispatchEvent(f)}},s.toUpperCase()),c=t.h("div",{class:"block-code-title"},o.t("codeBlock.title")),a=t.h("pre",{class:"block-code-highlight","aria-hidden":"true"},[t.h("code",{class:"hljs",innerHTML:l.value})]);return t.h("div",{class:["block-code-wrapper","block-focus-root",...En(e.block.attrs)],"data-lang":s},[c,i,a,t.h(Un,{block:e.block,placeholder:e.placeholder,class:"block-code"})])}}}),Hh={name:"codeBlock",schema:{type:"codeBlock",content:"text",nestable:!1,isolating:!0,inlineMarks:!1,attrs:{...Zd,language:{default:"plain",validate:e=>typeof e=="string"&&e.length>0}}},renderer:{component:Ph},slashCommands:[{id:"code-block",title:"slash.codeBlock.title",keywords:["code","fence","pre","代码","代码块","```","codeblock"],description:"slash.codeBlock.description",icon:ul,command:"convertBlock",category:"other",args:()=>({id:"__currentBlock__",type:"codeBlock",attrs:{language:"plain"}})}],inputRules:[{name:"code-fence",pattern:/^``` ?$/,command:"convertBlock",args:e=>(e==null||e.input,{id:"__currentBlock__",type:"codeBlock",attrs:{language:"plain"},__stripPrefix:3})}]},Vh={align:tn.align,indent:tn.indent,src:{default:"",validate:e=>typeof e=="string"},alt:{default:"",validate:e=>typeof e=="string"},title:{default:"",validate:e=>typeof e=="string"},width:{default:0,validate:e=>typeof e=="number"&&Number.isFinite(e)&&e>=0},height:{default:0,validate:e=>typeof e=="number"&&Number.isFinite(e)&&e>=0},caption:{default:"",validate:e=>typeof e=="string"},fileId:{default:0,validate:e=>typeof e=="number"&&Number.isFinite(e)&&Number.isInteger(e)&&e>=0}},Uh=t.defineComponent({name:"ImageBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){e.placeholder;const n=fn(),o=Yn(),r=en(),l=e.block.id,s=t.ref(Xn(l)),i=Oi((S,K)=>{S===l&&(s.value=K)});t.onBeforeUnmount(()=>{i()});const c=t.ref(null),a=t.ref(null),d=t.ref(!1);let f=0,u=0,h=0,p=1;function m(){var _,O;const S=a.value;if(!S)return;c.value={w:S.naturalWidth,h:S.naturalHeight};const K=e.block.attrs;(!K.width||K.width===0)&&(!K.height||K.height===0)&&((O=(_=n.commands).setAttrs)==null||O.call(_,{id:l,attrs:{...K,width:S.naturalWidth,height:S.naturalHeight}}))}function k(S){var N,A,W;S.preventDefault(),S.stopPropagation();const K=e.block.attrs,_=(N=a.value)==null?void 0:N.closest(".block-image-container"),O=_?_.clientWidth-8:0;let M=K.width||((A=c.value)==null?void 0:A.w)||200,E=K.height||((W=c.value)==null?void 0:W.h)||150;if(E>x){const me=M/Math.max(1,E);E=x,M=Math.round(E*me)}if(O>0&&M>O){const me=M/Math.max(1,E);M=O,E=Math.round(M/me)}f=M,u=E,h=S.clientX,p=f/Math.max(1,u),d.value=!0,document.addEventListener("mousemove",D,!0),document.addEventListener("mouseup",U,!0),document.addEventListener("selectstart",F,!0)}const x=600;function D(S){var E,N,A;if(!d.value)return;const K=S.clientX-h;let _=Math.max(40,Math.round(f+K)),O=Math.max(40,Math.round(_/p));O>x&&(O=x,_=Math.max(40,Math.round(O*p)));const M=(E=a.value)==null?void 0:E.closest(".block-image-container");if(M){const W=M.clientWidth-8;_>W&&(_=Math.max(40,W),O=Math.max(40,Math.round(_/p)))}(A=(N=n.commands).setAttrs)==null||A.call(N,{id:l,attrs:{...e.block.attrs,width:_,height:O}})}function U(){d.value=!1,document.removeEventListener("mousemove",D,!0),document.removeEventListener("mouseup",U,!0),document.removeEventListener("selectstart",F,!0)}function F(S){S.preventDefault()}const ee=t.ref(null);function $(){if(!ee.value){const S=document.createElement("input");S.type="file",S.accept="image/*",S.multiple=!1,ee.value=S,S.addEventListener("change",()=>{var _;const K=(_=S.files)==null?void 0:_[0];K&&V(K),S.value=""})}ee.value.click()}function V(S){const K=Xr(S),_=new AbortController;wn(l,{status:"pending",progress:0,file:S,tempPreviewUrl:K,controller:_}),Di(S.name,S,_,{onProgress:O=>{const M=Xn(l);M&&wn(l,{...M,progress:Math.max(0,Math.min(1,O))})},onSuccess:O=>{var A,W;const M=Xn(l);if(M!=null&&M.tempPreviewUrl&&M.tempPreviewUrl!==O.url)try{URL.revokeObjectURL(M.tempPreviewUrl)}catch{}const E={...e.block.attrs,src:O.url},N={...E,width:O.width??E.width,height:O.height??E.height,alt:O.alt??E.alt,title:O.title??E.title,fileId:O.fileId??E.fileId};(W=(A=n.commands).setAttrs)==null||W.call(A,{id:l,attrs:N}),wn(l,null)},onError:O=>{const M=Xn(l);M&&wn(l,{...M,status:"error",progress:0,error:O})}})}function re(){const S=Xn(l);!S||!S.file||V(S.file)}function G(){var S,K;(K=(S=n.commands).removeBlock)==null||K.call(S,{id:l})}function ne(){const S=s.value;return S!=null&&S.tempPreviewUrl?S.tempPreviewUrl:e.block.attrs.src??""}function Z(S){var K,_;S.stopPropagation(),o.value&&((_=(K=n.commands).selectBlock)==null||_.call(K,{id:l}))}return()=>{const S=e.block.attrs,K=ne(),_=s.value,O=S.width,M=S.height;let E=O;O>0&&M>x&&(E=Math.max(1,Math.round(O*x/M)));const N={},A=(_==null?void 0:_.status)==="error";O&&O>0&&!A&&(N.width=`${E}px`);const W=[],me=!!_&&_.status!=="success",le=n.getState().selection,he=le.kind==="blocks"&&le.blockIds.includes(l);if(o.value&&W.push(t.h("div",{class:["image-block-toolbar",{"image-block-toolbar-visible":me||he}]},[t.h("button",{class:"image-block-btn",title:r.t("image.replace"),onClick:Te=>{Te.stopPropagation(),$()}},[t.h(pn,{html:nu})]),t.h("button",{class:"image-block-btn",title:r.t("image.remove"),onClick:Te=>{Te.stopPropagation(),G()}},[t.h(pn,{html:tu})])])),(_==null?void 0:_.status)==="pending"){const Te=Math.round(_.progress*100);W.push(t.h("div",{class:"image-block-upload-overlay"},[t.h(pn,{html:Jd,class:"image-block-spinner"}),t.h("div",{class:"image-block-upload-label"},r.t("image.uploading")),t.h("div",{class:"image-block-progress-track"},[t.h("div",{class:"image-block-progress-bar",style:{width:`${Te}%`}})]),t.h("div",{class:"image-block-progress-pct"},`${Te}%`)]))}if((_==null?void 0:_.status)==="error"&&W.push(t.h("div",{class:"image-block-error-overlay"},[t.h("div",{class:"image-block-error-icon"},"!"),t.h("div",{class:"image-block-error-title"},r.t("image.uploadFailed")),t.h("div",{class:"image-block-error-msg"},_.error??""),t.h("button",{class:"image-block-retry-btn",onClick:Te=>{Te.stopPropagation(),re()}},[t.h(pn,{html:eu})," ",r.t("image.retry")])])),!K&&(!_||_.status==="success")&&W.push(t.h("div",{class:"image-block-empty",onClick:Te=>{Te.stopPropagation(),o.value&&$()}},[t.h(pn,{html:ou,class:"image-block-empty-icon"}),t.h("div",{class:"image-block-empty-title"},r.t("image.emptyTitle")),t.h("div",{class:"image-block-empty-sub"},r.t("image.emptySub"))])),K&&(_==null?void 0:_.status)!=="error"){const Te={};O&&O>0&&(Te.width=`${E}px`);const We=[t.h("img",{ref:a,class:"image-block-img",src:K,alt:S.alt||"",title:S.title||"",style:Te,draggable:!1,onLoad:m,onError:()=>{(!_||_.status!=="pending"&&_.status!=="error")&&wn(l,{status:"error",progress:0,error:r.t("image.loadFailed"),tempPreviewUrl:void 0})}})];c.value&&o.value&&We.push(t.h("div",{class:"image-block-resize-handle",onMousedown:k,title:r.t("image.resize")})),W.push(t.h("div",{class:"image-block-main"},We))}const ae=S.caption||"";!((_==null?void 0:_.status)==="error")&&(ae||K)&&W.push(t.h("div",{class:"image-block-caption",contenteditable:o.value?"true":"false","data-placeholder":r.t("image.captionPlaceholder"),onBlur:Te=>{var Mt,Zt;const We=Te.currentTarget.textContent??"";We!==ae&&((Zt=(Mt=n.commands).setAttrs)==null||Zt.call(Mt,{id:l,attrs:{...e.block.attrs,caption:We}}))},onInput:()=>{},onMousedown:Te=>{Te.stopPropagation()},onClick:Te=>{Te.stopPropagation()}},ae));const Se=["block-image-wrapper"];return(_==null?void 0:_.status)==="error"&&Se.push("image-block-wrapper-error"),(_==null?void 0:_.status)==="pending"&&!K&&!_.tempPreviewUrl&&Se.push("image-block-wrapper-loading"),t.h("div",{class:["block-image-container","block-focus-root",...En(S)]},[t.h("div",{class:Se,style:N,onClick:Z},W)])}}}),Qs={name:"image",schema:{type:"image",content:"none",nestable:!1,attrs:{...Vh},empty:e=>{const n=e.attrs.src;return typeof n!="string"||n.length===0}},renderer:{component:Uh,editable:!1},slashCommands:[{id:"image",title:"slash.image.title",keywords:["image","picture","photo","img","图片","图像","照片"],description:"slash.image.description",icon:Qd,command:"convertBlock",category:"other",args:()=>({id:"__currentBlock__",type:"image",attrs:{}})}],serialize:{toHTML:e=>{const n=e.attrs,o=n.src;if(!o)return"";const r=n.alt||"",l=n.title||"",s=n.width,i=n.height,c=n.caption||"",a=[];s&&s>0&&a.push(`width:${s}px`),i&&i>0&&a.push(`height:${i}px`);const d=a.length?` style="${a.join(";")}"`:"",f=l?` title="${vl(l)}"`:"",u=`<img src="${vl(o)}" alt="${vl(r)}"${f}${d}>`;return c?`<figure>${u}<figcaption>${zh(c)}</figcaption></figure>`:u},toMarkdown:e=>{const n=e.attrs,o=n.src;if(!o)return"";const r=n.alt||"",l=n.title||"",s=n.caption||"",i=l?``:``;return s?`${i}
|
|
17
|
+
*${s}*`:i}}};function vl(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function zh(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}const Cr='<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="3" width="12" height="10" rx="1"/><path d="M2 7h12M2 10h12M6 3v10M10 3v10"/></svg>',Fh='<svg viewBox="0 0 1024 1024" width="14" height="14" fill="currentColor" aria-hidden="true"><path d="M160 85.333333a32 32 0 0 0-32 32v42.666667A138.666667 138.666667 0 0 0 266.666667 298.666667h490.666666A138.666667 138.666667 0 0 0 896 160v-42.666667a32 32 0 0 0-64 0v42.666667a74.666667 74.666667 0 0 1-74.666667 74.666667H661.333333V117.333333a32 32 0 0 0-64 0V234.666667h-170.666666V117.333333a32 32 0 0 0-64 0V234.666667H266.666667A74.666667 74.666667 0 0 1 192 160v-42.666667A32 32 0 0 0 160 85.333333zM160 938.666667a32 32 0 0 1-32-32v-42.666667A138.666667 138.666667 0 0 1 266.666667 725.333333h490.666666A138.666667 138.666667 0 0 1 896 864v42.666667a32 32 0 0 1-64 0v-42.666667a74.666667 74.666667 0 0 0-74.666667-74.666667H661.333333v117.333334a32 32 0 0 1-64 0V789.333333h-170.666666v117.333334a32 32 0 0 1-64 0V789.333333H266.666667a74.666667 74.666667 0 0 0-74.666667 74.666667v42.666667a32 32 0 0 1-32 32zM512 557.226667l62.72 62.72a32 32 0 1 0 45.226667-45.226667L557.226667 512l62.72-62.72a32 32 0 1 0-45.226667-45.226667L512 466.773333l-62.72-62.72a32 32 0 1 0-45.226667 45.226667L466.773333 512l-62.72 62.72a32 32 0 1 0 45.226667 45.226667L512 557.226667z"/><path d="M372.352 544c0.981333-1.109333 2.005333-2.176 3.072-3.242667L404.181333 512l-28.757333-28.757333a78.72 78.72 0 0 1-3.072-3.242667H117.333333a32 32 0 0 0 0 64h255.018667zM662.314667 544h244.352a32 32 0 0 0 0-64h-244.352a77.909333 77.909333 0 0 1-3.072 3.242667l-28.757334 28.757333 28.757334 28.757333 3.072 3.242667z"/></svg>',Kh='<svg viewBox="0 0 1024 1024" width="14" height="14" fill="currentColor" aria-hidden="true"><path d="M938.666667 160a32 32 0 0 0-32-32h-42.666667A138.666667 138.666667 0 0 0 725.333333 266.666667v490.666666A138.666667 138.666667 0 0 0 864 896h42.666667a32 32 0 0 0 0-64h-42.666667a74.666667 74.666667 0 0 1-74.666667-74.666667V661.333333h117.333334a32 32 0 0 0 0-64H789.333333v-170.666666h117.333334a32 32 0 0 0 0-64H789.333333V266.666667c0-41.216 33.450667-74.666667 74.666667-74.666667h42.666667a32 32 0 0 0 32-32zM85.333333 160A32 32 0 0 1 117.333333 128h42.666667A138.666667 138.666667 0 0 1 298.666667 266.666667v490.666666A138.666667 138.666667 0 0 1 160 896h-42.666667a32 32 0 0 1 0-64h42.666667a74.666667 74.666667 0 0 0 74.666667-74.666667V661.333333H117.333333a32 32 0 0 1 0-64H234.666667v-170.666666H117.333333a32 32 0 0 1 0-64H234.666667V266.666667A74.666667 74.666667 0 0 0 160 192h-42.666667A32 32 0 0 1 85.333333 160zM466.773333 512l-62.72 62.72a32 32 0 1 0 45.226667 45.226667L512 557.226667l62.72 62.72a32 32 0 1 0 45.226667-45.226667L557.226667 512l62.72-62.72a32 32 0 1 0-45.226667-45.226667L512 466.773333l-62.72-62.72a32 32 0 1 0-45.226667 45.226667L466.773333 512z"/><path d="M480 372.352c1.109333 0.981333 2.176 2.005333 3.242667 3.072l28.757333 28.757333 28.757333-28.757333c1.066667-1.066667 2.133333-2.090667 3.242667-3.072V117.333333a32 32 0 0 0-64 0v255.018667zM480 662.314667v244.352a32 32 0 0 0 64 0v-244.352a77.909333 77.909333 0 0 1-3.242667-3.072L512 630.485333l-28.757333 28.757334-3.242667 3.072z"/></svg>',Js='<svg viewBox="0 0 1024 1024" width="14" height="14" fill="currentColor" aria-hidden="true"><path d="M128 266.666667A138.666667 138.666667 0 0 1 266.666667 128h490.666666A138.666667 138.666667 0 0 1 896 266.666667v246.272a276.096 276.096 0 0 0-64-30.250667V426.666667h-170.666667v56.021333a276.096 276.096 0 0 0-64 30.250667V426.666667h-170.666666v170.666666h86.272a276.096 276.096 0 0 0-30.250667 64H426.666667v170.666667h56.021333c7.381333 22.784 17.578667 44.245333 30.250667 64H266.666667A138.666667 138.666667 0 0 1 128 757.333333V266.666667zM266.666667 192A74.666667 74.666667 0 0 0 192 266.666667V362.666667h170.666667v-170.666667H266.666667zM192 426.666667v170.666666h170.666667v-170.666666h-170.666667z m469.333333-64h170.666667V266.666667a74.666667 74.666667 0 0 0-74.666667-74.666667H661.333333v170.666667z m-64-170.666667h-170.666666v170.666667h170.666666v-170.666667z m-405.333333 469.333333v96c0 41.216 33.450667 74.666667 74.666667 74.666667H362.666667v-170.666667h-170.666667z"/><path d="M981.333333 746.666667a234.666667 234.666667 0 1 1-469.333333 0 234.666667 234.666667 0 0 1 469.333333 0z m-234.666666-30.165334l-70.229334-70.272a21.333333 21.333333 0 0 0-30.208 30.208l70.272 70.229334-70.272 70.229333a21.333333 21.333333 0 0 0 30.208 30.208l70.229334-70.272 70.229333 70.272a21.333333 21.333333 0 0 0 30.208-30.208L776.832 746.666667l70.272-70.229334a21.333333 21.333333 0 0 0-30.208-30.208L746.666667 716.501333z"/></svg>',Wh={indent:tn.indent,rows:{default:3,validate:e=>typeof e=="number"&&Number.isInteger(e)&&e>=1},cols:{default:3,validate:e=>typeof e=="number"&&Number.isInteger(e)&&e>=1},cells:{default:[],validate:rd},colWidths:{default:[],validate:e=>Array.isArray(e)},headerRow:{default:!1,validate:e=>typeof e=="boolean"}},Gh=t.defineComponent({name:"TableBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e,{expose:n}){e.placeholder;const o=fn(),r=Yn(),l=en(),s=e.block.id,i=t.inject($r,null);let c="__none__";function a(y){if(!y)return"null";const v=y.selectionRect,T=y.tableActiveMarks?[...y.tableActiveMarks].sort().join(","):"";return[y.visible?"v":"-",y.cellEditMode?"c":y.tableMode?"t":"-",String(y.blockId??""),String(y.blockType??""),y.showDelete?"D":"-",y.showMerge?"M":"-",y.showSplit?"S":"-",y.showHeaderRow?"H":"-",y.headerRowActive?"h":"-",y.tableActiveColor??"",y.tableActiveBgColor??"",y.tableActiveVerticalAlign??"",T,v?`${v.left.toFixed(1)},${v.top.toFixed(1)},${v.width.toFixed(1)},${v.height.toFixed(1)}`:"",y.blockAttrs?JSON.stringify(y.blockAttrs):""].join("|")}function d(y){if(!i)return;const v=a(y);v!==c&&(c=v,i.value=y)}function f(y){i&&t.nextTick(()=>{d(y)})}const u=t.computed(()=>ro(e.block.attrs)),h=new Map,p=t.ref(null),m=t.ref(null),k=t.ref(null);let x=0;const D=500;function U(){return Date.now()-x<D}function F(y){var R;const v=y.target;!!(v&&(v.nodeType===1?v.closest(".hover-toolbar"):(R=v.parentElement)!=null&&R.closest(".hover-toolbar")))&&(x=Date.now())}function ee(){x=Date.now()}const $=t.ref(null);let V=0,re=0;const G=t.ref({kind:"none"}),ne=t.ref(null);let Z=!1;const S=t.ref(null);let K=null,_=null,O=!1,M=!1;const E=t.reactive({blockType:"paragraph",blockAttrs:{align:"left"},marks:new Set,textColor:"",bgColor:"",verticalAlign:"middle",showDelete:!1,deleteLabel:"",deleteIcon:Js,showMerge:!1,showSplit:!1,showHeaderRow:!1,headerRowActive:!1}),N=t.ref(null),A=t.reactive({visible:!1,selectionRect:null}),W=t.reactive({visible:!1,anchorRect:null,href:"",text:"",initialMode:"edit",showTextInput:!1});let me=null,le=null,he=!1;const ae=t.reactive({visible:!1,row:-1,col:-1,anchor:null,canContinue:!1,canStartNew:!1,currentNumber:1});function ie(){ae.visible=!1,ae.anchor=null,ae.row=-1,ae.col=-1}const Se=t.reactive({visible:!1,row:-1,col:-1,anchor:null,initialValue:1});function Te(){Se.visible=!1,Se.anchor=null,Se.row=-1,Se.col=-1}function We(y,v,T){var pe,xe;if(!r.value)return;const R=(pe=u.value.cells[y])==null?void 0:pe[v];if(!R||R.covered||R.cellType!=="orderedList")return;const q=qr(u.value,y,v),X=typeof R.startNumber=="number";let ce=!1;for(let Ne=y-1;Ne>=0;Ne--){const qe=(xe=u.value.cells[Ne])==null?void 0:xe[v];if(!(!qe||qe.covered)){ce=qe.cellType==="orderedList";break}}const ue=X&&ce,ke=q!==1;tt(),A.visible=!1,A.selectionRect=null,Te(),ae.visible=!0,ae.row=y,ae.col=v,ae.anchor=T,ae.canContinue=ue,ae.canStartNew=ke,ae.currentNumber=q}function Mt(){var v,T;if(ae.row<0||ae.col<0)return;const y=Fo(u.value,ae.row,ae.col,{startNumber:null});(T=(v=o.commands).setAttrs)==null||T.call(v,{id:s,attrs:y}),ie()}function Zt(){var v,T;if(ae.row<0||ae.col<0)return;const y=Fo(u.value,ae.row,ae.col,{startNumber:1});(T=(v=o.commands).setAttrs)==null||T.call(v,{id:s,attrs:y}),ie()}function Gt(){if(ae.row<0||ae.col<0)return;const y=ae.anchor,v=ae.row,T=ae.col,R=ae.currentNumber;ie(),y&&(Se.visible=!0,Se.initialValue=R,Se.anchor=y,Se.row=v,Se.col=T)}function Rt(y){var T,R;if(Se.row<0||Se.col<0){Te();return}const v=Fo(u.value,Se.row,Se.col,{startNumber:y});(R=(T=o.commands).setAttrs)==null||R.call(T,{id:s,attrs:v}),Te()}function tt(){if(!W.visible)return;if(W.visible=!1,me=null,le=null,A.visible=!1,A.selectionRect=null,he){he=!1;return}const y=k.value;if(y){const v=h.get(`${y.row}-${y.col}`);v&&ve(y.row,y.col,v),k.value=null}}function yt(){const y=window.getSelection();if(!y||y.rangeCount===0)return null;const T=y.getRangeAt(0).commonAncestorContainer,R=T.nodeType===1?T:T.parentElement;return R?R.closest("a"):null}function vt(){const y=window.getSelection();if(!y||y.rangeCount===0)return;const v=y.getRangeAt(0),T=v.getBoundingClientRect();if(T.width===0&&T.height===0)return;me=v.cloneRange();const R=yt(),q=(R==null?void 0:R.getAttribute("href"))??"",X=y.toString();W.anchorRect=T,W.href=q,W.text=X,W.initialMode=q?"view":"edit",W.showTextInput=!X&&!q,W.visible=!0,A.visible=!1}function Ze(y){const v=y.getAttribute("href")||"",T=y.textContent||"",R=y.getBoundingClientRect();W.anchorRect=R,W.href=v,W.text=T,W.initialMode="view",W.showTextInput=!1,W.visible=!0,he=!0,le=y,A.visible=!1,A.selectionRect=null}function Ve(y){const v=y.closest(".table-cell-inner");if(!v)return;const T=v.closest(".table-cell");if(!T)return;const R=Number(T.getAttribute("data-row")),q=Number(T.getAttribute("data-col"));!Number.isFinite(R)||!Number.isFinite(q)||ve(R,q,v)}function Ct(y,v){if(le&&le.isConnected){le.setAttribute("href",y),le.setAttribute("target","_blank"),le.setAttribute("rel","noopener noreferrer"),v!==void 0&&v!==le.textContent&&(le.textContent=v),Ve(le);return}const T=window.getSelection();if(!T)return;if(me){const q=k.value,X=q?h.get(`${q.row}-${q.col}`):null;X&&X.isConnected&&(T.removeAllRanges(),T.addRange(me))}const R=yt();if(R)R.setAttribute("href",y),R.setAttribute("target","_blank"),R.setAttribute("rel","noopener noreferrer"),v!==void 0&&v!==R.textContent&&(R.textContent=v);else{if(T.rangeCount===0)return;const q=T.getRangeAt(0),X=document.createElement("a");X.setAttribute("href",y),X.setAttribute("target","_blank"),X.setAttribute("rel","noopener noreferrer");try{X.appendChild(q.extractContents()),q.insertNode(X),T.removeAllRanges();const ce=document.createRange();ce.selectNodeContents(X),T.addRange(ce),me=ce.cloneRange()}catch{}}Tt()}function fe(){if(le&&le.isConnected){const R=le,q=R.parentElement;if(q){for(;R.firstChild;)q.insertBefore(R.firstChild,R);q.removeChild(R)}Ve(R);return}const y=window.getSelection();if(!y)return;if(me){const R=k.value,q=R?h.get(`${R.row}-${R.col}`):null;q&&q.isConnected&&(y.removeAllRanges(),y.addRange(me))}const v=yt();if(!v)return;const T=v.parentElement;if(T){for(;v.firstChild;)T.insertBefore(v.firstChild,v);T.removeChild(v);try{y.removeAllRanges(),me&&me.startContainer!==v&&y.addRange(me)}catch{}Tt()}}function Tt(){const y=k.value;if(!y)return;const v=h.get(`${y.row}-${y.col}`);v&&ve(y.row,y.col,v)}let Xe=!1;function Re(){var X,ce;if(!r.value){A.visible=!1,A.selectionRect=null;return}if(A.visible&&U())return;if(!k.value){const ue=window.getSelection();if(!ue||ue.rangeCount===0||ue.isCollapsed){A.visible=!1,A.selectionRect=null;return}const ke=ue.getRangeAt(0);if(!((X=ke.commonAncestorContainer.nodeType===1?ke.commonAncestorContainer:ke.commonAncestorContainer.parentElement)==null?void 0:X.closest(".table-cell-inner"))){A.visible=!1,A.selectionRect=null;return}return}const v=window.getSelection();if(!v||v.rangeCount===0||v.isCollapsed){A.visible=!1,A.selectionRect=null;return}const T=v.getRangeAt(0);if(!((ce=T.commonAncestorContainer.nodeType===1?T.commonAncestorContainer:T.commonAncestorContainer.parentElement)==null?void 0:ce.closest(".table-cell-inner"))){A.visible=!1,A.selectionRect=null;return}const q=T.getBoundingClientRect();if(q.width===0&&q.height===0){A.visible=!1,A.selectionRect=null;return}Xe||(A.visible=!0,A.selectionRect=q,K&&(clearTimeout(K),K=null),S.value=null)}function qt(){Xe&&(Xe=!1,Re())}function rt(y){const v=ht.value;if(!v)return y;const T=v.getBoundingClientRect();return new DOMRect(T.left+y.left-v.scrollLeft,T.top+y.top,y.width,y.height)}function Et(y){r.value&&(K&&(clearTimeout(K),K=null),_&&(clearTimeout(_),_=null),A.visible=!1,A.selectionRect=null,O=!1,S.value=rt(y))}function P(y=150){_&&(clearTimeout(_),_=null),O=!1,K=setTimeout(()=>{S.value=null,K=null},y)}function w(){const y=N.value;y&&y.focus()}function z(y){var T,R;const v=y.target;if(v.closest("a")&&v.closest(".table-cell-inner")){y.preventDefault();return}v.closest(".table-cell, .table-wrapper, table, .table-row-strip, .table-col-strip, .table-insert-dot, .table-corner-handle")||(y.stopPropagation(),G.value={kind:"none"},m.value=null,P(0),(R=(T=o.commands).selectBlock)==null||R.call(T,{id:s}))}function we(y,v){if(y.length!==v.length)return!1;for(let T=0;T<y.length;T++){const R=y[T],q=v[T];if(R.type!==q.type||"text"in R&&R.text!==q.text)return!1;const X=R.marks??[],ce=q.marks??[];if(X.length!==ce.length)return!1;for(let ue=0;ue<X.length;ue++){const ke=X[ue],pe=ce[ue];if(ke.type!==pe.type)return!1;const xe=ke.attrs??{},Ne=pe.attrs??{},qe=Object.keys(xe),je=Object.keys(Ne);if(qe.length!==je.length)return!1;for(const at of qe)if(xe[at]!==Ne[at])return!1}}return!0}function ve(y,v,T){var ke,pe,xe;const R=mn(T),q=lr(R),X=u.value,ce=(ke=X.cells[y])==null?void 0:ke[v];if(ce&&we(ce.content,q))return;const ue=zo(X,y,v,q);if((xe=(pe=o.commands).setAttrs)==null||xe.call(pe,{id:s,attrs:ue}),q!==R){const Ne=Zn(q);T.innerHTML!==Ne&&(T.innerHTML=Ne)}}function nt(y,v,T,R){var X,ce,ue;if(A.visible&&U())return;const q=R==null?void 0:R.relatedTarget;if(!(q!=null&&q.closest(".link-popover"))&&!(q!=null&&q.closest(".hover-toolbar"))){if(A.visible){const ke=window.getSelection();if(ke&&ke.rangeCount>0&&!ke.isCollapsed){const pe=ke.getRangeAt(0);if((X=pe.commonAncestorContainer.nodeType===1?pe.commonAncestorContainer:pe.commonAncestorContainer.parentElement)==null?void 0:X.closest(".table-cell-inner"))return}}((ce=k.value)==null?void 0:ce.row)===y&&((ue=k.value)==null?void 0:ue.col)===v&&(k.value=null),A.visible=!1,A.selectionRect=null,tt(),ve(y,v,T)}}function lt(y){var R;if(A.visible&&U()){m.value&&(m.value=null),G.value.kind!=="none"&&(G.value={kind:"none"},P(0)),ie(),Te();return}const v=y.currentTarget,T=y.relatedTarget;if(!(T&&v.contains(T))&&!(T!=null&&T.closest(".link-popover"))&&!(T!=null&&T.closest(".hover-toolbar"))){if(A.visible){const q=window.getSelection();if(q&&q.rangeCount>0&&!q.isCollapsed){const X=q.getRangeAt(0);if((R=X.commonAncestorContainer.nodeType===1?X.commonAncestorContainer:X.commonAncestorContainer.parentElement)==null?void 0:R.closest(".table-cell-inner")){m.value&&(m.value=null),G.value.kind!=="none"&&(G.value={kind:"none"},P(0)),ie(),Te();return}}}m.value&&(m.value=null),G.value.kind!=="none"&&(G.value={kind:"none"},P(0)),k.value&&(k.value=null),tt(),ie(),Te()}}function on(y,v,T,R){var q,X,ce,ue,ke,pe,xe,Ne,qe,je,at,Yt,jt;if(R.key==="Enter"&&!R.shiftKey&&!R.ctrlKey&&!R.metaKey){const Ot=(q=u.value.cells[y])==null?void 0:q[v];if((Ot==null?void 0:Ot.cellType)==="codeBlock"){R.preventDefault(),R.stopPropagation();const Ue=window.getSelection();let Ye=((X=T.textContent)==null?void 0:X.length)??0;if(Ue&&Ue.rangeCount>0){const ut=Ue.getRangeAt(0);if(T.contains(ut.startContainer)){const xt=document.createRange();xt.selectNodeContents(T);try{xt.setEnd(ut.startContainer,ut.startOffset),Ye=xt.toString().length}catch{Ye=((ce=T.textContent)==null?void 0:ce.length)??0}}}if(Ue&&Ue.rangeCount>0){const ut=Ue.getRangeAt(0);if(T.contains(ut.commonAncestorContainer)){ut.collapsed||ut.deleteContents();const xt=document.createTextNode(`
|
|
18
|
+
`);ut.insertNode(xt),ut.setStartAfter(xt),ut.collapse(!0),Ue.removeAllRanges(),Ue.addRange(ut)}}ve(y,v,T);const Qt=Ye+1;t.nextTick(()=>{const ut=h.get(`${y}-${v}`);if(!ut)return;ut.focus();const xt=window.getSelection();if(!xt)return;const Jt=document.createRange();let Pt=0,Dt=!1;const Rn=Vt=>{var Ln;if(!Dt)if(Vt.nodeType===Node.TEXT_NODE){const Ut=((Ln=Vt.textContent)==null?void 0:Ln.length)??0;Pt+Ut>=Qt&&(Jt.setStart(Vt,Math.max(0,Qt-Pt)),Jt.collapse(!0),Dt=!0),Pt+=Ut}else for(const Ut of Vt.childNodes)Rn(Ut)};Rn(ut),Dt||(Jt.selectNodeContents(ut),Jt.collapse(!1)),xt.removeAllRanges(),xt.addRange(Jt)});return}R.preventDefault(),R.stopPropagation(),ve(y,v,T),k.value=null,A.visible=!1,A.selectionRect=null,tt(),T.blur(),G.value={kind:"cell",rect:{r1:y,c1:v,r2:y,c2:v}},m.value={anchor:{row:y,col:v},focus:{row:y,col:v}},w(),t.nextTick(()=>{const Ue=ct(y,v,y,v);Ue&&Et(Ue)});return}if(R.key==="Tab"){R.preventDefault(),R.stopPropagation(),tt();const Ot=qh(u.value,y,v,R.shiftKey);if(!Ot){if(Yh(u.value,y,v)&&!R.shiftKey){const Dt=mn(T),Rn=u.value,Vt=zo(Rn,y,v,Dt),Ln=Ti(Vt,Vt.rows);(ke=(ue=o.commands).setAttrs)==null||ke.call(ue,{id:s,attrs:Ln}),t.nextTick(()=>{const Ut=`${Ln.rows-1}-0`,$t=h.get(Ut);$t==null||$t.focus(),Cl($t)});return}return}const{r:Ue,c:Ye}=Ot,Qt=mn(T),ut=u.value,xt=(pe=ut.cells[y])==null?void 0:pe[v];let Jt=ut;xt&&(we(xt.content,Qt)||(Jt=zo(ut,y,v,Qt))),Jt!==ut&&((Ne=(xe=o.commands).setAttrs)==null||Ne.call(xe,{id:s,attrs:Jt})),t.nextTick(()=>{const Pt=`${Ue}-${Ye}`,Dt=h.get(Pt);Dt==null||Dt.focus(),R.shiftKey?ec(Dt):Cl(Dt)});return}if(R.key==="Backspace"){const Ot=(qe=u.value.cells[y])==null?void 0:qe[v],Ue=Ot==null?void 0:Ot.cellType;if(Ue&&Ue!=="paragraph"){const Ye=window.getSelection();let Qt=((je=T.textContent)==null?void 0:je.length)??0;if(Ye&&Ye.rangeCount>0){const ut=Ye.getRangeAt(0);if(T.contains(ut.startContainer)){const xt=document.createRange();xt.selectNodeContents(T);try{xt.setEnd(ut.startContainer,ut.startOffset),Qt=xt.toString().length}catch{Qt=((at=T.textContent)==null?void 0:at.length)??0}}}if(Qt===0&&(!T.textContent||T.textContent.trim()===""||(Ue==="bulletList"||Ue==="orderedList"||Ue==="todoList"))){R.preventDefault(),R.stopPropagation(),tt(),ie(),Te();const Jt=mn(T),Pt=u.value,Dt=zo(Pt,y,v,Jt),Rn=Fo(Dt,y,v,{cellType:"paragraph"});(jt=(Yt=o.commands).setAttrs)==null||jt.call(Yt,{id:s,attrs:Rn}),t.nextTick(()=>{const Vt=h.get(`${y}-${v}`);Vt&&(Vt.focus(),ec(Vt))});return}}}R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),ve(y,v,T),k.value=null,A.visible=!1,A.selectionRect=null,tt(),T.blur())}function cn(y,v,T){k.value={row:y,col:v},m.value&&(m.value=null),G.value.kind!=="none"&&(G.value={kind:"none"},P(0))}function He(y){const v=y.target;if(!v)return null;const T=v.closest(".table-cell");if(!T)return null;const R=Number(T.getAttribute("data-row")??T.dataset.row),q=Number(T.getAttribute("data-col")??T.dataset.col);return!Number.isFinite(R)||!Number.isFinite(q)?null:{r:R,c:q,el:T}}function vn(y){if(!r.value)return;const v=y.target;if(!v)return;const T=v.closest(".table-cell-inner");if(!T)return;const R=T.closest(".table-cell");if(!R)return;const q=Number(R.getAttribute("data-row")),X=Number(R.getAttribute("data-col"));!Number.isFinite(q)||!Number.isFinite(X)||on(q,X,T,y)}function Xt(y){var pe,xe;const v=y.target;if(v.closest(".table-row-strip, .table-col-strip, .table-insert-dot, .table-corner-handle, .table-col-resizer")||v.tagName==="INPUT"&&v.classList.contains("table-cell-todo-checkbox")||v.classList.contains("table-cell-ol-marker"))return;const T=v.closest("a");if(T&&T.closest(".table-cell-inner")){y.preventDefault(),y.stopPropagation(),Ze(T);return}W.visible&&tt();const R=He(y);if(!R||y.button!==0)return;const q=k.value;if(q&&q.row===R.r&&q.col===R.c){Xe=!0,document.addEventListener("mouseup",qt,{once:!0,capture:!0});return}y.preventDefault(),y.stopPropagation();const{r:X,c:ce}=R,ue=document.activeElement;ue&&ue.closest(".table-cell-inner")&&ue.blur(),k.value=null,(xe=(pe=o.commands).selectBlock)==null||xe.call(pe,{id:s}),w(),M=S.value!==null,M&&(O=!0,K&&(clearTimeout(K),K=null),_&&(clearTimeout(_),_=null)),G.value={kind:"none"},Z=!0;const ke={row:X,col:ce};ne.value={start:ke,current:ke},m.value={anchor:ke,focus:ke},document.addEventListener("mouseup",Tn,!0)}function bn(y){if(!Z||!ne.value)return;const v=He(y);if(!v)return;const{r:T,c:R}=v,q=ne.value.current;if(T===q.row&&R===q.col)return;ne.value={...ne.value,current:{row:T,col:R}};const X=ne.value.start;m.value={anchor:X,focus:{row:T,col:R}}}function Cn(y){if(!r.value)return;const v=y.target;if(v.tagName==="INPUT"&&v.classList.contains("table-cell-todo-checkbox")||v.classList.contains("table-cell-ol-marker"))return;const T=He(y);if(!T)return;const{r:R,c:q}=T,X=k.value;X&&X.row===R&&X.col===q||(y.preventDefault(),y.stopPropagation(),_&&(clearTimeout(_),_=null),O=!1,Z=!1,ne.value=null,m.value=null,G.value={kind:"none"},P(0),document.removeEventListener("mouseup",Tn,!0),k.value={row:R,col:q},t.nextTick(()=>{const ce=`${R}-${q}`,ue=h.get(ce);ue&&(ue.focus(),Cl(ue))}))}function Tn(y){if(Z&&ne.value){const v=ne.value.start,T=ne.value.current,R=Math.min(v.row,T.row),q=Math.min(v.col,T.col),X=Math.max(v.row,T.row),ce=Math.max(v.col,T.col),ue=Hn(u.value,R,q,X,ce),{r1:ke,c1:pe,r2:xe,c2:Ne}=ue;if(G.value={kind:"cell",rect:{r1:ke,c1:pe,r2:xe,c2:Ne}},m.value={anchor:{row:ke,col:pe},focus:{row:xe,col:Ne}},ke!==xe||pe!==Ne)t.nextTick(()=>{const je=ct(ke,pe,xe,Ne);je&&Et(je)});else if(M){const je=ct(ke,pe,xe,Ne);je&&Et(je)}else _&&clearTimeout(_),_=setTimeout(()=>{_=null;const je=ct(ke,pe,xe,Ne);je&&Et(je)},250)}Z=!1,ne.value=null,document.removeEventListener("mouseup",Tn,!0)}function Me(y){if(G.value.kind==="row"&&G.value.row===y){G.value={kind:"none"},m.value=null,P(0);return}S.value!==null&&(O=!0);const v=u.value,T=v.cols,R=y,q=0,X=y,ce=Math.max(0,T-1),ue=T>0?Hn(v,R,q,X,ce):{r1:R,c1:q,r2:X,c2:ce};G.value={kind:"row",row:y},m.value=T>0?{anchor:{row:ue.r1,col:ue.c1},focus:{row:ue.r2,col:ue.c2}}:null,k.value=null;const ke=document.activeElement;ke&&ke.closest(".table-cell-inner")&&ke.blur(),w(),t.nextTick(()=>{const pe=At.value,xe=pe.rowTops[ue.r1]??0,Ne=pe.rowTops[ue.r2]??0,qe=pe.rowHeights[ue.r2]??32,je=Ne+qe-xe,at=pe.colWidths.length>0?pe.colWidths.reduce((Ot,Ue)=>Ot+Ue,0):v.colWidths.reduce((Ot,Ue)=>Ot+Ue,0),Yt=pe.colLefts[0]??0,jt=new DOMRect(Yt,xe,at,je);Et(jt)})}function Ie(y){if(G.value.kind==="col"&&G.value.col===y){G.value={kind:"none"},m.value=null,P(0);return}S.value!==null&&(O=!0);const v=u.value,T=v.rows,R=0,q=y,X=Math.max(0,T-1),ce=y,ue=T>0?Hn(v,R,q,X,ce):{r1:R,c1:q,r2:X,c2:ce};G.value={kind:"col",col:y},m.value=T>0?{anchor:{row:ue.r1,col:ue.c1},focus:{row:ue.r2,col:ue.c2}}:null,k.value=null;const ke=document.activeElement;ke&&ke.closest(".table-cell-inner")&&ke.blur(),w(),t.nextTick(()=>{const pe=At.value,xe=pe.colLefts[ue.c1]??0,Ne=pe.colLefts[ue.c2]??0,qe=pe.colWidths[ue.c2]??80,je=Ne+qe-xe,at=pe.rowTops[0]??0,Yt=T>0?(pe.rowTops[T-1]??0)+(pe.rowHeights[T-1]??32)-at:32,jt=new DOMRect(xe,at,je,Yt);Et(jt)})}function Ge(){if(G.value.kind==="all"){G.value={kind:"none"},m.value=null,P(0);return}S.value!==null&&(O=!0);const y=u.value;if(y.rows===0||y.cols===0)return;G.value={kind:"all"};const v=Hn(y,0,0,y.rows-1,y.cols-1);m.value={anchor:{row:v.r1,col:v.c1},focus:{row:v.r2,col:v.c2}},k.value=null;const T=document.activeElement;T&&T.closest(".table-cell-inner")&&T.blur(),w(),t.nextTick(()=>{const R=At.value,q=R.rowTops[0]??0,X=R.colLefts[0]??0,ce=R.colWidths.length>0?R.colWidths.reduce((xe,Ne)=>xe+Ne,0):y.colWidths.reduce((xe,Ne)=>xe+Ne,0),ue=R.rowTops[y.rows-1]??0,ke=R.rowHeights[y.rows-1]??32,pe=new DOMRect(X,q,ce,ue+ke-q);Et(pe)})}function ct(y,v,T,R){const q=At.value,X=q.rowTops[y]??0,ce=q.rowTops[T]??0,ue=q.rowHeights[T]??32,ke=ce+ue,pe=q.colLefts[v]??0,xe=q.colLefts[R]??0,Ne=q.colWidths[R]??80,qe=xe+Ne;return new DOMRect(pe,X,qe-pe,ke-X)}t.onBeforeUnmount(()=>{document.removeEventListener("mouseup",Tn,!0),document.removeEventListener("mouseup",qt,!0),document.removeEventListener("mousemove",_n,!0),document.removeEventListener("mouseup",xn,!0),document.removeEventListener("keydown",Ke,!0),document.removeEventListener("selectionchange",Re),document.removeEventListener("mousedown",_t,!0),window.removeEventListener("scroll",ft,!0),document.removeEventListener("touchmove",ft,!0),document.removeEventListener("mousedown",F,!0),document.removeEventListener("mouseup",ee,!0),_&&(clearTimeout(_),_=null)});function Ke(y){var q,X;if(!r.value)return;const v=G.value;if(v.kind==="none")return;const T=document.activeElement;if(T!=null&&T.closest(".table-cell-inner"))return;if(y.key==="Escape"){y.preventDefault(),y.stopPropagation(),G.value={kind:"none"},m.value=null,P(0);return}if(y.key==="Delete"||y.key==="Backspace"){if(y.preventDefault(),y.stopPropagation(),v.kind==="row")Be("tableRemoveRow",{row:v.row});else if(v.kind==="col")Be("tableRemoveCol",{col:v.col});else if(v.kind==="all")Be("tableDelete");else if(v.kind==="cell"){const{r1:ce,c1:ue,r2:ke,c2:pe}=v.rect,xe=[];let Ne=u.value;for(let qe=ce;qe<=ke;qe++)for(let je=ue;je<=pe;je++)Ne=zo(Ne,qe,je,xe);(X=(q=o.commands).setAttrs)==null||X.call(q,{id:s,attrs:Ne})}}}function _t(y){if(!W.visible&&!ae.visible&&!Se.visible)return;const v=y.target;v.closest(".link-popover")||v.closest(".ordered-list-menu")||v.closest(".number-picker")||N.value&&N.value.contains(v)||(W.visible&&tt(),ae.visible&&ie(),Se.visible&&Te())}function ft(){if(W.visible&&tt(),ae.visible&&ie(),Se.visible&&Te(),S.value!==null&&m.value){const y=Yo(m.value);if(y){const v=Hn(u.value,y.r1,y.c1,y.r2,y.c2),T=ct(v.r1,v.c1,v.r2,v.c2);T&&(S.value=rt(T))}}}t.onMounted(()=>{document.addEventListener("keydown",Ke,!0),document.addEventListener("selectionchange",Re),document.addEventListener("mousedown",_t,!0),document.addEventListener("mousedown",F,!0),document.addEventListener("mouseup",ee,!0),window.addEventListener("scroll",ft,!0),document.addEventListener("touchmove",ft,{passive:!0,capture:!0})});const ht=t.ref(null),At=t.ref({rowTops:[],rowHeights:[],colLefts:[],colWidths:[],wrapperOffsetLeft:0,wrapperOffsetTop:0,tableTotalWidth:0,tableTotalHeight:0});function an(){const y=p.value,v=ht.value,T=N.value;if(!y||!v||!T)return;const R=u.value.rows,q=u.value.cols,X=v.getBoundingClientRect(),ce=T.getBoundingClientRect(),ue=Math.round(X.left-ce.left),ke=Math.round(X.top-ce.top),pe=Array.from(y.querySelectorAll("tr")),xe=[],Ne=[];for(const Ue of pe){const Ye=Ue.getBoundingClientRect();xe.push(Math.round(Ye.top-X.top)),Ne.push(Math.round(Ye.height))}for(;xe.length<R;){const Ue=xe.length>0?xe[xe.length-1]+Ne[Ne.length-1]:0;xe.push(Ue),Ne.push(Ne.length>0?Ne[Ne.length-1]:32)}const qe=v.scrollLeft,je=[],at=[],Yt=Array.from(y.querySelectorAll("colgroup > col"));if(Yt.length>0)for(const Ue of Yt){const Ye=Ue.getBoundingClientRect();je.push(Math.round(Ye.left-X.left+qe)),at.push(Math.round(Ye.width))}for(;je.length<q;){const Ue=je.length>0?je[je.length-1]+at[at.length-1]:0;je.push(Ue),at.push(at.length>0?at[at.length-1]:80)}const jt=at.reduce((Ue,Ye)=>Ue+Ye,0),Ot=Ne.reduce((Ue,Ye)=>Ue+Ye,0);At.value={rowTops:xe,rowHeights:Ne,colLefts:je,colWidths:at,wrapperOffsetLeft:ue,wrapperOffsetTop:ke,tableTotalWidth:jt,tableTotalHeight:Ot},de()}t.watchEffect(()=>{var y,v;u.value.rows,u.value.cols,u.value.headerRow,(y=k.value)==null||y.row,(v=k.value)==null||v.col,t.nextTick(()=>{$.value===null&&an()})});let Lt=null;t.onMounted(()=>{var v;Lt=new ResizeObserver(()=>{$.value===null&&(an(),de())}),ht.value&&Lt.observe(ht.value),p.value&&Lt.observe(p.value);const y=(v=N.value)==null?void 0:v.closest(".block-editor");y&&Lt.observe(y),ht.value&&ht.value.addEventListener("scroll",_e,{passive:!0}),de()}),t.onBeforeUnmount(()=>{var y;Lt==null||Lt.disconnect(),ht.value&&ht.value.removeEventListener("scroll",_e),b&&cancelAnimationFrame(b),L&&clearTimeout(L),i&&((y=i.value)==null?void 0:y.blockId)===s&&(i.value=null)});function hn(y,v){if(!r.value)return;v.preventDefault(),v.stopPropagation(),$.value=y,re=At.value.colWidths[y]??80,V=v.clientX,document.addEventListener("mousemove",_n,!0),document.addEventListener("mouseup",xn,!0),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}function _n(y){var X,ce;if($.value===null)return;const v=y.clientX-V;let T=Math.max(40,Math.round(re+v));const R=ht.value;if(R){const ue=R.clientWidth-4,ke=u.value.colWidths.reduce((xe,Ne,qe)=>qe===$.value?xe:xe+Ne,0);if(ke+T<=ue){const xe=Math.max(40,ue-ke);T=Math.min(T,xe)}}const q=Mi(u.value,$.value,T);(ce=(X=o.commands).setAttrs)==null||ce.call(X,{id:s,attrs:q})}function xn(){$.value=null,document.removeEventListener("mousemove",_n,!0),document.removeEventListener("mouseup",xn,!0),document.body.style.cursor="",document.body.style.userSelect="",t.nextTick(()=>{an(),de()})}const dn=t.ref(0),Qn=t.ref(0),Mn=t.ref(0),B=t.ref(!1);let b=0,L;function de(){const y=ht.value;y&&(dn.value=y.scrollLeft,Qn.value=y.clientWidth,Mn.value=y.scrollWidth)}function _e(){B.value||(B.value=!0),b&&cancelAnimationFrame(b),b=requestAnimationFrame(()=>{b=0,de()}),L&&clearTimeout(L),L=setTimeout(()=>{B.value=!1,de()},130)}const Oe=t.computed(()=>{if(!r.value)return[];const y=At.value,v=u.value.cols,T=y.colLefts,R=y.colWidths;if(v===0||T.length<v||R.length<v)return[];const q=dn.value,X=Qn.value,ce=Mn.value;if(X<=0)return[];const ue=q<=0,ke=q+X>=ce-1,pe=ce<=X+1,xe=6,Ne=[];for(let qe=0;qe<=v;qe++){const at=(qe===0?T[0]??0:qe===v?(T[v-1]??0)+(R[v-1]??0):T[qe]??0)-q;let Yt=at>=-1&&at<=X+1;if(qe===0&&(ue||pe)&&(Yt=!0),qe===v&&(ke||pe)&&(Yt=!0),!Yt)continue;const jt=Math.max(xe,Math.min(at,X-xe))+(qe>0?2:-2);Ne.push({c:qe,left:jt})}return Ne});function Be(y,v){var R,q;const T={id:s,...v};(q=(R=o.commands)[y])==null||q.call(R,T)}function be(){k.value=null,m.value=null,G.value.kind!=="none"&&(G.value={kind:"none"}),P(0),ie(),Te()}return n({clearInnerFocus:be}),()=>{var Jn,Xo,Mo,ic,sc,cc,ac,dc,uc,fc,mc;const y=u.value,v=y.rows,T=y.cols,R=Yo(m.value),q=R?Hn(y,R.r1,R.c1,R.r2,R.c2):null,X=At.value,ce=G.value,ue=[],ke=t.h("div",{class:"table-toolbar"},[t.h("div",{class:"table-toolbar-title"},[t.h(pn,{html:Cr,class:"table-toolbar-icon"}),t.h("span",l.t("table.title"))])]),pe=[];for(let Y=0;Y<T;Y++){const Ee=y.colWidths[Y]??0,Ce={};Ee&&Ee>0&&(Ce.width=`${Ee}px`),pe.push(t.h("col",{"data-col":Y,style:Ce}))}const xe=t.h("colgroup",{},pe),Ne=[],qe=[],je=y.headerRow?0:-1;for(let Y=0;Y<v;Y++){const Ee=[];for(let Ce=0;Ce<T;Ce++){const ye=(Jn=y.cells[Y])==null?void 0:Jn[Ce];if(!ye||ye.covered)continue;const Je=`${Y}-${Ce}`,Sn=je===0&&Y===0,No=!!q&&Zh(Y,Ce,q),So=ce.kind==="row"&&ce.row===Y,Ao=ce.kind==="col"&&ce.col===Ce,jo=ce.kind==="all",bg=No||So||Ao||jo;let Nl=Zn(ye.content);ye.cellType==="codeBlock"&&Nl.endsWith(`
|
|
19
|
+
`)&&(Nl+="<br>");const ao=["table-cell"];Sn&&ao.push("table-cell-header"),No&&ao.push("table-cell-selected"),(So||Ao||jo)&&ao.push("table-cell-selected"),typeof ye.align=="string"&&ye.align!=="left"&&ao.push(`be-align-${ye.align}`),typeof ye.bgColor=="string"&&ye.bgColor!=="default"&&ao.push(`be-bg-${ye.bgColor}`);const pc=ye.verticalAlign??"middle";let hc;pc!=="top"&&(hc={verticalAlign:pc});const gc=!bg&&((Xo=k.value)==null?void 0:Xo.row)===Y&&((Mo=k.value)==null?void 0:Mo.col)===Ce;gc&&ao.push("table-cell-focused");const gn=["table-cell-inner"],rn=ye.cellType;rn==="heading"||rn==="heading1"?gn.push("table-cell-heading","table-cell-h1"):rn==="heading2"?gn.push("table-cell-heading","table-cell-h2"):rn==="heading3"?gn.push("table-cell-heading","table-cell-h3"):rn==="heading4"?gn.push("table-cell-heading","table-cell-h4"):rn==="heading5"?gn.push("table-cell-heading","table-cell-h5"):rn==="heading6"?gn.push("table-cell-heading","table-cell-h6"):rn==="bulletList"?gn.push("table-cell-bullet"):rn==="orderedList"?gn.push("table-cell-ordered"):rn==="todoList"?(gn.push("table-cell-todo"),ye.checked&&gn.push("todo-checked")):rn==="quote"?gn.push("table-cell-quote"):rn==="codeBlock"&&gn.push("table-cell-code");const bc=rn==="orderedList"?qr(y,Y,Ce):-1,Sl=t.h("div",{class:gn,contenteditable:gc&&r.value?"true":"false","data-placeholder":l.t("table.cellPlaceholder"),innerHTML:Nl,ref:An=>{An instanceof HTMLDivElement?h.set(Je,An):h.delete(Je)},onBlur:An=>nt(Y,Ce,An.currentTarget,An),onFocus:An=>cn(Y,Ce,An.currentTarget)});let xr;if(rn==="todoList"){const An=t.h("input",{type:"checkbox",class:"table-cell-todo-checkbox",checked:!!ye.checked,onClick:Kn=>{Kn.stopPropagation()},onchange:Kn=>{var kc,yc;if(!r.value)return;const Al=Kn.target,yg=Fo(u.value,Y,Ce,{checked:Al.checked});(yc=(kc=o.commands).setAttrs)==null||yc.call(kc,{id:s,attrs:yg})}});xr=[t.h("div",{class:"table-cell-todo-wrapper"},[An,Sl])]}else if(rn==="orderedList"&&bc>=1){const An=t.h("div",{class:"ol-marker table-cell-ol-marker",onMousedown:Kn=>{Kn.preventDefault(),Kn.stopPropagation()},onClick:Kn=>{Kn.stopPropagation();const Al=Kn.currentTarget;We(Y,Ce,Al)}},`${bc}.`);xr=[t.h("div",{class:"block-ordered-list-wrapper"},[An,Sl])]}else xr=[Sl];const kg=t.h(Sn?"th":"td",{rowspan:ye.rowspan>1?ye.rowspan:void 0,colspan:ye.colspan>1?ye.colspan:void 0,class:ao,style:hc,"data-row":Y,"data-col":Ce},xr);Ee.push(kg)}je===0&&Y===0?Ne.push(t.h("tr",{class:"table-row table-row-head"},Ee)):qe.push(t.h("tr",{class:"table-row"},Ee))}const at=[xe];Ne.length>0&&at.push(t.h("thead",{},Ne)),at.push(t.h("tbody",{},qe));const Yt=t.h("table",{ref:p,class:"block-table-grid"},at),jt=[];for(let Y=0;Y<v;Y++){const Ee=X.rowTops[Y],Ce=X.rowHeights[Y]??32,ye=ce.kind==="row"&&ce.row===Y;jt.push(t.h("div",{class:`table-row-strip${ye?" is-selected":""}`,"data-row":Y,style:{top:`${Ee}px`,height:`${Ce}px`},title:l.t("table.selectRow"),onClick:Je=>{Je.preventDefault(),Me(Y)}}))}const Ot=$.value!==null,Ue=[],Ye=[];let Qt;if(Ot){const Y=y.colWidths;let Ee=0;for(let Ce=0;Ce<T;Ce++){Ue.push(Ee);const ye=Y[Ce]??80;Ye.push(ye),Ee+=ye}Qt=Ee}else{for(let Y=0;Y<T;Y++)Ue.push(X.colLefts[Y]??0),Ye.push(X.colWidths[Y]??0);Qt=X.tableTotalWidth}const ut=[];for(let Y=0;Y<T;Y++){const Ee=Ue[Y],Ce=Ye[Y]??0,ye=ce.kind==="col"&&ce.col===Y;ut.push(t.h("div",{class:`table-col-strip${ye?" is-selected":""}`,"data-col":Y,style:{left:`${Ee}px`,width:`${Ce}px`},title:l.t("table.selectCol"),onClick:Je=>{Je.preventDefault(),Ie(Y)}}))}const xt=[];if(r.value)for(let Y=0;Y<=v;Y++){let Ee;if(Y===0)Ee=(X.rowTops[0]??0)+3;else if(Y===v){const Ce=X.rowTops[Y-1]??0,ye=X.rowHeights[Y-1]??32;Ee=Ce+ye+2}else{const Ce=(X.rowTops[Y-1]??0)+(X.rowHeights[Y-1]??32),ye=X.rowTops[Y]??0;Ee=Math.round((Ce+ye)/2)}xt.push(t.h("div",{class:"table-insert-dot table-insert-dot-row",style:{top:`${Ee}px`},title:Y<v?l.t("table.insertRowAbove"):l.t("table.insertRowBelow"),onClick:Ce=>{Ce.preventDefault(),Ce.stopPropagation(),Be("tableInsertRow",{beforeRow:Y})}}))}const Jt=[];for(let Y=0;Y<T;Y++){const Ee=Ue[Y]??0,Ce=Ye[Y]??0;Jt.push(t.h("div",{class:"table-col-resize-item",style:{left:`${Ee}px`,width:`${Ce}px`}},[t.h("div",{class:"table-col-resizer",title:l.t("table.resizeCol"),onMousedown:ye=>hn(Y,ye)})]))}const Pt=t.h("div",{class:"table-corner-handle",title:l.t("table.selectAll"),onClick:Y=>{Y.preventDefault(),Ge()}});ue.push(ke,Pt),ue.push(t.h("div",{class:"table-row-handles",style:{height:`${X.tableTotalHeight}px`}},[...jt,...xt])),ue.push(t.h("div",{class:"table-wrapper",ref:ht},[t.h("div",{class:"table-col-handles",style:{width:`${Qt}px`}},[...ut]),t.h("div",{class:"table-col-resizers"},Jt),Yt])),ue.push(t.h("div",{class:["table-col-insert-dots",B.value||$.value!==null?"is-scrolling":""]},Oe.value.map(Y=>t.h("div",{class:"table-insert-dot table-insert-dot-col",style:{left:`${Y.left}px`},title:Y.c<T?l.t("table.insertColLeft"):l.t("table.insertColRight"),onClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),Be("tableInsertCol",{beforeCol:Y.c})}}))));const Dt=S.value,Rn=ce.kind==="row"||ce.kind==="col"||ce.kind==="all",Vt=Yo(m.value),Ln=Vt?Hn(u.value,Vt.r1,Vt.c1,Vt.r2,Vt.c2):null,Ut=k.value?{r1:k.value.row,c1:k.value.col,r2:k.value.row,c2:k.value.col}:null,$t=Ln??Ut,Tl=($t?Wa(u.value,$t.r1,$t.c1,$t.r2,$t.c2):0)>=2,Nn=$t?Ci(u.value,$t.r1,$t.c1,$t.r2,$t.c2):!1,_l=ce.kind==="row"?l.t("table.deleteRow"):ce.kind==="col"?l.t("table.deleteCol"):ce.kind==="all"?l.t("table.deleteTable"):"",Tr=ce.kind==="row"?Fh:ce.kind==="col"?Kh:Js,Fn=()=>{ce.kind==="row"?Be("tableRemoveRow",{row:ce.row}):ce.kind==="col"?Be("tableRemoveCol",{col:ce.col}):Be("tableDelete")},xl=()=>{$t&&Be("tableMergeCells",$t)},_o=()=>{$t&&Be("tableSplitCellsInRect",$t)},xo=()=>{Be("tableToggleHeaderRow")},_r=()=>{G.value={kind:"none"},m.value=null,P(0)};function On(){var Ce;const Y=Yo(m.value);if(!Y)return[];const Ee=[];for(let ye=Y.r1;ye<=Y.r2;ye++)for(let Je=Y.c1;Je<=Y.c2;Je++){const Sn=(Ce=u.value.cells[ye])==null?void 0:Ce[Je];Sn&&!Sn.covered&&Ee.push({row:ye,col:Je})}return Ee}const g=On().map(Y=>{var Ee;return(Ee=u.value.cells[Y.row])==null?void 0:Ee[Y.col]}).filter(Y=>!!Y&&!Y.covered),C=new Set(g.map(Y=>Y.cellType??"paragraph"));let I="paragraph",H;if(C.size===1){const Y=[...C][0];Y==="heading"||Y==="heading1"?(I="heading",H=1):Y==="heading2"?(I="heading",H=2):Y==="heading3"?(I="heading",H=3):Y==="heading4"?(I="heading",H=4):Y==="heading5"?(I="heading",H=5):Y==="heading6"?(I="heading",H=6):Y==="bulletList"?I="bulletList":Y==="orderedList"?I="orderedList":Y==="todoList"?I="todoList":Y==="quote"?I="quote":Y==="codeBlock"&&(I="codeBlock")}const j=new Set(g.map(Y=>Y.align??"left")),oe={align:j.size===1?[...j][0]:"left"},te=new Set(g.map(Y=>Y.verticalAlign??"middle")),Q=te.size===1?[...te][0]:"middle";oe.verticalAlign=Q,H!==void 0&&(oe.level=H);const ge=["bold","italic","underline","strikethrough","code"],$e=new Set;for(const Y of ge){let Ee=!0,Ce=!1;for(const ye of g){for(const Je of ye.content)if(Je.type==="text"&&(Ce=!0,!((ic=Je.marks)!=null&&ic.some(Sn=>Sn.type===Y)))){Ee=!1;break}if(!Ee)break}Ce&&Ee&&$e.add(Y)}const De=new Set;for(const Y of g)for(const Ee of Y.content){if(Ee.type!=="text")continue;const Ce=(sc=Ee.marks)==null?void 0:sc.find(Je=>Je.type==="color"),ye=(cc=Ce==null?void 0:Ce.attrs)==null?void 0:cc.color;typeof ye=="string"&&De.add(ye)}const it=De.size===1?[...De][0]:"",Fe=new Set(g.map(Y=>Y.bgColor??"")),Qe=Fe.size===1?[...Fe][0]:"";if((ce.kind==="row"||ce.kind==="col"||ce.kind==="all"||g.length>0)&&!O){E.blockType=I,E.blockAttrs={...oe},E.marks.clear();for(const Y of $e)E.marks.add(Y);E.textColor=it,E.bgColor=Qe,E.verticalAlign=Q,E.showDelete=Rn,E.deleteLabel=_l,E.deleteIcon=Tr,E.showMerge=Tl,E.showSplit=Nn,E.showHeaderRow=ce.kind==="all",E.headerRowActive=!!u.value.headerRow}const dt=Y=>{var ye,Je;const Ee=On();if(Ee.length===0)return;const Ce=oo(u.value,Ee,{cellType:Y});(Je=(ye=o.commands).setAttrs)==null||Je.call(ye,{id:s,attrs:Ce})},Le=Y=>{var ye,Je;const Ee=On();if(Ee.length===0)return;const Ce=oo(u.value,Ee,{align:Y});(Je=(ye=o.commands).setAttrs)==null||Je.call(ye,{id:s,attrs:Ce})},It=Y=>{var ye,Je;const Ee=On();if(Ee.length===0)return;const Ce=oo(u.value,Ee,{verticalAlign:Y});(Je=(ye=o.commands).setAttrs)==null||Je.call(ye,{id:s,attrs:Ce})},mt=Y=>{var ye,Je;const Ee=On();if(Ee.length===0)return;const Ce=ja(u.value,Ee,Y);(Je=(ye=o.commands).setAttrs)==null||Je.call(ye,{id:s,attrs:Ce})},gt=Y=>{var ye,Je;const Ee=On();if(Ee.length===0)return;const Ce=_i(u.value,Ee,"color",Y?{color:Y}:null);(Je=(ye=o.commands).setAttrs)==null||Je.call(ye,{id:s,attrs:Ce})},pt=Y=>{var ye,Je;const Ee=On();if(Ee.length===0)return;const Ce=oo(u.value,Ee,{bgColor:Y??"default"});(Je=(ye=o.commands).setAttrs)==null||Je.call(ye,{id:s,attrs:Ce})},Nt=()=>{var ye,Je;const Y=Yo(m.value);if(!Y)return;const Ee=[];for(let Sn=Y.r1;Sn<=Y.r2;Sn++){const No=[];for(let So=Y.c1;So<=Y.c2;So++){const Ao=(ye=u.value.cells[Sn])==null?void 0:ye[So];Ao&&!Ao.covered?No.push(Ao.content.map(jo=>jo.type==="text"?jo.text:"").join("")):No.push("")}Ee.push(No.join(" "))}const Ce=Ee.join(`
|
|
20
|
+
`);Ce&&((Je=navigator.clipboard)==null||Je.writeText(Ce))},zt={visible:!!Dt,selectionRect:Dt,blockId:s,blockType:E.blockType,blockAttrs:E.blockAttrs,rootEl:document.querySelector(".block-editor"),tableMode:!0,tableActiveMarks:E.marks,tableActiveColor:E.textColor,tableActiveBgColor:E.bgColor,tableActiveVerticalAlign:E.verticalAlign,showDelete:E.showDelete,deleteLabel:E.deleteLabel,deleteIcon:E.deleteIcon,showMerge:E.showMerge,showSplit:E.showSplit,showHeaderRow:E.showHeaderRow,headerRowActive:E.headerRowActive,onDelete:Fn,onMerge:xl,onSplit:_o,onTableHeaderRow:xo,onClose:_r,onTableType:dt,onTableAlign:Le,onTableVerticalAlign:It,onTableMark:mt,onTableTextColor:gt,onTableBgColor:pt,onTableCopy:Nt};i&&(zt.visible?f(zt):((ac=i.value)==null?void 0:ac.blockId)===s&&!((dc=i.value)!=null&&dc.cellEditMode)&&f(null));const bt=k.value,Ft=bt?(uc=u.value.cells[bt.row])==null?void 0:uc[bt.col]:void 0,Pe=Ft==null?void 0:Ft.cellType;let ot="paragraph";const Kt={};Pe==="heading"||Pe==="heading1"?(ot="heading",Kt.level=1):Pe==="heading2"?(ot="heading",Kt.level=2):Pe==="heading3"?(ot="heading",Kt.level=3):Pe==="heading4"?(ot="heading",Kt.level=4):Pe==="heading5"?(ot="heading",Kt.level=5):Pe==="heading6"?(ot="heading",Kt.level=6):Pe==="bulletList"?ot="bulletList":Pe==="orderedList"?ot="orderedList":Pe==="todoList"?ot="todoList":Pe==="quote"?ot="quote":Pe==="codeBlock"&&(ot="codeBlock"),typeof(Ft==null?void 0:Ft.align)=="string"&&(Kt.align=Ft.align),typeof(Ft==null?void 0:Ft.verticalAlign)=="string"&&(Kt.verticalAlign=Ft.verticalAlign);const kn={visible:A.visible&&!!A.selectionRect,selectionRect:A.selectionRect,blockId:s,blockType:ot,blockAttrs:Kt,rootEl:document.querySelector(".block-editor"),cellEditMode:!0,onClose:()=>{A.visible=!1,A.selectionRect=null},onTableType:Y=>{var Ce,ye;if(!bt)return;const Ee=oo(u.value,[{row:bt.row,col:bt.col}],{cellType:Y});(ye=(Ce=o.commands).setAttrs)==null||ye.call(Ce,{id:s,attrs:Ee})},onTableAlign:Y=>{var Ce,ye;if(!bt)return;const Ee=oo(u.value,[{row:bt.row,col:bt.col}],{align:Y});(ye=(Ce=o.commands).setAttrs)==null||ye.call(Ce,{id:s,attrs:Ee})},onTableVerticalAlign:Y=>{var Ce,ye;if(!bt)return;const Ee=oo(u.value,[{row:bt.row,col:bt.col}],{verticalAlign:Y});(ye=(Ce=o.commands).setAttrs)==null||ye.call(Ce,{id:s,attrs:Ee})},onLinkClick:()=>{vt()}};return i&&(kn.visible?f(kn):((fc=i.value)==null?void 0:fc.blockId)===s&&((mc=i.value)!=null&&mc.cellEditMode)&&f(null)),ue.push(t.h(ls,{visible:W.visible,anchorRect:W.anchorRect,blockId:null,from:0,to:0,href:W.href,text:W.text,initialMode:W.initialMode,showTextInput:W.showTextInput,readonly:!r.value,onSaveLink:(Y,Ee)=>{Ct(Y,Ee),W.href=Y,Ee!==void 0&&(W.text=Ee)},onRemoveLinkMark:()=>{fe()},onClose:()=>{tt()}})),ue.push(t.h(ns,{visible:ae.visible,blockId:null,anchor:ae.anchor,rootEl:document.querySelector(".block-editor"),canContinue:ae.canContinue,canStartNew:ae.canStartNew,currentNumber:ae.currentNumber,onContinue:Mt,onStartNew:Zt,onModify:Gt,onClose:ie})),ue.push(t.h(os,{visible:Se.visible,initialValue:Se.initialValue,anchor:Se.anchor,rootEl:document.querySelector(".block-editor"),onConfirm:Rt,onClose:Te})),t.h("div",{class:["block-table-container","block-focus-root",...En(e.block.attrs)],ref:N,tabindex:"-1",onClick:z,onMousedown:Xt,onMouseover:bn,onDblclick:Cn,onFocusout:lt,onKeydown:vn},ue)}}});function qh(e,n,o,r){var i;const l=[];for(let c=0;c<e.rows;c++)for(let a=0;a<e.cols;a++){const d=(i=e.cells[c])==null?void 0:i[a];d&&!d.covered&&l.push({r:c,c:a})}const s=l.findIndex(c=>c.r===n&&c.c===o);return s===-1?null:r?s===0?null:l[s-1]??null:s===l.length-1?null:l[s+1]??null}function Yh(e,n,o){var l;let r=null;for(let s=0;s<e.rows;s++)for(let i=0;i<e.cols;i++){const c=(l=e.cells[s])==null?void 0:l[i];c&&!c.covered&&(r={r:s,c:i})}return r!==null&&r.r===n&&r.c===o}function Cl(e){if(!e)return;e.focus();const n=document.createRange();n.selectNodeContents(e),n.collapse(!1);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(n)}function ec(e){if(!e)return;e.focus();const n=document.createRange();n.selectNodeContents(e),n.collapse(!0);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(n)}function Yo(e){if(!e)return null;const n=e.anchor,o=e.focus,r=Math.min(n.row,o.row),l=Math.max(n.row,o.row),s=Math.min(n.col,o.col),i=Math.max(n.col,o.col);return{r1:r,c1:s,r2:l,c2:i}}function Zh(e,n,o){return e>=o.r1&&e<=o.r2&&n>=o.c1&&n<=o.c2}function Zo(e,n){return null}function zn(e,n,o,r){const l=e.doc.blocks.get(n);if(!l||l.type!=="table")return!1;const s=Uo(l.attrs),i=r(s),c=et();return c.setAttrs(n,i),o==null||o(c.build()),!0}function Xh(){return{name:"tableInsertRow",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs);Zo(n,e.id);const s=e.beforeRow??l.rows;return zn(n,e.id,o,i=>Ti(i,s))}}}function jh(){return{name:"tableRemoveRow",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs);Zo(n,e.id);const s=e.row??l.rows-1;return zn(n,e.id,o,i=>Ya(i,s))}}}function Qh(){return{name:"tableInsertCol",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs);Zo(n,e.id);const s=e.beforeCol??l.cols;return zn(n,e.id,o,i=>Za(i,s))}}}function Jh(){return{name:"tableRemoveCol",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs);Zo(n,e.id);const s=e.col??l.cols-1;return zn(n,e.id,o,i=>Xa(i,s))}}}function eg(){return{name:"tableToggleHeaderRow",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);return!r||r.type!=="table"?!1:zn(n,e.id,o,ed)}}}function tg(){return{name:"tableMergeCells",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs);Zo(n,e.id);const s=e.r1??0,i=e.c1??0;let c=e.r2??0,a=e.c2??0;if(s===c&&i===a&&(c+1<l.rows&&(c=s+1),a+1<l.cols&&(a=i+1),s===c&&i===a))return!1;const d=Hn(l,s,i,c,a);return d.r1===d.r2&&d.c1===d.c2?!1:zn(n,e.id,o,f=>Qa(f,d.r1,d.c1,d.r2,d.c2))}}}function ng(){return{name:"tableSplitCell",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);return!r||r.type!=="table"?!1:zn(n,e.id,o,l=>xi(l,e.row,e.col))}}}function og(){return{name:"tableSplitCellsInRect",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=ro(r.attrs),s=Hn(l,e.r1,e.c1,e.r2,e.c2);return Ci(l,s.r1,s.c1,s.r2,s.c2)?zn(n,e.id,o,i=>Ja(i,s.r1,s.c1,s.r2,s.c2)):!1}}}function rg(){return{name:"tableSetColWidth",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);return!r||r.type!=="table"?!1:zn(n,e.id,o,l=>Mi(l,e.col,e.width))}}}function lg(){return{name:"tableDelete",run:e=>(n,o)=>{const r=n.doc.blocks.get(e.id);if(!r||r.type!=="table")return!1;const l=et();return l.removeBlock(e.id),o==null||o(l.build()),!0}}}function ig(){return{name:"insertTable",run:e=>(n,o)=>{const r=e.rows??3,l=e.cols??3,s=Math.max(1,Math.min(50,Number.isInteger(r)?r:3)),i=Math.max(1,Math.min(20,Number.isInteger(l)?l:3)),c=Ga(s,i),d={rows:s,cols:i,cells:Vn(c,s,i),colWidths:new Array(i).fill(120),headerRow:!0};let f=null,u=n.doc.root.length,h=null;if(e.replaceCurrent){const $=n.selection,V=$.kind==="caret"?$.blockId:$.kind==="text"?$.focus.blockId:$.blockIds[0]??null;V&&(h=V)}if(h&&(n.doc.blocks.get(h)?(f=Bt(n.doc,h),u=sn(n.doc,h)):h=null),!h)if(e.after){if(!n.doc.blocks.get(e.after))return!1;f=Bt(n.doc,e.after),u=sn(n.doc,e.after)+1}else{const $=n.selection,V=$.kind==="caret"?$.blockId:$.kind==="text"?$.focus.blockId:$.blockIds[0]??null;V&&(f=Bt(n.doc,V),u=sn(n.doc,V)+1)}const p=et();h&&p.removeBlock(h);const m=f===null?0:Dn(n.doc,f)+1,k=m>0?{...d,indent:m}:d,x=p.insertBlock({parent:f,index:u,type:"table",attrs:k,content:[]}),D=Jo(n.doc,p.peek()),U=po(D.doc,x),F=$n(D.doc,x),ee=U??F;return ee?p.setSelection(st(ee.id,0)):p.setSelection(st(x,0)),o==null||o(p.build()),!0}}}const tc={name:"table",schema:{type:"table",content:"none",nestable:!1,isolating:!0,inlineMarks:!1,attrs:{...Wh},empty:e=>{var o;const n=Uo(e.attrs);for(let r=0;r<n.rows;r++)for(let l=0;l<n.cols;l++){const s=(o=n.cells[r])==null?void 0:o[l];if(!(!s||s.covered)){for(const i of s.content)if(i.type==="text"&&i.text.length>0)return!1}}return!0}},renderer:{component:Gh,editable:!1},commands:[Xh(),jh(),Qh(),Jh(),eg(),tg(),ng(),og(),rg(),lg(),ig()],slashCommands:[{id:"table-3x3",title:"slash.table3x3.title",keywords:["table","grid","spreadsheet","表格","数据表","网格"],description:"slash.table3x3.description",icon:Cr,command:"insertTable",category:"other",args:()=>({rows:3,cols:3,replaceCurrent:!0})},{id:"table-2x2",title:"slash.table2x2.title",keywords:["table","grid","表格","2行2列"],description:"slash.table2x2.description",icon:Cr,command:"insertTable",category:"other",args:()=>({rows:2,cols:2,replaceCurrent:!0})},{id:"table-4x4",title:"slash.table4x4.title",keywords:["table","grid","表格","4行4列"],description:"slash.table4x4.description",icon:Cr,command:"insertTable",category:"other",args:()=>({rows:4,cols:4,replaceCurrent:!0})}],serialize:{toHTML:e=>{if(e.type!=="table")return"";const n=Uo(e.attrs);return nd(n)},toMarkdown:e=>{if(e.type!=="table")return"";const n=Uo(e.attrs);return td(n)}}},sg=t.defineComponent({name:"DividerBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){return e.placeholder,()=>t.h("div",{class:["block-divider","block-focus-root",...En(e.block.attrs)],"data-block-divider":!0})}}),nc={name:"divider",schema:{type:"divider",content:"none",nestable:!1,inlineMarks:!1,attrs:{indent:tn.indent},empty:()=>!1},renderer:{component:sg,editable:!1},slashCommands:[{id:"divider",title:"slash.divider.title",keywords:["divider","separator","hr","horizontal","line","分隔符","分割线","水平线","横线"],description:"slash.divider.description",icon:Xd,command:"convertBlock",category:"basic",args:()=>({id:"__currentBlock__",type:"divider"})}],inputRules:[{name:"divider-md-thematic-break",pattern:/^(?:-{3,}|\*{3,}|_{3,})\s*$/,command:"convertBlock",args:()=>({id:"__currentBlock__",type:"divider"})}],serialize:{toHTML:()=>"<hr/>",toMarkdown:()=>"---"},deserialize:{fromMarkdown:e=>{const n=e.trim();return/^-{3,}$/.test(n)||/^\*{3,}$/.test(n)||/^_{3,}$/.test(n)?{type:"divider"}:null}}};function cg(e){const n=[];for(const o of e.root){const r=e.blocks.get(o);if(!r||r.type!=="heading")continue;const l=Ae(r.content).trim();if(l.length===0)continue;const s=typeof r.attrs.level=="number"?r.attrs.level:1;n.push({id:o,level:Math.max(1,Math.min(6,Math.floor(s))),text:l})}return n}const ag=t.defineComponent({name:"TableOfContentsBlock",props:{block:{type:Object,required:!0},placeholder:{type:String,default:void 0}},setup(e){e.block,e.placeholder;const n=fn(),o=en(),r=t.ref(null),l=t.ref(0),s=t.computed(()=>(l.value,cg(n.getState().doc)));let i=null;t.onMounted(()=>{i=n.subscribe(()=>{l.value++})}),t.onBeforeUnmount(()=>{i==null||i()});function c(a){var d,f;(f=(d=n.commands).setSelection)==null||f.call(d,{selection:st(a,0)}),t.nextTick(()=>{var p,m;const u=(m=(p=r.value)==null?void 0:p.closest)==null?void 0:m.call(p,".block-editor"),h=u?$o(u,a):null;h==null||h.scrollIntoView({block:"center",behavior:"smooth"})})}return()=>{const a=s.value,d=[t.h("div",{class:"toc-title"},o.t("toc.title"))];if(a.length===0)d.push(t.h("div",{class:"toc-empty"},o.t("toc.empty")));else for(const f of a)d.push(t.h("button",{type:"button",class:["toc-item",`toc-level-${f.level}`],style:{paddingLeft:`${(f.level-1)*16}px`},"data-toc-target":f.id,onClick:()=>c(f.id)},f.text));return t.h("div",{ref:r,class:["block-table-of-contents","block-focus-root",...En(e.block.attrs)]},d)}}}),oc={name:"tableOfContents",schema:{type:"tableOfContents",content:"none",nestable:!1,inlineMarks:!1,attrs:{indent:tn.indent},empty:()=>!1},renderer:{component:ag,editable:!1},slashCommands:[{id:"tableOfContents",title:"slash.tableOfContents.title",keywords:["toc","contents","table of contents","outline","目录","标题","大纲"],description:"slash.tableOfContents.description",icon:jd,command:"convertBlock",category:"basic",args:()=>({id:"__currentBlock__",type:"tableOfContents"})}],serialize:{toHTML:()=>"",toMarkdown:()=>""}},rc=[ss,cs,Gm,zm,Ym,Xm,Hh,Qs,tc,nc,oc,as,ds],dg={class:"editor-content"},ug={key:0,class:"cross-block-selection-overlay","aria-hidden":"true"},fg=200,mg=.25,pg=.75,hg=400,gg=t.defineComponent({__name:"BlockEditor",props:{extensions:{default:()=>rc},modelValue:{default:()=>({blocks:[]})},editable:{type:Boolean,default:!0},placeholder:{default:""},theme:{default:"light"},locale:{default:"zh-CN"},uploadImage:{type:Function,default:void 0},width:{default:void 0},height:{default:void 0},toolbarPosition:{default:"auto"}},emits:["update:modelValue","cleanup:image-file"],setup(e,{expose:n,emit:o}){const r=e,l=r.placeholder!=="",s=o,i=t.computed(()=>Hi(r.locale)),c=t.computed(()=>Vi(r.theme)),a=t.ref(i.value),d=t.ref(c.value);xd(a,d),t.watch([i,c],([g,C])=>{a.value=g,d.value=C});const f=en(),u=t.computed(()=>`theme-${c.value}`),h=t.computed(()=>{const g={};return g.width=r.width!==void 0?typeof r.width=="number"?`${r.width}px`:r.width:"100%",g.height=r.height!==void 0?typeof r.height=="number"?`${r.height}px`:r.height:"100%",g});t.watch(c,g=>{if(typeof document>"u")return;const C=document.body;C.classList.toggle("theme-dark",g==="dark"),C.classList.toggle("theme-light",g==="light")},{immediate:!0});const p=t.computed(()=>l?r.placeholder??"":f.t("editor.placeholder")),m=new ai({extensions:r.extensions,initialDocument:r.modelValue,editable:r.editable}),k=t.ref(r.editable);t.provide(pi,k),t.provide(Pr,m);const x=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(pointer: coarse)"):null,D=t.ref(!!(x!=null&&x.matches));function U(){D.value=!!(x!=null&&x.matches)}const F=t.ref(null);t.provide(mi,D),t.provide($r,F);const ee=t.computed(()=>r.toolbarPosition==="top"?"top":r.toolbarPosition==="bottom"||D.value?"bottom":"top");t.provide(Do,t.computed(()=>ee.value==="bottom")),t.watch(()=>r.editable,g=>{var C,I;k.value=g,m.editable=g,g||(N.visible=!1,N.selectionRect=null,N.blockId=null,N.blockType=null,N.blockAttrs={},Ut(),Nn(),Fn(),Se(),pe(),X(),Ct(null,{clearNativeSelection:!0}),(I=(C=m.commands).clearSelection)==null||I.call(C))}),wd((g,C,I,H)=>{const{onProgress:j,onSuccess:J,onError:oe}=H,te=r.uploadImage;typeof te=="function"?te(g,C,I,Q=>{const ge=Number.isFinite(Q)?Math.max(0,Math.min(1,Q/100)):0;j(ge)}).then(Q=>{J({url:Q.url,width:Q.width,height:Q.height,alt:Q.alt,title:Q.title,fileId:Q.fileId})}).catch(Q=>{I.signal.aborted||oe(Q instanceof Error?Q.message:String(Q))}):Ed(C,j).then(Q=>J({url:Q.url,width:Q.width,height:Q.height}),Q=>oe(Q instanceof Error?Q.message:String(Q)))});const $=t.ref(0),V=md(()=>{$.value++}),re=async(g,C={})=>{var Q,ge,$e,De,it,Fe,Qe,ze,dt,Le,It,mt,gt,pt,Nt,zt,bt,Ft;const{relativeToBlockId:I=null,position:H="after",convertIfEmpty:j=!0}=C;$.value;let J=null,oe=I??null;if(!oe){const Pe=m.getState().selection;Pe.kind==="caret"?oe=Pe.blockId:Pe.kind==="text"&&(oe=Pe.anchor.blockId)}if(oe||(oe=G.value.doc.root[0]??null),H==="replace"&&oe){const Pe=m.registries.schema.get("image");Pe&&((ge=(Q=m.commands).replaceBlock)==null||ge.call(Q,{id:oe,type:"image",attrs:Gn(Pe)}),J=oe)}if(!J&&oe&&j&&H!=="before"){const ot=m.getState().doc.blocks.get(oe);if(ot&&ot.type==="paragraph"&&Ae(ot.content).length===0){const Kt=m.registries.schema.get("image");Kt&&((De=($e=m.commands).replaceBlock)==null||De.call($e,{id:oe,type:"image",attrs:Gn(Kt)}),J=oe)}}if(!J&&oe&&H==="before"){const Pe=m.registries.schema.get("image");if(Pe){(Fe=(it=m.commands).insertBlock)==null||Fe.call(it,{before:oe,type:"image",attrs:Gn(Pe)});const ot=m.getState().selection;ot.kind==="caret"?J=ot.blockId:ot.kind==="text"&&(J=ot.anchor.blockId)}}if(!J&&oe){const Pe=m.registries.schema.get("image");if(Pe){(ze=(Qe=m.commands).insertBlock)==null||ze.call(Qe,{after:oe,type:"image",attrs:Gn(Pe)});const ot=m.getState().selection;ot.kind==="caret"?J=ot.blockId:ot.kind==="text"&&(J=ot.anchor.blockId)}}if(!J){const Pe=m.registries.schema.get("image");if(!Pe)return null;const ot=m.getState().doc,Kt=ot.root[ot.root.length-1]??null;Kt?(Le=(dt=m.commands).insertBlock)==null||Le.call(dt,{after:Kt,type:"image",attrs:Gn(Pe)}):(mt=(It=m.commands).insertBlock)==null||mt.call(It,{after:null,type:"image",attrs:Gn(Pe)});const kn=m.getState().selection;kn.kind==="caret"?J=kn.blockId:kn.kind==="text"&&(J=kn.anchor.blockId)}if(!J)return null;if(typeof g=="string"){const Pe=g;try{const ot=await new Promise(kn=>{if(typeof document>"u")return kn({});const Jn=document.createElement("img");let Xo=!1;const Mo=()=>{Xo||(Xo=!0,kn({width:Jn.naturalWidth||void 0,height:Jn.naturalHeight||void 0}))};Jn.onload=Mo,Jn.onerror=Mo,Jn.src=Pe,setTimeout(Mo,4e3)}),Kt={src:Pe,width:ot.width,height:ot.height};(pt=(gt=m.commands).setAttrs)==null||pt.call(gt,{id:J,attrs:Kt})}catch{(zt=(Nt=m.commands).setAttrs)==null||zt.call(Nt,{id:J,attrs:{src:Pe}})}return J}const te=await vd(J,g);if(te.ok){const Pe=te.value,ot={src:Pe.url,alt:Pe.alt,title:Pe.title,width:Pe.width,height:Pe.height,fileId:Pe.fileId};(Ft=(bt=m.commands).setAttrs)==null||Ft.call(bt,{id:J,attrs:ot})}return J};t.provide(hi,re);const G=t.shallowRef(m.getState());let ne=m.getState().selection,Z=!1,S=!1;const K=t.computed(()=>{const g=G.value.doc,C=[];for(const I of g.root){const H=g.blocks.get(I);H&&C.push({id:I,block:H})}return C}),_=t.reactive({visible:!1,anchorEl:null,blockId:"",query:"",mode:"slash"}),O=t.ref(null),M=t.reactive({visible:!1,anchorEl:null,blockId:null}),E=t.ref(null),N=t.reactive({visible:!1,selectionRect:null,blockId:null,blockType:null,blockAttrs:{}});let A=!1,W=null;function me(){A=!0,W&&clearTimeout(W),W=setTimeout(()=>{A=!1,W=null,je({force:!0})},500)}const le=t.reactive({visible:!1,blockId:null,anchor:null,canContinue:!1,canStartNew:!1,currentNumber:1}),he=t.reactive({visible:!1,initialValue:1,anchor:null,blockId:null}),ae=t.reactive({visible:!1,initialValue:"plain",anchor:null,blockId:null}),ie=t.reactive({visible:!1,anchorRect:null,blockId:null,from:0,to:0,href:"",text:"",initialMode:"view",showTextInput:!1});function Se(){ie.visible=!1}t.watch(()=>ie.visible,g=>{g&&(N.visible=!1)});function Te(g,C){var j,J;const I=m.getState().doc.blocks.get(g);if(!I)return null;let H=0;for(const oe of I.content){if(oe.type!=="text")continue;const te=H,Q=H+oe.text.length;if(C>=te&&C<=Q){const ge=(j=oe.marks)==null?void 0:j.find($e=>$e.type==="link");if(ge&&typeof((J=ge.attrs)==null?void 0:J.href)=="string")return{from:te,to:Q,href:ge.attrs.href,text:oe.text};if(C<Q)return null}H=Q}return null}function We(g,C,I){var $e,De,it;const H=m.getState().doc.blocks.get(g);if(!H)return;let j="",J="",oe=0;for(const Fe of H.content){if(Fe.type!=="text")continue;const Qe=oe,ze=oe+Fe.text.length;if(ze>C&&Qe<I){const dt=($e=Fe.marks)==null?void 0:$e.find(Le=>Le.type==="link");if(dt&&typeof((De=dt.attrs)==null?void 0:De.href)=="string"){j=dt.attrs.href,J=Fe.text;break}}oe=ze}let te=null;const Q=(it=He.value)==null?void 0:it.querySelector(`[data-block-id="${g}"]`);if(Q){const Fe=window.getSelection();if(Fe&&Fe.rangeCount>0){const Qe=Fe.getRangeAt(0);Q.contains(Qe.commonAncestorContainer)&&(te=Qe.getBoundingClientRect())}te||(te=Q.getBoundingClientRect())}const ge=C<I;pe(),X(),Ut(),Nn(),Fn(),ie.blockId=g,ie.from=C,ie.to=I,ie.href=j,ie.text=J,ie.anchorRect=te,ie.initialMode=j||!k.value?"view":"edit",ie.showTextInput=!ge&&!j,ie.visible=!0}function Mt(){var C;if(!k.value)return;bn();const g=m.getState().selection;if(g.kind==="caret"){const I=Te(g.blockId,g.offset);if(I){ie.blockId=g.blockId,ie.from=I.from,ie.to=I.to,ie.href=I.href,ie.text=I.text;const H=(C=He.value)==null?void 0:C.querySelector(`[data-block-id="${g.blockId}"]`),j=H==null?void 0:H.querySelector("a");ie.anchorRect=(j==null?void 0:j.getBoundingClientRect())??(H==null?void 0:H.getBoundingClientRect())??null,ie.initialMode="view",ie.showTextInput=!1,ie.visible=!0}}else g.kind==="text"&&!Ht(g)&&We(g.focus.blockId,g.anchor.offset,g.focus.offset)}function Zt(g,C,I){We(g,C,I)}function Gt(g,C){var J;const I=Te(g,C);if(!I)return;const H=(J=He.value)==null?void 0:J.querySelector(`[data-block-id="${g}"]`),j=H==null?void 0:H.querySelector("a");ie.blockId=g,ie.from=I.from,ie.to=I.to,ie.href=I.href,ie.text=I.text,ie.anchorRect=(j==null?void 0:j.getBoundingClientRect())??(H==null?void 0:H.getBoundingClientRect())??null,ie.initialMode="view",ie.showTextInput=!1,ie.visible=!0}function Rt(g){Ct(g)}const tt=t.ref(null),yt=t.ref(null),vt=t.ref(null);let Ze=!1,Ve=!1;function Ct(g,C={}){const{clearNativeSelection:I=!1}=C;if(I)try{const H=window.getSelection();H&&H.removeAllRanges()}catch{}yt.value=g}let fe=null,Tt=0,Xe=null;const Re=t.ref([]);function qt(g){tt.value=g}function rt(){const g=He.value;if(!g){Re.value=[];return}const C=m.getState().selection;if(C.kind!=="text"||!Ht(C)){Re.value=[];return}Re.value=Vr(g,m.getState().doc,C)}function Et(g){g.preventDefault()}function P(g){var oe,te;const C=He.value;if(!C||!fe)return;const I=rr(g.clientX,g.clientY,C,m.getState().doc);if(!I)return;const H=fe.start;if(I.blockId===H.blockId){if(fe.crossBlock){fe.crossBlock=!1,Re.value=[],document.removeEventListener("selectstart",Et,!0);const Q=window.getSelection();Q&&Q.removeAllRanges()}return}if(!fe.crossBlock){fe.crossBlock=!0,document.addEventListener("selectstart",Et,!0);const Q=window.getSelection();Q&&Q.removeAllRanges()}const j={blockId:I.blockId,offset:I.offset},J=Br(H,j);Z=!0,(te=(oe=m.commands).setSelection)==null||te.call(oe,{selection:J}),Z=!1,rt()}function w(g){fe&&(Xe=g,!Tt&&(Tt=requestAnimationFrame(()=>{Tt=0,Xe&&P(Xe)})))}function z(){if(!fe)return;fe=null,Tt&&(cancelAnimationFrame(Tt),Tt=0),Xe=null,document.removeEventListener("mousemove",w,!0),document.removeEventListener("mouseup",z,!0),document.removeEventListener("selectstart",Et,!0),rt();const g=m.getState().selection;g.kind==="text"&&Ht(g)&&jt(g)}const we=new Set(["image","divider","table","toc","tableOfContents","codeBlock"]),ve=new Map;let nt=m.getState().doc.blocks;{const g=m.getState().doc;for(const C of g.root){const I=g.blocks.get(C);if(!I||I.type!=="image")continue;const H=I.attrs.fileId;typeof H=="number"&&Number.isFinite(H)&&H>0&&ve.set(H,(ve.get(H)??0)+1)}}let lt=!1;const on=m.subscribe(g=>{if(G.value=g.state,g.removed.size>0&&kd(g.removed),g.changed.size>0||g.removed.size>0){const j=new Map;for(const oe of g.state.doc.root){const te=g.state.doc.blocks.get(oe);if(!te||te.type!=="image")continue;const Q=te.attrs.fileId;typeof Q=="number"&&Number.isFinite(Q)&&Q>0&&j.set(Q,(j.get(Q)??0)+1)}const J=new Set;for(const oe of g.changed){const te=oe?nt.get(oe):void 0;if(te&&te.type==="image"){const Q=te.attrs.fileId;typeof Q=="number"&&Number.isFinite(Q)&&Q>0&&J.add(Q)}}for(const oe of g.removed){const te=oe?nt.get(oe):void 0;if(te&&te.type==="image"){const Q=te.attrs.fileId;typeof Q=="number"&&Number.isFinite(Q)&&Q>0&&J.add(Q)}}for(const oe of j.keys())J.add(oe);for(const oe of J){const te=j.get(oe)??0,Q=ve.get(oe)??0;ve.set(oe,te),te===0&&Q>0&&s("cleanup:image-file",oe)}nt=g.state.doc.blocks,lt=!0,s("update:modelValue",m.toData()),Promise.resolve().then(()=>{lt=!1})}const C=g.state.selection;let H=C.kind==="caret"?C.blockId:C.kind==="text"?C.focus.blockId:C.kind==="blocks"?C.blockIds[0]??null:null;if(yt.value!==null&&H!==yt.value){const j=g.state.doc.blocks.get(yt.value);j&&we.has(j.type)&&(C.kind!=="blocks"||C.blockIds.length===0)&&(H=yt.value)}A||Ct(H),!Z&&C!==ne&&(S?S=!1:t.nextTick(()=>{const j=He.value;j&&yi(j,C)})),C.kind==="text"&&Ht(C)?t.nextTick(()=>{rt(),!fe&&!Ze&&jt(C)}):Re.value.length>0&&(Re.value=[]),ne=C});function cn(g,C){if(Object.is(g,C))return!0;if(typeof g!=typeof C||g===null||C===null||typeof g!="object"||Array.isArray(g)!==Array.isArray(C))return!1;if(Array.isArray(g)){if(g.length!==C.length)return!1;for(let j=0;j<g.length;j++)if(!cn(g[j],C[j]))return!1;return!0}const I=Object.keys(g),H=Object.keys(C);if(I.length!==H.length)return!1;for(const j of I)if(!Object.prototype.hasOwnProperty.call(C,j)||!cn(g[j],C[j]))return!1;return!0}t.watch(()=>r.modelValue,g=>{if(lt||g===void 0)return;const C=m.toData();cn(C,g)||m.setDocument(g)},{deep:!0});const He=t.ref(null),vn=t.ref(null),Xt=()=>vn.value;function bn(){const g=He.value;if(!g)return;const C=gi(g,m.getState().doc);if(!C)return;const I={steps:[],selectionAfter:C,meta:{addToHistory:!1}};Z=!0,m.dispatch(I),Z=!1}function Cn(g){var J,oe,te,Q,ge,$e,De,it,Fe,Qe,ze,dt;if(_.visible&&((J=O.value)!=null&&J.onKeyDown(g))||M.visible&&((oe=E.value)!=null&&oe.onKeyDown(g)))return;if(!k.value){const Le=g.key,It=g.ctrlKey||g.metaKey,mt=Le.length===1&&!It&&!g.altKey&&!g.isComposing,gt=Le==="Enter"||Le==="Backspace"||Le==="Delete",pt=Le.toLowerCase();if(mt||gt||It&&(pt==="x"||pt==="v"||pt==="z"||pt==="y"||pt==="d")){g.preventDefault();return}if(It&&pt==="a"){g.preventDefault(),(Q=(te=m.commands).selectAll)==null||Q.call(te);return}if(It&&pt==="c"){const zt=m.getState().selection;if(zt.kind==="text"&&Ht(zt)){const bt=Dt(zt);if(bt){g.preventDefault();const Ft=window.ClipboardItem;if(Ft){const Pe=new Ft({"text/plain":new Blob([bt.text],{type:"text/plain"}),"text/html":new Blob([bt.html],{type:"text/html"})});navigator.clipboard.write([Pe]).catch(()=>{navigator.clipboard.writeText(bt.text).catch(()=>{})})}else navigator.clipboard.writeText(bt.text).catch(()=>{})}}return}return}if((g.metaKey||g.ctrlKey)&&g.key.toLowerCase()==="k"&&!g.isComposing){g.preventDefault(),Mt();return}const C=g.target;if(C&&C.classList.contains("image-block-caption")||C&&C.closest(".table-cell-inner"))return;const I=m.getState().selection;I.kind==="text"&&Ht(I)||bn();const H=m.getState().selection;if(H.kind==="text"&&Ht(H)&&!g.isComposing){const Le=g.key,It=Le.length===1&&!g.ctrlKey&&!g.metaKey&&!g.altKey;if(It||Le==="Enter"||Le==="Tab"){if(g.preventDefault(),($e=(ge=m.commands).backspace)==null||$e.call(ge),It){const mt=m.getState().selection;if(mt.kind==="caret"){const gt=m.getState().doc.blocks.get(mt.blockId);if(gt){const[pt,Nt]=Wt(gt.content,mt.offset),zt=[...pt,{type:"text",text:Le},...Nt];(it=(De=m.commands).setText)==null||it.call(De,{id:mt.blockId,content:zt,selectionAfter:st(mt.blockId,mt.offset+1)})}}}return}if((g.ctrlKey||g.metaKey)&&(Le==="c"||Le==="C"||Le==="x"||Le==="X")){const mt=Dt(H);if(mt){g.preventDefault();const gt=window.ClipboardItem;if(gt){const pt=new gt({"text/plain":new Blob([mt.text],{type:"text/plain"}),"text/html":new Blob([mt.html],{type:"text/html"})});navigator.clipboard.write([pt]).catch(()=>{navigator.clipboard.writeText(mt.text).catch(()=>{})})}else navigator.clipboard.writeText(mt.text).catch(()=>{});(Le==="x"||Le==="X")&&((Qe=(Fe=m.commands).backspace)==null||Qe.call(Fe))}return}if(Le==="ArrowLeft"||Le==="ArrowUp"||Le==="ArrowRight"||Le==="ArrowDown"){g.preventDefault();const mt=In(m.getState().doc),gt=mt.indexOf(H.anchor.blockId),pt=mt.indexOf(H.focus.blockId),[Nt,zt]=gt<=pt?[H.anchor,H.focus]:[H.focus,H.anchor],bt=Le==="ArrowLeft"||Le==="ArrowUp"?Nt:zt;Re.value=[],(dt=(ze=m.commands).setSelection)==null||dt.call(ze,{selection:st(bt.blockId,bt.offset)});return}}if((g.key==="ArrowUp"||g.key==="ArrowDown")&&!g.shiftKey&&!g.isComposing){const Le=m.getState().selection;if(Le.kind==="caret"||Le.kind==="text"){const It=Le.kind==="caret"?Le.blockId:Le.focus.blockId,mt=Le.kind==="caret"?Le.offset:Le.focus.offset,gt=m.getState().doc.blocks.get(It);if(gt&&m.registries.schema.get(gt.type).isolating){const Nt=Ae(gt.content),zt=Nt.slice(0,mt),bt=Nt.slice(mt),Ft=zt.lastIndexOf(`
|
|
21
|
+
`)+1,Pe=bt.indexOf(`
|
|
22
|
+
`),ot=Pe===-1?Nt.length:mt+Pe,Kt=Ft===0,kn=ot===Nt.length;if(g.key==="ArrowUp"&&!Kt||g.key==="ArrowDown"&&!kn)return}}}if(xa(m,g)){g.preventDefault();return}if(g.key==="Enter"&&!g.shiftKey&&!g.isComposing){const Le=m.getState().selection;if(Le.kind==="caret"||Le.kind==="text"){const It=Le.kind==="caret"?Le.blockId:Le.focus.blockId,mt=Le.kind==="caret"?Le.offset:Le.focus.offset,gt=m.getState().doc.blocks.get(It);gt&&m.registries.schema.get(gt.type).isolating&&(g.preventDefault(),Tn(It,mt))}}}function Tn(g,C){const I=m.getState().doc.blocks.get(g);if(!I)return;const[H,j]=Wt(I.content,C),J=[...H,{type:"text",text:`
|
|
23
|
+
`},...j],oe=Ae(J),te=He.value,Q=te?$o(te,g):null,ge=window.getSelection();if(Q&&ge&&ge.rangeCount>0){const De=ge.getRangeAt(0);if(Q.contains(De.commonAncestorContainer)){De.collapsed||De.deleteContents();const it=document.createTextNode(`
|
|
24
|
+
`);if(De.insertNode(it),De.setStartAfter(it),De.collapse(!0),ge.removeAllRanges(),ge.addRange(De),oe.endsWith(`
|
|
25
|
+
`)){const Qe=Q.lastChild;Qe&&Qe.nodeType===Node.ELEMENT_NODE&&Qe.tagName==="BR"&&Q.removeChild(Qe),Q.appendChild(document.createElement("br"))}S=!0}else Q.textContent=oe}else Q&&(Q.textContent=oe);const $e={steps:[{op:"setText",id:g,content:J}],selectionAfter:st(g,C+1),meta:{source:"input",addToHistory:!0}};m.dispatch($e)}const Me=t.ref(null),Ie=t.ref("after");let Ge="idle",ct=0,Ke=0,_t=4,ft=null,ht=null,At=0,an=0,Lt=null,hn=null,_n=null,xn=null;function dn(){xn!==null&&(clearTimeout(xn),xn=null),_n=null}function Qn(){var g;Lt&&(Lt.classList.remove("block-being-dragged"),Lt=null),ht&&(ht.remove(),ht=null),hn!==null&&((g=Xt())==null||g.setBlockHandleDragging(hn,!1)),hn=null,ft=null,Ge="idle",vt.value=null,Me.value=null,Ie.value="after",dn()}function Mn(){document.removeEventListener("mousemove",de,!0),document.removeEventListener("mouseup",_e,!0),document.removeEventListener("selectstart",L,!0)}function B(g,C,I,H){k.value&&(Ge!=="idle"&&(Mn(),Qn()),Ge="pending",ft=g,ct=C,Ke=I,_t=H.thresholdPx,document.addEventListener("selectstart",L,!0),document.addEventListener("mousemove",de,!0),document.addEventListener("mouseup",_e,!0))}function b(g){}function L(g){g.preventDefault()}function de(g){if(Ge==="pending"){const ze=g.clientX-ct,dt=g.clientY-Ke;if(Math.sqrt(ze*ze+dt*dt)<=_t)return;Oe()}if(Ge!=="active")return;try{const ze=window.getSelection();ze&&ze.rangeCount>0&&ze.removeAllRanges()}catch{}ht&&(ht.style.left=`${g.clientX+At}px`,ht.style.top=`${g.clientY+an}px`);const C=hn;if(!C)return;const I=Array.from(document.querySelectorAll(".block-host"));if(I.length<=1){Me.value=null;return}const H=I[0].getBoundingClientRect(),j=I[I.length-1].getBoundingClientRect();if(g.clientY<H.top+H.height/2){dn(),Me.value=null,Ie.value="first";return}if(g.clientY>j.bottom-j.height/2){dn(),Me.value=null,Ie.value="last";return}const J=document.elementFromPoint(g.clientX,g.clientY);if(!J){dn(),Me.value=null;return}const oe=J.closest(".block-host");if(!oe){dn(),Me.value=null;return}const te=oe.dataset.blockId;if(!te||te===C){dn(),Me.value=null;return}const Q=oe.getBoundingClientRect(),ge=Q.height===0?0:(g.clientY-Q.top)/Q.height;let $e=!1;const De=m.getState().doc,it=De.blocks.get(te);if(it){const ze=m.registries.schema.get(it.type);if(ze!=null&&ze.nestable){let dt=te;for($e=!0;dt!==null;){if(dt===C){$e=!1;break}dt=Bt(De,dt)}}}if(ge>mg&&ge<pg&&$e){Me.value=te;const ze=ge<.5;_n!==te&&(dn(),_n=te,xn=setTimeout(()=>{_n===te&&(Me.value=te,Ie.value="into")},fg)),Ie.value!=="into"&&(Ie.value=ze?"before":"after")}else dn(),Me.value=te,Ie.value=ge<.5?"before":"after"}function _e(g){if(Mn(),Ge==="pending"){Ge="idle",ft=null;return}const C=hn,I=Me.value,H=Ie.value;Qn(),C&&(H==="into"&&!I||!I&&H!=="first"&&H!=="last"||Be(C,I,H))}function Oe(){var ge,$e;const g=ft;if(!g)return;const C=ct,I=Ke;try{const De=window.getSelection();De&&De.removeAllRanges()}catch{}fe&&(fe=null,Tt&&(cancelAnimationFrame(Tt),Tt=0),Xe=null,document.removeEventListener("mousemove",w,!0),document.removeEventListener("mouseup",z,!0),document.removeEventListener("selectstart",Et,!0),Re.value=[]),Ct(null);const H=document.querySelector(`.block-host[data-block-id="${g}"]`);if(!H){Mn(),Ge="idle",ft=null;return}H.classList.add("block-being-dragged"),Lt=H;const j=H.querySelector(".block-host-content");if(!j){H.classList.remove("block-being-dragged"),Lt=null,Mn(),Ge="idle",ft=null;return}const J=j.getBoundingClientRect(),oe=((ge=j.firstElementChild)==null?void 0:ge.getBoundingClientRect())??J;At=oe.left-C,an=oe.top-I;const te=document.createElement("div");te.className="drag-ghost";const Q=j.firstElementChild;Q&&te.appendChild(Q.cloneNode(!0)),te.style.width=`${oe.width}px`,te.style.left=`${C+At}px`,te.style.top=`${I+an}px`,document.body.appendChild(te),ht=te,vt.value=g,hn=g,Me.value=null,Ie.value="after",($e=Xt())==null||$e.setBlockHandleDragging(g,!0),Ge="active"}function Be(g,C,I){var De,it,Fe;vt.value=null;const H=m.getState().doc;if(!H.blocks.get(g))return;if(C){let Qe=C;for(;Qe!==null;){if(Qe===g)return;Qe=Bt(H,Qe)}}const J=Bt(H,g),oe=sn(H,g);if(oe===-1)return;let te=null,Q;if(I==="first")te=null,Q=0;else if(I==="last")te=null,Q=H.root.length;else if(I==="into"&&C){const Qe=H.blocks.get(C);if(!Qe)return;const ze=m.registries.schema.get(Qe.type);if(!(ze!=null&&ze.nestable))return;let dt=C;for(;dt!==null;){if(dt===g)return;dt=Bt(H,dt)}te=C,Q=0}else if((I==="before"||I==="after")&&C){const Qe=Bt(H,C),ze=sn(H,C);if(ze===-1)return;te=Qe,Q=I==="before"?ze:ze+1}else return;J===te&&oe<Q&&Q--,Q=Math.max(0,Q);const $e=te===null?H.root:(De=H.blocks.get(te))==null?void 0:De.children;$e&&(Q=Math.min(Q,$e.length)),(Fe=(it=m.commands).moveBlock)==null||Fe.call(it,{id:g,toParent:te,toIndex:Q})}const be=t.ref(!1);function y(g){const C=[];if(!g||!g.types||!Array.from(g.types).includes("Files"))return C;const I=new Set;if(g.items&&g.items.length>0)for(let H=0;H<g.items.length;H++){const j=g.items[H];if(j.kind!=="file")continue;const J=j.getAsFile();if(!J||!J.type.startsWith("image/"))continue;const oe=`${J.name||""}:${J.size}:${J.type}`;I.has(oe)||(I.add(oe),C.push(J))}if(g.files&&g.files.length>0)for(let H=0;H<g.files.length;H++){const j=g.files[H];if(!j.type.startsWith("image/"))continue;const J=`${j.name||""}:${j.size}:${j.type}`;I.has(J)||(I.add(J),C.push(j))}return C}function v(g){if(vt.value)return;const C=g.dataTransfer;if(!C||y(C).length===0)return;be.value||(be.value=!0);const H=Array.from(document.querySelectorAll(".block-host"));if(H.length===0){Me.value=null,Ie.value="last";return}const j=H[0].getBoundingClientRect(),J=H[H.length-1].getBoundingClientRect(),oe=g.clientY;if(oe<j.top+j.height/2){Me.value=null,Ie.value="first";return}if(oe>J.bottom-J.height/2){Me.value=null,Ie.value="last";return}const te=document.elementFromPoint(g.clientX,g.clientY);if(!te){Me.value=null,Ie.value="last";return}const Q=te.closest(".block-host");if(!Q){Me.value=null,Ie.value="last";return}const ge=Q.getBoundingClientRect(),$e=Q.dataset.blockId;if(!$e){Me.value=null,Ie.value="last";return}Me.value=$e,Ie.value=oe<ge.top+ge.height/2?"before":"after"}function T(g){const C=g.relatedTarget,I=He.value;I&&C&&I.contains(C)||be.value&&(be.value=!1,Me.value=null,Ie.value="after")}async function R(g){if(vt.value)return;const C=g.dataTransfer;if(!C)return;const I=y(C);if(I.length===0)return;const H=Me.value,j=Ie.value;be.value=!1,Me.value=null,Ie.value="after";let J=H,oe=j==="before"?"before":"after";const te=m.getState().doc;j==="first"?(J=te.root[0]??null,oe="before"):j==="last"&&(J=te.root[te.root.length-1]??null,oe="after");let Q=J;for(let ge=0;ge<I.length;ge++){const $e=I[ge],De=await re($e,{relativeToBlockId:Q,position:ge===0?oe:"after",convertIfEmpty:ge===0});De&&(Q=De)}}function q(g,C){pe(),X(),M.visible=!0,M.anchorEl=C,M.blockId=g}function X(){M.visible=!1,M.anchorEl=null}function ce(g,C){var Q,ge;if(!k.value)return;X(),pe();const I=m.getState().doc.blocks.get(g);if(!I)return;const H=m.registries.schema.get(I.type);if((H==null?void 0:H.content)==="text"&&Ae(I.content).length===0){_.visible=!0,_.anchorEl=C,_.blockId=g,_.query="",_.mode="slash",_.sourceBlockId=void 0;return}(ge=(Q=m.commands).insertBlock)==null||ge.call(Q,{type:m.registries.defaultBlockType,after:g,content:[]});const oe=m.getState().selection,te=oe.kind==="caret"?oe.blockId:g;_.visible=!0,_.anchorEl=C,_.blockId=te,_.query="",_.mode="insert",_.sourceBlockId=g}function ue(g,C,I){k.value&&(X(),_.visible=!0,_.anchorEl=g,_.blockId=C,_.query=I,_.mode="slash",_.sourceBlockId=void 0)}function ke(g,C){if(!_.visible)return;if(g!==_.blockId){pe();return}const I=C.match(/\/([^/]*)$/);if(!I){pe();return}_.query=I[1]??""}function pe(){_.visible=!1,_.anchorEl=null,_.query="",_.sourceBlockId=void 0}t.watch(()=>N.visible,g=>{g&&(_.visible||pe(),M.visible||X())});function xe(g,C){var J,oe,te,Q;const I=_.blockId,H=Ne(I),j=qe(H);m.history.beginGroup();try{H!==j&&((oe=(J=m.commands).setText)==null||oe.call(J,{id:I,content:Wn(j)}));const ge=m.registries.slash.all.find($e=>$e.id===g.id);if(ge){const $e=typeof ge.args=="function"?ge.args(null):ge.args,De=$e&&typeof $e=="object"?{...$e}:{};De.id==="__currentBlock__"&&(De.id=I),De.after==="__currentBlock__"&&(De.after=I);const it=m.commands[ge.command];it==null||it(De),(Q=(te=m.commands).setSelection)==null||Q.call(te,{selection:{kind:"caret",blockId:I,offset:0}}),g.id==="image"&&t.nextTick(()=>{const Fe=document.createElement("input");Fe.type="file",Fe.accept="image/*",Fe.multiple=!1,Fe.addEventListener("change",()=>{var ze;const Qe=(ze=Fe.files)==null?void 0:ze[0];Qe&&re(Qe,{relativeToBlockId:I,position:"replace",convertIfEmpty:!0})}),Fe.click()})}}finally{m.history.endGroup()}pe()}function Ne(g){const C=He.value;if(!C)return"";const I=C.querySelector(`.block-content[data-block-id="${g}"]`);return(I==null?void 0:I.textContent)??""}function qe(g){const C=g.lastIndexOf("/");return C<0?g:g.slice(0,C)}function je(g){var ze,dt,Le,It,mt;let C=!1;g&&typeof g=="object"&&!("type"in g)&&(C=!!g.force);const I=He.value;if(I){const gt=window.getSelection();let pt=null;if(gt&>.rangeCount>0){const Nt=gt.focusNode,zt=(Nt==null?void 0:Nt.nodeType)===1?Nt.closest(".block-content"):(ze=Nt==null?void 0:Nt.parentElement)==null?void 0:ze.closest(".block-content");if(zt&&I.contains(zt)){const bt=zt.getAttribute("data-block-id");bt&&(pt=bt)}}if(pt!==null&&yt.value!==null&&pt!==yt.value){const Nt=m.getState().doc.blocks.get(yt.value);Nt&&we.has(Nt.type)&&(pt=null)}pt!==null&&!A&&Ct(pt)}if(!k.value){N.visible=!1,N.selectionRect=null,N.blockId=null,N.blockType=null,N.blockAttrs={};return}const H=He.value;if(!H)return;const j=m.getState().selection;if(j.kind==="text"&&Ht(j)&&!fe)return;if(Ro(j)&&j.blockIds.length>0){const gt=window.getSelection();if(gt&>.rangeCount>0&>.getRangeAt(0).collapsed){const pt=gi(H,m.getState().doc);pt&&pt.kind==="caret"&&(Z=!0,(Le=(dt=m.commands).setSelection)==null||Le.call(dt,{selection:pt}),Z=!1)}}const J=window.getSelection();if(!J||J.rangeCount===0){!A&&!Ze&&(N.visible=!1,N.selectionRect=null,N.blockId=null,N.blockType=null,N.blockAttrs={});return}const oe=J.getRangeAt(0);if(oe.collapsed){!A&&!Ze&&(N.visible=!1,N.selectionRect=null,N.blockId=null);return}if(!H.contains(oe.commonAncestorContainer)){!A&&!Ze&&(N.visible=!1,N.selectionRect=null,N.blockId=null);return}if(Ze&&!C)return;const te=J.anchorNode;if((te==null?void 0:te.nodeType)===1?te.closest(".table-cell-inner"):(It=te==null?void 0:te.parentElement)==null?void 0:It.closest(".table-cell-inner")){!A&&!Ze&&(N.visible=!1,N.selectionRect=null,N.blockId=null,N.blockType=null,N.blockAttrs={});return}const ge=(te==null?void 0:te.nodeType)===1?te.closest(".block-content"):(mt=te==null?void 0:te.parentElement)==null?void 0:mt.closest(".block-content");if(!ge){!A&&!Ze&&(N.visible=!1,N.selectionRect=null,N.blockId=null);return}const $e=ge.getAttribute("data-block-id");if(!$e){!A&&!Ze&&(N.visible=!1,N.selectionRect=null,N.blockId=null);return}const it=m.getState().doc.blocks.get($e),Fe=oe.getBoundingClientRect(),Qe=Fe.width===0&&Fe.height===0?ge.getBoundingClientRect():Fe;N.visible=!0,N.selectionRect=Qe,N.blockId=$e,N.blockType=(it==null?void 0:it.type)??null,N.blockAttrs=(it==null?void 0:it.attrs)??{}}function at(){const g=m.getState().selection;if(g.kind==="text"&&Ht(g)){if(rt(),N.visible){const j=He.value;if(j){const J=Vr(j,m.getState().doc,g);J.length>0&&(N.selectionRect=Yt(J))}}return}if(!N.visible)return;const C=window.getSelection();if(!C||C.rangeCount===0)return;const I=C.getRangeAt(0);if(I.collapsed)return;const H=I.getBoundingClientRect();H.width===0&&H.height===0||(N.selectionRect=H)}function Yt(g){if(g.length===0)return new DOMRect(0,0,0,0);let C=1/0,I=1/0,H=-1/0,j=-1/0;for(const J of g)C=Math.min(C,J.left),I=Math.min(I,J.top),H=Math.max(H,J.right),j=Math.max(j,J.bottom);return new DOMRect(C,I,H-C,j-I)}function jt(g){if(!k.value)return;const C=He.value;if(!C)return;const I=Vr(C,m.getState().doc,g);if(I.length===0)return;const H=Yt(I),J=m.getState().doc.blocks.get(g.focus.blockId);N.visible=!0,N.selectionRect=H,N.blockId=g.focus.blockId,N.blockType=(J==null?void 0:J.type)??null,N.blockAttrs=(J==null?void 0:J.attrs)??{}}function Ot(g){var j,J;const C=He.value;if(!C||D.value||!C.contains(g.target))return;const I=g.target;if(I&&I.closest(".block-handle"))return;Ze=!0,N.visible=!1;const H=m.getState().selection;if(H.kind==="text"&&Ht(H)&&(Re.value=[]),g.button===0&&!g.shiftKey){const oe=g.target;if(oe&&(oe.closest(".table-cell-inner, .block-table-container, .block-table-of-contents")||oe.closest(".block-focus-root")&&!oe.closest('[contenteditable="true"]'))){Ve=!0;try{const Q=window.getSelection();Q&&Q.removeAllRanges()}catch{}return}else Ve=!1;const te=rr(g.clientX,g.clientY,C,m.getState().doc);te&&(H.kind==="text"&&Ht(H)&&(Z=!0,(J=(j=m.commands).setSelection)==null||J.call(j,{selection:st(te.blockId,te.offset)}),Z=!1),fe={start:{blockId:te.blockId,offset:te.offset},crossBlock:!1},document.addEventListener("mousemove",w,!0),document.addEventListener("mouseup",z,!0))}}function Ue(){if(!Ze)return;if(D.value){Ze=!1;return}if(Ze=!1,Ve){Ve=!1;return}const g=m.getState().selection;g.kind==="text"&&Ht(g)||je()}let Ye=null,Qt=!1;function ut(g){if(!D.value)return;const C=He.value;if(!C||!C.contains(g.target))return;const I=g.target;if(!I||!I.closest(".block-content")||I.closest(".block-handle, .tt-btn, .ht-btn, a[href]"))return;const j=g.touches[0];j&&(Qt=!1,Ye={longPressTimer:window.setTimeout(()=>{Ye&&Jt(C,Ye.startTouch)},hg),startTouch:j},document.addEventListener("touchmove",xt,{passive:!1,capture:!0}),document.addEventListener("touchend",Pt,!0),document.addEventListener("touchcancel",Pt,!0))}function xt(g){var te,Q;if(!Ye)return;Qt=!0;const C=He.value;if(!C)return;if(!fe){const ge=g.touches[0];if(!ge)return;const $e=ge.clientX-Ye.startTouch.clientX,De=ge.clientY-Ye.startTouch.clientY;if(Math.hypot($e,De)>10){Ye.longPressTimer&&clearTimeout(Ye.longPressTimer),Ye=null;return}return}const I=g.touches[0];if(!I)return;const H=rr(I.clientX,I.clientY,C,m.getState().doc);if(!H)return;const j=fe.start;if(H.blockId===j.blockId){if(fe.crossBlock){fe.crossBlock=!1,Re.value=[],document.removeEventListener("selectstart",Et,!0);const ge=window.getSelection();ge&&ge.removeAllRanges()}return}if(g.preventDefault(),!fe.crossBlock){fe.crossBlock=!0,document.addEventListener("selectstart",Et,!0);const ge=window.getSelection();ge&&ge.removeAllRanges()}const J={blockId:H.blockId,offset:H.offset},oe=Br(j,J);Z=!0,(Q=(te=m.commands).setSelection)==null||Q.call(te,{selection:oe}),Z=!1,rt()}function Jt(g,C){const I=rr(C.clientX,C.clientY,g,m.getState().doc);if(!I){Ye=null;return}N.visible=!1;const H=m.getState().selection;H.kind==="text"&&Ht(H)&&(Re.value=[]),fe={start:{blockId:I.blockId,offset:I.offset},crossBlock:!1}}function Pt(){if(Ye&&(Ye.longPressTimer&&clearTimeout(Ye.longPressTimer),Ye=null),!fe){document.removeEventListener("touchmove",xt,!0),document.removeEventListener("touchend",Pt,!0),document.removeEventListener("touchcancel",Pt,!0);return}if(fe=null,document.removeEventListener("touchmove",xt,!0),document.removeEventListener("touchend",Pt,!0),document.removeEventListener("touchcancel",Pt,!0),document.removeEventListener("selectstart",Et,!0),!Qt)return;rt();const g=m.getState().selection;g.kind==="text"&&Ht(g)&&jt(g)}function Dt(g){const C=m.getState().doc,I=In(C),H=I.indexOf(g.anchor.blockId),j=I.indexOf(g.focus.blockId);if(H===-1||j===-1)return null;const[J,oe]=H<=j?[g.anchor,g.focus]:[g.focus,g.anchor],te=I.indexOf(J.blockId),Q=I.indexOf(oe.blockId);if(te===-1||Q===-1)return null;const ge=[],$e=[];for(let De=te;De<=Q;De++){const it=I[De],Fe=C.blocks.get(it);if(!Fe)continue;const Qe=Ae(Fe.content).length;let ze=0,dt=Qe;De===te&&(ze=Math.min(J.offset,Qe)),De===Q&&(dt=Math.min(oe.offset,Qe)),ze>dt&&([ze,dt]=[dt,ze]);const[,Le]=Wt(Fe.content,ze),[It]=Wt(Le,dt-ze);ge.push(Ae(It)),$e.push(Zn(It))}return{text:ge.join(`
|
|
26
|
+
`),html:$e.join("<br>")}}function Rn(g){var H,j;const C=m.getState().selection;if(C.kind!=="text"||!Ht(C))return;const I=Dt(C);I&&(g.preventDefault(),(H=g.clipboardData)==null||H.setData("text/plain",I.text),(j=g.clipboardData)==null||j.setData("text/html",I.html))}function Vt(g){var H,j,J,oe;if(!k.value){g.preventDefault();return}const C=m.getState().selection;if(C.kind!=="text"||!Ht(C))return;const I=Dt(C);I&&(g.preventDefault(),(H=g.clipboardData)==null||H.setData("text/plain",I.text),(j=g.clipboardData)==null||j.setData("text/html",I.html),(oe=(J=m.commands).backspace)==null||oe.call(J))}function Ln(g){if(!k.value)return;const C=g.detail;if(!(C!=null&&C.blockId)||!(C!=null&&C.anchor))return;const I=C.blockId,H=m.getState().doc,j=H.blocks.get(I),J=$n(H,I),te=typeof(j==null?void 0:j.attrs).startNumber=="number"&&!!J&&J.type==="orderedList",Q=is(H,I),ge=Q!==1;pe(),X(),Nn(),Se(),N.visible=!1,le.visible=!0,le.blockId=I,le.anchor=C.anchor,le.canContinue=te,le.canStartNew=ge,le.currentNumber=Q}function Ut(){le.visible=!1,le.anchor=null,le.blockId=null}function $t(){var g,C;le.blockId&&((C=(g=m.commands).setStartNumber)==null||C.call(g,{id:le.blockId,startNumber:null}),Ut())}function lc(){var g,C;le.blockId&&((C=(g=m.commands).setStartNumber)==null||C.call(g,{id:le.blockId,startNumber:1}),Ut())}function Tl(g){if(!le.blockId)return;const C=le.anchor,I=le.blockId;Ut(),C&&(he.visible=!0,he.initialValue=g,he.anchor=C,he.blockId=I)}function Nn(){he.visible=!1,he.anchor=null,he.blockId=null}function _l(g){var C,I;if(!he.blockId){Nn();return}(I=(C=m.commands).setStartNumber)==null||I.call(C,{id:he.blockId,startNumber:g}),Nn(),Ut()}function Tr(g){if(!k.value)return;const C=g.detail;if(!(C!=null&&C.blockId)||!(C!=null&&C.anchor))return;const I=C.blockId,j=m.getState().doc.blocks.get(I);if(!j)return;const J=j.attrs.language??"plain";pe(),X(),Nn(),Ut(),Se(),N.visible=!1,ae.visible=!0,ae.blockId=I,ae.anchor=C.anchor,ae.initialValue=J}function Fn(){ae.visible=!1,ae.anchor=null,ae.blockId=null}function xl(g){var C,I;if(!ae.blockId){Fn();return}(I=(C=m.commands).setAttrs)==null||I.call(C,{id:ae.blockId,attrs:{language:g}}),Fn()}function _o(g){var te,Q,ge,$e,De;const C=g.target,I=document.querySelector(".ordered-list-menu"),H=document.querySelector(".number-picker"),j=document.querySelector(".code-lang-picker"),J=document.querySelector(".link-popover");if(I&&I.contains(C)||H&&H.contains(C)||j&&j.contains(C)||J&&J.contains(C)||C instanceof Node&&((te=C.closest)!=null&&te.call(C,".ol-marker"))||C instanceof Node&&((Q=C.closest)!=null&&Q.call(C,".block-code-lang"))||C instanceof Node&&((ge=C.closest)!=null&&ge.call(C,"a[href]")))return;Ut(),Nn(),Fn(),Se();const oe=m.getState().selection;if(oe.kind==="blocks"&&oe.blockIds.length>0){const it=He.value;if(it&&it.contains(C)){const Fe=C.nodeType===1?C:C.parentElement??null;if(Fe&&(Fe.closest("[contenteditable]")||Fe.closest(".block-image-wrapper, .block-image-container, .block-table-container, .block-code-wrapper, .block-divider, .block-todo-checkbox, .block-ordered-list-wrapper, .block-video, .block-file, .block-embed, .block-callout")))return}(De=($e=m.commands).clearSelection)==null||De.call($e)}}function xo(g){const C=g.target;C instanceof Element&&(C.closest(".code-lang-picker")||C.closest(".ordered-list-menu")||C.closest(".number-picker")||C.closest(".link-popover"))||(le.visible&&Ut(),he.visible&&Nn(),ae.visible&&Fn(),ie.visible&&Se())}function _r(g){var I,H;if(g.key!=="Escape")return;const C=m.getState().selection;C.kind==="blocks"&&C.blockIds.length>0&&(g.preventDefault(),(H=(I=m.commands).clearSelection)==null||H.call(I))}function On(g){const C=g.target;if(!C||C.closest(".block-handle")||C.closest('[contenteditable="true"]'))return;const I=C.closest(".block-focus-root");if(!I)return;const H=I.closest(".block-host");if(!H)return;const j=He.value;if(!j||!j.contains(H))return;const J=H.getAttribute("data-block-id");J&&Ct(J,{clearNativeSelection:!0})}function Ml(g){g.target===He.value&&Ct(null,{clearNativeSelection:!0})}return t.onMounted(()=>{t.nextTick(()=>{const g=He.value;if(!g)return;const C=m.getState().selection;yi(g,C),g.addEventListener("ordered-list-marker-click",Ln),g.addEventListener("code-lang-click",Tr),g.addEventListener("click",On),g.addEventListener("click",Ml)}),document.addEventListener("selectionchange",je),document.addEventListener("mousedown",Ot,!0),document.addEventListener("mouseup",Ue,!0),document.addEventListener("mousedown",_o,!0),document.addEventListener("touchstart",_o,!0),window.addEventListener("scroll",at,!0),window.addEventListener("resize",at),window.addEventListener("scroll",xo,!0),document.addEventListener("touchmove",xo,{passive:!0,capture:!0}),document.addEventListener("keydown",_r,!0),x==null||x.addEventListener("change",U),document.addEventListener("touchstart",ut,{passive:!1,capture:!0})}),t.onBeforeUnmount(()=>{const g=He.value;g&&(g.removeEventListener("ordered-list-marker-click",Ln),g.removeEventListener("code-lang-click",Tr),g.removeEventListener("click",On),g.removeEventListener("click",Ml)),document.removeEventListener("selectionchange",je),document.removeEventListener("mousedown",Ot,!0),document.removeEventListener("mouseup",Ue,!0),document.removeEventListener("mousedown",_o,!0),document.removeEventListener("touchstart",_o,!0),window.removeEventListener("scroll",at,!0),window.removeEventListener("resize",at),window.removeEventListener("scroll",xo,!0),document.removeEventListener("touchmove",xo,!0),document.removeEventListener("keydown",_r,!0),x==null||x.removeEventListener("change",U),document.removeEventListener("touchstart",ut,!0),document.removeEventListener("touchmove",xt,!0),document.removeEventListener("touchend",Pt,!0),document.removeEventListener("touchcancel",Pt,!0),on(),m.destroy(),V(),hd(),gd()}),n({editor:m}),(g,C)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"rootEl",ref:He,class:t.normalizeClass(["block-editor",[u.value,{"block-editor-dragging":vt.value!==null,"is-mobile":D.value}]]),style:t.normalizeStyle(h.value),contenteditable:!1,onKeydown:Cn,onCopy:Rn,onCut:Vt,onDragover:t.withModifiers(v,["prevent"]),onDragleave:T,onDrop:t.withModifiers(R,["prevent"])},[t.createVNode(rm,{"root-el":He.value,"focus-block-id":yt.value,"hover-visible":N.visible,"hover-selection-rect":N.selectionRect,"hover-block-id":N.blockId,"hover-block-type":N.blockType,"hover-block-attrs":N.blockAttrs,"plus-menu-visible":_.visible,"settings-menu-visible":M.visible,position:ee.value,onToolbarInteracting:me,onOpenPlusMenu:ce,onOpenSettingsMenu:q,onLinkClick:Zt,onHoverClose:C[0]||(C[0]=I=>N.visible=!1)},null,8,["root-el","focus-block-id","hover-visible","hover-selection-rect","hover-block-id","hover-block-type","hover-block-attrs","plus-menu-visible","settings-menu-visible","position"]),t.createElementVNode("div",dg,[t.createVNode(Ki,{ref_key:"blockListRef",ref:vn,items:K.value,"blocks-map":G.value.doc.blocks,"first-block-placeholder":p.value,"hovered-block-id":tt.value,"focused-block-id":yt.value,"has-text-selection":N.visible,"dragging-block-id":vt.value,"drop-target-block-id":Me.value,"drop-position":Ie.value,"menu-open-block-id":M.visible?M.blockId:null,onOpenSettingsMenu:q,onOpenPlusMenu:ce,onSlashTrigger:ue,onInputChanged:ke,onHoverChange:qt,onGripPointerDown:B,onGripPointerUp:b,onLinkClick:Gt,onFocusIn:Rt},null,8,["items","blocks-map","first-block-placeholder","hovered-block-id","focused-block-id","has-text-selection","dragging-block-id","drop-target-block-id","drop-position","menu-open-block-id"])]),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[Re.value.length>0?(t.openBlock(),t.createElementBlock("div",ug,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(Re.value,(I,H)=>(t.openBlock(),t.createElementBlock("div",{key:H,class:"cross-block-selection-rect",style:t.normalizeStyle({left:I.left+"px",top:I.top+"px",width:I.width+"px",height:I.height+"px"})},null,4))),128))])):t.createCommentVNode("",!0)])),t.createVNode(Wd,{ref_key:"plusMenuRef",ref:O,visible:_.visible,"anchor-el":_.anchorEl,"block-id":_.blockId,query:_.query,"root-el":He.value,mode:_.mode,onClose:pe,onCommit:xe},null,8,["visible","anchor-el","block-id","query","root-el","mode"]),t.createVNode(Ju,{ref_key:"settingsMenuRef",ref:E,visible:M.visible,"anchor-el":M.anchorEl,"block-id":M.blockId,"root-el":He.value,onClose:X},null,8,["visible","anchor-el","block-id","root-el"]),t.createVNode(ns,{visible:le.visible,"block-id":le.blockId,anchor:le.anchor,"root-el":He.value,"can-continue":le.canContinue,"can-start-new":le.canStartNew,"current-number":le.currentNumber,onContinue:$t,onStartNew:lc,onModify:Tl,onClose:Ut},null,8,["visible","block-id","anchor","root-el","can-continue","can-start-new","current-number"]),t.createVNode(os,{visible:he.visible,"initial-value":he.initialValue,anchor:he.anchor,"root-el":He.value,onConfirm:_l,onClose:Nn},null,8,["visible","initial-value","anchor","root-el"]),t.createVNode(Tm,{visible:ae.visible,"initial-value":ae.initialValue,anchor:ae.anchor,"root-el":He.value,onConfirm:xl,onClose:Fn},null,8,["visible","initial-value","anchor","root-el"]),t.createVNode(ls,{visible:ie.visible,"anchor-rect":ie.anchorRect,"block-id":ie.blockId,from:ie.from,to:ie.to,href:ie.href,text:ie.text,"initial-mode":ie.initialMode,"show-text-input":ie.showTextInput,readonly:!k.value,onClose:Se},null,8,["visible","anchor-rect","block-id","from","to","href","text","initial-mode","show-text-input","readonly"])],38))}});se.BlockContent=Un,se.BlockEditor=gg,se.BlockHost=Fi,se.BlockList=Ki,se.BuiltinExtensions=rc,se.CommandRegistry=ql,se.DeserializerRegistry=li,se.DividerExtension=nc,se.Editor=ai,se.HeadingExtension=cs,se.HistoryExtension=ds,se.HistoryManager=ci,se.ImageExtension=Qs,se.InputRuleRegistry=ni,se.KeymapExtension=as,se.KeymapRegistry=ti,se.ParagraphExtension=ss,se.SchemaRegistry=Pl,se.SerializerRegistry=ri,se.SlashCommandRegistry=oi,se.TableExtension=tc,se.TableOfContentsExtension=oc,se.TransactionBuilder=Kl,se.applySteps=Jo,se.applyTransaction=Fl,se.asBlockId=vc,se.blockAfter=po,se.blockBefore=$n,se.blocksSelection=Bc,se.buildRegistries=si,se.canContain=Ll,se.caretSelection=st,se.coerceAttrs=Rl,se.collectIndentSyncPatches=zl,se.createBlockId=fo,se.createPrimitiveCommands=Ql,se.createState=Ir,se.createTransaction=et,se.defaultAttrs=Gn,se.defineSchema=Mr,se.depthOf=Dn,se.docFromData=Nr,se.docToData=Vl,se.editorKey=Pr,se.extensionBlockType=sa,se.flatten=In,se.flattenExtensions=ii,se.focusOffset=Rc,se.getBlock=St,se.hasText=Ol,se.indexOf=sn,se.inlineFromString=Wn,se.inlineText=Ae,se.invertSteps=Wl,se.isBlockId=uo,se.isBlocks=Ro,se.isCaret=ho,se.isCollapsed=Rr,se.isEmpty=$l,se.isIsolating=Dl,se.isText=qn,se.isTextRun=wc,se.keyMatches=ei,se.keyNameFromEvent=Jl,se.lastDescendant=Ul,se.nextSibling=_c,se.normalizeLocale=Hi,se.normalizeTheme=Vi,se.orderedAnchors=Lc,se.parentOf=Bt,se.prevSibling=Ar,se.primaryBlock=Gl,se.requireBlock=ln,se.siblingList=mo,se.splitInline=Wt,se.textSelection=Br,se.useEditor=fn,se.useI18n=en,se.withAttrs=Mc,se.withContent=xc,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})});
|