wysimark-lite 0.27.2 → 0.27.3

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/index.js CHANGED
@@ -1,43 +1,43 @@
1
- "use client";import{createRef as hx,useCallback as gx,useImperativeHandle as bx,useRef as Ex,useState as xx}from"react";import{createRoot as kx}from"react-dom/client";import mx from"lodash.throttle";import{useCallback as eo,useRef as to,useState as Fd}from"react";import{Editor as cx,Transforms as px}from"slate";import{ReactEditor as dx,Slate as ux}from"slate-react";import xu from"remark-parse";import{unified as ku}from"unified";import{gfm as Kd}from"micromark-extension-gfm";import{gfmFromMarkdown as Gd,gfmToMarkdown as qd}from"mdast-util-gfm";function In(e){if(e)return function(t){return this.data||(this.data={}),e.call(this,t)}}function Qd(e){if(e.enter)for(let t of Object.keys(e.enter))e.enter[t]=In(e.enter[t]);if(e.exit)for(let t of Object.keys(e.exit))e.exit[t]=In(e.exit[t]);return e}function Mn(){return function(){if(!this)return;let e=this.data(),t=e.micromarkExtensions||(e.micromarkExtensions=[]),o=e.fromMarkdownExtensions||(e.fromMarkdownExtensions=[]),r=e.toMarkdownExtensions||(e.toMarkdownExtensions=[]);t.push(Kd());let n=Gd().map(Qd);o.push(...n),r.push(qd())}}var or="wysimark:wiki-link:",rr="wysimark:wiki-embed:",Cn="\uE000WYSIMARK_ESCAPED_WIKI_OPEN\uE000",Pn="\uE000WYSIMARK_ESCAPED_WIKI_CLOSE\uE000";function Sn(e){return e.replace(/\\\[\[/g,Cn).replace(/\\\]/g,Pn)}function Oe(e){return e.replace(new RegExp(Cn,"g"),"[[").replace(new RegExp(Pn,"g"),"]")}function Ze(e){return`${or}${encodeURIComponent(e)}`}function ro(e){return`${rr}${encodeURIComponent(e)}`}function ue(e){return e.startsWith(or)}function et(e){return e.startsWith(rr)}function $t(e){return decodeURIComponent(e.slice(or.length))}function Dt(e){return decodeURIComponent(e.slice(rr.length))}function tt(e){let t=e.lastIndexOf("|");return t<0?{target:e.trim()}:{target:e.slice(0,t).trim(),display:e.slice(t+1).trim()}}function Ln(e){return tt(e).target}function no(e){let t=e.trim(),o=t.match(/^!?\[\[([\s\S]+)\]\]$/);return tt(o?o[1]:t)}function ke(e){let{target:t,display:o}=tt(e);if(o)return o;if(t.startsWith("##"))return t.slice(2).trim()||"Headings";if(t.startsWith("^^"))return t.slice(2).trim()||"Blocks";let r=t.indexOf("#");if(r<0)return t;let n=t.slice(0,r).trim(),i=t.slice(r+1).split("#").map(a=>a.trim()).filter(Boolean);return n?i.length===0?n:[n,...i].join(" > "):i.join(" > ")}function Rn(e,t){let o=$t(e),{target:r,display:n}=tt(o),i=t.trim();if(n&&i===n)return`[[${r}|${n}]]`;let a=ke(r);return i&&i!==a?`[[${r}|${i}]]`:`[[${r}]]`}function Bn(e){return`![[${Dt(e)}]]`}function Ce(e){let t=/\[([^\]]+)\]\(([^)]+)\)/g,o="\x07WYSIMARK_",r=`${o}LINK_`,n=`${o}HTML_`,i="\x07",a=[],l=0,s=e.replace(t,p=>(a.push(p),`${r}${l++}${i}`)),m=[];s=Xd(s,m,n,i);let d=/(https?:\/\/[^\s]+)/g;s=s.replace(d,p=>p.replace(/\//g,"\\/"));for(let p=0;p<m.length;p++)s=s.replace(`${n}${p}${i}`,m[p]);for(let p=0;p<a.length;p++)s=s.replace(`${r}${p}${i}`,a[p]);return s}function zt(e){return e.replace(/\\\//g,"/")}function io(e){return e.replace(/\\([\\`*_\[\]~|<])/g,"$1")}var jd=new Set(["script","style"]);function Xd(e,t,o,r){let n="",i=0;for(;i<e.length;){let a=e.indexOf("<",i);if(a===-1){n+=e.slice(i);break}if(n+=e.slice(i,a),e.startsWith("<!--",a)){let u=e.indexOf("-->",a+4);if(u===-1){n+=e.slice(a);break}let g=e.slice(a,u+3);t.push(g),n+=`${o}${t.length-1}${r}`,i=u+3;continue}if(e.startsWith("<![CDATA[",a)){let u=e.indexOf("]]>",a+9);if(u===-1){n+=e.slice(a);break}let g=e.slice(a,u+3);t.push(g),n+=`${o}${t.length-1}${r}`,i=u+3;continue}let l=nr(e,a);if(!l){n+="<",i=a+1;continue}let s=t.length,m=`${o}${s}${r}`;if(!l.name){let u=e.slice(a,l.endIndex+1);t.push(u),n+=m,i=l.endIndex+1;continue}let c=l.name.toLowerCase();if(l.isClosing||l.isSelfClosing){let u=e.slice(a,l.endIndex+1);t.push(u),n+=m,i=l.endIndex+1;continue}if(jd.has(c)){let u=e.toLowerCase().indexOf(`</${c}`,l.endIndex+1);if(u!==-1){let g=nr(e,u);if(g){let x=e.slice(a,g.endIndex+1);t.push(x),n+=m,i=g.endIndex+1;continue}}}let d=Jd(e,c,l.endIndex+1);if(d!==null){let u=e.slice(a,d+1);t.push(u),n+=m,i=d+1;continue}let p=e.slice(a,l.endIndex+1);t.push(p),n+=m,i=l.endIndex+1}return n}function nr(e,t){if(e[t]!=="<")return null;let o=Yd(e,t);if(o===-1)return null;let r=t+1;if(r>=e.length)return null;let n=e[r];if(n==="!"||n==="?")return{name:null,endIndex:o,isClosing:!1,isSelfClosing:!0};let i=!1;n==="/"&&(i=!0,r+=1);let a=/^[A-Za-z][A-Za-z0-9-]*/.exec(e.slice(r));if(!a)return null;let l=a[0],s=e.slice(t,o+1),m=/\/\s*>$/.test(s);return{name:l,endIndex:o,isClosing:i,isSelfClosing:m}}function Yd(e,t){let o=null;for(let r=t+1;r<e.length;r++){let n=e[r];if(o){n===o&&(o=null);continue}if(n==="'"||n==='"'){o=n;continue}if(n===">")return r}return-1}function Jd(e,t,o){let r=1,n=o,i=t.toLowerCase();for(;n<e.length;){let a=e.indexOf("<",n);if(a===-1)return null;let l=nr(e,a);if(!l||!l.name){n=a+1;continue}if(l.name.toLowerCase()===i&&(l.isClosing?r-=1:l.isSelfClosing||(r+=1),r===0))return l.endIndex;n=l.endIndex+1}return null}function $n(e,t){if(!e)throw new Error(`${t}`)}function ao(e,t){if(e.type!==t)throw new Error(`Expected element to be of type ${JSON.stringify(e)} but is ${JSON.stringify(e,null,2)}`)}function Pe(e){throw new Error(`Didn't expect to get here with value ${JSON.stringify(e,null,2)}`)}function Zd(e){let t=e[0];if(!t||t.type!=="paragraph")return e;let o=t.children[0];if(!o||!("text"in o))return e;let r=o.text.match(/^(\[![A-Za-z0-9_-]+\][+-]?(?:[^\n]*))(?:\n([\s\S]*))?$/);if(!r)return e;let n=r[1],i=r[2],a={type:"paragraph",children:[{...o,text:n}]};if(!i)return[a,...e.slice(1)];let l={...t,children:[{...o,text:i},...t.children.slice(1)]};return[a,l,...e.slice(1)]}function Dn(e,t={}){return[{type:"block-quote",children:Zd(ot(e.children,t))}]}function zn(e){let t=e.value.split(`
2
- `);return[{type:"code-block",language:e.lang||"text",children:t.map(o=>({type:"code-block-line",children:[{text:o}]}))}]}function Nn(e,t={}){return[{type:"block-quote",children:[{type:"paragraph",children:[{text:`[${e.identifier}]`}]},...ot(e.children,t)]}]}import{Text as qn}from"slate";import{Text as Kn}from"slate";import*as Nt from"slate";function q(e){return Nt.Text.isText(e)}function ce(e){return Nt.Element.isElement(e)}function A(e){return Nt.Text.isText(e)&&!!e.text.match(/^\s+$/)&&!e.code}var Hn={bold:"**",italic:"_",strike:"~~",highlight:"<mark>",code:""},An={bold:"**",italic:"_",strike:"~~",highlight:"</mark>",code:""};function eu(e){if(e in Hn)return Hn[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_OPEN_TOKEN lookup`)}function tu(e){if(e in An)return An[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_CLOSE_TOKEN lookup`)}function On(e){return e.map(eu).join("")}function Un(e){return e.map(tu).join("")}import{Text as ou}from"slate";function Ht(e){let{text:t,...o}=e;return Object.keys(o)}function ir(e){if(ou.isText(e)){if(A(e))throw new Error("You probably didn't mean to do this. We should only be getting marks from segments that are not plain space segments.");return Ht(e)}else{if(e.type==="anchor")return lo(e.children);throw new Error(`Unhandled type ${e.type}`)}}function lo(e){let t;for(let o of e){if(!q(o)){if(o.type==="image-inline")continue;throw new Error("Expected every segment in an anchor to be a Text segment")}if(A(o))continue;let r=Ht(o);if(t===void 0){t=r;continue}t=t.filter(n=>r.includes(n))}return t===void 0?[]:t}var Fn=["bold","italic","underline","strike","highlight","code"];function Wn(e){return e.slice().sort((t,o)=>Fn.indexOf(t)-Fn.indexOf(o))}function ru(e){return/[!-/:-@\[-`{-~]/.test(e)}function nt(e){return e===""||/\s/u.test(e)}function rt(e){return e!==""&&/[\p{P}\p{S}]/u.test(e)}function nu(e){return/[a-zA-Z/?!]/.test(e)}function Vn(e,t,o){let r=new Set,n=[];for(let i=0;i<e.length;i++){if(e[i]!==t)continue;let a=i>0?e[i-1]:"",l=i+1<e.length?e[i+1]:"",s=!nt(l)&&(!rt(l)||nt(a)||rt(a)),m=!nt(a)&&(!rt(a)||nt(l)||rt(l)),c=s&&(o||!m||rt(a));m&&(o||!s||rt(l))&&n.length>0&&(r.add(n.pop()),r.add(i)),c&&n.push(i)}return r}function iu(e){let t=new Set,o=[];for(let r=0;r<e.length;r++){if(e[r]!=="~")continue;let n=r>0?e[r-1]:"",i=r+1<e.length?e[r+1]:"",a=!nt(i);!nt(n)&&o.length>0&&(t.add(o.pop()),t.add(r)),a&&o.push(r)}return t}function au(e,t=!1){let o=new Set,r=[];for(let n=0;n<e.length;n++)if(e[n]==="[")t&&e[n+1]==="["&&o.add(n),e[n+1]==="^"&&o.add(n),r.push(n);else if(e[n]==="]"){let i=r.pop();i!==void 0&&e[n+1]==="("&&(o.add(i),o.add(n))}return o}function _n(e,t={}){let o=Array.from(e),r=Vn(o,"_",!1),n=Vn(o,"*",!0),i=iu(o),a=au(o,t.enableInternalLinks),l=t.escapeBackticks??o.filter(m=>m==="`").length>=2,s="";for(let m=0;m<o.length;m++){let c=o[m],d=m+1<o.length?o[m+1]:"";c==="`"?s+=l?"\\`":c:c==="\\"?s+=ru(d)?"\\\\":"\\":c==="<"?s+=nu(d)?"\\<":"<":c==="_"?s+=r.has(m)?`\\${c}`:c:c==="*"?s+=n.has(m)?`\\${c}`:c:c==="~"?s+=i.has(m)?`\\${c}`:c:c==="["||c==="]"?s+=t.inAnchorLabel||a.has(m)?`\\${c}`:c:s+=c}return s=s.replace(/^(#{1,6})(\s)/m,"\\$1$2"),s=s.replace(/^(\d+)([.)]\s)/m,"$1\\$2"),s=s.replace(/^([-+*>])\s/m,"\\$1 "),s}function lu(e,t){let o=Ht(e),r=Ht(t);return o.length==r.length&&o.every(n=>r.includes(n))}function Gn(e,t){let o=Kn.isText(e),r=Kn.isText(t);return t&&!r&&!o?[{text:""},e]:o?t===void 0||!r?[e]:lu(t,e)?(t.text=[t.text,e.text].join(""),[]):[e]:[e]}function Qn(e){let t=[];for(let o=0;o<e.length;o++){let r=t[t.length-1];t.push(...Gn(e[o],r))}return t.length===0&&t.push({text:""}),qn.isText(t[0])||t.unshift({text:""}),qn.isText(t[t.length-1])||t.push({text:""}),t}function jn(e){return{url:e.url,title:e.title||void 0,alt:e.alt||void 0}}var su=/^([^?#]*)(?:\?([^#]*))?(#.*)?$/;function it(e){try{let t=new URL(e);return{origin:t.origin,hostname:t.hostname,pathname:t.pathname,searchParams:t.searchParams,hash:t.hash}}catch{let t=e.match(su);if(t===null)throw new Error(`Invalid format should not happen: ${e}`);let[,o,r,n]=[...t];return{origin:"",hostname:"",pathname:o||"",searchParams:new URLSearchParams(r),hash:n||""}}}function At(e){if(typeof e!="string")return null;let t=e.match(/^(\d+)x(\d+)$/);return t===null?null:{width:parseInt(t[1],10),height:parseInt(t[2],10)}}function Xn(e){let t=it(e.url);if(!t.hostname.match(/[.]portive[.]com$/i))return;let o=t.searchParams.get("size");if(o===null)return;let r=At(o);if(r===null)return;let n=t.pathname.match(/[-][-](\d+)x(\d+)[.][a-zA-Z]+$/);if(n!==null)return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:parseInt(n[1],10),srcHeight:parseInt(n[2],10)}}function Yn(e){let t=it(e.url);if(t.hash.length===0)return;let o=new URLSearchParams(t.hash.slice(1)),r=At(o.get("size")),n=At(o.get("srcSize"));if(!(!r||!n))return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:n.width,srcHeight:n.height}}var Jn=[Xn,Yn,jn];function Zn(e){for(let t of Jn){let o=t(e);if(o)return[{type:"image-inline",...o,children:[{text:""}]}]}throw new Error("Shouldn't get here because last parser always returns data")}function mu(e,t){if(/^<br\s*\/?>$/i.test(e))return[{text:`
3
- `,...t}];let o=e.match(/^<mark\b[^>]*>(.+?)<\/mark>$/is);return o?[{text:o[1],...t,highlight:!0}]:[{text:e,code:!0}]}function cu(e,t){let o=[],r=/(!)?\[\[((?:\\.|[^\]\\\n])+?)\]\]/g,n=0,i;for(;(i=r.exec(e))!==null;){let a=i.index;if(a>0&&e[a-1]==="\\")continue;a>n&&o.push({text:Oe(e.slice(n,a)),...t});let l=io(Oe(i[2])).trim();i[1]?o.push({type:"image-inline",url:ro(l),alt:l,children:[{text:""}]}):o.push({type:"anchor",href:Ze(l),children:[{text:ke(l),...t}]}),n=a+i[0].length}return n===0?[{text:Oe(e),...t}]:(n<e.length&&o.push({text:Oe(e.slice(n)),...t}),o)}function Y(e,t={},o={}){let r=[],n={...t};for(let a of e){if(a.type==="html"){if(/^<mark\b[^>]*>$/i.test(a.value)){n={...n,highlight:!0};continue}if(/^<\/mark>$/i.test(a.value)){let{highlight:l,...s}=n;n=s;continue}}r.push(...pu(a,n,o))}return Qn(r)}function pu(e,t={},o={}){switch(e.type){case"delete":return Y(e.children,{...t,strike:!0},o);case"emphasis":return Y(e.children,{...t,italic:!0},o);case"footnoteReference":return[{text:`[${e.identifier}]`}];case"html":return mu(e.value,t);case"image":return Zn(e);case"inlineCode":return[{text:Oe(e.value),...t,code:!0}];case"link":return[{type:"anchor",href:e.url,title:e.title==null?void 0:e.title,children:Y(e.children,t,o)}];case"strong":return Y(e.children,{...t,bold:!0},o);case"text":return o.enableInternalLinks?cu(e.value,t):[{text:Oe(e.value),...t}];case"linkReference":case"imageReference":throw new Error("linkReference and imageReference should be converted to link and image through our transformInlineLinks function");case"break":return[{text:`
4
- `}];case"footnote":throw new Error("footnote is not supported yet")}Pe(e)}function ei(e,t={}){return[{type:"heading",level:e.depth,children:Y(e.children,{},t)}]}function ti(e){return[{type:"html-block",html:e.value,children:[{text:""}]}]}function oi(e,{depth:t,ordered:o,checked:r},n={}){switch(e.type){case"paragraph":return r===!0||r===!1?[{type:"task-list-item",depth:t,checked:r,children:Y(e.children,{},n)}]:o?[{type:"ordered-list-item",depth:t,children:Y(e.children,{},n)}]:[{type:"unordered-list-item",depth:t,children:Y(e.children,{},n)}];case"list":return so(e,t+1,n);default:return ar(e,n)}}function ri(e,t,o={}){let r=[];for(let n of e.children)r.push(...oi(n,{...t,checked:e.checked},o));return r}function so(e,t=0,o={}){let r=[];for(let n of e.children)r.push(...ri(n,{depth:t,ordered:!!e.ordered},o));return r}function du(e){return!(e.length!==3||!("text"in e[0])||e[0].text!==""||!("text"in e[2])||e[2].text!==""||!("type"in e[1])||e[1].type!=="image-inline")}var uu="\xA0";function fu(e){return!(e.length!==1||!("text"in e[0])||e[0].text!==uu)}function ni(e,t={}){let o=Y(e.children,{},t);return du(o)?[{...o[1],type:"image-block"}]:fu(o)?[{type:"paragraph",children:[{text:""}]}]:[{type:"paragraph",children:o}]}function ii(e,t={}){if(e.align==null)throw new Error("Expected an array of AlignType for table.align");return[{type:"table",columns:e.align.map(o=>({align:o||"left"})),children:e.children.map(o=>hu(o,t))}]}function hu(e,t){if(e.type!=="tableRow")throw new Error("Expected a tableRow");return{type:"table-row",children:e.children.map(o=>gu(o,t))}}function gu(e,t){if(e.type!=="tableCell")throw new Error("Expected a tableCell");return{type:"table-cell",children:[{type:"table-content",children:Y(e.children,{},t)}]}}function ai(){return[{type:"horizontal-rule",children:[{text:""}]}]}function ot(e,t={}){let o=[];for(let r=0;r<e.length;r++){if(r>0){let n=e[r-1],i=e[r];if(n.position&&i.position){let a=i.position.start.line-n.position.end.line-1;for(let l=1;l<a;l++)o.push({type:"paragraph",children:[{text:""}]})}}o.push(...ar(e[r],t))}return o}function ar(e,t={}){switch(e.type){case"blockquote":return Dn(e,t);case"code":return zn(e);case"definition":throw new Error('The type "definition" should not exist. See comments');case"footnoteDefinition":return Nn(e,t);case"heading":return ei(e,t);case"html":return ti(e);case"list":return so(e,0,t);case"paragraph":return ni(e,t);case"table":return ii(e,t);case"thematicBreak":return ai();case"yaml":return[]}Pe(e)}import{definitions as bu}from"mdast-util-definitions";import{SKIP as li,visit as Eu}from"unist-util-visit";function si(e){let t=bu(e);Eu(e,(o,r,n)=>{let i=o,a=n;if(i.type==="definition"&&a!==null&&typeof r=="number")return a.children.splice(r,1),[li,r];if(i.type==="imageReference"||i.type==="linkReference"){let l="identifier"in i&&typeof i.identifier=="string"?i.identifier:"",s=t(l);if(s&&a!==null&&typeof r=="number"){let m=i.type==="imageReference"?{type:"image",url:s.url,title:s.title,alt:i.alt}:{type:"link",url:s.url,title:s.title,children:i.children};return a.children[r]=m,[li,r]}}})}var yu=ku().use(xu).use(Mn());function vu(e,t={}){let o=yu.parse(t.enableInternalLinks?Sn(e):e);return si(o),o}function Se(e,t={}){let o=vu(e,t);return o.children.length===0?[{type:"paragraph",children:[{text:""}]}]:ot(o.children,t)}function Tu(e){return e.type==="ordered-list-item"||e.type==="unordered-list-item"||e.type==="task-list-item"}function mi(e){let t=[],o=-1;for(let r of e){if(!Tu(r)){t.push(r),o=-1;continue}let n=r.depth>o+1?o+1:r.depth;t.push({...r,depth:n}),o=n}return t}function ci(e){if(e.type!=="code-block-line")throw new Error(`Expected all children of code-block to be a codeline but is ${JSON.stringify(e,null,2)}`);return e.children.map(t=>t.text).join("")}function pi(e){let t=[],o=3;for(let r of e.children){let n=ci(r),i=n.match(/^([`]+)/);i&&(o=Math.max(o,i[1].length+1)),t.push(n)}return t.unshift(`${"`".repeat(o)}${e.language}`),t.push(`${"`".repeat(o)}`),`${t.join(`
1
+ "use client";import{createRef as Bx,useCallback as $x,useImperativeHandle as Dx,useRef as zx,useState as Nx}from"react";import{createRoot as Hx}from"react-dom/client";import Mx from"lodash.throttle";import{useCallback as Zt,useRef as eo,useState as Yd}from"react";import{Editor as Cx,Transforms as Px}from"slate";import{ReactEditor as Sx,Slate as Lx}from"slate-react";import Lu from"remark-parse";import{unified as Ru}from"unified";import{gfm as ou}from"micromark-extension-gfm";import{gfmFromMarkdown as ru,gfmToMarkdown as nu}from"mdast-util-gfm";function Dn(e){if(e)return function(t){return this.data||(this.data={}),e.call(this,t)}}function iu(e){if(e.enter)for(let t of Object.keys(e.enter))e.enter[t]=Dn(e.enter[t]);if(e.exit)for(let t of Object.keys(e.exit))e.exit[t]=Dn(e.exit[t]);return e}function zn(){return function(){if(!this)return;let e=this.data(),t=e.micromarkExtensions||(e.micromarkExtensions=[]),o=e.fromMarkdownExtensions||(e.fromMarkdownExtensions=[]),r=e.toMarkdownExtensions||(e.toMarkdownExtensions=[]);t.push(ou());let n=ru().map(iu);o.push(...n),r.push(nu())}}var mr="wysimark:wiki-link:",cr="wysimark:wiki-embed:",Nn="\uE000WYSIMARK_ESCAPED_WIKI_OPEN\uE000",Hn="\uE000WYSIMARK_ESCAPED_WIKI_CLOSE\uE000";function An(e){return e.replace(/\\\[\[/g,Nn).replace(/\\\]/g,Hn)}function Oe(e){return e.replace(new RegExp(Nn,"g"),"[[").replace(new RegExp(Hn,"g"),"]")}function Ce(e){return`${mr}${encodeURIComponent(e)}`}function no(e){return`${cr}${encodeURIComponent(e)}`}function ue(e){return e.startsWith(mr)}function Ze(e){return e.startsWith(cr)}function $t(e){return decodeURIComponent(e.slice(mr.length))}function pr(e){return decodeURIComponent(e.slice(cr.length))}function et(e){let t=e.lastIndexOf("|");return t<0?{target:e.trim()}:{target:e.slice(0,t).trim(),display:e.slice(t+1).trim()}}function On(e){return et(e).target}function io(e){let t=e.trim(),o=t.match(/^!?\[\[([\s\S]+)\]\]$/);return et(o?o[1]:t)}function se(e){let{target:t,display:o}=et(e);if(o)return o;if(t.startsWith("##"))return t.slice(2).trim()||"Headings";if(t.startsWith("^^"))return t.slice(2).trim()||"Blocks";let r=t.indexOf("#");if(r<0)return t;let n=t.slice(0,r).trim(),i=t.slice(r+1).split("#").map(a=>a.trim()).filter(Boolean);return n?i.length===0?n:[n,...i].join(" > "):i.join(" > ")}function Un(e,t){let o=$t(e),{target:r,display:n}=et(o),i=t.trim();if(n&&i===n)return`[[${r}|${n}]]`;let a=se(r);return i&&i!==a?`[[${r}|${i}]]`:`[[${r}]]`}function Fn(e){return`![[${pr(e)}]]`}function Pe(e){let t=/\[([^\]]+)\]\(([^)]+)\)/g,o="\x07WYSIMARK_",r=`${o}LINK_`,n=`${o}HTML_`,i="\x07",a=[],l=0,s=e.replace(t,p=>(a.push(p),`${r}${l++}${i}`)),m=[];s=lu(s,m,n,i);let d=/(https?:\/\/[^\s]+)/g;s=s.replace(d,p=>p.replace(/\//g,"\\/"));for(let p=0;p<m.length;p++)s=s.replace(`${n}${p}${i}`,m[p]);for(let p=0;p<a.length;p++)s=s.replace(`${r}${p}${i}`,a[p]);return s}function Dt(e){return e.replace(/\\\//g,"/")}function ao(e){return e.replace(/\\([\\`*_\[\]~|<])/g,"$1")}var au=new Set(["script","style"]);function lu(e,t,o,r){let n="",i=0;for(;i<e.length;){let a=e.indexOf("<",i);if(a===-1){n+=e.slice(i);break}if(n+=e.slice(i,a),e.startsWith("<!--",a)){let u=e.indexOf("-->",a+4);if(u===-1){n+=e.slice(a);break}let g=e.slice(a,u+3);t.push(g),n+=`${o}${t.length-1}${r}`,i=u+3;continue}if(e.startsWith("<![CDATA[",a)){let u=e.indexOf("]]>",a+9);if(u===-1){n+=e.slice(a);break}let g=e.slice(a,u+3);t.push(g),n+=`${o}${t.length-1}${r}`,i=u+3;continue}let l=dr(e,a);if(!l){n+="<",i=a+1;continue}let s=t.length,m=`${o}${s}${r}`;if(!l.name){let u=e.slice(a,l.endIndex+1);t.push(u),n+=m,i=l.endIndex+1;continue}let c=l.name.toLowerCase();if(l.isClosing||l.isSelfClosing){let u=e.slice(a,l.endIndex+1);t.push(u),n+=m,i=l.endIndex+1;continue}if(au.has(c)){let u=e.toLowerCase().indexOf(`</${c}`,l.endIndex+1);if(u!==-1){let g=dr(e,u);if(g){let x=e.slice(a,g.endIndex+1);t.push(x),n+=m,i=g.endIndex+1;continue}}}let d=mu(e,c,l.endIndex+1);if(d!==null){let u=e.slice(a,d+1);t.push(u),n+=m,i=d+1;continue}let p=e.slice(a,l.endIndex+1);t.push(p),n+=m,i=l.endIndex+1}return n}function dr(e,t){if(e[t]!=="<")return null;let o=su(e,t);if(o===-1)return null;let r=t+1;if(r>=e.length)return null;let n=e[r];if(n==="!"||n==="?")return{name:null,endIndex:o,isClosing:!1,isSelfClosing:!0};let i=!1;n==="/"&&(i=!0,r+=1);let a=/^[A-Za-z][A-Za-z0-9-]*/.exec(e.slice(r));if(!a)return null;let l=a[0],s=e.slice(t,o+1),m=/\/\s*>$/.test(s);return{name:l,endIndex:o,isClosing:i,isSelfClosing:m}}function su(e,t){let o=null;for(let r=t+1;r<e.length;r++){let n=e[r];if(o){n===o&&(o=null);continue}if(n==="'"||n==='"'){o=n;continue}if(n===">")return r}return-1}function mu(e,t,o){let r=1,n=o,i=t.toLowerCase();for(;n<e.length;){let a=e.indexOf("<",n);if(a===-1)return null;let l=dr(e,a);if(!l||!l.name){n=a+1;continue}if(l.name.toLowerCase()===i&&(l.isClosing?r-=1:l.isSelfClosing||(r+=1),r===0))return l.endIndex;n=l.endIndex+1}return null}function Wn(e,t){if(!e)throw new Error(`${t}`)}function lo(e,t){if(e.type!==t)throw new Error(`Expected element to be of type ${JSON.stringify(e)} but is ${JSON.stringify(e,null,2)}`)}function Se(e){throw new Error(`Didn't expect to get here with value ${JSON.stringify(e,null,2)}`)}function cu(e){let t=e[0];if(!t||t.type!=="paragraph")return e;let o=t.children[0];if(!o||!("text"in o))return e;let r=o.text.match(/^(\[![A-Za-z0-9_-]+\][+-]?(?:[^\n]*))(?:\n([\s\S]*))?$/);if(!r)return e;let n=r[1],i=r[2],a={type:"paragraph",children:[{...o,text:n}]};if(!i)return[a,...e.slice(1)];let l={...t,children:[{...o,text:i},...t.children.slice(1)]};return[a,l,...e.slice(1)]}function Vn(e,t={}){return[{type:"block-quote",children:cu(tt(e.children,t))}]}function _n(e){let t=e.value.split(`
2
+ `);return[{type:"code-block",language:e.lang||"text",children:t.map(o=>({type:"code-block-line",children:[{text:o}]}))}]}function Kn(e,t={}){return[{type:"block-quote",children:[{type:"paragraph",children:[{text:`[${e.identifier}]`}]},...tt(e.children,t)]}]}import{Text as oi}from"slate";import{Text as ei}from"slate";import*as zt from"slate";function q(e){return zt.Text.isText(e)}function me(e){return zt.Element.isElement(e)}function H(e){return zt.Text.isText(e)&&!!e.text.match(/^\s+$/)&&!e.code}var Gn={bold:"**",italic:"_",strike:"~~",highlight:"<mark>",code:""},qn={bold:"**",italic:"_",strike:"~~",highlight:"</mark>",code:""};function pu(e){if(e in Gn)return Gn[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_OPEN_TOKEN lookup`)}function du(e){if(e in qn)return qn[e];throw new Error(`Could not find mark ${JSON.stringify(e)} in MARK_KEY_TO_CLOSE_TOKEN lookup`)}function Qn(e){return e.map(pu).join("")}function jn(e){return e.map(du).join("")}import{Text as uu}from"slate";function Nt(e){let{text:t,...o}=e;return Object.keys(o)}function ur(e){if(uu.isText(e)){if(H(e))throw new Error("You probably didn't mean to do this. We should only be getting marks from segments that are not plain space segments.");return Nt(e)}else{if(e.type==="anchor")return so(e.children);throw new Error(`Unhandled type ${e.type}`)}}function so(e){let t;for(let o of e){if(!q(o)){if(o.type==="image-inline")continue;throw new Error("Expected every segment in an anchor to be a Text segment")}if(H(o))continue;let r=Nt(o);if(t===void 0){t=r;continue}t=t.filter(n=>r.includes(n))}return t===void 0?[]:t}var Xn=["bold","italic","underline","strike","highlight","code"];function Yn(e){return e.slice().sort((t,o)=>Xn.indexOf(t)-Xn.indexOf(o))}function fu(e){return/[!-/:-@\[-`{-~]/.test(e)}function rt(e){return e===""||/\s/u.test(e)}function ot(e){return e!==""&&/[\p{P}\p{S}]/u.test(e)}function hu(e){return/[a-zA-Z/?!]/.test(e)}function Jn(e,t,o){let r=new Set,n=[];for(let i=0;i<e.length;i++){if(e[i]!==t)continue;let a=i>0?e[i-1]:"",l=i+1<e.length?e[i+1]:"",s=!rt(l)&&(!ot(l)||rt(a)||ot(a)),m=!rt(a)&&(!ot(a)||rt(l)||ot(l)),c=s&&(o||!m||ot(a));m&&(o||!s||ot(l))&&n.length>0&&(r.add(n.pop()),r.add(i)),c&&n.push(i)}return r}function gu(e){let t=new Set,o=[];for(let r=0;r<e.length;r++){if(e[r]!=="~")continue;let n=r>0?e[r-1]:"",i=r+1<e.length?e[r+1]:"",a=!rt(i);!rt(n)&&o.length>0&&(t.add(o.pop()),t.add(r)),a&&o.push(r)}return t}function bu(e,t=!1){let o=new Set,r=[];for(let n=0;n<e.length;n++)if(e[n]==="[")t&&e[n+1]==="["&&o.add(n),e[n+1]==="^"&&o.add(n),r.push(n);else if(e[n]==="]"){let i=r.pop();i!==void 0&&e[n+1]==="("&&(o.add(i),o.add(n))}return o}function Zn(e,t={}){let o=Array.from(e),r=Jn(o,"_",!1),n=Jn(o,"*",!0),i=gu(o),a=bu(o,t.enableInternalLinks),l=t.escapeBackticks??o.filter(m=>m==="`").length>=2,s="";for(let m=0;m<o.length;m++){let c=o[m],d=m+1<o.length?o[m+1]:"";c==="`"?s+=l?"\\`":c:c==="\\"?s+=fu(d)?"\\\\":"\\":c==="<"?s+=hu(d)?"\\<":"<":c==="_"?s+=r.has(m)?`\\${c}`:c:c==="*"?s+=n.has(m)?`\\${c}`:c:c==="~"?s+=i.has(m)?`\\${c}`:c:c==="["||c==="]"?s+=t.inAnchorLabel||a.has(m)?`\\${c}`:c:s+=c}return s=s.replace(/^(#{1,6})(\s)/m,"\\$1$2"),s=s.replace(/^(\d+)([.)]\s)/m,"$1\\$2"),s=s.replace(/^([-+*>])\s/m,"\\$1 "),s}function Eu(e,t){let o=Nt(e),r=Nt(t);return o.length==r.length&&o.every(n=>r.includes(n))}function ti(e,t){let o=ei.isText(e),r=ei.isText(t);return t&&!r&&!o?[{text:""},e]:o?t===void 0||!r?[e]:Eu(t,e)?(t.text=[t.text,e.text].join(""),[]):[e]:[e]}function ri(e){let t=[];for(let o=0;o<e.length;o++){let r=t[t.length-1];t.push(...ti(e[o],r))}return t.length===0&&t.push({text:""}),oi.isText(t[0])||t.unshift({text:""}),oi.isText(t[t.length-1])||t.push({text:""}),t}function ni(e){return{url:e.url,title:e.title||void 0,alt:e.alt||void 0}}var xu=/^([^?#]*)(?:\?([^#]*))?(#.*)?$/;function nt(e){try{let t=new URL(e);return{origin:t.origin,hostname:t.hostname,pathname:t.pathname,searchParams:t.searchParams,hash:t.hash}}catch{let t=e.match(xu);if(t===null)throw new Error(`Invalid format should not happen: ${e}`);let[,o,r,n]=[...t];return{origin:"",hostname:"",pathname:o||"",searchParams:new URLSearchParams(r),hash:n||""}}}function Ht(e){if(typeof e!="string")return null;let t=e.match(/^(\d+)x(\d+)$/);return t===null?null:{width:parseInt(t[1],10),height:parseInt(t[2],10)}}function ii(e){let t=nt(e.url);if(!t.hostname.match(/[.]portive[.]com$/i))return;let o=t.searchParams.get("size");if(o===null)return;let r=Ht(o);if(r===null)return;let n=t.pathname.match(/[-][-](\d+)x(\d+)[.][a-zA-Z]+$/);if(n!==null)return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:parseInt(n[1],10),srcHeight:parseInt(n[2],10)}}function ai(e){let t=nt(e.url);if(t.hash.length===0)return;let o=new URLSearchParams(t.hash.slice(1)),r=Ht(o.get("size")),n=Ht(o.get("srcSize"));if(!(!r||!n))return{url:`${t.origin}${t.pathname}`,title:e.title||void 0,alt:e.alt||void 0,width:r.width,height:r.height,srcWidth:n.width,srcHeight:n.height}}var li=[ii,ai,ni];function si(e){for(let t of li){let o=t(e);if(o)return[{type:"image-inline",...o,children:[{text:""}]}]}throw new Error("Shouldn't get here because last parser always returns data")}function ku(e,t){if(/^<br\s*\/?>$/i.test(e))return[{text:`
3
+ `,...t}];let o=e.match(/^<mark\b[^>]*>(.+?)<\/mark>$/is);return o?[{text:o[1],...t,highlight:!0}]:[{text:e,code:!0}]}function yu(e,t){let o=[],r=/(!)?\[\[((?:\\.|[^\]\\\n])+?)\]\]/g,n=0,i;for(;(i=r.exec(e))!==null;){let a=i.index;if(a>0&&e[a-1]==="\\")continue;a>n&&o.push({text:Oe(e.slice(n,a)),...t});let l=ao(Oe(i[2])).trim();i[1]?o.push({type:"image-inline",url:no(l),alt:l,children:[{text:""}]}):o.push({type:"anchor",href:Ce(l),children:[{text:se(l),...t}]}),n=a+i[0].length}return n===0?[{text:Oe(e),...t}]:(n<e.length&&o.push({text:Oe(e.slice(n)),...t}),o)}function J(e,t={},o={}){let r=[],n={...t};for(let a of e){if(a.type==="html"){if(/^<mark\b[^>]*>$/i.test(a.value)){n={...n,highlight:!0};continue}if(/^<\/mark>$/i.test(a.value)){let{highlight:l,...s}=n;n=s;continue}}r.push(...vu(a,n,o))}return ri(r)}function vu(e,t={},o={}){switch(e.type){case"delete":return J(e.children,{...t,strike:!0},o);case"emphasis":return J(e.children,{...t,italic:!0},o);case"footnoteReference":return[{text:`[${e.identifier}]`}];case"html":return ku(e.value,t);case"image":return si(e);case"inlineCode":return[{text:Oe(e.value),...t,code:!0}];case"link":return[{type:"anchor",href:e.url,title:e.title==null?void 0:e.title,children:J(e.children,t,o)}];case"strong":return J(e.children,{...t,bold:!0},o);case"text":return o.enableInternalLinks?yu(e.value,t):[{text:Oe(e.value),...t}];case"linkReference":case"imageReference":throw new Error("linkReference and imageReference should be converted to link and image through our transformInlineLinks function");case"break":return[{text:`
4
+ `}];case"footnote":throw new Error("footnote is not supported yet")}Se(e)}function mi(e,t={}){return[{type:"heading",level:e.depth,children:J(e.children,{},t)}]}function ci(e){return[{type:"html-block",html:e.value,children:[{text:""}]}]}function pi(e,{depth:t,ordered:o,checked:r},n={}){switch(e.type){case"paragraph":return r===!0||r===!1?[{type:"task-list-item",depth:t,checked:r,children:J(e.children,{},n)}]:o?[{type:"ordered-list-item",depth:t,children:J(e.children,{},n)}]:[{type:"unordered-list-item",depth:t,children:J(e.children,{},n)}];case"list":return mo(e,t+1,n);default:return fr(e,n)}}function di(e,t,o={}){let r=[];for(let n of e.children)r.push(...pi(n,{...t,checked:e.checked},o));return r}function mo(e,t=0,o={}){let r=[];for(let n of e.children)r.push(...di(n,{depth:t,ordered:!!e.ordered},o));return r}function Tu(e){return!(e.length!==3||!("text"in e[0])||e[0].text!==""||!("text"in e[2])||e[2].text!==""||!("type"in e[1])||e[1].type!=="image-inline")}var wu="\xA0";function Iu(e){return!(e.length!==1||!("text"in e[0])||e[0].text!==wu)}function ui(e,t={}){let o=J(e.children,{},t);return Tu(o)?[{...o[1],type:"image-block"}]:Iu(o)?[{type:"paragraph",children:[{text:""}]}]:[{type:"paragraph",children:o}]}function fi(e,t={}){if(e.align==null)throw new Error("Expected an array of AlignType for table.align");return[{type:"table",columns:e.align.map(o=>({align:o||"left"})),children:e.children.map(o=>Mu(o,t))}]}function Mu(e,t){if(e.type!=="tableRow")throw new Error("Expected a tableRow");return{type:"table-row",children:e.children.map(o=>Cu(o,t))}}function Cu(e,t){if(e.type!=="tableCell")throw new Error("Expected a tableCell");return{type:"table-cell",children:[{type:"table-content",children:J(e.children,{},t)}]}}function hi(){return[{type:"horizontal-rule",children:[{text:""}]}]}function tt(e,t={}){let o=[];for(let r=0;r<e.length;r++){if(r>0){let n=e[r-1],i=e[r];if(n.position&&i.position){let a=i.position.start.line-n.position.end.line-1;for(let l=1;l<a;l++)o.push({type:"paragraph",children:[{text:""}]})}}o.push(...fr(e[r],t))}return o}function fr(e,t={}){switch(e.type){case"blockquote":return Vn(e,t);case"code":return _n(e);case"definition":throw new Error('The type "definition" should not exist. See comments');case"footnoteDefinition":return Kn(e,t);case"heading":return mi(e,t);case"html":return ci(e);case"list":return mo(e,0,t);case"paragraph":return ui(e,t);case"table":return fi(e,t);case"thematicBreak":return hi();case"yaml":return[]}Se(e)}import{definitions as Pu}from"mdast-util-definitions";import{SKIP as gi,visit as Su}from"unist-util-visit";function bi(e){let t=Pu(e);Su(e,(o,r,n)=>{let i=o,a=n;if(i.type==="definition"&&a!==null&&typeof r=="number")return a.children.splice(r,1),[gi,r];if(i.type==="imageReference"||i.type==="linkReference"){let l="identifier"in i&&typeof i.identifier=="string"?i.identifier:"",s=t(l);if(s&&a!==null&&typeof r=="number"){let m=i.type==="imageReference"?{type:"image",url:s.url,title:s.title,alt:i.alt}:{type:"link",url:s.url,title:s.title,children:i.children};return a.children[r]=m,[gi,r]}}})}var Bu=Ru().use(Lu).use(zn());function $u(e,t={}){let o=Bu.parse(t.enableInternalLinks?An(e):e);return bi(o),o}function Le(e,t={}){let o=$u(e,t);return o.children.length===0?[{type:"paragraph",children:[{text:""}]}]:tt(o.children,t)}function Du(e){return e.type==="ordered-list-item"||e.type==="unordered-list-item"||e.type==="task-list-item"}function Ei(e){let t=[],o=-1;for(let r of e){if(!Du(r)){t.push(r),o=-1;continue}let n=r.depth>o+1?o+1:r.depth;t.push({...r,depth:n}),o=n}return t}function xi(e){if(e.type!=="code-block-line")throw new Error(`Expected all children of code-block to be a codeline but is ${JSON.stringify(e,null,2)}`);return e.children.map(t=>t.text).join("")}function ki(e){let t=[],o=3;for(let r of e.children){let n=xi(r),i=n.match(/^([`]+)/);i&&(o=Math.max(o,i[1].length+1)),t.push(n)}return t.unshift(`${"`".repeat(o)}${e.language}`),t.push(`${"`".repeat(o)}`),`${t.join(`
5
5
  `)}
6
6
 
7
- `}function di(e){return e.url}function ui(e){if(e.url.startsWith("$"))return"";let{hostname:t}=it(e.url);if(t.match(/[.]portive[.]com$/i)&&e.width&&e.height)return`${e.url}?size=${e.width}x${e.height}`}function fi(e){if(e.width&&e.height&&e.srcWidth&&e.srcHeight)return`${e.url}#srcSize=${e.srcWidth}x${e.srcHeight}&size=${e.width}x${e.height}`}var wu=[ui,fi,di];function mo(e,t={}){if(t.enableInternalLinks&&et(e.url))return Bn(e.url);for(let o of wu){let r=o(e);if(typeof r=="string")return r===""?"":`![${e.alt}](${r}${typeof e.title=="string"?` "${e.title}"`:""})`}throw new Error("Shouldn't get here")}function hi(e,t={}){let o=mo(e,t);return o?`${o}
7
+ `}function yi(e){return e.url}function vi(e){if(e.url.startsWith("$"))return"";let{hostname:t}=nt(e.url);if(t.match(/[.]portive[.]com$/i)&&e.width&&e.height)return`${e.url}?size=${e.width}x${e.height}`}function Ti(e){if(e.width&&e.height&&e.srcWidth&&e.srcHeight)return`${e.url}#srcSize=${e.srcWidth}x${e.srcHeight}&size=${e.width}x${e.height}`}var zu=[vi,Ti,yi];function co(e,t={}){if(t.enableInternalLinks&&Ze(e.url))return Fn(e.url);for(let o of zu){let r=o(e);if(typeof r=="string")return r===""?"":`![${e.alt}](${r}${typeof e.title=="string"?` "${e.title}"`:""})`}throw new Error("Shouldn't get here")}function wi(e,t={}){let o=co(e,t);return o?`${o}
8
8
 
9
- `:""}import{Element as Su,Text as $i}from"slate";function gi(e,t){let o=t.filter(n=>!e.includes(n));return{orderedMarksToAdd:Wn(o)}}function bi(e,t){let o=[...e],r=e.filter(i=>!t.includes(i)),n=[];for(let i=0;i<e.length&&r.length!==0;i++){let a=o.pop();if(a===void 0)throw new Error("This shouldn't happen unless we made a mistake in the algorithm");n.push(a);let l=r.indexOf(a);l!==-1&&r.splice(l,1)}return{orderedMarksToRemove:n,nextOrderedMarks:o}}function lr(e,t){let{orderedMarksToRemove:o,nextOrderedMarks:r}=bi(e,t),{orderedMarksToAdd:n}=gi(r,t);return{remove:o,add:n,nextOrderedMarks:[...r,...n]}}import{Element as Mu}from"slate";function Ei({node:e,nextNode:t,nodes:o,index:r}){return!q(e)||!A(e)||e.code||!q(t)||!A(t)||t.code?!1:(o.splice(r,2,{text:`${e.text}${t.text}`}),!0)}function xi({node:e,nodes:t,prevNode:o,index:r}){if(!ce(e)||e.type!=="anchor")return!1;let n=e.children[0];return q(n)&&A(n)?(e.children.splice(0,1),q(o)&&A(o)?o.text=`${o.text}${n.text}`:t.splice(r,0,{text:n.text}),!0):!1}function ki({node:e,nodes:t,nextNode:o,index:r}){if(!ce(e)||e.type!=="anchor")return!1;let n=e.children[e.children.length-1];return q(n)&&A(n)?(e.children.splice(e.children.length-1,1),q(o)&&A(o)?o.text=`${n.text}${o.text}`:t.splice(r+1,0,{text:n.text}),!0):!1}function yi({node:e}){return!ce(e)||e.type!=="line"||e.children.length>0?!1:(e.children.push({text:""}),!0)}function vi({node:e,nodes:t,index:o}){if(!q(e)||A(e)||e.code)return!1;let r=e.text.match(/^(\s*)(.*?)(\s*)$/);if(!r||r[1].length===0&&r[3].length===0)return!1;let n=[{text:r[1]},{...e,text:r[2]},{text:r[3]}].filter(i=>i.text!=="");return t.splice(o,1,...n),!0}function Ti({index:e,nodes:t,node:o,parent:r}){return e!==t.length-1||t.length<=1||!q(o)||!A(o)?!1:r&&ce(r)&&r.type==="line"?(t.splice(t.length-1,1),!0):!1}function wi({index:e,nodes:t,node:o,parent:r}){return e!==0||t.length===0||!q(o)||!A(o)?!1:r&&ce(r)&&r.type==="line"?(t.splice(0,1),!0):!1}var Ii=[vi,xi,ki,Ei,wi,Ti,yi];function Mi(e){for(let t of Ii)if(t(e))return!0;return!1}var Iu=72;function sr(e,t){let o=!1,r,n=0,i=(e.length+1)*Iu;do{if(r=!1,n=n+1,n>i)throw new Error(`There have been ${n} normalization passes (72x the number of nodes at this level). This likely indicates a bug in the code.`);e:for(let a=0;a<e.length;a++){let l=e[a];if(ce(l)&&sr(l.children,l)){r=!0,o=!0;break e}let s=e[a-1],m=e[a+1];if(Mi({parent:t,node:l,prevNode:s,nextNode:m,index:a,nodes:e})){r=!0,o=!0;break e}}}while(r);return o}var Ci=e=>e.map(t=>Mu.isElement(t)&&t.type==="anchor"?{...t,children:Ci(t.children)}:t);function Pi(e){let t={type:"line",children:Ci(e)};return sr([t],void 0),t.children}import{Text as Pu}from"slate";function Si(e){let t=0;for(let o of e.text.matchAll(/[`]+/g))t=Math.max(t,o[0].length);return t===0?`\`${e.text.replace(/[`]/g,"\\`")}\``:`${"`".repeat(t+1)} ${e.text} ${"`".repeat(t+1)}`}function Cu(e){return e.replace(/"/g,'\\"')}function Li(e,t){if(t?.enableInternalLinks&&ue(e.href)){let n=lo(e.children),i={...t,inAnchorLabel:!0};return Rn(e.href,j(e.children,n,n,i))}let o=lo(e.children),r={...t,inAnchorLabel:!0};return e.href.startsWith("$")?j(e.children,o,o,t):typeof e.title=="string"&&e.title.length>0?`[${j(e.children,o,o,r)}](${e.href} "${Cu(e.title)}")`:`[${j(e.children,o,o,r)}](${e.href})`}function Ri(e,t){return _n(e.text,t).replace(/\n/g,`
10
- `)}function Bi(e,t){if(Pu.isText(e))return e.code?Si(e):Ri(e,t);switch(e.type){case"anchor":return Li(e,t);case"image-inline":return mo(e,t);default:Pe(e)}}function Lu(e){let t=0,o=r=>{for(let n of r)if($i.isText(n)){if(n.code)return!0;for(let i of n.text)if(i==="`"&&++t>=2)return!0}else if(n.type==="anchor"&&o(n.children))return!0;return!1};return o(e)}function j(e,t=[],o=[],r){let n=Pi(e),i=[],a={...r,escapeBackticks:r?.escapeBackticks??Lu(n)},l=lr(t,ir(n[0]));for(let s=0;s<n.length;s++){let m=n[s];if($i.isText(m)&&A(m)){i.push(m.text);continue}i.push(On(l.add)),i.push(Bi(m,a));let c=Ru(n,s,o),d=lr(l.nextOrderedMarks,c);i.push(Un(d.remove)),l=d}return i.join("")}function Ru(e,t,o){for(let r=t+1;r<e.length;r++){let n=e[r];if(!A(n)&&!(Su.isElement(n)&&n.type==="image-inline"))return ir(n)}return o}function zi(e,t={}){let o=[];return o.push(Di(e.children[0],t)),o.push(Bu(e.columns)),e.children.slice(1).forEach(r=>{o.push(Di(r,t))}),`${o.join(`
9
+ `:""}import{Element as Uu,Text as Wi}from"slate";function Ii(e,t){let o=t.filter(n=>!e.includes(n));return{orderedMarksToAdd:Yn(o)}}function Mi(e,t){let o=[...e],r=e.filter(i=>!t.includes(i)),n=[];for(let i=0;i<e.length&&r.length!==0;i++){let a=o.pop();if(a===void 0)throw new Error("This shouldn't happen unless we made a mistake in the algorithm");n.push(a);let l=r.indexOf(a);l!==-1&&r.splice(l,1)}return{orderedMarksToRemove:n,nextOrderedMarks:o}}function hr(e,t){let{orderedMarksToRemove:o,nextOrderedMarks:r}=Mi(e,t),{orderedMarksToAdd:n}=Ii(r,t);return{remove:o,add:n,nextOrderedMarks:[...r,...n]}}import{Element as Hu}from"slate";function Ci({node:e,nextNode:t,nodes:o,index:r}){return!q(e)||!H(e)||e.code||!q(t)||!H(t)||t.code?!1:(o.splice(r,2,{text:`${e.text}${t.text}`}),!0)}function Pi({node:e,nodes:t,prevNode:o,index:r}){if(!me(e)||e.type!=="anchor")return!1;let n=e.children[0];return q(n)&&H(n)?(e.children.splice(0,1),q(o)&&H(o)?o.text=`${o.text}${n.text}`:t.splice(r,0,{text:n.text}),!0):!1}function Si({node:e,nodes:t,nextNode:o,index:r}){if(!me(e)||e.type!=="anchor")return!1;let n=e.children[e.children.length-1];return q(n)&&H(n)?(e.children.splice(e.children.length-1,1),q(o)&&H(o)?o.text=`${n.text}${o.text}`:t.splice(r+1,0,{text:n.text}),!0):!1}function Li({node:e}){return!me(e)||e.type!=="line"||e.children.length>0?!1:(e.children.push({text:""}),!0)}function Ri({node:e,nodes:t,index:o}){if(!q(e)||H(e)||e.code)return!1;let r=e.text.match(/^(\s*)(.*?)(\s*)$/);if(!r||r[1].length===0&&r[3].length===0)return!1;let n=[{text:r[1]},{...e,text:r[2]},{text:r[3]}].filter(i=>i.text!=="");return t.splice(o,1,...n),!0}function Bi({index:e,nodes:t,node:o,parent:r}){return e!==t.length-1||t.length<=1||!q(o)||!H(o)?!1:r&&me(r)&&r.type==="line"?(t.splice(t.length-1,1),!0):!1}function $i({index:e,nodes:t,node:o,parent:r}){return e!==0||t.length===0||!q(o)||!H(o)?!1:r&&me(r)&&r.type==="line"?(t.splice(0,1),!0):!1}var Di=[Ri,Pi,Si,Ci,$i,Bi,Li];function zi(e){for(let t of Di)if(t(e))return!0;return!1}var Nu=72;function gr(e,t){let o=!1,r,n=0,i=(e.length+1)*Nu;do{if(r=!1,n=n+1,n>i)throw new Error(`There have been ${n} normalization passes (72x the number of nodes at this level). This likely indicates a bug in the code.`);e:for(let a=0;a<e.length;a++){let l=e[a];if(me(l)&&gr(l.children,l)){r=!0,o=!0;break e}let s=e[a-1],m=e[a+1];if(zi({parent:t,node:l,prevNode:s,nextNode:m,index:a,nodes:e})){r=!0,o=!0;break e}}}while(r);return o}var Ni=e=>e.map(t=>Hu.isElement(t)&&t.type==="anchor"?{...t,children:Ni(t.children)}:t);function Hi(e){let t={type:"line",children:Ni(e)};return gr([t],void 0),t.children}import{Text as Ou}from"slate";function Ai(e){let t=0;for(let o of e.text.matchAll(/[`]+/g))t=Math.max(t,o[0].length);return t===0?`\`${e.text.replace(/[`]/g,"\\`")}\``:`${"`".repeat(t+1)} ${e.text} ${"`".repeat(t+1)}`}function Au(e){return e.replace(/"/g,'\\"')}function Oi(e,t){if(t?.enableInternalLinks&&ue(e.href)){let n=so(e.children),i={...t,inAnchorLabel:!0};return Un(e.href,X(e.children,n,n,i))}let o=so(e.children),r={...t,inAnchorLabel:!0};return e.href.startsWith("$")?X(e.children,o,o,t):typeof e.title=="string"&&e.title.length>0?`[${X(e.children,o,o,r)}](${e.href} "${Au(e.title)}")`:`[${X(e.children,o,o,r)}](${e.href})`}function Ui(e,t){return Zn(e.text,t).replace(/\n/g,`
10
+ `)}function Fi(e,t){if(Ou.isText(e))return e.code?Ai(e):Ui(e,t);switch(e.type){case"anchor":return Oi(e,t);case"image-inline":return co(e,t);default:Se(e)}}function Fu(e){let t=0,o=r=>{for(let n of r)if(Wi.isText(n)){if(n.code)return!0;for(let i of n.text)if(i==="`"&&++t>=2)return!0}else if(n.type==="anchor"&&o(n.children))return!0;return!1};return o(e)}function X(e,t=[],o=[],r){let n=Hi(e),i=[],a={...r,escapeBackticks:r?.escapeBackticks??Fu(n)},l=hr(t,ur(n[0]));for(let s=0;s<n.length;s++){let m=n[s];if(Wi.isText(m)&&H(m)){i.push(m.text);continue}i.push(Qn(l.add)),i.push(Fi(m,a));let c=Wu(n,s,o),d=hr(l.nextOrderedMarks,c);i.push(jn(d.remove)),l=d}return i.join("")}function Wu(e,t,o){for(let r=t+1;r<e.length;r++){let n=e[r];if(!H(n)&&!(Uu.isElement(n)&&n.type==="image-inline"))return ur(n)}return o}function _i(e,t={}){let o=[];return o.push(Vi(e.children[0],t)),o.push(Vu(e.columns)),e.children.slice(1).forEach(r=>{o.push(Vi(r,t))}),`${o.join(`
11
11
  `)}
12
12
 
13
- `}function Bu(e){return e.every(o=>o.align==="left")?`|${e.map(()=>"---").join("|")}|`:`|${e.map(o=>$u(o.align)).join("|")}|`}function $u(e){switch(e){case"left":return":---";case"center":return":---:";case"right":return"---:"}}function Di(e,t){return ao(e,"table-row"),`|${e.children.map(o=>Du(o,t)).join("|")}|`}function Du(e,t){return ao(e,"table-cell"),$n(e.children.length===1,`Expected table-cell to have one child but is ${JSON.stringify(e.children)}`),e.children.map(o=>zu(o,t)).join("")}function zu(e,t){return ao(e,"table-content"),j(e.children,[],[],t).replace(/\|/g,"\\|").replace(/ {2}\n/g,"<br>").replace(/\n/g,"<br>")}var mr=4;function cr(e,t,o={}){switch(e.type){case"anchor":return`[${j(e.children)}](${e.href})`;case"block-quote":{let r=e.children,n=r[0];return`${(n?.type==="paragraph"&&/^\[![A-Za-z0-9_-]+\][+-]?(?:\s+.*)?$/.test(j(n.children))?`${cr(n,t,o).trimEnd()}
14
- ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
13
+ `}function Vu(e){return e.every(o=>o.align==="left")?`|${e.map(()=>"---").join("|")}|`:`|${e.map(o=>_u(o.align)).join("|")}|`}function _u(e){switch(e){case"left":return":---";case"center":return":---:";case"right":return"---:"}}function Vi(e,t){return lo(e,"table-row"),`|${e.children.map(o=>Ku(o,t)).join("|")}|`}function Ku(e,t){return lo(e,"table-cell"),Wn(e.children.length===1,`Expected table-cell to have one child but is ${JSON.stringify(e.children)}`),e.children.map(o=>Gu(o,t)).join("")}function Gu(e,t){return lo(e,"table-content"),X(e.children,[],[],t).replace(/\|/g,"\\|").replace(/ {2}\n/g,"<br>").replace(/\n/g,"<br>")}var br=4;function Er(e,t,o={}){switch(e.type){case"anchor":return`[${X(e.children)}](${e.href})`;case"block-quote":{let r=e.children,n=r[0];return`${(n?.type==="paragraph"&&/^\[![A-Za-z0-9_-]+\][+-]?(?:\s+.*)?$/.test(X(n.children))?`${Er(n,t,o).trimEnd()}
14
+ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
15
15
  `).map(l=>l?`> ${l}`:">").join(`
16
16
  `)}
17
17
 
18
- `}case"heading":return`${"#".repeat(e.level)} ${j(e.children)}
18
+ `}case"heading":return`${"#".repeat(e.level)} ${X(e.children)}
19
19
 
20
20
  `;case"horizontal-rule":return`---
21
21
 
22
- `;case"paragraph":{let r=j(e.children,[],[],o);return r===""?`\xA0
22
+ `;case"paragraph":{let r=X(e.children,[],[],o);return r===""?`\xA0
23
23
 
24
24
  `:`${r}
25
25
 
26
- `}case"table":return zi(e,o);case"table-row":case"table-cell":case"table-content":throw new Error(`Table elements should only be present as children of table which should be handled by serializeTable. Got ${e.type} may indicate an error in normalization.`);case"unordered-list-item":return`${" ".repeat(e.depth*mr)}- ${j(e.children,[],[],o)}
27
- `;case"ordered-list-item":return`${" ".repeat(e.depth*mr)}${t[e.depth]}. ${j(e.children,[],[],o)}
28
- `;case"task-list-item":{let r=" ".repeat(e.depth*mr),n=j(e.children,[],[],o);return n.trim()===""&&(n="&#32;"),`${r}- [${e.checked?"x":" "}] ${n}
29
- `}case"image-block":return hi(e,o);case"image-inline":return`![${e.alt||""}](${e.url})`;case"code-block":return pi(e);case"code-block-line":throw new Error("Code block line elements should only be present as children of code-block which should be handled by serializeCodeBlock. Got code-block-line may indicate an error in normalization.");case"html-block":return`${e.html}
26
+ `}case"table":return _i(e,o);case"table-row":case"table-cell":case"table-content":throw new Error(`Table elements should only be present as children of table which should be handled by serializeTable. Got ${e.type} may indicate an error in normalization.`);case"unordered-list-item":return`${" ".repeat(e.depth*br)}- ${X(e.children,[],[],o)}
27
+ `;case"ordered-list-item":return`${" ".repeat(e.depth*br)}${t[e.depth]}. ${X(e.children,[],[],o)}
28
+ `;case"task-list-item":{let r=" ".repeat(e.depth*br),n=X(e.children,[],[],o);return n.trim()===""&&(n="&#32;"),`${r}- [${e.checked?"x":" "}] ${n}
29
+ `}case"image-block":return wi(e,o);case"image-inline":return`![${e.alt||""}](${e.url})`;case"code-block":return ki(e);case"code-block-line":throw new Error("Code block line elements should only be present as children of code-block which should be handled by serializeCodeBlock. Got code-block-line may indicate an error in normalization.");case"html-block":return`${e.html}
30
30
 
31
- `}Pe(e)}function Ot(e,t={}){let o=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],l=i<e.length-1?e[i+1]:null;a.type==="ordered-list-item"?(r[a.depth]=(r[a.depth]||0)+1,r=r.slice(0,a.depth+1)):a.type==="unordered-list-item"||a.type==="task-list-item"?r=r.slice(0,a.depth):r=[];let s=cr(a,r,t);(a.type==="ordered-list-item"||a.type==="unordered-list-item"||a.type==="task-list-item")&&(!l||l.type!=="ordered-list-item"&&l.type!=="unordered-list-item"&&l.type!=="task-list-item")&&(s=s.replace(/\n$/,`
31
+ `}Se(e)}function At(e,t={}){let o=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],l=i<e.length-1?e[i+1]:null;a.type==="ordered-list-item"?(r[a.depth]=(r[a.depth]||0)+1,r=r.slice(0,a.depth+1)):a.type==="unordered-list-item"||a.type==="task-list-item"?r=r.slice(0,a.depth):r=[];let s=Er(a,r,t);(a.type==="ordered-list-item"||a.type==="unordered-list-item"||a.type==="task-list-item")&&(!l||l.type!=="ordered-list-item"&&l.type!=="unordered-list-item"&&l.type!=="task-list-item")&&(s=s.replace(/\n$/,`
32
32
 
33
- `)),o.push(s)}let n=o.join("");return n.replace(/[\t\n\r ]/g,"")===""?"":n.replace(/^\n+/,"").replace(/[\t\n\r ]+$/,"")}function fe(e,t={}){let o=mi(e);return Ot(o,t)}var pr={ja:{bold:"\u592A\u5B57",italic:"\u659C\u4F53",strike:"\u53D6\u308A\u6D88\u3057\u7DDA",inlineCode:"\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",underline:"\u4E0B\u7DDA",highlight:"\u30CF\u30A4\u30E9\u30A4\u30C8",increaseDepth:"\u968E\u5C64\u3092\u6DF1\u304F\u3059\u308B",decreaseDepth:"\u968E\u5C64\u3092\u6D45\u304F\u3059\u308B",heading1:"\u898B\u51FA\u30571",heading2:"\u898B\u51FA\u30572",heading3:"\u898B\u51FA\u30573",normal:"\u6A19\u6E96",paragraph:"\u6BB5\u843D",paragraphStyle:"\u6BB5\u843D\u30B9\u30BF\u30A4\u30EB",bulletList:"\u7B87\u6761\u66F8\u304D",numberedList:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkList:"\u30C1\u30A7\u30C3\u30AF\u30EA\u30B9\u30C8",list:"\u30EA\u30B9\u30C8",linkUrl:"\u30EA\u30F3\u30AF\u306EURL",linkTypeExternal:"\u5916\u90E8",linkTypeInternal:"\u5185\u90E8",internalLinkTarget:"\u5185\u90E8\u30EA\u30F3\u30AF\u5148",internalLinkTargetHint:"\u4F8B: Page \u307E\u305F\u306F Folder/Page#Heading",internalLinkEmbed:"\u57CB\u3081\u8FBC\u307F\u3068\u3057\u3066\u633F\u5165",internalLinkEmbedHint:"\u30AA\u30F3\u306B\u3059\u308B\u3068 ![[...]] \u3068\u3057\u3066\u57CB\u3081\u8FBC\u307E\u308C\u307E\u3059",linkText:"\u30EA\u30F3\u30AF\u30C6\u30AD\u30B9\u30C8",linkTextHint:"\u30EA\u30F3\u30AF\u3068\u3057\u3066\u8868\u793A\u3055\u308C\u308B\u30C6\u30AD\u30B9\u30C8",tooltipText:"\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\u30C6\u30AD\u30B9\u30C8",tooltipHint:"\u30DE\u30A6\u30B9\u30DB\u30D0\u30FC\u6642\u306B\u8868\u793A\u3055\u308C\u308B\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",apply:"\u9069\u7528",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",insertLink:"\u30EA\u30F3\u30AF",quote:"\u5F15\u7528",insertTable:"\u8868",insertImage:"\u753B\u50CF",insertImageFromUrl:"\u753B\u50CF",insert:"\u633F\u5165",format:"\u66F8\u5F0F",imageUrlRequired:"\u753B\u50CFURL\uFF08\u5FC5\u9808\uFF09\uFF1A",altText:"\u4EE3\u66FF\u30C6\u30AD\u30B9\u30C8\uFF1A",title:"\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\uFF1A",imageDescription:"\u753B\u50CF\u306E\u8AAC\u660E",imageTitle:"\u753B\u50CF\u306E\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",switchToVisualEditor:"\u30D3\u30B8\u30E5\u30A2\u30EB\u30A8\u30C7\u30A3\u30BF\u306B\u5207\u308A\u66FF\u3048",switchToRawMarkdown:"\u30DE\u30FC\u30AF\u30C0\u30A6\u30F3\u8868\u793A\u306B\u5207\u308A\u66FF\u3048",codeBlock:"\u30B3\u30FC\u30C9\u30D6\u30ED\u30C3\u30AF",increaseQuoteDepth:"\u5F15\u7528\u3092\u91CD\u306D\u308B",horizontalRule:"\u533A\u5207\u308A\u7DDA",register:"\u767B\u9332",imageSourceUrl:"URL",imageSourceFile:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9",selectFile:"\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E",uploading:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D...",saving:"\u4FDD\u5B58\u4E2D...",uploadComplete:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u5B8C\u4E86",imageSourceSelect:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u6E08\u307F",vaultPath:"\u4FDD\u5B58\u5148\u30D1\u30B9\uFF1A",vaultPathHint:"vault\u5185\u306E\u4FDD\u5B58\u5148\u30D1\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},en:{bold:"Bold",italic:"Italic",strike:"Strikethrough",inlineCode:"Inline Code",underline:"Underline",highlight:"Highlight",increaseDepth:"Increase Depth",decreaseDepth:"Decrease Depth",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",normal:"Normal",paragraph:"Paragraph",paragraphStyle:"Paragraph Style",bulletList:"Bullet List",numberedList:"Numbered List",checkList:"Check List",list:"List",linkUrl:"Link URL",linkTypeExternal:"External",linkTypeInternal:"Internal",internalLinkTarget:"Internal Link Target",internalLinkTargetHint:"Example: Page or Folder/Page#Heading",internalLinkEmbed:"Insert as embed",internalLinkEmbedHint:"When on, inserts as ![[...]]",linkText:"Link Text",linkTextHint:"Text displayed as the link",tooltipText:"Tooltip Text",tooltipHint:"Tooltip shown on mouse hover",apply:"Apply",cancel:"Cancel",insertLink:"Link",quote:"Quote",insertTable:"Table",insertImage:"Image",insertImageFromUrl:"Image",insert:"Insert",format:"Format",imageUrlRequired:"Image URL (required):",altText:"Alt Text:",title:"tooltip:",imageDescription:"Description of the image",imageTitle:"tooltip",switchToVisualEditor:"Switch to visual editor",switchToRawMarkdown:"Switch to raw markdown",codeBlock:"Code Block",increaseQuoteDepth:"Increase Quote Depth",horizontalRule:"Horizontal Rule",register:"Register",imageSourceUrl:"URL",imageSourceFile:"Upload",selectFile:"Select File",uploading:"Uploading...",saving:"Saving...",uploadComplete:"Upload Complete",imageSourceSelect:"Uploaded",vaultPath:"Save Path:",vaultPathHint:"Enter the path within the vault to save the file"}},Ni=()=>{try{if(typeof window<"u"&&window.navigator)return window.navigator.language.split("-")[0]}catch{}return"en"},f=e=>{let t=Ni();return pr[t==="ja"?"ja":"en"][e]},dr=e=>{let t=Ni();return Object.keys(pr[t==="ja"?"ja":"en"]).find(r=>pr[t==="ja"?"ja":"en"][r]===e)||""};var y=e=>({fn:e});import{useCallback as Uu,useEffect as Fu,useMemo as Gi,useRef as Wu}from"react";import{Editor as uo,Range as Vu,Transforms as qi}from"slate";import{ReactEditor as _u,useSlateStatic as Ku}from"slate-react";function he(e){return!!e}function Hi(e,t){let o=t.map(r=>r.editableProps?.decorate).filter(he);return function(r){let n=[];for(let i of o){let a=i(r);n.push(...a)}return e&&n.push(...e(r)),n}}import{Editable as Nu}from"slate-react";import{jsx as Hu}from"react/jsx-runtime";function Ai(e){let t=e.map(r=>r.renderEditable).filter(he),o=r=>Hu(Nu,{...r});for(let r of t){let n=o;o=i=>r({attributes:i,Editable:n})}return o}function co(e,t){let o=[];for(let r of e){let n=r.editableProps?.[t];n&&o.push(n)}return o}function po(e,t){return function(o){for(let r of e)if(r(o))return;t?.(o)}}var Oi=(e,t)=>{let o=co(t,"onKeyDown");return po(o,e)},Ui=(e,t)=>{let o=co(t,"onKeyUp");return po(o,e)},Fi=(e,t)=>{let o=co(t,"onPaste");return po(o,e)},Wi=(e,t)=>{let o=co(t,"onDrop");return po(o,e)};function Vi(e,t){let o=t.map(r=>r.editableProps?.renderElement).filter(he);return function(n){for(let i of o){let a=i(n);if(a)return a}if(e===void 0)throw new Error(`Element with type ${n.element.type} not handled. Note that renderElement is not defined on SinkEditable so this is only the result of checking the Sink Plugins.`);return e(n)}}import{cloneElement as Au}from"react";function _i(e,t){if(e===void 0)throw new Error("renderLeaf was not defined on SinkEditable");let o=t.map(r=>r.editableProps?.renderLeaf).filter(he).reverse();return function(r){let n=e({...r,attributes:{}});for(let i of o){let a=i({...r,children:n});a&&(n=a)}return n=Au(n,r.attributes),n}}function Ki(e,t){if(e)return e;let o=t.map(r=>r.editableProps?.renderPlaceholder).filter(he);if(o.length!==0)return function(r){if(o.length>1)throw new Error(`Only one plugin can define renderPlaceholder but there are ${o.length}`);let n=o[0];if(n==null)throw new Error("Expected fn to be defined");return n(r)}}import Ou from"@emotion/styled";var Ut=Ou("div")`
33
+ `)),o.push(s)}let n=o.join("");return n.replace(/[\t\n\r ]/g,"")===""?"":n.replace(/^\n+/,"").replace(/[\t\n\r ]+$/,"")}function fe(e,t={}){let o=Ei(e);return At(o,t)}var xr={ja:{bold:"\u592A\u5B57",italic:"\u659C\u4F53",strike:"\u53D6\u308A\u6D88\u3057\u7DDA",inlineCode:"\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",underline:"\u4E0B\u7DDA",highlight:"\u30CF\u30A4\u30E9\u30A4\u30C8",increaseDepth:"\u968E\u5C64\u3092\u6DF1\u304F\u3059\u308B",decreaseDepth:"\u968E\u5C64\u3092\u6D45\u304F\u3059\u308B",heading1:"\u898B\u51FA\u30571",heading2:"\u898B\u51FA\u30572",heading3:"\u898B\u51FA\u30573",normal:"\u6A19\u6E96",paragraph:"\u6BB5\u843D",paragraphStyle:"\u6BB5\u843D\u30B9\u30BF\u30A4\u30EB",bulletList:"\u7B87\u6761\u66F8\u304D",numberedList:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkList:"\u30C1\u30A7\u30C3\u30AF\u30EA\u30B9\u30C8",list:"\u30EA\u30B9\u30C8",linkUrl:"\u30EA\u30F3\u30AF\u306EURL",linkTypeExternal:"\u5916\u90E8",linkTypeInternal:"\u5185\u90E8",internalLinkTarget:"\u5185\u90E8\u30EA\u30F3\u30AF\u5148",internalLinkTargetHint:"\u4F8B: Page \u307E\u305F\u306F Folder/Page#Heading",internalLinkEmbed:"\u57CB\u3081\u8FBC\u307F\u3068\u3057\u3066\u633F\u5165",internalLinkEmbedHint:"\u30AA\u30F3\u306B\u3059\u308B\u3068 ![[...]] \u3068\u3057\u3066\u57CB\u3081\u8FBC\u307E\u308C\u307E\u3059",linkText:"\u30EA\u30F3\u30AF\u30C6\u30AD\u30B9\u30C8",linkTextHint:"\u30EA\u30F3\u30AF\u3068\u3057\u3066\u8868\u793A\u3055\u308C\u308B\u30C6\u30AD\u30B9\u30C8",tooltipText:"\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\u30C6\u30AD\u30B9\u30C8",tooltipHint:"\u30DE\u30A6\u30B9\u30DB\u30D0\u30FC\u6642\u306B\u8868\u793A\u3055\u308C\u308B\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",apply:"\u9069\u7528",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",edit:"\u7DE8\u96C6",remove:"\u524A\u9664",insertLink:"\u30EA\u30F3\u30AF",quote:"\u5F15\u7528",insertTable:"\u8868",insertImage:"\u753B\u50CF",insertImageFromUrl:"\u753B\u50CF",insert:"\u633F\u5165",format:"\u66F8\u5F0F",imageUrlRequired:"\u753B\u50CFURL\uFF08\u5FC5\u9808\uFF09\uFF1A",altText:"\u4EE3\u66FF\u30C6\u30AD\u30B9\u30C8\uFF1A",title:"\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\uFF1A",imageDescription:"\u753B\u50CF\u306E\u8AAC\u660E",imageTitle:"\u753B\u50CF\u306E\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",switchToVisualEditor:"\u30D3\u30B8\u30E5\u30A2\u30EB\u30A8\u30C7\u30A3\u30BF\u306B\u5207\u308A\u66FF\u3048",switchToRawMarkdown:"\u30DE\u30FC\u30AF\u30C0\u30A6\u30F3\u8868\u793A\u306B\u5207\u308A\u66FF\u3048",codeBlock:"\u30B3\u30FC\u30C9\u30D6\u30ED\u30C3\u30AF",increaseQuoteDepth:"\u5F15\u7528\u3092\u91CD\u306D\u308B",horizontalRule:"\u533A\u5207\u308A\u7DDA",register:"\u767B\u9332",imageSourceUrl:"URL",imageSourceFile:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9",selectFile:"\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E",uploading:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D...",saving:"\u4FDD\u5B58\u4E2D...",uploadComplete:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u5B8C\u4E86",imageSourceSelect:"\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u6E08\u307F",vaultPath:"\u4FDD\u5B58\u5148\u30D1\u30B9\uFF1A",vaultPathHint:"vault\u5185\u306E\u4FDD\u5B58\u5148\u30D1\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},en:{bold:"Bold",italic:"Italic",strike:"Strikethrough",inlineCode:"Inline Code",underline:"Underline",highlight:"Highlight",increaseDepth:"Increase Depth",decreaseDepth:"Decrease Depth",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",normal:"Normal",paragraph:"Paragraph",paragraphStyle:"Paragraph Style",bulletList:"Bullet List",numberedList:"Numbered List",checkList:"Check List",list:"List",linkUrl:"Link URL",linkTypeExternal:"External",linkTypeInternal:"Internal",internalLinkTarget:"Internal Link Target",internalLinkTargetHint:"Example: Page or Folder/Page#Heading",internalLinkEmbed:"Insert as embed",internalLinkEmbedHint:"When on, inserts as ![[...]]",linkText:"Link Text",linkTextHint:"Text displayed as the link",tooltipText:"Tooltip Text",tooltipHint:"Tooltip shown on mouse hover",apply:"Apply",cancel:"Cancel",edit:"Edit",remove:"Remove",insertLink:"Link",quote:"Quote",insertTable:"Table",insertImage:"Image",insertImageFromUrl:"Image",insert:"Insert",format:"Format",imageUrlRequired:"Image URL (required):",altText:"Alt Text:",title:"tooltip:",imageDescription:"Description of the image",imageTitle:"tooltip",switchToVisualEditor:"Switch to visual editor",switchToRawMarkdown:"Switch to raw markdown",codeBlock:"Code Block",increaseQuoteDepth:"Increase Quote Depth",horizontalRule:"Horizontal Rule",register:"Register",imageSourceUrl:"URL",imageSourceFile:"Upload",selectFile:"Select File",uploading:"Uploading...",saving:"Saving...",uploadComplete:"Upload Complete",imageSourceSelect:"Uploaded",vaultPath:"Save Path:",vaultPathHint:"Enter the path within the vault to save the file"}},Ki=()=>{try{if(typeof window<"u"&&window.navigator)return window.navigator.language.split("-")[0]}catch{}return"en"},f=e=>{let t=Ki();return xr[t==="ja"?"ja":"en"][e]},kr=e=>{let t=Ki();return Object.keys(xr[t==="ja"?"ja":"en"]).find(r=>xr[t==="ja"?"ja":"en"][r]===e)||""};var y=e=>({fn:e});import{useCallback as Yu,useEffect as Ju,useMemo as ta,useRef as Zu}from"react";import{Editor as fo,Range as ef,Transforms as oa}from"slate";import{ReactEditor as tf,useSlateStatic as of}from"slate-react";function he(e){return!!e}function Gi(e,t){let o=t.map(r=>r.editableProps?.decorate).filter(he);return function(r){let n=[];for(let i of o){let a=i(r);n.push(...a)}return e&&n.push(...e(r)),n}}import{Editable as qu}from"slate-react";import{jsx as Qu}from"react/jsx-runtime";function qi(e){let t=e.map(r=>r.renderEditable).filter(he),o=r=>Qu(qu,{...r});for(let r of t){let n=o;o=i=>r({attributes:i,Editable:n})}return o}function po(e,t){let o=[];for(let r of e){let n=r.editableProps?.[t];n&&o.push(n)}return o}function uo(e,t){return function(o){for(let r of e)if(r(o))return;t?.(o)}}var Qi=(e,t)=>{let o=po(t,"onKeyDown");return uo(o,e)},ji=(e,t)=>{let o=po(t,"onKeyUp");return uo(o,e)},Xi=(e,t)=>{let o=po(t,"onPaste");return uo(o,e)},Yi=(e,t)=>{let o=po(t,"onDrop");return uo(o,e)};function Ji(e,t){let o=t.map(r=>r.editableProps?.renderElement).filter(he);return function(n){for(let i of o){let a=i(n);if(a)return a}if(e===void 0)throw new Error(`Element with type ${n.element.type} not handled. Note that renderElement is not defined on SinkEditable so this is only the result of checking the Sink Plugins.`);return e(n)}}import{cloneElement as ju}from"react";function Zi(e,t){if(e===void 0)throw new Error("renderLeaf was not defined on SinkEditable");let o=t.map(r=>r.editableProps?.renderLeaf).filter(he).reverse();return function(r){let n=e({...r,attributes:{}});for(let i of o){let a=i({...r,children:n});a&&(n=a)}return n=ju(n,r.attributes),n}}function ea(e,t){if(e)return e;let o=t.map(r=>r.editableProps?.renderPlaceholder).filter(he);if(o.length!==0)return function(r){if(o.length>1)throw new Error(`Only one plugin can define renderPlaceholder but there are ${o.length}`);let n=o[0];if(n==null)throw new Error("Expected fn to be defined");return n(r)}}import Xu from"@emotion/styled";var Ot=Xu("div")`
34
34
  -webkit-font-smoothing: antialiased;
35
35
  -moz-osx-font-smoothing: grayscale;
36
36
  font-size: 1rem;
37
37
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
38
38
  Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
39
39
  box-sizing: border-box;
40
- `;import{jsx as ju}from"react/jsx-runtime";var Qi=e=>/[^\x00-\x7F]/.test(e);function Gu(e,t){let[o]=t.getTargetRanges();if(o)try{let r=_u.toSlateRange(e,o,{exactMatch:!1,suppressThrow:!1});qi.select(e,r)}catch{}}function qu(e,t,o){return r=>{let n=e?.(r);return n!=null||r.defaultPrevented||r.inputType!=="insertText"||r.isComposing||typeof r.data!="string"||r.data.length===0||!Qi(r.data)?n:(Gu(t,r),r.preventDefault(),uo.insertText(t,r.data),o.current=r.data,!0)}}function Qu(e,t,o){return r=>{let n=e?.(r);if(n!=null||r.defaultPrevented)return n;let i=r.nativeEvent;return!(i instanceof InputEvent)||i.inputType!=="insertText"||i.isComposing||typeof i.data!="string"||i.data.length===0||!Qi(i.data)?n:o.current===i.data?(o.current=null,n):(uo.insertText(t,i.data),n)}}function ji(e){let t=Ku(),o=Wu(null),r=Uu((l,s)=>{let{selection:m}=t;if(m==null||Vu.isCollapsed(m))return!1;let c=uo.fragment(t,m),d=fe(c,{enableInternalLinks:t.wysimark.enableInternalLinks}).trimEnd();return d===""?!1:(l.preventDefault(),l.clipboardData.setData("text/plain",d),l.clipboardData.setData("text/markdown",d),s.deleteSelection&&qi.delete(t),!0)},[t]);Fu(()=>{uo.normalize(t,{force:!0})},[t]);let{plugins:n}=t.sink,i=Gi(()=>({...e,decorate:Hi(e.decorate,n),renderElement:Vi(e.renderElement,n),renderLeaf:_i(e.renderLeaf,n),renderPlaceholder:Ki(e.renderPlaceholder,n),onKeyDown:Oi(e.onKeyDown,n),onKeyUp:Ui(e.onKeyUp,n),onPaste:Fi(e.onPaste,n),onCopy:l=>{e.onCopy?.(l),l.defaultPrevented||r(l,{deleteSelection:!1})},onCut:l=>{e.onCut?.(l),l.defaultPrevented||r(l,{deleteSelection:!0})},onDrop:Wi(e.onDrop,n),onDOMBeforeInput:qu(e.onDOMBeforeInput,t,o),onInput:Qu(e.onInput,t,o)}),[e.decorate,e.renderElement,e.renderLeaf,e.renderPlaceholder,e.onKeyDown,e.onKeyUp,e.onPaste,e.onCopy,e.onCut,e.onDrop,e.onDOMBeforeInput,e.onInput,e.placeholder,e.className,t,n,r]),a=Gi(()=>Ai(n),[n]);return ju(a,{...i})}function at(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(a){for(let s of n){let c=s.editor?.[t],d=c?.(a);if(typeof d=="boolean")return d}return r(a)}}function ye(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(...a){let l=!1,s=[];for(let m of n){let c=m.editor?.[t]?.(...a);if(typeof c=="function")s.push(c);else if(c===!0){l=!0;break}}l||r(...a),s.forEach(m=>m())}}function Xi(e){return(t,o)=>{let r=t,n=e.map(i=>i(r,o,{createPolicy:a=>a}));return r.sink={plugins:n},r.isMaster="isMaster"in r?r.isMaster:()=>!1,r.isSlave="isSlave"in r?r.isSlave:()=>!1,r.isStandalone="isStandalone"in r?r.isStandalone:()=>!1,Object.assign(r,{normalizeNode:ye(r,"normalizeNode",n),deleteBackward:ye(r,"deleteBackward",n),deleteForward:ye(r,"deleteForward",n),deleteFragment:ye(r,"deleteFragment",n),insertBreak:ye(r,"insertBreak",n),insertFragment:ye(r,"insertFragment",n),insertNode:ye(r,"insertNode",n),insertText:ye(r,"insertText",n),isInline:at(r,"isInline",n),isVoid:at(r,"isVoid",n),isMaster:at(r,"isMaster",n),isSlave:at(r,"isSlave",n),isStandalone:at(r,"isStandalone",n)}),r}}var Yi=e=>{let t=e.map(n=>n.fn);return{withSink:Xi(t),SinkEditable:ji}};import{Element as Xu}from"slate";import{ReactEditor as Yu}from"slate-react";function Ji(e,t){return Xu.isElement(t)?Yu.findPath(e,t):t}function h(e,t){return e.bind(null,t)}function oe(e,t,o){return e.bind(null,t,o)}var Ju=/mac os x|macintosh/i,Ft;function fo(){if(Ft!==void 0)return Ft;try{let{userAgent:e}=window.navigator;Ft=Ju.test(e)}catch{Ft=!1}return Ft}function Ue(e){e.preventDefault(),e.stopPropagation()}import{Editor as ta,Path as Zu}from"slate";import{Element as Zi}from"slate";function ea(e){if(typeof e=="function")return e;if(typeof e=="string")return o=>Zi.isElement(o)&&o.type===e;if(Array.isArray(e))return o=>Zi.isElement(o)&&e.includes(o.type);let t=e;throw new Error(`Expected matchNode to be a function, string or array but is ${t}`)}function E(e,t,{at:o=e.selection}={}){if(o===null)return;let r=Ji(e,o),n=ea(t);if(Zu.isPath(r)){let i=ta.node(e,r);if(i&&n(i[0]))return i}return ta.above(e,{at:r,match:n})}function lt(...e){return E(...e)?.[1]}import{jsx as ef}from"react/jsx-runtime";var k=({strokeWidth:e=1.5,...t})=>ef("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:e,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...t});import{Range as tf}from"slate";function ve(e){return e==null?!1:tf.isCollapsed(e)}import{Element as oa}from"slate";function ho(e){return Array.isArray(e)?t=>oa.isElement(t)&&e.includes(t.type):t=>oa.isElement(t)&&e==t.type}import{Editor as of}from"slate";function ra(e,t){let{selection:o}=e;if(!ve(o))return!1;let r=E(e,t,{at:o});return!!r&&of.isEnd(e,o.anchor,r[1])}import{Editor as ST}from"slate";import{Editor as rf}from"slate";function Fe(e,t){let{selection:o}=e;if(!ve(o))return!1;let r=E(e,t,{at:o});return!!r&&rf.isStart(e,o.anchor,r[1])}import{isHotkey as na}from"is-hotkey";import{Editor as ur,Element as nf,Range as af,Transforms as lf}from"slate";var sf=na(" "),mf=na("SHIFT+SPACE");function go(e,t){return o=>{if(!sf(o.nativeEvent)&&!mf(o.nativeEvent))return!1;let{selection:r}=e;if(r===null||af.isExpanded(r))return!1;let n=E(e,m=>nf.isElement(m)&&e.convertElement.isConvertibleElement(m));if(!n)return!1;let i={anchor:ur.start(e,n[1]),focus:r.focus},a=ur.string(e,i),l=t[a];if(!l)return!1;Ue(o);let s={anchor:ur.start(e,n[1]),focus:r.focus};return lf.delete(e,{at:s}),l(),!0}}import{isHotkey as cf}from"is-hotkey";function ia(e){let t=e.replace(/\bsuper\b/g,fo()?"cmd+alt":"ctrl+shift");return cf(t)}function W(e){let t=null;return function(r){t==null&&(t=Object.entries(e).map(([n,i])=>[ia(n),i]));for(let[n,i]of t)if(n(r.nativeEvent)){let a=i();if(a===!0||a===void 0)return r.preventDefault(),r.stopPropagation(),!0}return!1}}import{Editor as pf,Transforms as aa}from"slate";function la(e,t){pf.withoutNormalizing(e,()=>{aa.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:"123"},{at:t}),aa.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:null},{at:t})})}import{Editor as sa}from"slate";function st(e,t,o){let[,r]=t,n=sa.previous(e,{at:r});if(n&&o(n,t))return!0;let i=sa.next(e,{at:r});return!!(i&&o(t,i))}import{Editor as ma,Transforms as ca}from"slate";function re(e,t){ca.select(e,ma.start(e,t))}function pa(e,t){ca.select(e,ma.end(e,t))}function da(e,t){return typeof t!="function"?t:t(e)}import{Editor as fr,Element as df,Path as uf,Transforms as Wt}from"slate";function ua(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=E(e,n=>df.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;fr.withoutNormalizing(e,()=>{Wt.insertNodes(e,t,{at:o}),n&&(Wt.select(e,n),Wt.move(e))})}else{let n=uf.next(r[1]);fr.withoutNormalizing(e,()=>{Wt.insertNodes(e,t,{at:n}),Wt.select(e,fr.start(e,n))})}return!0}import{Editor as fa,Transforms as ha}from"slate";function Vt(e,t,o){fa.withoutNormalizing(e,()=>{let r=fa.node(e,o),n=da(r[0],t);ha.wrapNodes(e,n,{at:o}),ha.unwrapNodes(e,{at:[...o,0]})})}import{Editor as ff,Transforms as hf}from"slate";function bo(e,t,o){let r=Array.from(ff.nodes(e,o));if(r.length===0)return!1;for(let n of r){let[i]=n;hf.setNodes(e,t(i),{at:n[1]})}return!0}import{Editor as gf,Path as Eo,Range as xo}from"slate";import{ReactEditor as ga,useSlate as ba}from"slate-react";function Ea(e,t){if(!e)return!1;let o=e.anchor.path,r=e.focus.path;return Eo.equals(t,o)||Eo.equals(t,r)||Eo.isAncestor(t,o)||Eo.isAncestor(t,r)}function xa(e){let t=ba(),{selection:o}=t;if(!o)return!1;try{let r=ga.findPath(t,e);return Ea(o,r)}catch{return!1}}function ka(e){let t=ba(),{selection:o}=t;if(!o)return!1;try{let r=ga.findPath(t,e);if(Ea(o,r))return!0;let n=gf.range(t,r);return xo.includes(o,n.anchor)||xo.includes(o,n.focus)||xo.includes(n,o.anchor)||xo.includes(n,o.focus)}catch{return!1}}function ya(e,t){let o=t.clipboardData,{types:r}=o;if(r.length>1||r[0]!=="text/plain")return!1;let n=o.getData("text/plain");return bf(n)?(t.preventDefault(),t.stopPropagation(),e.anchor.insertLink(n),!0):!1}function bf(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"||t.protocol==="mailto:"}import{Editor as Ef,Transforms as va}from"slate";function Ta(e,t,{at:o}){let r=E(e,"anchor",{at:o});if(!r)return!1;let[,n]=r;return Ef.withoutNormalizing(e,()=>{va.removeNodes(e,{at:n}),va.insertNodes(e,{type:"image-inline",url:ro(t),alt:t,children:[{text:""}]},{at:n})}),!0}import{Editor as xf,Node as kf,Transforms as hr}from"slate";function wa(e,{href:t,title:o,text:r},{at:n}){let i=E(e,"anchor",{at:n});if(!i)return!1;let[a,l]=i;if(hr.setNodes(e,{href:t,title:o},{at:l}),r!==void 0){let s=kf.string(a);r!==s&&xf.withoutNormalizing(e,()=>{let m=a.children.length;for(let c=m-1;c>=0;c--)hr.removeNodes(e,{at:[...l,c]});hr.insertNodes(e,{text:r},{at:[...l,0]})})}return!0}import{Editor as ko,Element as yf,Range as vf,Text as Tf,Transforms as gr}from"slate";function Ia(e,t,o=t,{select:r=!0,title:n}={}){let i=e.selection||{anchor:ko.start(e,[0]),focus:ko.start(e,[0])};if(vf.isCollapsed(i)){if(gr.insertNodes(e,{type:"anchor",href:t,title:n,children:[{text:o}]},{select:r,at:i}),r&&e.selection){let a=ko.node(e,e.selection);gr.select(e,a[1])}}else gr.wrapNodes(e,{type:"anchor",href:t,title:n,children:[]},{split:!0,match:a=>Tf.isText(a)||yf.isElement(a)&&ko.isInline(e,a)})}import{Transforms as wf}from"slate";function Ma(e,{at:t}){let o=E(e,"anchor",{at:t});return o?(wf.unwrapNodes(e,{at:o[1]}),!0):!1}function Ca(e){return{insertLink:h(Ia,e),removeLink:h(Ma,e),editLink:h(wa,e),convertToEmbed:h(Ta,e)}}import{Element as Pa,Transforms as If}from"slate";function Sa(e,t){if(!Pa.isElement(t[0])||t[0].type!=="anchor")return!1;let o=t[0].children;for(let r=0;r<o.length;r++){let n=o[r];if(!(!Pa.isElement(n)||n.type!=="anchor"))return If.unwrapNodes(e,{at:[...t[1],r]}),!0}return!1}import{clsx as xh}from"clsx";import{useEffect as kh,useRef as gl}from"react";import{useSelected as yh,useSlate as vh}from"slate-react";import{createContext as Ra,useState as Cf}from"react";import{createPortal as Mf}from"react-dom";function La({children:e}){return typeof document>"u"||!document.body?null:Mf(e,document.body)}import{jsx as br,jsxs as Sf}from"react/jsx-runtime";var Er=Ra({}),Pf=Ra({});function Ba({children:e}){let[t,o]=Cf({});function r(i){o(a=>({...a,[i.type]:i}))}function n(i){o(a=>{let l={...a};return delete l[i],l})}return Sf(Er.Provider,{value:{layers:t,setLayers:o,openLayer:r,closeLayer:n},children:[e,Object.entries(t).map(([,i])=>br(La,{children:br(Pf.Provider,{value:i,children:br(i.Component,{})})},i.type))]})}import{useContext as Lf}from"react";function K(e){let{openLayer:t,closeLayer:o,layers:r}=Lf(Er);function n(a){t({type:e,Component:a})}function i(){o(e)}return{open:n,close:i,layer:r[e],type:e}}import yo from"@emotion/styled";var $a=yo("a")`
40
+ `;import{jsx as lf}from"react/jsx-runtime";var ra=e=>/[^\x00-\x7F]/.test(e);function rf(e,t){let[o]=t.getTargetRanges();if(o)try{let r=tf.toSlateRange(e,o,{exactMatch:!1,suppressThrow:!1});oa.select(e,r)}catch{}}function nf(e,t,o){return r=>{let n=e?.(r);return n!=null||r.defaultPrevented||r.inputType!=="insertText"||r.isComposing||typeof r.data!="string"||r.data.length===0||!ra(r.data)?n:(rf(t,r),r.preventDefault(),fo.insertText(t,r.data),o.current=r.data,!0)}}function af(e,t,o){return r=>{let n=e?.(r);if(n!=null||r.defaultPrevented)return n;let i=r.nativeEvent;return!(i instanceof InputEvent)||i.inputType!=="insertText"||i.isComposing||typeof i.data!="string"||i.data.length===0||!ra(i.data)?n:o.current===i.data?(o.current=null,n):(fo.insertText(t,i.data),n)}}function na(e){let t=of(),o=Zu(null),r=Yu((l,s)=>{let{selection:m}=t;if(m==null||ef.isCollapsed(m))return!1;let c=fo.fragment(t,m),d=fe(c,{enableInternalLinks:t.wysimark.enableInternalLinks}).trimEnd();return d===""?!1:(l.preventDefault(),l.clipboardData.setData("text/plain",d),l.clipboardData.setData("text/markdown",d),s.deleteSelection&&oa.delete(t),!0)},[t]);Ju(()=>{fo.normalize(t,{force:!0})},[t]);let{plugins:n}=t.sink,i=ta(()=>({...e,decorate:Gi(e.decorate,n),renderElement:Ji(e.renderElement,n),renderLeaf:Zi(e.renderLeaf,n),renderPlaceholder:ea(e.renderPlaceholder,n),onKeyDown:Qi(e.onKeyDown,n),onKeyUp:ji(e.onKeyUp,n),onPaste:Xi(e.onPaste,n),onCopy:l=>{e.onCopy?.(l),l.defaultPrevented||r(l,{deleteSelection:!1})},onCut:l=>{e.onCut?.(l),l.defaultPrevented||r(l,{deleteSelection:!0})},onDrop:Yi(e.onDrop,n),onDOMBeforeInput:nf(e.onDOMBeforeInput,t,o),onInput:af(e.onInput,t,o)}),[e.decorate,e.renderElement,e.renderLeaf,e.renderPlaceholder,e.onKeyDown,e.onKeyUp,e.onPaste,e.onCopy,e.onCut,e.onDrop,e.onDOMBeforeInput,e.onInput,e.placeholder,e.className,t,n,r]),a=ta(()=>qi(n),[n]);return lf(a,{...i})}function it(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(a){for(let s of n){let c=s.editor?.[t],d=c?.(a);if(typeof d=="boolean")return d}return r(a)}}function ke(e,t,o){let r=e[t],n=o.filter(i=>i.editor?.[t]);return function(...a){let l=!1,s=[];for(let m of n){let c=m.editor?.[t]?.(...a);if(typeof c=="function")s.push(c);else if(c===!0){l=!0;break}}l||r(...a),s.forEach(m=>m())}}function ia(e){return(t,o)=>{let r=t,n=e.map(i=>i(r,o,{createPolicy:a=>a}));return r.sink={plugins:n},r.isMaster="isMaster"in r?r.isMaster:()=>!1,r.isSlave="isSlave"in r?r.isSlave:()=>!1,r.isStandalone="isStandalone"in r?r.isStandalone:()=>!1,Object.assign(r,{normalizeNode:ke(r,"normalizeNode",n),deleteBackward:ke(r,"deleteBackward",n),deleteForward:ke(r,"deleteForward",n),deleteFragment:ke(r,"deleteFragment",n),insertBreak:ke(r,"insertBreak",n),insertFragment:ke(r,"insertFragment",n),insertNode:ke(r,"insertNode",n),insertText:ke(r,"insertText",n),isInline:it(r,"isInline",n),isVoid:it(r,"isVoid",n),isMaster:it(r,"isMaster",n),isSlave:it(r,"isSlave",n),isStandalone:it(r,"isStandalone",n)}),r}}var aa=e=>{let t=e.map(n=>n.fn);return{withSink:ia(t),SinkEditable:na}};import{Element as sf}from"slate";import{ReactEditor as mf}from"slate-react";function la(e,t){return sf.isElement(t)?mf.findPath(e,t):t}function h(e,t){return e.bind(null,t)}function ee(e,t,o){return e.bind(null,t,o)}var cf=/mac os x|macintosh/i,Ut;function ho(){if(Ut!==void 0)return Ut;try{let{userAgent:e}=window.navigator;Ut=cf.test(e)}catch{Ut=!1}return Ut}function Ue(e){e.preventDefault(),e.stopPropagation()}import{Editor as ca,Path as pf}from"slate";import{Element as sa}from"slate";function ma(e){if(typeof e=="function")return e;if(typeof e=="string")return o=>sa.isElement(o)&&o.type===e;if(Array.isArray(e))return o=>sa.isElement(o)&&e.includes(o.type);let t=e;throw new Error(`Expected matchNode to be a function, string or array but is ${t}`)}function E(e,t,{at:o=e.selection}={}){if(o===null)return;let r=la(e,o),n=ma(t);if(pf.isPath(r)){let i=ca.node(e,r);if(i&&n(i[0]))return i}return ca.above(e,{at:r,match:n})}function at(...e){return E(...e)?.[1]}import{jsx as df}from"react/jsx-runtime";var k=({strokeWidth:e=1.5,...t})=>df("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:e,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...t});import{Range as uf}from"slate";function ye(e){return e==null?!1:uf.isCollapsed(e)}import{Element as pa}from"slate";function go(e){return Array.isArray(e)?t=>pa.isElement(t)&&e.includes(t.type):t=>pa.isElement(t)&&e==t.type}import{Editor as ff}from"slate";function da(e,t){let{selection:o}=e;if(!ye(o))return!1;let r=E(e,t,{at:o});return!!r&&ff.isEnd(e,o.anchor,r[1])}import{Editor as GT}from"slate";import{Editor as hf}from"slate";function Fe(e,t){let{selection:o}=e;if(!ye(o))return!1;let r=E(e,t,{at:o});return!!r&&hf.isStart(e,o.anchor,r[1])}import{isHotkey as ua}from"is-hotkey";import{Editor as yr,Element as gf,Range as bf,Transforms as Ef}from"slate";var xf=ua(" "),kf=ua("SHIFT+SPACE");function bo(e,t){return o=>{if(!xf(o.nativeEvent)&&!kf(o.nativeEvent))return!1;let{selection:r}=e;if(r===null||bf.isExpanded(r))return!1;let n=E(e,m=>gf.isElement(m)&&e.convertElement.isConvertibleElement(m));if(!n)return!1;let i={anchor:yr.start(e,n[1]),focus:r.focus},a=yr.string(e,i),l=t[a];if(!l)return!1;Ue(o);let s={anchor:yr.start(e,n[1]),focus:r.focus};return Ef.delete(e,{at:s}),l(),!0}}import{isHotkey as yf}from"is-hotkey";function fa(e){let t=e.replace(/\bsuper\b/g,ho()?"cmd+alt":"ctrl+shift");return yf(t)}function V(e){let t=null;return function(r){t==null&&(t=Object.entries(e).map(([n,i])=>[fa(n),i]));for(let[n,i]of t)if(n(r.nativeEvent)){let a=i();if(a===!0||a===void 0)return r.preventDefault(),r.stopPropagation(),!0}return!1}}import{Editor as vf,Transforms as ha}from"slate";function ga(e,t){vf.withoutNormalizing(e,()=>{ha.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:"123"},{at:t}),ha.setNodes(e,{__DOESNT_MATTER_JUST_TO_START_NORMALIZING__:null},{at:t})})}import{Editor as ba}from"slate";function lt(e,t,o){let[,r]=t,n=ba.previous(e,{at:r});if(n&&o(n,t))return!0;let i=ba.next(e,{at:r});return!!(i&&o(t,i))}import{Editor as Ea,Transforms as xa}from"slate";function te(e,t){xa.select(e,Ea.start(e,t))}function ka(e,t){xa.select(e,Ea.end(e,t))}function ya(e,t){return typeof t!="function"?t:t(e)}import{Editor as vr,Element as Tf,Path as wf,Transforms as Ft}from"slate";function va(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=E(e,n=>Tf.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;vr.withoutNormalizing(e,()=>{Ft.insertNodes(e,t,{at:o}),n&&(Ft.select(e,n),Ft.move(e))})}else{let n=wf.next(r[1]);vr.withoutNormalizing(e,()=>{Ft.insertNodes(e,t,{at:n}),Ft.select(e,vr.start(e,n))})}return!0}import{Editor as Ta,Transforms as wa}from"slate";function Wt(e,t,o){Ta.withoutNormalizing(e,()=>{let r=Ta.node(e,o),n=ya(r[0],t);wa.wrapNodes(e,n,{at:o}),wa.unwrapNodes(e,{at:[...o,0]})})}import{Editor as If,Transforms as Mf}from"slate";function Eo(e,t,o){let r=Array.from(If.nodes(e,o));if(r.length===0)return!1;for(let n of r){let[i]=n;Mf.setNodes(e,t(i),{at:n[1]})}return!0}import{Editor as Cf,Path as xo,Range as ko}from"slate";import{ReactEditor as Ia,useSlate as Ma}from"slate-react";function Ca(e,t){if(!e)return!1;let o=e.anchor.path,r=e.focus.path;return xo.equals(t,o)||xo.equals(t,r)||xo.isAncestor(t,o)||xo.isAncestor(t,r)}function Pa(e){let t=Ma(),{selection:o}=t;if(!o)return!1;try{let r=Ia.findPath(t,e);return Ca(o,r)}catch{return!1}}function Sa(e){let t=Ma(),{selection:o}=t;if(!o)return!1;try{let r=Ia.findPath(t,e);if(Ca(o,r))return!0;let n=Cf.range(t,r);return ko.includes(o,n.anchor)||ko.includes(o,n.focus)||ko.includes(n,o.anchor)||ko.includes(n,o.focus)}catch{return!1}}function La(e,t){let o=t.clipboardData,{types:r}=o;if(r.length>1||r[0]!=="text/plain")return!1;let n=o.getData("text/plain");return Pf(n)?(t.preventDefault(),t.stopPropagation(),e.anchor.insertLink(n),!0):!1}function Pf(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"||t.protocol==="mailto:"}import{Editor as Sf,Transforms as Ra}from"slate";function Ba(e,t,{at:o}){let r=E(e,"anchor",{at:o});if(!r)return!1;let[,n]=r;return Sf.withoutNormalizing(e,()=>{Ra.removeNodes(e,{at:n}),Ra.insertNodes(e,{type:"image-inline",url:no(t),alt:t,children:[{text:""}]},{at:n})}),!0}import{Editor as $a,Transforms as st}from"slate";function Da(e,t,{at:o}){let r=E(e,["image-inline","image-block"],{at:o});if(!r)return!1;let[n,i]=r,a=se(t),l={type:"anchor",href:Ce(t),children:[{text:a}]};if(n.type==="image-block"){let s={type:"paragraph",children:[{text:""},l,{text:""}]};$a.withoutNormalizing(e,()=>{st.removeNodes(e,{at:i}),st.insertNodes(e,s,{at:i})});let m=[...i,1];return st.select(e,m),[l,m]}return $a.withoutNormalizing(e,()=>{st.removeNodes(e,{at:i}),st.insertNodes(e,l,{at:i})}),st.select(e,i),[l,i]}import{Editor as Lf,Node as Rf,Transforms as Tr}from"slate";function za(e,{href:t,title:o,text:r},{at:n}){let i=E(e,"anchor",{at:n});if(!i)return!1;let[a,l]=i;if(Tr.setNodes(e,{href:t,title:o},{at:l}),r!==void 0){let s=Rf.string(a);r!==s&&Lf.withoutNormalizing(e,()=>{let m=a.children.length;for(let c=m-1;c>=0;c--)Tr.removeNodes(e,{at:[...l,c]});Tr.insertNodes(e,{text:r},{at:[...l,0]})})}return!0}import{Editor as yo,Element as Bf,Range as $f,Text as Df,Transforms as wr}from"slate";function Na(e,t,o=t,{select:r=!0,title:n}={}){let i=e.selection||{anchor:yo.start(e,[0]),focus:yo.start(e,[0])};if($f.isCollapsed(i)){if(wr.insertNodes(e,{type:"anchor",href:t,title:n,children:[{text:o}]},{select:r,at:i}),r&&e.selection){let a=yo.node(e,e.selection);wr.select(e,a[1])}}else wr.wrapNodes(e,{type:"anchor",href:t,title:n,children:[]},{split:!0,match:a=>Df.isText(a)||Bf.isElement(a)&&yo.isInline(e,a)})}import{Transforms as zf}from"slate";function Ha(e,{at:t}){let o=E(e,"anchor",{at:t});return o?(zf.unwrapNodes(e,{at:o[1]}),!0):!1}function Aa(e){return{insertLink:h(Na,e),removeLink:h(Ha,e),editLink:h(za,e),convertToEmbed:h(Ba,e),convertToLink:h(Da,e)}}import{Element as Oa,Transforms as Nf}from"slate";function Ua(e,t){if(!Oa.isElement(t[0])||t[0].type!=="anchor")return!1;let o=t[0].children;for(let r=0;r<o.length;r++){let n=o[r];if(!(!Oa.isElement(n)||n.type!=="anchor"))return Nf.unwrapNodes(e,{at:[...t[1],r]}),!0}return!1}import{clsx as Lh}from"clsx";import{useEffect as Rh,useRef as wl}from"react";import{useSelected as Bh,useSlate as $h}from"slate-react";import{createContext as Wa,useState as Af}from"react";import{createPortal as Hf}from"react-dom";function Fa({children:e}){return typeof document>"u"||!document.body?null:Hf(e,document.body)}import{jsx as Ir,jsxs as Uf}from"react/jsx-runtime";var Mr=Wa({}),Of=Wa({});function Va({children:e}){let[t,o]=Af({});function r(i){o(a=>({...a,[i.type]:i}))}function n(i){o(a=>{let l={...a};return delete l[i],l})}return Uf(Mr.Provider,{value:{layers:t,setLayers:o,openLayer:r,closeLayer:n},children:[e,Object.entries(t).map(([,i])=>Ir(Fa,{children:Ir(Of.Provider,{value:i,children:Ir(i.Component,{})})},i.type))]})}import{useContext as Ff}from"react";function F(e){let{openLayer:t,closeLayer:o,layers:r}=Ff(Mr);function n(a){t({type:e,Component:a})}function i(){o(e)}return{open:n,close:i,layer:r[e],type:e}}import vo from"@emotion/styled";var _a=vo("a")`
41
41
  /**
42
42
  * Link colors
43
43
  */
@@ -59,10 +59,10 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
59
59
  &.--selected {
60
60
  background: var(--blue-50);
61
61
  }
62
- `,xr=yo("span")`
62
+ `,Cr=vo("span")`
63
63
  display: inline;
64
64
  padding: 0 1px 0 0;
65
- `,KI=yo("span")`
65
+ `,fM=vo("span")`
66
66
  position: fixed;
67
67
  width: 100px;
68
68
  background: var(--shade-50);
@@ -71,14 +71,14 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
71
71
  border: 1px solid var(--shade-400);
72
72
  overflow: hidden;
73
73
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
74
- `,GI=yo("span")`
74
+ `,hM=vo("span")`
75
75
  position: absolute;
76
76
  left: 0;
77
77
  top: 0;
78
78
  height: 14px;
79
79
  background: var(--blue-400);
80
80
  transition: width 100ms linear;
81
- `;import uh from"@emotion/styled";import{useCallback as Co,useRef as fh,useState as hh}from"react";import{useSlateStatic as gh}from"slate-react";import{useRef as Bf}from"react";import Rf from"@emotion/styled";var Da=Rf("div")`
81
+ `;import wh from"@emotion/styled";import{useCallback as Ro,useRef as Ih,useState as Mh}from"react";import{useSlateStatic as Ch}from"slate-react";import{useRef as Vf}from"react";import Wf from"@emotion/styled";var Ka=Wf("div")`
82
82
  position: fixed;
83
83
  user-select: none;
84
84
  top: 0;
@@ -87,7 +87,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
87
87
  bottom: 0;
88
88
  overflow-y: auto;
89
89
  background: rgba(0, 0, 0, 0.01);
90
- `;import{jsx as $f}from"react/jsx-runtime";function Le({close:e}){let t=Bf(null);return $f(Da,{ref:t,onClick:e})}var ge={cmd:"\u2318",ctrl:"\u2303",shift:"\u21E7",opt:"\u2325",enter:"\u23CE"},Df={shift:ge.shift,opt:ge.opt,alt:ge.opt,ctrl:ge.ctrl,mod:ge.cmd,cmd:ge.cmd,enter:ge.enter,super:`${ge.opt}${ge.cmd}`},zf={alt:"ALT",ctrl:"CTRL",opt:"ALT",shift:"SHIFT",mod:"CTRL",cmd:"CTRL",enter:ge.enter,super:"CTRL+SHIFT"};function za(e,t){let o=e.findIndex(r=>r===t);o!==-1&&e.splice(o,1)}function Nf(e){let t=[];return Object.entries(Df).forEach(([o,r])=>{e.includes(o)&&(t.push(r),za(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("")}function Hf(e){let t=[];return Object.entries(zf).forEach(([o,r])=>{e.includes(o)&&(t.push(r),za(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("+")}function vo(e){let t=e.toLowerCase().split("+");return fo()?Nf(t):Hf(t)}import{useRef as jf}from"react";import{useSlateStatic as Xf}from"slate-react";function kr(e){let t=e.getBoundingClientRect();return{top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height}}function Na(e){let t=kr(e),{scrollY:o}=window;return Object.assign(t,{top:t.top+o,bottom:t.bottom+o})}function yr(){let e=document.documentElement.clientWidth||document.body.clientWidth;return{top:0,right:e,bottom:window.innerHeight,left:0,width:e,height:window.innerHeight}}function Ha(){let e=yr();return Object.assign(e,{top:window.scrollY,bottom:window.scrollY+e.height})}var Aa=Af;function Af(e,t){for(var o={},r=Object.keys(e),n=r.length,i=0;i<n;i++){var a=r[i];o[a]=t(e[a],a,e)}return o}function vr(e,t){return Aa(e,r=>{let n=r instanceof HTMLElement?r:r.current;return n?t(n):null})}import{useEffect as Wf}from"react";import Of from"lodash.throttle";import{useMemo as Uf,useState as Ff}from"react";function To(e=100){let[t,o]=Ff(0),r=Uf(()=>Of(()=>{o(n=>n+1)},e,{trailing:!0}),[e]);return Object.assign(r,{counter:t})}function Tr(){let e=To();return Wf(()=>(e(),window.addEventListener("resize",e),window.addEventListener("scroll",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e)}),[]),e}function ne(e,t){let o=Tr(),r=vr(e,n=>Na(n));return t(r,Ha(),o)}function Re(e,t,o,{margin:r=0}={}){if(e==null)return{...o,left:-1024};let{top:n}=o,{left:i}=o,a=t.right-t.left-r*2;return e.width>=a?i=t.left+r:(i+e.width>t.right-r&&(i=t.right-e.width-r),i<t.left+r&&(i=t.left+r)),{left:i,top:n}}import wr from"@emotion/styled";import Vf from"@emotion/styled";var ie=Vf(Ut)`
90
+ `;import{jsx as _f}from"react/jsx-runtime";function Re({close:e}){let t=Vf(null);return _f(Ka,{ref:t,onClick:e})}var ge={cmd:"\u2318",ctrl:"\u2303",shift:"\u21E7",opt:"\u2325",enter:"\u23CE"},Kf={shift:ge.shift,opt:ge.opt,alt:ge.opt,ctrl:ge.ctrl,mod:ge.cmd,cmd:ge.cmd,enter:ge.enter,super:`${ge.opt}${ge.cmd}`},Gf={alt:"ALT",ctrl:"CTRL",opt:"ALT",shift:"SHIFT",mod:"CTRL",cmd:"CTRL",enter:ge.enter,super:"CTRL+SHIFT"};function Ga(e,t){let o=e.findIndex(r=>r===t);o!==-1&&e.splice(o,1)}function qf(e){let t=[];return Object.entries(Kf).forEach(([o,r])=>{e.includes(o)&&(t.push(r),Ga(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("")}function Qf(e){let t=[];return Object.entries(Gf).forEach(([o,r])=>{e.includes(o)&&(t.push(r),Ga(e,o))}),t.push(...e.map(o=>o.toUpperCase())),t.join("+")}function To(e){let t=e.toLowerCase().split("+");return ho()?qf(t):Qf(t)}import{useRef as ah}from"react";import{useSlateStatic as lh}from"slate-react";function Pr(e){let t=e.getBoundingClientRect();return{top:t.top,right:t.right,bottom:t.bottom,left:t.left,width:t.width,height:t.height}}function qa(e){let t=Pr(e),{scrollY:o}=window;return Object.assign(t,{top:t.top+o,bottom:t.bottom+o})}function Sr(){let e=document.documentElement.clientWidth||document.body.clientWidth;return{top:0,right:e,bottom:window.innerHeight,left:0,width:e,height:window.innerHeight}}function Qa(){let e=Sr();return Object.assign(e,{top:window.scrollY,bottom:window.scrollY+e.height})}var ja=jf;function jf(e,t){for(var o={},r=Object.keys(e),n=r.length,i=0;i<n;i++){var a=r[i];o[a]=t(e[a],a,e)}return o}function Lr(e,t){return ja(e,r=>{let n=r instanceof HTMLElement?r:r.current;return n?t(n):null})}import{useEffect as Zf}from"react";import Xf from"lodash.throttle";import{useMemo as Yf,useState as Jf}from"react";function wo(e=100){let[t,o]=Jf(0),r=Yf(()=>Xf(()=>{o(n=>n+1)},e,{trailing:!0}),[e]);return Object.assign(r,{counter:t})}function Rr(){let e=wo();return Zf(()=>(e(),window.addEventListener("resize",e),window.addEventListener("scroll",e),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e)}),[]),e}function oe(e,t){let o=Rr(),r=Lr(e,n=>qa(n));return t(r,Qa(),o)}function Be(e,t,o,{margin:r=0}={}){if(e==null)return{...o,left:-1024};let{top:n}=o,{left:i}=o,a=t.right-t.left-r*2;return e.width>=a?i=t.left+r:(i+e.width>t.right-r&&(i=t.right-e.width-r),i<t.left+r&&(i=t.left+r)),{left:i,top:n}}import Br from"@emotion/styled";import eh from"@emotion/styled";var re=eh(Ot)`
91
91
  position: absolute;
92
92
  z-index: 1000;
93
93
  border: 1px solid var(--table-border-color);
@@ -116,14 +116,14 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
116
116
  * even if we did, it looks better this way.
117
117
  */
118
118
  /* transition: left 100ms, top 100ms; */
119
- `;var Oa=wr(ie)`
119
+ `;var Xa=Br(re)`
120
120
  width: 24em;
121
121
  padding: 0;
122
122
  overflow: hidden;
123
- `,_t=wr("div")`
123
+ `,Vt=Br("div")`
124
124
  display: flex;
125
125
  gap: 0.5em;
126
- `,Kt=wr("input")`
126
+ `,_t=Br("input")`
127
127
  flex: 1 1 auto;
128
128
  padding: 0.5em 0.75em;
129
129
  border-radius: 0.25em;
@@ -134,7 +134,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
134
134
  &:focus {
135
135
  outline: 2px solid var(--blue-200);
136
136
  }
137
- `;import Fa from"@emotion/styled";import _f from"@emotion/styled";var Ua=_f(Ut)`
137
+ `;import Ja from"@emotion/styled";import th from"@emotion/styled";var Ya=th(Ot)`
138
138
  border: 1px solid var(--shade-300); /* shade-300 */
139
139
  border-radius: 0.5em;
140
140
  color: rgb(39 39 42); /* shade-800 */
@@ -150,11 +150,11 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
150
150
  */
151
151
  outline: 2px solid var(--select-editor-color) !important;
152
152
  }
153
- `;var Wa=Fa("div")`
153
+ `;var Za=Ja("div")`
154
154
  padding: 2em;
155
155
  flex: 1;
156
156
  min-height: 0;
157
- `,Va=Fa(Ua)`
157
+ `,el=Ja(Ya)`
158
158
  /**
159
159
  * We use this to make sure the top of the container is rounded even though
160
160
  * the toolbar inside is square. We keep the toolbar square so that as the
@@ -177,7 +177,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
177
177
  flex-direction: column;
178
178
  flex: 1;
179
179
  min-height: 0;
180
- `;import Ir from"@emotion/styled";var _a=Ir(ie)`
180
+ `;import $r from"@emotion/styled";var tl=$r(re)`
181
181
  position: absolute;
182
182
  padding-top: 0.5em;
183
183
  padding-bottom: 0.5em;
@@ -187,7 +187,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
187
187
  * Prevent clicks from stealing focus from the editor
188
188
  */
189
189
  user-select: none;
190
- `,Ka=Ir("div")`
190
+ `,ol=$r("div")`
191
191
  display: flex;
192
192
  z-index: 10;
193
193
  padding: 0 1em 0 1.5em;
@@ -227,12 +227,12 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
227
227
  &:hover {
228
228
  background: var(--blue-50);
229
229
  }
230
- `,Ga=Ir("div")`
230
+ `,rl=$r("div")`
231
231
  height: 1px;
232
232
  background: var(--shade-200);
233
233
  margin-top: 0.25em;
234
234
  margin-bottom: 0.25em;
235
- `;import Gt from"@emotion/styled";var qa=Gt("div")`
235
+ `;import Kt from"@emotion/styled";var nl=Kt("div")`
236
236
  /**
237
237
  * This flex rule applies to the "display: flex;" of the parent container.
238
238
  * Ensures the toolbar does not shrink or grow vertically.
@@ -271,22 +271,22 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
271
271
  3em + 1px
272
272
  ); // $ToolbarDivider height + border-bottom of 1px above
273
273
  overflow: hidden;
274
- `,Qa=Gt("div")`
274
+ `,il=Kt("div")`
275
275
  display: inline-block;
276
276
  height: calc(
277
277
  3em + 1px
278
278
  ); // $ToolbarDivider height + border-bottom of 1px above
279
- `,ja=Gt("div")`
279
+ `,al=Kt("div")`
280
280
  display: inline-block;
281
281
  height: 3em;
282
282
  padding: 0 0.375em;
283
- `,Xa=Gt("div")`
283
+ `,ll=Kt("div")`
284
284
  display: inline-block;
285
285
  background: var(--shade-300);
286
286
  opacity: 50%;
287
287
  width: 1px;
288
288
  height: 3em;
289
- `,Ya=Gt("div")`
289
+ `,sl=Kt("div")`
290
290
  box-sizing: border-box;
291
291
  position: relative;
292
292
  display: inline-block;
@@ -336,7 +336,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
336
336
  margin-left: -0.25em;
337
337
  opacity: 0.375;
338
338
  }
339
- `;import{useCallback as Kf}from"react";import{ReactEditor as Gf}from"slate-react";import{Fragment as Qf,jsx as mt,jsxs as qf}from"react/jsx-runtime";function Ja({editor:e,item:t,close:o,dest:r}){let n=K("menu"),i=Kf(()=>{if(t.Component){let a=t.Component;n.open(()=>mt(a,{dest:r,close:n.close}))}else t.action&&(t.action(e),Gf.focus(e),o())},[e,t]);return mt(Qf,{children:qf(Ka,{onClick:i,children:[mt("div",{className:"--icon",children:mt(t.icon,{})}),mt("div",{className:"--title",children:t.title}),mt("div",{className:"--hotkey",children:t.hotkey?vo(t.hotkey):void 0})]})})}import{Fragment as Yf,jsx as wo,jsxs as Jf}from"react/jsx-runtime";function ct({dest:e,items:t,close:o}){let r=Xf(),n=jf(null),i=ne({src:n,dest:e},({dest:a})=>a?{left:a.left-8,top:a.top+a.height}:{left:0,top:0});return Jf(Yf,{children:[wo(Le,{close:o}),wo(_a,{ref:n,style:i,children:t.map((a,l)=>a==="divider"?wo(Ga,{},l):a.show&&!a.show(r)?null:wo(Ja,{editor:r,item:a,close:o,dest:e},l))})]})}import{useCallback as ol}from"react";import Za from"@emotion/styled";import{jsx as th,jsxs as oh}from"react/jsx-runtime";function Mr(e){return e.getBoundingClientRect()}var Zf=Za("div")`
339
+ `;import{useCallback as oh}from"react";import{ReactEditor as rh}from"slate-react";import{Fragment as ih,jsx as mt,jsxs as nh}from"react/jsx-runtime";function ml({editor:e,item:t,close:o,dest:r}){let n=F("menu"),i=oh(()=>{if(t.Component){let a=t.Component;n.open(()=>mt(a,{dest:r,close:n.close}))}else t.action&&(t.action(e),rh.focus(e),o())},[e,t]);return mt(ih,{children:nh(ol,{onClick:i,children:[mt("div",{className:"--icon",children:mt(t.icon,{})}),mt("div",{className:"--title",children:t.title}),mt("div",{className:"--hotkey",children:t.hotkey?To(t.hotkey):void 0})]})})}import{Fragment as sh,jsx as Io,jsxs as mh}from"react/jsx-runtime";function ct({dest:e,items:t,close:o}){let r=lh(),n=ah(null),i=oe({src:n,dest:e},({dest:a})=>a?{left:a.left-8,top:a.top+a.height}:{left:0,top:0});return mh(sh,{children:[Io(Re,{close:o}),Io(tl,{ref:n,style:i,children:t.map((a,l)=>a==="divider"?Io(rl,{},l):a.show&&!a.show(r)?null:Io(ml,{editor:r,item:a,close:o,dest:e},l))})]})}import{useCallback as ul}from"react";import cl from"@emotion/styled";import{jsx as dh,jsxs as uh}from"react/jsx-runtime";function Dr(e){return e.getBoundingClientRect()}var ch=cl("div")`
340
340
  position: fixed;
341
341
  z-index: 10;
342
342
  -webkit-font-smoothing: antialiased;
@@ -352,12 +352,12 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
352
352
  background: var(--shade-700);
353
353
  border-radius: 0.25em;
354
354
  white-space: nowrap;
355
- `,eh=Za("span")`
355
+ `,ph=cl("span")`
356
356
  margin-left: 0.75em;
357
357
  font-size: 0.875em;
358
358
  font-weight: 500;
359
359
  color: var(--shade-400);
360
- `;function el({title:e,hotkey:t,dest:o}){let r=Mr(o);return oh(Zf,{style:{left:r.left,top:`calc(${r.top}px - 2em)`},children:[e,t?th(eh,{children:t}):null]})}import rh from"@emotion/styled";import{jsx as ih}from"react/jsx-runtime";var nh=rh("span")`
360
+ `;function pl({title:e,hotkey:t,dest:o}){let r=Dr(o);return uh(ch,{style:{left:r.left,top:`calc(${r.top}px - 2em)`},children:[e,t?dh(ph,{children:t}):null]})}import fh from"@emotion/styled";import{jsx as gh}from"react/jsx-runtime";var hh=fh("span")`
361
361
  position: fixed;
362
362
  z-index: 10;
363
363
  width: 0;
@@ -365,7 +365,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
365
365
  border-left: 0.375em solid transparent;
366
366
  border-right: 0.375em solid transparent;
367
367
  border-top: 0.375em solid var(--shade-700);
368
- `;function tl({dest:e}){let t=Mr(e);return ih(nh,{style:{left:`calc(${t.left+t.width/2}px - 0.375em)`,top:`calc(${t.top}px - 0.5em)`}})}import{jsx as rl}from"react/jsx-runtime";function ae({title:e,hotkey:t},o=[]){let r=K("tooltip-label"),n=K("tooltip-triangle"),i=ol(l=>{let s=l.currentTarget;e!==void 0&&(r.open(()=>rl(el,{title:e,hotkey:typeof t=="function"?t():t,dest:s})),n.open(()=>rl(tl,{dest:s})))},[e,t,r,n,...o]),a=ol(()=>{r.close(),n.close()},[r,n,...o]);return{onMouseEnter:i,onMouseLeave:a}}import mh from"@emotion/styled";import{useCallback as De,useRef as cl,useState as Ve}from"react";import{Node as pl}from"slate";import{useSlateStatic as ch}from"slate-react";import Be from"@emotion/styled";var Te=Be("div")`
368
+ `;function dl({dest:e}){let t=Dr(e);return gh(hh,{style:{left:`calc(${t.left+t.width/2}px - 0.375em)`,top:`calc(${t.top}px - 0.5em)`}})}import{jsx as fl}from"react/jsx-runtime";function ne({title:e,hotkey:t},o=[]){let r=F("tooltip-label"),n=F("tooltip-triangle"),i=ul(l=>{let s=l.currentTarget;e!==void 0&&(r.open(()=>fl(pl,{title:e,hotkey:typeof t=="function"?t():t,dest:s})),n.open(()=>fl(dl,{dest:s})))},[e,t,r,n,...o]),a=ul(()=>{r.close(),n.close()},[r,n,...o]);return{onMouseEnter:i,onMouseLeave:a}}import kh from"@emotion/styled";import{useCallback as Te,useRef as yl,useState as Ve}from"react";import{Node as vl}from"slate";import{useSlateStatic as yh}from"slate-react";import $e from"@emotion/styled";var ve=$e("div")`
369
369
  margin: 0.5em 0;
370
370
  &:first-of-type {
371
371
  margin-top: 0;
@@ -373,15 +373,15 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
373
373
  &:last-of-type {
374
374
  margin-bottom: 0;
375
375
  }
376
- `,qt=Be("div")`
376
+ `,Gt=$e("div")`
377
377
  font-size: 0.9375em;
378
378
  margin-bottom: 0.25em;
379
379
  color: var(--shade-700);
380
- `,Qt=Be("div")`
380
+ `,qt=$e("div")`
381
381
  font-size: 0.875em;
382
382
  margin-top: 0.25em;
383
383
  color: var(--shade-500);
384
- `,nl=Be("input")`
384
+ `,hl=$e("input")`
385
385
  box-sizing: border-box;
386
386
  width: 100%;
387
387
  height: 6em;
@@ -395,7 +395,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
395
395
  &:focus {
396
396
  outline: 2px solid var(--blue-200);
397
397
  }
398
- `,Io=Be("input")`
398
+ `,Mo=$e("input")`
399
399
  box-sizing: border-box;
400
400
  width: 100%;
401
401
  padding: 0.5em 0.75em;
@@ -407,7 +407,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
407
407
  &:focus {
408
408
  outline: 2px solid var(--blue-200);
409
409
  }
410
- `,il=Be("div")`
410
+ `,gl=$e("div")`
411
411
  /* Center vertically and horizontally */
412
412
  display: flex;
413
413
  align-items: center;
@@ -421,7 +421,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
421
421
  font-size: 1.25em;
422
422
  stroke-width: 2px;
423
423
  }
424
- `,al=Be(il)`
424
+ `,bl=$e(gl)`
425
425
  color: var(--blue-50);
426
426
  background: var(--blue-500);
427
427
  outline: 0px solid white;
@@ -433,7 +433,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
433
433
  svg {
434
434
  color: var(--blue-200);
435
435
  }
436
- `,ll=Be(il)`
436
+ `,El=$e(gl)`
437
437
  color: var(--shade-500);
438
438
  background: var(--shade-200);
439
439
  outline: 0px solid white;
@@ -445,7 +445,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
445
445
  svg {
446
446
  color: var(--shade-400);
447
447
  }
448
- `;import{useRef as ah,useCallback as We}from"react";import ml from"@emotion/styled";import{jsx as sl}from"react/jsx-runtime";var lh=ml.div`
448
+ `;import{useRef as bh,useCallback as We}from"react";import kl from"@emotion/styled";import{jsx as xl}from"react/jsx-runtime";var Eh=kl.div`
449
449
  display: flex;
450
450
  align-items: center;
451
451
  justify-content: center;
@@ -460,12 +460,12 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
460
460
  &:active {
461
461
  cursor: grabbing;
462
462
  }
463
- `,sh=ml.div`
463
+ `,xh=kl.div`
464
464
  width: 32px;
465
465
  height: 4px;
466
466
  background: #ccc;
467
467
  border-radius: 2px;
468
- `;function $e({onDrag:e}){let t=ah(null),o=We((m,c)=>{t.current={x:m,y:c}},[]),r=We((m,c)=>{if(!t.current)return;let d=m-t.current.x,p=c-t.current.y;t.current={x:m,y:c},e(d,p)},[e]),n=We(()=>{t.current=null},[]),i=We(m=>{m.preventDefault(),o(m.clientX,m.clientY);let c=p=>{r(p.clientX,p.clientY)},d=()=>{n(),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",d)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",d)},[o,r,n]),a=We(m=>{if(m.touches.length!==1)return;let c=m.touches[0];o(c.clientX,c.clientY)},[o]),l=We(m=>{if(m.touches.length!==1)return;let c=m.touches[0];r(c.clientX,c.clientY)},[r]),s=We(()=>{n()},[n]);return sl(lh,{onMouseDown:i,onTouchStart:a,onTouchMove:l,onTouchEnd:s,children:sl(sh,{})})}import{Fragment as dh,jsx as N,jsxs as be}from"react/jsx-runtime";var ph=mh(ie)`
468
+ `;function De({onDrag:e}){let t=bh(null),o=We((m,c)=>{t.current={x:m,y:c}},[]),r=We((m,c)=>{if(!t.current)return;let d=m-t.current.x,p=c-t.current.y;t.current={x:m,y:c},e(d,p)},[e]),n=We(()=>{t.current=null},[]),i=We(m=>{m.preventDefault(),o(m.clientX,m.clientY);let c=p=>{r(p.clientX,p.clientY)},d=()=>{n(),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",d)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",d)},[o,r,n]),a=We(m=>{if(m.touches.length!==1)return;let c=m.touches[0];o(c.clientX,c.clientY)},[o]),l=We(m=>{if(m.touches.length!==1)return;let c=m.touches[0];r(c.clientX,c.clientY)},[r]),s=We(()=>{n()},[n]);return xl(Eh,{onMouseDown:i,onTouchStart:a,onTouchMove:l,onTouchEnd:s,children:xl(xh,{})})}import{Fragment as Th,jsx as N,jsxs as be}from"react/jsx-runtime";var vh=kh(re)`
469
469
  position: absolute;
470
470
  width: 20em;
471
471
  padding: 0;
@@ -494,7 +494,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
494
494
  background: white;
495
495
  box-shadow: 0 1px 2px rgb(0 0 0 / 12%);
496
496
  }
497
- `;function dl({destAnchor:e,destStartEdge:t,element:o}){let r=K("dialog"),n=cl(null),[i,a]=Ve({x:0,y:0}),l=De((z,Z)=>{a(ee=>({x:ee.x+z,y:ee.y+Z}))},[]),s=ne({src:n,destAnchor:e,destStartEdge:t},({src:z,destAnchor:Z,destStartEdge:ee},Rt)=>Re(z,Rt,{left:ee.left,top:Z.top+Z.height},{margin:16})),m={...s,left:s.left+i.x,top:s.top+i.y},c=ch(),d=ue(o.href),p=d?$t(o.href):"",u=tt(p),g=d?u.target:"",[x,C]=Ve(d?"internal":"external"),[L,T]=Ve(!1),[U,I]=Ve(o.href),[$,w]=Ve(g),[P,S]=Ve(d?u.display||pl.string(o):pl.string(o)),[D,M]=Ve(o.title||""),G=cl({href:U,target:$,text:P,title:D,mode:x,embed:L});G.current={href:U,target:$,text:P,title:D,mode:x,embed:L};let v=De(z=>{I(z.target.value)},[]),B=De(z=>{S(z.target.value)},[]),de=De(z=>{M(z.target.value)},[]),oo=De(z=>{let Z=z.target.value,ee=no(Z);w(ee.target),ee.display!==void 0&&S(ee.display)},[]),Je=De(z=>{C(z),z==="external"&&I(Z=>ue(Z)?"":Z)},[]),Lt=De(()=>{r.open(()=>N(Mo,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]),tr=De(()=>{let{href:z,target:Z,text:ee,title:Rt,mode:Bt,embed:R}=G.current;if(Bt==="internal"){let H=Z.trim();if(H==="")return;let te=ee.trim(),wn=te&&te!==ke(H)?`${H}|${te}`:H;if(R){c.anchor.convertToEmbed(wn,{at:o}),r.close();return}c.anchor.editLink({href:Ze(wn),text:te||ke(H),title:void 0},{at:o})}else{if(z.trim()===""||ue(z))return;c.anchor.editLink({href:z,text:ee,title:Rt},{at:o})}Lt()},[c,o,r,Lt]);return be(ph,{ref:n,contentEditable:!1,style:m,children:[N($e,{onDrag:l}),be("div",{style:{padding:"1em"},children:[c.wysimark.enableInternalLinks?N(Te,{children:be("div",{className:"--link-type",children:[N("button",{type:"button",className:x==="external"?"--active":void 0,onClick:()=>Je("external"),children:f("linkTypeExternal")}),N("button",{type:"button",className:x==="internal"?"--active":void 0,onClick:()=>Je("internal"),children:f("linkTypeInternal")})]})}):null,x==="internal"?be(dh,{children:[be(Te,{children:[N(qt,{children:f("internalLinkTarget")}),N(Io,{type:"text",value:$,onChange:oo}),N(Qt,{children:f("internalLinkTargetHint")})]}),be(Te,{children:[be("label",{style:{display:"flex",alignItems:"center",gap:"0.5em",cursor:"pointer"},children:[N("input",{type:"checkbox",checked:L,onChange:z=>T(z.target.checked)}),f("internalLinkEmbed")]}),N(Qt,{children:f("internalLinkEmbedHint")})]})]}):be(Te,{children:[N(qt,{children:f("linkUrl")}),N(nl,{as:"textarea",value:U,onChange:v})]}),x==="external"||x==="internal"?be(Te,{children:[N(qt,{children:f("linkText")}),N(Io,{type:"text",value:P,onChange:B}),N(Qt,{children:f("linkTextHint")})]}):null,x==="external"?be(Te,{children:[N(qt,{children:f("tooltipText")}),N(Io,{type:"text",value:D,onChange:de}),N(Qt,{children:f("tooltipHint")})]}):null,N(Te,{children:N(al,{onClick:tr,children:f("apply")})}),N(Te,{children:N(ll,{onClick:Lt,children:f("cancel")})})]})]})}import{jsx as ze}from"react/jsx-runtime";var Cr=e=>ze(k,{...e,children:ze("path",{d:"M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6M11 13l9-9M15 4h5v5"})}),ul=e=>ze(k,{...e,children:ze("path",{d:"m9 15 3-3m2-2 1-1M11 6l.463-.536a5 5 0 0 1 7.071 7.072L18 13M3 3l18 18M13 18l-.397.534a5.068 5.068 0 0 1-7.127 0 4.972 4.972 0 0 1 0-7.071L6 11"})}),fl=e=>ze(k,{...e,children:ze("path",{d:"M4 20h4L18.5 9.5a1.5 1.5 0 0 0-4-4L4 16v4M13.5 6.5l4 4"})}),hl=e=>ze(k,{...e,children:ze("path",{d:"M18 6L6 18M6 6l12 12"})});import{jsx as Q,jsxs as _e}from"react/jsx-runtime";var bh=uh(ie)`
497
+ `;function Co({destAnchor:e,destStartEdge:t,element:o,initialEmbed:r=!1,onCancel:n}){let i=F("dialog"),a=yl(null),[l,s]=Ve({x:0,y:0}),m=Te((z,j)=>{s(w=>({x:w.x+z,y:w.y+j}))},[]),c=oe({src:a,destAnchor:e,destStartEdge:t},({src:z,destAnchor:j,destStartEdge:w},U)=>Be(z,U,{left:w.left,top:j.top+j.height},{margin:16})),d={...c,left:c.left+l.x,top:c.top+l.y},p=yh(),u=ue(o.href),g=u?$t(o.href):"",x=et(g),C=u?x.target:"",[I,M]=Ve(u?"internal":"external"),[O,P]=Ve(r),[$,T]=Ve(o.href),[L,R]=Ve(C),[D,S]=Ve(u?x.display||vl.string(o):vl.string(o)),[G,v]=Ve(o.title||""),B=yl({href:$,target:L,text:D,title:G,mode:I,embed:O});B.current={href:$,target:L,text:D,title:G,mode:I,embed:O};let pe=Te(z=>{T(z.target.value)},[]),to=Te(z=>{S(z.target.value)},[]),Rt=Te(z=>{v(z.target.value)},[]),ar=Te(z=>{let j=z.target.value,w=io(j);R(w.target),w.display!==void 0&&S(w.display)},[]),oo=Te(z=>{M(z),z==="external"&&T(j=>ue(j)?"":j)},[]),Je=Te(()=>{i.open(()=>N(Po,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]),lr=Te(()=>{if(n){n();return}Je()},[n,Je]),sr=Te(()=>{let{href:z,target:j,text:w,title:U,mode:de,embed:tu}=B.current;if(de==="internal"){let Bt=j.trim();if(Bt==="")return;let ro=w.trim(),$n=ro&&ro!==se(Bt)?`${Bt}|${ro}`:Bt;if(tu){p.anchor.convertToEmbed($n,{at:o}),i.close();return}p.anchor.editLink({href:Ce($n),text:ro||se(Bt),title:void 0},{at:o})}else{if(z.trim()===""||ue(z))return;p.anchor.editLink({href:z,text:w,title:U},{at:o})}Je()},[p,o,i,Je]);return be(vh,{ref:a,contentEditable:!1,style:d,children:[N(De,{onDrag:m}),be("div",{style:{padding:"1em"},children:[p.wysimark.enableInternalLinks?N(ve,{children:be("div",{className:"--link-type",children:[N("button",{type:"button",className:I==="external"?"--active":void 0,onClick:()=>oo("external"),children:f("linkTypeExternal")}),N("button",{type:"button",className:I==="internal"?"--active":void 0,onClick:()=>oo("internal"),children:f("linkTypeInternal")})]})}):null,I==="internal"?be(Th,{children:[be(ve,{children:[N(Gt,{children:f("internalLinkTarget")}),N(Mo,{type:"text",value:L,onChange:ar}),N(qt,{children:f("internalLinkTargetHint")})]}),be(ve,{children:[be("label",{style:{display:"flex",alignItems:"center",gap:"0.5em",cursor:"pointer"},children:[N("input",{type:"checkbox",checked:O,onChange:z=>P(z.target.checked)}),f("internalLinkEmbed")]}),N(qt,{children:f("internalLinkEmbedHint")})]})]}):be(ve,{children:[N(Gt,{children:f("linkUrl")}),N(hl,{as:"textarea",value:$,onChange:pe})]}),I==="external"||I==="internal"?be(ve,{children:[N(Gt,{children:f("linkText")}),N(Mo,{type:"text",value:D,onChange:to}),N(qt,{children:f("linkTextHint")})]}):null,I==="external"?be(ve,{children:[N(Gt,{children:f("tooltipText")}),N(Mo,{type:"text",value:G,onChange:Rt}),N(qt,{children:f("tooltipHint")})]}):null,N(ve,{children:N(bl,{onClick:sr,children:f("apply")})}),N(ve,{children:N(El,{onClick:lr,children:f("cancel")})})]})]})}import{jsx as ze}from"react/jsx-runtime";var zr=e=>ze(k,{...e,children:ze("path",{d:"M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6M11 13l9-9M15 4h5v5"})}),Tl=e=>ze(k,{...e,children:ze("path",{d:"m9 15 3-3m2-2 1-1M11 6l.463-.536a5 5 0 0 1 7.071 7.072L18 13M3 3l18 18M13 18l-.397.534a5.068 5.068 0 0 1-7.127 0 4.972 4.972 0 0 1 0-7.071L6 11"})}),So=e=>ze(k,{...e,children:ze("path",{d:"M4 20h4L18.5 9.5a1.5 1.5 0 0 0-4-4L4 16v4M13.5 6.5l4 4"})}),Lo=e=>ze(k,{...e,children:ze("path",{d:"M18 6L6 18M6 6l12 12"})});import{jsx as Q,jsxs as _e}from"react/jsx-runtime";var Ph=wh(re)`
498
498
  position: absolute;
499
499
  width: 20em;
500
500
  z-index: 1000;
@@ -603,10 +603,10 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
603
603
  height: 1.25em;
604
604
  stroke-width: 1.5;
605
605
  }
606
- `;function Eh(e){try{let t=new URL(e);return{hostname:t.hostname,pathname:t.pathname}}catch{return{hostname:"",pathname:""}}}function Mo({destAnchor:e,destStartEdge:t,element:o}){let r=K("dialog"),n=gh(),i=fh(null),a=Eh(o.href),l=ue(o.href),s=l?Ln($t(o.href)):"",m=l?n.wysimark.renderInternalLinkPreview?.(s):null,[c,d]=hh({x:0,y:0}),p=Co(($,w)=>{d(P=>({x:P.x+$,y:P.y+w}))},[]),u=ne({src:i,destAnchor:e,destStartEdge:t},({src:$,destAnchor:w,destStartEdge:P},S)=>Re($,S,{left:P.left,top:w.top+w.height},{margin:16})),g={...u,left:u.left+c.x,top:u.top+c.y},x=ae({title:"\u30EA\u30F3\u30AF\u3092\u524A\u9664"}),C=ae({title:"\u30EA\u30F3\u30AF\u3092\u7DE8\u96C6"}),L=ae({title:"\u9589\u3058\u308B"}),T=Co(()=>{r.close()},[r]),U=Co(()=>{n.anchor.removeLink({at:o}),r.close()},[n,r]),I=Co(()=>{C.onMouseLeave(),r.open(()=>Q(dl,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]);return _e(bh,{ref:i,contentEditable:!1,style:g,children:[Q($e,{onDrag:p}),_e("div",{style:{display:"flex",padding:"1em"},children:[l?_e("span",{className:"--internal-link",children:[Q(Cr,{}),_e("div",{className:"--url",children:[Q("div",{className:"--hostname",children:f("linkTypeInternal")}),Q("div",{className:"--pathname",children:s}),Q("div",{className:"--internal-preview",children:m??s})]})]}):_e("a",{className:"--link",href:o.href,target:"_blank",rel:"noreferrer",children:[Q(Cr,{}),_e("div",{className:"--url",children:[Q("div",{className:"--hostname",children:a.hostname}),a.pathname===""||a.pathname==="/"?null:Q("div",{className:"--pathname",children:a.pathname}),o.title==null||o.title===""?null:Q("div",{className:"--tooltip",children:o.title})]})]}),_e("span",{className:"--icons",children:[Q("span",{className:"--icon",onClick:U,onMouseEnter:x.onMouseEnter,onMouseLeave:x.onMouseLeave,children:Q(ul,{})}),Q("span",{className:"--icon",onMouseEnter:C.onMouseEnter,onMouseLeave:C.onMouseLeave,onClick:I,children:Q(fl,{})}),Q("span",{className:"--icon",onClick:T,onMouseEnter:L.onMouseEnter,onMouseLeave:L.onMouseLeave,children:Q(hl,{})})]})]})]})}import{jsx as Po,jsxs as Th}from"react/jsx-runtime";function bl({element:e,attributes:t,children:o}){let r=gl(null),n=gl(null),i=yh(),a=vh(),l=K("dialog"),s=ue(e.href);return kh(()=>{let m=n.current,c=r.current;if(!m||!c)return;let d=a.selection&&a.selection.anchor.offset!==a.selection.focus.offset;i&&!d?setTimeout(()=>{l.open(()=>Po(Mo,{destAnchor:m,destStartEdge:c,element:e}))}):l.close()},[i,e]),Th($a,{className:xh({"--selected":i,"--internal-link":s}),href:s?void 0:e.href,target:s?void 0:e.target,"data-internal-link":s?"true":void 0,onClick:s?m=>m.preventDefault():void 0,...t,ref:n,children:[Po(xr,{ref:r,contentEditable:!1}),Po("span",{children:o}),Po(xr,{contentEditable:!1})]})}import{jsx as wh}from"react/jsx-runtime";var El=y((e,t,{createPolicy:o})=>(e.anchor=Ca(e),o({name:"anchor",editor:{isInline(r){if(r.type==="anchor")return!0},normalizeNode:h(Sa,e)},editableProps:{onPaste:h(ya,e),renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="anchor")return wh(bl,{element:r,attributes:n,children:i})}}})));import{Editor as So,Transforms as yl}from"slate";import{Element as xl,Path as kl}from"slate";function Pr(e,t,o){if(!t||!o||kl.equals(t[1],o[1]))return!0;let r=E(e,i=>xl.isElement(i)&&e.isMaster(i),{at:t[1]}),n=E(e,i=>xl.isElement(i)&&e.isMaster(i),{at:o[1]});return!!(!r&&!n||r&&n&&kl.equals(r[1],n[1]))}var vl=y(e=>(e.atomicDelete=!0,{name:"atomic-delete",editor:{deleteBackward(){if(e.selection==null)return!1;let t=So.node(e,e.selection),o=So.previous(e,{mode:"lowest"});return Pr(e,t,o)?!1:(yl.move(e,{unit:"character",reverse:!0}),!0)},deleteForward(){if(e.selection==null)return!1;let t=So.node(e,e.selection),o=So.next(e,{mode:"lowest"});return Pr(e,t,o)?!1:(yl.move(e,{unit:"character"}),!0)}}}));import{Transforms as pg}from"slate";import{ReactEditor as dg}from"slate-react";import{Editor as Ih,Transforms as Tl}from"slate";import{ReactEditor as Mh}from"slate-react";function Ch(e){}function Ph(e,t,o,r){let{selection:n}=e;if(Tl.insertNodes(e,{type:"image-block",url:t,alt:o||"",title:r||"",width:320,height:240,children:[{text:""}]}),!n){let i=Ih.end(e,[]);Tl.select(e,i),Mh.focus(e)}}function wl(e){return{noop:h(Ch,e),insertImageFromUrl:h(Ph,e)}}function Il(e,t){return!1}import{useSlateStatic as sg}from"slate-react";import Sh from"@emotion/styled";var Ml=Sh("div")`
606
+ `;function Sh(e){try{let t=new URL(e);return{hostname:t.hostname,pathname:t.pathname}}catch{return{hostname:"",pathname:""}}}function Po({destAnchor:e,destStartEdge:t,element:o}){let r=F("dialog"),n=Ch(),i=Ih(null),a=Sh(o.href),l=ue(o.href),s=l?On($t(o.href)):"",m=l?n.wysimark.renderInternalLinkPreview?.(s):null,[c,d]=Mh({x:0,y:0}),p=Ro(($,T)=>{d(L=>({x:L.x+$,y:L.y+T}))},[]),u=oe({src:i,destAnchor:e,destStartEdge:t},({src:$,destAnchor:T,destStartEdge:L},R)=>Be($,R,{left:L.left,top:T.top+T.height},{margin:16})),g={...u,left:u.left+c.x,top:u.top+c.y},x=ne({title:"\u30EA\u30F3\u30AF\u3092\u524A\u9664"}),C=ne({title:"\u30EA\u30F3\u30AF\u3092\u7DE8\u96C6"}),I=ne({title:"\u9589\u3058\u308B"}),M=Ro(()=>{r.close()},[r]),O=Ro(()=>{n.anchor.removeLink({at:o}),r.close()},[n,r]),P=Ro(()=>{C.onMouseLeave(),r.open(()=>Q(Co,{destAnchor:e,destStartEdge:t,element:o}))},[e,t,o]);return _e(Ph,{ref:i,contentEditable:!1,style:g,children:[Q(De,{onDrag:p}),_e("div",{style:{display:"flex",padding:"1em"},children:[l?_e("span",{className:"--internal-link",children:[Q(zr,{}),_e("div",{className:"--url",children:[Q("div",{className:"--hostname",children:f("linkTypeInternal")}),Q("div",{className:"--pathname",children:s}),Q("div",{className:"--internal-preview",children:m??s})]})]}):_e("a",{className:"--link",href:o.href,target:"_blank",rel:"noreferrer",children:[Q(zr,{}),_e("div",{className:"--url",children:[Q("div",{className:"--hostname",children:a.hostname}),a.pathname===""||a.pathname==="/"?null:Q("div",{className:"--pathname",children:a.pathname}),o.title==null||o.title===""?null:Q("div",{className:"--tooltip",children:o.title})]})]}),_e("span",{className:"--icons",children:[Q("span",{className:"--icon",onClick:O,onMouseEnter:x.onMouseEnter,onMouseLeave:x.onMouseLeave,children:Q(Tl,{})}),Q("span",{className:"--icon",onMouseEnter:C.onMouseEnter,onMouseLeave:C.onMouseLeave,onClick:P,children:Q(So,{})}),Q("span",{className:"--icon",onClick:M,onMouseEnter:I.onMouseEnter,onMouseLeave:I.onMouseLeave,children:Q(Lo,{})})]})]})]})}import{jsx as Bo,jsxs as Dh}from"react/jsx-runtime";function Il({element:e,attributes:t,children:o}){let r=wl(null),n=wl(null),i=Bh(),a=$h(),l=F("dialog"),s=ue(e.href);return Rh(()=>{let m=n.current,c=r.current;if(!m||!c)return;let d=a.selection&&a.selection.anchor.offset!==a.selection.focus.offset;i&&!d?setTimeout(()=>{l.open(()=>Bo(Po,{destAnchor:m,destStartEdge:c,element:e}))}):l.close()},[i,e]),Dh(_a,{className:Lh({"--selected":i,"--internal-link":s}),href:s?void 0:e.href,target:s?void 0:e.target,"data-internal-link":s?"true":void 0,onClick:s?m=>m.preventDefault():void 0,...t,ref:n,children:[Bo(Cr,{ref:r,contentEditable:!1}),Bo("span",{children:o}),Bo(Cr,{contentEditable:!1})]})}import{jsx as zh}from"react/jsx-runtime";var Ml=y((e,t,{createPolicy:o})=>(e.anchor=Aa(e),o({name:"anchor",editor:{isInline(r){if(r.type==="anchor")return!0},normalizeNode:h(Ua,e)},editableProps:{onPaste:h(La,e),renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="anchor")return zh(Il,{element:r,attributes:n,children:i})}}})));import{Editor as $o,Transforms as Sl}from"slate";import{Element as Cl,Path as Pl}from"slate";function Nr(e,t,o){if(!t||!o||Pl.equals(t[1],o[1]))return!0;let r=E(e,i=>Cl.isElement(i)&&e.isMaster(i),{at:t[1]}),n=E(e,i=>Cl.isElement(i)&&e.isMaster(i),{at:o[1]});return!!(!r&&!n||r&&n&&Pl.equals(r[1],n[1]))}var Ll=y(e=>(e.atomicDelete=!0,{name:"atomic-delete",editor:{deleteBackward(){if(e.selection==null)return!1;let t=$o.node(e,e.selection),o=$o.previous(e,{mode:"lowest"});return Nr(e,t,o)?!1:(Sl.move(e,{unit:"character",reverse:!0}),!0)},deleteForward(){if(e.selection==null)return!1;let t=$o.node(e,e.selection),o=$o.next(e,{mode:"lowest"});return Nr(e,t,o)?!1:(Sl.move(e,{unit:"character"}),!0)}}}));import{Transforms as Pg}from"slate";import{ReactEditor as Sg}from"slate-react";import{Editor as Nh,Transforms as Rl}from"slate";import{ReactEditor as Hh}from"slate-react";function Ah(e){}function Oh(e,t,o,r){let{selection:n}=e;if(Rl.insertNodes(e,{type:"image-block",url:t,alt:o||"",title:r||"",width:320,height:240,children:[{text:""}]}),!n){let i=Nh.end(e,[]);Rl.select(e,i),Hh.focus(e)}}function Bl(e){return{noop:h(Ah,e),insertImageFromUrl:h(Oh,e)}}function $l(e,t){return!1}import{useSlateStatic as Ig}from"slate-react";import Uh from"@emotion/styled";var Dl=Uh("div")`
607
607
  display: block;
608
608
  margin: 1em 0;
609
- `;import{clsx as ig}from"clsx";import{useState as ls}from"react";import{useSelected as ag}from"slate-react";import Cl from"@emotion/styled";var Pl=Cl("span")`
609
+ `;import{clsx as gg}from"clsx";import{useState as hs}from"react";import{useSelected as bg}from"slate-react";import zl from"@emotion/styled";var Nl=zl("span")`
610
610
  /**
611
611
  * In order for this container to wrap tightly (without space), it needs to be
612
612
  * an "inline-block". If it's just an "inline" we end up with spacing
@@ -618,7 +618,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
618
618
  * so that we can place UI controls for the image in and around the image.
619
619
  */
620
620
  position: relative;
621
- `,Sl=Cl("img")`
621
+ `,Hl=zl("img")`
622
622
  /**
623
623
  * TODO:
624
624
  *
@@ -681,7 +681,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
681
681
  .--dragging > & {
682
682
  transition: border-radius 250ms;
683
683
  }
684
- `;import{clsx as Dh}from"clsx";import{useCallback as zl,useEffect as zh,useRef as Ro}from"react";import{Transforms as Nl}from"slate";import{ReactEditor as Lr,useSlateStatic as Nh}from"slate-react";import{useEffect as Lh}from"react";function Ll(){let e=To();return Lh(()=>(e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}),[]),e}import Rl from"@emotion/styled";var Bl=Rl("span")`
684
+ `;import{clsx as Kh}from"clsx";import{useCallback as Vl,useEffect as Gh,useRef as zo}from"react";import{Transforms as _l}from"slate";import{ReactEditor as Ar,useSlateStatic as qh}from"slate-react";import{useEffect as Fh}from"react";function Al(){let e=wo();return Fh(()=>(e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}),[]),e}import Ol from"@emotion/styled";var Ul=Ol("span")`
685
685
  position: absolute;
686
686
  display: block;
687
687
  /**
@@ -708,7 +708,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
708
708
  /* background: green; */
709
709
  width: 1.25em;
710
710
  }
711
- `,$l=Rl("span")`
711
+ `,Fl=Ol("span")`
712
712
  position: absolute;
713
713
  display: block;
714
714
  background: var(--select-color);
@@ -801,7 +801,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
801
801
  .--small > & > .--bar-right {
802
802
  left: calc(50% + 1px);
803
803
  }
804
- `;function Sr({value:e,min:t,max:o}){if(!(o>=t))throw new Error("Expected max >= min but is not");return Math.max(t,Math.min(o,e))}import{ReactEditor as Rh}from"slate-react";function Lo(e,t){e=Math.round(e);let o=t.width/t.height;return{width:e,height:Math.round(e/o)}}function Bh(e,t){e=Math.round(e);let o=t.width/t.height;return{width:Math.round(e*o),height:e}}function $h(e,t){let o=e.width/e.height,r=t.width/t.height;if(o>=r){if(e.width>t.width)return Lo(t.width,e)}else if(e.height>t.height)return Bh(t.height,e);return e}function Ke(e,t,o){switch(o.type){case"bounds":return $h(t,o);case"scale":return{width:Math.round(t.width*o.scale),height:Math.round(t.height*o.scale)}}}function Dl(e){let t=Rh.toDOMNode(e,e),o=getComputedStyle(t),r=parseInt(o.paddingLeft,10)+parseInt(o.paddingRight,10);return t.clientWidth-r}import{Fragment as Oh,jsx as jt,jsxs as Ah}from"react/jsx-runtime";function Hh(e,t){let r=Lr.toDOMNode(e,t).querySelector("img");if(!r)throw new Error("Image Element could not be found but should exist");return r.getBoundingClientRect()}function Hl({element:e,srcSize:t,size:o,setSize:r,isDragging:n,setIsDragging:i}){let a=Nh(),l=Ro(null),s=Ro(null),m=Ro(null),c=Ro(null);Ll();let d=Dl(a),p=o.width,u=Math.min(t.width,d),g=Math.min(12,t.width),x=zl(T=>{Ue(T),i(!0);let U=T.clientX,$=Hh(a,e).width,w={...o},P=D=>{let M=Sr({value:$+D.clientX-U,min:g,max:u});w=Lo(M,t),r(w)},S=()=>{document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",S),l.current=null,s.current=null;let D=Lr.findPath(a,e),M={width:w.width,height:w.height};r(M),Nl.setNodes(a,M,{at:D}),i(!1)};l.current=P,s.current=S,document.addEventListener("mousemove",P),document.addEventListener("mouseup",S)},[t.width,t.height,o.width,e]),C=zl(T=>{Ue(T),i(!0);let U=T.changedTouches[0].clientX,I=o.width,$={...o},w=S=>{let D=S.changedTouches[0],M=Sr({value:I+D.clientX-U,min:g,max:u});$=Lo(M,t),r($)},P=()=>{document.removeEventListener("touchmove",w),document.removeEventListener("touchend",P),m.current=null,c.current=null;let S=Lr.findPath(a,e);Nl.setNodes(a,{width:$.width,height:$.height},{at:S}),i(!1)};m.current=w,c.current=P,document.addEventListener("touchmove",w),document.addEventListener("touchend",P)},[t.width,t.height,o.width,e]);zh(()=>()=>{l.current&&document.removeEventListener("mousemove",l.current),s.current&&document.removeEventListener("mouseup",s.current),m.current&&document.removeEventListener("touchmove",m.current),c.current&&document.removeEventListener("touchend",c.current)},[]);let L=Dh({"--center":p<u&&p>g,"--left":p>=u&&p>g,"--right":p<=g&&p<u,"--dragging":n,"--small":p<=64||o.height<=64});return jt(Oh,{children:jt(Bl,{className:L,onMouseDown:x,onTouchStart:C,children:Ah($l,{children:[jt("span",{className:"--bar --bar-left"}),jt("span",{className:"--bar --bar-center"}),jt("span",{className:"--bar --bar-right"})]})})})}import Uh from"@emotion/styled";var Al=Uh("span")`
804
+ `;function Hr({value:e,min:t,max:o}){if(!(o>=t))throw new Error("Expected max >= min but is not");return Math.max(t,Math.min(o,e))}import{ReactEditor as Wh}from"slate-react";function Do(e,t){e=Math.round(e);let o=t.width/t.height;return{width:e,height:Math.round(e/o)}}function Vh(e,t){e=Math.round(e);let o=t.width/t.height;return{width:Math.round(e*o),height:e}}function _h(e,t){let o=e.width/e.height,r=t.width/t.height;if(o>=r){if(e.width>t.width)return Do(t.width,e)}else if(e.height>t.height)return Vh(t.height,e);return e}function Ke(e,t,o){switch(o.type){case"bounds":return _h(t,o);case"scale":return{width:Math.round(t.width*o.scale),height:Math.round(t.height*o.scale)}}}function Wl(e){let t=Wh.toDOMNode(e,e),o=getComputedStyle(t),r=parseInt(o.paddingLeft,10)+parseInt(o.paddingRight,10);return t.clientWidth-r}import{Fragment as Xh,jsx as Qt,jsxs as jh}from"react/jsx-runtime";function Qh(e,t){let r=Ar.toDOMNode(e,t).querySelector("img");if(!r)throw new Error("Image Element could not be found but should exist");return r.getBoundingClientRect()}function Kl({element:e,srcSize:t,size:o,setSize:r,isDragging:n,setIsDragging:i}){let a=qh(),l=zo(null),s=zo(null),m=zo(null),c=zo(null);Al();let d=Wl(a),p=o.width,u=Math.min(t.width,d),g=Math.min(12,t.width),x=Vl(M=>{Ue(M),i(!0);let O=M.clientX,$=Qh(a,e).width,T={...o},L=D=>{let S=Hr({value:$+D.clientX-O,min:g,max:u});T=Do(S,t),r(T)},R=()=>{document.removeEventListener("mousemove",L),document.removeEventListener("mouseup",R),l.current=null,s.current=null;let D=Ar.findPath(a,e),S={width:T.width,height:T.height};r(S),_l.setNodes(a,S,{at:D}),i(!1)};l.current=L,s.current=R,document.addEventListener("mousemove",L),document.addEventListener("mouseup",R)},[t.width,t.height,o.width,e]),C=Vl(M=>{Ue(M),i(!0);let O=M.changedTouches[0].clientX,P=o.width,$={...o},T=R=>{let D=R.changedTouches[0],S=Hr({value:P+D.clientX-O,min:g,max:u});$=Do(S,t),r($)},L=()=>{document.removeEventListener("touchmove",T),document.removeEventListener("touchend",L),m.current=null,c.current=null;let R=Ar.findPath(a,e);_l.setNodes(a,{width:$.width,height:$.height},{at:R}),i(!1)};m.current=T,c.current=L,document.addEventListener("touchmove",T),document.addEventListener("touchend",L)},[t.width,t.height,o.width,e]);Gh(()=>()=>{l.current&&document.removeEventListener("mousemove",l.current),s.current&&document.removeEventListener("mouseup",s.current),m.current&&document.removeEventListener("touchmove",m.current),c.current&&document.removeEventListener("touchend",c.current)},[]);let I=Kh({"--center":p<u&&p>g,"--left":p>=u&&p>g,"--right":p<=g&&p<u,"--dragging":n,"--small":p<=64||o.height<=64});return Qt(Xh,{children:Qt(Ul,{className:I,onMouseDown:x,onTouchStart:C,children:jh(Fl,{children:[Qt("span",{className:"--bar --bar-left"}),Qt("span",{className:"--bar --bar-center"}),Qt("span",{className:"--bar --bar-right"})]})})})}import Yh from"@emotion/styled";var Gl=Yh("span")`
805
805
  position: absolute;
806
806
  /**
807
807
  * The status appears with a 1px gap from the outline.
@@ -823,7 +823,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
823
823
 
824
824
  /* force numbers to be monospaced for better alignment */
825
825
  font-variant-numeric: tabular-nums;
826
- `;import{jsxs as Fh}from"react/jsx-runtime";function Ol({size:e}){return Fh(Al,{children:[e.width," \xD7 ",e.height]})}import Wh from"@emotion/styled";var Ul=Wh("span")`
826
+ `;import{jsxs as Jh}from"react/jsx-runtime";function ql({size:e}){return Jh(Gl,{children:[e.width," \xD7 ",e.height]})}import Zh from"@emotion/styled";var Ql=Zh("span")`
827
827
  position: absolute;
828
828
  /**
829
829
  * On top of the image +1 for space inside outline, +2 for outline,
@@ -854,7 +854,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
854
854
  }
855
855
  display: flex;
856
856
  gap: 0.25em;
857
- `;import Fl from"@emotion/styled";var Bo=Fl("span")`
857
+ `;import jl from"@emotion/styled";var No=jl("span")`
858
858
  /* font-size: 0.75em; */
859
859
  border-radius: 0.5em;
860
860
  display: flex;
@@ -867,7 +867,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
867
867
  * see the border of the buttons.
868
868
  */
869
869
  outline: 1px solid white;
870
- `,pt=Fl("span")`
870
+ `,pt=jl("span")`
871
871
  font-size: 0.75em;
872
872
  line-height: 2em;
873
873
  padding: 0 0.625em;
@@ -921,17 +921,48 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
921
921
  font-size: 1.33em;
922
922
  line-height: 1em;
923
923
  }
924
- `;import{clsx as Vh}from"clsx";import{useCallback as _h}from"react";import{Transforms as Kh}from"slate";import{ReactEditor as Gh,useSlateStatic as qh}from"slate-react";import{jsx as Qh}from"react/jsx-runtime";function Wl({element:e,preset:t,size:o,setSize:r,srcSize:n}){let i=qh(),a=Ke(o,n,t),l=ae({title:t.title,hotkey:`${a.width}x${a.height}`}),s=_h(()=>{let u=Gh.findPath(i,e),g=Ke(o,n,t);r(g),Kh.setNodes(i,g,{at:u})},[e,t,o,n]),c=!(t.type==="scale"?!0:t.width<=n.width||t.height<=n.height),d=o.width===a.width&&o.height===a.height,p=Vh({"--disabled":c,"--selected":!c&&d});return Qh(pt,{className:p,onClick:c?void 0:s,onMouseEnter:l.onMouseEnter,onMouseLeave:l.onMouseLeave,children:t.name})}import{jsx as Vl}from"react/jsx-runtime";function _l({element:e,size:t,setSize:o,srcSize:r,presets:n}){return Vl(Bo,{children:n.map((i,a)=>Vl(Wl,{element:e,preset:i,size:t,setSize:o,srcSize:r},a))})}import{useCallback as Yh}from"react";import{useSlateStatic as Jh}from"slate-react";import{jsx as $o,jsxs as ql}from"react/jsx-runtime";var Kl=e=>ql(k,{...e,children:[$o("rect",{width:6,height:6,x:4,y:5,rx:1}),$o("path",{d:"M4 15h16M4 19h16"})]}),Gl=e=>ql(k,{...e,children:[$o("rect",{width:6,height:6,x:9,y:5,rx:1}),$o("path",{d:"M4 7h1M4 11h1M19 7h1M19 11h1M4 15h16M4 19h16"})]});import{Editor as jh,Transforms as Ql}from"slate";import{ReactEditor as Xh}from"slate-react";function jl(e,t){if(!t.width||!t.height||!t.srcWidth||!t.srcHeight)return;let o={width:t.width,height:t.height},r={width:t.srcWidth,height:t.srcHeight},n=Xh.findPath(e,t);jh.withoutNormalizing(e,()=>{let i=Ke(o,r,{name:"initial-inline-image",title:"",type:"bounds",width:24,height:24});Ql.setNodes(e,{type:"image-inline",...i},{at:n}),Ql.wrapNodes(e,{type:"paragraph",children:[]},{at:n})})}import{jsx as Xl}from"react/jsx-runtime";function Yl({element:e}){let t=Jh(),o=ae({title:"Inline Image",hotkey:"In a line with text"}),r=Yh(()=>{e.type==="image-block"&&jl(t,e)},[t,e]);return Xl(pt,{className:e.type==="image-inline"?"--selected":"",onClick:e.type==="image-inline"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:Xl(Gl,{})})}import{useCallback as tg}from"react";import{useSlateStatic as og}from"slate-react";import{Editor as Jl,Element as Zh,Text as Zl,Transforms as Do}from"slate";import{ReactEditor as eg}from"slate-react";function es(e,t){if(!t.width||!t.height||!t.srcWidth||!t.srcHeight)return;let o={width:t.width,height:t.height},r={width:t.srcWidth,height:t.srcHeight},n=eg.findPath(e,t);Jl.withoutNormalizing(e,()=>{let i=Ke(o,r,{name:"initial-block-image",title:"",type:"bounds",width:320,height:320});Do.setNodes(e,{type:"image-block",...i},{at:n});let a=E(e,x=>Zh.isElement(x)&&Jl.isBlock(e,x)&&x.type!=="image-block");if(!a)throw new Error("This shouldn't happen");let[l,s]=a,m=l.children,c=l.children.length,d=n.slice(-1)[0],p=m[c-1];d===c-2&&Zl.isText(p)&&p.text===""&&Do.removeNodes(e,{at:[...s,c-1]});let u=m[0],g=d===1&&Zl.isText(u)&&u.text==="";g&&Do.removeNodes(e,{at:[...s,0]}),Do.liftNodes(e,{at:[...s,g?d-1:d]})})}import{jsx as ts}from"react/jsx-runtime";function os({element:e}){let t=og(),o=ae({title:"Block Image",hotkey:"On a line by itself"}),r=tg(()=>{e.type==="image-inline"&&es(t,e)},[t,e]);return ts(pt,{className:e.type==="image-block"?"--selected":"",onClick:e.type==="image-block"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:ts(Kl,{})})}import{jsx as rs,jsxs as rg}from"react/jsx-runtime";function ns({element:e}){return rg(Bo,{children:[rs(os,{element:e}),rs(Yl,{element:e})]})}import{jsx as is,jsxs as ng}from"react/jsx-runtime";function as({element:e,size:t,setSize:o,srcSize:r,presets:n}){return ng(Ul,{children:[is(ns,{element:e}),is(_l,{element:e,size:t,setSize:o,srcSize:r,presets:n})]})}import{jsx as zo,jsxs as lg}from"react/jsx-runtime";function No({element:e,presets:t}){let o=e.url,r=ag(),[n,i]=ls(!1),[a,l]=ls(e.srcWidth&&e.srcHeight&&e.width&&e.height?{width:e.width,height:e.height}:null),s=e.srcWidth&&e.srcHeight?{width:e.srcWidth,height:e.srcHeight}:null,m=r&&a&&s,c=ig({"--selected":r,"--dragging":n,"--small":a&&(a.width<=64||a.height<=64)});return lg(Pl,{className:c,children:[zo(Sl,{src:o,width:a?.width,height:a?.height}),m?zo(as,{element:e,size:a,setSize:l,srcSize:s,presets:t}):null,n&&a?zo(Ol,{size:a}):null,m?zo(Hl,{element:e,srcSize:s,isDragging:n,setIsDragging:i,size:a,setSize:l}):null]})}import{jsx as Rr,jsxs as ss}from"react/jsx-runtime";function ms({element:e,attributes:t,children:o}){let r=sg(),n=r.wysimark.renderInternalEmbed;return et(e.url)&&n?ss("div",{...t,children:[Rr("div",{contentEditable:!1,children:n(Dt(e.url))}),o]}):ss("div",{...t,children:[Rr(Ml,{contentEditable:!1,children:Rr(No,{element:e,presets:r.image.imageBlockPresets})}),o]})}import{useSlateStatic as cg}from"slate-react";import mg from"@emotion/styled";var cs=mg("span")`
924
+ `;import{clsx as eg}from"clsx";import{useCallback as tg}from"react";import{Transforms as og}from"slate";import{ReactEditor as rg,useSlateStatic as ng}from"slate-react";import{jsx as ig}from"react/jsx-runtime";function Xl({element:e,preset:t,size:o,setSize:r,srcSize:n}){let i=ng(),a=Ke(o,n,t),l=ne({title:t.title,hotkey:`${a.width}x${a.height}`}),s=tg(()=>{let u=rg.findPath(i,e),g=Ke(o,n,t);r(g),og.setNodes(i,g,{at:u})},[e,t,o,n]),c=!(t.type==="scale"?!0:t.width<=n.width||t.height<=n.height),d=o.width===a.width&&o.height===a.height,p=eg({"--disabled":c,"--selected":!c&&d});return ig(pt,{className:p,onClick:c?void 0:s,onMouseEnter:l.onMouseEnter,onMouseLeave:l.onMouseLeave,children:t.name})}import{jsx as Yl}from"react/jsx-runtime";function Jl({element:e,size:t,setSize:o,srcSize:r,presets:n}){return Yl(No,{children:n.map((i,a)=>Yl(Xl,{element:e,preset:i,size:t,setSize:o,srcSize:r},a))})}import{useCallback as sg}from"react";import{useSlateStatic as mg}from"slate-react";import{jsx as Ho,jsxs as ts}from"react/jsx-runtime";var Zl=e=>ts(k,{...e,children:[Ho("rect",{width:6,height:6,x:4,y:5,rx:1}),Ho("path",{d:"M4 15h16M4 19h16"})]}),es=e=>ts(k,{...e,children:[Ho("rect",{width:6,height:6,x:9,y:5,rx:1}),Ho("path",{d:"M4 7h1M4 11h1M19 7h1M19 11h1M4 15h16M4 19h16"})]});import{Editor as ag,Transforms as os}from"slate";import{ReactEditor as lg}from"slate-react";function rs(e,t){if(!t.width||!t.height||!t.srcWidth||!t.srcHeight)return;let o={width:t.width,height:t.height},r={width:t.srcWidth,height:t.srcHeight},n=lg.findPath(e,t);ag.withoutNormalizing(e,()=>{let i=Ke(o,r,{name:"initial-inline-image",title:"",type:"bounds",width:24,height:24});os.setNodes(e,{type:"image-inline",...i},{at:n}),os.wrapNodes(e,{type:"paragraph",children:[]},{at:n})})}import{jsx as ns}from"react/jsx-runtime";function is({element:e}){let t=mg(),o=ne({title:"Inline Image",hotkey:"In a line with text"}),r=sg(()=>{e.type==="image-block"&&rs(t,e)},[t,e]);return ns(pt,{className:e.type==="image-inline"?"--selected":"",onClick:e.type==="image-inline"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:ns(es,{})})}import{useCallback as dg}from"react";import{useSlateStatic as ug}from"slate-react";import{Editor as as,Element as cg,Text as ls,Transforms as Ao}from"slate";import{ReactEditor as pg}from"slate-react";function ss(e,t){if(!t.width||!t.height||!t.srcWidth||!t.srcHeight)return;let o={width:t.width,height:t.height},r={width:t.srcWidth,height:t.srcHeight},n=pg.findPath(e,t);as.withoutNormalizing(e,()=>{let i=Ke(o,r,{name:"initial-block-image",title:"",type:"bounds",width:320,height:320});Ao.setNodes(e,{type:"image-block",...i},{at:n});let a=E(e,x=>cg.isElement(x)&&as.isBlock(e,x)&&x.type!=="image-block");if(!a)throw new Error("This shouldn't happen");let[l,s]=a,m=l.children,c=l.children.length,d=n.slice(-1)[0],p=m[c-1];d===c-2&&ls.isText(p)&&p.text===""&&Ao.removeNodes(e,{at:[...s,c-1]});let u=m[0],g=d===1&&ls.isText(u)&&u.text==="";g&&Ao.removeNodes(e,{at:[...s,0]}),Ao.liftNodes(e,{at:[...s,g?d-1:d]})})}import{jsx as ms}from"react/jsx-runtime";function cs({element:e}){let t=ug(),o=ne({title:"Block Image",hotkey:"On a line by itself"}),r=dg(()=>{e.type==="image-inline"&&ss(t,e)},[t,e]);return ms(pt,{className:e.type==="image-block"?"--selected":"",onClick:e.type==="image-block"?void 0:r,onMouseEnter:o.onMouseEnter,onMouseLeave:o.onMouseLeave,children:ms(Zl,{})})}import{jsx as ps,jsxs as fg}from"react/jsx-runtime";function ds({element:e}){return fg(No,{children:[ps(cs,{element:e}),ps(is,{element:e})]})}import{jsx as us,jsxs as hg}from"react/jsx-runtime";function fs({element:e,size:t,setSize:o,srcSize:r,presets:n}){return hg(Ql,{children:[us(ds,{element:e}),us(Jl,{element:e,size:t,setSize:o,srcSize:r,presets:n})]})}import{jsx as Oo,jsxs as Eg}from"react/jsx-runtime";function Uo({element:e,presets:t}){let o=e.url,r=bg(),[n,i]=hs(!1),[a,l]=hs(e.srcWidth&&e.srcHeight&&e.width&&e.height?{width:e.width,height:e.height}:null),s=e.srcWidth&&e.srcHeight?{width:e.srcWidth,height:e.srcHeight}:null,m=r&&a&&s,c=gg({"--selected":r,"--dragging":n,"--small":a&&(a.width<=64||a.height<=64)});return Eg(Nl,{className:c,children:[Oo(Hl,{src:o,width:a?.width,height:a?.height}),m?Oo(fs,{element:e,size:a,setSize:l,srcSize:s,presets:t}):null,n&&a?Oo(ql,{size:a}):null,m?Oo(Kl,{element:e,srcSize:s,isDragging:n,setIsDragging:i,size:a,setSize:l}):null]})}import xg from"@emotion/styled";import{useCallback as kg,useRef as gs}from"react";import{Transforms as yg}from"slate";import{ReactEditor as Or,useSelected as vg,useSlateStatic as Tg}from"slate-react";import{jsx as dt,jsxs as bs}from"react/jsx-runtime";var wg=xg("span")`
925
+ position: relative;
926
+ display: inline-block;
927
+
928
+ .--wiki-embed-toolbar {
929
+ position: absolute;
930
+ top: 0.25em;
931
+ right: 0.25em;
932
+ display: flex;
933
+ gap: 0.125em;
934
+ padding: 0.125em;
935
+ border-radius: 0.25em;
936
+ background: var(--shade-100);
937
+ box-shadow: 0 1px 2px rgb(0 0 0 / 12%);
938
+ }
939
+
940
+ .--wiki-embed-toolbar button {
941
+ display: flex;
942
+ align-items: center;
943
+ border: 0;
944
+ border-radius: 0.1875em;
945
+ padding: 0.1875em;
946
+ color: var(--shade-500);
947
+ background: transparent;
948
+ cursor: pointer;
949
+ }
950
+
951
+ .--wiki-embed-toolbar button:hover {
952
+ color: var(--shade-700);
953
+ background: white;
954
+ }
955
+ `;function Fo({element:e}){let t=Tg(),o=vg(),r=F("dialog"),n=gs(null),i=gs(null),a=t.wysimark.renderInternalEmbed,l=pr(e.url),s=kg(c=>{c.preventDefault(),c.stopPropagation();let d=n.current,p=i.current;if(!d||!p)return;let u=Or.findPath(t,e),g=t.anchor.convertToLink(l,{at:u});if(!g)return;let[x]=g;setTimeout(()=>{let C=d;try{C=Or.toDOMNode(t,x)}catch{}let I=C.querySelector('[contenteditable="false"]')||p;r.open(()=>dt(Co,{destAnchor:C,destStartEdge:I,element:x,initialEmbed:!0,onCancel:()=>{t.anchor.convertToEmbed(l,{at:x}),r.close()}}))})},[r,t,e,l]),m=c=>{c.preventDefault(),c.stopPropagation();let d=Or.findPath(t,e);yg.removeNodes(t,{at:d})};return bs(wg,{ref:n,contentEditable:!1,onMouseDown:s,children:[dt("span",{ref:i,style:{display:"none"}}),a?.(l),o?bs("span",{className:"--wiki-embed-toolbar",children:[dt("button",{type:"button",title:f("edit"),onMouseDown:s,children:dt(So,{width:"1em",height:"1em"})}),dt("button",{type:"button",title:f("remove"),onMouseDown:m,children:dt(Lo,{width:"1em",height:"1em"})})]}):null]})}import{jsx as Ur,jsxs as Es}from"react/jsx-runtime";function xs({element:e,attributes:t,children:o}){let r=Ig();return Ze(e.url)&&r.wysimark.renderInternalEmbed?Es("div",{...t,children:[Ur(Fo,{element:e}),o]}):Es("div",{...t,children:[Ur(Dl,{contentEditable:!1,children:Ur(Uo,{element:e,presets:r.image.imageBlockPresets})}),o]})}import{useSlateStatic as Cg}from"slate-react";import Mg from"@emotion/styled";var ks=Mg("span")`
925
956
  display: inline;
926
- `;import{jsx as Br,jsxs as ps}from"react/jsx-runtime";function ds({element:e,attributes:t,children:o}){let r=cg(),n=r.wysimark.renderInternalEmbed;return et(e.url)&&n?ps("span",{...t,style:{display:"inline-block"},children:[Br("span",{contentEditable:!1,children:n(Dt(e.url))}),o]}):ps("span",{...t,style:{display:"inline-block"},children:[Br(cs,{contentEditable:!1,children:Br(No,{element:e,presets:r.image.imageInlinePresets})}),o]})}import{jsx as us}from"react/jsx-runtime";function fs({element:e,attributes:t,children:o}){switch(e.type){case"image-block":return us(ms,{element:e,attributes:t,children:o});case"image-inline":return us(ds,{element:e,attributes:t,children:o})}}function ug(e){return t=>{let{dataTransfer:o}=t;if(!o.files||o.files.length===0)return!1;let r=Array.from(o.files).filter(a=>a.type.startsWith("image/"));if(r.length===0)return!1;t.preventDefault(),t.stopPropagation();let n=dg.findEventRange(e,t);n&&pg.select(e,n);let i=e.wysimark?.onImageChange;for(let a of r)if(i)i(a).then(l=>{l&&e.image.insertImageFromUrl(l,a.name,"")}).catch(()=>{});else{let l=new FileReader;l.onload=()=>{let s=l.result;e.image.insertImageFromUrl(s,a.name,"")},l.readAsDataURL(a)}return!0}}var fg={maxInitialInlineImageSize:{width:64,height:64},maxInitialImageSize:{width:320,height:320},maxImageSize:{width:1024,height:1024},imageBlockPresets:[{name:"S",title:"Small",type:"bounds",width:160,height:160},{name:"M",title:"Medium",type:"bounds",width:320,height:320},{name:"L",title:"Large",type:"bounds",width:640,height:640},{name:"\u2153",title:"1/3 scale",type:"scale",scale:1/3},{name:"\xBD",title:"1/2 scale",type:"scale",scale:.5},{name:"Full",title:"Full size",type:"scale",scale:1}],imageInlinePresets:[{name:"16",title:"16 pixels",type:"bounds",width:16,height:16},{name:"24",title:"24 pixels",type:"bounds",width:24,height:24},{name:"32",title:"32 pixels",type:"bounds",width:32,height:32},{name:"\u2153",title:"1/3 scale",type:"scale",scale:1/3},{name:"\xBD",title:"1/2 scale",type:"scale",scale:.5},{name:"Full",title:"Full size",type:"scale",scale:1}]},hs=y((e,t,{createPolicy:o})=>{let r={...fg,...t.image};return e.image={...wl(e),maxInitialInlineImageSize:r.maxInitialInlineImageSize,maxInitialImageSize:r.maxInitialImageSize,maxImageSize:r.maxImageSize,imageBlockPresets:r.imageBlockPresets,imageInlinePresets:r.imageInlinePresets},o({name:"image",editor:{isVoid:n=>{if(["image-block","image-inline"].includes(n.type))return!0},isInline:n=>{if(n.type==="image-inline")return!0},normalizeNode:h(Il,e)},editableProps:{renderElement:fs,onDrop:ug(e)}})});import{Editor as dt,Element as Ee,Transforms as ut}from"slate";import{ReactEditor as Is,useFocused as kg,useSlateStatic as yg}from"slate-react";import{Element as hg,Node as gg}from"slate";var bg=new Set(["note","abstract","info","todo","tip","success","question","warning","failure","danger","bug","example","quote"]),Eg={summary:"abstract",tldr:"abstract",hint:"tip",important:"tip",check:"success",done:"success",help:"question",faq:"question",caution:"warning",attention:"warning",fail:"failure",missing:"failure",error:"danger",cite:"quote"},gs={note:"i",abstract:"\u2261",info:"i",todo:"\u2713",tip:"\u2691",success:"\u2713",question:"?",warning:"!",failure:"\xD7",danger:"!",bug:"\u25CF",example:"\u25A1",quote:"\u201C"};function xg(e){return e.split("-").filter(Boolean).map(t=>`${t.charAt(0).toUpperCase()}${t.slice(1)}`).join(" ")}function bs(e){let t=e.children[0];if(!hg.isElement(t)||t.type!=="paragraph")return null;let r=gg.string(t).split(`
927
- `,1)[0].trim().match(/^\[!([A-Za-z0-9_-]+)\]([+-])?(?:\s+(.*))?$/);if(!r)return null;let n=r[1].toLowerCase(),i=Eg[n]||n,a=bg.has(i)?i:"note",l=r[2]==="+"?"open":r[2]==="-"?"closed":void 0,s=r[3]?.trim()||xg(n);return{type:a,displayType:n,title:s,fold:l,icon:gs[a]||gs.note}}import Ne from"@emotion/styled";var Es=Ne("blockquote")`
957
+ `;import{jsx as Fr,jsxs as ys}from"react/jsx-runtime";function vs({element:e,attributes:t,children:o}){let r=Cg();return Ze(e.url)&&r.wysimark.renderInternalEmbed?ys("span",{...t,style:{display:"inline-block"},children:[Fr(Fo,{element:e}),o]}):ys("span",{...t,style:{display:"inline-block"},children:[Fr(ks,{contentEditable:!1,children:Fr(Uo,{element:e,presets:r.image.imageInlinePresets})}),o]})}import{jsx as Ts}from"react/jsx-runtime";function ws({element:e,attributes:t,children:o}){switch(e.type){case"image-block":return Ts(xs,{element:e,attributes:t,children:o});case"image-inline":return Ts(vs,{element:e,attributes:t,children:o})}}function Lg(e){return t=>{let{dataTransfer:o}=t;if(!o.files||o.files.length===0)return!1;let r=Array.from(o.files).filter(a=>a.type.startsWith("image/"));if(r.length===0)return!1;t.preventDefault(),t.stopPropagation();let n=Sg.findEventRange(e,t);n&&Pg.select(e,n);let i=e.wysimark?.onImageChange;for(let a of r)if(i)i(a).then(l=>{l&&e.image.insertImageFromUrl(l,a.name,"")}).catch(()=>{});else{let l=new FileReader;l.onload=()=>{let s=l.result;e.image.insertImageFromUrl(s,a.name,"")},l.readAsDataURL(a)}return!0}}var Rg={maxInitialInlineImageSize:{width:64,height:64},maxInitialImageSize:{width:320,height:320},maxImageSize:{width:1024,height:1024},imageBlockPresets:[{name:"S",title:"Small",type:"bounds",width:160,height:160},{name:"M",title:"Medium",type:"bounds",width:320,height:320},{name:"L",title:"Large",type:"bounds",width:640,height:640},{name:"\u2153",title:"1/3 scale",type:"scale",scale:1/3},{name:"\xBD",title:"1/2 scale",type:"scale",scale:.5},{name:"Full",title:"Full size",type:"scale",scale:1}],imageInlinePresets:[{name:"16",title:"16 pixels",type:"bounds",width:16,height:16},{name:"24",title:"24 pixels",type:"bounds",width:24,height:24},{name:"32",title:"32 pixels",type:"bounds",width:32,height:32},{name:"\u2153",title:"1/3 scale",type:"scale",scale:1/3},{name:"\xBD",title:"1/2 scale",type:"scale",scale:.5},{name:"Full",title:"Full size",type:"scale",scale:1}]},Is=y((e,t,{createPolicy:o})=>{let r={...Rg,...t.image};return e.image={...Bl(e),maxInitialInlineImageSize:r.maxInitialInlineImageSize,maxInitialImageSize:r.maxInitialImageSize,maxImageSize:r.maxImageSize,imageBlockPresets:r.imageBlockPresets,imageInlinePresets:r.imageInlinePresets},o({name:"image",editor:{isVoid:n=>{if(["image-block","image-inline"].includes(n.type))return!0},isInline:n=>{if(n.type==="image-inline")return!0},normalizeNode:h($l,e)},editableProps:{renderElement:ws,onDrop:Lg(e)}})});import{Editor as ut,Element as Ee,Transforms as ft}from"slate";import{ReactEditor as zs,useFocused as Hg,useSlateStatic as Ag}from"slate-react";import{Element as Bg,Node as $g}from"slate";var Dg=new Set(["note","abstract","info","todo","tip","success","question","warning","failure","danger","bug","example","quote"]),zg={summary:"abstract",tldr:"abstract",hint:"tip",important:"tip",check:"success",done:"success",help:"question",faq:"question",caution:"warning",attention:"warning",fail:"failure",missing:"failure",error:"danger",cite:"quote"},Ms={note:"i",abstract:"\u2261",info:"i",todo:"\u2713",tip:"\u2691",success:"\u2713",question:"?",warning:"!",failure:"\xD7",danger:"!",bug:"\u25CF",example:"\u25A1",quote:"\u201C"};function Ng(e){return e.split("-").filter(Boolean).map(t=>`${t.charAt(0).toUpperCase()}${t.slice(1)}`).join(" ")}function Cs(e){let t=e.children[0];if(!Bg.isElement(t)||t.type!=="paragraph")return null;let r=$g.string(t).split(`
958
+ `,1)[0].trim().match(/^\[!([A-Za-z0-9_-]+)\]([+-])?(?:\s+(.*))?$/);if(!r)return null;let n=r[1].toLowerCase(),i=zg[n]||n,a=Dg.has(i)?i:"note",l=r[2]==="+"?"open":r[2]==="-"?"closed":void 0,s=r[3]?.trim()||Ng(n);return{type:a,displayType:n,title:s,fold:l,icon:Ms[a]||Ms.note}}import Ne from"@emotion/styled";var Ps=Ne("blockquote")`
928
959
  position: relative;
929
960
  margin-top: 1em;
930
961
  margin-bottom: 1em;
931
962
  margin-left: 0;
932
963
  border-left: 0.25em solid rgba(0, 0, 0, 0.075);
933
964
  padding-left: 1.5em;
934
- `,xs=Ne("blockquote")`
965
+ `,Ss=Ne("blockquote")`
935
966
  --callout-color: 8, 109, 221;
936
967
  position: relative;
937
968
  margin: 1em 0;
@@ -987,7 +1018,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
987
1018
  > :first-of-type:not(.wysimark-callout-title) {
988
1019
  display: none;
989
1020
  }
990
- `,ks=Ne("div")`
1021
+ `,Ls=Ne("div")`
991
1022
  display: flex;
992
1023
  align-items: center;
993
1024
  gap: 0.5em;
@@ -1000,7 +1031,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1000
1031
  &[data-fold="closed"] {
1001
1032
  margin-bottom: 0;
1002
1033
  }
1003
- `,ys=Ne("span")`
1034
+ `,Rs=Ne("span")`
1004
1035
  display: inline-flex;
1005
1036
  align-items: center;
1006
1037
  justify-content: center;
@@ -1012,11 +1043,11 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1012
1043
  font-size: 0.75em;
1013
1044
  line-height: 1;
1014
1045
  flex: 0 0 auto;
1015
- `,vs=Ne("span")`
1046
+ `,Bs=Ne("span")`
1016
1047
  color: rgb(var(--callout-color));
1017
1048
  flex: 0 0 auto;
1018
1049
  margin-left: -0.125em;
1019
- `,Ts=Ne("div")`
1050
+ `,$s=Ne("div")`
1020
1051
  color: inherit;
1021
1052
 
1022
1053
  > :first-child {
@@ -1027,9 +1058,9 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1027
1058
  > :last-child {
1028
1059
  margin-bottom: 0;
1029
1060
  }
1030
- `,ws=Ne("span")`
1061
+ `,Ds=Ne("span")`
1031
1062
  flex: 1 1 auto;
1032
- `,DL=Ne("div")`
1063
+ `,gR=Ne("div")`
1033
1064
  color: var(--shade-500);
1034
1065
  font-size: 0.875em;
1035
1066
  margin-bottom: 0.25em;
@@ -1042,8 +1073,8 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1042
1073
  margin-right: 0.5em;
1043
1074
  color: var(--shade-400);
1044
1075
  }
1045
- `;import{jsx as ft,jsxs as Cs}from"react/jsx-runtime";function vg({element:e,attributes:t,children:o}){let r=yg(),n=bs(e),i=kg(),a=xa(e),l=i&&a;function s(m){let c=m.target;if(c instanceof HTMLElement&&c.closest(".wysimark-callout-body"))return;m.preventDefault();let d=Is.findPath(r,e);ut.select(r,dt.start(r,d)),Is.focus(r)}return n&&!l?Cs(xs,{...t,"data-callout":n.type,"data-callout-source-type":n.displayType,"data-callout-fold":n.fold,onMouseDown:s,children:[Cs(ks,{className:"wysimark-callout-title",contentEditable:!1,"data-fold":n.fold,children:[ft(vs,{children:n.fold==="closed"?"\u203A":n.fold==="open"?"\u2304":null}),ft(ys,{children:n.icon}),ft(ws,{children:n.title})]}),ft(Ts,{className:"wysimark-callout-body",children:o})]}):ft(Es,{...t,children:o})}function Ms(e){return Ee.isElement(e)&&(e.type==="paragraph"||e.type==="code-block"||e.type==="table"||e.type==="horizontal-rule"||e.type==="task-list-item"||e.type==="unordered-list-item"||e.type==="ordered-list-item"||e.type==="heading")}var Tg=2,Ps=y(e=>{e.supportsBlockQuote=!0,e.blockQuotePlugin={indent:()=>{ut.wrapNodes(e,{type:"block-quote",children:[]},{match:Ms})},outdent:()=>{ut.liftNodes(e,{match:(r,n)=>Ms(r)&&n.length>1})},isActive:()=>{let[r]=dt.nodes(e,{match:n=>Ee.isElement(n)&&n.type==="block-quote"});return!!r},increaseDepth:()=>{let[r]=dt.nodes(e,{match:i=>Ee.isElement(i)&&i.type==="block-quote"});if(!r||!e.blockQuotePlugin.canIncreaseDepth())return;let[,n]=r;ut.select(e,n),ut.wrapNodes(e,{type:"block-quote",children:[]},{at:n,split:!1})},decreaseDepth:()=>{let[r]=dt.nodes(e,{match:l=>Ee.isElement(l)&&l.type==="block-quote"});if(!r||!e.blockQuotePlugin.canDecreaseDepth())return;let[n,i]=r,a=n.children;a.length===1&&Ee.isElement(a[0])&&a[0].type==="block-quote"&&ut.unwrapNodes(e,{at:[...i,0],match:l=>Ee.isElement(l)&&l.type==="block-quote"})},canIncreaseDepth:()=>{let[r]=dt.nodes(e,{match:l=>Ee.isElement(l)&&l.type==="block-quote"});if(!r)return!1;let[n]=r,i=0,a=n;for(;a.children.length===1&&Ee.isElement(a.children[0])&&a.children[0].type==="block-quote";)i++,a=a.children[0];return i<Tg},canDecreaseDepth:()=>{let[r]=dt.nodes(e,{match:i=>Ee.isElement(i)&&i.type==="block-quote"});if(!r)return!1;let[n]=r;return n.children.length===1&&Ee.isElement(n.children[0])&&n.children[0]&&n.children[0].type==="block-quote"}};let t=go(e,{">":e.blockQuotePlugin.indent}),o=W({"super+.":e.blockQuotePlugin.indent,"super+,":e.blockQuotePlugin.outdent});return{name:"block-quote",editableProps:{renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="block-quote")return ft(vg,{element:r,attributes:n,children:i})},onKeyDown:r=>!!(o(r)||t(r))}}});import{Editor as eb,Element as tb,Transforms as sm}from"slate";import wg from"prismjs";import{Element as Cg,Node as Pg}from"slate";var{languages:Ig,tokenize:Mg}=wg;function Sg(e){let t=0,o=[];for(let r of e)o.push(t),t=t+r.length;return o}function Ss(e){let[t,o]=e;if(!Cg.isElement(t))return[];if(t.type!=="code-block")return[];let r=Ig[t.language];if(r===void 0)return[];let i=t.children.map(p=>`${Pg.string(p)}
1046
- `),a=i.join(""),l=Sg(i);function s(p){for(let u=l.length-1;u>=0;u--){let g=l[u];if(g<=p)return{path:[...o,u],offset:p-g}}throw new Error("This shouldn't happen and indicates a bug in the logic")}let m=[],c=Mg(a,r),d=0;for(let p of c)if(typeof p=="string")d+=p.length;else{let u=s(d),g=s(d+p.length);m.push({anchor:u,focus:g,prismToken:p.type}),d+=p.length}return m}function Ls(e,{language:t}){ua(e,{type:"code-block",language:t,children:[{type:"code-block-line",children:[{text:""}]}]})}import{Element as Lg,Transforms as Rg}from"slate";function Rs(e,t,o={}){let r=E(e,n=>Lg.isElement(n)&&n.type==="code-block",{at:o.at});return r?(Rg.setNodes(e,{language:t},{at:r[1]}),!0):!1}function Bs(e){return{createCodeBlock:h(Ls,e),setCodeBlockLanguage:h(Rs,e)}}var Ho={color:"#999988",fontStyle:"italic"},Bg={opacity:"0.7"},$s={color:"#e3116c"},Ds={color:"#393a34"},xe={color:"#36acaa"},$r={color:"#00a4db"},zs={color:"#9a050f"},Ns={color:"#00009f"},Dr={fontWeight:"bold"},$g={fontStyle:"italic"},Hs={comment:Ho,prolog:Ho,doctype:Ho,cdata:Ho,namespace:Bg,string:$s,"attr-value":$s,puncutation:Ds,operator:Ds,entity:xe,url:xe,symbol:xe,number:xe,boolean:xe,variable:xe,constant:xe,property:xe,regex:xe,insert:xe,atrule:$r,keyword:$r,"attr-name":$r,function:{...zs,...Dr},delete:zs,tag:Ns,selector:Ns,important:Dr,bold:Dr,italic:$g};var As=["text","html","css","svg","mermaid","javascript","java","c"];import{Element as zr,Node as Nr,Transforms as ht}from"slate";function Os(e,t){if(!zr.isElement(t[0]))return!1;if(t[0].type==="code-block-line"){for(let[o,r]of Nr.children(e,t[1]))if(zr.isElement(o))return e.isVoid(o)?(ht.removeNodes(e,{at:r}),!0):(ht.unwrapNodes(e,{at:r}),!0)}if(t[0].type==="code-block"){for(let[o,r]of Nr.children(e,t[1]))if(zr.isElement(o)&&o.type!=="code-block-line")return o.type==="code-block"?(ht.unwrapNodes(e,{at:r}),!0):e.isVoid(o)?(ht.removeNodes(e,{at:r}),!0):(ht.removeNodes(e,{at:r}),ht.insertNodes(e,{type:"code-block-line",children:[{text:Nr.string(o)}]}),!0)}return!1}import{useCallback as qg,useRef as Qg}from"react";import{useFocused as jg,useSelected as Xg}from"slate-react";import{jsx as Us}from"react/jsx-runtime";var Fs=e=>Us(k,{...e,children:Us("path",{d:"m6 9 6 6 6-6"})});import le from"@emotion/styled";var Hr=le("div")`
1076
+ `;import{jsx as ht,jsxs as Hs}from"react/jsx-runtime";function Og({element:e,attributes:t,children:o}){let r=Ag(),n=Cs(e),i=Hg(),a=Pa(e),l=i&&a;function s(m){let c=m.target;if(c instanceof HTMLElement&&c.closest(".wysimark-callout-body"))return;m.preventDefault();let d=zs.findPath(r,e);ft.select(r,ut.start(r,d)),zs.focus(r)}return n&&!l?Hs(Ss,{...t,"data-callout":n.type,"data-callout-source-type":n.displayType,"data-callout-fold":n.fold,onMouseDown:s,children:[Hs(Ls,{className:"wysimark-callout-title",contentEditable:!1,"data-fold":n.fold,children:[ht(Bs,{children:n.fold==="closed"?"\u203A":n.fold==="open"?"\u2304":null}),ht(Rs,{children:n.icon}),ht(Ds,{children:n.title})]}),ht($s,{className:"wysimark-callout-body",children:o})]}):ht(Ps,{...t,children:o})}function Ns(e){return Ee.isElement(e)&&(e.type==="paragraph"||e.type==="code-block"||e.type==="table"||e.type==="horizontal-rule"||e.type==="task-list-item"||e.type==="unordered-list-item"||e.type==="ordered-list-item"||e.type==="heading")}var Ug=2,As=y(e=>{e.supportsBlockQuote=!0,e.blockQuotePlugin={indent:()=>{ft.wrapNodes(e,{type:"block-quote",children:[]},{match:Ns})},outdent:()=>{ft.liftNodes(e,{match:(r,n)=>Ns(r)&&n.length>1})},isActive:()=>{let[r]=ut.nodes(e,{match:n=>Ee.isElement(n)&&n.type==="block-quote"});return!!r},increaseDepth:()=>{let[r]=ut.nodes(e,{match:i=>Ee.isElement(i)&&i.type==="block-quote"});if(!r||!e.blockQuotePlugin.canIncreaseDepth())return;let[,n]=r;ft.select(e,n),ft.wrapNodes(e,{type:"block-quote",children:[]},{at:n,split:!1})},decreaseDepth:()=>{let[r]=ut.nodes(e,{match:l=>Ee.isElement(l)&&l.type==="block-quote"});if(!r||!e.blockQuotePlugin.canDecreaseDepth())return;let[n,i]=r,a=n.children;a.length===1&&Ee.isElement(a[0])&&a[0].type==="block-quote"&&ft.unwrapNodes(e,{at:[...i,0],match:l=>Ee.isElement(l)&&l.type==="block-quote"})},canIncreaseDepth:()=>{let[r]=ut.nodes(e,{match:l=>Ee.isElement(l)&&l.type==="block-quote"});if(!r)return!1;let[n]=r,i=0,a=n;for(;a.children.length===1&&Ee.isElement(a.children[0])&&a.children[0].type==="block-quote";)i++,a=a.children[0];return i<Ug},canDecreaseDepth:()=>{let[r]=ut.nodes(e,{match:i=>Ee.isElement(i)&&i.type==="block-quote"});if(!r)return!1;let[n]=r;return n.children.length===1&&Ee.isElement(n.children[0])&&n.children[0]&&n.children[0].type==="block-quote"}};let t=bo(e,{">":e.blockQuotePlugin.indent}),o=V({"super+.":e.blockQuotePlugin.indent,"super+,":e.blockQuotePlugin.outdent});return{name:"block-quote",editableProps:{renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="block-quote")return ht(Og,{element:r,attributes:n,children:i})},onKeyDown:r=>!!(o(r)||t(r))}}});import{Editor as bb,Element as Eb,Transforms as Em}from"slate";import Fg from"prismjs";import{Element as _g,Node as Kg}from"slate";var{languages:Wg,tokenize:Vg}=Fg;function Gg(e){let t=0,o=[];for(let r of e)o.push(t),t=t+r.length;return o}function Os(e){let[t,o]=e;if(!_g.isElement(t))return[];if(t.type!=="code-block")return[];let r=Wg[t.language];if(r===void 0)return[];let i=t.children.map(p=>`${Kg.string(p)}
1077
+ `),a=i.join(""),l=Gg(i);function s(p){for(let u=l.length-1;u>=0;u--){let g=l[u];if(g<=p)return{path:[...o,u],offset:p-g}}throw new Error("This shouldn't happen and indicates a bug in the logic")}let m=[],c=Vg(a,r),d=0;for(let p of c)if(typeof p=="string")d+=p.length;else{let u=s(d),g=s(d+p.length);m.push({anchor:u,focus:g,prismToken:p.type}),d+=p.length}return m}function Us(e,{language:t}){va(e,{type:"code-block",language:t,children:[{type:"code-block-line",children:[{text:""}]}]})}import{Element as qg,Transforms as Qg}from"slate";function Fs(e,t,o={}){let r=E(e,n=>qg.isElement(n)&&n.type==="code-block",{at:o.at});return r?(Qg.setNodes(e,{language:t},{at:r[1]}),!0):!1}function Ws(e){return{createCodeBlock:h(Us,e),setCodeBlockLanguage:h(Fs,e)}}var Wo={color:"#999988",fontStyle:"italic"},jg={opacity:"0.7"},Vs={color:"#e3116c"},_s={color:"#393a34"},xe={color:"#36acaa"},Wr={color:"#00a4db"},Ks={color:"#9a050f"},Gs={color:"#00009f"},Vr={fontWeight:"bold"},Xg={fontStyle:"italic"},qs={comment:Wo,prolog:Wo,doctype:Wo,cdata:Wo,namespace:jg,string:Vs,"attr-value":Vs,puncutation:_s,operator:_s,entity:xe,url:xe,symbol:xe,number:xe,boolean:xe,variable:xe,constant:xe,property:xe,regex:xe,insert:xe,atrule:Wr,keyword:Wr,"attr-name":Wr,function:{...Ks,...Vr},delete:Ks,tag:Gs,selector:Gs,important:Vr,bold:Vr,italic:Xg};var Qs=["text","html","css","svg","mermaid","javascript","java","c"];import{Element as _r,Node as Kr,Transforms as gt}from"slate";function js(e,t){if(!_r.isElement(t[0]))return!1;if(t[0].type==="code-block-line"){for(let[o,r]of Kr.children(e,t[1]))if(_r.isElement(o))return e.isVoid(o)?(gt.removeNodes(e,{at:r}),!0):(gt.unwrapNodes(e,{at:r}),!0)}if(t[0].type==="code-block"){for(let[o,r]of Kr.children(e,t[1]))if(_r.isElement(o)&&o.type!=="code-block-line")return o.type==="code-block"?(gt.unwrapNodes(e,{at:r}),!0):e.isVoid(o)?(gt.removeNodes(e,{at:r}),!0):(gt.removeNodes(e,{at:r}),gt.insertNodes(e,{type:"code-block-line",children:[{text:Kr.string(o)}]}),!0)}return!1}import{useCallback as cb,useRef as pb}from"react";import{useFocused as db,useSelected as ub}from"slate-react";import{jsx as Xs}from"react/jsx-runtime";var Ys=e=>Xs(k,{...e,children:Xs("path",{d:"m6 9 6 6 6-6"})});import ie from"@emotion/styled";var Gr=ie("div")`
1047
1078
  position: relative;
1048
1079
  background: var(--code-block-bgcolor);
1049
1080
  margin: 1em 0;
@@ -1062,20 +1093,20 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1062
1093
  * Otherwise they will be square.
1063
1094
  */
1064
1095
  overflow-x: hidden;
1065
- `,Ar=le("div")`
1096
+ `,qr=ie("div")`
1066
1097
  padding: 2.25em 1em 1.5em 1em;
1067
1098
  border-radius: 0.5em;
1068
1099
  overflow-x: auto;
1069
- `,Ws=le(Ar)`
1100
+ `,Js=ie(qr)`
1070
1101
  padding-top: 1em;
1071
- `,Vs=le("div")`
1102
+ `,Zs=ie("div")`
1072
1103
  position: absolute;
1073
1104
  top: 0.25em;
1074
1105
  right: 0.25em;
1075
1106
  z-index: 2;
1076
1107
  display: flex;
1077
1108
  gap: 0.25em;
1078
- `,Or=le("button")`
1109
+ `,Qr=ie("button")`
1079
1110
  width: 2em;
1080
1111
  height: 2em;
1081
1112
  display: inline-flex;
@@ -1093,7 +1124,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1093
1124
  color: var(--shade-900);
1094
1125
  background: var(--shade-200);
1095
1126
  }
1096
- `,_s=le("span")`
1127
+ `,em=ie("span")`
1097
1128
  cursor: pointer;
1098
1129
  position: absolute;
1099
1130
  top: 0.25em;
@@ -1119,7 +1150,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1119
1150
  color: var(--shade-800);
1120
1151
  background: var(--shade-300);
1121
1152
  }
1122
- `,xR=le("input")`
1153
+ `,t5=ie("input")`
1123
1154
  box-sizing: border-box;
1124
1155
  min-width: 0;
1125
1156
  flex: 1 1 auto;
@@ -1130,7 +1161,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1130
1161
  background: transparent;
1131
1162
  font: inherit;
1132
1163
  text-align: left;
1133
- `,Ks=le("div")`
1164
+ `,tm=ie("div")`
1134
1165
  white-space: pre;
1135
1166
  line-height: 1.5em;
1136
1167
  counter-increment: line;
@@ -1153,10 +1184,10 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1153
1184
  display: inline-block;
1154
1185
  width: 2em;
1155
1186
  } */
1156
- `,Gs=le(Hr)`
1187
+ `,om=ie(Gr)`
1157
1188
  min-height: 8em;
1158
1189
  cursor: text;
1159
- `,qs=le("div")`
1190
+ `,rm=ie("div")`
1160
1191
  box-sizing: border-box;
1161
1192
  min-height: 8em;
1162
1193
  padding: 1.5em 1em;
@@ -1170,7 +1201,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1170
1201
  max-width: 100%;
1171
1202
  height: auto;
1172
1203
  }
1173
- `,Qs=le("pre")`
1204
+ `,nm=ie("pre")`
1174
1205
  box-sizing: border-box;
1175
1206
  width: 100%;
1176
1207
  margin: 0;
@@ -1182,15 +1213,15 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1182
1213
  padding: 0.75em;
1183
1214
  font-family: "andale mono", AndaleMono, monospace;
1184
1215
  font-size: 0.8125em;
1185
- `,js=le("div")`
1216
+ `,im=ie("div")`
1186
1217
  position: absolute;
1187
1218
  width: 1px;
1188
1219
  height: 1px;
1189
1220
  overflow: hidden;
1190
1221
  opacity: 0;
1191
1222
  pointer-events: none;
1192
- `;import{useCallback as Xs}from"react";import{Transforms as Dg}from"slate";import{ReactEditor as Ys,useSlateStatic as zg}from"slate-react";import{jsx as Zs,jsxs as Ng}from"react/jsx-runtime";async function Js(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}throw new Error("Clipboard API is unavailable")}function Ao({element:e}){let t=zg(),o=Xs(async n=>{n.preventDefault(),n.stopPropagation();try{await Js(fe([e]).trimEnd())}catch{}},[e]),r=Xs(async n=>{n.preventDefault(),n.stopPropagation();try{await Js(fe([e]).trimEnd())}catch{return}let i=Ys.findPath(t,e);Dg.removeNodes(t,{at:i}),Ys.focus(t)},[t,e]);return Ng(Vs,{contentEditable:!1,children:[Zs(Or,{"aria-label":"Copy code block",title:"Copy",type:"button",onMouseDown:n=>{n.preventDefault(),n.stopPropagation()},onClick:o,children:"\u29C9"}),Zs(Or,{"aria-label":"Cut code block",title:"Cut",type:"button",onMouseDown:n=>{n.preventDefault(),n.stopPropagation()},onClick:r,children:"\u2702"})]})}import{useEffect as Hg,useMemo as Ag,useState as em}from"react";import om from"mermaid";import{Editor as Og,Node as Ug,Transforms as Fg}from"slate";import{ReactEditor as tm,useFocused as Wg,useSelected as Vg,useSlateStatic as _g}from"slate-react";import{jsx as gt,jsxs as Gg}from"react/jsx-runtime";om.initialize({startOnLoad:!1,securityLevel:"strict",theme:"default"});var Kg=0;function rm({element:e,attributes:t,children:o}){let r=_g(),n=Vg(),i=Wg(),a=Ag(()=>e.children.map(p=>Ug.string(p)).join(`
1193
- `),[e.children]),[l,s]=em(""),[m,c]=em("");Hg(()=>{let p=!1,u=`wysimark-mermaid-${++Kg}`;c(""),s("");async function g(){try{let x=await om.render(u,a);p||s(x.svg)}catch(x){p||c(x instanceof Error?x.message:"Invalid Mermaid diagram")}}return g(),()=>{p=!0}},[a]);function d(p){p.preventDefault(),p.stopPropagation();let u=tm.findPath(r,e);Fg.select(r,Og.start(r,u)),tm.focus(r)}return Gg(Gs,{...t,onMouseDown:d,children:[n&&i?gt(Ao,{element:e}):null,gt(qs,{contentEditable:!1,onMouseDown:d,children:m?gt(Qs,{children:m}):l?gt("div",{dangerouslySetInnerHTML:{__html:l}}):gt("span",{children:"Rendering diagram..."})}),gt(js,{"aria-hidden":"true",children:o})]})}import{Fragment as Yg,jsx as He,jsxs as Ur}from"react/jsx-runtime";function nm({element:e,attributes:t,children:o}){let r=Qg(null),n=Xg(),i=jg(),a=ka(e),l=i&&a,s=K("code-block-dropdown"),m=qg(()=>{s.layer&&s.close();let c=r.current;if(c===null)return;let d=As.map(p=>({icon:()=>He("span",{}),title:p,action:u=>{u.codeBlock.setCodeBlockLanguage(p,{at:e})}}));s.open(()=>He(ct,{dest:c,items:d,close:s.close}))},[s,e]);return e.language.toLowerCase()==="mermaid"&&!l?He(rm,{element:e,attributes:t,children:o}):Ur(Hr,{className:n?"--selected":"",...t,children:[n&&i?He(Ao,{element:e}):null,l?He(Ws,{children:o}):Ur(Yg,{children:[Ur(_s,{contentEditable:!1,onClick:m,ref:r,children:[He("span",{children:e.language}),He(Fs,{})]}),He(Ar,{children:o})]})]})}import{useSelected as Jg}from"slate-react";import{jsx as Zg}from"react/jsx-runtime";function im({attributes:e,children:t}){let o=Jg();return Zg(Ks,{className:o?"--selected":"",...e,spellCheck:"false",children:t})}import{jsx as am}from"react/jsx-runtime";function lm({element:e,attributes:t,children:o}){if(e.type==="code-block")return am(nm,{element:e,attributes:t,children:o});if(e.type==="code-block-line")return am(im,{element:e,attributes:t,children:o})}import{Fragment as ob,jsx as mm}from"react/jsx-runtime";var cm=y((e,t,{createPolicy:o})=>{e.codeBlock=Bs(e);function r(){let{selection:n}=e;if(!ve(n))return!1;let i=E(e,"code-block");return i==null?!1:eb.string(e,i[1])===""?(sm.removeNodes(e,{at:i[1]}),!0):!1}return o({name:"code-block",editor:{deleteBackward:r,deleteForward:r,isInline(n){if(n.type==="code-block"||n.type==="code-block-line")return!1},isVoid(n){if(n.type==="code-block"||n.type==="code-block-line")return!1},isMaster(n){if(n.type==="code-block")return!0},normalizeNode:h(Os,e)},editableProps:{decorate:Ss,onKeyDown:W({"super+`":()=>e.codeBlock.createCodeBlock({language:"text"}),"mod+a":()=>{let n=E(e,i=>tb.isElement(i)&&i.type==="code-block");return n?(sm.select(e,n[1]),!0):!1}}),renderElement:lm,renderLeaf:({leaf:n,children:i})=>{let a=n.prismToken&&Hs[n.prismToken]||null;return a===null?mm(ob,{children:i}):mm("span",{style:a,children:i})}}})});import{Transforms as nb}from"slate";import pm from"@emotion/styled";var dm=pm("div")`
1223
+ `;import{useCallback as am}from"react";import{Transforms as Yg}from"slate";import{ReactEditor as lm,useSlateStatic as Jg}from"slate-react";import{jsx as mm,jsxs as Zg}from"react/jsx-runtime";async function sm(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}throw new Error("Clipboard API is unavailable")}function Vo({element:e}){let t=Jg(),o=am(async n=>{n.preventDefault(),n.stopPropagation();try{await sm(fe([e]).trimEnd())}catch{}},[e]),r=am(async n=>{n.preventDefault(),n.stopPropagation();try{await sm(fe([e]).trimEnd())}catch{return}let i=lm.findPath(t,e);Yg.removeNodes(t,{at:i}),lm.focus(t)},[t,e]);return Zg(Zs,{contentEditable:!1,children:[mm(Qr,{"aria-label":"Copy code block",title:"Copy",type:"button",onMouseDown:n=>{n.preventDefault(),n.stopPropagation()},onClick:o,children:"\u29C9"}),mm(Qr,{"aria-label":"Cut code block",title:"Cut",type:"button",onMouseDown:n=>{n.preventDefault(),n.stopPropagation()},onClick:r,children:"\u2702"})]})}import{useEffect as eb,useMemo as tb,useState as cm}from"react";import dm from"mermaid";import{Editor as ob,Node as rb,Transforms as nb}from"slate";import{ReactEditor as pm,useFocused as ib,useSelected as ab,useSlateStatic as lb}from"slate-react";import{jsx as bt,jsxs as mb}from"react/jsx-runtime";dm.initialize({startOnLoad:!1,securityLevel:"strict",theme:"default"});var sb=0;function um({element:e,attributes:t,children:o}){let r=lb(),n=ab(),i=ib(),a=tb(()=>e.children.map(p=>rb.string(p)).join(`
1224
+ `),[e.children]),[l,s]=cm(""),[m,c]=cm("");eb(()=>{let p=!1,u=`wysimark-mermaid-${++sb}`;c(""),s("");async function g(){try{let x=await dm.render(u,a);p||s(x.svg)}catch(x){p||c(x instanceof Error?x.message:"Invalid Mermaid diagram")}}return g(),()=>{p=!0}},[a]);function d(p){p.preventDefault(),p.stopPropagation();let u=pm.findPath(r,e);nb.select(r,ob.start(r,u)),pm.focus(r)}return mb(om,{...t,onMouseDown:d,children:[n&&i?bt(Vo,{element:e}):null,bt(rm,{contentEditable:!1,onMouseDown:d,children:m?bt(nm,{children:m}):l?bt("div",{dangerouslySetInnerHTML:{__html:l}}):bt("span",{children:"Rendering diagram..."})}),bt(im,{"aria-hidden":"true",children:o})]})}import{Fragment as fb,jsx as He,jsxs as jr}from"react/jsx-runtime";function fm({element:e,attributes:t,children:o}){let r=pb(null),n=ub(),i=db(),a=Sa(e),l=i&&a,s=F("code-block-dropdown"),m=cb(()=>{s.layer&&s.close();let c=r.current;if(c===null)return;let d=Qs.map(p=>({icon:()=>He("span",{}),title:p,action:u=>{u.codeBlock.setCodeBlockLanguage(p,{at:e})}}));s.open(()=>He(ct,{dest:c,items:d,close:s.close}))},[s,e]);return e.language.toLowerCase()==="mermaid"&&!l?He(um,{element:e,attributes:t,children:o}):jr(Gr,{className:n?"--selected":"",...t,children:[n&&i?He(Vo,{element:e}):null,l?He(Js,{children:o}):jr(fb,{children:[jr(em,{contentEditable:!1,onClick:m,ref:r,children:[He("span",{children:e.language}),He(Ys,{})]}),He(qr,{children:o})]})]})}import{useSelected as hb}from"slate-react";import{jsx as gb}from"react/jsx-runtime";function hm({attributes:e,children:t}){let o=hb();return gb(tm,{className:o?"--selected":"",...e,spellCheck:"false",children:t})}import{jsx as gm}from"react/jsx-runtime";function bm({element:e,attributes:t,children:o}){if(e.type==="code-block")return gm(fm,{element:e,attributes:t,children:o});if(e.type==="code-block-line")return gm(hm,{element:e,attributes:t,children:o})}import{Fragment as xb,jsx as xm}from"react/jsx-runtime";var km=y((e,t,{createPolicy:o})=>{e.codeBlock=Ws(e);function r(){let{selection:n}=e;if(!ye(n))return!1;let i=E(e,"code-block");return i==null?!1:bb.string(e,i[1])===""?(Em.removeNodes(e,{at:i[1]}),!0):!1}return o({name:"code-block",editor:{deleteBackward:r,deleteForward:r,isInline(n){if(n.type==="code-block"||n.type==="code-block-line")return!1},isVoid(n){if(n.type==="code-block"||n.type==="code-block-line")return!1},isMaster(n){if(n.type==="code-block")return!0},normalizeNode:h(js,e)},editableProps:{decorate:Os,onKeyDown:V({"super+`":()=>e.codeBlock.createCodeBlock({language:"text"}),"mod+a":()=>{let n=E(e,i=>Eb.isElement(i)&&i.type==="code-block");return n?(Em.select(e,n[1]),!0):!1}}),renderElement:bm,renderLeaf:({leaf:n,children:i})=>{let a=n.prismToken&&qs[n.prismToken]||null;return a===null?xm(xb,{children:i}):xm("span",{style:a,children:i})}}})});import{Transforms as yb}from"slate";import ym from"@emotion/styled";var vm=ym("div")`
1194
1225
  position: relative;
1195
1226
  background-color: var(--shade-100);
1196
1227
  border: 1px solid var(--shade-300);
@@ -1208,7 +1239,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1208
1239
  &.--selected {
1209
1240
  outline: 2px solid var(--select-color);
1210
1241
  }
1211
- `,um=pm("span")`
1242
+ `,Tm=ym("span")`
1212
1243
  position: absolute;
1213
1244
  top: 0.25em;
1214
1245
  right: 0.5em;
@@ -1216,7 +1247,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1216
1247
  color: var(--shade-500);
1217
1248
  text-transform: uppercase;
1218
1249
  letter-spacing: 0.5px;
1219
- `;import{jsx as fm,jsxs as rb}from"react/jsx-runtime";function hm({attributes:e,children:t,element:o}){return rb(dm,{...e,contentEditable:!1,children:[fm(um,{children:"HTML"}),fm("div",{children:zt(o.html)}),t]})}import{jsx as ib}from"react/jsx-runtime";var gm=y((e,t,{createPolicy:o})=>{function r(){let{selection:n}=e;if(!ve(n))return!1;let i=E(e,"html-block");return i==null?!1:(nb.removeNodes(e,{at:i[1]}),!0)}return o({name:"html-block",editor:{deleteBackward:r,deleteForward:r,isInline(n){if(n.type==="html-block")return!1},isVoid(n){if(n.type==="html-block")return!0},isMaster(n){if(n.type==="html-block")return!0}},editableProps:{renderElement:({element:n,attributes:i,children:a})=>{if(n.type==="html-block")return ib(hm,{element:n,attributes:i,children:a})}}})});import{Element as cb}from"slate";import{Element as ab,Transforms as lb}from"slate";function bm(e){return ab.isElement(e)&&e.type==="paragraph"}function Em(e,t){return st(e,t,(o,r)=>!bm(o[0])||!bm(r[0])?!1:o[0].__collapsible&&r[0].__collapsible?(lb.removeNodes(e,{at:o[1]}),!0):!1)}import{Element as sb,Transforms as mb}from"slate";function Fr(e,t){return sb.isElement(t)?e.isVoid(t)||e.isMaster(t):!1}function xm(e,t){return Fr(e,t[0])?st(e,t,(o,r)=>!Fr(e,o[0])||!Fr(e,r[0])?!1:(mb.insertNodes(e,{type:"paragraph",__collapsible:!0,children:[{text:""}]},{at:r[1]}),!0)):!1}function km(e,t){let[o,r]=t;return cb.isElement(o)?!!(xm(e,[o,r])||Em(e,[o,r])):!1}import{clsx as ub}from"clsx";import{useSelected as fb}from"slate-react";import pb from"@emotion/styled";var ym=pb("p")`
1250
+ `;import{jsx as wm,jsxs as kb}from"react/jsx-runtime";function Im({attributes:e,children:t,element:o}){return kb(vm,{...e,contentEditable:!1,children:[wm(Tm,{children:"HTML"}),wm("div",{children:Dt(o.html)}),t]})}import{jsx as vb}from"react/jsx-runtime";var Mm=y((e,t,{createPolicy:o})=>{function r(){let{selection:n}=e;if(!ye(n))return!1;let i=E(e,"html-block");return i==null?!1:(yb.removeNodes(e,{at:i[1]}),!0)}return o({name:"html-block",editor:{deleteBackward:r,deleteForward:r,isInline(n){if(n.type==="html-block")return!1},isVoid(n){if(n.type==="html-block")return!0},isMaster(n){if(n.type==="html-block")return!0}},editableProps:{renderElement:({element:n,attributes:i,children:a})=>{if(n.type==="html-block")return vb(Im,{element:n,attributes:i,children:a})}}})});import{Element as Cb}from"slate";import{Element as Tb,Transforms as wb}from"slate";function Cm(e){return Tb.isElement(e)&&e.type==="paragraph"}function Pm(e,t){return lt(e,t,(o,r)=>!Cm(o[0])||!Cm(r[0])?!1:o[0].__collapsible&&r[0].__collapsible?(wb.removeNodes(e,{at:o[1]}),!0):!1)}import{Element as Ib,Transforms as Mb}from"slate";function Xr(e,t){return Ib.isElement(t)?e.isVoid(t)||e.isMaster(t):!1}function Sm(e,t){return Xr(e,t[0])?lt(e,t,(o,r)=>!Xr(e,o[0])||!Xr(e,r[0])?!1:(Mb.insertNodes(e,{type:"paragraph",__collapsible:!0,children:[{text:""}]},{at:r[1]}),!0)):!1}function Lm(e,t){let[o,r]=t;return Cb.isElement(o)?!!(Sm(e,[o,r])||Pm(e,[o,r])):!1}import{clsx as Lb}from"clsx";import{useSelected as Rb}from"slate-react";import Pb from"@emotion/styled";var Rm=Pb("p")`
1220
1251
  padding: 0;
1221
1252
  margin: 0;
1222
1253
  &:first-of-type {
@@ -1250,41 +1281,41 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1250
1281
  }
1251
1282
  border-radius: 8px;
1252
1283
  }
1253
- `;import{Node as db}from"slate";function vm(e){return e.children.length===1&&db.string(e.children[0]).length===0}import{jsx as hb}from"react/jsx-runtime";function Tm({element:e,attributes:t,children:o}){let r=fb(),n=vm(e);return hb(ym,{...t,className:ub({"--selected":r,"--empty":n,"--collapsible":!!e.__collapsible}),children:o})}import{jsx as gb}from"react/jsx-runtime";var wm=y(e=>{let{insertBreak:t}=e;if(e.insertBreak=()=>{t()},e.insertSoftBreak=()=>{e.insertText(`
1254
- `)},e.convertElement.addConvertElementType("paragraph"),e.collapsibleParagraph={convertParagraph:()=>{e.convertElement.convertElements(()=>!1,{type:"paragraph"},!1)}},!e.normalizeAfterDelete)throw new Error("The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.");return{name:"collapsible-paragraph",editor:{normalizeNode:h(km,e)},editableProps:{renderElement:({element:o,attributes:r,children:n})=>{if(o.type==="paragraph")return gb(Tm,{element:o,attributes:r,children:n})},onKeyDown:o=>o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),o.shiftKey?e.insertSoftBreak():e.insertBreak(),!0):W({"super+0":e.collapsibleParagraph.convertParagraph})(o)}}});function Im(e,t){Array.isArray(t)?e.convertElement.convertElementTypes.push(...t):e.convertElement.convertElementTypes.push(t)}import{Editor as J,Element as Oo,Node as pe,Point as bt,Range as bb,Transforms as Ge}from"slate";function Mm(e,t,o){try{let r=J.start(e,o),n=J.end(e,o);if(bt.isBefore(t,r)||bt.isAfter(t,n))return-1;let i={anchor:r,focus:t};return J.string(e,i).length}catch{return-1}}function Cm(e,t,o){try{let r=pe.get(e,t);if(!Oo.isElement(r))return;let n=pe.string(r),i=Math.min(o,n.length),a=J.start(e,t),l=0,s=a.path,m=0;for(let[d,p]of pe.texts(r)){let u=d.text.length;if(l+u>=i){s=[...t,...p],m=i-l;break}l+=u}let c={path:s,offset:m};Ge.select(e,{anchor:c,focus:c})}catch{}}function Eb(e){return pe.string(e).includes(`
1255
- `)}function xb(e,t,o,r){let n=pe.string(t),i=n.split(`
1256
- `),a=J.start(e,o),l=J.end(e,o),s=bt.isBefore(r.anchor,a)?a:bt.isAfter(r.anchor,l)?l:r.anchor,m=bt.isBefore(r.focus,a)?a:bt.isAfter(r.focus,l)?l:r.focus,c=Math.min(J.string(e,{anchor:a,focus:s}).length,n.length),d=Math.min(J.string(e,{anchor:a,focus:m}).length,n.length),p=Math.min(c,d),u=Math.max(c,d),g=0,x=0,C=i.length-1;for(let L=0;L<i.length;L++){let T=g+i[L].length;if(g<=p&&p<=T&&(x=L),g<=u&&u<=T){C=L;break}g=T+1}return{startLineIndex:x,endLineIndex:C}}function kb(e,t,o,r){let n=pe.string(t);if(!n.includes(`
1284
+ `;import{Node as Sb}from"slate";function Bm(e){return e.children.length===1&&Sb.string(e.children[0]).length===0}import{jsx as Bb}from"react/jsx-runtime";function $m({element:e,attributes:t,children:o}){let r=Rb(),n=Bm(e);return Bb(Rm,{...t,className:Lb({"--selected":r,"--empty":n,"--collapsible":!!e.__collapsible}),children:o})}import{jsx as $b}from"react/jsx-runtime";var Dm=y(e=>{let{insertBreak:t}=e;if(e.insertBreak=()=>{t()},e.insertSoftBreak=()=>{e.insertText(`
1285
+ `)},e.convertElement.addConvertElementType("paragraph"),e.collapsibleParagraph={convertParagraph:()=>{e.convertElement.convertElements(()=>!1,{type:"paragraph"},!1)}},!e.normalizeAfterDelete)throw new Error("The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.");return{name:"collapsible-paragraph",editor:{normalizeNode:h(Lm,e)},editableProps:{renderElement:({element:o,attributes:r,children:n})=>{if(o.type==="paragraph")return $b($m,{element:o,attributes:r,children:n})},onKeyDown:o=>o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),o.shiftKey?e.insertSoftBreak():e.insertBreak(),!0):V({"super+0":e.collapsibleParagraph.convertParagraph})(o)}}});function zm(e,t){Array.isArray(t)?e.convertElement.convertElementTypes.push(...t):e.convertElement.convertElementTypes.push(t)}import{Editor as Z,Element as _o,Node as ce,Point as Et,Range as Db,Transforms as Ge}from"slate";function Nm(e,t,o){try{let r=Z.start(e,o),n=Z.end(e,o);if(Et.isBefore(t,r)||Et.isAfter(t,n))return-1;let i={anchor:r,focus:t};return Z.string(e,i).length}catch{return-1}}function Hm(e,t,o){try{let r=ce.get(e,t);if(!_o.isElement(r))return;let n=ce.string(r),i=Math.min(o,n.length),a=Z.start(e,t),l=0,s=a.path,m=0;for(let[d,p]of ce.texts(r)){let u=d.text.length;if(l+u>=i){s=[...t,...p],m=i-l;break}l+=u}let c={path:s,offset:m};Ge.select(e,{anchor:c,focus:c})}catch{}}function zb(e){return ce.string(e).includes(`
1286
+ `)}function Nb(e,t,o,r){let n=ce.string(t),i=n.split(`
1287
+ `),a=Z.start(e,o),l=Z.end(e,o),s=Et.isBefore(r.anchor,a)?a:Et.isAfter(r.anchor,l)?l:r.anchor,m=Et.isBefore(r.focus,a)?a:Et.isAfter(r.focus,l)?l:r.focus,c=Math.min(Z.string(e,{anchor:a,focus:s}).length,n.length),d=Math.min(Z.string(e,{anchor:a,focus:m}).length,n.length),p=Math.min(c,d),u=Math.max(c,d),g=0,x=0,C=i.length-1;for(let I=0;I<i.length;I++){let M=g+i[I].length;if(g<=p&&p<=M&&(x=I),g<=u&&u<=M){C=I;break}g=M+1}return{startLineIndex:x,endLineIndex:C}}function Hb(e,t,o,r){let n=ce.string(t);if(!n.includes(`
1257
1288
  `))return o;let i=n.split(`
1258
- `);if(i.length<=1)return o;let{startLineIndex:a,endLineIndex:l}=xb(e,t,o,r),s=i.slice(0,a),m=i.slice(a,l+1),c=i.slice(l+1);return s.length===0&&c.length===0?o:(J.withoutNormalizing(e,()=>{let d=o.slice(0,-1),p=o[o.length-1];if(c.length>0){let g=c.join(`
1289
+ `);if(i.length<=1)return o;let{startLineIndex:a,endLineIndex:l}=Nb(e,t,o,r),s=i.slice(0,a),m=i.slice(a,l+1),c=i.slice(l+1);return s.length===0&&c.length===0?o:(Z.withoutNormalizing(e,()=>{let d=o.slice(0,-1),p=o[o.length-1];if(c.length>0){let g=c.join(`
1259
1290
  `),x={...t,children:[{text:g}]};Ge.insertNodes(e,x,{at:[...d,p+1]})}let u=t.children.length;for(let g=u-1;g>=0;g--)Ge.removeNodes(e,{at:[...o,g]});if(s.length>0){Ge.insertNodes(e,{text:s.join(`
1260
1291
  `)},{at:[...o,0]});let x={type:"paragraph",children:[{text:m.join(`
1261
1292
  `)}]};Ge.insertNodes(e,x,{at:[...d,p+1]})}else Ge.insertNodes(e,{text:m.join(`
1262
- `)},{at:[...o,0]})}),s.length>0?[...o.slice(0,-1),o[o.length-1]+1]:o)}function Pm(e,t,o,r){let{selection:n}=e;if(!n)return!1;let i=-1,a=-1,l=bb.isCollapsed(n),s=Array.from(J.nodes(e,{match:p=>Oo.isElement(p)&&e.convertElement.isConvertibleElement(p)}));if(s.length>0){let[,p]=s[0];i=Mm(e,n.anchor,p),a=Mm(e,n.focus,p)}if(s.length===0)return!1;let m=[];J.withoutNormalizing(e,()=>{for(let p=s.length-1;p>=0;p--){let[u,g]=s[p];if(Eb(u)){let x=kb(e,u,g,n);m.unshift(x)}else m.unshift(g)}});let c=m.map(p=>{try{let u=pe.get(e,p);return Oo.isElement(u)?[u,p]:null}catch{return null}}).filter(p=>p!==null);if(c.length===0)return!1;if(r&&c.every(p=>t(p[0]))?J.withoutNormalizing(e,()=>{for(let p of c)Vt(e,{type:"paragraph"},p[1])}):J.withoutNormalizing(e,()=>{for(let p of c)Vt(e,o,p[1])}),c.length>0&&i>=0){let[,p]=c[0];if(l)Cm(e,p,i);else if(a>=0)try{let u=pe.get(e,p);if(Oo.isElement(u)){let g=pe.string(u),x=Math.min(i,g.length),C=Math.min(a,g.length),L=J.start(e,p),T=L.path,U=x,I=0;for(let[P,S]of pe.texts(u)){let D=P.text.length;if(I+D>=x){T=[...p,...S],U=x-I;break}I+=D}let $=L.path,w=C;I=0;for(let[P,S]of pe.texts(u)){let D=P.text.length;if(I+D>=C){$=[...p,...S],w=C-I;break}I+=D}Ge.select(e,{anchor:{path:T,offset:U},focus:{path:$,offset:w}})}}catch{Cm(e,p,i)}}return!0}function Sm(e,t){return e.convertElement.convertElementTypes.includes(t.type)}function Lm(e){return{convertElementTypes:[],addConvertElementType:h(Im,e),isConvertibleElement:h(Sm,e),convertElements:h(Pm,e)}}var Rm=y(e=>(e.convertElement=Lm(e),{name:"convert-element"}));import{Editor as Wr,Path as yb,Range as vb,Transforms as Bm}from"slate";function $m(e){let t=E(e,"heading");if(!t||!e.selection||vb.isExpanded(e.selection)||!Wr.isEnd(e,e.selection.anchor,t[1]))return!1;let o=yb.next(t[1]);return Bm.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:o}),Bm.select(e,{anchor:Wr.start(e,o),focus:Wr.start(e,o)}),!0}import{Editor as Tb}from"slate";function wb(e,t,o){e.convertElement.convertElements(r=>r.type==="heading"&&r.level==t,{type:"heading",level:t},o)}function Ib(e,t){let[o]=Tb.nodes(e,{match:r=>"type"in r&&"level"in r&&r.type==="heading"&&r.level===t});return!!o}function Dm(e){return{convertHeading:h(wb,e),isHeadingActive:h(Ib,e)}}import{css as Mb}from"@emotion/react";import Et from"@emotion/styled";var xt=Mb`
1293
+ `)},{at:[...o,0]})}),s.length>0?[...o.slice(0,-1),o[o.length-1]+1]:o)}function Am(e,t,o,r){let{selection:n}=e;if(!n)return!1;let i=-1,a=-1,l=Db.isCollapsed(n),s=Array.from(Z.nodes(e,{match:p=>_o.isElement(p)&&e.convertElement.isConvertibleElement(p)}));if(s.length>0){let[,p]=s[0];i=Nm(e,n.anchor,p),a=Nm(e,n.focus,p)}if(s.length===0)return!1;let m=[];Z.withoutNormalizing(e,()=>{for(let p=s.length-1;p>=0;p--){let[u,g]=s[p];if(zb(u)){let x=Hb(e,u,g,n);m.unshift(x)}else m.unshift(g)}});let c=m.map(p=>{try{let u=ce.get(e,p);return _o.isElement(u)?[u,p]:null}catch{return null}}).filter(p=>p!==null);if(c.length===0)return!1;if(r&&c.every(p=>t(p[0]))?Z.withoutNormalizing(e,()=>{for(let p of c)Wt(e,{type:"paragraph"},p[1])}):Z.withoutNormalizing(e,()=>{for(let p of c)Wt(e,o,p[1])}),c.length>0&&i>=0){let[,p]=c[0];if(l)Hm(e,p,i);else if(a>=0)try{let u=ce.get(e,p);if(_o.isElement(u)){let g=ce.string(u),x=Math.min(i,g.length),C=Math.min(a,g.length),I=Z.start(e,p),M=I.path,O=x,P=0;for(let[L,R]of ce.texts(u)){let D=L.text.length;if(P+D>=x){M=[...p,...R],O=x-P;break}P+=D}let $=I.path,T=C;P=0;for(let[L,R]of ce.texts(u)){let D=L.text.length;if(P+D>=C){$=[...p,...R],T=C-P;break}P+=D}Ge.select(e,{anchor:{path:M,offset:O},focus:{path:$,offset:T}})}}catch{Hm(e,p,i)}}return!0}function Om(e,t){return e.convertElement.convertElementTypes.includes(t.type)}function Um(e){return{convertElementTypes:[],addConvertElementType:h(zm,e),isConvertibleElement:h(Om,e),convertElements:h(Am,e)}}var Fm=y(e=>(e.convertElement=Um(e),{name:"convert-element"}));import{Editor as Yr,Path as Ab,Range as Ob,Transforms as Wm}from"slate";function Vm(e){let t=E(e,"heading");if(!t||!e.selection||Ob.isExpanded(e.selection)||!Yr.isEnd(e,e.selection.anchor,t[1]))return!1;let o=Ab.next(t[1]);return Wm.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:o}),Wm.select(e,{anchor:Yr.start(e,o),focus:Yr.start(e,o)}),!0}import{Editor as Ub}from"slate";function Fb(e,t,o){e.convertElement.convertElements(r=>r.type==="heading"&&r.level==t,{type:"heading",level:t},o)}function Wb(e,t){let[o]=Ub.nodes(e,{match:r=>"type"in r&&"level"in r&&r.type==="heading"&&r.level===t});return!!o}function _m(e){return{convertHeading:h(Fb,e),isHeadingActive:h(Wb,e)}}import{css as Vb}from"@emotion/react";import xt from"@emotion/styled";var kt=Vb`
1263
1294
  margin-top: 1em;
1264
1295
  &:first-of-type {
1265
1296
  margin-top: 0;
1266
1297
  }
1267
1298
  font-weight: bold;
1268
- `,zm=Et("h1")`
1269
- ${xt}
1299
+ `,Km=xt("h1")`
1300
+ ${kt}
1270
1301
  font-size: 2.25em;
1271
1302
  letter-spacing: -0.01em;
1272
- `,Nm=Et("h2")`
1273
- ${xt}
1303
+ `,Gm=xt("h2")`
1304
+ ${kt}
1274
1305
  font-size: 1.5em;
1275
- `,Hm=Et("h3")`
1276
- ${xt}
1306
+ `,qm=xt("h3")`
1307
+ ${kt}
1277
1308
  font-size: 1.25em;
1278
- `,Am=Et("h4")`
1279
- ${xt}
1309
+ `,Qm=xt("h4")`
1310
+ ${kt}
1280
1311
  font-size: 1em;
1281
- `,Om=Et("h5")`
1282
- ${xt}
1312
+ `,jm=xt("h5")`
1313
+ ${kt}
1283
1314
  font-size: 1em;
1284
- `,Um=Et("h6")`
1285
- ${xt}
1315
+ `,Xm=xt("h6")`
1316
+ ${kt}
1286
1317
  font-size: 1em;
1287
- `;import{jsx as kt}from"react/jsx-runtime";var Fm=y(e=>{e.convertElement.addConvertElementType("heading"),e.heading=Dm(e);let t=W({"super+1":oe(e.heading.convertHeading,1,!0),"super+2":oe(e.heading.convertHeading,2,!0),"super+3":oe(e.heading.convertHeading,3,!0),"super+4":oe(e.heading.convertHeading,4,!0),"super+5":oe(e.heading.convertHeading,5,!0),"super+6":oe(e.heading.convertHeading,6,!0)}),o=go(e,{"#":oe(e.heading.convertHeading,1,!1),"##":oe(e.heading.convertHeading,2,!1),"###":oe(e.heading.convertHeading,3,!1),"####":oe(e.heading.convertHeading,4,!1),"#####":oe(e.heading.convertHeading,5,!1),"######":oe(e.heading.convertHeading,6,!1)});return{name:"heading",editor:{insertBreak:h($m,e)},editableProps:{renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="heading")switch(r.level){case 1:return kt(zm,{...n,children:i});case 2:return kt(Nm,{...n,children:i});case 3:return kt(Hm,{...n,children:i});case 4:return kt(Am,{...n,children:i});case 5:return kt(Om,{...n,children:i});case 6:return kt(Um,{...n,children:i});default:{let a=r.level;throw new Error(`Expected element.level to be 1-6 but got ${a}`)}}},onKeyDown:r=>!!(t(r)||o(r))}}});import{useSelected as Pb}from"slate-react";import Cb from"@emotion/styled";var Wm=Cb("hr")`
1318
+ `;import{jsx as yt}from"react/jsx-runtime";var Ym=y(e=>{e.convertElement.addConvertElementType("heading"),e.heading=_m(e);let t=V({"super+1":ee(e.heading.convertHeading,1,!0),"super+2":ee(e.heading.convertHeading,2,!0),"super+3":ee(e.heading.convertHeading,3,!0),"super+4":ee(e.heading.convertHeading,4,!0),"super+5":ee(e.heading.convertHeading,5,!0),"super+6":ee(e.heading.convertHeading,6,!0)}),o=bo(e,{"#":ee(e.heading.convertHeading,1,!1),"##":ee(e.heading.convertHeading,2,!1),"###":ee(e.heading.convertHeading,3,!1),"####":ee(e.heading.convertHeading,4,!1),"#####":ee(e.heading.convertHeading,5,!1),"######":ee(e.heading.convertHeading,6,!1)});return{name:"heading",editor:{insertBreak:h(Vm,e)},editableProps:{renderElement:({element:r,attributes:n,children:i})=>{if(r.type==="heading")switch(r.level){case 1:return yt(Km,{...n,children:i});case 2:return yt(Gm,{...n,children:i});case 3:return yt(qm,{...n,children:i});case 4:return yt(Qm,{...n,children:i});case 5:return yt(jm,{...n,children:i});case 6:return yt(Xm,{...n,children:i});default:{let a=r.level;throw new Error(`Expected element.level to be 1-6 but got ${a}`)}}},onKeyDown:r=>!!(t(r)||o(r))}}});import{useSelected as Kb}from"slate-react";import _b from"@emotion/styled";var Jm=_b("hr")`
1288
1319
  position: relative;
1289
1320
  height: 1em;
1290
1321
  /* background-color: var(--hr-color); */
@@ -1314,7 +1345,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1314
1345
  outline: 2px solid var(--select-color, blue);
1315
1346
  }
1316
1347
  }
1317
- `;import{jsx as Vm,jsxs as Sb}from"react/jsx-runtime";function _m({attributes:e,children:t}){let o=Pb();return Sb("div",{...e,draggable:!0,children:[t,Vm("div",{contentEditable:!1,children:Vm(Wm,{className:o?"--selected":""})})]})}import{Editor as Vr,Element as Lb,Path as Km,Transforms as Uo}from"slate";function Rb(e){let{selection:t}=e;if(!t)return!1;let o=E(e,i=>Lb.isElement(i)&&e.isMaster(i)),r={type:"horizontal-rule",children:[{text:""}]},n={type:"paragraph",children:[{text:""}]};if(o==null)Vr.withoutNormalizing(e,()=>{Uo.insertNodes(e,[r,n]),Uo.move(e)});else{let i=Km.next(o[1]);Vr.withoutNormalizing(e,()=>{Uo.insertNodes(e,[r,n],{at:i});let a=Km.next(i);Uo.select(e,Vr.start(e,a))})}return!0}function Gm(e){return{insertHorizontalRule:h(Rb,e)}}import{jsx as Bb}from"react/jsx-runtime";var qm=y((e,t,{createPolicy:o})=>(e.horizontalRule=Gm(e),o({name:"horizontal-rule",editor:{isVoid(r){if(r.type==="horizontal-rule")return!0}},editableProps:{renderElement:r=>{if(r.element.type==="horizontal-rule")return Bb(_m,{...r})},onKeyDown:W({"super+-":e.horizontalRule.insertHorizontalRule})}})));import Qm from"@emotion/styled";var jm=Qm("code")`
1348
+ `;import{jsx as Zm,jsxs as Gb}from"react/jsx-runtime";function ec({attributes:e,children:t}){let o=Kb();return Gb("div",{...e,draggable:!0,children:[t,Zm("div",{contentEditable:!1,children:Zm(Jm,{className:o?"--selected":""})})]})}import{Editor as Jr,Element as qb,Path as tc,Transforms as Ko}from"slate";function Qb(e){let{selection:t}=e;if(!t)return!1;let o=E(e,i=>qb.isElement(i)&&e.isMaster(i)),r={type:"horizontal-rule",children:[{text:""}]},n={type:"paragraph",children:[{text:""}]};if(o==null)Jr.withoutNormalizing(e,()=>{Ko.insertNodes(e,[r,n]),Ko.move(e)});else{let i=tc.next(o[1]);Jr.withoutNormalizing(e,()=>{Ko.insertNodes(e,[r,n],{at:i});let a=tc.next(i);Ko.select(e,Jr.start(e,a))})}return!0}function oc(e){return{insertHorizontalRule:h(Qb,e)}}import{jsx as jb}from"react/jsx-runtime";var rc=y((e,t,{createPolicy:o})=>(e.horizontalRule=oc(e),o({name:"horizontal-rule",editor:{isVoid(r){if(r.type==="horizontal-rule")return!0}},editableProps:{renderElement:r=>{if(r.element.type==="horizontal-rule")return jb(ec,{...r})},onKeyDown:V({"super+-":e.horizontalRule.insertHorizontalRule})}})));import nc from"@emotion/styled";var ic=nc("code")`
1318
1349
  color: var(--shade-600);
1319
1350
  background-color: var(--inline-code-bgcolor);
1320
1351
  border: 1px solid var(--inline-code-border-color);
@@ -1335,16 +1366,16 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1335
1366
  */
1336
1367
  font-size: 0.75em;
1337
1368
  vertical-align: baseline;
1338
- `,_r=Qm("span")`
1369
+ `,Zr=nc("span")`
1339
1370
  display: inline-block;
1340
1371
  opacity: 0;
1341
1372
  width: 1px;
1342
1373
  overflow: hidden;
1343
- `;import{jsx as Xm,jsxs as $b}from"react/jsx-runtime";var Ym=y(e=>{if(!e.marksPlugin)throw new Error("InlineCodePlugin has a dependency on the MarksPlugin but the MarksPlugin has not been added or is added after the InlineCodePlugin");return e.inlineCode={toggleInlineCode:()=>e.marksPlugin.toggleMark("code")},{name:"inline-code",editableProps:{renderLeaf:({leaf:t,children:o})=>t.code?$b(jm,{spellCheck:!1,children:[Xm(_r,{contentEditable:!1,children:"|"}),o,Xm(_r,{contentEditable:!1,children:"|"})]}):o,onKeyDown:W({"mod+j":()=>e.inlineCode.toggleInlineCode()})}}});import{Editor as Xt,Element as Xb,Range as Yb,Transforms as vc}from"slate";function Jm(e,t){return e.convertElement.convertElements(o=>o.type==="ordered-list-item",o=>({type:"ordered-list-item",depth:"depth"in o?o.depth:0}),t)}function Zm(e,t){return e.convertElement.convertElements(o=>o.type==="task-list-item",o=>({type:"task-list-item",checked:"checked"in o?o.checked:!1,depth:"depth"in o?o.depth:0}),t)}function ec(e,t){return e.convertElement.convertElements(o=>o.type==="unordered-list-item",o=>({type:"unordered-list-item",depth:"depth"in o?o.depth:0}),t)}var Db=2;function Fo(e){let t=E(e,F);return t?t[0].depth:0}function Kr(e){return Fe(e,F)?Fo(e)<Db:!1}function Gr(e){return Fe(e,F)?Fo(e)>0:!1}function tc(e){Kr(e)&&e.list.indent()}function oc(e){Gr(e)&&e.list.outdent()}function rc(e){return bo(e,t=>({depth:t.depth+1}),{match:F})}import{Editor as zb,Transforms as qr}from"slate";function nc(e){let t=E(e,F);if(!t)return!1;let[o,r]=t;if(zb.isEmpty(e,o))return o.depth>0?(qr.setNodes(e,{depth:o.depth-1},{at:r}),!0):(Vt(e,{type:"paragraph"},r),!0);qr.splitNodes(e,{always:!0});let n=E(e,F);return n&&n[0].type==="task-list-item"&&n[0].checked===!0&&qr.setNodes(e,{checked:!1},{at:n[1]}),!0}import{Editor as Nb}from"slate";function ic(e){let t=Array.from(Nb.nodes(e,{match:F}));for(let o of t)if(o[0].depth===0)return!0;return bo(e,o=>({depth:Math.max(0,o.depth-1)}),{match:F})}import{Transforms as Hb}from"slate";function ac(e,{at:t=e.selection}={}){let o=E(e,"task-list-item",{at:t});if(!o)return!1;let r=!o[0].checked;return Hb.setNodes(e,{checked:r},{at:o[1]}),!0}function lc(e){return{indent:h(rc,e),outdent:h(ic,e),convertUnorderedList:h(ec,e),convertOrderedList:h(Jm,e),convertTaskList:h(Zm,e),insertBreak:h(nc,e),toggleTaskListItem:h(ac,e),getListDepth:h(Fo,e),canIncreaseDepth:h(Kr,e),canDecreaseDepth:h(Gr,e),increaseDepth:h(tc,e),decreaseDepth:h(oc,e)}}import{Element as Ab,Transforms as Ob}from"slate";var sc=ho(["ordered-list-item"]);function Wo(e,t){let[o,r]=t;return Ab.isElement(o)?st(e,[o,r],(n,i)=>{if(!sc(i[0]))return!1;let a=sc(n[0])||F(n[0])?i[0].depth>n[0].depth:!0;return i[0].__firstAtDepth!==a?(Ob.setNodes(e,{__firstAtDepth:a},{at:i[1]}),!0):!1}):!1}function mc(e,t){let[o]=t;return F(o)?Wo(e,t):!1}import{clsx as Fb}from"clsx";import{useEffect as Wb}from"react";import{ReactEditor as Vb,useSlateStatic as _b}from"slate-react";import Vo from"@emotion/styled";var Qr=Vo("li")`
1374
+ `;import{jsx as ac,jsxs as Xb}from"react/jsx-runtime";var lc=y(e=>{if(!e.marksPlugin)throw new Error("InlineCodePlugin has a dependency on the MarksPlugin but the MarksPlugin has not been added or is added after the InlineCodePlugin");return e.inlineCode={toggleInlineCode:()=>e.marksPlugin.toggleMark("code")},{name:"inline-code",editableProps:{renderLeaf:({leaf:t,children:o})=>t.code?Xb(ic,{spellCheck:!1,children:[ac(Zr,{contentEditable:!1,children:"|"}),o,ac(Zr,{contentEditable:!1,children:"|"})]}):o,onKeyDown:V({"mod+j":()=>e.inlineCode.toggleInlineCode()})}}});import{Editor as jt,Element as uE,Range as fE,Transforms as Bc}from"slate";function sc(e,t){return e.convertElement.convertElements(o=>o.type==="ordered-list-item",o=>({type:"ordered-list-item",depth:"depth"in o?o.depth:0}),t)}function mc(e,t){return e.convertElement.convertElements(o=>o.type==="task-list-item",o=>({type:"task-list-item",checked:"checked"in o?o.checked:!1,depth:"depth"in o?o.depth:0}),t)}function cc(e,t){return e.convertElement.convertElements(o=>o.type==="unordered-list-item",o=>({type:"unordered-list-item",depth:"depth"in o?o.depth:0}),t)}var Yb=2;function Go(e){let t=E(e,W);return t?t[0].depth:0}function en(e){return Fe(e,W)?Go(e)<Yb:!1}function tn(e){return Fe(e,W)?Go(e)>0:!1}function pc(e){en(e)&&e.list.indent()}function dc(e){tn(e)&&e.list.outdent()}function uc(e){return Eo(e,t=>({depth:t.depth+1}),{match:W})}import{Editor as Jb,Transforms as on}from"slate";function fc(e){let t=E(e,W);if(!t)return!1;let[o,r]=t;if(Jb.isEmpty(e,o))return o.depth>0?(on.setNodes(e,{depth:o.depth-1},{at:r}),!0):(Wt(e,{type:"paragraph"},r),!0);on.splitNodes(e,{always:!0});let n=E(e,W);return n&&n[0].type==="task-list-item"&&n[0].checked===!0&&on.setNodes(e,{checked:!1},{at:n[1]}),!0}import{Editor as Zb}from"slate";function hc(e){let t=Array.from(Zb.nodes(e,{match:W}));for(let o of t)if(o[0].depth===0)return!0;return Eo(e,o=>({depth:Math.max(0,o.depth-1)}),{match:W})}import{Transforms as eE}from"slate";function gc(e,{at:t=e.selection}={}){let o=E(e,"task-list-item",{at:t});if(!o)return!1;let r=!o[0].checked;return eE.setNodes(e,{checked:r},{at:o[1]}),!0}function bc(e){return{indent:h(uc,e),outdent:h(hc,e),convertUnorderedList:h(cc,e),convertOrderedList:h(sc,e),convertTaskList:h(mc,e),insertBreak:h(fc,e),toggleTaskListItem:h(gc,e),getListDepth:h(Go,e),canIncreaseDepth:h(en,e),canDecreaseDepth:h(tn,e),increaseDepth:h(pc,e),decreaseDepth:h(dc,e)}}import{Element as tE,Transforms as oE}from"slate";var Ec=go(["ordered-list-item"]);function qo(e,t){let[o,r]=t;return tE.isElement(o)?lt(e,[o,r],(n,i)=>{if(!Ec(i[0]))return!1;let a=Ec(n[0])||W(n[0])?i[0].depth>n[0].depth:!0;return i[0].__firstAtDepth!==a?(oE.setNodes(e,{__firstAtDepth:a},{at:i[1]}),!0):!1}):!1}function xc(e,t){let[o]=t;return W(o)?qo(e,t):!1}import{clsx as nE}from"clsx";import{useEffect as iE}from"react";import{ReactEditor as aE,useSlateStatic as lE}from"slate-react";import Qo from"@emotion/styled";var rn=Qo("li")`
1344
1375
  margin-top: 0.5em;
1345
1376
  margin-bottom: 0.5em;
1346
1377
  list-style-position: outside;
1347
- `,cc=Vo(Qr)`
1378
+ `,kc=Qo(rn)`
1348
1379
  position: relative;
1349
1380
  list-style-type: none;
1350
1381
  .--list-item-icon {
@@ -1354,7 +1385,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1354
1385
  line-height: 1.5em;
1355
1386
  color: var(--shade-600);
1356
1387
  }
1357
- `,pc=Vo(Qr)`
1388
+ `,yc=Qo(rn)`
1358
1389
  position: relative;
1359
1390
  list-style-type: none;
1360
1391
  counter-increment: var(--list-item-var);
@@ -1379,7 +1410,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1379
1410
  /* force numbers to be monospaced for better alignment */
1380
1411
  font-variant-numeric: tabular-nums;
1381
1412
  }
1382
- `,dc=Vo(Qr)`
1413
+ `,vc=Qo(rn)`
1383
1414
  position: relative;
1384
1415
  list-style-type: none;
1385
1416
  .--list-item-icon {
@@ -1393,7 +1424,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1393
1424
  stroke-width: 3px;
1394
1425
  }
1395
1426
  }
1396
- `;import{jsx as Kb}from"react/jsx-runtime";function uc({element:e,attributes:t,children:o}){let r=_b();Wb(()=>{let a=Vb.findPath(r,e);Wo(r,[e,a])},[]);let n={marginLeft:`${2+e.depth*2}em`,"--list-item-var":`list-item-depth-${e.depth}`},i=Fb({"--first-at-depth":e.__firstAtDepth});return Kb(pc,{...t,className:i,style:n,children:o})}import{useCallback as Gb}from"react";import{useSlateStatic as qb}from"slate-react";import{jsx as qe,jsxs as bc}from"react/jsx-runtime";var fc=e=>bc("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[qe("path",{d:"M0 0h24v24H0z",stroke:"none"}),qe("rect",{x:4,y:4,width:16,height:16,rx:2})]}),hc=e=>bc("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-checkbox",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[qe("path",{d:"M0 0h24v24H0z",stroke:"none"}),qe("path",{d:"m9 11 3 3 8-8",className:"--checkmark"}),qe("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),gc=e=>qe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",...e,children:qe("path",{d:"M12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5z"})});import{jsx as jr,jsxs as Qb}from"react/jsx-runtime";function Ec({element:e,attributes:t,children:o}){let r=qb(),n=Gb(()=>{r.list.toggleTaskListItem({at:e})},[r,e]),i=`${2+e.depth*2}em`;return Qb(dc,{...t,style:{marginLeft:i},children:[jr("div",{className:"--list-item-icon",contentEditable:!1,children:e.checked?jr(hc,{onClick:n,style:{cursor:"pointer"}}):jr(fc,{onClick:n,style:{cursor:"pointer"}})}),o]})}import{jsx as xc,jsxs as jb}from"react/jsx-runtime";function kc({element:e,attributes:t,children:o}){let r=`${2+e.depth*2}em`;return jb(cc,{...t,style:{marginLeft:r},children:[xc("div",{className:"--list-item-icon",contentEditable:!1,children:xc(gc,{})}),o]})}import{jsx as Xr}from"react/jsx-runtime";function yc({element:e,attributes:t,children:o}){switch(e.type){case"ordered-list-item":return Xr(uc,{element:e,attributes:t,children:o});case"unordered-list-item":return Xr(kc,{element:e,attributes:t,children:o});case"task-list-item":return Xr(Ec,{element:e,attributes:t,children:o})}}var Tc=["unordered-list-item","ordered-list-item","task-list-item"],F=ho(Tc);function Jb(e,t){if(t!==" "||!e.selection||!Yb.isCollapsed(e.selection))return!1;let[o]=Array.from(Xt.nodes(e,{match:s=>Xb.isElement(s)&&s.type==="paragraph",mode:"lowest"}));if(!o)return!1;let[,r]=o,i={anchor:Xt.start(e,r),focus:e.selection.anchor},a=Xt.string(e,i),l=/^-\s+\[([ xX])\]$/.exec(a);return l?(Xt.withoutNormalizing(e,()=>{vc.delete(e,{at:i}),e.convertElement.convertElements(s=>s.type==="task-list-item",s=>({type:"task-list-item",checked:l[1].toLowerCase()==="x",depth:"depth"in s&&typeof s.depth=="number"?s.depth:0}),!1)}),!0):!1}var wc=y((e,t,{createPolicy:o})=>{e.convertElement.addConvertElementType(Tc);let r=e.list=lc(e),n=W({tab:r.indent,"shift+tab":r.outdent,"super+7":h(r.convertOrderedList,!0),"super+8":h(r.convertUnorderedList,!0),"super+9":h(r.convertTaskList,!0)});return o({name:"list",editor:{normalizeNode:i=>mc(e,i),insertText:i=>Jb(e,i),insertBreak:r.insertBreak,deleteBackward:i=>{if(i!=="character"||!Fe(e,F))return!1;let a=E(e,F);if(!a)return!1;let[l,s]=a;return l.depth>0?(vc.setNodes(e,{depth:l.depth-1},{at:s}),!0):(e.collapsibleParagraph.convertParagraph(),!0)}},editableProps:{renderElement:yc,onKeyDown(i){return Xt.nodes(e,{match:F})?n(i):!1}}})});import{clsx as nE}from"clsx";import{Editor as Yr,Range as iE}from"slate";import{Editor as Zb,Text as Ic,Transforms as eE}from"slate";function Mc(e,{at:t=e.selection}={}){if(t==null)return;let o=[...Zb.nodes(e,{match:n=>Ic.isText(n),at:t})],r={};for(let[n]of o)for(let i of Object.keys(n))i!=="text"&&(r[i]=null);eE.setNodes(e,r,{match:n=>Ic.isText(n),split:!0,at:t})}import{Editor as Qe,Point as tE,Range as oE}from"slate";function je(e,t,o,{at:r=e.selection}={}){if(r==null)return;let n=oE.isRange(r)?r.focus:r,i=tE.isPoint(n)&&(Qe.after(e,n)===null||Qe.isEnd(e,n,Qe.end(e,[]))),a=t,s=(Qe.marks(e)||{})[a]===!0;if(i)if(!s)e.activeMarks={...e.activeMarks,[a]:!0};else{let{[a]:m,...c}=e.activeMarks||{};e.activeMarks=c}s?Qe.removeMark(e,a):Qe.addMark(e,a,!0),typeof o=="string"&&Qe.removeMark(e,o)}function Cc(e){return{removeMarks:h(Mc,e),toggleMark:h(je,e),toggleBold:()=>je(e,"bold"),toggleItalic:()=>je(e,"italic"),toggleUnderline:()=>je(e,"underline"),toggleStrike:()=>je(e,"strike"),toggleHighlight:()=>je(e,"highlight")}}import rE from"@emotion/styled";var Pc=rE("span")`
1427
+ `;import{jsx as sE}from"react/jsx-runtime";function Tc({element:e,attributes:t,children:o}){let r=lE();iE(()=>{let a=aE.findPath(r,e);qo(r,[e,a])},[]);let n={marginLeft:`${2+e.depth*2}em`,"--list-item-var":`list-item-depth-${e.depth}`},i=nE({"--first-at-depth":e.__firstAtDepth});return sE(yc,{...t,className:i,style:n,children:o})}import{useCallback as mE}from"react";import{useSlateStatic as cE}from"slate-react";import{jsx as qe,jsxs as Cc}from"react/jsx-runtime";var wc=e=>Cc("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[qe("path",{d:"M0 0h24v24H0z",stroke:"none"}),qe("rect",{x:4,y:4,width:16,height:16,rx:2})]}),Ic=e=>Cc("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-checkbox",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[qe("path",{d:"M0 0h24v24H0z",stroke:"none"}),qe("path",{d:"m9 11 3 3 8-8",className:"--checkmark"}),qe("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),Mc=e=>qe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",...e,children:qe("path",{d:"M12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5z"})});import{jsx as nn,jsxs as pE}from"react/jsx-runtime";function Pc({element:e,attributes:t,children:o}){let r=cE(),n=mE(()=>{r.list.toggleTaskListItem({at:e})},[r,e]),i=`${2+e.depth*2}em`;return pE(vc,{...t,style:{marginLeft:i},children:[nn("div",{className:"--list-item-icon",contentEditable:!1,children:e.checked?nn(Ic,{onClick:n,style:{cursor:"pointer"}}):nn(wc,{onClick:n,style:{cursor:"pointer"}})}),o]})}import{jsx as Sc,jsxs as dE}from"react/jsx-runtime";function Lc({element:e,attributes:t,children:o}){let r=`${2+e.depth*2}em`;return dE(kc,{...t,style:{marginLeft:r},children:[Sc("div",{className:"--list-item-icon",contentEditable:!1,children:Sc(Mc,{})}),o]})}import{jsx as an}from"react/jsx-runtime";function Rc({element:e,attributes:t,children:o}){switch(e.type){case"ordered-list-item":return an(Tc,{element:e,attributes:t,children:o});case"unordered-list-item":return an(Lc,{element:e,attributes:t,children:o});case"task-list-item":return an(Pc,{element:e,attributes:t,children:o})}}var $c=["unordered-list-item","ordered-list-item","task-list-item"],W=go($c);function hE(e,t){if(t!==" "||!e.selection||!fE.isCollapsed(e.selection))return!1;let[o]=Array.from(jt.nodes(e,{match:s=>uE.isElement(s)&&s.type==="paragraph",mode:"lowest"}));if(!o)return!1;let[,r]=o,i={anchor:jt.start(e,r),focus:e.selection.anchor},a=jt.string(e,i),l=/^-\s+\[([ xX])\]$/.exec(a);return l?(jt.withoutNormalizing(e,()=>{Bc.delete(e,{at:i}),e.convertElement.convertElements(s=>s.type==="task-list-item",s=>({type:"task-list-item",checked:l[1].toLowerCase()==="x",depth:"depth"in s&&typeof s.depth=="number"?s.depth:0}),!1)}),!0):!1}var Dc=y((e,t,{createPolicy:o})=>{e.convertElement.addConvertElementType($c);let r=e.list=bc(e),n=V({tab:r.indent,"shift+tab":r.outdent,"super+7":h(r.convertOrderedList,!0),"super+8":h(r.convertUnorderedList,!0),"super+9":h(r.convertTaskList,!0)});return o({name:"list",editor:{normalizeNode:i=>xc(e,i),insertText:i=>hE(e,i),insertBreak:r.insertBreak,deleteBackward:i=>{if(i!=="character"||!Fe(e,W))return!1;let a=E(e,W);if(!a)return!1;let[l,s]=a;return l.depth>0?(Bc.setNodes(e,{depth:l.depth-1},{at:s}),!0):(e.collapsibleParagraph.convertParagraph(),!0)}},editableProps:{renderElement:Rc,onKeyDown(i){return jt.nodes(e,{match:W})?n(i):!1}}})});import{clsx as yE}from"clsx";import{Editor as ln,Range as vE}from"slate";import{Editor as gE,Text as zc,Transforms as bE}from"slate";function Nc(e,{at:t=e.selection}={}){if(t==null)return;let o=[...gE.nodes(e,{match:n=>zc.isText(n),at:t})],r={};for(let[n]of o)for(let i of Object.keys(n))i!=="text"&&(r[i]=null);bE.setNodes(e,r,{match:n=>zc.isText(n),split:!0,at:t})}import{Editor as Qe,Point as EE,Range as xE}from"slate";function je(e,t,o,{at:r=e.selection}={}){if(r==null)return;let n=xE.isRange(r)?r.focus:r,i=EE.isPoint(n)&&(Qe.after(e,n)===null||Qe.isEnd(e,n,Qe.end(e,[]))),a=t,s=(Qe.marks(e)||{})[a]===!0;if(i)if(!s)e.activeMarks={...e.activeMarks,[a]:!0};else{let{[a]:m,...c}=e.activeMarks||{};e.activeMarks=c}s?Qe.removeMark(e,a):Qe.addMark(e,a,!0),typeof o=="string"&&Qe.removeMark(e,o)}function Hc(e){return{removeMarks:h(Nc,e),toggleMark:h(je,e),toggleBold:()=>je(e,"bold"),toggleItalic:()=>je(e,"italic"),toggleUnderline:()=>je(e,"underline"),toggleStrike:()=>je(e,"strike"),toggleHighlight:()=>je(e,"highlight")}}import kE from"@emotion/styled";var Ac=kE("span")`
1397
1428
  &.--bold {
1398
1429
  font-weight: bold;
1399
1430
  }
@@ -1416,7 +1447,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1416
1447
  &.--highlight {
1417
1448
  background-color: #ffff00;
1418
1449
  }
1419
- `;import{jsx as aE}from"react/jsx-runtime";var Sc=y(e=>{e.marksPlugin=Cc(e),e.activeMarks={};let t=W({"mod+b":e.marksPlugin.toggleBold,"mod+i":e.marksPlugin.toggleItalic,"mod+u":e.marksPlugin.toggleUnderline,"super+0":e.marksPlugin.removeMarks,"super+k":e.marksPlugin.toggleStrike,"mod+h":e.marksPlugin.toggleHighlight}),{insertText:o}=e;e.insertText=n=>{if(e.activeMarks&&Object.keys(e.activeMarks).length>0){let{activeMarks:i}=e;Object.entries(i).forEach(([a,l])=>{l&&e.addMark(a,!0)})}o(n)};let{removeMarks:r}=e.marksPlugin;return e.marksPlugin.removeMarks=()=>{if(r(),e.selection&&iE.isRange(e.selection)){let n=e.selection.focus;(Yr.after(e,n)===null||Yr.isEnd(e,n,Yr.end(e,[])))&&(e.activeMarks={})}},{name:"marks",editableProps:{renderLeaf:({leaf:n,children:i})=>aE(Pc,{className:nE({"--bold":n.bold,"--italic":n.italic,"--underline":n.underline,"--strike":n.strike,"--highlight":n.highlight}),children:i}),onKeyDown:n=>!!t(n)}}});import{Editor as Yt,Point as Lc}from"slate";function Rc(e){if(!e.selection)return;let t=Yt.parent(e,e.selection);la(e,t[1])}var Bc=y(e=>(e.normalizeAfterDelete=!0,{name:"normalize-after-delete",editor:{deleteBackward(){if(!e.selection)return!1;let t=Yt.parent(e,e.selection);return Lc.equals(Yt.start(e,t[1]),e.selection.anchor)?function(){Rc(e)}:!1},deleteForward(){if(!e.selection)return!1;let t=Yt.parent(e,e.selection);return Lc.equals(Yt.end(e,t[1]),e.selection.anchor)?function(){Rc(e)}:!1}},editableProps:{}}));import{Element as qE}from"slate";import{Editor as Dc,Path as mE,Transforms as zc}from"slate";import{Editor as lE,Path as sE}from"slate";function $c(e,t,o){let r=[...lE.positions(e,{at:t})],n=[],i,a,l;i=a=r[0],l=lt(e,o,{at:i});for(let m of r){let c=lt(e,o,{at:m});if(l&&c&&sE.equals(l,c)||l==null&&c==null)a=m;else{let d={anchor:i,focus:a};n.push(d),i=a=m,l=c}}let s={anchor:i,focus:a};return n.push(s),n.reverse(),n}function Nc(e,t){if(e.selection==null)return!1;let[o,r]=Dc.edges(e,e.selection),n=lt(e,t,{at:o}),i=lt(e,t,{at:r});if(!n&&!i||n&&i&&mE.equals(n,i))return!1;let a=$c(e,e.selection,t);return Dc.withoutNormalizing(e,()=>{for(let l of a)zc.delete(e,{at:l});zc.collapse(e,{edge:"start"})}),!0}import{Transforms as ME}from"slate";function O(e,{at:t=e.selection}={}){if(t==null)return;let o=E(e,"table-cell",{at:t});if(!o)return;let r=E(e,"table-row",{at:t});if(!r)return;let n=E(e,"table",{at:t});if(!n)return;let[i,a]=n,[l,s]=r,[m,c]=o;return{tableElement:i,tablePath:a,tableColumns:i.columns,rowElement:l,rowPath:s,rowIndex:s.slice(-1)[0],rowCount:i.children.length,cellElement:m,cellPath:c,cellIndex:c.slice(-1)[0],cellCount:l.children.length}}import{Editor as cE,Transforms as Hc}from"slate";function yt(e,t=[{type:"table-content",children:[{text:""}]}]){return{type:"table-cell",children:t}}function Ac(e,{offset:t=0,at:o=e.selection}={}){let r=O(e,{at:o});if(r===void 0)return!1;let{tableElement:n,tablePath:i,cellIndex:a}=r,l=a+t;return cE.withoutNormalizing(e,()=>{let{columns:s}=n,m=[...s],c=Math.min(l,s.length-1);m.splice(l,0,s[c]),Hc.setNodes(e,{columns:m},{at:i}),n.children.forEach((d,p)=>{Hc.insertNodes(e,yt(l),{at:[...i,p,l]})})}),!0}import{Transforms as pE}from"slate";function dE(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>yt(t))}}function Jr(e,{at:t=e.selection,offset:o=0}={}){let r=O(e,{at:t});if(!r)return!1;let n=dE(r.tableElement.columns.length);return pE.insertNodes(e,n,{at:[...r.tablePath,r.rowIndex+o]}),!0}function Oc(e,{at:t}={}){return Jr(e,{at:t,offset:1})}import{Editor as Zr,Element as uE,Path as fE,Transforms as Jt}from"slate";function Uc(e){return[...Array(e).keys()]}function hE(e){return Uc(e).map(()=>({align:"left"}))}function gE(e,t){return{type:"table",columns:hE(e),children:Uc(t).map(()=>bE(e))}}function bE(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>yt(t))}}function Fc(e,t,o,{at:r=e.selection}={}){let n=gE(t,o);return EE(e,n,{at:r})}function EE(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=E(e,n=>uE.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;Zr.withoutNormalizing(e,()=>{Jt.insertNodes(e,t,{at:o}),n&&(Jt.select(e,n),Jt.move(e))})}else{let n=fE.next(r[1]);Zr.withoutNormalizing(e,()=>{Jt.insertNodes(e,t,{at:n}),Jt.select(e,Zr.start(e,n))})}return!0}import{Path as Wc}from"slate";function Vc(e,t){let{cellIndex:o,rowIndex:r,rowCount:n,tablePath:i}=t;if(r<n-1)return re(e,[...i,r+1,o]),!0;try{return re(e,Wc.next(i)),!0}catch{return!1}}function _c(e,t){let{cellIndex:o,rowIndex:r,tablePath:n}=t;if(r>0)return re(e,[...n,r-1,o]),!0;try{return pa(e,Wc.previous(n)),!0}catch{return!1}}import{ReactEditor as xE}from"slate-react";function kE(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;try{return e.getRangeAt(0).getBoundingClientRect()}catch{return null}}function yE(e,t){return xE.toDOMNode(e,t).getBoundingClientRect()}function en(e,t){let o=kE();if(!o)return!1;let r=yE(e,t);return o.right<r.right&&o.left>r.left&&o.bottom<r.bottom&&o.top>r.top}function Kc(e){let t=O(e);return t&&setTimeout(()=>{en(e,t.cellElement)||Vc(e,t)}),!1}function Gc(e){let t=O(e);return t&&setTimeout(()=>{en(e,t.cellElement)||_c(e,t)}),!1}import{Editor as qc,Transforms as tn}from"slate";import{Transforms as vE}from"slate";function vt(e){let t=e.tablePlugin.getTableInfo();return t===void 0?!1:(vE.removeNodes(e,{at:t.tablePath}),!0)}function Qc(e,{at:t=e.selection}={}){let o=O(e,{at:t});if(!o)return!1;let{tableElement:r,tablePath:n,rowIndex:i,cellIndex:a,cellCount:l}=o;if(l===1)return vt(e);qc.withoutNormalizing(e,()=>{let s=[...r.columns];s.splice(a,1),tn.setNodes(e,{columns:s},{at:n}),r.children.forEach((c,d)=>{tn.removeNodes(e,{at:[...n,d,a]})});let m=qc.start(e,[...n,i,Math.min(a,l-2)]);tn.select(e,m)})}import{Editor as jc,Transforms as Xc}from"slate";function Yc(e,{at:t=e.selection}={}){let o=O(e,{at:t});return o===void 0?!1:o.rowCount===1?(vt(e),!0):(jc.withoutNormalizing(e,()=>{Xc.removeNodes(e,{at:o.rowPath}),Xc.select(e,jc.start(e,[...o.tablePath,Math.min(o.rowIndex,o.rowCount-2),o.cellIndex]))}),!0)}import{Transforms as TE}from"slate";function Jc(e,t){let o=O(e);if(o===void 0)return!1;let{tableElement:r,tablePath:n,cellIndex:i}=o,a=r.columns.slice();return a.splice(i,1,{align:t.align}),TE.setNodes(e,{columns:a},{at:n}),!0}import{Path as wE,Transforms as IE}from"slate";function Zc(e){let t=O(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;if(o<r-1)return re(e,[...a,n,o+1]),!0;if(n<i-1)return re(e,[...a,n+1,0]),!0;let l=wE.next(a);return IE.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:l}),re(e,l),!0}function ep(e){let t=O(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,tablePath:i}=t;if(o>0)return re(e,[...i,n,o-1]),!0;if(n>0)return re(e,[...i,n-1,r-1]),!0}function tp(e){let t=O(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;return o<r-1?(re(e,[...a,n,o+1]),!0):n<i-1?(re(e,[...a,n+1,0]),!0):(Oc(e),re(e,[...a,n+1,0]),!0)}function op(e){return{getTableInfo:h(O,e),insertTable:h(Fc,e),insertColumn:h(Ac,e),insertRow:h(Jr,e),removeTable:h(vt,e),removeColumn:h(Qc,e),removeRow:h(Yc,e),tabForward:h(Zc,e),tabBackward:h(ep,e),shiftEnterForward:h(tp,e),selectCell:h(CE,e),down:h(Kc,e),up:h(Gc,e),setTableColumnAlign:h(Jc,e)}}function CE(e,{at:t=e.selection}={}){let o=O(e,{at:t});if(o===void 0)return!1;let{cellPath:r}=o;return ME.select(e,r),!0}import{Transforms as PE}from"slate";function _o(e,t){let o=!1;return t[0].children.forEach((n,i)=>{n.children.forEach((l,s)=>{(l.x!==s||l.y!==i)&&(PE.setNodes(e,{x:s,y:i},{at:[...t[1],i,s]}),o=!0)})}),o}import{Editor as SE,Transforms as on}from"slate";function rp(e,t){let[o,r]=t;return o.children.length===1&&o.children[0].type==="table-content"?!1:(SE.withoutNormalizing(e,()=>{on.insertNodes(e,{type:"table-content",children:[{text:"X"}]},{at:[...t[1],0]});for(let n=o.children.length;n>=0;n--)on.mergeNodes(e,{at:[...r,n]});on.delete(e,{at:{path:[...r,0,0],offset:0},unit:"character"})}),!0)}import{useEffect as RE}from"react";import{ReactEditor as BE,useSelected as $E,useSlateStatic as DE}from"slate-react";import Go from"@emotion/styled";import we from"@emotion/styled";var np=we("div")`
1450
+ `;import{jsx as TE}from"react/jsx-runtime";var Oc=y(e=>{e.marksPlugin=Hc(e),e.activeMarks={};let t=V({"mod+b":e.marksPlugin.toggleBold,"mod+i":e.marksPlugin.toggleItalic,"mod+u":e.marksPlugin.toggleUnderline,"super+0":e.marksPlugin.removeMarks,"super+k":e.marksPlugin.toggleStrike,"mod+h":e.marksPlugin.toggleHighlight}),{insertText:o}=e;e.insertText=n=>{if(e.activeMarks&&Object.keys(e.activeMarks).length>0){let{activeMarks:i}=e;Object.entries(i).forEach(([a,l])=>{l&&e.addMark(a,!0)})}o(n)};let{removeMarks:r}=e.marksPlugin;return e.marksPlugin.removeMarks=()=>{if(r(),e.selection&&vE.isRange(e.selection)){let n=e.selection.focus;(ln.after(e,n)===null||ln.isEnd(e,n,ln.end(e,[])))&&(e.activeMarks={})}},{name:"marks",editableProps:{renderLeaf:({leaf:n,children:i})=>TE(Ac,{className:yE({"--bold":n.bold,"--italic":n.italic,"--underline":n.underline,"--strike":n.strike,"--highlight":n.highlight}),children:i}),onKeyDown:n=>!!t(n)}}});import{Editor as Xt,Point as Uc}from"slate";function Fc(e){if(!e.selection)return;let t=Xt.parent(e,e.selection);ga(e,t[1])}var Wc=y(e=>(e.normalizeAfterDelete=!0,{name:"normalize-after-delete",editor:{deleteBackward(){if(!e.selection)return!1;let t=Xt.parent(e,e.selection);return Uc.equals(Xt.start(e,t[1]),e.selection.anchor)?function(){Fc(e)}:!1},deleteForward(){if(!e.selection)return!1;let t=Xt.parent(e,e.selection);return Uc.equals(Xt.end(e,t[1]),e.selection.anchor)?function(){Fc(e)}:!1}},editableProps:{}}));import{Element as c0}from"slate";import{Editor as _c,Path as ME,Transforms as Kc}from"slate";import{Editor as wE,Path as IE}from"slate";function Vc(e,t,o){let r=[...wE.positions(e,{at:t})],n=[],i,a,l;i=a=r[0],l=at(e,o,{at:i});for(let m of r){let c=at(e,o,{at:m});if(l&&c&&IE.equals(l,c)||l==null&&c==null)a=m;else{let d={anchor:i,focus:a};n.push(d),i=a=m,l=c}}let s={anchor:i,focus:a};return n.push(s),n.reverse(),n}function Gc(e,t){if(e.selection==null)return!1;let[o,r]=_c.edges(e,e.selection),n=at(e,t,{at:o}),i=at(e,t,{at:r});if(!n&&!i||n&&i&&ME.equals(n,i))return!1;let a=Vc(e,e.selection,t);return _c.withoutNormalizing(e,()=>{for(let l of a)Kc.delete(e,{at:l});Kc.collapse(e,{edge:"start"})}),!0}import{Transforms as VE}from"slate";function A(e,{at:t=e.selection}={}){if(t==null)return;let o=E(e,"table-cell",{at:t});if(!o)return;let r=E(e,"table-row",{at:t});if(!r)return;let n=E(e,"table",{at:t});if(!n)return;let[i,a]=n,[l,s]=r,[m,c]=o;return{tableElement:i,tablePath:a,tableColumns:i.columns,rowElement:l,rowPath:s,rowIndex:s.slice(-1)[0],rowCount:i.children.length,cellElement:m,cellPath:c,cellIndex:c.slice(-1)[0],cellCount:l.children.length}}import{Editor as CE,Transforms as qc}from"slate";function vt(e,t=[{type:"table-content",children:[{text:""}]}]){return{type:"table-cell",children:t}}function Qc(e,{offset:t=0,at:o=e.selection}={}){let r=A(e,{at:o});if(r===void 0)return!1;let{tableElement:n,tablePath:i,cellIndex:a}=r,l=a+t;return CE.withoutNormalizing(e,()=>{let{columns:s}=n,m=[...s],c=Math.min(l,s.length-1);m.splice(l,0,s[c]),qc.setNodes(e,{columns:m},{at:i}),n.children.forEach((d,p)=>{qc.insertNodes(e,vt(l),{at:[...i,p,l]})})}),!0}import{Transforms as PE}from"slate";function SE(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>vt(t))}}function sn(e,{at:t=e.selection,offset:o=0}={}){let r=A(e,{at:t});if(!r)return!1;let n=SE(r.tableElement.columns.length);return PE.insertNodes(e,n,{at:[...r.tablePath,r.rowIndex+o]}),!0}function jc(e,{at:t}={}){return sn(e,{at:t,offset:1})}import{Editor as mn,Element as LE,Path as RE,Transforms as Yt}from"slate";function Xc(e){return[...Array(e).keys()]}function BE(e){return Xc(e).map(()=>({align:"left"}))}function $E(e,t){return{type:"table",columns:BE(e),children:Xc(t).map(()=>DE(e))}}function DE(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>vt(t))}}function Yc(e,t,o,{at:r=e.selection}={}){let n=$E(t,o);return zE(e,n,{at:r})}function zE(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=E(e,n=>LE.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;mn.withoutNormalizing(e,()=>{Yt.insertNodes(e,t,{at:o}),n&&(Yt.select(e,n),Yt.move(e))})}else{let n=RE.next(r[1]);mn.withoutNormalizing(e,()=>{Yt.insertNodes(e,t,{at:n}),Yt.select(e,mn.start(e,n))})}return!0}import{Path as Jc}from"slate";function Zc(e,t){let{cellIndex:o,rowIndex:r,rowCount:n,tablePath:i}=t;if(r<n-1)return te(e,[...i,r+1,o]),!0;try{return te(e,Jc.next(i)),!0}catch{return!1}}function ep(e,t){let{cellIndex:o,rowIndex:r,tablePath:n}=t;if(r>0)return te(e,[...n,r-1,o]),!0;try{return ka(e,Jc.previous(n)),!0}catch{return!1}}import{ReactEditor as NE}from"slate-react";function HE(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;try{return e.getRangeAt(0).getBoundingClientRect()}catch{return null}}function AE(e,t){return NE.toDOMNode(e,t).getBoundingClientRect()}function cn(e,t){let o=HE();if(!o)return!1;let r=AE(e,t);return o.right<r.right&&o.left>r.left&&o.bottom<r.bottom&&o.top>r.top}function tp(e){let t=A(e);return t&&setTimeout(()=>{cn(e,t.cellElement)||Zc(e,t)}),!1}function op(e){let t=A(e);return t&&setTimeout(()=>{cn(e,t.cellElement)||ep(e,t)}),!1}import{Editor as rp,Transforms as pn}from"slate";import{Transforms as OE}from"slate";function Tt(e){let t=e.tablePlugin.getTableInfo();return t===void 0?!1:(OE.removeNodes(e,{at:t.tablePath}),!0)}function np(e,{at:t=e.selection}={}){let o=A(e,{at:t});if(!o)return!1;let{tableElement:r,tablePath:n,rowIndex:i,cellIndex:a,cellCount:l}=o;if(l===1)return Tt(e);rp.withoutNormalizing(e,()=>{let s=[...r.columns];s.splice(a,1),pn.setNodes(e,{columns:s},{at:n}),r.children.forEach((c,d)=>{pn.removeNodes(e,{at:[...n,d,a]})});let m=rp.start(e,[...n,i,Math.min(a,l-2)]);pn.select(e,m)})}import{Editor as ip,Transforms as ap}from"slate";function lp(e,{at:t=e.selection}={}){let o=A(e,{at:t});return o===void 0?!1:o.rowCount===1?(Tt(e),!0):(ip.withoutNormalizing(e,()=>{ap.removeNodes(e,{at:o.rowPath}),ap.select(e,ip.start(e,[...o.tablePath,Math.min(o.rowIndex,o.rowCount-2),o.cellIndex]))}),!0)}import{Transforms as UE}from"slate";function sp(e,t){let o=A(e);if(o===void 0)return!1;let{tableElement:r,tablePath:n,cellIndex:i}=o,a=r.columns.slice();return a.splice(i,1,{align:t.align}),UE.setNodes(e,{columns:a},{at:n}),!0}import{Path as FE,Transforms as WE}from"slate";function mp(e){let t=A(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;if(o<r-1)return te(e,[...a,n,o+1]),!0;if(n<i-1)return te(e,[...a,n+1,0]),!0;let l=FE.next(a);return WE.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:l}),te(e,l),!0}function cp(e){let t=A(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,tablePath:i}=t;if(o>0)return te(e,[...i,n,o-1]),!0;if(n>0)return te(e,[...i,n-1,r-1]),!0}function pp(e){let t=A(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;return o<r-1?(te(e,[...a,n,o+1]),!0):n<i-1?(te(e,[...a,n+1,0]),!0):(jc(e),te(e,[...a,n+1,0]),!0)}function dp(e){return{getTableInfo:h(A,e),insertTable:h(Yc,e),insertColumn:h(Qc,e),insertRow:h(sn,e),removeTable:h(Tt,e),removeColumn:h(np,e),removeRow:h(lp,e),tabForward:h(mp,e),tabBackward:h(cp,e),shiftEnterForward:h(pp,e),selectCell:h(_E,e),down:h(tp,e),up:h(op,e),setTableColumnAlign:h(sp,e)}}function _E(e,{at:t=e.selection}={}){let o=A(e,{at:t});if(o===void 0)return!1;let{cellPath:r}=o;return VE.select(e,r),!0}import{Transforms as KE}from"slate";function jo(e,t){let o=!1;return t[0].children.forEach((n,i)=>{n.children.forEach((l,s)=>{(l.x!==s||l.y!==i)&&(KE.setNodes(e,{x:s,y:i},{at:[...t[1],i,s]}),o=!0)})}),o}import{Editor as GE,Transforms as dn}from"slate";function up(e,t){let[o,r]=t;return o.children.length===1&&o.children[0].type==="table-content"?!1:(GE.withoutNormalizing(e,()=>{dn.insertNodes(e,{type:"table-content",children:[{text:"X"}]},{at:[...t[1],0]});for(let n=o.children.length;n>=0;n--)dn.mergeNodes(e,{at:[...r,n]});dn.delete(e,{at:{path:[...r,0,0],offset:0},unit:"character"})}),!0)}import{useEffect as QE}from"react";import{ReactEditor as jE,useSelected as XE,useSlateStatic as YE}from"slate-react";import Yo from"@emotion/styled";import we from"@emotion/styled";var fp=we("div")`
1420
1451
  position: absolute;
1421
1452
  /**
1422
1453
  * very slightly shaded
@@ -1440,7 +1471,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1440
1471
  background: rgba(0, 0, 0, 0.15);
1441
1472
  }
1442
1473
  }
1443
- `,ip=we(np)`
1474
+ `,hp=we(fp)`
1444
1475
  cursor: pointer;
1445
1476
  /**
1446
1477
  * hangs out on top
@@ -1450,7 +1481,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1450
1481
  right: 0;
1451
1482
  height: 3em;
1452
1483
  top: -3em;
1453
- `,ap=we(np)`
1484
+ `,gp=we(fp)`
1454
1485
  /**
1455
1486
  * hangs out on left
1456
1487
  */
@@ -1458,7 +1489,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1458
1489
  bottom: -1px;
1459
1490
  width: 3em;
1460
1491
  left: -3em;
1461
- `,lp=we("div")`
1492
+ `,bp=we("div")`
1462
1493
  position: absolute;
1463
1494
  background: rgba(0, 0, 0, 0.05);
1464
1495
  border: 1px solid rgba(0, 0, 0, 0.05);
@@ -1470,7 +1501,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1470
1501
  left: 0;
1471
1502
  right: 0;
1472
1503
  bottom: 0;
1473
- `,sp=we(lp)`
1504
+ `,Ep=we(bp)`
1474
1505
  top: 50%;
1475
1506
  border-bottom: none;
1476
1507
  border-right: none;
@@ -1496,7 +1527,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1496
1527
 
1497
1528
  /* border-top-left-radius: 0.5em;
1498
1529
  border-top-right-radius: 0.5em; */
1499
- `,mp=we(lp)`
1530
+ `,xp=we(bp)`
1500
1531
  left: 50%;
1501
1532
  border-right: none;
1502
1533
  border-bottom: none;
@@ -1522,7 +1553,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1522
1553
 
1523
1554
  /* border-top-left-radius: 0.5em;
1524
1555
  border-bottom-left-radius: 0.5em; */
1525
- `,cp=we("div")`
1556
+ `,kp=we("div")`
1526
1557
  position: absolute;
1527
1558
  font-size: 1.5em;
1528
1559
  background: white;
@@ -1531,27 +1562,27 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1531
1562
  svg {
1532
1563
  display: block;
1533
1564
  }
1534
- `,Tt=we(cp)`
1565
+ `,wt=we(kp)`
1535
1566
  color: #c0c0c0;
1536
1567
  &:hover {
1537
1568
  color: royalblue;
1538
1569
  }
1539
- `,Ko=we(cp)`
1570
+ `,Xo=we(kp)`
1540
1571
  color: #c0c0c0;
1541
1572
  &:hover {
1542
1573
  color: firebrick;
1543
1574
  }
1544
- `;var pp=Go("table")`
1575
+ `;var yp=Yo("table")`
1545
1576
  border-collapse: collapse;
1546
1577
  margin: 1em 0;
1547
1578
  ${({columns:e})=>e.map((t,o)=>`td:nth-of-type(${o+1}) { text-align: ${t.align}; }`).join(`
1548
1579
  `)}
1549
- `,dp=Go("tr")`
1580
+ `,vp=Yo("tr")`
1550
1581
  position: relative;
1551
1582
  &:first-of-type {
1552
1583
  background: var(--table-head-bgcolor);
1553
1584
  }
1554
- `,up=Go("td")`
1585
+ `,Tp=Yo("td")`
1555
1586
  position: relative;
1556
1587
  border-width: 1px;
1557
1588
  border-style: solid;
@@ -1571,7 +1602,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1571
1602
  &:last-of-type {
1572
1603
  border-right-color: var(--table-border-color);
1573
1604
  }
1574
- `,fp=Go("div")`
1605
+ `,wp=Yo("div")`
1575
1606
  /**
1576
1607
  * Smaller font inside a table than outside of it
1577
1608
  */
@@ -1583,7 +1614,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1583
1614
  color: rgba(0, 0, 0, 0.6);
1584
1615
  font-size: 0.875em; /* 14px */
1585
1616
  }
1586
- `;import{createContext as LE}from"react";var qo=LE({isSelected:!1});import{jsx as rn}from"react/jsx-runtime";function hp({element:e,attributes:t,children:o}){let r=DE(),n=$E();return RE(()=>{try{let i=BE.findPath(r,e);_o(r,[e,i])}catch{}},[]),rn(qo.Provider,{value:{isSelected:n},children:rn(pp,{...t,columns:e.columns,children:rn("tbody",{children:o})})})}import{useContext as WE}from"react";import{useSelected as VE}from"slate-react";import{useCallback as nn,useRef as zE,useState as NE}from"react";import{useSlateStatic as HE}from"slate-react";import{jsx as se}from"react/jsx-runtime";var wt=e=>se("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:se("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm.75-11.25a.75.75 0 0 0-1.5 0v2.5h-2.5a.75.75 0 0 0 0 1.5h2.5v2.5a.75.75 0 0 0 1.5 0v-2.5h2.5a.75.75 0 0 0 0-1.5h-2.5v-2.5z",clipRule:"evenodd"})}),Qo=e=>se("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:se("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM6.75 9.25a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5z",clipRule:"evenodd"})}),jo=()=>se(k,{children:se("path",{d:"M4 6h16M4 12h16M4 18h16"})}),gp=()=>se(k,{children:se("path",{d:"M4 6h16M4 12h10M4 18h14"})}),bp=()=>se(k,{children:se("path",{d:"M4 6h16M8 12h8M6 18h12"})}),Ep=()=>se(k,{children:se("path",{d:"M4 6h16M10 12h10M6 18h14"})});import{Fragment as AE,jsx as Ie,jsxs as xp}from"react/jsx-runtime";function kp({cellElement:e}){let t=HE(),o=K("column-menu"),r=zE(null),[n,i]=NE(!1),a=nn(()=>{i(!0)},[]),l=nn(()=>{i(!1)},[]),s=nn(()=>{o.layer&&o.close();let m=r.current;if(m===null)return;let c=[{icon:gp,title:"\u5DE6\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"left"})}},{icon:bp,title:"\u4E2D\u592E\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"center"})}},{icon:Ep,title:"\u53F3\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"right"})}}];o.open(()=>Ie(ct,{dest:m,items:c,close:o.close}))},[]);return xp(ip,{ref:r,contentEditable:!1,onClick:s,onMouseEnter:a,onMouseLeave:l,children:[Ie(sp,{className:"--tile",children:Ie(jo,{})}),n?xp(AE,{children:[Ie(Ko,{style:{top:0,left:"50%",marginLeft:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeColumn({at:e}),children:Ie(Qo,{})}),Ie(Tt,{style:{left:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e}),children:Ie(wt,{})}),Ie(Tt,{style:{right:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e,offset:1}),children:Ie(wt,{})})]}):null]})}import{useState as OE}from"react";import{useSlateStatic as UE}from"slate-react";import{Fragment as FE,jsx as Ae,jsxs as yp}from"react/jsx-runtime";function vp({cellElement:e}){let t=UE(),[o,r]=OE(!1);return yp(ap,{contentEditable:!1,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[Ae(mp,{className:"--tile",children:Ae(jo,{})}),o?yp(FE,{children:[Ae(Ko,{style:{top:"50%",left:"0.5em",marginTop:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeRow({at:e}),children:Ae(Qo,{})}),Ae(Tt,{style:{top:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e}),children:Ae(wt,{})}),Ae(Tt,{style:{bottom:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e,offset:1}),children:Ae(wt,{})})]}):null]})}import Tp from"@emotion/styled";var wp=Tp("div")`
1617
+ `;import{createContext as qE}from"react";var Jo=qE({isSelected:!1});import{jsx as un}from"react/jsx-runtime";function Ip({element:e,attributes:t,children:o}){let r=YE(),n=XE();return QE(()=>{try{let i=jE.findPath(r,e);jo(r,[e,i])}catch{}},[]),un(Jo.Provider,{value:{isSelected:n},children:un(yp,{...t,columns:e.columns,children:un("tbody",{children:o})})})}import{useContext as i0}from"react";import{useSelected as a0}from"slate-react";import{useCallback as fn,useRef as JE,useState as ZE}from"react";import{useSlateStatic as e0}from"slate-react";import{jsx as ae}from"react/jsx-runtime";var It=e=>ae("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:ae("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm.75-11.25a.75.75 0 0 0-1.5 0v2.5h-2.5a.75.75 0 0 0 0 1.5h2.5v2.5a.75.75 0 0 0 1.5 0v-2.5h2.5a.75.75 0 0 0 0-1.5h-2.5v-2.5z",clipRule:"evenodd"})}),Zo=e=>ae("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"1em",height:"1em",...e,children:ae("path",{fillRule:"evenodd",d:"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM6.75 9.25a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5z",clipRule:"evenodd"})}),er=()=>ae(k,{children:ae("path",{d:"M4 6h16M4 12h16M4 18h16"})}),Mp=()=>ae(k,{children:ae("path",{d:"M4 6h16M4 12h10M4 18h14"})}),Cp=()=>ae(k,{children:ae("path",{d:"M4 6h16M8 12h8M6 18h12"})}),Pp=()=>ae(k,{children:ae("path",{d:"M4 6h16M10 12h10M6 18h14"})});import{Fragment as t0,jsx as Ie,jsxs as Sp}from"react/jsx-runtime";function Lp({cellElement:e}){let t=e0(),o=F("column-menu"),r=JE(null),[n,i]=ZE(!1),a=fn(()=>{i(!0)},[]),l=fn(()=>{i(!1)},[]),s=fn(()=>{o.layer&&o.close();let m=r.current;if(m===null)return;let c=[{icon:Mp,title:"\u5DE6\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"left"})}},{icon:Cp,title:"\u4E2D\u592E\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"center"})}},{icon:Pp,title:"\u53F3\u63C3\u3048",action:()=>{t.tablePlugin.setTableColumnAlign({align:"right"})}}];o.open(()=>Ie(ct,{dest:m,items:c,close:o.close}))},[]);return Sp(hp,{ref:r,contentEditable:!1,onClick:s,onMouseEnter:a,onMouseLeave:l,children:[Ie(Ep,{className:"--tile",children:Ie(er,{})}),n?Sp(t0,{children:[Ie(Xo,{style:{top:0,left:"50%",marginLeft:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeColumn({at:e}),children:Ie(Zo,{})}),Ie(wt,{style:{left:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e}),children:Ie(It,{})}),Ie(wt,{style:{right:"-0.5em",top:0},onMouseDown:()=>t.tablePlugin.insertColumn({at:e,offset:1}),children:Ie(It,{})})]}):null]})}import{useState as o0}from"react";import{useSlateStatic as r0}from"slate-react";import{Fragment as n0,jsx as Ae,jsxs as Rp}from"react/jsx-runtime";function Bp({cellElement:e}){let t=r0(),[o,r]=o0(!1);return Rp(gp,{contentEditable:!1,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[Ae(xp,{className:"--tile",children:Ae(er,{})}),o?Rp(n0,{children:[Ae(Xo,{style:{top:"50%",left:"0.5em",marginTop:"-0.5em"},onMouseDown:()=>t.tablePlugin.removeRow({at:e}),children:Ae(Zo,{})}),Ae(wt,{style:{top:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e}),children:Ae(It,{})}),Ae(wt,{style:{bottom:"-0.5em",left:"0.5em"},onMouseDown:()=>t.tablePlugin.insertRow({at:e,offset:1}),children:Ae(It,{})})]}):null]})}import $p from"@emotion/styled";var Dp=$p("div")`
1587
1618
  position: absolute;
1588
1619
  /**
1589
1620
  * very slightly shaded
@@ -1615,7 +1646,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1615
1646
  background: rgba(0, 0, 0, 0.15);
1616
1647
  }
1617
1648
  }
1618
- `,Ip=Tp("div")`
1649
+ `,zp=$p("div")`
1619
1650
  position: absolute;
1620
1651
  left: 0;
1621
1652
  top: 0;
@@ -1623,8 +1654,8 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1623
1654
  height: 1.5em;
1624
1655
  background: rgba(0, 0, 0, 0.05);
1625
1656
  border-radius: 50%;
1626
- `;import{jsx as Mp}from"react/jsx-runtime";function Cp(){return Mp(wp,{contentEditable:!1,children:Mp(Ip,{className:"--table-menu-tile"})})}import{jsx as an,jsxs as _E}from"react/jsx-runtime";function Pp({element:e,attributes:t,children:o}){let r=WE(qo),n=VE(),i=r.isSelected&&e.x===0&&e.y===0,a=r.isSelected&&e.x===0,l=r.isSelected&&e.y===0;return _E(up,{className:n?"--selected":"",...t,"data-x":e.x,"data-y":e.y,children:[o,i?an(Cp,{}):null,a?an(vp,{cellElement:e}):null,l?an(kp,{cellElement:e}):null]})}import{jsx as KE}from"react/jsx-runtime";function Sp({attributes:e,children:t}){return KE(fp,{...e,children:t})}import{jsx as GE}from"react/jsx-runtime";function Lp({attributes:e,children:t}){return GE(dp,{...e,children:t})}import{jsx as Xo}from"react/jsx-runtime";function Rp({element:e,attributes:t,children:o}){switch(e.type){case"table":return Xo(hp,{element:e,attributes:t,children:o});case"table-row":return Xo(Lp,{element:e,attributes:t,children:o});case"table-cell":return Xo(Pp,{element:e,attributes:t,children:o});case"table-content":return Xo(Sp,{element:e,attributes:t,children:o})}}var Bp=y((e,t,{createPolicy:o})=>(e.supportsTable=!0,e.tablePlugin=op(e),o({name:"table",editor:{deleteBackward:()=>Fe(e,"table-cell"),deleteForward:()=>ra(e,"table-cell"),deleteFragment:()=>Nc(e,["table-cell"]),insertBreak:()=>E(e,"table-cell")?(e.insertText(`
1627
- `),!0):!1,isMaster(r){if(r.type==="table")return!0},normalizeNode:r=>{let[n]=r;if(!qE.isElement(n))return!1;switch(n.type){case"table":return _o(e,r);case"table-cell":return rp(e,r)}return!1}},editableProps:{renderElement:Rp,onKeyDown:W({tab:e.tablePlugin.tabForward,"shift+tab":e.tablePlugin.tabBackward,"shift+enter":e.tablePlugin.shiftEnterForward,down:e.tablePlugin.down,up:e.tablePlugin.up,"mod+a":e.tablePlugin.selectCell,"super+t":()=>e.tablePlugin.insertTable(3,2),"mod+shift+enter":()=>e.tablePlugin.insertRow({offset:0}),"mod+enter":()=>e.tablePlugin.insertRow({offset:1}),"super+[":()=>e.tablePlugin.insertColumn({offset:0}),"super+]":()=>e.tablePlugin.insertColumn({offset:1}),"super+backspace":e.tablePlugin.removeTable,"mod+backspace":e.tablePlugin.removeRow,"mod+shift+backspace":e.tablePlugin.removeColumn})}})));import{Global as YE}from"@emotion/react";import{css as QE}from"@emotion/react";var jE=`
1657
+ `;import{jsx as Np}from"react/jsx-runtime";function Hp(){return Np(Dp,{contentEditable:!1,children:Np(zp,{className:"--table-menu-tile"})})}import{jsx as hn,jsxs as l0}from"react/jsx-runtime";function Ap({element:e,attributes:t,children:o}){let r=i0(Jo),n=a0(),i=r.isSelected&&e.x===0&&e.y===0,a=r.isSelected&&e.x===0,l=r.isSelected&&e.y===0;return l0(Tp,{className:n?"--selected":"",...t,"data-x":e.x,"data-y":e.y,children:[o,i?hn(Hp,{}):null,a?hn(Bp,{cellElement:e}):null,l?hn(Lp,{cellElement:e}):null]})}import{jsx as s0}from"react/jsx-runtime";function Op({attributes:e,children:t}){return s0(wp,{...e,children:t})}import{jsx as m0}from"react/jsx-runtime";function Up({attributes:e,children:t}){return m0(vp,{...e,children:t})}import{jsx as tr}from"react/jsx-runtime";function Fp({element:e,attributes:t,children:o}){switch(e.type){case"table":return tr(Ip,{element:e,attributes:t,children:o});case"table-row":return tr(Up,{element:e,attributes:t,children:o});case"table-cell":return tr(Ap,{element:e,attributes:t,children:o});case"table-content":return tr(Op,{element:e,attributes:t,children:o})}}var Wp=y((e,t,{createPolicy:o})=>(e.supportsTable=!0,e.tablePlugin=dp(e),o({name:"table",editor:{deleteBackward:()=>Fe(e,"table-cell"),deleteForward:()=>da(e,"table-cell"),deleteFragment:()=>Gc(e,["table-cell"]),insertBreak:()=>E(e,"table-cell")?(e.insertText(`
1658
+ `),!0):!1,isMaster(r){if(r.type==="table")return!0},normalizeNode:r=>{let[n]=r;if(!c0.isElement(n))return!1;switch(n.type){case"table":return jo(e,r);case"table-cell":return up(e,r)}return!1}},editableProps:{renderElement:Fp,onKeyDown:V({tab:e.tablePlugin.tabForward,"shift+tab":e.tablePlugin.tabBackward,"shift+enter":e.tablePlugin.shiftEnterForward,down:e.tablePlugin.down,up:e.tablePlugin.up,"mod+a":e.tablePlugin.selectCell,"super+t":()=>e.tablePlugin.insertTable(3,2),"mod+shift+enter":()=>e.tablePlugin.insertRow({offset:0}),"mod+enter":()=>e.tablePlugin.insertRow({offset:1}),"super+[":()=>e.tablePlugin.insertColumn({offset:0}),"super+]":()=>e.tablePlugin.insertColumn({offset:1}),"super+backspace":e.tablePlugin.removeTable,"mod+backspace":e.tablePlugin.removeRow,"mod+shift+backspace":e.tablePlugin.removeColumn})}})));import{Global as f0}from"@emotion/react";import{css as p0}from"@emotion/react";var d0=`
1628
1659
  --blue-50: rgb(239 246 255);
1629
1660
  --blue-100: rgb(219 234 254);
1630
1661
  --blue-200: rgb(191 219 254);
@@ -1635,7 +1666,7 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1635
1666
  --blue-700: rgb(29 78 216);
1636
1667
  --blue-800: rgb(30 64 175);
1637
1668
  --blue-900: rgb(30 58 138);
1638
- `,XE=`
1669
+ `,u0=`
1639
1670
  --shade-50: rgb(250 250 250);
1640
1671
  --shade-100: rgb(244 244 245);
1641
1672
  --shade-200: rgb(228 228 231);
@@ -1646,11 +1677,11 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1646
1677
  --shade-700: rgb(63 63 70);
1647
1678
  --shade-800: rgb(39 39 42);
1648
1679
  --shade-900: rgb(24 24 27);
1649
- `,$p=QE`
1680
+ `,Vp=p0`
1650
1681
  :root {
1651
1682
  /* Tailwind Colors */
1652
- ${jE}
1653
- ${XE}
1683
+ ${d0}
1684
+ ${u0}
1654
1685
  /* Select Colors */
1655
1686
  --select-color: var(--blue-400);
1656
1687
  --select-editor-color: var(--blue-200);
@@ -1672,14 +1703,14 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1672
1703
  /* Horizontal Rule Colors */
1673
1704
  --hr-color: var(--shade-300);
1674
1705
  }
1675
- `;import{Fragment as JE,jsx as Dp,jsxs as ZE}from"react/jsx-runtime";var zp=y(e=>(e.theme=!0,{name:"theme",editor:{},renderEditable:({attributes:t,Editable:o})=>ZE(JE,{children:[Dp(YE,{styles:$p}),Dp(o,{...t})]}),editableProps:{}}));import{clsx as A0}from"clsx";import{useCallback as O0,useRef as U0}from"react";import{Editor as F0,Transforms as W0}from"slate";import{ReactEditor as V0,useFocused as _0,useSlateStatic as K0}from"slate-react";import{clsx as e0}from"clsx";import{useCallback as Op,useRef as t0,useState as o0}from"react";import{ReactEditor as r0,useSlateStatic as n0}from"slate-react";import ln from"@emotion/styled";var Np=ln(ie)`
1706
+ `;import{Fragment as h0,jsx as _p,jsxs as g0}from"react/jsx-runtime";var Kp=y(e=>(e.theme=!0,{name:"theme",editor:{},renderEditable:({attributes:t,Editable:o})=>g0(h0,{children:[_p(f0,{styles:Vp}),_p(o,{...t})]}),editableProps:{}}));import{clsx as tx}from"clsx";import{useCallback as ox,useRef as rx}from"react";import{Editor as nx,Transforms as ix}from"slate";import{ReactEditor as ax,useFocused as lx,useSlateStatic as sx}from"slate-react";import{clsx as b0}from"clsx";import{useCallback as jp,useRef as E0,useState as x0}from"react";import{ReactEditor as k0,useSlateStatic as y0}from"slate-react";import gn from"@emotion/styled";var Gp=gn(re)`
1676
1707
  padding: 0.5em;
1677
- `,Hp=ln("div")`
1708
+ `,qp=gn("div")`
1678
1709
  display: grid;
1679
1710
  grid-template-columns: repeat(5, 1.75em);
1680
1711
  grid-template-rows: 1.5em;
1681
1712
  /* grid-gap: 1px; */
1682
- `,Ap=ln("div")`
1713
+ `,Qp=gn("div")`
1683
1714
  background: var(--shade-100);
1684
1715
  height: 1.5em;
1685
1716
  border-radius: 0.125em;
@@ -1689,11 +1720,11 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1689
1720
  &.--selected {
1690
1721
  background: var(--blue-100);
1691
1722
  }
1692
- `;import{Fragment as i0,jsx as Yo,jsxs as a0}from"react/jsx-runtime";function Up(e){return[...Array(e).keys()]}function Fp({dest:e,close:t}){let[o,r]=o0({x:0,y:0}),n=n0(),i=t0(null),a=ne({src:i,dest:e},({dest:d})=>d?{left:d.left-8,top:d.top+d.height}:{left:0,top:0}),l=Up(5).map(d=>d+1),s=Up(5).map(d=>d+1),m=Op((d,p)=>{r({x:d,y:p})},[r]),c=Op((d,p)=>{n.tablePlugin.insertTable(d,p),r0.focus(n),t()},[n]);return a0(i0,{children:[Yo(Le,{close:t}),Yo(Np,{ref:i,style:a,children:Yo(Hp,{onMouseLeave:()=>m(0,0),children:l.map(d=>s.map(p=>{let u=p<=o.x&&d<=o.y;return Yo(Ap,{className:e0({"--selected":u}),onMouseEnter:()=>m(p,d),onClick:()=>c(p,d)},`${p},${d}`)}))})})]})}import{useEffect as L0,useRef as R0,useState as B0}from"react";import{useSlateStatic as $0}from"slate-react";import{jsx as b,jsxs as It}from"react/jsx-runtime";var Wp=()=>b(k,{children:b("path",{d:"M7 12h10M7 5v14M17 5v14M15 19h4M15 5h4M5 19h4M5 5h4"})}),Vp=()=>b(k,{className:"--more-icon",width:"0.5em",viewBox:"0 0 12 24",children:b("path",{d:"m2 12 4 4 4-4"})}),_p=()=>b(k,{width:"0.5em",viewBox:"6 0 12 24",children:b("path",{d:"M9 12h6M12 9v6"})}),Kp=()=>b(k,{children:b("path",{d:"M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),Gp=()=>b(k,{children:b("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591-.417 1.318-.816 1.858L17 18.001h4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),qp=()=>b(k,{children:b("path",{d:"M19 14a2 2 0 1 0-2-2M17 16a2 2 0 1 0 2-2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})});var Qp=()=>b(k,{children:b("path",{d:"M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z"})}),sn=()=>b(k,{children:b("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7"})}),jp=()=>b(k,{children:b("path",{d:"M11 5h6M7 19h6M14 5l-4 14"})});var Jo=()=>It(k,{children:[b("path",{d:"M10 14a3.5 3.5 0 0 0 5 0l4-4a3.5 3.5 0 0 0-5-5l-.5.5"}),b("path",{d:"M14 10a3.5 3.5 0 0 0-5 0l-4 4a3.5 3.5 0 0 0 5 5l.5-.5"})]});var mn=()=>b(k,{children:b("path",{d:"M10 11H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5M19 11h-4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5"})}),Xp=()=>It(k,{children:[b("path",{d:"M10 9l4 3-4 3"}),b("path",{d:"M16 9l4 3-4 3"})]});var Yp=()=>b(k,{children:b("path",{d:"M9 6h11M9 12h11M9 18h11M5 6v.01M5 12v.01M5 18v.01"})}),Jp=()=>It(k,{children:[b("rect",{x:4,y:4,width:16,height:16,rx:2}),b("path",{d:"M4 10h16M10 4v16"})]}),Zp=()=>b(k,{children:b("path",{d:"m7 8-4 4 4 4M17 8l4 4-4 4M14 4l-4 16"})}),ed=()=>b(k,{children:b("path",{d:"M9 8L5 12L9 16M15 8L19 12L15 16"})}),td=()=>It(k,{children:[b("path",{d:"M15 8h.01"}),b("rect",{x:4,y:4,width:16,height:16,rx:3}),b("path",{d:"m4 15 4-4a3 5 0 0 1 3 0l5 5"}),b("path",{d:"m14 14 1-1a3 5 0 0 1 3 0l2 2"})]});var od=()=>b(k,{children:b("path",{d:"M12 5v14M5 12h14"})}),rd=()=>b(k,{children:b("path",{d:"M5 12h14M16 6.5A4 2 0 0 0 12 5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1-4-1.5"})}),nd=()=>b(k,{children:b("path",{d:"M7 5v5a5 5 0 0 0 10 0V5M5 19h14"})});var id=()=>It(k,{children:[b("path",{d:"m9 11 3 3 8-8"}),b("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),cn=()=>b(k,{children:b("path",{d:"M11 6h9M11 12h9M12 18h8M4 16a2 2 0 1 1 4 0c0 .591-.5 1-1 1.5L4 20h4M6 10V4L4 6"})}),ad=()=>b(k,{children:b("path",{d:"M4 6h16M8 12h12M12 18h8M7 12l-3-3M7 12l-3 3"})}),ld=()=>b(k,{children:b("path",{d:"M4 6h16M8 12h12M12 18h8M4 12l3-3M4 12l3 3"})});var sd=()=>b(k,{children:b("path",{d:"M18 6L6 18M6 6l12 12"})}),md=()=>It(k,{children:[b("path",{d:"M4 20h4l10.5-10.5a2.828 2.828 0 1 0-4-4L4 16v4"}),b("path",{d:"M13.5 6.5l4 4"}),b("path",{d:"m14 19 6-6M18 15l2 2M5 21h4"})]}),cd=()=>b(k,{children:b("path",{d:"M5 12h14"})});var pn=[{icon:ad,title:f("increaseDepth"),hotkey:"tab",action:e=>e.list.increaseDepth(),active:e=>e.list.canIncreaseDepth()},{icon:ld,title:f("decreaseDepth"),hotkey:"shift+tab",action:e=>e.list.decreaseDepth(),active:e=>e.list.canDecreaseDepth()}],pd=[{icon:Qp,title:f("normal"),hotkey:"super+0",action:e=>{e.collapsibleParagraph.convertParagraph()}},{icon:Kp,title:f("heading1"),hotkey:"super+1",action:e=>e.heading.convertHeading(1,!0),active:e=>e.heading.isHeadingActive(1)},{icon:Gp,title:f("heading2"),hotkey:"super+2",action:e=>e.heading.convertHeading(2,!0),active:e=>e.heading.isHeadingActive(2)},{icon:qp,title:f("heading3"),hotkey:"super+3",action:e=>e.heading.convertHeading(3,!0),active:e=>e.heading.isHeadingActive(3)}],dd=[...pd],dn=[{icon:Wp,title:f("paragraphStyle"),more:!0,children:pd}];import{useState as Me,useRef as fd,useEffect as s0,useCallback as un}from"react";import{useSlateStatic as m0}from"slate-react";import l0 from"@emotion/styled";var ud=l0(ie)`
1723
+ `;import{Fragment as v0,jsx as or,jsxs as T0}from"react/jsx-runtime";function Xp(e){return[...Array(e).keys()]}function Yp({dest:e,close:t}){let[o,r]=x0({x:0,y:0}),n=y0(),i=E0(null),a=oe({src:i,dest:e},({dest:d})=>d?{left:d.left-8,top:d.top+d.height}:{left:0,top:0}),l=Xp(5).map(d=>d+1),s=Xp(5).map(d=>d+1),m=jp((d,p)=>{r({x:d,y:p})},[r]),c=jp((d,p)=>{n.tablePlugin.insertTable(d,p),k0.focus(n),t()},[n]);return T0(v0,{children:[or(Re,{close:t}),or(Gp,{ref:i,style:a,children:or(qp,{onMouseLeave:()=>m(0,0),children:l.map(d=>s.map(p=>{let u=p<=o.x&&d<=o.y;return or(Qp,{className:b0({"--selected":u}),onMouseEnter:()=>m(p,d),onClick:()=>c(p,d)},`${p},${d}`)}))})})]})}import{useEffect as q0,useRef as Q0,useState as j0}from"react";import{useSlateStatic as X0}from"slate-react";import{jsx as b,jsxs as Mt}from"react/jsx-runtime";var Jp=()=>b(k,{children:b("path",{d:"M7 12h10M7 5v14M17 5v14M15 19h4M15 5h4M5 19h4M5 5h4"})}),Zp=()=>b(k,{className:"--more-icon",width:"0.5em",viewBox:"0 0 12 24",children:b("path",{d:"m2 12 4 4 4-4"})}),ed=()=>b(k,{width:"0.5em",viewBox:"6 0 12 24",children:b("path",{d:"M9 12h6M12 9v6"})}),td=()=>b(k,{children:b("path",{d:"M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),od=()=>b(k,{children:b("path",{d:"M17 12a2 2 0 1 1 4 0c0 .591-.417 1.318-.816 1.858L17 18.001h4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})}),rd=()=>b(k,{children:b("path",{d:"M19 14a2 2 0 1 0-2-2M17 16a2 2 0 1 0 2-2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2"})});var nd=()=>b(k,{children:b("path",{d:"M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z"})}),bn=()=>b(k,{children:b("path",{d:"M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7"})}),id=()=>b(k,{children:b("path",{d:"M11 5h6M7 19h6M14 5l-4 14"})});var rr=()=>Mt(k,{children:[b("path",{d:"M10 14a3.5 3.5 0 0 0 5 0l4-4a3.5 3.5 0 0 0-5-5l-.5.5"}),b("path",{d:"M14 10a3.5 3.5 0 0 0-5 0l-4 4a3.5 3.5 0 0 0 5 5l.5-.5"})]});var En=()=>b(k,{children:b("path",{d:"M10 11H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5M19 11h-4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5"})}),ad=()=>Mt(k,{children:[b("path",{d:"M10 9l4 3-4 3"}),b("path",{d:"M16 9l4 3-4 3"})]});var ld=()=>b(k,{children:b("path",{d:"M9 6h11M9 12h11M9 18h11M5 6v.01M5 12v.01M5 18v.01"})}),sd=()=>Mt(k,{children:[b("rect",{x:4,y:4,width:16,height:16,rx:2}),b("path",{d:"M4 10h16M10 4v16"})]}),md=()=>b(k,{children:b("path",{d:"m7 8-4 4 4 4M17 8l4 4-4 4M14 4l-4 16"})}),cd=()=>b(k,{children:b("path",{d:"M9 8L5 12L9 16M15 8L19 12L15 16"})}),pd=()=>Mt(k,{children:[b("path",{d:"M15 8h.01"}),b("rect",{x:4,y:4,width:16,height:16,rx:3}),b("path",{d:"m4 15 4-4a3 5 0 0 1 3 0l5 5"}),b("path",{d:"m14 14 1-1a3 5 0 0 1 3 0l2 2"})]});var dd=()=>b(k,{children:b("path",{d:"M12 5v14M5 12h14"})}),ud=()=>b(k,{children:b("path",{d:"M5 12h14M16 6.5A4 2 0 0 0 12 5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1-4-1.5"})}),fd=()=>b(k,{children:b("path",{d:"M7 5v5a5 5 0 0 0 10 0V5M5 19h14"})});var hd=()=>Mt(k,{children:[b("path",{d:"m9 11 3 3 8-8"}),b("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),xn=()=>b(k,{children:b("path",{d:"M11 6h9M11 12h9M12 18h8M4 16a2 2 0 1 1 4 0c0 .591-.5 1-1 1.5L4 20h4M6 10V4L4 6"})}),gd=()=>b(k,{children:b("path",{d:"M4 6h16M8 12h12M12 18h8M7 12l-3-3M7 12l-3 3"})}),bd=()=>b(k,{children:b("path",{d:"M4 6h16M8 12h12M12 18h8M4 12l3-3M4 12l3 3"})});var Ed=()=>b(k,{children:b("path",{d:"M18 6L6 18M6 6l12 12"})}),xd=()=>Mt(k,{children:[b("path",{d:"M4 20h4l10.5-10.5a2.828 2.828 0 1 0-4-4L4 16v4"}),b("path",{d:"M13.5 6.5l4 4"}),b("path",{d:"m14 19 6-6M18 15l2 2M5 21h4"})]}),kd=()=>b(k,{children:b("path",{d:"M5 12h14"})});var kn=[{icon:gd,title:f("increaseDepth"),hotkey:"tab",action:e=>e.list.increaseDepth(),active:e=>e.list.canIncreaseDepth()},{icon:bd,title:f("decreaseDepth"),hotkey:"shift+tab",action:e=>e.list.decreaseDepth(),active:e=>e.list.canDecreaseDepth()}],yd=[{icon:nd,title:f("normal"),hotkey:"super+0",action:e=>{e.collapsibleParagraph.convertParagraph()}},{icon:td,title:f("heading1"),hotkey:"super+1",action:e=>e.heading.convertHeading(1,!0),active:e=>e.heading.isHeadingActive(1)},{icon:od,title:f("heading2"),hotkey:"super+2",action:e=>e.heading.convertHeading(2,!0),active:e=>e.heading.isHeadingActive(2)},{icon:rd,title:f("heading3"),hotkey:"super+3",action:e=>e.heading.convertHeading(3,!0),active:e=>e.heading.isHeadingActive(3)}],vd=[...yd],yn=[{icon:Jp,title:f("paragraphStyle"),more:!0,children:yd}];import{useState as Me,useRef as wd,useEffect as I0,useCallback as vn}from"react";import{useSlateStatic as M0}from"slate-react";import w0 from"@emotion/styled";var Td=w0(re)`
1693
1724
  width: 18em;
1694
1725
  padding: 0;
1695
1726
  overflow: hidden;
1696
- `;import{Fragment as c0,jsx as V,jsxs as X}from"react/jsx-runtime";function hd({dest:e,close:t}){let o=m0(),r=fd(null),n=fd(null),[i,a]=Me({x:0,y:0}),l=un((R,H)=>{a(te=>({x:te.x+R,y:te.y+H}))},[]),s=o.wysimark?.imageDialogState,m=!!o.wysimark?.onImageChange,c=!!o.wysimark?.onFileSelect,d=s?.imageSource??(m?"file":c?"select":"url"),[p,u]=Me(s?.url??""),[g,x]=Me(s?.alt??""),[C,L]=Me(s?.title??""),[T,U]=Me(!1),[I,$]=Me(d),[w,P]=Me(!1),[S,D]=Me(s?.uploadedUrl??""),M=R=>{$(R),D(""),v("")},[G,v]=Me(""),B=un(R=>{let H=R.target.value;x(H),T||L(H)},[T]),de=un(R=>{L(R.target.value),U(!0)},[]);s0(()=>{o.wysimark&&(o.wysimark.imageDialogState={url:p,alt:g,title:C,imageSource:I,uploadedUrl:S})},[o,p,g,C,I,S]);let oo=()=>{o.wysimark&&(o.wysimark.imageDialogState=void 0)},Je=ne({src:r,dest:e},({src:R,dest:H},te)=>Re(R,te,{left:H.left-16,top:H.top+H.height},{margin:16})),Lt={...Je,left:Je.left+i.x,top:Je.top+i.y};function tr(R){R.preventDefault();let H=I==="file"||I==="select"?S:p;H.trim()!==""&&(o.image.insertImageFromUrl(H,g,C),oo(),t())}function z(){oo(),t()}async function Z(R){let H=R.target.files?.[0];if(!(!H||!o.wysimark?.onImageChange)){v(H.name),P(!0);try{let te=await o.wysimark.onImageChange(H);D(te)}catch(te){}finally{P(!1)}}}function ee(){n.current?.click()}async function Rt(){if(o.wysimark?.onFileSelect){P(!0);try{let R=await o.wysimark.onFileSelect();R&&D(R)}catch(R){}finally{P(!1)}}}let Bt=I==="file"||I==="select"?S.trim()===""||w:p.trim()==="";return X(c0,{children:[V(Le,{close:t}),X(ud,{ref:r,style:Lt,children:[V($e,{onDrag:l}),X("form",{onSubmit:R=>{tr(R)},style:{padding:"8px"},children:[(m||c)&&X("div",{style:{marginBottom:"12px"},children:[m&&X("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[V("input",{type:"radio",name:"imageSource",value:"file",checked:I==="file",onChange:()=>M("file"),style:{marginRight:"4px"}}),f("imageSourceFile")]}),c&&X("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[V("input",{type:"radio",name:"imageSource",value:"select",checked:I==="select",onChange:()=>M("select"),style:{marginRight:"4px"}}),f("imageSourceSelect")]}),X("label",{style:{display:"inline-flex",alignItems:"center",cursor:"pointer"},children:[V("input",{type:"radio",name:"imageSource",value:"url",checked:I==="url",onChange:()=>M("url"),style:{marginRight:"4px"}}),f("imageSourceUrl")]})]}),I==="url"?X("div",{style:{marginBottom:"8px"},children:[V("label",{style:{display:"block",marginBottom:"4px"},children:f("imageUrlRequired")}),V("input",{type:"text",value:p,onChange:R=>u(R.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:"https://example.com/image.jpg"})]}):I==="select"?X("div",{style:{marginBottom:"8px"},children:[V("button",{type:"button",onClick:()=>{Rt()},disabled:w,style:{padding:"8px 16px",backgroundColor:w?"#ccc":"#0078d4",color:w?"#666":"white",border:"none",borderRadius:"4px",cursor:w?"not-allowed":"pointer",marginBottom:"8px",fontWeight:"bold"},children:w?f("uploading"):f("imageSourceSelect")}),S&&V("div",{style:{marginTop:"8px",padding:"8px",backgroundColor:"var(--shade-100)",borderRadius:"4px"},children:X("div",{style:{color:"green",marginBottom:"4px"},children:["\u2713 ",S.split("/").pop()]})})]}):X("div",{style:{marginBottom:"8px"},children:[V("input",{ref:n,type:"file",accept:"image/*",onChange:R=>{Z(R)},style:{display:"none"}}),V("button",{type:"button",onClick:ee,disabled:w,style:{padding:"8px 16px",backgroundColor:w?"#ccc":"#0078d4",color:w?"#666":"white",border:"none",borderRadius:"4px",cursor:w?"not-allowed":"pointer",marginBottom:"8px",fontWeight:"bold"},children:w?f("uploading"):f("selectFile")}),S&&V("div",{style:{marginTop:"8px",padding:"8px",backgroundColor:"var(--shade-100)",borderRadius:"4px"},children:X("div",{style:{color:"green",marginBottom:"4px"},children:["\u2713 ",G]})})]}),X("div",{style:{marginBottom:"8px"},children:[V("label",{style:{display:"block",marginBottom:"4px"},children:f("altText")}),V("input",{type:"text",value:g,onChange:B,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:f("imageDescription")})]}),X("div",{style:{marginBottom:"8px"},children:[V("label",{style:{display:"block",marginBottom:"4px"},children:f("title")}),V("input",{type:"text",value:C,onChange:de,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:f("imageTitle")})]}),X("div",{style:{display:"flex",gap:"8px"},children:[V("button",{type:"submit",disabled:Bt,style:{display:"flex",alignItems:"center",padding:"8px 16px",backgroundColor:Bt?"#ccc":"#0078d4",color:"white",border:"none",borderRadius:"4px",cursor:Bt?"not-allowed":"pointer",fontWeight:"bold"},children:f("register")}),V("button",{type:"button",onClick:z,style:{padding:"8px 16px",backgroundColor:"var(--shade-100)",color:"var(--shade-700)",border:"1px solid var(--shade-300)",borderRadius:"4px",cursor:"pointer"},children:f("cancel")})]})]})]})]})}import{isHotkey as p0}from"is-hotkey";import{useCallback as Zt,useMemo as d0,useRef as u0,useState as Ye}from"react";import{Editor as f0,Range as h0}from"slate";import{ReactEditor as g0,useSlateStatic as b0}from"slate-react";import gd from"@emotion/styled";var fn=gd("div")`
1727
+ `;import{Fragment as C0,jsx as _,jsxs as Y}from"react/jsx-runtime";function Id({dest:e,close:t}){let o=M0(),r=wd(null),n=wd(null),[i,a]=Me({x:0,y:0}),l=vn((w,U)=>{a(de=>({x:de.x+w,y:de.y+U}))},[]),s=o.wysimark?.imageDialogState,m=!!o.wysimark?.onImageChange,c=!!o.wysimark?.onFileSelect,d=s?.imageSource??(m?"file":c?"select":"url"),[p,u]=Me(s?.url??""),[g,x]=Me(s?.alt??""),[C,I]=Me(s?.title??""),[M,O]=Me(!1),[P,$]=Me(d),[T,L]=Me(!1),[R,D]=Me(s?.uploadedUrl??""),S=w=>{$(w),D(""),v("")},[G,v]=Me(""),B=vn(w=>{let U=w.target.value;x(U),M||I(U)},[M]),pe=vn(w=>{I(w.target.value),O(!0)},[]);I0(()=>{o.wysimark&&(o.wysimark.imageDialogState={url:p,alt:g,title:C,imageSource:P,uploadedUrl:R})},[o,p,g,C,P,R]);let to=()=>{o.wysimark&&(o.wysimark.imageDialogState=void 0)},Rt=oe({src:r,dest:e},({src:w,dest:U},de)=>Be(w,de,{left:U.left-16,top:U.top+U.height},{margin:16})),ar={...Rt,left:Rt.left+i.x,top:Rt.top+i.y};function oo(w){w.preventDefault();let U=P==="file"||P==="select"?R:p;U.trim()!==""&&(o.image.insertImageFromUrl(U,g,C),to(),t())}function Je(){to(),t()}async function lr(w){let U=w.target.files?.[0];if(!(!U||!o.wysimark?.onImageChange)){v(U.name),L(!0);try{let de=await o.wysimark.onImageChange(U);D(de)}catch(de){}finally{L(!1)}}}function sr(){n.current?.click()}async function z(){if(o.wysimark?.onFileSelect){L(!0);try{let w=await o.wysimark.onFileSelect();w&&D(w)}catch(w){}finally{L(!1)}}}let j=P==="file"||P==="select"?R.trim()===""||T:p.trim()==="";return Y(C0,{children:[_(Re,{close:t}),Y(Td,{ref:r,style:ar,children:[_(De,{onDrag:l}),Y("form",{onSubmit:w=>{oo(w)},style:{padding:"8px"},children:[(m||c)&&Y("div",{style:{marginBottom:"12px"},children:[m&&Y("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[_("input",{type:"radio",name:"imageSource",value:"file",checked:P==="file",onChange:()=>S("file"),style:{marginRight:"4px"}}),f("imageSourceFile")]}),c&&Y("label",{style:{display:"inline-flex",alignItems:"center",marginRight:"16px",cursor:"pointer"},children:[_("input",{type:"radio",name:"imageSource",value:"select",checked:P==="select",onChange:()=>S("select"),style:{marginRight:"4px"}}),f("imageSourceSelect")]}),Y("label",{style:{display:"inline-flex",alignItems:"center",cursor:"pointer"},children:[_("input",{type:"radio",name:"imageSource",value:"url",checked:P==="url",onChange:()=>S("url"),style:{marginRight:"4px"}}),f("imageSourceUrl")]})]}),P==="url"?Y("div",{style:{marginBottom:"8px"},children:[_("label",{style:{display:"block",marginBottom:"4px"},children:f("imageUrlRequired")}),_("input",{type:"text",value:p,onChange:w=>u(w.target.value),style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:"https://example.com/image.jpg"})]}):P==="select"?Y("div",{style:{marginBottom:"8px"},children:[_("button",{type:"button",onClick:()=>{z()},disabled:T,style:{padding:"8px 16px",backgroundColor:T?"#ccc":"#0078d4",color:T?"#666":"white",border:"none",borderRadius:"4px",cursor:T?"not-allowed":"pointer",marginBottom:"8px",fontWeight:"bold"},children:T?f("uploading"):f("imageSourceSelect")}),R&&_("div",{style:{marginTop:"8px",padding:"8px",backgroundColor:"var(--shade-100)",borderRadius:"4px"},children:Y("div",{style:{color:"green",marginBottom:"4px"},children:["\u2713 ",R.split("/").pop()]})})]}):Y("div",{style:{marginBottom:"8px"},children:[_("input",{ref:n,type:"file",accept:"image/*",onChange:w=>{lr(w)},style:{display:"none"}}),_("button",{type:"button",onClick:sr,disabled:T,style:{padding:"8px 16px",backgroundColor:T?"#ccc":"#0078d4",color:T?"#666":"white",border:"none",borderRadius:"4px",cursor:T?"not-allowed":"pointer",marginBottom:"8px",fontWeight:"bold"},children:T?f("uploading"):f("selectFile")}),R&&_("div",{style:{marginTop:"8px",padding:"8px",backgroundColor:"var(--shade-100)",borderRadius:"4px"},children:Y("div",{style:{color:"green",marginBottom:"4px"},children:["\u2713 ",G]})})]}),Y("div",{style:{marginBottom:"8px"},children:[_("label",{style:{display:"block",marginBottom:"4px"},children:f("altText")}),_("input",{type:"text",value:g,onChange:B,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:f("imageDescription")})]}),Y("div",{style:{marginBottom:"8px"},children:[_("label",{style:{display:"block",marginBottom:"4px"},children:f("title")}),_("input",{type:"text",value:C,onChange:pe,style:{width:"100%",padding:"6px",boxSizing:"border-box",border:"1px solid var(--shade-300)",borderRadius:"4px",backgroundColor:"var(--shade-50)",color:"var(--shade-700)"},placeholder:f("imageTitle")})]}),Y("div",{style:{display:"flex",gap:"8px"},children:[_("button",{type:"submit",disabled:j,style:{display:"flex",alignItems:"center",padding:"8px 16px",backgroundColor:j?"#ccc":"#0078d4",color:"white",border:"none",borderRadius:"4px",cursor:j?"not-allowed":"pointer",fontWeight:"bold"},children:f("register")}),_("button",{type:"button",onClick:Je,style:{padding:"8px 16px",backgroundColor:"var(--shade-100)",color:"var(--shade-700)",border:"1px solid var(--shade-300)",borderRadius:"4px",cursor:"pointer"},children:f("cancel")})]})]})]})]})}import{isHotkey as P0}from"is-hotkey";import{useCallback as Jt,useMemo as S0,useRef as L0,useState as Ye}from"react";import{Editor as R0,Range as B0}from"slate";import{ReactEditor as $0,useSlateStatic as D0}from"slate-react";import Md from"@emotion/styled";var Tn=Md("div")`
1697
1728
  /* Center vertically and horizontally */
1698
1729
  display: flex;
1699
1730
  align-items: center;
@@ -1717,9 +1748,9 @@ ${Ot(r.slice(1),o).trimStart()}`:Ot(r,o)).split(`
1717
1748
  font-size: 1.25em;
1718
1749
  stroke-width: 2px;
1719
1750
  }
1720
- `,hn=gd("div")`
1751
+ `,wn=Md("div")`
1721
1752
  font-size: 0.875em;
1722
1753
  margin-top: 0.5em;
1723
1754
  color: var(--shade-500);
1724
1755
  line-height: 1.375;
1725
- `;import{Fragment as x0,jsx as _,jsxs as Mt}from"react/jsx-runtime";var E0=p0("enter");function bd({dest:e,close:t}){let o=b0(),r=u0(null),[n,i]=Ye({x:0,y:0}),a=Zt((v,B)=>{i(de=>({x:de.x+v,y:de.y+B}))},[]),l=ne({src:r,dest:e},({src:v,dest:B},de)=>!v||!B?{left:0,top:0}:Re(v,de,{left:B.left-12,top:B.top+B.height},{margin:16})),s={...l,left:l.left+n.x,top:l.top+n.y},m=d0(()=>{let{selection:v}=o;return v&&!h0.isCollapsed(v)?f0.string(o,v):""},[]),[c,d]=Ye(""),[p,u]=Ye(""),[g,x]=Ye(m),[C,L]=Ye(m),[T,U]=Ye("external"),[I,$]=Ye(!1),w=()=>{if(T==="internal"){let v=p.trim();if(v==="")return;let B=g.trim(),de=B&&B!==ke(v)?`${v}|${B}`:v;o.anchor.insertLink(Ze(de),B||ke(v),{select:!0})}else{let v=g.trim()||c,B=C.trim()||void 0;o.anchor.insertLink(c,v,{select:!0,title:B})}g0.focus(o),t()},P=Zt(v=>{d(v.currentTarget.value)},[d]),S=Zt(v=>{let B=no(v.currentTarget.value);u(B.target),B.display!==void 0&&x(B.display)},[u,x]),D=Zt(v=>{let B=v.currentTarget.value;x(B),I||L(B)},[x,L,I]),M=Zt(v=>{L(v.currentTarget.value),$(!0)},[L]),G=v=>{E0(v)&&(v.preventDefault(),v.stopPropagation(),w())};return Mt(x0,{children:[_(Le,{close:t}),Mt(Oa,{ref:r,style:s,children:[_($e,{onDrag:a}),Mt("div",{style:{padding:"0.75em"},children:[o.wysimark.enableInternalLinks?_(_t,{children:Mt("div",{style:{display:"flex",gap:"0.25em",padding:"0.25em",borderRadius:"0.375em",background:"var(--shade-100)",width:"100%"},children:[_("button",{type:"button",onClick:()=>U("external"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:T==="external"?"white":"transparent",color:T==="external"?"var(--shade-700)":"var(--shade-500)",boxShadow:T==="external"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeExternal")}),_("button",{type:"button",onClick:()=>U("internal"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:T==="internal"?"white":"transparent",color:T==="internal"?"var(--shade-700)":"var(--shade-500)",boxShadow:T==="internal"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeInternal")})]})}):null,_(_t,{style:{marginTop:o.wysimark.enableInternalLinks?"0.5em":0},children:T==="internal"?_(Kt,{type:"text",value:p,autoFocus:!0,placeholder:f("internalLinkTarget"),onChange:S,onKeyDown:G}):_(Kt,{type:"text",value:c,autoFocus:!0,placeholder:f("linkUrl"),onChange:P,onKeyDown:G})}),_(_t,{style:{marginTop:"0.5em"},children:_(Kt,{type:"text",value:g,placeholder:f("linkText"),onChange:D,onKeyDown:G})}),Mt(_t,{style:{marginTop:"0.5em"},children:[T==="external"?_(Kt,{type:"text",value:C,placeholder:f("tooltipText"),onChange:M,onKeyDown:G}):_("span",{style:{flex:"1 1 auto"}}),Mt(fn,{onClick:w,children:[_(Jo,{}),_(_p,{})]}),_(fn,{onClick:t,style:{marginLeft:"0.25em",background:"var(--shade-400)"},children:_(sd,{})})]}),T==="external"?_(hn,{children:f("tooltipHint")}):_(hn,{children:f("internalLinkTargetHint")})]})]})]})}var gn=[{icon:Jo,title:f("insertLink"),more:!0,hotkey:"mod+k",Component:bd},{icon:td,title:f("insertImageFromUrl"),more:!0,Component:hd},{icon:Jp,title:f("insertTable"),more:!0,Component:Fp},{icon:cd,title:f("horizontalRule"),hotkey:"super+-",action:e=>e.horizontalRule.insertHorizontalRule()}],Ed=gn,xd=gn,kd=[{icon:od,title:f("insert"),more:!0,children:gn}];import{Editor as k0}from"slate";function Ct(e){let t=k0.marks(e);return{bold:t?.bold||!1,italic:t?.italic||!1,strike:t?.strike||!1,code:t?.code||!1,underline:t?.underline||!1,highlight:t?.highlight||!1}}var yd=[{icon:sn,title:f("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>Ct(e).bold},{icon:jp,title:f("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>Ct(e).italic},{icon:rd,title:f("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>Ct(e).strike},{icon:Zp,title:f("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>Ct(e).code},{icon:nd,title:f("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>Ct(e).underline},{icon:md,title:f("highlight"),hotkey:"mod+h",action:e=>e.marksPlugin.toggleHighlight(),active:e=>Ct(e).highlight,show:e=>!e.wysimark.disableHighlight}],bn=yd,vd=[{icon:sn,title:f("format"),more:!0,children:yd}];var Td=[{icon:Yp,title:f("bulletList"),hotkey:"super+8",action:e=>e.list.convertUnorderedList(!0)},{icon:cn,title:f("numberedList"),hotkey:"super+7",action:e=>e.list.convertOrderedList(!0)},{icon:id,title:f("checkList"),hotkey:"super+9",action:e=>e.list.convertTaskList(!0),show:e=>!e.wysimark.disableTaskList}],En=[...Td,"divider",...pn],wd=[{icon:cn,title:f("list"),more:!0,children:[...Td,"divider",...pn]}];import{Editor as Id,Path as y0,Transforms as Zo}from"slate";var Md=[{icon:mn,title:f("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:Xp,title:f("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:ed,title:f("codeBlock"),action:e=>{let{selection:t}=e,o=E(e,"code-block");if(o){let[,r]=o,n=Id.string(e,r);Zo.removeNodes(e,{at:r}),Zo.insertNodes(e,{type:"paragraph",children:[{text:n}]},{at:r});return}if(t&&!y0.equals(t.anchor.path,t.focus.path)){e.codeBlock.createCodeBlock({language:"text"});return}if(t&&t.anchor.offset!==t.focus.offset){let r=Id.string(e,t);Zo.delete(e),Zo.insertNodes(e,{type:"code-block",language:"text",children:[{type:"code-block-line",children:[{text:r}]}]});return}e.codeBlock.createCodeBlock({language:"text"})},active:e=>!!E(e,"code-block"),show:e=>!e.wysimark.disableCodeBlock}],xn=Md,Cd=[{icon:mn,title:f("quote"),more:!0,children:Md}];var v0=[...dd,"divider",...En,"divider",...bn,"divider",...Ed,"divider",...xn],T0=[...dn,"divider",...En,"divider",...bn,"divider",...xd,"divider",...xn],Pd=[...dn,"divider",...wd,"divider",...vd,"divider",...kd,"divider",...Cd],Sd=Pd;var Pt=[v0,T0,Pd];import{clsx as w0}from"clsx";import{useCallback as kn,useRef as I0}from"react";import{ReactEditor as M0,useSlate as C0,useSlateStatic as P0}from"slate-react";import{jsx as er,jsxs as S0}from"react/jsx-runtime";function Ld({item:e}){let t=P0(),o=C0(),r=e.active?e.active(o):!1,n=I0(null),i=ae({title:e.title,hotkey:()=>e.hotkey?vo(e.hotkey):void 0}),a=K("menu"),l=kn(()=>{let c=n.current,d=e.children,p=e.Component;c&&(d?a.open(()=>er(ct,{dest:c,items:d,close:a.close})):p&&a.open(()=>er(p,{dest:c,close:a.close})))},[e]),s=kn(()=>{if(e.action){e.action(t),M0.focus(t);return}a.layer?a.close():l()},[a.layer,e]),m=kn(c=>{i.onMouseEnter(c),a.layer&&l()},[a.layer,l,i.onMouseEnter]);return S0(Ya,{"data-item-type":"button",ref:n,onMouseEnter:m,onMouseLeave:i.onMouseLeave,onClick:s,className:w0({"--active":r&&!dr(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&dr(e?.title)?.includes("Depth")}),children:[er(e.icon,{}),e.more?er(Vp,{}):null]})}import{jsx as St}from"react/jsx-runtime";function D0({item:e}){let t=$0();return e==="divider"?St(ja,{"data-item-type":"divider",children:St(Xa,{})}):(e.show===void 0?!0:e.show(t))?St(Ld,{item:e}):null}function z0(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");return!t||!o?null:{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function N0(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var H0=4;function Rd(){let e=R0(null),[t,o]=B0(Sd);return L0(()=>{let r=e.current;if(!r)return;let n=()=>{let a=z0(r);if(a){for(let l=0;l<Pt.length-1;l++)if(N0(Pt[l],a.button,a.divider)<a.toolbar-H0){o(Pt[l]);return}o(Pt[Pt.length-1])}},i=new ResizeObserver(n);return i.observe(r),()=>{i.disconnect()}},[]),St(qa,{ref:e,children:St(Qa,{children:t.map((r,n)=>St(D0,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as yn,jsxs as G0}from"react/jsx-runtime";function Bd({attributes:e,Editable:t}){let o=U0(null),r=K0(),n=_0(),i=O0(a=>{a.target===a.currentTarget&&(W0.select(r,F0.end(r,[])),V0.focus(r))},[r]);return yn(Ba,{children:G0(Va,{ref:o,className:A0({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[yn(Rd,{}),yn(t,{as:Wa,...e,style:{overflowY:"auto"}})]})})}var $d=y((e,t)=>(e.toolbar={height:t.toolbar?.height,minHeight:t.toolbar?.minHeight,maxHeight:t.toolbar?.maxHeight,showUploadButtons:t.toolbar?.showUploadButtons??!0},{name:"toolbar",editor:{},renderEditable:Bd,editableProps:{}}));import{Editor as vn,Node as q0,Path as Q0,Transforms as j0}from"slate";var Dd=y(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!vn.isEditor(t[0]))return!1;let o=[e.children.length-1],r=q0.child(e,e.children.length-1);return(vn.hasBlocks(e,r)||vn.isVoid(e,r))&&j0.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:Q0.next(o)}),!0}}}));import{Transforms as X0}from"slate";function Y0(e,t){let o=Ce(t),r=Se(o,{enableInternalLinks:e.wysimark.enableInternalLinks});X0.insertNodes(e,r)}function zd(e){return{pasteMarkdown:h(Y0,e)}}function J0(e){return e.length===1&&e[0]==="text/plain"}function Z0(e){return/^>\s*\[![A-Za-z0-9_-]+\][+-]?(?:\s|$)/m.test(e)}var Nd=y(e=>(e.pasteMarkdown=zd(e),{name:"paste-markdown",editor:{},editableProps:{onPaste(t){let o=Array.from(t.clipboardData.types),r=t.clipboardData.getData("text/markdown"),n=t.clipboardData.getData("text/plain");return r||n&&(J0(o)||Z0(n))?(e.pasteMarkdown.pasteMarkdown(r||n),Ue(t),!0):!1}}}));import{jsx as tx}from"react/jsx-runtime";function ex(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return tx("span",{...t,children:e.children})}var Hd=y((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:ex}})));var Ad=[Nd,Rm,El,Fm,Sc,Ym,Ps,cm,gm,Bp,qm,Dd,wc,vl,Bc,wm,zp,$d,hs,Hd];var ox=Yi(Ad),{withSink:Od,SinkEditable:Ud}=ox;import{useState as rx}from"react";import{createEditor as nx,Editor as ix,Transforms as ax}from"slate";import{withHistory as lx}from"slate-history";import{withReact as sx}from"slate-react";function Tn({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l,enableInternalLinks:s,renderInternalLinkPreview:m,renderInternalEmbed:c}={}){let[d]=rx(()=>{let p=nx(),u=Od(sx(lx(p)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return u.convertElement.addConvertElementType("paragraph"),p.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0,enableInternalLinks:s??!1,renderInternalLinkPreview:m,renderInternalEmbed:c},p.getMarkdown=()=>fe(p.children,{enableInternalLinks:p.wysimark.enableInternalLinks}),p.setMarkdown=g=>{let x=Ce(g),C=Se(x,{enableInternalLinks:p.wysimark.enableInternalLinks});p.children=C,p.selection=null,ax.select(p,ix.start(p,[0]))},u});return d}import{jsx as me,jsxs as Wd}from"react/jsx-runtime";function fx({children:e,attributes:t}){return me("span",{...t,children:e})}function Vd({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l,onFileSelect:s}){let[m,c]=Fd(!1),[d,p]=Fd(t),u=to(!1),g=to(void 0),x=to(void 0),C=to(null),L=to(o);L.current=o;let T=eo(mx(()=>{let M=fe(e.children,{enableInternalLinks:e.wysimark.enableInternalLinks});e.wysimark.prevValue={markdown:M,children:e.children},L.current(M)},r,{leading:!1,trailing:!0}),[e,r]),U=eo(()=>{x.current!==e.children&&(x.current=e.children,T())},[T]);if(!m){let M=C.current??t;if(C.current!==null&&(C.current=null),e.wysimark.prevValue==null||g.current==null){u.current=!0;let G=Ce(M),v=Se(G,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,x.current=g.current=v,e.wysimark.prevValue={markdown:M,children:v}}else if(M!==e.wysimark.prevValue.markdown){u.current=!0;let G=Ce(M),v=Se(G,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,e.selection=null,px.select(e,cx.start(e,[0]))}}let I=eo(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&dx.focus(e)},[e]),$=eo(()=>{T.flush()},[T]),w=M=>{let G=M.target.value;p(G),o(G)},P=eo(()=>{let M=e.getMarkdown();p(M)},[e]),S=()=>{m?(C.current=d,e.wysimark.prevValue=void 0,g.current=void 0,x.current=void 0):P(),c(!m)};e.wysimark.onImageChange=l,e.wysimark.onFileSelect=s;let D=e.wysimark.disableRawMode;return Wd("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[!D&&me("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:me("div",{onClick:S,style:{background:"none",border:m?"1px solid #4a90e2":"1px solid transparent",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:m?"rgba(74, 144, 226, 0.1)":"transparent",boxShadow:m?"0 1px 3px rgba(0, 0, 0, 0.1)":"none",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:m?f("switchToVisualEditor"):f("switchToRawMarkdown"),role:"button",tabIndex:0,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(S(),M.preventDefault())},children:Wd("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[me("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",fill:m?"rgba(74, 144, 226, 0.05)":"transparent"}),me("path",{d:"M7 15V9L10 12L13 9V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),me("path",{d:"M16 9H18V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),me("path",{d:"M16 12H18",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),me("div",{style:{display:m?"block":"none",textAlign:"center"},children:me("textarea",{value:zt(d),onChange:w,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"1rem",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),me("div",{style:{display:m?"none":"flex",flexDirection:"column",flex:1,minHeight:0},children:me(ux,{editor:e,initialValue:g.current,onChange:U,children:me(Ud,{renderLeaf:fx,onMouseDown:I,onBlur:$,placeholder:n,className:i,style:a})})})]})}import{jsx as _d}from"react/jsx-runtime";function yx({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=xx(r.initialMarkdown||""),l=Ex(i),s=Tn(r);l.current=i,bx(n,()=>({getMarkdown(){return l.current},setMarkdown(c){l.current=c,a(c)}}),[l,a]);let m=gx(c=>{l.current=c,a(c),e?.(c)},[s]);return _d(Vd,{editor:s,value:i,className:o||"",onChange:m,placeholder:t})}function k3(e,t){let o=hx(),r=kx(e);return r.render(_d(yx,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{Vd as Editable,k3 as createWysimark,io as unescapeMarkdown,Tn as useEditor};
1756
+ `;import{Fragment as N0,jsx as K,jsxs as Ct}from"react/jsx-runtime";var z0=P0("enter");function Cd({dest:e,close:t}){let o=D0(),r=L0(null),[n,i]=Ye({x:0,y:0}),a=Jt((v,B)=>{i(pe=>({x:pe.x+v,y:pe.y+B}))},[]),l=oe({src:r,dest:e},({src:v,dest:B},pe)=>!v||!B?{left:0,top:0}:Be(v,pe,{left:B.left-12,top:B.top+B.height},{margin:16})),s={...l,left:l.left+n.x,top:l.top+n.y},m=S0(()=>{let{selection:v}=o;return v&&!B0.isCollapsed(v)?R0.string(o,v):""},[]),[c,d]=Ye(""),[p,u]=Ye(""),[g,x]=Ye(m),[C,I]=Ye(m),[M,O]=Ye("external"),[P,$]=Ye(!1),T=()=>{if(M==="internal"){let v=p.trim();if(v==="")return;let B=g.trim(),pe=B&&B!==se(v)?`${v}|${B}`:v;o.anchor.insertLink(Ce(pe),B||se(v),{select:!0})}else{let v=g.trim()||c,B=C.trim()||void 0;o.anchor.insertLink(c,v,{select:!0,title:B})}$0.focus(o),t()},L=Jt(v=>{d(v.currentTarget.value)},[d]),R=Jt(v=>{let B=io(v.currentTarget.value);u(B.target),B.display!==void 0&&x(B.display)},[u,x]),D=Jt(v=>{let B=v.currentTarget.value;x(B),P||I(B)},[x,I,P]),S=Jt(v=>{I(v.currentTarget.value),$(!0)},[I]),G=v=>{z0(v)&&(v.preventDefault(),v.stopPropagation(),T())};return Ct(N0,{children:[K(Re,{close:t}),Ct(Xa,{ref:r,style:s,children:[K(De,{onDrag:a}),Ct("div",{style:{padding:"0.75em"},children:[o.wysimark.enableInternalLinks?K(Vt,{children:Ct("div",{style:{display:"flex",gap:"0.25em",padding:"0.25em",borderRadius:"0.375em",background:"var(--shade-100)",width:"100%"},children:[K("button",{type:"button",onClick:()=>O("external"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:M==="external"?"white":"transparent",color:M==="external"?"var(--shade-700)":"var(--shade-500)",boxShadow:M==="external"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeExternal")}),K("button",{type:"button",onClick:()=>O("internal"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:M==="internal"?"white":"transparent",color:M==="internal"?"var(--shade-700)":"var(--shade-500)",boxShadow:M==="internal"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeInternal")})]})}):null,K(Vt,{style:{marginTop:o.wysimark.enableInternalLinks?"0.5em":0},children:M==="internal"?K(_t,{type:"text",value:p,autoFocus:!0,placeholder:f("internalLinkTarget"),onChange:R,onKeyDown:G}):K(_t,{type:"text",value:c,autoFocus:!0,placeholder:f("linkUrl"),onChange:L,onKeyDown:G})}),K(Vt,{style:{marginTop:"0.5em"},children:K(_t,{type:"text",value:g,placeholder:f("linkText"),onChange:D,onKeyDown:G})}),Ct(Vt,{style:{marginTop:"0.5em"},children:[M==="external"?K(_t,{type:"text",value:C,placeholder:f("tooltipText"),onChange:S,onKeyDown:G}):K("span",{style:{flex:"1 1 auto"}}),Ct(Tn,{onClick:T,children:[K(rr,{}),K(ed,{})]}),K(Tn,{onClick:t,style:{marginLeft:"0.25em",background:"var(--shade-400)"},children:K(Ed,{})})]}),M==="external"?K(wn,{children:f("tooltipHint")}):K(wn,{children:f("internalLinkTargetHint")})]})]})]})}var In=[{icon:rr,title:f("insertLink"),more:!0,hotkey:"mod+k",Component:Cd},{icon:pd,title:f("insertImageFromUrl"),more:!0,Component:Id},{icon:sd,title:f("insertTable"),more:!0,Component:Yp},{icon:kd,title:f("horizontalRule"),hotkey:"super+-",action:e=>e.horizontalRule.insertHorizontalRule()}],Pd=In,Sd=In,Ld=[{icon:dd,title:f("insert"),more:!0,children:In}];import{Editor as H0}from"slate";function Pt(e){let t=H0.marks(e);return{bold:t?.bold||!1,italic:t?.italic||!1,strike:t?.strike||!1,code:t?.code||!1,underline:t?.underline||!1,highlight:t?.highlight||!1}}var Rd=[{icon:bn,title:f("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>Pt(e).bold},{icon:id,title:f("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>Pt(e).italic},{icon:ud,title:f("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>Pt(e).strike},{icon:md,title:f("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>Pt(e).code},{icon:fd,title:f("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>Pt(e).underline},{icon:xd,title:f("highlight"),hotkey:"mod+h",action:e=>e.marksPlugin.toggleHighlight(),active:e=>Pt(e).highlight,show:e=>!e.wysimark.disableHighlight}],Mn=Rd,Bd=[{icon:bn,title:f("format"),more:!0,children:Rd}];var $d=[{icon:ld,title:f("bulletList"),hotkey:"super+8",action:e=>e.list.convertUnorderedList(!0)},{icon:xn,title:f("numberedList"),hotkey:"super+7",action:e=>e.list.convertOrderedList(!0)},{icon:hd,title:f("checkList"),hotkey:"super+9",action:e=>e.list.convertTaskList(!0),show:e=>!e.wysimark.disableTaskList}],Cn=[...$d,"divider",...kn],Dd=[{icon:xn,title:f("list"),more:!0,children:[...$d,"divider",...kn]}];import{Editor as zd,Path as A0,Transforms as nr}from"slate";var Nd=[{icon:En,title:f("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:ad,title:f("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:cd,title:f("codeBlock"),action:e=>{let{selection:t}=e,o=E(e,"code-block");if(o){let[,r]=o,n=zd.string(e,r);nr.removeNodes(e,{at:r}),nr.insertNodes(e,{type:"paragraph",children:[{text:n}]},{at:r});return}if(t&&!A0.equals(t.anchor.path,t.focus.path)){e.codeBlock.createCodeBlock({language:"text"});return}if(t&&t.anchor.offset!==t.focus.offset){let r=zd.string(e,t);nr.delete(e),nr.insertNodes(e,{type:"code-block",language:"text",children:[{type:"code-block-line",children:[{text:r}]}]});return}e.codeBlock.createCodeBlock({language:"text"})},active:e=>!!E(e,"code-block"),show:e=>!e.wysimark.disableCodeBlock}],Pn=Nd,Hd=[{icon:En,title:f("quote"),more:!0,children:Nd}];var O0=[...vd,"divider",...Cn,"divider",...Mn,"divider",...Pd,"divider",...Pn],U0=[...yn,"divider",...Cn,"divider",...Mn,"divider",...Sd,"divider",...Pn],Ad=[...yn,"divider",...Dd,"divider",...Bd,"divider",...Ld,"divider",...Hd],Od=Ad;var St=[O0,U0,Ad];import{clsx as F0}from"clsx";import{useCallback as Sn,useRef as W0}from"react";import{ReactEditor as V0,useSlate as _0,useSlateStatic as K0}from"slate-react";import{jsx as ir,jsxs as G0}from"react/jsx-runtime";function Ud({item:e}){let t=K0(),o=_0(),r=e.active?e.active(o):!1,n=W0(null),i=ne({title:e.title,hotkey:()=>e.hotkey?To(e.hotkey):void 0}),a=F("menu"),l=Sn(()=>{let c=n.current,d=e.children,p=e.Component;c&&(d?a.open(()=>ir(ct,{dest:c,items:d,close:a.close})):p&&a.open(()=>ir(p,{dest:c,close:a.close})))},[e]),s=Sn(()=>{if(e.action){e.action(t),V0.focus(t);return}a.layer?a.close():l()},[a.layer,e]),m=Sn(c=>{i.onMouseEnter(c),a.layer&&l()},[a.layer,l,i.onMouseEnter]);return G0(sl,{"data-item-type":"button",ref:n,onMouseEnter:m,onMouseLeave:i.onMouseLeave,onClick:s,className:F0({"--active":r&&!kr(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&kr(e?.title)?.includes("Depth")}),children:[ir(e.icon,{}),e.more?ir(Zp,{}):null]})}import{jsx as Lt}from"react/jsx-runtime";function Y0({item:e}){let t=X0();return e==="divider"?Lt(al,{"data-item-type":"divider",children:Lt(ll,{})}):(e.show===void 0?!0:e.show(t))?Lt(Ud,{item:e}):null}function J0(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");return!t||!o?null:{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function Z0(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var ex=4;function Fd(){let e=Q0(null),[t,o]=j0(Od);return q0(()=>{let r=e.current;if(!r)return;let n=()=>{let a=J0(r);if(a){for(let l=0;l<St.length-1;l++)if(Z0(St[l],a.button,a.divider)<a.toolbar-ex){o(St[l]);return}o(St[St.length-1])}},i=new ResizeObserver(n);return i.observe(r),()=>{i.disconnect()}},[]),Lt(nl,{ref:e,children:Lt(il,{children:t.map((r,n)=>Lt(Y0,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as Ln,jsxs as mx}from"react/jsx-runtime";function Wd({attributes:e,Editable:t}){let o=rx(null),r=sx(),n=lx(),i=ox(a=>{a.target===a.currentTarget&&(ix.select(r,nx.end(r,[])),ax.focus(r))},[r]);return Ln(Va,{children:mx(el,{ref:o,className:tx({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[Ln(Fd,{}),Ln(t,{as:Za,...e,style:{overflowY:"auto"}})]})})}var Vd=y((e,t)=>(e.toolbar={height:t.toolbar?.height,minHeight:t.toolbar?.minHeight,maxHeight:t.toolbar?.maxHeight,showUploadButtons:t.toolbar?.showUploadButtons??!0},{name:"toolbar",editor:{},renderEditable:Wd,editableProps:{}}));import{Editor as Rn,Node as cx,Path as px,Transforms as dx}from"slate";var _d=y(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!Rn.isEditor(t[0]))return!1;let o=[e.children.length-1],r=cx.child(e,e.children.length-1);return(Rn.hasBlocks(e,r)||Rn.isVoid(e,r))&&dx.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:px.next(o)}),!0}}}));import{Transforms as ux}from"slate";function fx(e,t){let o=Pe(t),r=Le(o,{enableInternalLinks:e.wysimark.enableInternalLinks});ux.insertNodes(e,r)}function Kd(e){return{pasteMarkdown:h(fx,e)}}function hx(e){return e.length===1&&e[0]==="text/plain"}function gx(e){return/^>\s*\[![A-Za-z0-9_-]+\][+-]?(?:\s|$)/m.test(e)}var Gd=y(e=>(e.pasteMarkdown=Kd(e),{name:"paste-markdown",editor:{},editableProps:{onPaste(t){let o=Array.from(t.clipboardData.types),r=t.clipboardData.getData("text/markdown"),n=t.clipboardData.getData("text/plain");return r||n&&(hx(o)||gx(n))?(e.pasteMarkdown.pasteMarkdown(r||n),Ue(t),!0):!1}}}));import{jsx as Ex}from"react/jsx-runtime";function bx(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return Ex("span",{...t,children:e.children})}var qd=y((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:bx}})));var Qd=[Gd,Fm,Ml,Ym,Oc,lc,As,km,Mm,Wp,rc,_d,Dc,Ll,Wc,Dm,Kp,Vd,Is,qd];var xx=aa(Qd),{withSink:jd,SinkEditable:Xd}=xx;import{useState as kx}from"react";import{createEditor as yx,Editor as vx,Transforms as Tx}from"slate";import{withHistory as wx}from"slate-history";import{withReact as Ix}from"slate-react";function Bn({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l,enableInternalLinks:s,renderInternalLinkPreview:m,renderInternalEmbed:c}={}){let[d]=kx(()=>{let p=yx(),u=jd(Ix(wx(p)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return u.convertElement.addConvertElementType("paragraph"),p.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0,enableInternalLinks:s??!1,renderInternalLinkPreview:m,renderInternalEmbed:c},p.getMarkdown=()=>fe(p.children,{enableInternalLinks:p.wysimark.enableInternalLinks}),p.setMarkdown=g=>{let x=Pe(g),C=Le(x,{enableInternalLinks:p.wysimark.enableInternalLinks});p.children=C,p.selection=null,Tx.select(p,vx.start(p,[0]))},u});return d}import{jsx as le,jsxs as Jd}from"react/jsx-runtime";function Rx({children:e,attributes:t}){return le("span",{...t,children:e})}function Zd({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l,onFileSelect:s}){let[m,c]=Yd(!1),[d,p]=Yd(t),u=eo(!1),g=eo(void 0),x=eo(void 0),C=eo(null),I=eo(o);I.current=o;let M=Zt(Mx(()=>{let S=fe(e.children,{enableInternalLinks:e.wysimark.enableInternalLinks});e.wysimark.prevValue={markdown:S,children:e.children},I.current(S)},r,{leading:!1,trailing:!0}),[e,r]),O=Zt(()=>{x.current!==e.children&&(x.current=e.children,M())},[M]);if(!m){let S=C.current??t;if(C.current!==null&&(C.current=null),e.wysimark.prevValue==null||g.current==null){u.current=!0;let G=Pe(S),v=Le(G,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,x.current=g.current=v,e.wysimark.prevValue={markdown:S,children:v}}else if(S!==e.wysimark.prevValue.markdown){u.current=!0;let G=Pe(S),v=Le(G,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,e.selection=null,Px.select(e,Cx.start(e,[0]))}}let P=Zt(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&Sx.focus(e)},[e]),$=Zt(()=>{M.flush()},[M]),T=S=>{let G=S.target.value;p(G),o(G)},L=Zt(()=>{let S=e.getMarkdown();p(S)},[e]),R=()=>{m?(C.current=d,e.wysimark.prevValue=void 0,g.current=void 0,x.current=void 0):L(),c(!m)};e.wysimark.onImageChange=l,e.wysimark.onFileSelect=s;let D=e.wysimark.disableRawMode;return Jd("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[!D&&le("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:le("div",{onClick:R,style:{background:"none",border:m?"1px solid #4a90e2":"1px solid transparent",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:m?"rgba(74, 144, 226, 0.1)":"transparent",boxShadow:m?"0 1px 3px rgba(0, 0, 0, 0.1)":"none",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:m?f("switchToVisualEditor"):f("switchToRawMarkdown"),role:"button",tabIndex:0,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(R(),S.preventDefault())},children:Jd("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[le("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",fill:m?"rgba(74, 144, 226, 0.05)":"transparent"}),le("path",{d:"M7 15V9L10 12L13 9V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),le("path",{d:"M16 9H18V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),le("path",{d:"M16 12H18",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),le("div",{style:{display:m?"block":"none",textAlign:"center"},children:le("textarea",{value:Dt(d),onChange:T,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"1rem",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),le("div",{style:{display:m?"none":"flex",flexDirection:"column",flex:1,minHeight:0},children:le(Lx,{editor:e,initialValue:g.current,onChange:O,children:le(Xd,{renderLeaf:Rx,onMouseDown:P,onBlur:$,placeholder:n,className:i,style:a})})})]})}import{jsx as eu}from"react/jsx-runtime";function Ax({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=Nx(r.initialMarkdown||""),l=zx(i),s=Bn(r);l.current=i,Dx(n,()=>({getMarkdown(){return l.current},setMarkdown(c){l.current=c,a(c)}}),[l,a]);let m=$x(c=>{l.current=c,a(c),e?.(c)},[s]);return eu(Zd,{editor:s,value:i,className:o||"",onChange:m,placeholder:t})}function o6(e,t){let o=Bx(),r=Hx(e);return r.render(eu(Ax,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{Zd as Editable,o6 as createWysimark,ao as unescapeMarkdown,Bn as useEditor};