import{N as e}from"./index-C06UNqy_.js";import{n}from"./vue-vendor-CXH4vh4f.js";import"./utils-CVerdzLB.js";import"./element-plus-iW1UGqN4.js";import"./terminal-CLC_Uyhw.js";import"./echarts-tmlBSIFE.js";import"./markdown-CjUgdZ68.js";import"./icons-DvkvZK0u.js";const t=e=>{const n="v-md-editor-preview";return e.classList.contains(n)?e:e.querySelector(`.${n}`)},i=e=>{const n=e.renderer.rules.fence;e.renderer.rules.fence=(...e)=>{const t=n(...e);if(e[0][e[1]].content.split("\n").length<10)return t;return t.replace("\x3c!--beforeend--\x3e",'\n <button class="v-md-ai-explain-btn relative" type="button">\n <div class="tooltiptext">AI代码解释</div>\n <i>\n <svg width="1.5em" height="1.5em" viewBox="0 0 512 512" aria-hidden="true" focusable="false" data-icon="copy"><path d="M259.92 262.91L216.4 149.77a9 9 0 0 0-16.8 0l-43.52 113.14a9 9 0 0 1-5.17 5.17L37.77 311.6a9 9 0 0 0 0 16.8l113.14 43.52a9 9 0 0 1 5.17 5.17l43.52 113.14a9 9 0 0 0 16.8 0l43.52-113.14a9 9 0 0 1 5.17-5.17l113.14-43.52a9 9 0 0 0 0-16.8l-113.14-43.52a9 9 0 0 1-5.17-5.17z" fill="none" stroke="#29a4f1" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"></path><path fill="none" stroke="#29a4f1" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M108 68L88 16L68 68L16 88l52 20l20 52l20-52l52-20l-52-20z"></path><path fill="none" stroke="#29a4f1" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M426.67 117.33L400 48l-26.67 69.33L304 144l69.33 26.67L400 240l26.67-69.33L496 144l-69.33-26.67z"></path></svg></i>\n </button>\x3c!--beforeend--\x3e').replace("v-md-pre-wrapper","v-md-pre-wrapper ai-explain-mode")}},r=e=>{e.extendMarkdown(e=>{e.use(i)})},o=e=>!!e.classList.contains("v-md-ai-explain-btn")||!e.classList.contains("v-md-editor-preview")&&o(e.parentNode),s=e=>e.classList.contains("v-md-pre-wrapper")?e:s(e.parentNode),a=()=>({install:i=>{i.mixins||(i.mixins=[]),i.vMdParser.use(r),i.mixins.push({emits:["ai-explain"],mounted(){n(()=>{t(this.$el).addEventListener("click",this.handleCodeExplainClick)})},unmounted(){t(this.$el).removeEventListener("click",this.handleCodeExplainClick)},methods:{handleCodeExplainClick({target:n}){var t;if(o(n)){const i=s(n.parentNode);if(i){const n=(null==(t=i.querySelector("code"))?void 0:t.innerText)||"";-1!==n.indexOf("NSSCTF 智能助手")?e.warning({message:"已经是解释后的代码了!"}):this.$emit("ai-explain",n)}}}}})}});export{a as createAiPlugin};