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