markstream-vue 0.0.11 → 0.0.12-beta.1

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.
@@ -1 +1 @@
1
- var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,a=(n,t,l)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[t]=l,r=(e,n)=>{for(var t in n||(n={}))o.call(n,t)&&a(e,t,n[t]);if(l)for(var t of l(n))i.call(n,t)&&a(e,t,n[t]);return e},u=(e,l)=>n(e,t(l)),d=(e,n,t)=>new Promise((l,o)=>{var i=e=>{try{r(t.next(e))}catch(n){o(n)}},a=e=>{try{r(t.throw(e))}catch(n){o(n)}},r=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,a);r((t=t.apply(e,n)).next())});import{defineComponent as s,computed as c,onMounted as v,onUnmounted as f,openBlock as p,createBlock as m,Teleport as h,createElementVNode as g,normalizeClass as y,withModifiers as w,toDisplayString as b,unref as k,getCurrentInstance as S,ref as C,watch as x,onBeforeUnmount as O,nextTick as E,createElementBlock as L,normalizeStyle as M,createVNode as P,createSlots as B,withCtx as H,withDirectives as z,createCommentVNode as N,vShow as D,renderSlot as _}from"vue";import{b as T,_ as F,n as R,k as $,u as j,l as A,c as U,m as W,o as q,p as V,h as I,q as G,v as J,e as X,w as Y}from"./exports.js";const K={class:"html-preview-frame__header"},Q={class:"html-preview-frame__title"},Z={class:"html-preview-frame__label"},ee=["srcdoc"],ne=/* @__PURE__ */F(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},onClose:{type:Function},title:{}},setup(e){const n=e,{t}=T(),l=c(()=>{const e=n.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${n.isDark?"#020617":"#ffffff"};\n color: ${n.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`});function o(e){var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=n.onClose)||t.call(n)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",o)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",o)}),(e,o)=>(p(),m(h,{to:"body"},[g("div",{class:y(["markstream-vue",{dark:n.isDark}])},[g("div",{class:"html-preview-frame__backdrop",onClick:o[2]||(o[2]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})},[g("div",{class:"html-preview-frame",onClick:o[1]||(o[1]=w(()=>{},["stop"]))},[g("div",K,[g("div",Q,[o[3]||(o[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",Z,b(n.title||k(t)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:"html-preview-frame__close",onClick:o[0]||(o[0]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})}," × ")]),g("iframe",{class:"html-preview-frame__iframe",sandbox:"allow-scripts allow-same-origin",srcdoc:l.value},null,8,ee)])])],2)]))}}),[["__scopeId","data-v-fd3f9c21"]]);let te=null,le=null,oe=null,ie=null,ae=null,re=null;const ue=/* @__PURE__ */new WeakMap;let de=0;const se=["data-markstream-enhanced"],ce={class:"code-header-main"},ve=["innerHTML"],fe={class:"code-header-copy"},pe={class:"code-header-title"},me={key:0,class:"code-header-caption"},he={class:"code-editor-layer"},ge="__markstreamMonacoPassiveTouch__",ye=/* @__PURE__ */F(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isShowPreview:{type:Boolean,default:!0},monacoOptions:{},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},customId:{},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:n}){var t;const l=e,o=n;const i=S(),a=c(()=>{const e=null==i?void 0:i.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:s}=T(),v=C(null),h=C(null),w=C(!1),F=C(R(l.node.language)),K=c(()=>$(F.value)),Q=c(()=>"plaintext"===K.value),Z=C(!1),ee=C(!1),ye=C(!1),we=C(!1),be=C(!1);let ke=!1,Se=null;const Ce=C(null);let xe=0;const Oe=j(),Ee=C(null),Le=C("undefined"==typeof window);"undefined"!=typeof window&&x(()=>h.value,e=>{var n;if(null==(n=Ee.value)||n.destroy(),Ee.value=null,!e)return void(Le.value=!1);const t=Oe(e,{rootMargin:"400px"});Ee.value=t,Le.value=t.isVisible.value,t.whenVisible.then(()=>{Le.value=!0})},{immediate:!0}),O(()=>{var e;ke=!0,null==(e=Ee.value)||e.destroy(),Ee.value=null});let Me=null,Pe=null,Be=()=>{},He=()=>{},ze=()=>null,Ne=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),De=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),_e=()=>{},Te=()=>{},Fe=()=>{},Re=null,$e=()=>{var e;return String(null!=(e=l.node.language)?e:"plaintext")},je=()=>d(null,null,function*(){});const Ae=[],Ue=[];let We=null;const qe=c(()=>l.node.diff),Ve=C({removed:0,added:0}),Ie=c(()=>`-${Ve.value.removed} +${Ve.value.added}`),Ge=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function Je(e){var n;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const t=e;return u(r(r({},Ge),t),{enabled:null==(n=t.enabled)||n})}return r({},Ge)}const Xe=c(()=>{var e;const n=l.monacoOptions?r({},l.monacoOptions):{};if(!qe.value)return n;const t=void 0===n.diffHideUnchangedRegions?r({},Ge):Je(n.diffHideUnchangedRegions),o=void 0===n.hideUnchangedRegions?void 0:Je(n.hideUnchangedRegions),i=null!=(e=n.diffUnchangedRegionStyle)?e:"line-info";return u(r(r(r({},{maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,diffHideUnchangedRegions:t,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:i,diffHunkActionsOnHover:!1}),n),void 0===o?{}:{hideUnchangedRegions:o}),{diffHideUnchangedRegions:t})}),Ye=c(()=>qe.value?"diff":"single"),Ke=C(Ye.value),Qe=C(!1),Ze=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.wordWrap;return null==n||"off"!==String(n)}),en=c(()=>!Qe.value&&!we.value),nn=C(!1);"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield A();if(ke)return;if(!e)return void(Qe.value=!0);const n=e.useMonaco,t=e.detectLanguage;if("function"==typeof t&&($e=t),"function"==typeof n){const e=Qn();if(e&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(e))throw new Error("Preferred theme not in provided themes array");We=tt();const t=n(We);Me=t.createEditor||Me,Pe=t.createDiffEditor||Pe,Be=t.updateCode||Be,He=t.updateDiff||He,ze=t.getEditor||ze,Ne=t.getEditorView||Ne,De=t.getDiffEditorView||De,_e=t.cleanupEditor||_e,Te=t.safeClean||t.cleanupEditor||Te,Fe=t.refreshDiffPresentation||Fe,je=t.setTheme||je,be.value=!0,!ke&&v.value&&(yield Jn(v.value))}}catch(e){if(ke)return;Qe.value=!0}});const tn=C("number"==typeof(null==(t=l.monacoOptions)?void 0:t.fontSize)?l.monacoOptions.fontSize:Number.NaN),ln=C(tn.value),on=c(()=>{const e=tn.value,n=ln.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),an=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n;const t=ln.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:12}),rn=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.lineHeight;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:Math.round(1.5*an.value)}),un=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.tabSize;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:4}),dn=c(()=>{const e=l.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}),sn=c(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.fontFamily;return r(r({fontSize:`${an.value}px`,lineHeight:`${rn.value}px`,tabSize:un.value},null!=dn.value?{minHeight:`${dn.value}px`}:{}),"string"==typeof n&&n.trim()?{"--markstream-code-font-family":n.trim()}:{})}),cn=c(()=>null!=dn.value&&!we.value),vn=c(()=>{if(cn.value)return{minHeight:`${dn.value}px`}});function fn(){var e,n,t,l,o;try{const i=qe.value?null!=(t=null==(n=null==(e=De())?void 0:e.getModifiedEditor)?void 0:n.call(e))?t:De():Ne(),a=ze(),r=null==(l=null==a?void 0:a.EditorOption)?void 0:l.fontInfo;if(i&&null!=r){const e=null==(o=i.getOption)?void 0:o.call(i,r),n=null==e?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n}}catch(i){}try{const e=v.value;if(e){const n=e.querySelector(".view-lines .view-line");if(n)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(n).fontSize,t=e&&e.match(/^(\d+(?:\.\d+)?)/);if(t)return Number.parseFloat(t[1])}}catch(i){}}}catch(i){}return null}function pn(e){var n,t;try{const l=ze(),o=null==(n=null==l?void 0:l.EditorOption)?void 0:n.lineHeight;if(null!=o){const n=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o);if("number"==typeof n&&n>0)return n}}catch(i){}const l=function(){try{const e=v.value;if(!e)return null;const n=e.querySelector(".view-lines .view-line");if(n){const e=Math.ceil(n.getBoundingClientRect().height);if(e>0)return e}}catch(i){}return null}();if(l&&l>0)return l;const o=Number.isFinite(ln.value)&&ln.value>0?ln.value:14;return Math.max(12,Math.round(1.35*o))}function mn(e,n){return"number"!=typeof e||"number"!=typeof n||e<1||n<e?0:n-e+1}function hn(e){if(!e)return[];const n=e.split(/\r?\n/);return 1===n.length&&""===n[0]?[]:n}function gn(){var e,n;qe.value?Ve.value=function(e,n){const t=hn(e),l=hn(n);let o=0,i=t.length-1,a=l.length-1;for(;o<=i&&o<=a&&t[o]===l[o];)o++;for(;i>=o&&a>=o&&t[i]===l[a];)i--,a--;return{removed:Math.max(0,i-o+1),added:Math.max(0,a-o+1)}}(String(null!=(e=l.node.originalCode)?e:""),String(null!=(n=l.node.updatedCode)?n:"")):Ve.value={removed:0,added:0}}function yn(){var e;if(qe.value)try{const n=De(),t=null==(e=null==n?void 0:n.getLineChanges)?void 0:e.call(n);if(!Array.isArray(t))return void gn();let l=0,o=0;for(const e of t)l+=mn(e.originalStartLineNumber,e.originalEndLineNumber),o+=mn(e.modifiedStartLineNumber,e.modifiedEndLineNumber);Ve.value={removed:l,added:o}}catch(n){gn()}else Ve.value={removed:0,added:0}}function wn(){var e;if(Number.isFinite(ln.value)&&ln.value>0&&Number.isFinite(tn.value))return ln.value;const n=fn();return"number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?(tn.value=l.monacoOptions.fontSize,ln.value=l.monacoOptions.fontSize,ln.value):n&&n>0?(tn.value=n,ln.value=n,n):(tn.value=12,ln.value=12,12)}function bn(){const e=wn(),n=Math.min(36,e+1);ln.value=n}function kn(){const e=wn(),n=Math.max(10,e-1);ln.value=n}function Sn(){wn(),Number.isFinite(tn.value)&&(ln.value=tn.value)}function Cn(){var e,n,t,l,o,i,a,r,u,d,s,c,v,f;try{const p=qe.value?De():null,m=qe.value?p:Ne();if(!m)return null;if((null==p?void 0:p.getOriginalEditor)&&(null==p?void 0:p.getModifiedEditor)){const v=null==(e=p.getOriginalEditor)?void 0:e.call(p),f=null==(n=p.getModifiedEditor)?void 0:n.call(p);null==(t=null==v?void 0:v.layout)||t.call(v),null==(l=null==f?void 0:f.layout)||l.call(f);const m=(null==(o=null==v?void 0:v.getContentHeight)?void 0:o.call(v))||0,h=(null==(i=null==f?void 0:f.getContentHeight)?void 0:i.call(f))||0,g=Math.max(m,h);if(g>0)return Math.ceil(g+1);const y=(null==(u=null==(r=null==(a=null==v?void 0:v.getModel)?void 0:a.call(v))?void 0:r.getLineCount)?void 0:u.call(r))||1,w=(null==(c=null==(s=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:s.getLineCount)?void 0:c.call(s))||1,b=Math.max(y,w),k=Math.max(pn(v),pn(f));return Math.ceil(b*(k+1.5)+0+1)}if(null==m?void 0:m.getContentHeight){null==(v=null==m?void 0:m.layout)||v.call(m);const e=m.getContentHeight();if(e>0)return Math.ceil(e+1)}const h=null==(f=null==m?void 0:m.getModel)?void 0:f.call(m);let g=1;h&&"function"==typeof h.getLineCount&&(g=h.getLineCount());const y=pn(m);return Math.ceil(g*(y+1.5)+0+1)}catch(p){return null}}function xn(e){const n=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!n||n.length<3)return null;const[t,l,o]=n.slice(0,3).map(Number);return.2126*t+.7152*l+.0722*o}function On(){var e,n,t,l,o,i,a,r;const u=v.value,d=h.value;if(!u||!d)return;const s=u;if(qe.value)return s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--vscode-editor-background"),void s.style.removeProperty("--vscode-editor-selectionBackground");const c=u.querySelector(".monaco-editor")||u,f=c.querySelector(".monaco-editor-background")||c,p=c.querySelector(".view-lines")||c;let m=null,g=null,y=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(m=window.getComputedStyle(c),g=f===c?m:window.getComputedStyle(f),y=p===c?m:window.getComputedStyle(p))}catch(x){m=null,g=null,y=null}const w=String(null!=(e=null==m?void 0:m.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),b=String(null!=(n=null==m?void 0:m.getPropertyValue("--vscode-editor-background"))?n:"").trim(),k=String(null!=(l=null!=(t=null==m?void 0:m.getPropertyValue("--vscode-editor-selectionBackground"))?t:null==m?void 0:m.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?l:"").trim(),S=w||String(null!=(i=null!=(o=null==y?void 0:y.color)?o:null==m?void 0:m.color)?i:"").trim(),C=b||String(null!=(r=null!=(a=null==g?void 0:g.backgroundColor)?a:null==m?void 0:m.backgroundColor)?r:"").trim();if(function(e,n,t){if(!Q.value)return!1;const l=xn(e),o=xn(n);return t?null!=l&&l>170||null!=o&&o<110:null!=l&&l<85||null!=o&&o>190}(C,S,d.classList.contains("is-dark")))return s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--vscode-editor-background"),void s.style.removeProperty("--vscode-editor-selectionBackground");S&&s.style.setProperty("--vscode-editor-foreground",S),C&&s.style.setProperty("--vscode-editor-background",C),k&&s.style.setProperty("--vscode-editor-selectionBackground",k)}c(()=>{if(null!=dn.value)return{minHeight:`${dn.value}px`}});const En=/auto|scroll|overlay/i;function Ln(e,n,t){var l;if("undefined"==typeof window)return;const o=Math.ceil(n),i=Math.ceil(t)-o;if(!i)return;const a=function(e){var n,t;if("undefined"==typeof window)return null;const l=null!=(n=null==e?void 0:e.ownerDocument)?n:document,o=l.scrollingElement||l.documentElement||l.body;let i=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;i&&i!==l.body&&i!==o;){const e=window.getComputedStyle(i),n=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(En.test(n)||En.test(t))return i;i=i.parentElement}return o}(e);if(!a)return;const r=null!=(l=e.ownerDocument)?l:document,u=a===r.body||a===r.documentElement||a===r.scrollingElement,d=u?0:a.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,i):a.scrollTop+=i)}function Mn(){try{const e=v.value;if(!e)return;const n=e.getBoundingClientRect().height,t=Cn();if(null!=t&&t>0){const l=Math.ceil(t);e.style.minHeight="0px",e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",Ln(e,n,l)}}catch(e){}}function Pn(){for(var e,n;Ae.length>0;)try{null==(n=null==(e=Ae.pop())?void 0:e.dispose)||n.call(e)}catch(t){}null!=Se&&(Y(Se),Se=null)}function Bn(){for(var e;Ue.length>0;)try{null==(e=Ue.pop())||e()}catch(n){}}function Hn(){if(Bn(),!qe.value)return;const e=v.value;if(!e)return;const n=e.querySelector(".monaco-diff-editor");if(!n||n.classList.contains("side-by-side"))return;const t=Array.from(n.querySelectorAll(".editor.original .diff-hidden-lines")),l=Array.from(n.querySelectorAll(".editor.modified .diff-hidden-lines")),o=Math.min(t.length,l.length);for(let i=0;i<o;i++){const e=t[i],n=l[i].querySelector("a"),o=e.querySelector(".center > div:first-child");if(!n||!o)continue;const a=document.createElement("button");a.type="button",a.className="markstream-inline-fold-proxy";const r=n.getAttribute("title")||"Show Unchanged Region";a.title=r,a.setAttribute("aria-label",r);const u=n.querySelector(".codicon"),d=document.createElement("span");d.className=(null==u?void 0:u.className)||"codicon codicon-unfold",a.append(d);const s=e=>{e.preventDefault(),e.stopPropagation()},c=e=>{e.preventDefault(),e.stopPropagation(),n.click()},v=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),n.click())};a.addEventListener("mousedown",s),a.addEventListener("click",c),a.addEventListener("keydown",v),o.replaceChildren(a),Ue.push(()=>{a.removeEventListener("mousedown",s),a.removeEventListener("click",c),a.removeEventListener("keydown",v),o.contains(a)&&o.replaceChildren()})}}function zn(){null==Se&&(Se=U(()=>{Se=null,U(()=>{Hn(),ee.value||(Z.value?Mn():Dn())})}))}function Nn(e,n,t){const l=Math.min(n,t),o=n>t+1;return e.style.minHeight="0px",e.style.height=`${Math.ceil(l)}px`,e.style.maxHeight=`${Math.ceil(t)}px`,e.style.overflow=o?"auto":"hidden",Math.ceil(l)}function Dn(){var e;try{const n=v.value;if(!n)return;const t=n.getBoundingClientRect().height,o=function(){var e,n;const t=null!=(n=null==(e=l.monacoOptions)?void 0:e.MAX_HEIGHT)?n:500;if("number"==typeof t)return t;const o=String(t).match(/^(\d+(?:\.\d+)?)/);return o?Number.parseFloat(o[1]):500}();if(xe>0&&(xe--,null!=Ce.value))return void Ln(n,t,Nn(n,Ce.value,o));const i=Cn();if(null!=i&&i>0)return void Ln(n,t,Nn(n,i,o));if(null!=Ce.value)return void Ln(n,t,Nn(n,Ce.value,o));const a=Math.ceil((null==(e=n.getBoundingClientRect)?void 0:e.call(n).height)||0);if(a>0)return void Ln(n,t,Nn(n,a,o));const r=Number.parseFloat(n.style.height);!Number.isNaN(r)&&r>0?Ln(n,t,Nn(n,r,o)):Ln(n,t,Nn(n,o,o))}catch(n){}}const _n=c(()=>l.isShowPreview&&("html"===F.value||"svg"===F.value));x(()=>l.node.language,e=>{F.value=R(e)}),x(()=>[l.node.originalCode,l.node.updatedCode,qe.value],()=>{gn(),U(()=>yn())},{immediate:!0}),x(()=>[l.node.originalCode,l.node.updatedCode,K.value,qe.value],e=>d(null,[e],function*([e,n,t,o]){if(!1!==l.stream&&o){if(Me&&!ye.value&&v.value)try{yield Jn(v.value)}catch(i){}He(String(null!=e?e:""),String(null!=n?n:""),K.value),Z.value&&U(()=>Mn())}})),x(()=>l.node.code,e=>d(null,null,function*(){if(!1!==l.stream&&(F.value||(F.value=R($e(e))),!qe.value)){if(Me&&!ye.value&&v.value)try{yield Jn(v.value)}catch(n){}Be(e,K.value),Z.value&&U(()=>Mn())}}));const Tn=c(()=>{const e=F.value;return e?W[e]||e.charAt(0).toUpperCase()+e.slice(1):W[""]||"Plain Text"});const Fn=c(()=>{var e;return function(e){const n=function(e){var n,t;const l=null!=(t=null==(n=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:n.trim())?t:"";if(l.length<3)return"";const o=l[0];if("`"!==o&&"~"!==o||l[1]!==o||l[2]!==o)return"";let i=3;for(;l[i]===o;)i+=1;return l.slice(i).trim()}(e);if(!n)return"";const t=n.split(/\s+/).filter(Boolean);if(!t.length)return"";const l="diff"===t[0]?t.slice(1):t;for(const o of l){const e=o.includes(":")?o.slice(o.indexOf(":")+1):o;if(e&&/[./\\-]/.test(e))return e}return""}(String(null!=(e=l.node.raw)?e:""))}),Rn=c(()=>Fn.value||Tn.value),$n=c(()=>Fn.value?qe.value?`Diff / ${Tn.value}`:Tn.value:""),jn=c(()=>(q.value,V(F.value||""))),An=c(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=n(l.minWidth),o=n(l.maxWidth);return t&&(e.minWidth=t),o&&(e.maxWidth=o),qe.value||(e.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg))",e.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg))",e.borderColor="var(--markstream-code-border-color)"),e});c(()=>{});const Un=c(()=>!1!==l.showTooltips);function Wn(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(l.node.code)),w.value=!0,o("copy",l.node.code),setTimeout(()=>{w.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function qn(e){if(Z.value=!Z.value,e&&Un.value){const n=function(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}(e);if(n){const e=Z.value?s("common.collapse")||"Collapse":s("common.expand")||"Expand";X(n,e,"top",!1,void 0,l.isDark)}}const n=qe.value?De():Ne(),t=v.value;n&&t&&(Z.value?(Gn(!0),t.style.maxHeight="none",t.style.overflow="visible",Mn()):(Gn(!1),t.style.overflow="auto",Dn()))}function Vn(){var e,n,t;if(ee.value=!ee.value,ee.value){if(v.value){const t=Math.ceil((null==(n=(e=v.value).getBoundingClientRect)?void 0:n.call(e).height)||0);t>0&&(Ce.value=t)}Gn(!1)}else{Z.value&&Gn(!0),v.value&&null!=Ce.value&&(v.value.style.height=`${Ce.value}px`);const e=qe.value?De():Ne();try{null==(t=null==e?void 0:e.layout)||t.call(e)}catch(l){}xe=2,U(()=>{Z.value?Mn():Dn()})}}function In(){if(!_n.value)return;const e=F.value;if(a.value){const n="html"===e?"text/html":"image/svg+xml",t="html"===e?s("artifacts.htmlPreviewTitle")||"HTML Preview":s("artifacts.svgPreviewTitle")||"SVG Preview";return void o("previewCode",{node:l.node,artifactType:n,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(nn.value=!nn.value)}function Gn(e){var n,t;try{if(qe.value){const t=De();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}else{const n=Ne();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}}catch(l){}}function Jn(e){if(!Me||ke)return null;if(function(){var e;try{const n=window;if(n[ge])return;const t=null==(e=window.Element)?void 0:e.prototype,l=null==t?void 0:t.addEventListener;if(!t||!l)return;t.addEventListener=function(e,n,t){return"touchstart"===e&&function(e,n){if(!e)return!1;const t=e;return!("function"!=typeof t.closest||!t.closest(".monaco-editor, .monaco-diff-editor")||n&&"object"==typeof n&&"passive"in n)}(this,t)?l.call(this,e,n,function(e){return null==e?{passive:!0}:"boolean"==typeof e?{capture:e,passive:!0}:"object"==typeof e?"passive"in e?e:u(r({},e),{passive:!0}):{passive:!0}}(t)):l.call(this,e,n,t)},n[ge]=!0}catch(n){}}(),Re)return Re;if(ye.value&&we.value)return Promise.resolve();ye.value=!0;const n=d(null,null,function*(){yield function(e){return d(this,null,function*(){var n,t,o;if(!Me||ke)return;if(Pn(),Bn(),function(e){e.replaceChildren()}(e),ke)return;if(qe.value?(Te(),Pe?yield Pe(e,String(null!=(n=l.node.originalCode)?n:""),String(null!=(t=l.node.updatedCode)?t:""),K.value):yield Me(e,l.node.code,K.value)):yield Me(e,l.node.code,K.value),ke)return;const i=qe.value?De():Ne();if("number"==typeof(null==(o=l.monacoOptions)?void 0:o.fontSize))null==i||i.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),tn.value=l.monacoOptions.fontSize,ln.value=l.monacoOptions.fontSize;else{const e=fn();e&&e>0?(tn.value=e,ln.value=e):(tn.value=12,ln.value=12)}if(Z.value||ee.value||Dn(),!1===l.loading){if(yield E(),ke)return;U(()=>{ke||(Z.value&&!ee.value?Mn():ee.value||Dn())})}yield E(),ke||(we.value=!0,function(){var e,n,t,l,o;if(Pn(),qe.value){const l=De(),o=null==(e=null==l?void 0:l.getOriginalEditor)?void 0:e.call(l),a=null==(n=null==l?void 0:l.getModifiedEditor)?void 0:n.call(l),r=(e,n)=>{try{const t=null==e?void 0:e[n];if("function"!=typeof t)return;const l=t.call(e,()=>zn());l&&Ae.push(l)}catch(t){}};try{const e=null==(t=null==l?void 0:l.onDidUpdateDiff)?void 0:t.call(l,()=>{zn(),U(()=>yn())});e&&Ae.push(e)}catch(i){}r(o,"onDidContentSizeChange"),r(a,"onDidContentSizeChange"),r(o,"onDidLayoutChange"),r(a,"onDidLayoutChange")}else{const e=Ne();try{const n=null==(l=null==e?void 0:e.onDidContentSizeChange)?void 0:l.call(e,()=>zn());n&&Ae.push(n)}catch(i){}try{const n=null==(o=null==e?void 0:e.onDidLayoutChange)?void 0:o.call(e,()=>zn());n&&Ae.push(n)}catch(i){}}}(),On(),Hn(),yn(),zn())})}(e)}).finally(()=>{Re===n&&(Re=null)});return Re=n,n}x(Un,e=>{e||I()}),x(()=>ln.value,(e,n)=>{const t=qe.value?De():Ne();t&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(t.updateOptions({fontSize:e}),Z.value&&!ee.value&&Mn())},{flush:"post",immediate:!1});const Xn=x(()=>[v.value,qe.value,l.stream,l.loading,be.value,Le.value],e=>d(null,[e],function*([e,n,t,l,o,i]){if(!e||!Me)return;if(!i)return;if(!1===t&&!1!==l)return;const a=Jn(e);if(a){try{yield a}catch(r){we.value=!1}Xn()}}));function Yn(e){return!!e&&"object"==typeof e&&"light"in e&&"dark"in e}function Kn(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function Qn(){var e;const n=function(){if(void 0!==l.theme){const e=l.theme;return Yn(e)?l.isDark?e.dark:e.light:e}return l.isDark?l.darkTheme:l.lightTheme}(),t=null==(e=Xe.value)?void 0:e.theme,o=null!=n?n:t;if(null!=o&&"object"==typeof o)return o;const i=Array.isArray(l.themes)?l.themes:[];if(!i.length||null==o)return o;const a=Kn(o),r=i.map(e=>Kn(e)).filter(e=>!!e);if(!a||r.includes(a))return o;const u=Kn(t);return null!=t&&u&&r.includes(u)?t:i[0]}x(Ye,(e,n)=>d(null,null,function*(){if(e===n)return;if(Ke.value=e,!Me||!v.value)return;if(!ye.value)return;if(!1===l.stream&&!1!==l.loading)return;if(!Le.value)return;const t=Re;if(t){try{yield t}catch(o){}if(ke||!v.value)return}try{we.value=!1,ye.value=!1,Pn(),Bn(),Te(),yield E(),yield Jn(v.value)}catch(i){we.value=!1}}));const Zn=c(()=>void 0===l.theme||Yn(l.theme)?!!l.isDark:function(e){var n,t;if(e&&"object"==typeof e&&(null==(n=e.colors)?void 0:n["editor.background"])){const n=xn(e.colors["editor.background"]);if(null!=n)return n<128}const o=(null!=(t=Kn(e))?t:"").toLowerCase();return o?["dark","night","moon","black","dracula","mocha","frappe","macchiato","palenight","ocean","poimandres","monokai","laserwave","tokyo","slack-dark","rose-pine","github-dark","material-theme","one-dark","catppuccin-mocha","catppuccin-frappe","catppuccin-macchiato"].some(e=>o.includes(e))&&!["light","latte","dawn","lotus"].some(e=>o.includes(e)):!!l.isDark}(Qn())),et=c(()=>{var e;if(!qe.value)return Zn.value?"dark":"light";const n=null==(e=Xe.value)?void 0:e.diffAppearance;return"light"===n||"dark"===n?n:Zn.value?"dark":"light"}),nt=c(()=>qe.value?"dark"===et.value:Zn.value);function tt(){return u(r(u(r({wordWrap:"on",wrappingIndent:"same",themes:l.themes},Xe.value||{}),{theme:Qn()}),qe.value?{diffAppearance:et.value}:{}),{onThemeChange(){On()}})}function lt(){const e=tt();if(!We)return We=e,We;for(const n of Object.keys(We))n in e||delete We[n];return Object.assign(We,e),We}const ot=c(()=>{var e,n,t,l,o,i,a,r,u,d,s,c,v,f;return JSON.stringify({diffLineStyle:null!=(n=null==(e=Xe.value)?void 0:e.diffLineStyle)?n:"background",diffUnchangedRegionStyle:null!=(l=null==(t=Xe.value)?void 0:t.diffUnchangedRegionStyle)?l:"line-info",diffHideUnchangedRegions:null==(i=null==(o=Xe.value)?void 0:o.diffHideUnchangedRegions)||i,renderSideBySide:null==(r=null==(a=Xe.value)?void 0:a.renderSideBySide)||r,enableSplitViewResizing:null==(d=null==(u=Xe.value)?void 0:u.enableSplitViewResizing)||d,ignoreTrimWhitespace:null==(c=null==(s=Xe.value)?void 0:s.ignoreTrimWhitespace)||c,originalEditable:null!=(f=null==(v=Xe.value)?void 0:v.originalEditable)&&f})});x(()=>[l.monacoOptions,Le.value],()=>{var e,n;if(lt(),!Me||!Le.value)return;const t=qe.value?De():Ne(),o="number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?l.monacoOptions.fontSize:Number.isFinite(ln.value)?ln.value:void 0;"number"==typeof o&&Number.isFinite(o)&&o>0&&(null==(n=null==t?void 0:t.updateOptions)||n.call(t,{fontSize:o})),Z.value&&!ee.value?Mn():ee.value||Dn()},{deep:!0}),x(()=>[Qn(),et.value,be.value,ye.value,Le.value],()=>{be.value&&ye.value&&Le.value&&function(){lt();const e=Qn(),n=()=>{qe.value&&Fe(),U(()=>{On(),zn()})};e?function(e,n){const t=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&"name"in e)return String(e.name);if("object"==typeof e){const t=ue.get(e);if(t)return t;try{const n=JSON.stringify(e);if(n)return ue.set(e,n),n}catch(n){}const l="__theme_"+ ++de;return ue.set(e,l),l}return String(e)}(n);return t?(re=e,te||ae!==t?te?(ie===t||le===t||(oe=n,ie=t),te):(oe=n,ie=t,te=d(null,null,function*(){for(;ie&&null!=oe;){const t=oe,l=ie;if(oe=null,ie=null,ae!==l)try{le=l,yield(null!=re?re:e)(t),ae=l}catch(n){}}}).finally(()=>{te=null,le=null}),te):Promise.resolve()):Promise.resolve()}(je,e).then(n).catch(e=>{}):n()}()},{flush:"post"}),x(()=>[ot.value,be.value,Le.value],(e,n)=>d(null,[e,n],function*([e,n,t],[o]){if(lt(),!n||!t)return;if(!Me||!v.value)return;if(!ye.value)return;if(e===o)return;if(!1===l.stream&&!1!==l.loading)return;const i=Re;if(i){try{yield i}catch(a){}if(ke||!v.value)return}try{we.value=!1,ye.value=!1,Pn(),Bn(),Te(),yield E(),yield Jn(v.value)}catch(r){we.value=!1}}),{flush:"post"});const it=x(()=>[l.loading,Le.value],(e,n)=>d(null,[e,n],function*([e,n],t){if(!n)return;if(e)return;const o=null==t?void 0:t[0],i=void 0!==o&&!1!==o;yield E(),U(()=>{d(null,null,function*(){var e;try{if(i&&ye.value)if(qe.value&&v.value){const e=Re;if(e)try{yield e}catch(n){}we.value=!1,ye.value=!1,Pn(),Bn(),Te(),v.value.replaceChildren(),yield E(),yield Jn(v.value)}else Be(String(null!=(e=l.node.code)?e:""),K.value);ee.value||(Z.value?Mn():Dn()),it()}catch(t){}})})}),{immediate:!0,flush:"post"});return f(()=>{Pn(),Bn(),_e()}),(n,t)=>Qe.value?(p(),m(k(G),{key:0,node:l.node,loading:l.loading},null,8,["node","loading"])):(p(),L("div",{key:1,ref_key:"container",ref:h,style:M(An.value),class:y(["code-block-container rounded-lg border overflow-hidden",[{dark:l.isDark,"is-rendering":l.loading,"is-dark":nt.value,"is-diff":qe.value,"is-plain-text":Q.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":we.value&&!Qe.value?"true":"false"},[P(J,{"show-header":l.showHeader,"show-collapse-button":l.showCollapseButton,"show-font-size-buttons":l.showFontSizeButtons,"enable-font-size-control":l.enableFontSizeControl,"show-copy-button":l.showCopyButton,"show-expand-button":l.showExpandButton,"show-preview-button":l.showPreviewButton,"show-tooltips":l.showTooltips,"is-dark":l.isDark,loading:l.loading,stream:e.stream,"is-collapsed":ee.value,"is-expanded":Z.value,"copy-text":w.value,"is-previewable":_n.value,"code-font-size":ln.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":tn.value,"font-baseline-ready":on.value,"diff-stats":qe.value?Ve.value:null,"diff-stats-aria-label":Ie.value,onToggleCollapse:Vn,onDecreaseFont:kn,onResetFont:Sn,onIncreaseFont:bn,onCopy:Wn,onToggleExpand:qn,onPreview:In},B({"header-left":H(()=>[_(n.$slots,"header-left",{},()=>[g("div",ce,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:jn.value},null,8,ve),g("div",fe,[g("div",pe,b(Rn.value),1),$n.value?(p(),L("div",me,b($n.value),1)):N("",!0)])])],!0)]),loading:H(()=>[_(n.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[t[0]||(t[0]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))],!0)]),default:H(()=>[z(g("div",he,[g("div",{ref_key:"codeEditor",ref:v,class:y(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":en.value}]]),style:M(vn.value)},null,6),en.value?(p(),m(k(G),{key:0,class:y(["code-pre-fallback",{"is-wrap":Ze.value}]),style:M(sn.value),node:l.node},null,8,["class","style","node"])):N("",!0)],512),[[D,!(ee.value||!e.stream&&e.loading)]]),nn.value&&!a.value&&_n.value&&"html"===F.value?(p(),m(ne,{key:0,code:l.node.code,"is-dark":l.isDark,"on-close":()=>nn.value=!1},null,8,["code","is-dark","on-close"])):N("",!0)]),_:2},[n.$slots["header-right"]?{name:"header-right",fn:H(()=>[_(n.$slots,"header-right",{},void 0,!0)]),key:"0"}:void 0]),1032,["show-header","show-collapse-button","show-font-size-buttons","enable-font-size-control","show-copy-button","show-expand-button","show-preview-button","show-tooltips","is-dark","loading","stream","is-collapsed","is-expanded","copy-text","is-previewable","code-font-size","default-code-font-size","font-baseline-ready","diff-stats","diff-stats-aria-label"])],14,se))}}),[["__scopeId","data-v-21de71db"]]);export{ye as default};
1
+ var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,r=(n,t,l)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[t]=l,a=(e,n)=>{for(var t in n||(n={}))o.call(n,t)&&r(e,t,n[t]);if(l)for(var t of l(n))i.call(n,t)&&r(e,t,n[t]);return e},u=(e,l)=>n(e,t(l)),d=(e,n,t)=>new Promise((l,o)=>{var i=e=>{try{a(t.next(e))}catch(n){o(n)}},r=e=>{try{a(t.throw(e))}catch(n){o(n)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);a((t=t.apply(e,n)).next())});import{defineComponent as c,computed as s,onMounted as v,onUnmounted as f,openBlock as m,createBlock as p,Teleport as h,createElementVNode as g,normalizeClass as y,withModifiers as w,toDisplayString as b,unref as k,getCurrentInstance as S,ref as C,watch as x,onBeforeUnmount as O,nextTick as M,createElementBlock as E,normalizeStyle as L,createVNode as B,createSlots as P,withCtx as z,withDirectives as H,createCommentVNode as D,vShow as N,renderSlot as F}from"vue";import{b as T,_,n as R,k as A,u as $,l as j,c as W,m as I,o as U,p as q,h as V,q as G,v as J,e as X,w as Y}from"./exports.js";const K={class:"html-preview-frame__header"},Q={class:"html-preview-frame__title"},Z={class:"html-preview-frame__label"},ee=["srcdoc"],ne=/* @__PURE__ */_(/* @__PURE__ */c({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},onClose:{type:Function},title:{}},setup(e){const n=e,{t}=T(),l=s(()=>{const e=n.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${n.isDark?"#020617":"#ffffff"};\n color: ${n.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`});function o(e){var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=n.onClose)||t.call(n)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",o)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",o)}),(e,o)=>(m(),p(h,{to:"body"},[g("div",{class:y(["markstream-vue",{dark:n.isDark}])},[g("div",{class:"html-preview-frame__backdrop",onClick:o[2]||(o[2]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})},[g("div",{class:"html-preview-frame",onClick:o[1]||(o[1]=w(()=>{},["stop"]))},[g("div",K,[g("div",Q,[o[3]||(o[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",Z,b(n.title||k(t)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:"html-preview-frame__close",onClick:o[0]||(o[0]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})}," × ")]),g("iframe",{class:"html-preview-frame__iframe",sandbox:"allow-scripts allow-same-origin",srcdoc:l.value},null,8,ee)])])],2)]))}}),[["__scopeId","data-v-fd3f9c21"]]);let te=null,le=null,oe=null,ie=null,re=null,ae=null;const ue=/* @__PURE__ */new WeakMap;let de=0;const ce=["data-markstream-enhanced"],se={class:"code-header-main"},ve=["innerHTML"],fe={class:"code-header-copy"},me={class:"code-header-title"},pe={key:0,class:"code-header-caption"},he={class:"code-editor-layer"},ge="__markstreamMonacoPassiveTouch__",ye=/* @__PURE__ */_(/* @__PURE__ */c({__name:"CodeBlockNode",props:{node:{},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isShowPreview:{type:Boolean,default:!0},monacoOptions:{},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},customId:{},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:n}){var t;const l=e,o=n;const i=S(),r=s(()=>{const e=null==i?void 0:i.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:c}=T(),v=C(null),h=C(null),w=C(!1),_=C(R(l.node.language)),K=s(()=>A(_.value)),Q=s(()=>"plaintext"===K.value),Z=C(!1),ee=C(!1),ye=C(!1),we=C(!1),be=C(!1);let ke=!1,Se=null;const Ce=C(null),xe=C(null);let Oe=0,Me=0;const Ee=$(),Le=C(null),Be=C("undefined"==typeof window);"undefined"!=typeof window&&x(()=>h.value,e=>{var n;if(null==(n=Le.value)||n.destroy(),Le.value=null,!e)return void(Be.value=!1);const t=Ee(e,{rootMargin:"400px"});Le.value=t,Be.value=t.isVisible.value,t.whenVisible.then(()=>{Be.value=!0})},{immediate:!0}),O(()=>{var e;ke=!0,null==(e=Le.value)||e.destroy(),Le.value=null});let Pe=null,ze=null,He=()=>{},De=()=>{},Ne=()=>null,Fe=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Te=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),_e=()=>{},Re=()=>{},Ae=()=>{},$e=null,je=()=>{var e;return String(null!=(e=l.node.language)?e:"plaintext")},We=()=>d(null,null,function*(){});const Ie=[],Ue=[];let qe=null;const Ve=s(()=>l.node.diff),Ge=C({removed:0,added:0}),Je=s(()=>`-${Ge.value.removed} +${Ge.value.added}`),Xe=Object.freeze({enabled:!1}),Ye=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function Ke(e){var n;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const t=e;return u(a(a({},Ye),t),{enabled:null==(n=t.enabled)||n})}return a({},Ye)}function Qe(e,n){return{original:String(null!=e?e:""),updated:String(null!=n?n:"")}}const Ze=s(()=>{var e,n,t;const o=l.monacoOptions?a({},l.monacoOptions):{};if(!Ve.value)return o;const i=void 0===o.diffHideUnchangedRegions?a({},Ye):Ke(o.diffHideUnchangedRegions),r=void 0===o.hideUnchangedRegions?void 0:Ke(o.hideUnchangedRegions),d=!1!==l.stream&&!1!==l.loading,c=d?a({},Xe):i,s=d?a({},Xe):r,v=a({},null!=(e=o.experimental)?e:{}),f=null!=(n=o.diffUnchangedRegionStyle)?n:"line-info",m={maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,diffHideUnchangedRegions:c,useInlineViewWhenSpaceIsLimited:null!=(t=o.useInlineViewWhenSpaceIsLimited)&&t,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:f,diffHunkActionsOnHover:!1,experimental:v};return u(a(u(a(a({},m),o),{experimental:v}),void 0===s?{}:{hideUnchangedRegions:s}),{diffHideUnchangedRegions:c})}),en=s(()=>Ve.value?"diff":"single"),nn=C(en.value),tn=C(!1),ln=s(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.wordWrap;return null==n||"off"!==String(n)}),on=s(()=>!tn.value&&!we.value),rn=C(!1);"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield j();if(ke)return;if(!e)return void(tn.value=!0);const n=e.useMonaco,t=e.detectLanguage;if("function"==typeof t&&(je=t),"function"==typeof n){const e=lt();if(e&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(e))throw new Error("Preferred theme not in provided themes array");qe=at();const t=n(qe);Pe=t.createEditor||Pe,ze=t.createDiffEditor||ze,He=t.updateCode||He,De=t.updateDiff||De,Ne=t.getEditor||Ne,Fe=t.getEditorView||Fe,Te=t.getDiffEditorView||Te,_e=t.cleanupEditor||_e,Re=t.safeClean||t.cleanupEditor||Re,Ae=t.refreshDiffPresentation||Ae,We=t.setTheme||We,be.value=!0,!ke&&v.value&&(yield Zn(v.value))}}catch(e){if(ke)return;tn.value=!0}});const an=C("number"==typeof(null==(t=l.monacoOptions)?void 0:t.fontSize)?l.monacoOptions.fontSize:Number.NaN),un=C(an.value),dn=s(()=>{const e=an.value,n=un.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),cn=s(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n;const t=un.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:12}),sn=s(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.lineHeight;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:Math.round(1.5*cn.value)}),vn=s(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.tabSize;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:4}),fn=s(()=>{const e=l.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}),mn=s(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.fontFamily;return a(a({fontSize:`${cn.value}px`,lineHeight:`${sn.value}px`,tabSize:vn.value},null!=fn.value?{minHeight:`${fn.value}px`}:{}),"string"==typeof n&&n.trim()?{"--markstream-code-font-family":n.trim()}:{})}),pn=s(()=>null!=fn.value&&!we.value),hn=s(()=>{if(pn.value)return{minHeight:`${fn.value}px`}});function gn(){var e,n,t,l,o;try{const i=Ve.value?null!=(t=null==(n=null==(e=Te())?void 0:e.getModifiedEditor)?void 0:n.call(e))?t:Te():Fe(),r=Ne(),a=null==(l=null==r?void 0:r.EditorOption)?void 0:l.fontInfo;if(i&&null!=a){const e=null==(o=i.getOption)?void 0:o.call(i,a),n=null==e?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n}}catch(i){}try{const e=v.value;if(e){const n=e.querySelector(".view-lines .view-line");if(n)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(n).fontSize,t=e&&e.match(/^(\d+(?:\.\d+)?)/);if(t)return Number.parseFloat(t[1])}}catch(i){}}}catch(i){}return null}function yn(e){var n,t;try{const l=Ne(),o=null==(n=null==l?void 0:l.EditorOption)?void 0:n.lineHeight;if(null!=o){const n=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o);if("number"==typeof n&&n>0)return n}}catch(i){}const l=function(){try{const e=v.value;if(!e)return null;const n=e.querySelector(".view-lines .view-line");if(n){const e=Math.ceil(n.getBoundingClientRect().height);if(e>0)return e}}catch(i){}return null}();if(l&&l>0)return l;const o=Number.isFinite(un.value)&&un.value>0?un.value:14;return Math.max(12,Math.round(1.35*o))}function wn(e){var n,t,l;try{const l=Ne(),o=null==(n=null==l?void 0:l.EditorOption)?void 0:n.padding;if(null!=o){const n=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o),l="number"==typeof(null==n?void 0:n.top)?n.top:0,i="number"==typeof(null==n?void 0:n.bottom)?n.bottom:0;if(l>0||i>0)return l+i}}catch(a){}const o=null==(l=Ze.value)?void 0:l.padding,i="number"==typeof(null==o?void 0:o.top)?o.top:0,r="number"==typeof(null==o?void 0:o.bottom)?o.bottom:0;return i>0||r>0?i+r:Ve.value?24:0}function bn(e,n){return"number"!=typeof e||"number"!=typeof n||e<1||n<e?0:n-e+1}function kn(e){if(!e)return[];const n=e.split(/\r?\n/);return 1===n.length&&""===n[0]?[]:n}function Sn(){var e,n;Ve.value?Ge.value=function(e,n){const t=kn(e),l=kn(n);let o=0,i=t.length-1,r=l.length-1;for(;o<=i&&o<=r&&t[o]===l[o];)o++;for(;i>=o&&r>=o&&t[i]===l[r];)i--,r--;return{removed:Math.max(0,i-o+1),added:Math.max(0,r-o+1)}}(String(null!=(e=l.node.originalCode)?e:""),String(null!=(n=l.node.updatedCode)?n:"")):Ge.value={removed:0,added:0}}function Cn(){var e;if(Ve.value)try{const n=Te(),t=null==(e=null==n?void 0:n.getLineChanges)?void 0:e.call(n);if(!Array.isArray(t))return void Sn();let l=0,o=0;for(const e of t)l+=bn(e.originalStartLineNumber,e.originalEndLineNumber),o+=bn(e.modifiedStartLineNumber,e.modifiedEndLineNumber);Ge.value={removed:l,added:o}}catch(n){Sn()}else Ge.value={removed:0,added:0}}function xn(){var e;if(Number.isFinite(un.value)&&un.value>0&&Number.isFinite(an.value))return un.value;const n=gn();return"number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?(an.value=l.monacoOptions.fontSize,un.value=l.monacoOptions.fontSize,un.value):n&&n>0?(an.value=n,un.value=n,n):(an.value=12,un.value=12,12)}function On(){const e=xn(),n=Math.min(36,e+1);un.value=n}function Mn(){const e=xn(),n=Math.max(10,e-1);un.value=n}function En(){xn(),Number.isFinite(an.value)&&(un.value=an.value)}function Ln(){var e,n,t,l,o,i,r,a,u,d,c,s,v,f;try{const m=Ve.value?Te():null,p=Ve.value?m:Fe();if(!p)return null;if((null==m?void 0:m.getOriginalEditor)&&(null==m?void 0:m.getModifiedEditor)){const v=null==(e=m.getOriginalEditor)?void 0:e.call(m),f=null==(n=m.getModifiedEditor)?void 0:n.call(m);null==(t=null==v?void 0:v.layout)||t.call(v),null==(l=null==f?void 0:f.layout)||l.call(f);const p=(null==(o=null==v?void 0:v.getContentHeight)?void 0:o.call(v))||0,h=(null==(i=null==f?void 0:f.getContentHeight)?void 0:i.call(f))||0,g=Math.max(p,h);if(g>0)return Math.ceil(g+1);const y=(null==(u=null==(a=null==(r=null==v?void 0:v.getModel)?void 0:r.call(v))?void 0:a.getLineCount)?void 0:u.call(a))||1,w=(null==(s=null==(c=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:c.getLineCount)?void 0:s.call(c))||1,b=Math.max(y,w),k=Math.max(yn(v),yn(f));return Math.ceil(b*(k+1.5)+0+1)}if(null==p?void 0:p.getContentHeight){null==(v=null==p?void 0:p.layout)||v.call(p);const e=p.getContentHeight();if(e>0)return Math.ceil(e+1)}const h=null==(f=null==p?void 0:p.getModel)?void 0:f.call(p);let g=1;h&&"function"==typeof h.getLineCount&&(g=h.getLineCount());const y=yn(p);return Math.ceil(g*(y+1.5)+0+1)}catch(m){return null}}function Bn(e){const n=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!n||n.length<3)return null;const[t,l,o]=n.slice(0,3).map(Number);return.2126*t+.7152*l+.0722*o}function Pn(){var e,n,t,l,o,i,r,a;const u=v.value,d=h.value;if(!u||!d)return;const c=u;if(Ve.value)return c.style.removeProperty("--vscode-editor-foreground"),c.style.removeProperty("--vscode-editor-background"),void c.style.removeProperty("--vscode-editor-selectionBackground");const s=u.querySelector(".monaco-editor")||u,f=s.querySelector(".monaco-editor-background")||s,m=s.querySelector(".view-lines")||s;let p=null,g=null,y=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(p=window.getComputedStyle(s),g=f===s?p:window.getComputedStyle(f),y=m===s?p:window.getComputedStyle(m))}catch(x){p=null,g=null,y=null}const w=String(null!=(e=null==p?void 0:p.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),b=String(null!=(n=null==p?void 0:p.getPropertyValue("--vscode-editor-background"))?n:"").trim(),k=String(null!=(l=null!=(t=null==p?void 0:p.getPropertyValue("--vscode-editor-selectionBackground"))?t:null==p?void 0:p.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?l:"").trim(),S=w||String(null!=(i=null!=(o=null==y?void 0:y.color)?o:null==p?void 0:p.color)?i:"").trim(),C=b||String(null!=(a=null!=(r=null==g?void 0:g.backgroundColor)?r:null==p?void 0:p.backgroundColor)?a:"").trim();if(function(e,n,t){if(!Q.value)return!1;const l=Bn(e),o=Bn(n);return t?null!=l&&l>170||null!=o&&o<110:null!=l&&l<85||null!=o&&o>190}(C,S,d.classList.contains("is-dark")))return c.style.removeProperty("--vscode-editor-foreground"),c.style.removeProperty("--vscode-editor-background"),void c.style.removeProperty("--vscode-editor-selectionBackground");S&&c.style.setProperty("--vscode-editor-foreground",S),C&&c.style.setProperty("--vscode-editor-background",C),k&&c.style.setProperty("--vscode-editor-selectionBackground",k)}s(()=>{if(null!=fn.value)return{minHeight:`${fn.value}px`}});const zn=/auto|scroll|overlay/i;function Hn(e,n,t){var l;if("undefined"==typeof window)return;if(Ve.value)return;const o=Math.ceil(n),i=Math.ceil(t)-o;if(!i)return;const r=function(e){var n,t;if("undefined"==typeof window)return null;const l=null!=(n=null==e?void 0:e.ownerDocument)?n:document,o=l.scrollingElement||l.documentElement||l.body;let i=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;i&&i!==l.body&&i!==o;){const e=window.getComputedStyle(i),n=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(zn.test(n)||zn.test(t))return i;i=i.parentElement}return o}(e);if(!r)return;const a=null!=(l=e.ownerDocument)?l:document,u=r===a.body||r===a.documentElement||r===a.scrollingElement,d=u?0:r.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,i):r.scrollTop+=i)}function Dn(){try{const e=v.value;if(!e)return;const n=e.getBoundingClientRect().height,t=Ln();if(null!=t&&t>0){const l=Math.ceil(t);e.style.minHeight="0px",e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",Hn(e,n,l)}}catch(e){}}function Nn(){for(var e,n;Ie.length>0;)try{null==(n=null==(e=Ie.pop())?void 0:e.dispose)||n.call(e)}catch(t){}null!=Se&&(Y(Se),Se=null)}function Fn(){for(var e;Ue.length>0;)try{null==(e=Ue.pop())||e()}catch(n){}}function Tn(e=!1){ee.value||(Z.value?Dn():function(){var e;try{const n=v.value;if(!n)return;const t=n.getBoundingClientRect().height,o=function(){var e,n;const t=null!=(n=null==(e=l.monacoOptions)?void 0:e.MAX_HEIGHT)?n:500;if("number"==typeof t)return t;const o=String(t).match(/^(\d+(?:\.\d+)?)/);return o?Number.parseFloat(o[1]):500}(),i=Math.ceil((null==(e=n.getBoundingClientRect)?void 0:e.call(n).height)||0),r=Ve.value?function(){var e,n,t,l,o,i,r,a;try{const u=Te(),d=null==(e=null==u?void 0:u.getOriginalEditor)?void 0:e.call(u),c=null==(n=null==u?void 0:u.getModifiedEditor)?void 0:n.call(u);if(!d||!c)return null;const s=(null==(o=null==(l=null==(t=d.getModel)?void 0:t.call(d))?void 0:l.getLineCount)?void 0:o.call(l))||1,v=(null==(a=null==(r=null==(i=c.getModel)?void 0:i.call(c))?void 0:r.getLineCount)?void 0:a.call(r))||1,f=Math.max(s,v),m=Math.max(yn(d),yn(c)),p=Math.max(wn(d),wn(c));return Math.ceil(f*(m+1.5)+p+0+1)}catch(u){return null}}():null,a=Ve.value&&function(e){if("undefined"==typeof window)return!1;const n=e.querySelectorAll(".editor.modified .diff-hidden-lines .center, .stream-monaco-diff-unchanged-bridge");for(const t of Array.from(n)){if(!(t instanceof HTMLElement))continue;const e=window.getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const n=t.getBoundingClientRect();if(!(n.width<=0||n.height<=0))return!0}return!1}(n);if(a||(xe.value=null),Me>0&&(Me--,null!=Ce.value))return void Hn(n,t,An(n,Ce.value,o));const u=Ve.value?function(e){var n,t;if("undefined"==typeof window)return null;try{const l=e.getBoundingClientRect();if(l.height<=0)return null;const o=[".editor.original .view-lines .view-line",".editor.modified .view-lines .view-line",".editor.original .view-zones > div",".editor.modified .view-zones > div",".editor.original .margin-view-zones > div",".editor.modified .margin-view-zones > div",".editor.original .diff-hidden-lines",".editor.modified .diff-hidden-lines",".stream-monaco-diff-unchanged-bridge"];let i=0;for(const n of Array.from(e.querySelectorAll(o.join(",")))){if(!(n instanceof HTMLElement))continue;const e=window.getComputedStyle(n);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const t=n.getBoundingClientRect();t.height<=0||t.bottom<=l.top||(i=Math.max(i,t.bottom-l.top))}if(i>0)return Math.ceil(i+1);const r=e.querySelector(".monaco-diff-editor"),a=null!=(t=null==(n=null==r?void 0:r.getBoundingClientRect)?void 0:n.call(r).height)?t:0;return a>0?Math.ceil(a+1):null}catch(l){return null}}(n):Ln();if(null!=u&&u>0){const e=null!=xe.value&&Date.now()<Oe&&u>=o-1,l=a&&i>0&&i<o-1&&u>=o-1,r=An(n,e?xe.value:l?i:u,o);return a&&r<o-1&&(xe.value=r,Oe=Date.now()+160),void Hn(n,t,r)}if(null!=Ce.value)return void Hn(n,t,An(n,Ce.value,o));const d=a?i:Math.max(i,null!=r&&r>0?r:0);if(d>0){const e=null!=xe.value&&Date.now()<Oe&&d>=o-1,l=a&&i>0&&i<o-1&&d>=o-1,r=An(n,e?xe.value:l?i:d,o);return a&&r<o-1&&(xe.value=r,Oe=Date.now()+160),void Hn(n,t,r)}const c=Number.parseFloat(n.style.height);!Number.isNaN(c)&&c>0?Hn(n,t,An(n,c,o)):Ve.value||Hn(n,t,An(n,o,o))}catch(n){}}())}function _n(){if(!Ve.value)return void Fn();const e=v.value;if(!e)return void Fn();const n=e.querySelector(".monaco-diff-editor");if(!n||n.classList.contains("side-by-side"))return void Fn();const t=Array.from(n.querySelectorAll(".editor.original .diff-hidden-lines")),l=Array.from(n.querySelectorAll(".editor.modified .diff-hidden-lines")),o=Math.min(t.length,l.length);for(let i=0;i<o;i++){const e=l[i],n=e.querySelector("a"),t=e.querySelector(".center > div:first-child"),o=e.querySelector(".center");if(!n||!t||!o)continue;if(o.querySelector(".markstream-inline-fold-proxy"))continue;const r=document.createElement("button");r.type="button",r.className="markstream-inline-fold-proxy",r.dataset.markstreamInlineFoldProxy="true";const a=n.getAttribute("title")||"Show Unchanged Region";r.title=a,r.setAttribute("aria-label",a);const u=e=>{e.preventDefault(),e.stopPropagation()},d=e=>{e.preventDefault(),e.stopPropagation(),n.click(),W(()=>Rn())},c=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),n.click(),W(()=>Rn()))};r.addEventListener("mousedown",u),r.addEventListener("click",d),r.addEventListener("keydown",c),o.appendChild(r),Ue.push(()=>{r.removeEventListener("mousedown",u),r.removeEventListener("click",d),r.removeEventListener("keydown",c),r.parentElement===o&&o.removeChild(r)})}}function Rn(e=!1){null==Se&&(Se=W(()=>{Se=null,W(()=>{_n(),Tn(e)})}))}function An(e,n,t){const l=Math.min(n,t);if(e.style.minHeight="0px",e.style.height=`${Math.ceil(l)}px`,e.style.maxHeight=`${Math.ceil(t)}px`,Ve.value)e.style.overflow="hidden";else{const l=n>t+1;e.style.overflow=l?"auto":"hidden"}return Math.ceil(l)}const $n=s(()=>l.isShowPreview&&("html"===_.value||"svg"===_.value));x(()=>l.node.language,e=>{_.value=R(e)}),x(()=>[l.node.originalCode,l.node.updatedCode,Ve.value],()=>{Sn(),W(()=>Cn())},{immediate:!0}),x(()=>[l.node.originalCode,l.node.updatedCode,K.value,Ve.value],e=>d(null,[e],function*([e,n,t,o]){if(!1===l.stream||!o)return;if(Pe&&!ye.value&&v.value)try{yield Zn(v.value)}catch(r){}const i=Qe(String(null!=e?e:""),String(null!=n?n:""));!1===l.loading&&(ut(),Ae()),De(i.original,i.updated,K.value),Z.value&&W(()=>Dn())})),x(()=>l.node.code,e=>d(null,null,function*(){if(!1!==l.stream&&(_.value||(_.value=R(je(e))),!Ve.value)){if(Pe&&!ye.value&&v.value)try{yield Zn(v.value)}catch(n){}He(e,K.value),Z.value&&W(()=>Dn())}}));const jn=s(()=>{const e=_.value;return e?I[e]||e.charAt(0).toUpperCase()+e.slice(1):I[""]||"Plain Text"});const Wn=s(()=>{var e;return function(e){const n=function(e){var n,t;const l=null!=(t=null==(n=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:n.trim())?t:"";if(l.length<3)return"";const o=l[0];if("`"!==o&&"~"!==o||l[1]!==o||l[2]!==o)return"";let i=3;for(;l[i]===o;)i+=1;return l.slice(i).trim()}(e);if(!n)return"";const t=n.split(/\s+/).filter(Boolean);if(!t.length)return"";const l="diff"===t[0]?t.slice(1):t;for(const o of l){const e=o.includes(":")?o.slice(o.indexOf(":")+1):o;if(e&&/[./\\-]/.test(e))return e}return""}(String(null!=(e=l.node.raw)?e:""))}),In=s(()=>Wn.value||jn.value),Un=s(()=>Wn.value?Ve.value?`Diff / ${jn.value}`:jn.value:""),qn=s(()=>(U.value,q(_.value||""))),Vn=s(()=>{const e={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=n(l.minWidth),o=n(l.maxWidth);return t&&(e.minWidth=t),o&&(e.maxWidth=o),Ve.value||(e.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg))",e.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg))",e.borderColor="var(--markstream-code-border-color)"),e});s(()=>{});const Gn=s(()=>!1!==l.showTooltips);function Jn(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(l.node.code)),w.value=!0,o("copy",l.node.code),setTimeout(()=>{w.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function Xn(e){if(Z.value=!Z.value,e&&Gn.value){const n=function(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}(e);if(n){const e=Z.value?c("common.collapse")||"Collapse":c("common.expand")||"Expand";X(n,e,"top",!1,void 0,l.isDark)}}const n=Ve.value?Te():Fe(),t=v.value;n&&t&&(Z.value?(Qn(!0),t.style.maxHeight="none",t.style.overflow="visible",Tn(!0)):(Qn(!1),t.style.overflow=Ve.value?"hidden":"auto",Tn(!0)))}function Yn(){var e,n,t;if(ee.value=!ee.value,ee.value){if(v.value){const t=Math.ceil((null==(n=(e=v.value).getBoundingClientRect)?void 0:n.call(e).height)||0);t>0&&(Ce.value=t)}Qn(!1)}else{Z.value&&Qn(!0),v.value&&null!=Ce.value&&(v.value.style.height=`${Ce.value}px`);const e=Ve.value?Te():Fe();try{null==(t=null==e?void 0:e.layout)||t.call(e)}catch(l){}Me=2,W(()=>{Tn(!0)})}}function Kn(){if(!$n.value)return;const e=_.value;if(r.value){const n="html"===e?"text/html":"image/svg+xml",t="html"===e?c("artifacts.htmlPreviewTitle")||"HTML Preview":c("artifacts.svgPreviewTitle")||"SVG Preview";return void o("previewCode",{node:l.node,artifactType:n,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(rn.value=!rn.value)}function Qn(e){var n,t;try{if(Ve.value){const t=Te();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}else{const n=Fe();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}}catch(l){}}function Zn(e){if(!Pe||ke)return null;if(function(){var e;try{const n=window;if(n[ge])return;const t=null==(e=window.Element)?void 0:e.prototype,l=null==t?void 0:t.addEventListener;if(!t||!l)return;t.addEventListener=function(e,n,t){return"touchstart"===e&&function(e,n){if(!e)return!1;const t=e;return!("function"!=typeof t.closest||!t.closest(".monaco-editor, .monaco-diff-editor")||n&&"object"==typeof n&&"passive"in n)}(this,t)?l.call(this,e,n,function(e){return null==e?{passive:!0}:"boolean"==typeof e?{capture:e,passive:!0}:"object"==typeof e?"passive"in e?e:u(a({},e),{passive:!0}):{passive:!0}}(t)):l.call(this,e,n,t)},n[ge]=!0}catch(n){}}(),$e)return $e;if(ye.value&&we.value)return Promise.resolve();ye.value=!0;const n=d(null,null,function*(){yield function(e){return d(this,null,function*(){var n,t,o;if(!Pe||ke)return;if(Nn(),Fn(),function(e){e.replaceChildren()}(e),ke)return;if(Ve.value){Re();const o=Qe(String(null!=(n=l.node.originalCode)?n:""),String(null!=(t=l.node.updatedCode)?t:""));ze?yield ze(e,o.original,o.updated,K.value):yield Pe(e,l.node.code,K.value)}else yield Pe(e,l.node.code,K.value);if(ke)return;const i=Ve.value?Te():Fe();if("number"==typeof(null==(o=l.monacoOptions)?void 0:o.fontSize))null==i||i.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),an.value=l.monacoOptions.fontSize,un.value=l.monacoOptions.fontSize;else{const e=gn();e&&e>0?(an.value=e,un.value=e):(an.value=12,un.value=12)}if(Z.value||ee.value||Tn(!1),!1===l.loading){if(yield M(),ke)return;W(()=>{ke||Tn(!1)})}yield M(),ke||(we.value=!0,function(){var e,n,t,l,o;if(Nn(),Ve.value){const l=Te(),o=null==(e=null==l?void 0:l.getOriginalEditor)?void 0:e.call(l),i=null==(n=null==l?void 0:l.getModifiedEditor)?void 0:n.call(l),a=(e,n)=>{try{const t=null==e?void 0:e[n];if("function"!=typeof t)return;const l=t.call(e,()=>Rn());l&&Ie.push(l)}catch(t){}};try{const e=null==(t=null==l?void 0:l.onDidUpdateDiff)?void 0:t.call(l,()=>{Rn(),W(()=>Cn())});e&&Ie.push(e)}catch(r){}return a(o,"onDidContentSizeChange"),a(i,"onDidContentSizeChange"),a(o,"onDidLayoutChange"),void a(i,"onDidLayoutChange")}const i=Fe();try{const e=null==(l=null==i?void 0:i.onDidContentSizeChange)?void 0:l.call(i,()=>Rn());e&&Ie.push(e)}catch(r){}try{const e=null==(o=null==i?void 0:i.onDidLayoutChange)?void 0:o.call(i,()=>Rn());e&&Ie.push(e)}catch(r){}}(),Pn(),_n(),Cn(),Rn())})}(e)}).finally(()=>{$e===n&&($e=null)});return $e=n,n}x(Gn,e=>{e||V()}),x(()=>un.value,(e,n)=>{const t=Ve.value?Te():Fe();t&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(t.updateOptions({fontSize:e}),ee.value||Tn(!0))},{flush:"post",immediate:!1});const et=x(()=>[v.value,Ve.value,l.stream,l.loading,be.value,Be.value],e=>d(null,[e],function*([e,n,t,l,o,i]){if(!e||!Pe)return;if(!i)return;if(!1===t&&!1!==l)return;const r=Zn(e);if(r){try{yield r}catch(a){we.value=!1}et()}}));function nt(e){return!!e&&"object"==typeof e&&"light"in e&&"dark"in e}function tt(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function lt(){var e;const n=function(){if(void 0!==l.theme){const e=l.theme;return nt(e)?l.isDark?e.dark:e.light:e}return l.isDark?l.darkTheme:l.lightTheme}(),t=null==(e=Ze.value)?void 0:e.theme,o=null!=n?n:t;if(null!=o&&"object"==typeof o)return o;const i=Array.isArray(l.themes)?l.themes:[];if(!i.length||null==o)return o;const r=tt(o),a=i.map(e=>tt(e)).filter(e=>!!e);if(!r||a.includes(r))return o;const u=tt(t);return null!=t&&u&&a.includes(u)?t:i[0]}x(en,(e,n)=>d(null,null,function*(){if(e===n)return;if(nn.value=e,!Pe||!v.value)return;if(!ye.value)return;if(!1===l.stream&&!1!==l.loading)return;if(!Be.value)return;const t=$e;if(t){try{yield t}catch(o){}if(ke||!v.value)return}try{we.value=!1,ye.value=!1,Nn(),Fn(),Re(),yield M(),yield Zn(v.value)}catch(i){we.value=!1}}));const ot=s(()=>void 0===l.theme||nt(l.theme)?!!l.isDark:function(e){var n,t;if(e&&"object"==typeof e&&(null==(n=e.colors)?void 0:n["editor.background"])){const n=Bn(e.colors["editor.background"]);if(null!=n)return n<128}const o=(null!=(t=tt(e))?t:"").toLowerCase();return o?["dark","night","moon","black","dracula","mocha","frappe","macchiato","palenight","ocean","poimandres","monokai","laserwave","tokyo","slack-dark","rose-pine","github-dark","material-theme","one-dark","catppuccin-mocha","catppuccin-frappe","catppuccin-macchiato"].some(e=>o.includes(e))&&!["light","latte","dawn","lotus"].some(e=>o.includes(e)):!!l.isDark}(lt())),it=s(()=>{var e;if(!Ve.value)return ot.value?"dark":"light";const n=null==(e=Ze.value)?void 0:e.diffAppearance;return"light"===n||"dark"===n?n:ot.value?"dark":"light"}),rt=s(()=>Ve.value?"dark"===it.value:ot.value);function at(){return u(a(u(a({wordWrap:"on",wrappingIndent:"same",themes:l.themes},Ze.value||{}),{theme:lt()}),Ve.value?{diffAppearance:it.value}:{}),{onThemeChange(){Pn()}})}function ut(){const e=at();if(!qe)return qe=e,qe;for(const n of Object.keys(qe))n in e||delete qe[n];return Object.assign(qe,e),qe}const dt=s(()=>{var e,n,t,o,i,r,u,d,c,s,v,f,m,p,h;return JSON.stringify({diffLineStyle:null!=(n=null==(e=Ze.value)?void 0:e.diffLineStyle)?n:"background",diffUnchangedRegionStyle:null!=(o=null==(t=Ze.value)?void 0:t.diffUnchangedRegionStyle)?o:"line-info",diffHideUnchangedRegions:void 0===(null==(i=l.monacoOptions)?void 0:i.diffHideUnchangedRegions)?a({},Ye):Ke(l.monacoOptions.diffHideUnchangedRegions),renderSideBySide:null==(u=null==(r=Ze.value)?void 0:r.renderSideBySide)||u,useInlineViewWhenSpaceIsLimited:null==(c=null==(d=Ze.value)?void 0:d.useInlineViewWhenSpaceIsLimited)||c,enableSplitViewResizing:null==(v=null==(s=Ze.value)?void 0:s.enableSplitViewResizing)||v,ignoreTrimWhitespace:null==(m=null==(f=Ze.value)?void 0:f.ignoreTrimWhitespace)||m,originalEditable:null!=(h=null==(p=Ze.value)?void 0:p.originalEditable)&&h})});return x(()=>[l.monacoOptions,Be.value],()=>{var e,n;if(ut(),!Pe||!Be.value)return;const t=Ve.value?Te():Fe(),o="number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?l.monacoOptions.fontSize:Number.isFinite(un.value)?un.value:void 0;"number"==typeof o&&Number.isFinite(o)&&o>0&&(null==(n=null==t?void 0:t.updateOptions)||n.call(t,{fontSize:o})),Tn(!1)},{deep:!0}),x(()=>[lt(),it.value,be.value,ye.value,Be.value],()=>{be.value&&ye.value&&Be.value&&function(){ut();const e=lt(),n=()=>{Ve.value&&Ae(),W(()=>{Pn(),Rn()})};e?function(e,n){const t=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&"name"in e)return String(e.name);if("object"==typeof e){const t=ue.get(e);if(t)return t;try{const n=JSON.stringify(e);if(n)return ue.set(e,n),n}catch(n){}const l="__theme_"+ ++de;return ue.set(e,l),l}return String(e)}(n);return t?(ae=e,te||re!==t?te?(ie===t||le===t||(oe=n,ie=t),te):(oe=n,ie=t,te=d(null,null,function*(){for(;ie&&null!=oe;){const t=oe,l=ie;if(oe=null,ie=null,re!==l)try{le=l,yield(null!=ae?ae:e)(t),re=l}catch(n){}}}).finally(()=>{te=null,le=null}),te):Promise.resolve()):Promise.resolve()}(We,e).then(n).catch(e=>{}):n()}()},{flush:"post"}),x(()=>[dt.value,be.value,Be.value],(e,n)=>d(null,[e,n],function*([e,n,t],[o]){if(ut(),!n||!t)return;if(!Pe||!v.value)return;if(!ye.value)return;if(e===o)return;if(!1===l.stream&&!1!==l.loading)return;const i=$e;if(i){try{yield i}catch(r){}if(ke||!v.value)return}try{we.value=!1,ye.value=!1,Nn(),Fn(),Re(),yield M(),yield Zn(v.value)}catch(a){we.value=!1}}),{flush:"post"}),x(()=>[l.loading,Be.value],(e,n)=>d(null,[e,n],function*([e,n],t){if(!n)return;if(e)return;const o=null==t?void 0:t[0],i=void 0!==o&&!1!==o;yield M(),W(()=>{d(null,null,function*(){var e;try{if(i&&ye.value)if(Ve.value&&v.value){const e=$e;if(e)try{yield e}catch(n){}ut(),Ae(),_n(),Cn()}else He(String(null!=(e=l.node.code)?e:""),K.value);Tn(!1)}catch(t){}})})}),{immediate:!0,flush:"post"}),f(()=>{Nn(),Fn(),_e()}),(n,t)=>tn.value?(m(),p(k(G),{key:0,node:l.node,loading:l.loading},null,8,["node","loading"])):(m(),E("div",{key:1,ref_key:"container",ref:h,style:L(Vn.value),class:y(["code-block-container rounded-lg border overflow-hidden",[{dark:l.isDark,"is-rendering":l.loading,"is-dark":rt.value,"is-diff":Ve.value,"is-plain-text":Q.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":we.value&&!tn.value?"true":"false"},[B(J,{"show-header":l.showHeader,"show-collapse-button":l.showCollapseButton,"show-font-size-buttons":l.showFontSizeButtons,"enable-font-size-control":l.enableFontSizeControl,"show-copy-button":l.showCopyButton,"show-expand-button":l.showExpandButton,"show-preview-button":l.showPreviewButton,"show-tooltips":l.showTooltips,"is-dark":l.isDark,loading:l.loading,stream:e.stream,"is-collapsed":ee.value,"is-expanded":Z.value,"copy-text":w.value,"is-previewable":$n.value,"code-font-size":un.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":an.value,"font-baseline-ready":dn.value,"diff-stats":Ve.value?Ge.value:null,"diff-stats-aria-label":Je.value,onToggleCollapse:Yn,onDecreaseFont:Mn,onResetFont:En,onIncreaseFont:On,onCopy:Jn,onToggleExpand:Xn,onPreview:Kn},P({"header-left":z(()=>[F(n.$slots,"header-left",{},()=>[g("div",se,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:qn.value},null,8,ve),g("div",fe,[g("div",me,b(In.value),1),Un.value?(m(),E("div",pe,b(Un.value),1)):D("",!0)])])],!0)]),loading:z(()=>[F(n.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[t[0]||(t[0]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))],!0)]),default:z(()=>[H(g("div",he,[g("div",{ref_key:"codeEditor",ref:v,class:y(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":on.value}]]),style:L(hn.value)},null,6),on.value?(m(),p(k(G),{key:0,class:y(["code-pre-fallback",{"is-wrap":ln.value}]),style:L(mn.value),node:l.node},null,8,["class","style","node"])):D("",!0)],512),[[N,!(ee.value||!e.stream&&e.loading)]]),rn.value&&!r.value&&$n.value&&"html"===_.value?(m(),p(ne,{key:0,code:l.node.code,"is-dark":l.isDark,"on-close":()=>rn.value=!1},null,8,["code","is-dark","on-close"])):D("",!0)]),_:2},[n.$slots["header-right"]?{name:"header-right",fn:z(()=>[F(n.$slots,"header-right",{},void 0,!0)]),key:"0"}:void 0]),1032,["show-header","show-collapse-button","show-font-size-buttons","enable-font-size-control","show-copy-button","show-expand-button","show-preview-button","show-tooltips","is-dark","loading","stream","is-collapsed","is-expanded","copy-text","is-previewable","code-font-size","default-code-font-size","font-baseline-ready","diff-stats","diff-stats-aria-label"])],14,ce))}}),[["__scopeId","data-v-08365146"]]);export{ye as default};