import{_ as K}from"./BTPD_Ufu.js";import{_ as Y}from"./Dd5m_CIq.js";import{d as P,r as F,s as R,c6 as j,c as Q,o as H,u as S,y as T,w as C,f as u,aj as _,t as M,an as V,av as Z,i as z,b as J,ar as G,Y as ee,X,au as te}from"./Dih1Xbo1.js";import{R as ne,S as A}from"./ByDGVqbv.js";import{g as W}from"./BkY4Kcec.js";import{_ as oe}from"./Y29o_Eld.js";const ie=["title","onClick"],se={flex:"~ col","of-auto":"","w-62":"","pt-1":"","pb-2":""},le={p2:"","text-xs":"","text-gray":"",uppercase:""},re=P({__name:"EditorMonacoMenuOptions",props:{editor:{default:null}},setup(o){const r=o;if(!r.editor)throw new Error("Editor is required");const t=r.editor,l=F(!1),i=j(),k=R({get:()=>i.value.lineNumbers==="on",set(s){t.updateOptions({lineNumbers:s?"on":"off"}),i.value.lineNumbers=s?"on":"off"}}),p=R({get:()=>i.value.folding,set(s){t.updateOptions({folding:s}),i.value.folding=s}}),m=R({get:()=>i.value.wordWrap==="on",set(s){t.updateOptions({wordWrap:s?"on":"off"}),t.updateOptions({useInlineViewWhenSpaceIsLimited:s}),i.value.wordWrap=s?"on":"off"}}),$=R({get:()=>i.value.minimap?.enabled,set(s){t.updateOptions({minimap:{enabled:s}}),i.value.minimap.enabled=s}}),I=R({get:()=>i.value.scrollBeyondLastLine,set(s){t.updateOptions({scrollBeyondLastLine:s}),i.value.scrollBeyondLastLine=s}});return(s,f)=>{const w=K,g=Y;return H(),Q(g,{modelValue:S(l),"onUpdate:modelValue":f[5]||(f[5]=d=>T(l)?l.value=d:null),direction:"end","border-l":"","inline-block":"",class:"toolbar-button"},{trigger:C(({click:d})=>[u("button",{title:s.$t("options"),onClick:v=>d()},f[6]||(f[6]=[u("div",{class:"h-6 i-lucide:ellipsis"},null,-1)]),8,ie)]),default:C(()=>[u("div",se,[u("div",le,M(s.$t("editor-options")),1),_(w,{modelValue:S(k),"onUpdate:modelValue":f[0]||(f[0]=d=>T(k)?k.value=d:null),class:"option-item"},{default:C(()=>[V(M(s.$t("line-numbers")),1)]),_:1},8,["modelValue"]),_(w,{modelValue:S(p),"onUpdate:modelValue":f[1]||(f[1]=d=>T(p)?p.value=d:null),class:"option-item"},{default:C(()=>[V(M(s.$t("folding")),1)]),_:1},8,["modelValue"]),_(w,{modelValue:S(m),"onUpdate:modelValue":f[2]||(f[2]=d=>T(m)?m.value=d:null),class:"option-item"},{default:C(()=>[V(M(s.$t("word-wrap")),1)]),_:1},8,["modelValue"]),_(w,{modelValue:S($),"onUpdate:modelValue":f[3]||(f[3]=d=>T($)?$.value=d:null),class:"option-item"},{default:C(()=>[V(M(s.$t("minimap")),1)]),_:1},8,["modelValue"]),_(w,{modelValue:S(I),"onUpdate:modelValue":f[4]||(f[4]=d=>T(I)?I.value=d:null),class:"option-item"},{default:C(()=>[V(M(s.$t("scroll-beyond-last-line")),1)]),_:1},8,["modelValue"])])]),_:1},8,["modelValue"])}}}),Pe=Z(re,[["__scopeId","data-v-76617324"]]),ae=/^\s*/,de=/^\s*:{2,}[\w-]+/,ue=/^\s*:{2,}\s*$/,ce=/^[\w-]+:\s*[|>]/,me=/^\s*(?:`{3,}|~{3,})/,fe=/^\s*[-*]\s+/,pe=/^\s*\d+\.\s+/,ge=/^\s*[-*]\s+\[.\]\s+/,U=/^[\w-]+:\s*$/,D={};function E(o){return D[o]||(D[o]=" ".repeat(o)),D[o]}const be=(o,{tabSize:r=2,isFormatOnType:t=!1})=>{const l=o.split(`
`),i=Array.from({length:l.length}),k=[];let p=0,m=!1,$=!1,I=!1,s=0,f=null,w=null,g=!1;const d={baseIndent:null,multilineBaseIndent:null,multilineMinimumIndent:null};let v=null,y=0,L=null;for(let B=0;B<l.length;B++){const h=l[B],b=h.match(ae)?.[0].length||0,c=h.trim(),n=k[k.length-1]||0;if(c===""&&!t){i[s++]="";continue}if(me.test(c)){I=!I,I?(f=n,w=b,i[s++]=E(n)+c):(i[s++]=E(f)+c,f=null,w=null);continue}if(I&&f!==null){if(c===""&&!t){i[s++]="";continue}const e=b-(w||0),a=f+e;i[s++]=E(a)+c;continue}if(c==="---"){m=!m,$=!1,d.multilineBaseIndent=null,d.multilineMinimumIndent=null,d.baseIndent=m?b:null,m?L=n:L=null,g=!1,i[s++]=E(n)+"---";continue}if(de.test(h)){i[s++]=E(p)+c,k.push(p),p+=r,y++,v=null;continue}if(ue.test(h)){p=k.pop()||0,i[s++]=E(p)+c,v=null;continue}if(m){if(c){if($&&b<=d.baseIndent&&c.includes(":")&&($=!1,d.multilineBaseIndent=null,d.multilineMinimumIndent=null),ce.test(c)){$=!0,d.multilineBaseIndent=b,d.multilineMinimumIndent=n+r,i[s++]=E(n)+c,g=!1;continue}if($&&d.multilineBaseIndent!==null){const e=b-d.multilineBaseIndent,a=Math.max(d.multilineMinimumIndent,n+e);i[s++]=E(a)+h.slice(b);continue}if(!$){if(U.test(c)){i[s++]=E(L)+c,g=!0;continue}if(g&&c.includes(":")){i[s++]=E(L+r)+c,g=U.test(c);continue}if(g){i[s++]=E(L+r)+c;continue}if(c.includes(":")&&!c.startsWith("-")){i[s++]=E(L)+c,g=!1;continue}}if(d.baseIndent!==null){const e=b-d.baseIndent;i[s++]=E(L+Math.max(0,e))+c;continue}}else if(t)if($){const e=Math.max(d.multilineMinimumIndent||0,b);i[s++]=E(e)+"";continue}else{i[s++]=E(b)+"";continue}}if(fe.test(c)||pe.test(c)||ge.test(c)){!v||v.componentId!==y?v={componentLevel:n,baseIndent:b,nestingLevels:[b],componentId:y}:b<=v.baseIndent?(v.baseIndent=b,v.nestingLevels=[b]):v.nestingLevels.includes(b)||(v.nestingLevels.push(b),v.nestingLevels.sort((N,O)=>N-O));const e=v.nestingLevels.indexOf(b),a=v.componentLevel+e*r;i[s++]=E(a)+c,g=!1;continue}else if(!c&&v){i[s++]="";continue}else v=null;i[s++]=E(n)+c,g=!1}return i.length=s,i[i.length-1]!==""&&i.push(""),i.join(`
`)},ke=o=>{const r=[],t=[];let l=!1;for(let i=0;i<o.lineCount;i++){const k=o.getLine(i).trim();if(/^\s*(?:`{3,}|~{3,})/.test(k)){l=!l;continue}if(l)continue;const p=k.match(/^\s*(:{2,})([\w-]+)/);if(p){t.push({start:i,tagName:p[2],colons:p[1].length});continue}const m=k.match(/^\s*(:{2,})$/);if(m&&t.length>0){const $=m[1].length,I=t[t.length-1];I&&I.colons===$&&(t.pop(),r.push({start:I.start,end:i}))}}return r},$e=o=>{const r={getLine:l=>o.getLineContent(l+1),lineCount:o.getLineCount()};return ke(r).map(l=>({start:l.start+1,end:l.end+1}))},ve={defaultToken:"",tokenPostfix:".md",control:/[\\`*_[\]{}()#+\-.!]/,noncontrol:/[^\\`*_[\]{}()#+\-.!]/,escapes:/\\@control/,jsescapes:/\\(?:[btnfr\\"']|[0-3]?[0-7]{1,2})/,empty:["area","base","basefont","br","col","frame","hr","img","input","isindex","link","meta","param"],tokenizer:{root:[[/^---$/,{token:"",next:"@frontmatter",nextEmbedded:"yaml"}],{include:"markdown"}],frontmatter:[[/^\s*---\s*$/,{token:"",next:"@markdown",nextEmbedded:"@pop",bracket:"@close"}],[/.*$/,"variable.source"]],markdown:[[/^(\s{0,3}#+)/,{token:"keyword",next:"@headercontent"}],[/^\s*(=+|-+)\s*$/,"keyword"],[/^\s*((\* ?)+)\s*$/,"meta.separator"],[/^\s*>+/,"comment"],[/^\s*([*\-+]|\d+\.)\s/,"keyword"],[/^(\t| {4})[^ ].*$/,"string"],[/^\s*~~~\s*(?:([\w/\-#]+)\s*)?$/,{token:"",next:"@codeblock"}],[/^\s*```\s*([\w/\-#]+)\s*$/,{token:"",next:"@codeblockgh",nextEmbedded:"$1"}],[/^\s*```\s*$/,{token:"",next:"@codeblock"}],[/^\s*```\s*([\w/\-#]+)(\s*(\{[^}]*\}))?(\s*(\[[^\]]*\]))?(\s*(\{[^}]*\}))?.*$/,{token:"",next:"@codeblockmdc",nextEmbedded:"$1"}],[/^\s*(:{2,})([\w-]+)/,"tag","@componentWithData"],{include:"@linecontent"}],componentWithData:[[/\{/,"tag","@attributes"],[/^\s*---\s*$/,{token:"",next:"@componentData",nextEmbedded:"yaml"}],[/^\s*:{2,}\s*$/,"tag","@pop"],{include:"@component"}],component:[[/^\s*#[\w-]*\s*$/,"attribute.name.html"],{include:"@markdown"}],componentData:[[/^\s*---\s*$/,{token:"",next:"@pop",nextEmbedded:"@pop",bracket:"@close"}],[/.*$/,"variable.source"]],attributes:[[/[^}=][^\s=}]*[\s.#]*/,"attribute.name.html"],[/[^}=][^\s=}]*(\})/,["attribute.name.html",{token:"tag",next:"@pop"}]],[/(=)("[^"]*"|[^"\s=}]*)/,["","string.html"]],[/\}/,"tag","@pop"]],codeblock:[[/^\s*~~~\s*$/,{token:"",next:"@pop"}],[/^\s*```\s*$/,{token:"",next:"@pop"}],[/.*$/,"variable.source"]],codeblockgh:[[/```\s*$/,{token:"",next:"@pop",nextEmbedded:"@pop"}],[/[^`]+/,"variable.source"]],codeblockmdc:[[/```\s*$/,{token:"",next:"@pop",nextEmbedded:"@pop"}],[/[^`]+/,"string"]],headercontent:[[/^/,"keyword","@pop"],[/((?:[^\\#]|@escapes)+)(#*)/,"keyword"],{include:"@linecontent"}],linecontent:[[/&\w+;/,"string.escape"],[/@escapes/,"escape"],[/\b__([^\\_]|@escapes|_(?!_))+__\b/,"strong"],[/\*\*([^\\*]|@escapes|\*(?!\*))+\*\*/,"strong"],[/\b_[^_]+_\b/,"emphasis"],[/\*([^\\*]|@escapes)+\*/,"emphasis"],[/`([^\\`]|@escapes)+`/,"variable"],[/^\{[^}]*\}+/,"string.link"],[/[^*_)\]]\{[^}]*\}+/,"string.link"],[/(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^)]+\))/,["string.link","","string.link"]],[/\{/,{token:"tag",next:"@attributes"}],[/(:)([\w-]+)(\{)/,["tag","tag",{token:"tag",next:"@attributes"}]],[/(:)([\w-]+)/,["tag","tag"]],[/(\[)([^\]]*)(\])(\{)/,["string.link","","string.link",{token:"tag",next:"@attributes"}]],[/(\[)([^\]]*)(\])/,["string.link","","string.link"]],{include:"html"}],html:[[/<(\w+)\/>/,"tag"],[/<(\w+)/,{cases:{"@empty":{token:"tag",next:"@tag.$1"},"@default":{token:"tag",next:"@tag.$1"}}}],[/<\/(\w+)\s*>/,{token:"tag"}],[/<!--/,"comment","@comment"]],comment:[[/[^<-]+/,"comment.content"],[/-->/,"comment","@pop"],[/<!--/,"comment.content.invalid"],[/[<-]/,"comment.content"]],tag:[[/[ \t\r\n]+/,"white"],[/(type)(\s*=\s*)(")([^"]+)(")/,["attribute.name.html","delimiter.html","string.html",{token:"string.html",switchTo:"@tag.$S2.$4"},"string.html"]],[/(type)(\s*=\s*)(')([^']+)(')/,["attribute.name.html","delimiter.html","string.html",{token:"string.html",switchTo:"@tag.$S2.$4"},"string.html"]],[/(\w+)(\s*=\s*)("[^"]*"|'[^']*')/,["attribute.name.html","delimiter.html","string.html"]],[/\w+/,"attribute.name.html"],[/\/>/,"tag","@pop"],[/>/,{cases:{"$S2==style":{token:"tag",switchTo:"embeddedStyle",nextEmbedded:"text/css"},"$S2==script":{cases:{$S3:{token:"tag",switchTo:"embeddedScript",nextEmbedded:"$S3"},"@default":{token:"tag",switchTo:"embeddedScript",nextEmbedded:"text/javascript"}}},"@default":{token:"tag",next:"@pop"}}}]],embeddedStyle:[[/[^<]+/,""],[/<\/style\s*>/,{token:"@rematch",next:"@pop",nextEmbedded:"@pop"}],[/</,""]],embeddedScript:[[/[^<]+/,""],[/<\/script\s*>/,{token:"@rematch",next:"@pop",nextEmbedded:"@pop"}],[/</,""]]}};function Ie(o,r){return!r||r<1?r=1:r>6&&(r=6),`
${"#".repeat(r)} ${o}
`}function Ee(o,r,t){return t?.external?`<a href="${o instanceof URL?o.href:o}" title="${t?.title??""}" target="_blank">${r}</a>`:`[${r||o}](${o||"#"}${t?.title?` "${t.title}"`:""})`}function we(o,r,t){return`![${r||""}](${o||"#"}${t?.title?` "${t.title}"`:""})`}function xe(o,r,t){return`\`\`\`${r||""}${t?.ext?` ${t.ext}`:""}
${o}
\`\`\``}function Le(o){const r=`| ${o.columns.join(" | ")} |`,t=`| ${o.columns.map(()=>"---").join(" | ")} |`,l=o.rows.map(i=>`| ${i.join(" | ")} |`).join(`
`);return`${r}
${t}
${l}`}function he(o){return`**${o}**`}function Ce(o){return`_${o}_`}function Ne(o){return`***${o}***`}function Oe(o){return o.split(`
`).map(l=>`> ${l}`).join(`
`)}function Se(o){return`~~${o}~~`}function Te(o){return"-".repeat(o||3)}function Me(o,r={}){return o.map((t,l)=>`${r.ordered?`${l+1}.`:r.char||"-"} ${t}`).join(`
`)}const x={__proto__:null,blockquote:Oe,bold:he,boldAndItalic:Ne,codeBlock:xe,heading:Ie,hr:Te,image:we,italic:Ce,link:Ee,list:Me,strikethrough:Se,table:Le},ye={"w-full":"",flex:"~ items-center",p2:""},Be={class:"mx-auto text-xs big-dark-300",border:"~ base",rounded:"md"},je=P({__name:"EditorTextToolbar",props:{editor:{default:null}},setup(o){const r=o;if(!r.editor)throw new Error("Editor is required");const t=r.editor;function l(n,e={shouldHaveText:!0,createInNewLine:!1,extendSelection:!1,focus:!0}){if(t){let a=t.getSelection();if(e.extendSelection&&k(),e.createInNewLine&&i(),a=t.getSelection(),!a)return;const N=t.getModel()?.getValueInRange(a);if(e.shouldHaveText&&!N){t.focus();return}const O=n(N??"");t.executeEdits("",[{range:a,text:O}]),e.focus&&t.focus()}}function i(){const n=t.getPosition();if(!n)return;const e=new ne(n.lineNumber+1,1,n.lineNumber+1,1);t.executeEdits("toolbar",[{range:e,text:`
`,forceMoveMarkers:!0}]),t.setPosition({lineNumber:n.lineNumber+2,column:1})}function k(){const n=t.getSelections();if(!n)return;const e=n.map(a=>{const N=a.startLineNumber,O=a.endLineNumber;return new A(N,1,O,t.getModel()?.getLineMaxColumn(O)??0)});t.setSelections(e)}function p(n){const e=t.getSelection();e&&(t.setSelection(new A(e.startLineNumber,e.endColumn-n.length-1,e.endLineNumber,e.endColumn-1)),t.focus())}function m(){t.trigger("keyboard","undo",null)}function $(){t.trigger("keyboard","redo",null)}function I(){l(n=>x.heading(n,1),{shouldHaveText:!1,createInNewLine:!0})}function s(){l(n=>n.startsWith("**")&&n.endsWith("**")?n.slice(2,-2):x.bold(n))}function f(){l(n=>n.startsWith("_")&&n.endsWith("_")?n.slice(1,-1):x.italic(n))}function w(){l(n=>n.startsWith("~~")&&n.endsWith("~~")?n.slice(2,-2):x.strikethrough(n))}function g(){l(n=>n.startsWith("`")&&n.endsWith("`")?n.slice(1,-1):`\`${n}\``)}async function d(){const n=await W(),e=n?.startsWith("http")?n:"/";l(a=>x.link(e,a),{shouldHaveText:!1}),p(e)}async function v(){const n=await W()??"",e=G(n)==="image"?n:"/";l(a=>x.image(e,a),{shouldHaveText:!1}),p(e)}function y(){l(n=>x.blockquote(n),{shouldHaveText:!1,extendSelection:!0})}function L(){l(n=>x.codeBlock(n,"md"),{shouldHaveText:!1})}function B(){l(n=>{const e=n.split(`
`);return e.every(a=>a.startsWith("- "))?e.map(a=>a.slice(2)).join(`
`):x.list(e,{ordered:!1})},{shouldHaveText:!1,extendSelection:!0})}function h(){l(n=>{const e=n.split(`
`);return e.every(a=>/^\d+\.\s/.test(a))?e.map(a=>a.slice(3)).join(`
`):x.list(e,{ordered:!0})},{shouldHaveText:!1,extendSelection:!0})}function b(){l(()=>x.table({columns:["Breed","Origin","Size","Temperament"],rows:[["Abyssinian","Egypt","Medium","Active"],["Aegean","Greece","Medium","Active"],["American Bobtail","United States","Medium","Active"],["Applehead Siamese","Thailand","Medium","Active"]]}),{shouldHaveText:!1,createInNewLine:!0}),i()}function c(){const n=t.getValue();if(!n)return;const e=be(n,{tabSize:2,isFormatOnType:!0});t.setValue(e)}return(n,e)=>(H(),z("div",ye,[u("div",Be,[u("button",{class:"toolbar-button",title:"Undo",onClick:e[0]||(e[0]=a=>m())},e[15]||(e[15]=[u("div",{class:"h-6 ICON_UNDO"},null,-1)])),u("button",{class:"toolbar-button border-r",title:"Redo",onClick:e[1]||(e[1]=a=>$())},e[16]||(e[16]=[u("div",{class:"h-6 ICON_REDO"},null,-1)])),u("button",{class:"toolbar-button",title:"Heading",onClick:e[2]||(e[2]=a=>I())},e[17]||(e[17]=[u("div",{class:"h-6 ICON_H1"},null,-1)])),u("button",{class:"toolbar-button",title:"Bold",onClick:e[3]||(e[3]=a=>s())},e[18]||(e[18]=[u("div",{class:"h-6 ICON_BOLD"},null,-1)])),u("button",{class:"toolbar-button",title:"Italic",onClick:e[4]||(e[4]=a=>f())},e[19]||(e[19]=[u("div",{class:"h-6 ICON_ITALIC"},null,-1)])),u("button",{class:"toolbar-button hidden",title:"Strikethrough",onClick:e[5]||(e[5]=a=>w())},e[20]||(e[20]=[u("div",{class:"h-6 ICON_STRIKE"},null,-1)])),u("button",{class:"toolbar-button",title:"Unordered List",onClick:e[6]||(e[6]=a=>B())},e[21]||(e[21]=[u("div",{class:"h-6 ICON_LIST_BULLET"},null,-1)])),u("button",{class:"toolbar-button",title:"Ordered List",onClick:e[7]||(e[7]=a=>h())},e[22]||(e[22]=[u("div",{class:"h-6 ICON_LIST_ORDERED"},null,-1)])),u("button",{class:"toolbar-button",title:"Link",onClick:e[8]||(e[8]=a=>d())},e[23]||(e[23]=[u("div",{class:"h-6 ICON_LINK"},null,-1)])),u("button",{class:"toolbar-button",title:"Image",onClick:e[9]||(e[9]=a=>v())},e[24]||(e[24]=[u("div",{class:"h-6 ICON_IMAGE"},null,-1)])),u("button",{class:"toolbar-button",title:"Blockquote",onClick:e[10]||(e[10]=a=>y())},e[25]||(e[25]=[u("div",{class:"h-6 ICON_QUOTE"},null,-1)])),u("button",{class:"toolbar-button",title:"Table",onClick:e[11]||(e[11]=a=>b())},e[26]||(e[26]=[u("div",{class:"h-6 ICON_TABLE"},null,-1)])),u("button",{class:"toolbar-button",title:"Code",onClick:e[12]||(e[12]=a=>g())},e[27]||(e[27]=[u("div",{class:"h-6 ICON_CODE"},null,-1)])),u("button",{class:"toolbar-button",title:"Code Block",onClick:e[13]||(e[13]=a=>L())},e[28]||(e[28]=[u("div",{class:"h-6 ICON_CODE_BLOCK"},null,-1)])),u("button",{class:"toolbar-button border-l",title:"Prettify",onClick:e[14]||(e[14]=a=>c())},e[29]||(e[29]=[u("div",{class:"h-6 ICON_MAGIC"},null,-1)])),J(n.$slots,"default")])]))}}),Re=2;function He(o,r){const t=j(),l=ee(t.value,{theme:`vs-${o.value}`,language:r,automaticLayout:!0,roundedSelection:!0,selectionHighlight:!0,padding:{bottom:10},tabSize:Re,insertSpaces:!0,formatOnType:!0,formatOnPaste:!0});return l.useInlineViewWhenSpaceIsLimited=l.wordWrap==="on",l}function q(o){o.languages.register({id:"mdc"}),o.languages.setMonarchTokensProvider("mdc",ve),o.languages.registerFoldingRangeProvider("mdc",{provideFoldingRanges:$e})}function Ge(o,r="markdown"){if(!o)return;const t=X();q(t);const l=o.getModel(),i=r==="markdown"?"mdc":r;l&&t.editor.setModelLanguage(l,i),o.onDropIntoEditor(k=>{const p=k.event.dataTransfer.getData("itemKey");if(!p)return;let m=p;if(m){const g=m.split(":");if(g.includes("content")){const d=g.indexOf("content");m=`/${g.slice(d+1).join("/").replace(/\..*$/,"")}`}if(g.includes("public")){const d=g.indexOf("public");m=`/${g.slice(d+1).join("/")}`}props.lang==="markdown"&&G(m)==="image"&&(m=`![${g.at(-1).replace(/\..*$/,"").replaceAll("-"," ")}](${m})`)}const{lineNumber:$,column:I}=k.position,s=new t.Range($,I,$,I),w={identifier:{major:1,minor:1},range:s,text:m,forceMoveMarkers:!0};o.executeEdits("my-source",[w])})}function Xe(o,r="markdown"){if(!o)return;const t=X();q(t);const l=r==="markdown"?"mdc":r,i=o.getOriginalEditor(),k=o.getModifiedEditor(),p=i.getModel(),m=k.getModel();!p||!m||(t.editor.setModelLanguage(p,l),t.editor.setModelLanguage(m,l))}const qe=te(oe);export{qe as M,Pe as _,je as a,Xe as b,He as g,Ge as o};
