@payloadcms/richtext-lexical 3.62.0-canary.5 → 3.62.0-internal.54b5b1d

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.
Files changed (82) hide show
  1. package/dist/exports/client/Field-W7C7KSV7.js +2 -0
  2. package/dist/exports/client/Field-W7C7KSV7.js.map +7 -0
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/chunk-UDMS2AKL.js +12 -0
  5. package/dist/exports/client/chunk-UDMS2AKL.js.map +7 -0
  6. package/dist/exports/client/index.js +26 -26
  7. package/dist/exports/client/index.js.map +3 -3
  8. package/dist/exports/react/index.d.ts +1 -1
  9. package/dist/exports/react/index.d.ts.map +1 -1
  10. package/dist/exports/react/index.js.map +1 -1
  11. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +2 -14
  12. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  13. package/dist/features/converters/lexicalToJSX/Component/index.js +4 -2
  14. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  15. package/dist/features/converters/lexicalToJSX/converter/index.d.ts +16 -1
  16. package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
  17. package/dist/features/converters/lexicalToJSX/converter/index.js +76 -4
  18. package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
  19. package/dist/features/converters/lexicalToJSX/converter/types.d.ts +14 -10
  20. package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
  21. package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
  22. package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -1
  23. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  24. package/dist/field/Field.d.ts.map +1 -1
  25. package/dist/field/Field.js +10 -6
  26. package/dist/field/Field.js.map +1 -1
  27. package/dist/field/RichTextViewProvider.d.ts +84 -0
  28. package/dist/field/RichTextViewProvider.d.ts.map +1 -0
  29. package/dist/field/RichTextViewProvider.js +92 -0
  30. package/dist/field/RichTextViewProvider.js.map +1 -0
  31. package/dist/field/ViewSelector.d.ts +4 -0
  32. package/dist/field/ViewSelector.d.ts.map +1 -0
  33. package/dist/field/ViewSelector.js +89 -0
  34. package/dist/field/ViewSelector.js.map +1 -0
  35. package/dist/field/bundled.css +1 -1
  36. package/dist/field/index.d.ts.map +1 -1
  37. package/dist/field/index.js +48 -34
  38. package/dist/field/index.js.map +1 -1
  39. package/dist/field/rscEntry.d.ts +1 -1
  40. package/dist/field/rscEntry.d.ts.map +1 -1
  41. package/dist/field/rscEntry.js +12 -0
  42. package/dist/field/rscEntry.js.map +1 -1
  43. package/dist/index.d.ts +1 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +3 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  48. package/dist/lexical/LexicalEditor.js +2 -1
  49. package/dist/lexical/LexicalEditor.js.map +1 -1
  50. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  51. package/dist/lexical/LexicalProvider.js +12 -3
  52. package/dist/lexical/LexicalProvider.js.map +1 -1
  53. package/dist/lexical/config/client/sanitize.d.ts +1 -1
  54. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  55. package/dist/lexical/config/client/sanitize.js +3 -2
  56. package/dist/lexical/config/client/sanitize.js.map +1 -1
  57. package/dist/lexical/config/types.d.ts +4 -0
  58. package/dist/lexical/config/types.d.ts.map +1 -1
  59. package/dist/lexical/config/types.js.map +1 -1
  60. package/dist/lexical/nodes/index.d.ts +12 -2
  61. package/dist/lexical/nodes/index.d.ts.map +1 -1
  62. package/dist/lexical/nodes/index.js +195 -2
  63. package/dist/lexical/nodes/index.js.map +1 -1
  64. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +2 -0
  65. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -0
  66. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +48 -0
  67. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -0
  68. package/dist/types.d.ts +136 -2
  69. package/dist/types.d.ts.map +1 -1
  70. package/dist/types.js.map +1 -1
  71. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  72. package/dist/utilities/generateImportMap.js +1 -0
  73. package/dist/utilities/generateImportMap.js.map +1 -1
  74. package/dist/validate/hasText.d.ts +6 -1
  75. package/dist/validate/hasText.d.ts.map +1 -1
  76. package/dist/validate/hasText.js +10 -4
  77. package/dist/validate/hasText.js.map +1 -1
  78. package/package.json +6 -6
  79. package/dist/exports/client/Field-F2KOJLMQ.js +0 -2
  80. package/dist/exports/client/Field-F2KOJLMQ.js.map +0 -7
  81. package/dist/exports/client/chunk-AFXLIYGL.js +0 -12
  82. package/dist/exports/client/chunk-AFXLIYGL.js.map +0 -7
