import{bR as Hl,cd as Nl,bQ as tl,M as nl,bl as zl,af as Vn,bZ as Tl,c0 as ll,aU as L,c1 as en,bT as Dl,bE as U,az as Rl,c2 as _l,aI as ol,aL as Ae,s as gt,bk as sn,ce as Jn,u as Gn,I as Wl,A as Al,bJ as mt,aY as tn,bL as Il,v as z,aw as nn,au as wt,t as ln,bB as ql,bb as dn,q as g,cf as jl,c4 as Ul,c5 as Vl,c6 as Jl,a0 as Gl,c3 as Yn,aD as Yl,bO as Ql,T as Xl,as as ne,b$ as Zl,cg as Kl}from"./index-KEPtQokk.js";import{i as V,t as eo}from"./safeRaf-DGuzXxDK.js";import{V as to}from"./CodeBlockShell.vue_vue_type_style_index_0_lang-DCpGDnBA.js";var pt=(P,b,B)=>new Promise((r,ae)=>{var xe=C=>{try{J(B.next(C))}catch(E){ae(E)}},_=C=>{try{J(B.throw(C))}catch(E){ae(E)}},J=C=>C.done?r(C.value):Promise.resolve(C.value).then(xe,_);J((B=B.apply(P,b)).next())});let Qn=!1,et=null,ht=null,Xn=!1,tt=null;function no(){return pt(this,null,function*(){if(tt)return tt;tt=pt(null,null,function*(){if(!ht){if(Xn)return null;try{ht=yield Hl(()=>import("./__vite-optional-peer-dep_stream-monaco_markstream-vue-BIHI7g3E.js"),[])}catch{return Xn=!0,null}}try{return yield(function(P){return pt(this,null,function*(){return Qn?void 0:et||(et=pt(null,null,function*(){const B=globalThis?.MonacoEnvironment;B&&(typeof B.getWorker=="function"||typeof B.getWorkerUrl=="function")||typeof P?.preloadMonacoWorkers!="function"||(yield P.preloadMonacoWorkers()),Qn=!0}).finally(()=>{et=null}),et)})})(ht),Nl(),ht}catch{return null}});try{return yield tt}finally{tt=null}})}var lo=Object.defineProperty,oo=Object.defineProperties,io=Object.getOwnPropertyDescriptors,Zn=Object.getOwnPropertySymbols,ro=Object.prototype.hasOwnProperty,ao=Object.prototype.propertyIsEnumerable,Kn=(P,b,B)=>b in P?lo(P,b,{enumerable:!0,configurable:!0,writable:!0,value:B}):P[b]=B,N=(P,b)=>{for(var B in b||(b={}))ro.call(b,B)&&Kn(P,B,b[B]);if(Zn)for(var B of Zn(b))ao.call(b,B)&&Kn(P,B,b[B]);return P},ke=(P,b)=>oo(P,io(b)),H=(P,b,B)=>new Promise((r,ae)=>{var xe=C=>{try{J(B.next(C))}catch(E){ae(E)}},_=C=>{try{J(B.throw(C))}catch(E){ae(E)}},J=C=>C.done?r(C.value):Promise.resolve(C.value).then(xe,_);J((B=B.apply(P,b)).next())});const uo={class:"html-preview-frame__header"},so={class:"html-preview-frame__title"},co={class:"html-preview-frame__label"},vo=["sandbox","srcdoc"],fo=tl(nl({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(P){const b=P,B=import.meta!==void 0&&!1;let r=null;const{t:ae}=ll(),xe=g(()=>{const C=b.code||"",E=C.trim().toLowerCase();return E.startsWith("<!doctype")||E.startsWith("<html")||E.startsWith("<body")?C:`<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style>
      html, body {
        margin: 0;
        padding: 0;
        height: 100%;
        background-color: ${b.isDark?"#020617":"#ffffff"};
        color: ${b.isDark?"#e5e7eb":"#020617"};
      }
      body {
        font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;
      }
    </style>
  </head>
  <body>
    ${C}
  </body>
</html>`}),_=g(()=>{return C=b.htmlPreviewSandbox,E=b.htmlPreviewAllowScripts,typeof C=="string"?((function(pe){if(!B||typeof console>"u"||r===pe)return;const G=(function(S){return new Set(S.trim().toLowerCase().split(/\s+/).filter(Boolean))})(pe);G.has("allow-scripts")&&G.has("allow-same-origin")&&(r=pe,console.warn("[markstream-vue] htmlPreviewSandbox contains both allow-scripts and allow-same-origin. Use this only for fully trusted content served from an isolated origin."))})(C),C):C!==void 0?"":E===!0?"allow-scripts":"";var C,E});function J(C){var E;C.key!=="Escape"&&C.key!=="Esc"||(E=b.onClose)==null||E.call(b)}return Yl(()=>{typeof window<"u"&&window.addEventListener("keydown",J)}),ol(()=>{typeof window<"u"&&window.removeEventListener("keydown",J)}),(C,E)=>(Ae(),gt(Xl,{to:"body"},[z("div",{class:wt(["markstream-vue",{dark:b.isDark}])},[z("div",{class:"html-preview-frame__backdrop",onClick:E[2]||(E[2]=pe=>{var G;return(G=b.onClose)==null?void 0:G.call(b)})},[z("div",{class:"html-preview-frame",onClick:E[1]||(E[1]=Ql(()=>{},["stop"]))},[z("div",uo,[z("div",so,[E[3]||(E[3]=z("span",{class:"html-preview-frame__dot"},null,-1)),z("span",co,dn(b.title||sn(ae)("common.preview")||"Preview"),1)]),z("button",{type:"button",class:"html-preview-frame__close",onClick:E[0]||(E[0]=pe=>{var G;return(G=b.onClose)==null?void 0:G.call(b)})}," × ")]),z("iframe",{class:"html-preview-frame__iframe",sandbox:_.value,referrerpolicy:"no-referrer",srcdoc:xe.value},null,8,vo)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]);let _e=null,on=null,nt=null,We=null,rn=null,an=null;const un=new WeakMap;let mo=0;const po=["data-markstream-enhanced","data-markstream-pending"],ho={class:"code-header-main"},yo=["innerHTML"],go={class:"code-header-copy"},wo={class:"code-header-title"},bo={key:0,class:"code-header-caption"},So={class:"code-editor-layer"},el="__markstreamMonacoPassiveTouchState__",yt=1.5,Mo=tl(nl({__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},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(P,{emit:b}){var B;const r=P,ae=b,xe=zl(),_=Vn(Tl,null),J=Vn("markstreamHostScrollManaged",null),C=g(()=>Zl(r,xe)),E=Gl(),pe=g(()=>{const e=E?.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:G}=ll(),S=L(null),he=L(null),bt=L(!1),ue=L(en(r.node.language)),de=g(()=>jl(ue.value)),cn=g(()=>de.value==="plaintext"),se=L(!1),ye=L(!1),K=L(!1),le=L(!1),Ie=L(!1);let $=!1,Oe=null,ge="";const Ce=L(null),Me=L(null);let lt=0,St=0;const il=Dl(),qe=L(null),oe=L(typeof window>"u");typeof window<"u"&&U(()=>he.value,e=>{var t;if((t=qe.value)==null||t.destroy(),qe.value=null,!e)return void(oe.value=!1);const n=il(e,{rootMargin:"400px"});qe.value=n,oe.value=n.isVisible.value,n.whenVisible.then(()=>{oe.value=!0})},{immediate:!0}),Rl(()=>{var e;$=!0,(function(){const t=ge;_&&t&&(ge="",_.markSettled(t))})(),(e=qe.value)==null||e.destroy(),qe.value=null});let ee=null,ot=null,it=()=>{},rt=()=>{},je=()=>null,Y=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),T=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),kt=()=>{},Ue=()=>{},xt=()=>{},ce=null,vn=()=>{var e;return String((e=r.node.language)!=null?e:"plaintext")},Ct=()=>H(null,null,function*(){}),fn=!1;const Fe=[],Mt=[];let ve=null;function mn(e){var t;return((t=String(e??"").trim().split(/\s+/,1)[0])!=null?t:"")==="diff"}const v=g(()=>{var e;return r.node.diff===!0||mn(r.node.language)||mn(_n(String((e=r.node.raw)!=null?e:"")))}),Pe=L({removed:0,added:0}),rl=g(()=>`-${Pe.value.removed} +${Pe.value.added}`),Ve=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5}),pn=Object.freeze(ke(N({},Ve),{enabled:!1,revealLineCount:0}));function Pt(e){var t;if(typeof e=="boolean")return e;if(e&&typeof e=="object"){const n=e;return ke(N(N({},Ve),n),{enabled:(t=n.enabled)==null||t})}return N({},Ve)}function Bt(e,t){return{original:String(e??""),updated:String(t??"")}}function Je(e){var t;return String((t=e?.message)!=null?t:e).includes("no diff result available")}function $e(){try{const e=xt();e&&typeof e.catch=="function"&&e.catch(t=>{Je(t)})}catch(e){Je(e)}}const W=g(()=>{var e,t,n,o;const l=r.monacoOptions?N({},r.monacoOptions):{};if(!v.value)return l;const a=l.diffHideUnchangedRegions===void 0?N({},Ve):Pt(l.diffHideUnchangedRegions),s=l.hideUnchangedRegions===void 0?void 0:Pt(l.hideUnchangedRegions),i=r.stream!==!1&&r.loading!==!1,u=i?N({},pn):a,c=i?N({},pn):s,d=N({},(e=l.experimental)!=null?e:{}),p=(t=l.diffUnchangedRegionStyle)!=null?t:"line-info",h={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,minimap:{enabled:!1},renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,renderSideBySide:(n=l.renderSideBySide)==null||n,diffHideUnchangedRegions:u,useInlineViewWhenSpaceIsLimited:(o=l.useInlineViewWhenSpaceIsLimited)!=null&&o,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:p,diffHunkActionsOnHover:!1,experimental:d};return ke(N(ke(N(N({},h),l),{experimental:d}),c===void 0?{}:{hideUnchangedRegions:c}),{diffHideUnchangedRegions:u})}),hn=g(()=>v.value?"diff":"single"),al=L(hn.value),He=L(!1),A=L(!1),Ne=L(!1),ie=L(!1),re=L(!1);let Ge=null;const ul=g(()=>{var e;const t=(e=r.monacoOptions)==null?void 0:e.wordWrap;return t==null||String(t)!=="off"}),yn=g(()=>{var e,t,n,o,l,a;if(!v.value)return!1;if(((e=W.value)==null?void 0:e.renderSideBySide)===!1)return!0;if(((t=W.value)==null?void 0:t.useInlineViewWhenSpaceIsLimited)!==!0)return!1;const s=(n=W.value)==null?void 0:n.renderSideBySideInlineBreakpoint,i=typeof s=="number"&&Number.isFinite(s)?s:900,u=((l=(o=he.value)==null?void 0:o.getBoundingClientRect)==null?void 0:l.call(o).width)||((a=he.value)==null?void 0:a.clientWidth)||(typeof window>"u"?0:window.innerWidth);return u>0&&u<=i});function gn(e){return J?.value===!0||!!e&&(!!e.closest('[data-markstream-virtual-timeline="1"], .markstream-virtual-timeline')||!!e.closest(".vue-recycle-scroller, [data-virtualizer], [data-virtual-scroll-root]"))}const wn=g(()=>gn(he.value)),we=g(()=>!He.value&&(!!Ne.value||(v.value||wn.value||!Kl())&&!A.value)),bn=g(()=>we.value||ie.value),sl=g(()=>we.value&&!ie.value),dl=g(()=>!He.value&&!Ne.value&&(we.value||ie.value||re.value)),at=L(!1),Sn=g(()=>v.value&&r.node.diff!==!0?ke(N({},r.node),{diff:!0}):r.node);typeof window<"u"&&H(null,null,function*(){try{const e=yield no();if($)return;if(!e)return void(He.value=!0);const t=e.useMonaco,n=e.detectLanguage;if(typeof n=="function"&&(vn=n),typeof t=="function"){const o=Ke();if(o&&r.themes&&Array.isArray(r.themes)&&!r.themes.includes(o))throw new Error("Preferred theme not in provided themes array");ve=Un();const l=t(ve);ee=l.createEditor||ee,ot=l.createDiffEditor||ot,it=l.updateCode||it,rt=l.updateDiff||rt,je=l.getEditor||je,Y=l.getEditorView||Y,T=l.getDiffEditorView||T,kt=l.cleanupEditor||kt,Ue=l.safeClean||l.cleanupEditor||Ue,xt=l.refreshDiffPresentation||xt,Ct=l.setTheme||Ct,Ie.value=!0,!$&&S.value&&(yield Te(S.value))}}catch{if($)return;He.value=!0}});const Q=L(typeof((B=r.monacoOptions)==null?void 0:B.fontSize)=="number"?r.monacoOptions.fontSize:Number.NaN),F=L(Q.value),Et=L(null),ut=L(null),cl=g(()=>{const e=Q.value,t=F.value;return typeof e=="number"&&Number.isFinite(e)&&e>0&&typeof t=="number"&&Number.isFinite(t)&&t>0}),Lt=g(()=>{var e;const t=Et.value;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t;const n=(e=r.monacoOptions)==null?void 0:e.fontSize;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n;const o=F.value;return typeof o=="number"&&Number.isFinite(o)&&o>0?o:12}),kn=g(()=>{var e;const t=ut.value;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t;const n=(e=r.monacoOptions)==null?void 0:e.lineHeight;return typeof n=="number"&&Number.isFinite(n)&&n>0?n:Lt.value===12?18:Math.max(12,Math.round(1.5*Lt.value))}),Ot=g(()=>kn.value);function xn(e){const t=String(e??"");return t?Math.max(1,t.split(/\r\n|\n|\r/).length):1}function Ft(e){return e.startsWith("-")&&!e.startsWith("---")}function $t(e){return e.startsWith("+")&&!e.startsWith("+++")}const vl=g(()=>yn.value?(function(){var e,t,n;const o=String((e=r.node.code)!=null?e:"").split(/\r\n|\n|\r/);if(o.some(h=>Ft(h)||$t(h)))return Math.max(1,o.length);const l=String((t=r.node.originalCode)!=null?t:"").split(/\r\n|\n|\r/),a=String((n=r.node.updatedCode)!=null?n:"").split(/\r\n|\n|\r/);let s=0,i=l.length-1,u=a.length-1;for(;s<=i&&s<=u&&l[s]===a[s];)s++;let c=0;for(;i>=s&&u>=s&&l[i]===a[u];)c++,i--,u--;const d=Math.max(0,i-s+1),p=Math.max(0,u-s+1);return Math.max(1,s+d+p+c)})():(function(){var e;const t=String((e=r.node.code)!=null?e:"").split(/\r\n|\n|\r/);if(!t.some(l=>Ft(l)||$t(l))&&(r.node.originalCode!=null||r.node.updatedCode!=null))return Math.max(xn(r.node.originalCode),xn(r.node.updatedCode));let n=0,o=0;for(const l of t)Ft(l)?n++:($t(l)||n++,o++);return Math.max(1,n,o)})()),fl=g(()=>{var e;const t=(e=r.monacoOptions)==null?void 0:e.tabSize;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:4}),Ht=g(()=>{var e;const t=(e=r.monacoOptions)==null?void 0:e.padding;return{top:typeof t?.top=="number"&&Number.isFinite(t.top)&&t.top>0?t.top:0,bottom:typeof t?.bottom=="number"&&Number.isFinite(t.bottom)&&t.bottom>0?t.bottom:0}}),st=g(()=>{const e=r.estimatedContentHeightPx;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null});function dt(e){if(e==null)return null;const t=Math.ceil(e);return!Number.isFinite(t)||t<=0?null:Math.min(t,Math.ceil(Ze()))}const Ye=g(()=>v.value?Math.ceil(vl.value*Ot.value):st.value!=null?null:Math.ceil((e=>{const t=String(e??"");return t?Math.max(1,t.split(/\r\n|\n|\r/).length):1})(r.node.code)*(kn.value+yt)+1)),Nt=g(()=>{if(v.value){const t=Ye.value,n=Rt();return dt(n!=null&&t!=null?Math.max(t,n):n??t)}const e=st.value;return dt(e??Ye.value)}),ml=g(()=>{const e=r.estimatedHeightPx;return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}),zt=L(null),Tt=L(null);function be(){const e=zt.value;return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):null}function Dt(){return v.value&&r.stream!==!1&&(r.loading!==!1||we.value||ie.value||re.value)}function Rt(){if(!Dt())return null;const e=Tt.value;return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):null}function Cn(e){if(!Dt()||e==null)return;const t=Math.min(Math.ceil(e),Math.ceil(Ze()));if(!Number.isFinite(t)||t<=0)return;const n=Rt();Tt.value=n==null?t:Math.max(n,t)}const _t=g(()=>{const e=be();return e??(we.value||!A.value?Nt.value:null)}),pl=g(()=>{var e;const t=(e=r.monacoOptions)==null?void 0:e.fontFamily,n=dt(st.value),o=dt(Ye.value),l=N(N({fontSize:`${Lt.value}px`,lineHeight:`${Ot.value}px`,tabSize:fl.value,boxSizing:"border-box",maxHeight:`${Ze()}px`,overflow:"auto",paddingTop:`${Ht.value.top}px`,paddingBottom:`${Ht.value.bottom}px`},v.value?(function(a){if(a==null)return{};const s=Math.ceil(a),i=Math.ceil(Ze()),u=Math.min(s,i);return s>=i?{height:`${u}px`,minHeight:`${u}px`}:{minHeight:`${s}px`}})(Nt.value):n!=null?{height:`${n}px`,minHeight:`${n}px`}:o!=null?{minHeight:`${o}px`}:{}),typeof t=="string"&&t.trim()?{"--markstream-code-font-family":t.trim()}:{});return l["--markstream-pre-line-number-top"]=`${Ht.value.top}px`,l["--markstream-code-padding-left"]="62px",l["--markstream-pre-line-number-width"]="36px",l["--markstream-pre-line-number-gap"]="0px",v.value&&(l["--markstream-pre-diff-line-height"]=`${Ot.value}px`),l}),Mn=g(()=>_t.value!=null&&(!A.value||be()!=null)),hl=g(()=>{const e=_t.value;if(e==null)return null;if(v.value)return Math.ceil(e);const t=ml.value,n=st.value;if(t==null||n==null)return Math.ceil(e);const o=Math.max(0,Math.ceil(t)-Math.ceil(n));return Math.ceil(e+o)}),yl=g(()=>{if(v.value&&we.value)return;const e=_t.value;return Mn.value&&e!=null?{minHeight:`${e}px`}:void 0});function Wt(){Ge!=null&&typeof window<"u"&&window.clearTimeout(Ge),Ge=null}function Pn(){if(!v.value||!le.value||!A.value||ie.value||re.value)return!1;const e=S.value;return!!e&&Hn(e)}function Bn(e,t=!1,n={}){const o=Math.ceil(e),l=be();if(l==null)return o;const a=n.allowBelowEstimatedFloor===!0||Pn();return o>=l||a?((t||a)&&le.value&&(zt.value=null),o):l}function fe(){return new Promise(e=>{V(()=>e())})}function En(){try{const e=S.value;if(!e)return null;const t=e.querySelector(".view-lines .view-line");if(t){const n=Math.ceil(t.getBoundingClientRect().height);if(n>0)return n}}catch{}return null}function At(){var e,t,n,o,l;try{const a=v.value?(n=(t=(e=T())==null?void 0:e.getModifiedEditor)==null?void 0:t.call(e))!=null?n:T():Y(),s=je(),i=(o=s?.EditorOption)==null?void 0:o.fontInfo;if(a&&i!=null){const u=(l=a.getOption)==null?void 0:l.call(a,i),c=u?.fontSize;if(typeof c=="number"&&Number.isFinite(c)&&c>0)return c}}catch{}try{const a=S.value;if(a){const s=a.querySelector(".view-lines .view-line");if(s)try{if(typeof window<"u"&&typeof window.getComputedStyle=="function"){const i=window.getComputedStyle(s).fontSize,u=i&&i.match(/^(\d+(?:\.\d+)?)/);if(u)return Number.parseFloat(u[1])}}catch{}}}catch{}return null}function ze(e){var t,n;try{const a=je(),s=(t=a?.EditorOption)==null?void 0:t.lineHeight;if(s!=null){const i=(n=e?.getOption)==null?void 0:n.call(e,s);if(typeof i=="number"&&i>0)return i}}catch{}const o=En();if(o&&o>0)return o;const l=Number.isFinite(F.value)&&F.value>0?F.value:14;return Math.max(12,Math.round(1.35*l))}function Ln(e){var t,n,o;try{const i=je(),u=(t=i?.EditorOption)==null?void 0:t.padding;if(u!=null){const c=(n=e?.getOption)==null?void 0:n.call(e,u),d=typeof c?.top=="number"?c.top:0,p=typeof c?.bottom=="number"?c.bottom:0;if(d>0||p>0)return d+p}}catch{}const l=(o=W.value)==null?void 0:o.padding,a=typeof l?.top=="number"?l.top:0,s=typeof l?.bottom=="number"?l.bottom:0;return a>0||s>0?a+s:v.value?24:0}function On(e,t){return typeof e!="number"||typeof t!="number"||e<1||t<e?0:t-e+1}function Fn(e){if(!e)return[];const t=e.split(/\r?\n/);return t.length===1&&t[0]===""?[]:t}function It(){var e,t;v.value?Pe.value=(function(n,o){const l=Fn(n),a=Fn(o);let s=0,i=l.length-1,u=a.length-1;for(;s<=i&&s<=u&&l[s]===a[s];)s++;for(;i>=s&&u>=s&&l[i]===a[u];)i--,u--;return{removed:Math.max(0,i-s+1),added:Math.max(0,u-s+1)}})(String((e=r.node.originalCode)!=null?e:""),String((t=r.node.updatedCode)!=null?t:"")):Pe.value={removed:0,added:0}}function Be(){var e;if(v.value)try{const t=T(),n=(e=t?.getLineChanges)==null?void 0:e.call(t);if(!Array.isArray(n))return void It();let o=0,l=0;for(const a of n)o+=On(a.originalStartLineNumber,a.originalEndLineNumber),l+=On(a.modifiedStartLineNumber,a.modifiedEndLineNumber);Pe.value={removed:o,added:l}}catch{It()}else Pe.value={removed:0,added:0}}function qt(){var e;if(Number.isFinite(F.value)&&F.value>0&&Number.isFinite(Q.value))return F.value;const t=At();return typeof((e=r.monacoOptions)==null?void 0:e.fontSize)=="number"?(Q.value=r.monacoOptions.fontSize,F.value=r.monacoOptions.fontSize,F.value):t&&t>0?(Q.value=t,F.value=t,t):(Q.value=12,F.value=12,12)}function gl(){const e=qt(),t=Math.min(36,e+1);F.value=t}function wl(){const e=qt(),t=Math.max(10,e-1);F.value=t}function bl(){qt(),Number.isFinite(Q.value)&&(F.value=Q.value)}function $n(){var e,t,n,o,l,a,s,i,u,c,d,p,h,y;try{const f=v.value?T():null,m=v.value?f:Y();if(!m)return null;if(f?.getOriginalEditor&&f?.getModifiedEditor){const k=(e=f.getOriginalEditor)==null?void 0:e.call(f),w=(t=f.getModifiedEditor)==null?void 0:t.call(f);(n=k?.layout)==null||n.call(k),(o=w?.layout)==null||o.call(w);const M=((l=k?.getContentHeight)==null?void 0:l.call(k))||0,R=((a=w?.getContentHeight)==null?void 0:a.call(w))||0,j=Math.max(M,R);if(j>0)return Math.ceil(j+1);const Z=((u=(i=(s=k?.getModel)==null?void 0:s.call(k))==null?void 0:i.getLineCount)==null?void 0:u.call(i))||1,te=((p=(d=(c=w?.getModel)==null?void 0:c.call(w))==null?void 0:d.getLineCount)==null?void 0:p.call(d))||1,Se=Math.max(Z,te),Kt=Math.max(ze(k),ze(w));return Math.ceil(Se*(Kt+yt)+0+1)}if(m?.getContentHeight){(h=m?.layout)==null||h.call(m);const k=m.getContentHeight();if(k>0)return Math.ceil(k+1)}const x=(y=m?.getModel)==null?void 0:y.call(m);let O=1;x&&typeof x.getLineCount=="function"&&(O=x.getLineCount());const D=ze(m);return Math.ceil(O*(D+yt)+0+1)}catch{return null}}function Hn(e){if(typeof window>"u")return!1;const t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return!1;const n=e.querySelectorAll(".editor.modified .diff-hidden-lines .center, .stream-monaco-diff-unchanged-bridge");for(const o of Array.from(n)){if(!(o instanceof HTMLElement))continue;const l=window.getComputedStyle(o);if(l.display==="none"||l.visibility==="hidden"||Number.parseFloat(l.opacity||"1")<=.01)continue;const a=o.getBoundingClientRect();if(!(a.width<=0||a.height<=0||a.bottom<=t.top||a.top>=t.bottom))return!0}return!1}function jt(e){var t;const n=String(e??"").trim(),o=(t=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))==null?void 0:t[1];if(o){const u=o.length===3?o.split("").map(c=>`${c}${c}`).join(""):o;return .2126*Number.parseInt(u.slice(0,2),16)+.7152*Number.parseInt(u.slice(2,4),16)+.0722*Number.parseInt(u.slice(4,6),16)}const l=n.match(/\d+(?:\.\d+)?/g);if(!l||l.length<3)return null;const[a,s,i]=l.slice(0,3).map(Number);return .2126*a+.7152*s+.0722*i}function Nn(){var e;const t=(e=S.value)==null?void 0:e.parentElement;return t instanceof HTMLElement?t:null}function Qe(e,t){var n;t==null||!Number.isFinite(t)||t<=0||(n=Nn())==null||n.style.setProperty(e,`${t}px`)}function ct(){var e,t,n;if(zn())return;const o=At();o&&o>0&&(Et.value=o,F.value=o,Q.value=o);try{const l=ze(v.value?(n=(t=(e=T())==null?void 0:e.getModifiedEditor)==null?void 0:t.call(e))!=null?n:T():Y());l&&l>0&&(ut.value=l)}catch{}try{const l=En();l&&l>0&&(ut.value=l)}catch{}}function zn(){return v.value&&bn.value}function Ut(){var e,t,n,o,l,a,s,i;const u=S.value,c=he.value;if(!u||!c)return;const d=u,p=u.querySelector(".monaco-editor")||u,h=p.querySelector(".monaco-editor-background")||p,y=p.querySelector(".view-lines")||p;let f=null,m=null,x=null;try{typeof window<"u"&&typeof window.getComputedStyle=="function"&&(f=window.getComputedStyle(p),m=h===p?f:window.getComputedStyle(h),x=y===p?f:window.getComputedStyle(y))}catch{f=null,m=null,x=null}const O=String((e=f?.getPropertyValue("--vscode-editor-foreground"))!=null?e:"").trim(),D=String((t=f?.getPropertyValue("--vscode-editor-background"))!=null?t:"").trim(),k=String((o=(n=f?.getPropertyValue("--vscode-editor-selectionBackground"))!=null?n:f?.getPropertyValue("--vscode-editor-hoverHighlightBackground"))!=null?o:"").trim(),w=O||String((a=(l=x?.color)!=null?l:f?.color)!=null?a:"").trim(),M=D||String((i=(s=m?.backgroundColor)!=null?s:f?.backgroundColor)!=null?i:"").trim();return v.value?(w?(c.style.setProperty("--markstream-diff-editor-fg",w),d.style.setProperty("--vscode-editor-foreground",w),d.style.setProperty("--stream-monaco-editor-fg",w)):(c.style.removeProperty("--markstream-diff-editor-fg"),d.style.removeProperty("--vscode-editor-foreground"),d.style.removeProperty("--stream-monaco-editor-fg")),M?(c.style.setProperty("--markstream-diff-editor-bg",M),c.style.setProperty("--markstream-diff-panel-bg",M),c.style.setProperty("--markstream-diff-panel-bg-soft",M),c.style.setProperty("--markstream-diff-panel-bg-strong",M),d.style.setProperty("--vscode-editor-background",M),d.style.setProperty("--stream-monaco-editor-bg",M),d.style.setProperty("--stream-monaco-fixed-editor-bg",M),d.style.setProperty("--stream-monaco-panel-bg",M),d.style.setProperty("--stream-monaco-panel-bg-soft",M),d.style.setProperty("--stream-monaco-panel-bg-strong",M),d.style.backgroundColor=M):(c.style.removeProperty("--markstream-diff-editor-bg"),c.style.removeProperty("--markstream-diff-panel-bg"),c.style.removeProperty("--markstream-diff-panel-bg-soft"),c.style.removeProperty("--markstream-diff-panel-bg-strong"),d.style.removeProperty("--vscode-editor-background"),d.style.removeProperty("--stream-monaco-editor-bg"),d.style.removeProperty("--stream-monaco-fixed-editor-bg"),d.style.removeProperty("--stream-monaco-panel-bg"),d.style.removeProperty("--stream-monaco-panel-bg-soft"),d.style.removeProperty("--stream-monaco-panel-bg-strong"),d.style.backgroundColor=""),void(k?d.style.setProperty("--vscode-editor-selectionBackground",k):d.style.removeProperty("--vscode-editor-selectionBackground"))):(function(R,j,Z){if(!cn.value)return!1;const te=jt(R),Se=jt(j);return Z?te!=null&&te>170||Se!=null&&Se<110:te!=null&&te<85||Se!=null&&Se>190})(M,w,c.classList.contains("is-dark"))?(d.style.removeProperty("--vscode-editor-foreground"),d.style.removeProperty("--vscode-editor-background"),void d.style.removeProperty("--vscode-editor-selectionBackground")):(w&&d.style.setProperty("--vscode-editor-foreground",w),M&&d.style.setProperty("--vscode-editor-background",M),void(k&&d.style.setProperty("--vscode-editor-selectionBackground",k)))}let Vt=0,Jt=0;const Tn=/auto|scroll|overlay/i;function me(e,t,n){var o;if(typeof window>"u"||v.value||(function(d){return wn.value||gn(d)})(e))return;const l=Math.ceil(t),a=Math.ceil(n)-l;if(Math.abs(a)<=1)return;const s=(function(d){var p,h;if(typeof window>"u")return null;const y=(p=d?.ownerDocument)!=null?p:document,f=y.scrollingElement||y.documentElement||y.body;let m=(h=d?.parentElement)!=null?h:null;for(;m&&m!==y.body&&m!==f;){const x=window.getComputedStyle(m),O=(x.overflowY||"").toLowerCase(),D=(x.overflow||"").toLowerCase();if(Tn.test(O)||Tn.test(D))return m;m=m.parentElement}return f})(e);if(!s)return;const i=(o=e.ownerDocument)!=null?o:document,u=s===i.body||s===i.documentElement||s===i.scrollingElement,c=u?0:s.getBoundingClientRect().top;e.getBoundingClientRect().top-c>=0||(u&&typeof window.scrollBy=="function"?window.scrollBy(0,a):s.scrollTop+=a)}function Gt(){try{const e=S.value;if(!e)return;const t=e.getBoundingClientRect().height,n=$n();if(n!=null&&n>0){const l=Bn(n,!0),a=be();return e.style.minHeight=a!=null?`${a}px`:"0px",e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",void me(e,t,l)}const o=be();o!=null&&(e.style.minHeight=`${o}px`,e.style.height=`${o}px`,e.style.maxHeight="none",e.style.overflow="visible",me(e,t,o))}catch{}}function Xe(){for(var e,t;Fe.length>0;)try{(t=(e=Fe.pop())==null?void 0:e.dispose)==null||t.call(e)}catch{}Oe!=null&&(eo(Oe),Oe=null)}function Ee(){for(var e;Mt.length>0;)try{(e=Mt.pop())==null||e()}catch{}}function I(e=!1){ye.value||(se.value?Gt():(function(){var t;try{const n=S.value;if(!n)return;const o=n.getBoundingClientRect().height,l=Ze(),a=Math.ceil(((t=n.getBoundingClientRect)==null?void 0:t.call(n).height)||0),s=v.value?(function(){var f,m,x,O,D,k,w,M;try{const R=T(),j=(f=R?.getOriginalEditor)==null?void 0:f.call(R),Z=(m=R?.getModifiedEditor)==null?void 0:m.call(R);if(!j||!Z)return null;const te=((D=(O=(x=j.getModel)==null?void 0:x.call(j))==null?void 0:O.getLineCount)==null?void 0:D.call(O))||1,Se=((M=(w=(k=Z.getModel)==null?void 0:k.call(Z))==null?void 0:w.getLineCount)==null?void 0:M.call(w))||1,Kt=Math.max(te,Se),Fl=Math.max(ze(j),ze(Z)),$l=Math.max(Ln(j),Ln(Z));return Math.ceil(Kt*(Fl+yt)+$l+0+1)}catch{return null}})():null,i=v.value&&Hn(n),u=i&&le.value&&A.value&&!ie.value&&!re.value;if(i||(Me.value=null),St>0&&(St--,Ce.value!=null))return void me(n,o,Le(n,Ce.value,l,{allowBelowEstimatedFloor:u}));const c=v.value?(function(f){var m,x;if(typeof window>"u")return null;try{const O=f.getBoundingClientRect(),D=window.getComputedStyle(f);if(D.display==="none"||D.visibility==="hidden")return null;const k=[".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 w=0;for(const j of Array.from(f.querySelectorAll(k.join(",")))){if(!(j instanceof HTMLElement))continue;const Z=window.getComputedStyle(j);if(Z.display==="none"||Z.visibility==="hidden"||Number.parseFloat(Z.opacity||"1")<=.01)continue;const te=j.getBoundingClientRect();te.height<=0||te.bottom<=O.top||(w=Math.max(w,te.bottom-O.top))}if(w>0)return Math.ceil(w);const M=f.querySelector(".monaco-diff-editor"),R=(x=(m=M?.getBoundingClientRect)==null?void 0:m.call(M).height)!=null?x:0;return R>0?Math.ceil(R+1):null}catch{return null}})(n):null,d=v.value?i?c:s!=null?Math.max(c??0,s):c:$n();if(d!=null&&d>0){const f=Me.value!=null&&Date.now()<lt&&d>=l-1,m=i&&a>0&&a<l-1&&d>=l-1,x=Le(n,f?Me.value:m?a:d,l,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:u});return i&&x<l-1&&(Me.value=x,lt=Date.now()+160),void me(n,o,x)}if(Ce.value!=null)return void me(n,o,Le(n,Ce.value,l,{allowBelowEstimatedFloor:u}));const p=i?a:Math.max(a,s!=null&&s>0?s:0);if(p>0){const f=Me.value!=null&&Date.now()<lt&&p>=l-1,m=i&&a>0&&a<l-1&&p>=l-1,x=Le(n,f?Me.value:m?a:p,l,{allowBelowEstimatedFloor:u});return i&&x<l-1&&(Me.value=x,lt=Date.now()+160),void me(n,o,x)}const h=be();if(h!=null)return void me(n,o,Le(n,h,l,{allowBelowEstimatedFloor:u}));const y=Number.parseFloat(n.style.height);!Number.isNaN(y)&&y>0?me(n,o,Le(n,y,l,{allowBelowEstimatedFloor:u})):v.value||me(n,o,Le(n,l,l))}catch{}})())}function Dn(){Vt=0,Jt=0}function vt(e=!1){var t,n,o;const l=S.value;if(!l)return;const a=v.value?T():Y();if(a&&typeof a.layout=="function")try{const s=(t=l.getBoundingClientRect)==null?void 0:t.call(l),i=Math.ceil(((n=s?.width)!=null?n:0)||l.clientWidth||0),u=Math.ceil(((o=s?.height)!=null?o:0)||l.clientHeight||Number.parseFloat(l.style.height||"")||0);if(i>0&&u>0){if(!e&&i===Vt&&u===Jt)return;Vt=i,Jt=u,a.layout({width:i,height:u})}else Dn(),a.layout()}catch{}}function X(){if(!v.value)return void Ee();const e=S.value;if(!e)return void Ee();const t=e.querySelector(".monaco-diff-editor");if(!t||t.classList.contains("side-by-side"))return void Ee();const n=Array.from(t.querySelectorAll(".editor.original .diff-hidden-lines")),o=Array.from(t.querySelectorAll(".editor.modified .diff-hidden-lines")),l=Math.min(n.length,o.length);for(let a=0;a<l;a++){const s=o[a],i=s.querySelector("a"),u=s.querySelector(".center > div:first-child"),c=s.querySelector(".center");if(!i||!u||!c||c.querySelector(".markstream-inline-fold-proxy"))continue;const d=document.createElement("button");d.type="button",d.className="markstream-inline-fold-proxy",d.dataset.markstreamInlineFoldProxy="true";const p=i.getAttribute("title")||"Show Unchanged Region";d.title=p,d.setAttribute("aria-label",p);const h=m=>{m.preventDefault(),m.stopPropagation()},y=m=>{m.preventDefault(),m.stopPropagation(),i.click(),V(()=>q())},f=m=>{m.key!=="Enter"&&m.key!==" "||(m.preventDefault(),m.stopPropagation(),i.click(),V(()=>q()))};d.addEventListener("mousedown",h),d.addEventListener("click",y),d.addEventListener("keydown",f),c.appendChild(d),Mt.push(()=>{d.removeEventListener("mousedown",h),d.removeEventListener("click",y),d.removeEventListener("keydown",f),d.parentElement===c&&c.removeChild(d)})}}function q(e=!1){Oe==null&&(Oe=V(()=>{Oe=null,V(()=>{X(),I(e),vt()})}))}function Le(e,t,n,o={}){Cn(t);const l=Rt(),a=l!=null?Math.max(t,l):t,s=Math.min(a,n),i=o.allowBelowEstimatedFloor===!0||Pn(),u=Bn(s,o.clearEstimatedFloor===!0,{allowBelowEstimatedFloor:i}),c=be();if(e.style.minHeight=c==null||i?"0px":`${Math.min(c,Math.ceil(n))}px`,e.style.height=`${u}px`,e.style.maxHeight=`${Math.ceil(n)}px`,v.value)e.style.overflow="hidden";else{const d=a>n+1;e.style.overflow=d?"auto":"hidden"}return u}function Rn(e,t,n){return H(this,null,function*(){try{return void(yield rt(e,t,n))}catch(o){if(!Je(o))throw o}if(yield ne(),yield fe(),!$&&v.value)try{yield rt(e,t,n)}catch(o){if(!Je(o))throw o}})}function Ze(){var e,t;const n=(t=(e=r.monacoOptions)==null?void 0:e.MAX_HEIGHT)!=null?t:500;if(typeof n=="number")return n;const o=String(n).match(/^(\d+(?:\.\d+)?)/);return o?Number.parseFloat(o[1]):500}const Yt=g(()=>r.isShowPreview&&(ue.value==="html"||ue.value==="svg"));U(()=>r.node.language,e=>{ue.value=en(e)}),U(()=>[r.node.originalCode,r.node.updatedCode,v.value],()=>{It(),V(()=>Be())},{immediate:!0}),U(()=>[v.value,r.stream,r.loading,we.value,ie.value,re.value,Ye.value],()=>{Dt()?Cn(Ye.value):Tt.value=null},{immediate:!0}),U(()=>[r.node.originalCode,r.node.updatedCode,de.value,v.value],e=>H(null,[e],function*([t,n,o,l]){if(r.stream===!1||!l)return;if(ee&&!K.value&&S.value)try{yield Te(S.value)}catch{}const a=Bt(String(t??""),String(n??"")),s=r.loading===!1;s&&Re();try{yield Rn(a.original,a.updated,de.value),vt(!0)}catch{return}if(s){if($||!v.value)return;$e(),X(),Be(),q()}se.value&&V(()=>Gt())})),U(()=>r.node.code,e=>H(null,null,function*(){if(r.stream!==!1&&(ue.value||(ue.value=en(vn(e))),!v.value)){if(ee&&!K.value&&S.value)try{yield Te(S.value)}catch{}it(e,de.value),se.value&&V(()=>Gt())}}));const Qt=g(()=>{const e=ue.value;return e?Yn[e]||e.charAt(0).toUpperCase()+e.slice(1):Yn[""]});function _n(e){var t,n;const o=(n=(t=String(e??"").split(/\r?\n/,1)[0])==null?void 0:t.trim())!=null?n:"";if(o.length<3)return"";const l=o[0];if(l!=="`"&&l!=="~"||o[1]!==l||o[2]!==l)return"";let a=3;for(;o[a]===l;)a+=1;return o.slice(a).trim()}const Wn=g(()=>{var e;return(function(t){const n=_n(t);if(!n)return"";const o=n.split(/\s+/).filter(Boolean);if(!o.length)return"";const l=o[0]==="diff"?o.slice(1):o;for(const a of l){const s=a.includes(":")?a.slice(a.indexOf(":")+1):a;if(s&&/[./\\-]/.test(s))return s}return""})(String((e=r.node.raw)!=null?e:""))}),Sl=g(()=>Wn.value||Qt.value),An=g(()=>Wn.value?v.value?`Diff / ${Qt.value}`:Qt.value:""),kl=g(()=>(Ul.value,Vl(ue.value||""))),xl=g(()=>{const e={},t=l=>{if(l!=null)return typeof l=="number"?`${l}px`:String(l)},n=t(r.minWidth),o=t(r.maxWidth);if(n&&(e.minWidth=n),o&&(e.maxWidth=o),Mn.value&&!v.value){const l=hl.value;l!=null&&(e.minHeight=`${l}px`)}return v.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}),In=g(()=>r.showTooltips!==!1);function Cl(){return H(this,null,function*(){try{typeof navigator<"u"&&navigator.clipboard&&typeof navigator.clipboard.writeText=="function"&&(yield navigator.clipboard.writeText(r.node.code)),bt.value=!0,ae("copy",r.node.code),setTimeout(()=>{bt.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function Ml(e){if(se.value=!se.value,e&&In.value){const o=(function(l){const a=l.currentTarget||l.target;return!a||a.disabled?null:a})(e);if(o){const l=se.value?G("common.collapse")||"Collapse":G("common.expand")||"Expand";Jl(o,l,"top",!1,void 0,r.isDark)}}const t=v.value?T():Y(),n=S.value;t&&n&&(se.value?(ft(!0),n.style.maxHeight="none",n.style.overflow="visible",I(!0)):(ft(!1),n.style.overflow=v.value?"hidden":"auto",I(!0)))}function Pl(){var e,t,n;if(ye.value=!ye.value,ye.value){if(S.value){const o=Math.ceil(((t=(e=S.value).getBoundingClientRect)==null?void 0:t.call(e).height)||0);o>0&&(Ce.value=o)}ft(!1)}else{se.value&&ft(!0),S.value&&Ce.value!=null&&(S.value.style.height=`${Ce.value}px`);const o=v.value?T():Y();try{(n=o?.layout)==null||n.call(o)}catch{}St=2,V(()=>{I(!0)})}}function Bl(){if(!Yt.value)return;const e=ue.value;if(pe.value){const t=e==="html"?"text/html":"image/svg+xml",n=e==="html"?G("artifacts.htmlPreviewTitle")||"HTML Preview":G("artifacts.svgPreviewTitle")||"SVG Preview";return void ae("previewCode",{node:r.node,artifactType:t,artifactTitle:n,id:`temp-${e}-${Date.now()}`})}e==="html"&&(at.value=!at.value)}function ft(e){var t,n;try{if(v.value){const o=T();(t=o?.updateOptions)==null||t.call(o,{automaticLayout:e})}else{const o=Y();(n=o?.updateOptions)==null||n.call(o,{automaticLayout:e})}}catch{}}function Te(e){if(!ee||$)return null;if(ce)return ce;if(K.value&&le.value)return Promise.resolve();K.value=!0,(function(){const n=C.value;_&&n&&ge!==n&&(ge&&_.markSettled(ge),ge=n,_.markPending(n))})();const t=H(null,null,function*(){yield(function(n){return H(this,null,function*(){var o;if(typeof window>"u")return yield n();try{const l=(o=window.Element)==null?void 0:o.prototype,a=l?.addEventListener;if(!l||!a)return yield n();const s=(function(){const i=window,u=i[el];if(u)return u;const c={depth:0,original:null};return i[el]=c,c})();s.depth===0&&(s.original=a,l.addEventListener=function(i,u,c){var d;const p=(d=s.original)!=null?d:a;return i==="touchstart"&&(function(h,y){if(!h)return!1;const f=h;return!(typeof f.closest!="function"||!f.closest(".monaco-editor, .monaco-diff-editor")||y&&typeof y=="object"&&"passive"in y)})(this,c)?p.call(this,i,u,(function(h){return h==null?{passive:!0}:typeof h=="boolean"?{capture:h,passive:!0}:typeof h=="object"?"passive"in h?h:ke(N({},h),{passive:!0}):{passive:!0}})(c)):p.call(this,i,u,c)}),s.depth++;try{return yield n()}finally{s.depth=Math.max(0,s.depth-1),s.depth===0&&s.original&&l.addEventListener!==s.original&&(l.addEventListener=s.original,s.original=null)}}catch{return yield n()}})})(()=>(function(n){return H(this,null,function*(){var o,l,a;if(!ee||$||(Ne.value=!1,A.value=!1,ie.value=!1,re.value=!1,Wt(),Et.value=null,ut.value=null,(function(){const i=Nn();i&&(i.style.removeProperty("--stream-monaco-line-number-left"),i.style.removeProperty("--stream-monaco-line-number-width"),i.style.removeProperty("--stream-monaco-line-number-gap-to-code"),i.style.removeProperty("--stream-monaco-original-line-number-gap-to-code"),i.style.removeProperty("--stream-monaco-modified-line-number-gap-to-code"),i.style.removeProperty("--stream-monaco-original-scrollable-left"),i.style.removeProperty("--stream-monaco-modified-scrollable-left"))})(),Dn(),(function(){const i=Nt.value;zt.value=le.value||i==null?null:i})(),Xe(),Ee(),(function(i){i.replaceChildren()})(n),$))return;if(v.value){(function(){if(fn||typeof window>"u")return;fn=!0;const u=c=>{var d;Je("reason"in c?c.reason:(d=c.error)!=null?d:c.message)&&(c.preventDefault(),c.stopImmediatePropagation())};window.addEventListener("error",u,!0),window.addEventListener("unhandledrejection",u,!0)})(),Ue();const i=Bt(String((o=r.node.originalCode)!=null?o:""),String((l=r.node.updatedCode)!=null?l:""));ot?yield ot(n,i.original,i.updated,de.value):yield ee(n,r.node.code,de.value)}else yield ee(n,r.node.code,de.value);if($)return;const s=v.value?T():Y();if(typeof((a=r.monacoOptions)==null?void 0:a.fontSize)=="number")s?.updateOptions({fontSize:r.monacoOptions.fontSize,automaticLayout:!1}),Q.value=r.monacoOptions.fontSize,F.value=r.monacoOptions.fontSize;else if(!zn()){const i=At();i&&i>0?(Q.value=i,F.value=i):(Q.value=12,F.value=12)}ct(),se.value||ye.value||I(!1),yield(function(){return H(this,null,function*(){be()!=null&&(X(),I(!1),yield ne(),yield fe(),X(),I(!1),yield fe(),X(),I(!1))})})(),$||(le.value=!0,(function(){var i,u,c,d,p;if(Xe(),v.value){const y=T(),f=(i=y?.getOriginalEditor)==null?void 0:i.call(y),m=(u=y?.getModifiedEditor)==null?void 0:u.call(y),x=(O,D)=>{try{const k=O?.[D];if(typeof k!="function")return;const w=k.call(O,()=>q());w&&Fe.push(w)}catch{}};try{const O=(c=y?.onDidUpdateDiff)==null?void 0:c.call(y,()=>{q(),V(()=>Be())});O&&Fe.push(O)}catch{}return x(f,"onDidContentSizeChange"),x(m,"onDidContentSizeChange"),x(f,"onDidLayoutChange"),void x(m,"onDidLayoutChange")}const h=Y();try{const y=(d=h?.onDidContentSizeChange)==null?void 0:d.call(h,()=>q());y&&Fe.push(y)}catch{}try{const y=(p=h?.onDidLayoutChange)==null?void 0:p.call(h,()=>q());y&&Fe.push(y)}catch{}})(),Ut(),ct(),X(),Be(),q(),yield(function(){return H(this,null,function*(){X(),I(!1),yield ne(),yield fe(),X(),I(!1),yield fe(),X(),I(!1)})})(),yield(function(){return H(this,null,function*(){var i;if(v.value){for(let u=0;u<8;u++){if($)return;const c=S.value,d=T();let p=!1;try{const f=(i=d?.getLineChanges)==null?void 0:i.call(d);p=Array.isArray(f)}catch{p=!1}const h=!!c?.querySelector(".monaco-diff-editor"),y=!!c?.querySelector(".monaco-diff-editor .view-lines .view-line");if(h&&y&&p){if(yield ne(),yield fe(),$)return;try{$e(),X(),Be(),q()}catch{}return}if(u>=1&&!h)return;yield ne(),yield fe()}if(!$)try{$e(),X(),Be(),q()}catch{}}})})(),$||(ct(),(function(){if(!v.value)return;const i=S.value;if(!i)return;const u=i.querySelector(".monaco-diff-editor");function c(d,p,h,y){const f=d.querySelector(p);if(!f)return;const m=f.getBoundingClientRect();if(m.width<=0)return;const x=f.querySelector(".line-numbers"),O=f.querySelector(".view-lines .view-line"),D=f.querySelector(".margin");let k=null;if(O?(k=O.getBoundingClientRect().left-m.left,Qe(h,k)):D&&(k=D.getBoundingClientRect().width,Qe(h,k)),x){const w=x.getBoundingClientRect();if(w.width>=20&&w.width<=64&&Qe("--stream-monaco-line-number-width",w.width),k!=null){const M=k-(w.right-m.left);Number.isFinite(M)&&M>=0&&M<=32&&(Qe(y,M),Qe("--stream-monaco-line-number-gap-to-code",M))}}}u&&(c(u,".editor.original","--stream-monaco-original-scrollable-left","--stream-monaco-original-line-number-gap-to-code"),c(u,".editor.modified","--stream-monaco-modified-scrollable-left","--stream-monaco-modified-line-number-gap-to-code"))})(),yield ne(),(function(){var i;if(!v.value||!we.value)return;const u=S.value,c=(i=he.value)==null?void 0:i.querySelector("pre.code-pre-fallback");if(!u||!c)return;const d=Math.ceil(c.getBoundingClientRect().height);!Number.isFinite(d)||d<=0||(u.style.height=`${d}px`,u.style.minHeight=`${d}px`)})(),yield fe(),yield(function(){return H(this,null,function*(){if(v.value){if(ie.value=!0,re.value=!1,A.value=!0,yield ne(),yield fe(),!$){if(vt(!0),re.value=!0,Wt(),typeof window>"u")return ie.value=!1,void(re.value=!1);Ge=window.setTimeout(()=>{Ge=null,ie.value=!1,re.value=!1,V(()=>{ct(),X(),q()})},120)}}else A.value=!0})})()))})})(e))}).finally(()=>{ce===t&&(ce=null),(function(){const n=ge;_&&n&&(ge="",ne(()=>{var o,l;if(!$){const a=(l=(o=he.value)==null?void 0:o.offsetHeight)!=null?l:0;a>0&&_.reportHeight(n,a)}_.markSettled(n)}))})()});return ce=t,t}U(In,e=>{e||_l()}),U(()=>F.value,(e,t)=>{const n=v.value?T():Y();n&&typeof e=="number"&&Number.isFinite(e)&&e>0&&(n.updateOptions({fontSize:e}),ye.value||I(!0))},{flush:"post",immediate:!1});const El=U(()=>[S.value,v.value,r.stream,r.loading,Ie.value,oe.value],e=>H(null,[e],function*([t,n,o,l,a,s]){if(!t||!ee||!s||o===!1&&l!==!1)return;const i=Te(t);if(i){try{yield i}catch{le.value=!1,A.value=!1,Ne.value=!0}El()}}));function qn(e){return!!e&&typeof e=="object"&&"light"in e&&"dark"in e}function De(e){return typeof e=="string"?e:e&&typeof e=="object"&&"name"in e?String(e.name):null}function jn(e,t){if(e===t)return!0;const n=De(e),o=De(t);return!!n&&n===o}function Ke(){var e;const t=(function(){if(r.theme!==void 0){const u=r.theme;return qn(u)?r.isDark?u.dark:u.light:u}return r.isDark?r.darkTheme:r.lightTheme})(),n=(e=W.value)==null?void 0:e.theme,o=t??n;if(o!=null&&typeof o=="object")return o;const l=Array.isArray(r.themes)?r.themes:[];if(!l.length||o==null)return o;const a=De(o),s=l.map(u=>De(u)).filter(u=>!!u);if(!a||s.includes(a))return o;const i=De(n);return n!=null&&i&&s.includes(i)?n:l[0]}U(hn,(e,t)=>H(null,null,function*(){if(e===t||(al.value=e,!ee||!S.value)||!K.value||r.stream===!1&&r.loading!==!1||!oe.value)return;const n=ce;if(n){try{yield n}catch{}if($||!S.value)return}try{le.value=!1,A.value=!1,K.value=!1,Xe(),Ee(),Ue(),yield ne(),yield Te(S.value)}catch{le.value=!1,A.value=!1,Ne.value=!0}}));const Xt=g(()=>(r.theme!==void 0?!qn(r.theme):jn(r.darkTheme,r.lightTheme))?(function(e){var t,n;if(e&&typeof e=="object"&&((t=e.colors)!=null&&t["editor.background"])){const l=jt(e.colors["editor.background"]);if(l!=null)return l<128}const o=((n=De(e))!=null?n:"").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(l=>o.includes(l))&&!["light","latte","dawn","lotus"].some(l=>o.includes(l)):!!r.isDark})(Ke()):!!r.isDark),Zt=g(()=>{var e;if(!v.value)return Xt.value?"dark":"light";const t=(e=W.value)==null?void 0:e.diffAppearance;return t==="light"||t==="dark"?t:Xt.value?"dark":"light"}),Ll=g(()=>v.value?Zt.value==="dark":Xt.value);function Un(){return ke(N(ke(N({wordWrap:"on",wrappingIndent:"same",themes:r.themes},W.value||{}),{theme:Ke()}),v.value?{diffAppearance:Zt.value}:{}),{onThemeChange(){Ut()}})}function Re(){const e=Un();if(!ve)return ve=e,ve;for(const t of Object.keys(ve))t in e||delete ve[t];return Object.assign(ve,e),ve}const Ol=g(()=>{var e,t,n,o,l,a,s,i,u,c,d,p,h,y,f;return JSON.stringify({diffLineStyle:(t=(e=W.value)==null?void 0:e.diffLineStyle)!=null?t:"background",diffUnchangedRegionStyle:(o=(n=W.value)==null?void 0:n.diffUnchangedRegionStyle)!=null?o:"line-info",diffHideUnchangedRegions:((l=r.monacoOptions)==null?void 0:l.diffHideUnchangedRegions)===void 0?N({},Ve):Pt(r.monacoOptions.diffHideUnchangedRegions),renderSideBySide:(s=(a=W.value)==null?void 0:a.renderSideBySide)==null||s,useInlineViewWhenSpaceIsLimited:(u=(i=W.value)==null?void 0:i.useInlineViewWhenSpaceIsLimited)!=null&&u,enableSplitViewResizing:(d=(c=W.value)==null?void 0:c.enableSplitViewResizing)==null||d,ignoreTrimWhitespace:(h=(p=W.value)==null?void 0:p.ignoreTrimWhitespace)==null||h,originalEditable:(f=(y=W.value)==null?void 0:y.originalEditable)!=null&&f})});return U(()=>[r.monacoOptions,oe.value],()=>{var e,t;if(Re(),!ee||!oe.value)return;const n=v.value?T():Y(),o=typeof((e=r.monacoOptions)==null?void 0:e.fontSize)=="number"?r.monacoOptions.fontSize:Number.isFinite(F.value)?F.value:void 0;typeof o=="number"&&Number.isFinite(o)&&o>0&&((t=n?.updateOptions)==null||t.call(n,{fontSize:o})),I(!1)},{deep:!0}),U(()=>[Ke(),Zt.value,Ie.value,K.value,oe.value],([e],t)=>{Ie.value&&K.value&&oe.value&&(function(n={}){if(n.appearanceOnly)return;Re();const o=Ke(),l=()=>{v.value&&$e(),V(()=>{Ut(),q()})};o?(function(a,s){const i=(function(u){if(u==null)return null;if(typeof u=="string")return u;if(typeof u=="object"&&"name"in u)return String(u.name);if(typeof u=="object"){const c=un.get(u);if(c)return c;try{const p=JSON.stringify(u);if(p)return un.set(u,p),p}catch{}const d="__theme_"+ ++mo;return un.set(u,d),d}return String(u)})(s);return i?(an=a,_e||rn!==i?_e?(We===i||on===i||(nt=s,We=i),_e):(nt=s,We=i,_e=H(null,null,function*(){for(;We&&nt!=null;){const u=nt,c=We;if(nt=null,We=null,rn!==c)try{on=c,yield(an??a)(u),rn=c}catch{}}}).finally(()=>{_e=null,on=null}),_e):Promise.resolve()):Promise.resolve()})(Ct,o).then(l).catch(a=>{}):l()})({appearanceOnly:t!=null&&jn(e,t[0])})},{flush:"post"}),U(()=>[Ol.value,Ie.value,oe.value],(e,t)=>H(null,[e,t],function*([n,o,l],[a]){if(Re(),!o||!l||!ee||!S.value||!K.value||n===a||r.stream===!1&&r.loading!==!1)return;const s=ce;if(s){try{yield s}catch{}if($||!S.value)return}try{le.value=!1,A.value=!1,K.value=!1,Xe(),Ee(),Ue(),yield ne(),yield Te(S.value)}catch{le.value=!1,A.value=!1,Ne.value=!0}}),{flush:"post"}),U(()=>[r.loading,oe.value],(e,t)=>H(null,[e,t],function*([n,o],l){if(!o)return;const a=l?.[0];if(a===!1&&n!==!1&&v.value&&K.value&&(yield ne(),V(()=>{H(null,null,function*(){const i=ce;if(i)try{yield i}catch{}!$&&v.value&&r.loading!==!1&&(Re(),$e(),q())})})),n)return;const s=a!==void 0&&a!==!1;yield ne(),V(()=>{H(null,null,function*(){var i,u,c;try{if(s&&K.value)if(v.value&&S.value){const d=ce;if(d)try{yield d}catch{}Re();const p=Bt(String((i=r.node.originalCode)!=null?i:""),String((u=r.node.updatedCode)!=null?u:""));if(yield Rn(p.original,p.updated,de.value),$||!v.value)return;$e(),vt(!0),X(),Be(),q()}else it(String((c=r.node.code)!=null?c:""),de.value);I(!1)}catch{}})})}),{immediate:!0,flush:"post"}),ol(()=>{Wt(),Xe(),Ee(),kt()}),(e,t)=>He.value?(Ae(),gt(sn(Jn),{key:0,node:Sn.value,loading:r.loading},null,8,["node","loading"])):(Ae(),Gn("div",{key:1,ref_key:"container",ref:he,style:nn(xl.value),class:wt(["code-block-container rounded-lg border",[{dark:r.isDark,"is-rendering":r.loading,"is-dark":Ll.value,"is-diff":v.value,"is-plain-text":cn.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":A.value&&!He.value?"true":"false","data-markstream-pending":dl.value?"true":void 0},[Wl(to,{"show-header":r.showHeader,"show-collapse-button":r.showCollapseButton,"show-font-size-buttons":r.showFontSizeButtons,"enable-font-size-control":r.enableFontSizeControl,"show-copy-button":r.showCopyButton,"show-expand-button":r.showExpandButton,"show-preview-button":r.showPreviewButton,"show-tooltips":r.showTooltips,"is-dark":r.isDark,loading:r.loading,stream:P.stream,"is-collapsed":ye.value,"is-expanded":se.value,"copy-text":bt.value,"is-previewable":Yt.value,"code-font-size":F.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":Q.value,"font-baseline-ready":cl.value,"diff-stats":v.value?Pe.value:null,"diff-stats-aria-label":rl.value,onToggleCollapse:Pl,onDecreaseFont:wl,onResetFont:bl,onIncreaseFont:gl,onCopy:Cl,onToggleExpand:Ml,onPreview:Bl},Al({"header-left":mt(()=>[tn(e.$slots,"header-left",{},()=>[z("div",ho,[z("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:kl.value},null,8,yo),z("div",go,[z("div",wo,dn(Sl.value),1),An.value?(Ae(),Gn("div",bo,dn(An.value),1)):ln("",!0)])])],!0)]),loading:mt(()=>[tn(e.$slots,"loading",{loading:P.loading,stream:P.stream},()=>[t[0]||(t[0]=z("div",{class:"loading-skeleton"},[z("div",{class:"skeleton-line"}),z("div",{class:"skeleton-line"}),z("div",{class:"skeleton-line short"})],-1))],!0)]),default:mt(()=>[Il(z("div",So,[z("div",{ref_key:"codeEditor",ref:S,class:wt(["code-editor-container",[P.stream?"":"code-height-placeholder",{"is-hidden":sl.value}]]),style:nn(yl.value)},null,6),bn.value?(Ae(),gt(sn(Jn),{key:0,class:wt(["code-pre-fallback",{"is-wrap":ul.value,"is-fading-out":re.value}]),style:nn(pl.value),node:Sn.value,"show-line-numbers":!0,"diff-inline":yn.value},null,8,["class","style","node","diff-inline"])):ln("",!0)],512),[[ql,!(ye.value||!P.stream&&P.loading)]]),at.value&&!pe.value&&Yt.value&&ue.value==="html"?(Ae(),gt(fo,{key:0,code:r.node.code,"html-preview-allow-scripts":r.htmlPreviewAllowScripts,"html-preview-sandbox":r.htmlPreviewSandbox,"is-dark":r.isDark,"on-close":()=>at.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):ln("",!0)]),_:2},[e.$slots["header-right"]?{name:"header-right",fn:mt(()=>[tn(e.$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,po))}}),[["__scopeId","data-v-8c3c403e"]]);export{Mo as default};