@@ -0,0 +1,12 @@
1
+ var st=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";import{c as xe}from"react/compiler-runtime";import{useRef as Ee}from"react";function no(r){let t=xe(2),e=r===void 0?500:r,n=Ee(void 0),o;return t[0]!==e?(o=c=>new Promise(i=>{let l=()=>{c(),i()};"requestIdleCallback"in window?("cancelIdleCallback"in window&&n.current!==void 0&&cancelIdleCallback(n.current),n.current=requestIdleCallback(l,{timeout:e})):_e().then(l)}),t[0]=e,t[1]=o):o=t[1],o}function _e(){return new Promise(r=>{setTimeout(r,100),requestAnimationFrame(()=>{setTimeout(r,0)})})}var z=class{_x;_y;constructor(t,e){this._x=t,this._y=e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}equals({x:t,y:e}){return this.x===t&&this.y===e}get x(){return this._x}get y(){return this._y}};function ct(r){return r instanceof z}import{jsx as ve}from"react/jsx-runtime";import{useLexicalComposerContext as Pe}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as He}from"@lexical/utils";import{$getSelection as W,$isRangeSelection as V,$isTextNode as Ke,COMMAND_PRIORITY_LOW as Ue,createCommand as Xe,getDOMSelection as Ge}from"lexical";import{useCallback as Et,useEffect as _t,useState as ze}from"react";import*as j from"react";import{c as mt}from"react/compiler-runtime";import{useLexicalComposerContext as pt}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as lt}from"@lexical/utils";import{$getSelection as gt,$isRangeSelection as Te,$setSelection as we,COMMAND_PRIORITY_LOW as at,COMMAND_PRIORITY_NORMAL as $,createCommand as Se,KEY_ARROW_DOWN_COMMAND as Ce,KEY_ARROW_UP_COMMAND as Re,KEY_ENTER_COMMAND as ye,KEY_ESCAPE_COMMAND as Oe,KEY_TAB_COMMAND as be}from"lexical";import{useCallback as Y,useEffect as b,useLayoutEffect as ke,useMemo as Ne,useRef as Fe,useState as Ie}from"react";var Me="slash-menu-popup",ft=r=>{let t=document.getElementById("slash-menu");if(!t)return;let e=t.getBoundingClientRect();e.top+e.height>window.innerHeight&&t.scrollIntoView({block:"center"}),e.top<0&&t.scrollIntoView({block:"center"}),r.scrollIntoView({block:"nearest"})};function Ae(r,t,e){let n=e;for(let o=n;o<=t.length;o++)r.substring(r.length-o)===t.substring(0,o)&&(n=o);return n}function De(r){let t=gt();if(!Te(t)||!t.isCollapsed())return;let e=t.anchor;if(e.type!=="text")return;let n=e.getNode();if(!n.isSimpleText())return;let o=e.offset,s=n.getTextContent().slice(0,o),c=r.replaceableString.length,i=Ae(s,r.matchingString,c),l=o-i;if(l<0)return;let a;return l===0?[a]=n.splitText(o):[,a]=n.splitText(l,o),a}function Le(r,t){let e=getComputedStyle(r),n=e.position==="absolute",o=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let s=r;s=s.parentElement;)if(e=getComputedStyle(s),!(n&&e.position==="static")&&o.test(e.overflow+e.overflowY+e.overflowX))return s;return document.body}function ut(r,t){let e=r.getBoundingClientRect(),n=t.getBoundingClientRect();return e.top>n.top&&e.top<n.bottom}function $e(r,t,e,n){let o=mt(7),[s]=pt(),c,i;o[0]!==s||o[1]!==e||o[2]!==n||o[3]!==r||o[4]!==t?(c=()=>{let l=t.current;if(l!=null&&r!=null){let a=s.getRootElement(),u=a!=null?Le(a,!1):document.body,p=!1,m=ut(l,u),g=function(){p||(window.requestAnimationFrame(function(){e(),p=!1}),p=!0);let d=ut(l,u);d!==m&&(m=d,n?.(d))},f=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",g,{capture:!0,passive:!0}),f.observe(l),()=>{f.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",g,!0)}}},i=[s,n,e,r,t],o[0]=s,o[1]=e,o[2]=n,o[3]=r,o[4]=t,o[5]=c,o[6]=i):(c=o[5],i=o[6]),b(c,i)}var dt=Se("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function ht({anchorElementRef:r,close:t,editor:e,groups:n,menuRenderFn:o,resolution:s,shouldSplitNodeWithQuery:c=!1}){let[i,l]=Ie(null),a=s.match&&s.match.matchingString||"",u=Y(f=>{let d=e.getRootElement();d!==null&&(d.setAttribute("aria-activedescendant",`${Me}__item-${f.key}`),l(f.key))},[e]),p=Y(()=>{if(n!==null&&a!=null){let f=n.flatMap(d=>d.items);if(f.length){let d=f[0];u(d)}}},[n,u,a]);b(()=>{p()},[a,p]);let m=Y(f=>{t(),e.update(()=>{let d=s.match!=null&&c?De(s.match):null;d&&d.remove()}),setTimeout(()=>{let d;e.read(()=>{d=gt()?.clone()}),e.update(()=>{d&&we(d)}),f.onSelect({editor:e,queryString:s.match?s.match.matchingString:""})},0)},[e,c,s.match,t]);b(()=>()=>{let f=e.getRootElement();f!==null&&f.removeAttribute("aria-activedescendant")},[e]),ke(()=>{n===null?l(null):i===null&&p()},[n,i,u,p]),b(()=>lt(e.registerCommand(dt,({item:f})=>f.ref&&f.ref.current!=null?(ft(f.ref.current),!0):!1,at)),[e,u]),b(()=>lt(e.registerCommand(Ce,f=>{let d=f;if(n!==null&&n.length&&i!==null){let h=n.flatMap(T=>T.items),x=h.findIndex(T=>T.key===i),E=x!==h.length-1?x+1:0,_=h[E];if(!_)return!1;u(_),_.ref!=null&&_.ref.current&&e.dispatchCommand(dt,{index:E,item:_}),d.preventDefault(),d.stopImmediatePropagation()}return!0},$),e.registerCommand(Re,f=>{let d=f;if(n!==null&&n.length&&i!==null){let h=n.flatMap(T=>T.items),x=h.findIndex(T=>T.key===i),E=x!==0?x-1:h.length-1,_=h[E];if(!_)return!1;u(_),_.ref!=null&&_.ref.current&&ft(_.ref.current),d.preventDefault(),d.stopImmediatePropagation()}return!0},$),e.registerCommand(Oe,f=>{let d=f;return d.preventDefault(),d.stopImmediatePropagation(),t(),!0},at),e.registerCommand(be,f=>{let d=f;if(n===null||i===null)return!1;let x=n.flatMap(E=>E.items).find(E=>E.key===i);return x?(d.preventDefault(),d.stopImmediatePropagation(),m(x),!0):!1},$),e.registerCommand(ye,f=>{if(n===null||i===null)return!1;let h=n.flatMap(x=>x.items).find(x=>x.key===i);return h?(f!==null&&(f.preventDefault(),f.stopImmediatePropagation()),m(h),!0):!1},$)),[m,t,e,n,i,u]);let g=Ne(()=>({groups:n,selectedItemKey:i,selectItemAndCleanUp:m,setSelectedItemKey:l}),[m,i,n]);return o(r,g,s.match?s.match.matchingString:"")}function Be(r,t){t!=null&&(r.className=t),r.setAttribute("aria-label","Slash menu"),r.setAttribute("role","listbox"),r.style.display="block",r.style.position="absolute"}function xt(r,t,e,n){let o=mt(14),[s]=pt(),c;o[0]===Symbol.for("react.memo_cache_sentinel")?(c=st?document.createElement("div"):null,o[0]=c):c=o[0];let i=Fe(c),l;o[1]!==r||o[2]!==n||o[3]!==s||o[4]!==t?(l=()=>{if(i.current===null||parent===void 0)return;let f=s.getRootElement(),d=i.current,h=d.firstChild;if(f!==null&&t!==null){let{height:x,width:E}=t.getRect(),{left:_,top:T}=t.getRect(),O=T;if(T=T-(r.getBoundingClientRect().top+window.scrollY),_=_-(r.getBoundingClientRect().left+window.scrollX),d.style.left=`${_+window.scrollX}px`,d.style.height=`${x}px`,d.style.width=`${E}px`,h!==null){let w=h.getBoundingClientRect(),L=w.height,C=w.width,G=f.getBoundingClientRect(),rt=document.dir==="rtl"||document.documentElement.dir==="rtl",me=r.getBoundingClientRect(),it=Math.max(0,G.left);if(!rt&&_+C>G.right)d.style.left=`${G.right-C+window.scrollX}px`;else if(rt&&w.left<it){let he=it+C-me.left;d.style.left=`${he+window.scrollX}px`}let pe=O+L+32>window.innerHeight,ge=O<0;pe&&!ge?d.style.top=`${T+32-L+window.scrollY-(x+24)}px`:d.style.top=`${T+window.scrollY+32}px`}d.isConnected||(Be(d,n),r.append(d)),d.setAttribute("id","slash-menu"),i.current=d,f.setAttribute("aria-controls","slash-menu")}},o[1]=r,o[2]=n,o[3]=s,o[4]=t,o[5]=l):l=o[5];let a=l,u,p;o[6]!==s||o[7]!==a||o[8]!==t?(u=()=>{let f=s.getRootElement();if(t!==null)return a(),()=>{f!==null&&f.removeAttribute("aria-controls");let d=i.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},p=[s,a,t],o[6]=s,o[7]=a,o[8]=t,o[9]=u,o[10]=p):(u=o[9],p=o[10]),b(u,p);let m;return o[11]!==t||o[12]!==e?(m=f=>{t!==null&&(f||e(null))},o[11]=t,o[12]=e,o[13]=m):m=o[13],$e(t,i,a,m),i}var _o=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Ye(r){let t=r.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let n=t.offset;return e.getTextContent().slice(0,n)}function Tt(r,t,e){let n=Ge(e);if(n===null||!n.isCollapsed)return!1;let o=n.anchorNode,s=r,c=n.anchorOffset;if(o==null||c==null)return!1;try{t.setStart(o,s),t.setEnd(o,c>1?c:1)}catch{return!1}return!0}function je(r){let t;return r.getEditorState().read(()=>{let e=W();V(e)&&(t=Ye(e))}),t}function wt(r,t){return t!==0?!1:r.getEditorState().read(()=>{let e=W();if(V(e)){let s=e.anchor.getNode().getPreviousSibling();return Ke(s)&&s.isTextEntity()}return!1})}function St(r){j.startTransition?j.startTransition(r):r()}var We=Xe("ENABLE_SLASH_MENU_COMMAND");function To({anchorClassName:r,anchorElem:t,groups:e,menuRenderFn:n,onClose:o,onOpen:s,onQueryChange:c,triggerFn:i}){let[l]=Pe(),[a,u]=ze(null),p=xt(t,a,u,r),m=Et(()=>{u(null),o!=null&&a!==null&&o()},[o,a]),g=Et(f=>{u(f),s!=null&&a===null&&s(f)},[s,a]);return _t(()=>He(l.registerCommand(We,({node:f})=>(l.getEditorState().read(()=>{let d={leadOffset:0,matchingString:"",replaceableString:""};if(!wt(l,d.leadOffset)&&f!==null){let h=l._window??window,x=h.document.createRange();Tt(d.leadOffset,x,h)!==null&&St(()=>g({getRect:()=>x.getBoundingClientRect(),match:d}));return}}),!0),Ue)),[l,g]),_t(()=>{let f=()=>{l.getEditorState().read(()=>{let h=l._window??window,x=h.document.createRange(),E=W(),_=je(l);if(!V(E)||!E.isCollapsed()||_===void 0||x===null){m();return}let T=i({editor:l,query:_});if(c(T?T.matchingString:null),T!==null&&!wt(l,T.leadOffset)&&Tt(T.leadOffset,x,h)!==null){St(()=>g({getRect:()=>x.getBoundingClientRect(),match:T}));return}m()})},d=l.registerUpdateListener(f);return()=>{d()}},[l,i,c,a,m,g]),p.current===null||a===null||l===null?null:ve(ht,{anchorElementRef:p,close:m,editor:l,groups:e,menuRenderFn:n,resolution:a,shouldSplitNodeWithQuery:!0})}var Ct=class r{_bottom;_left;_right;_top;constructor(t,e,n,o){let[s,c]=e<=o?[e,o]:[o,e],[i,l]=t<=n?[t,n]:[n,t];this._top=s,this._right=l,this._left=i,this._bottom=c}static fromDOM(t){let{height:e,left:n,top:o,width:s}=t.getBoundingClientRect();return r.fromLWTH(n,s,o,e)}static fromDOMRect(t){let{height:e,left:n,top:o,width:s}=t;return r.fromLWTH(n,s,o,e)}static fromLTRB(t,e,n,o){return new r(t,e,n,o)}static fromLWTH(t,e,n,o){return new r(t,n,t+e,n+o)}static fromPoints(t,e){let{x:n,y:o}=t,{x:s,y:c}=e;return r.fromLTRB(n,o,s,c)}contains(t){if(ct(t)){let{x:c,y:i}=t,l=i<this._top,a=i>this._bottom,u=c<this._left,p=c>this._right;return{reason:{isOnBottomSide:a,isOnLeftSide:u,isOnRightSide:p,isOnTopSide:l},result:!l&&!a&&!u&&!p}}let{bottom:e,left:n,right:o,top:s}=t;return s>=this._top&&s<=this._bottom&&e>=this._top&&e<=this._bottom&&n>=this._left&&n<=this._right&&o>=this._left&&o<=this._right}distanceFromPoint(t){let e=this.contains(t);if(e.result)return{distance:0,isOnBottomSide:e.reason.isOnBottomSide,isOnLeftSide:e.reason.isOnLeftSide,isOnRightSide:e.reason.isOnRightSide,isOnTopSide:e.reason.isOnTopSide};let n=0,o=0;return t.x<this._left?n=this._left-t.x:t.x>this._right&&(n=t.x-this._right),t.y<this._top?o=this._top-t.y:t.y>this._bottom&&(o=t.y-this._bottom),{distance:Math.sqrt(n*n+o*o),isOnBottomSide:t.y>this._bottom,isOnLeftSide:t.x<this._left,isOnRightSide:t.x>this._right,isOnTopSide:t.y<this._top}}equals({bottom:t,left:e,right:n,top:o}){return o===this._top&&t===this._bottom&&e===this._left&&n===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:n=this.right,top:o=this.top}){return new r(e,o,n,t)}intersectsWith(t){let{height:e,left:n,top:o,width:s}=t,{height:c,left:i,top:l,width:a}=this,u=n+s>=i+a?n+s:i+a,p=o+e>=l+c?o+e:l+c,m=n<=i?n:i,g=o<=l?o:l;return u-m<=s+a&&p-g<=e+c}get bottom(){return this._bottom}get height(){return Math.abs(this._bottom-this._top)}get left(){return this._left}get right(){return this._right}get top(){return this._top}get width(){return Math.abs(this._left-this._right)}};import q from"react";var A=new WeakMap;function yo(r,t){A.has(r)||A.set(r,new Map);let e=A.get(r);for(let[n,o]of Object.entries(t))if(!(!o||typeof o!="object")){if(n==="blocks"){for(let[s,c]of Object.entries(o))e.set(`block:${s}`,c);continue}if(n==="inlineBlocks"){for(let[s,c]of Object.entries(o))e.set(`inlineBlock:${s}`,c);continue}e.set(n,o)}}function Oo(r){A.delete(r)}function Rt(r,t,e){let n=A.get(r);if(t==="block"&&e?.__fields?.blockType){let o=e.__fields.blockType;return n?.get(`block:${o}`)}if(t==="inlineBlock"&&e?.__fields?.blockType){let o=e.__fields.blockType;return n?.get(`inlineBlock:${o}`)}return n?.get(t)}function Ve({node:r,nodeType:t}){if(!("getType"in r)||r.getType()!==t)return;let e=r;if(e.prototype._originalDecorate||(e.prototype._originalDecorate=e.prototype.decorate),e.prototype._originalCreateDOM||(e.prototype._originalCreateDOM=e.prototype.createDOM),e.prototype.decorate&&!e.prototype._decorateOverridden){e.prototype._decorateOverridden=!0;let n=!!e.prototype.createDOM;e.prototype.decorate=function(o,s){let c=Rt(o,t,this);if(c){if(c.Component)return c.Component({config:s,editor:o,isEditor:!0,isJSXConverter:!1,node:this});if(c.createDOM&&c.html){let i=typeof c.html=="function"?c.html({config:s,editor:o,isEditor:!0,isJSXConverter:!1,node:this}):c.html;return q.createElement("span",{dangerouslySetInnerHTML:{__html:i}})}if(c.html&&n&&!c.createDOM)return q.createElement(q.Fragment)}return e.prototype._originalDecorate.call(this,o,s)}}e.prototype.createDOM&&!e.prototype._createDOMOverridden&&(e.prototype._createDOMOverridden=!0,e.prototype.createDOM=function(n,o){let s=Rt(o,t,this);if(s){if(s.createDOM)return s.createDOM({config:n,editor:o,node:this});if(s.html){let c=typeof s.html=="function"?s.html({config:n,editor:o,isEditor:!0,isJSXConverter:!1,node:this}):s.html,i=document.createElement("div");return i.innerHTML=c,i.firstElementChild||i}}return e.prototype._originalCreateDOM.call(this,n,o)})}function bo({editorConfig:r,nodeViews:t}){let e=qe({nodes:r.features.nodes});if(t){let n=new Set;for(let[o,s]of Object.entries(t))!s||typeof s!="object"||(o==="blocks"&&Object.keys(s).length>0?n.add("block"):o==="inlineBlocks"&&Object.keys(s).length>0?n.add("inlineBlock"):n.add(o));for(let o of e)if("getType"in o){let s=o.getType();n.has(s)&&Ve({node:o,nodeType:s})}}return e}function qe({nodes:r}){return r.map(t=>"node"in t?t.node:t)}import{jsx as Qe}from"react/jsx-runtime";import{createContext as Je,use as Ze,useMemo as yt}from"react";var Ot=Je({currentView:"default",currentViewMap:void 0,setCurrentView:void 0,views:void 0}),Mo=({children:r,currentView:t="default",setCurrentView:e,views:n})=>{let o=yt(()=>{if(n)return n[t]||n.default},[n,t]),s=yt(()=>({currentView:t,currentViewMap:o,setCurrentView:e,views:n}),[t,e,o,n]);return Qe(Ot,{value:s,children:r})};function Ao(){let r=Ze(Ot);if(!r)throw new Error("useRichTextView must be used within a RichTextViewProvider");return r}import{$getRoot as an,$isDecoratorNode as It,$isElementNode as P,$isLineBreakNode as fn,$isTextNode as H}from"lexical";import{$isListItemNode as tn,$isListNode as bt}from"@lexical/list";import{$isHeadingNode as en,$isQuoteNode as nn}from"@lexical/rich-text";import{$isParagraphNode as on,$isTextNode as rn}from"lexical";var S={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},R={...S,requiresParagraphStart:!0},vo={...R,export:k(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},Po={...R,export:k(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},Ho={...R,export:k(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},Ko={...R,export:k(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},Uo={...R,export:k(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},Xo={...R,export:k(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},Go={...R,export:cn,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},zo={...R,export:Q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},Yo={...R,export:Q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},jo={...R,export:Q,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},Wo={...R,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},Vo={...R,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},qo={...S,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},Qo={...S,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},Jo={...S,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},Zo={...S,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},tr={...S,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},er={...S,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},nr={...S,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},or={...S,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},rr={...S,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},ir={...S,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},sr={...S,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},cr={...S,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function k(r){return(t,e)=>en(t)&&t.getTag()==="h"+r?"#".repeat(r)+" "+e(t):null}function Q(r,t){return bt(r)?kt(r,t,0):null}var sn=4;function kt(r,t,e){let n=[],o=r.getChildren(),s=0;for(let c of o)if(tn(c)){if(c.getChildrenSize()===1){let a=c.getFirstChild();if(bt(a)){n.push(kt(a,t,e+1));continue}}let i=" ".repeat(e*sn),l=r.getListType()==="bullet"?"- ":`${r.getStart()+s}. `;n.push(i+l+t(c)),s++}return n.join(`
2
+ `)}function cn(r,t){return nn(r)?"> "+t(r):null}function B(r,t){let e={};for(let n of r){let o=t(n);o&&(e[o]?e[o].push(n):e[o]=[n])}return e}function N(r){let t=B(r,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var F=/[!-/:-@[-`{-~\s]/,ln=/^\s{0,3}$/;function D(r){if(!on(r))return!1;let t=r.getFirstChild();return t==null||r.getChildrenSize()===1&&rn(t)&&ln.test(t.getTextContent())}function Mt(r,t=!1){let e=N(r),n=[...e.multilineElement,...e.element],o=!t,s=e.textFormat.filter(c=>c.format.length===1).sort((c,i)=>c.format.includes("code")&&!i.format.includes("code")?1:!c.format.includes("code")&&i.format.includes("code")?-1:0);return c=>{let i=[],l=(c||an()).getChildren();return l.forEach((a,u)=>{let p=un(a,n,s,e.textMatch);p!=null&&i.push(o&&u>0&&!D(a)&&!D(l[u-1])?`
3
+ `.concat(p):p)}),i.join(`
4
+ `)}}function un(r,t,e,n){for(let o of t){if(!o.export)continue;let s=o.export(r,c=>K(c,e,n));if(s!=null)return s}return P(r)?K(r,e,n):It(r)?r.getTextContent():null}function K(r,t,e,n,o){let s=[],c=r.getChildren();n||(n=[]),o||(o=[]);t:for(let i of c){for(let l of e){if(!l.export)continue;let a=l.export(i,u=>K(u,t,e,n,[...o,...n]),(u,p)=>Nt(u,p,t,n,o));if(a!=null){s.push(a);continue t}}fn(i)?s.push(`
5
+ `):H(i)?s.push(Nt(i,i.getTextContent(),t,n,o)):P(i)?s.push(K(i,t,e,n,o)):It(i)&&s.push(i.getTextContent())}return s.join("")}function Nt(r,t,e,n,o){let s=t.trim(),c=s;r.hasFormat("code")||(c=c.replace(/([*_`~\\])/g,"\\$1"));let i="",l="",a="",u=Ft(r,!0),p=Ft(r,!1),m=new Set;for(let g of e){let f=g.format[0],d=g.tag;v(r,f)&&!m.has(f)&&(m.add(f),(!v(u,f)||!n.find(h=>h.tag===d))&&(n.push({format:f,tag:d}),i+=d))}for(let g=0;g<n.length;g++){let f=n[g],d=v(r,f.format),h=v(p,f.format);if(d&&h)continue;let x=[...n];for(;x.length>g;){let E=x.pop();o&&E&&o.find(_=>_.tag===E.tag)||(E&&typeof E.tag=="string"&&(d?h||(a+=E.tag):l+=E.tag),n.pop())}break}return c=i+c+a,l+t.replace(s,()=>c)}function Ft(r,t){let e=t?r.getPreviousSibling():r.getNextSibling();if(!e){let n=r.getParentOrThrow();n.isInline()&&(e=t?n.getPreviousSibling():n.getNextSibling())}for(;e;){if(P(e)){if(!e.isInline())break;let n=t?e.getLastDescendant():e.getFirstDescendant();if(H(n))return n;e=t?e.getPreviousSibling():e.getNextSibling()}if(H(e))return e;if(!P(e))return null}return null}function v(r,t){return H(r)&&r.hasFormat(t)}import{$isListItemNode as mn,$isListNode as Bt}from"@lexical/list";import{$isQuoteNode as pn}from"@lexical/rich-text";import{$findMatchingParent as gn}from"@lexical/utils";import{$createLineBreakNode as hn,$createParagraphNode as xn,$createTextNode as En,$getRoot as _n,$getSelection as Tn,$isParagraphNode as wn}from"lexical";import{$isTextNode as I}from"lexical";function At(r,t){let e=r.getTextContent(),n=dn(e,t);if(!n)return null;let o=n.index||0,s=o+n[0].length,c=t.transformersByTag[n[1]];return{endIndex:s,match:n,startIndex:o,transformer:c}}function dn(r,t){let e=r.match(t.openTagsRegExp);if(e==null)return null;for(let n of e){let o=n.replace(/^\s/,""),s=t.fullMatchRegExpByTag[o];if(s==null)continue;let c=r.match(s),i=t.transformersByTag[o];if(c!=null&&i!=null){if(i.intraword!==!1)return c;let{index:l=0}=c,a=r[l-1],u=r[l+c[0].length];if((!a||F.test(a))&&(!u||F.test(u)))return c}}return null}function Dt(r,t,e,n,o){let s=r.getTextContent(),c,i,l;if(o[0]===s?l=r:t===0?[l,c]=r.splitText(e):[i,l,c]=r.splitText(t,e),l.setTextContent(o[2]),n)for(let a of n.format)l.hasFormat(a)||l.toggleFormat(a);return{nodeAfter:c,nodeBefore:i,transformedNode:l}}function Lt(r,t){let e=r,n,o,s,c;for(let i of t){if(!i.replace||!i.importRegExp)continue;let l=e.getTextContent().match(i.importRegExp);if(!l)continue;let a=l.index||0,u=i.getEndIndex?i.getEndIndex(e,l):a+l[0].length;u!==!1&&(n===void 0||o===void 0||a<n&&u>o)&&(n=a,o=u,s=i,c=l)}return n===void 0||o===void 0||s===void 0||c===void 0?null:{endIndex:o,match:c,startIndex:n,transformer:s}}function $t(r,t,e,n,o){let s,c,i;if(t===0?[i,s]=r.splitText(e):[c,i,s]=r.splitText(t,e),!n.replace)return null;let l=i?n.replace(i,o):void 0;return{nodeAfter:s,nodeBefore:c,transformedNode:l||void 0}}function y(r,t,e){let n=At(r,t),o=Lt(r,e);if(n&&o&&(n.startIndex<=o.startIndex&&n.endIndex>=o.endIndex?o=null:n=null),n){let i=Dt(r,n.startIndex,n.endIndex,n.transformer,n.match);i.nodeAfter&&I(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&y(i.nodeAfter,t,e),i.nodeBefore&&I(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&y(i.nodeBefore,t,e),i.transformedNode&&I(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&y(i.transformedNode,t,e)}else if(o){let i=$t(r,o.startIndex,o.endIndex,o.transformer,o.match);if(!i)return;i.nodeAfter&&I(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&y(i.nodeAfter,t,e),i.nodeBefore&&I(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&y(i.nodeBefore,t,e),i.transformedNode&&I(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&y(i.transformedNode,t,e)}let c=r.getTextContent().replace(/\\([*_`~])/g,"$1");r.setTextContent(c)}function vt(r,t=!1){let e=N(r),n=Rn(e.textFormat);return(o,s)=>{let c=o.split(`
6
+ `),i=c.length,l=s||_n();l.clear();for(let u=0;u<i;u++){let p=c[u],[m,g]=Sn(c,u,e.multilineElement,l);if(m){u=g;continue}Cn(p,l,e.element,n,e.textMatch)}let a=l.getChildren();for(let u of a)!t&&D(u)&&l.getChildrenSize()>1&&u.remove();Tn()!==null&&l.selectStart()}}function Sn(r,t,e,n){for(let o of e){let{handleImportAfterStartMatch:s,regExpEnd:c,regExpStart:i,replace:l}=o,a=r[t]?.match(i);if(!a)continue;if(s){let f=s({lines:r,rootNode:n,startLineIndex:t,startMatch:a,transformer:o});if(f===null)continue;if(f)return f}let u=typeof c=="object"&&"regExp"in c?c.regExp:c,p=c&&typeof c=="object"&&"optional"in c?c.optional:!c,m=t,g=r.length;for(;m<g;){let f=u?r[m]?.match(u):null;if(!f&&(!p||p&&m<g-1)){m++;continue}if(f&&t===m&&f.index===a.index){m++;continue}let d=[];if(f&&t===m)d.push(r[t].slice(a[0].length,-f[0].length));else for(let h=t;h<=m;h++){let x=r[h];if(h===t){let E=x.slice(a[0].length);d.push(E)}else if(h===m&&f){let E=x.slice(0,-f[0].length);d.push(E)}else d.push(x)}if(l(n,null,a,f,d,!0)!==!1)return[!0,m];break}}return[!1,t]}function Cn(r,t,e,n,o){let s=En(r),c=xn();c.append(s),t.append(c);for(let{regExp:i,replace:l}of e){let a=r.match(i);if(a&&(s.setTextContent(r.slice(a[0].length)),l(c,[s],a,!0)!==!1))break}if(y(s,n,o),c.isAttached()&&r.length>0){let i=c.getPreviousSibling();if(wn(i)||pn(i)||Bt(i)){let l=i;if(Bt(i)){let a=i.getLastDescendant();a==null?l=null:l=gn(a,mn)}l!=null&&l.getTextContentSize()>0&&(l.splice(l.getChildrenSize(),0,[hn(),...c.getChildren()]),c.remove())}}}function Rn(r){let t={},e={},n=[],o="(?<![\\\\])";for(let s of r){let{tag:c}=s;t[c]=s;let i=c.replace(/([*^+])/g,"\\$1");n.push(i),c.length===1?e[c]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):e[c]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:e,openTagsRegExp:new RegExp(`${o}(${n.join("|")})`,"g"),transformersByTag:t}}import{$createRangeSelection as yn,$getSelection as J,$isLineBreakNode as On,$isRangeSelection as Z,$isRootOrShadowRoot as Ht,$isTextNode as Kt,$setSelection as bn}from"lexical";function kn(r,t,e,n){let o=r.getParent();if(!Ht(o)||r.getFirstChild()!==t)return!1;let s=t.getTextContent();if(s[e-1]!==" ")return!1;for(let{regExp:c,replace:i}of n){let l=s.match(c);if(l&&l[0].length===(l[0].endsWith(" ")?e:e-1)){let a=t.getNextSiblings(),[u,p]=t.splitText(e);u?.remove();let m=p?[p,...a]:a;if(i(r,m,l,!1)!==!1)return!0}}return!1}function Nn(r,t,e,n){let o=r.getParent();if(!Ht(o)||r.getFirstChild()!==t)return!1;let s=t.getTextContent();if(s[e-1]!==" ")return!1;for(let{regExpEnd:c,regExpStart:i,replace:l}of n){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;let a=s.match(i);if(a&&a[0].length===(a[0].endsWith(" ")?e:e-1)){let u=t.getNextSiblings(),[p,m]=t.splitText(e);p?.remove();let g=m?[m,...u]:u;if(l(r,g,a,null,null,!1)!==!1)return!0}}return!1}function Fn(r,t,e){let n=r.getTextContent(),o=n[t-1],s=e[o];if(s==null)return!1;t<n.length&&(n=n.slice(0,t));for(let c of s){if(!c.replace||!c.regExp)continue;let i=n.match(c.regExp);if(i===null)continue;let l=i.index||0,a=l+i[0].length,u;return l===0?[u]=r.splitText(a):[,u]=r.splitText(l,a),u&&(u.selectNext(0,0),c.replace(u,i)),!0}return!1}function In(r,t,e){let n=r.getTextContent(),o=t-1,s=n[o],c=e[s];if(!c)return!1;for(let i of c){let{tag:l}=i,a=l.length,u=o-a+1;if(a>1&&!Ut(n,u,l,0,a)||n[u-1]===" ")continue;let p=n[o+1];if(i.intraword===!1&&p&&!F.test(p))continue;let m=r,g=m,f=Pt(n,u,l),d=g;for(;f<0&&(d=d.getPreviousSibling())&&!On(d);)if(Kt(d)){let C=d.getTextContent();g=d,f=Pt(C,C.length,l)}if(f<0||g===m&&f+a===u)continue;let h=g.getTextContent();if(f>0&&h[f-1]===s)continue;let x=h[f-1];if(i.intraword===!1&&x&&!F.test(x))continue;let E=m.getTextContent(),_=E.slice(0,u)+E.slice(o+1);m.setTextContent(_);let T=g===m?_:h;g.setTextContent(T.slice(0,f)+T.slice(f+a));let O=J(),w=yn();bn(w);let L=o-a*(g===m?2:1)+1;w.anchor.set(g.__key,f,"text"),w.focus.set(m.__key,L,"text");for(let C of i.format)w.hasFormat(C)||w.formatText(C);w.anchor.set(w.focus.key,w.focus.offset,w.focus.type);for(let C of i.format)w.hasFormat(C)&&w.toggleFormat(C);return Z(O)&&(w.format=O.format),!0}return!1}function Pt(r,t,e){let n=e.length;for(let o=t;o>=n;o--){let s=o-n;if(Ut(r,s,e,0,n)&&r[s+n]!==" ")return s}return-1}function Ut(r,t,e,n,o){for(let s=0;s<o;s++)if(r[t+s]!==e[n+s])return!1;return!0}function Nr(r,t=U){let e=N(t),n=B(e.textFormat,({tag:c})=>c[c.length-1]),o=B(e.textMatch,({trigger:c})=>c);for(let c of t){let i=c.type;if(i==="element"||i==="text-match"||i==="multiline-element"){let l=c.dependencies;for(let a of l)if(!r.hasNode(a))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+a.getType())}}let s=(c,i,l)=>{kn(c,i,l,e.element)||Nn(c,i,l,e.multilineElement)||Fn(i,l,o)||In(i,l,n)};return r.registerUpdateListener(({dirtyLeaves:c,editorState:i,prevEditorState:l,tags:a})=>{if(a.has("collaboration")||a.has("historic")||r.isComposing())return;let u=i.read(J),p=l.read(J);if(!Z(p)||!Z(u)||!u.isCollapsed()||u.is(p))return;let m=u.anchor.key,g=u.anchor.offset,f=i._nodeMap.get(m);!Kt(f)||!c.has(m)||g!==1&&g>p.anchor.offset+1||r.update(()=>{if(f.hasFormat("code"))return;let d=f.getParent();d!==null&&s(d,f,u.anchor.offset)})})}import{$createListItemNode as Mn,$createListNode as An,$isListItemNode as Dn,$isListNode as M,ListItemNode as et,ListNode as nt}from"@lexical/list";import{$createHeadingNode as Ln,$createQuoteNode as $n,$isHeadingNode as Bn,$isQuoteNode as Xt,HeadingNode as vn,QuoteNode as Pn}from"@lexical/rich-text";import{$createLineBreakNode as Hn}from"lexical";var Gt=/^[\t ]*$/,Wt=/^(\s*)(\d+)\.\s/,Vt=/^(\s*)[-*+]\s/,qt=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,tt=/^(#{1,6})\s/,Qt=/^>\s/,Kn=/^[ \t]*(\\`\\`\\`|```)(\w+)?/,zt=/[ \t]*(\\`\\`\\`|```)$/,Un=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,Xn=/^\|(.+)\|\s?$/,Gn=/^(\| ?:?-*:? ?)+\|\s?$/,Yt=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,jt=/^[ \t]*<\/[a-z_][\w-]*\s*>/i,zn=r=>(t,e,n)=>{let o=r(n);o.append(...e),t.replace(o),o.select(0,0)},Jt=4;function Yn(r){let t=r.match(/\t/g),e=r.match(/ /g),n=0;return t&&(n+=t.length),e&&(n+=Math.floor(e.length/Jt)),n}var ot=r=>(t,e,n)=>{let o=t.getPreviousSibling(),s=t.getNextSibling(),c=Mn(r==="check"?n[3]==="x":void 0);if(M(s)&&s.getListType()===r){let l=s.getFirstChild();l!==null?l.insertBefore(c):s.append(c),t.remove()}else if(M(o)&&o.getListType()===r)o.append(c),t.remove();else{let l=An(r,r==="number"?Number(n[2]):void 0);l.append(c),t.replace(l)}c.append(...e),c.select(0,0);let i=Yn(n[1]);i&&c.setIndent(i)},X=(r,t,e)=>{let n=[],o=r.getChildren(),s=0;for(let c of o)if(Dn(c)){if(c.getChildrenSize()===1){let u=c.getFirstChild();if(M(u)){n.push(X(u,t,e+1));continue}}let i=" ".repeat(e*Jt),l=r.getListType(),a=l==="number"?`${r.getStart()+s}. `:l==="check"?`- [${c.getChecked()?"x":" "}] `:"- ";n.push(i+a+t(c)),s++}return n.join(`
7
+ `)},Zt={type:"element",dependencies:[vn],export:(r,t)=>{if(!Bn(r))return null;let e=Number(r.getTag().slice(1));return"#".repeat(e)+" "+t(r)},regExp:tt,replace:zn(r=>{let t="h"+r[1].length;return Ln(t)})},te={type:"element",dependencies:[Pn],export:(r,t)=>{if(!Xt(r))return null;let e=t(r).split(`
8
+ `),n=[];for(let o of e)n.push("> "+o);return n.join(`
9
+ `)},regExp:Qt,replace:(r,t,e,n)=>{if(n){let s=r.getPreviousSibling();if(Xt(s)){s.splice(s.getChildrenSize(),0,[Hn(),...t]),s.select(0,0),r.remove();return}}let o=$n();o.append(...t),r.replace(o),o.select(0,0)}},ee={type:"element",dependencies:[nt,et],export:(r,t)=>M(r)?X(r,t,0):null,regExp:Vt,replace:ot("bullet")},jn={type:"element",dependencies:[nt,et],export:(r,t)=>M(r)?X(r,t,0):null,regExp:qt,replace:ot("check")},ne={type:"element",dependencies:[nt,et],export:(r,t)=>M(r)?X(r,t,0):null,regExp:Wt,replace:ot("number")},oe={type:"text-format",format:["code"],tag:"`"},re={type:"text-format",format:["highlight"],tag:"=="},ie={type:"text-format",format:["bold","italic"],tag:"***"},se={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},ce={type:"text-format",format:["bold"],tag:"**"},le={type:"text-format",format:["bold"],intraword:!1,tag:"__"},ae={type:"text-format",format:["strikethrough"],tag:"~~"},fe={type:"text-format",format:["italic"],tag:"*"},ue={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function de(r,t){let e=r.split(`
10
+ `),n=!1,o=[],s=0;for(let c=0;c<e.length;c++){let i=e[c],l=o[o.length-1];if(Un.test(i)){o.push(i);continue}if(zt.test(i)){s===0&&(n=!0),s===1&&(n=!1),s>0&&s--,o.push(i);continue}if(Kn.test(i)){n=!0,s++,o.push(i);continue}if(n){o.push(i);continue}Gt.test(i)||Gt.test(l)||!l||tt.test(l)||tt.test(i)||Qt.test(i)||Wt.test(i)||Vt.test(i)||qt.test(i)||Xn.test(i)||Gn.test(i)||!t||Yt.test(i)||jt.test(i)||Yt.test(l)||jt.test(l)||zt.test(l)?o.push(i):o[o.length-1]=l+" "+i.trim()}return o.join(`
11
+ `)}var Wn=[Zt,te,ee,ne],Vn=[],qn=[oe,ie,se,ce,le,re,fe,ue,ae],Qn=[],U=[...Wn,...Vn,...qn,...Qn];function vr(r,t=U,e,n=!1,o=!0){let s=n?r:de(r,o);return vt(t,n)(s,e)}function Pr(r=U,t,e=!1){return Mt(r,e)(t)}export{Nr as a,vr as b,Pr as c,st as d,no as e,Mo as f,Ao as g,z as h,ct as i,_o as j,We as k,To as l,Ct as m,yo as n,Oo as o,bo as p};
12
+ //# sourceMappingURL=chunk-UDMS2AKL.js.map