markstream-vue 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CodeBlockNode.js +1 -1
- package/dist/exports.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.px.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/index8.js +1 -1
- package/dist/tailwind.js +0 -0
- package/package.json +2 -2
package/dist/CodeBlockNode.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,l=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,r=(l,t,n)=>t in l?e(l,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[t]=n,i=(e,l)=>{for(var t in l||(l={}))o.call(l,t)&&r(e,t,l[t]);if(n)for(var t of n(l))a.call(l,t)&&r(e,t,l[t]);return e},u=(e,n)=>l(e,t(n)),d=(e,l,t)=>new Promise((n,o)=>{var a=e=>{try{i(t.next(e))}catch(l){o(l)}},r=e=>{try{i(t.throw(e))}catch(l){o(l)}},i=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,r);i((t=t.apply(e,l)).next())});import{defineComponent as s,computed as v,onMounted as c,onUnmounted as f,openBlock as m,createBlock as h,Teleport as p,createElementVNode as g,normalizeClass as y,withModifiers as b,toDisplayString as w,unref as k,useAttrs as x,inject as S,getCurrentInstance as C,ref as M,shallowRef as B,watch as P,onBeforeUnmount as H,nextTick as O,normalizeStyle as F,createSlots as N,withCtx as E,renderSlot as D,createElementBlock as $,createVNode as T,withDirectives as z,createCommentVNode as L,vShow as _}from"vue";import{az as R,G as j,M as q,ak as I,aB as V,aC as W,ay as A,ab as G,am as U,ai as Y,b as J,c as X,an as K,ah as Q,a9 as Z,ae as ee,Y as le,al as te,au as ne,a8 as oe}from"./exports.js";import{M as ae,f as re,n as ie,c as ue,l as de}from"./index2.js";import{r as se,_ as ve,a as ce}from"./PreCodeBlock.vue_vue_type_style_index_0_lang.js";import{safeRaf as fe,safeCancelRaf as me}from"./utils/safeRaf.js";import{getStreamDiffsRuntime as he}from"./streamDiffs.js";const pe={class:"html-preview-frame__header"},ge={class:"html-preview-frame__title"},ye={class:"html-preview-frame__label"},be=["sandbox","srcdoc"],we=/* @__PURE__ */j(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){const l=e,t=void 0!==import.meta&&Boolean(!1);let n=null;const{t:o}=R(),a=v(()=>{const e=l.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${l.isDark?"#020617":"#ffffff"};\n color: ${l.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`}),r=v(()=>{return e=l.htmlPreviewSandbox,o=l.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!t||"undefined"==typeof console||n===e)return;const l=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);l.has("allow-scripts")&&l.has("allow-same-origin")&&(n=e,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."))}(e),e):void 0!==e?"":!0===o?"allow-scripts":"";var e,o});function i(e){var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=l.onClose)||t.call(l)}return c(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",i)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",i)}),(e,t)=>(m(),h(p,{to:"body"},[g("div",{class:y(["markstream-vue",{dark:l.isDark}])},[g("div",{class:"html-preview-frame__backdrop",onClick:t[2]||(t[2]=e=>{var t;return null==(t=l.onClose)?void 0:t.call(l)})},[g("div",{class:"html-preview-frame",onClick:t[1]||(t[1]=b(()=>{},["stop"]))},[g("div",pe,[g("div",ge,[t[3]||(t[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",ye,w(l.title||k(o)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:"html-preview-frame__close",onClick:t[0]||(t[0]=e=>{var t;return null==(t=l.onClose)?void 0:t.call(l)})}," × ")]),g("iframe",{class:"html-preview-frame__iframe",sandbox:r.value,referrerpolicy:"no-referrer",srcdoc:a.value},null,8,be)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]),ke=["data-markstream-enhanced","data-markstream-enhancement-state","data-markstream-code-block-state","data-markstream-pending","data-markstream-viewport-pending"],xe={class:"code-header-main"},Se=["innerHTML"],Ce={class:"code-header-copy"},Me={class:"code-header-title"},Be={key:0,class:"code-header-caption"},Pe=["data-markstream-host-hidden"],He=/* @__PURE__ */j(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},codeBlockOptions:{},showLineNumbers:{type:Boolean,default:void 0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:void 0},lightTheme:{default:void 0},isShowPreview:{type:Boolean,default:!0},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:{},estimatedDiffInline:{type:Boolean}},emits:["previewCode","copy"],setup(e,{emit:l}){var t,n,o,a,r;const s=e,p=l,b=v(()=>{var e,l;return null!=(l=s.showLineNumbers)?l:!0!==(null==(e=s.codeBlockOptions)?void 0:e.disableLineNumbers)}),j=x(),pe=S(ae,null),ge=S("markstreamHostScrollManaged",null),ye=S(q,void 0),be=v(()=>I(s,j));function He(e,l){}const Oe=C(),Fe=v(()=>{const e=null==Oe?void 0:Oe.vnode.props;return!(!e||!e.onPreviewCode&&!e["onPreview-code"])}),{t:Ne}=R(),Ee=M(null),De=M(null),$e=M(!1),Te=M(Kn(s.node.language,s.node.code,Xn())),ze=v(()=>re(Te.value)),Le=v(()=>"plaintext"===ze.value?"text":ze.value),_e=v(()=>"plaintext"===ze.value),Re=M(!1),je=M(!1),qe=M(!1),Ie=M(!1),Ve=M(!1),We=M(!1);let Ae=!1,Ge=!1,Ue=null,Ye=null,Je=null,Xe=0,Ke=!1,Qe="";const Ze=M(null);let el=0,ll=!1;const tl=V(),nl=W(),ol=A(),al=B(null),rl=M("undefined"==typeof window||!ol.value),il=null!=(o=null==(n=null==(t=C())?void 0:t.vnode.el)?void 0:n.textContent)?o:"",ul="undefined"!=typeof window&&String(null!=(a=s.node.code)?a:"").length>0&&il.includes(String(s.node.code)),dl=M(!ul);c(()=>{dl.value=!0}),"undefined"!=typeof window&&P([()=>De.value,ol],([e,l],t,n)=>{var o,a,r;if(null==(o=al.value)||o.destroy(),al.value=null,!l||rl.value)return void(rl.value=!0);if(!e)return void(rl.value=!1);let i=!0;const u=null!=(r=null!=(a=null==nl?void 0:nl.value.heavyBlockMargin)?a:null==nl?void 0:nl.value.rootMargin)?r:"0px",d=tl(e,{rootMargin:u,allowIdle:!1});al.value=d,rl.value=rl.value||d.isVisible.value,d.whenVisible.then(()=>{i&&al.value===d&&(rl.value=!0)}).catch(()=>{}),n(()=>{i=!1,d.destroy(),al.value===d&&(al.value=null)})},{immediate:!0}),H(()=>{var e;Ae=!0,function(){const e=Qe;pe&&e&&(Qe="",pe.markSettled(e))}(),null==(e=al.value)||e.destroy(),al.value=null});let sl=null,vl=null,cl=()=>{},fl=()=>{},ml=()=>{},hl=()=>{},pl=()=>null,gl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),yl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),bl=()=>{},wl=()=>{},kl=()=>{},xl=null,Sl=null,Cl=null,Ml=null,Bl=()=>{var e;return String(null!=(e=s.node.language)?e:"plaintext")},Pl=()=>d(null,null,function*(){}),Hl=!1,Ol=null;const Fl=[],Nl=[];let El=null,Dl=null;const $l=v(()=>G(s.node)),Tl=M({removed:0,added:0}),zl=v(()=>`-${Tl.value.removed} +${Tl.value.added}`);function Ll(e,l){return{original:e,updated:l}}function _l(e){return String(null!=e?e:"").replace(/\r\n$|\n$|\r$/,"")}function Rl(e){var l;return String(null!=(l=null==e?void 0:e.message)?l:e).includes("no diff result available")}function jl(){if(!Vn())try{const e=kl();e&&"function"==typeof e.catch&&e.catch(e=>{Rl(e)})}catch(e){Rl(e)}}const ql=v(()=>{const e=i({},s.codeBlockOptions||{});for(const n of["theme","themes","themeType","language","languages","stream","disableFileHeader","onThemeChange","renderCustomHeader","renderHeaderMetadata","renderHeaderPrefix","maxHeight","padding","tabSize"])delete e[n];if(!$l.value)return e;const l=e.parseDiffOptions&&"object"==typeof e.parseDiffOptions?e.parseDiffOptions:{},t={diffStyle:"split",expandUnchanged:!1,collapsedContextThreshold:5,hunkSeparators:"line-info",parseDiffOptions:{context:2}};return u(i(i({},t),e),{parseDiffOptions:i(i({},t.parseDiffOptions),l)})}),Il=v(()=>{return(void 0!==s.theme?(e=s.theme)&&"object"==typeof e&&"light"in e&&"dark"in e:!xo(s.darkTheme,s.lightTheme))?!!s.isDark:function(e){var l;const t=null!=(l=ko(e))?l:"";return ee(t,!0===s.isDark)}(So());var e}),Vl=v(()=>($l.value,Il.value?"dark":"light")),Wl=v(()=>$l.value?"dark"===Vl.value:Il.value),Al=v(()=>U({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})),Gl=v(()=>$l.value?"diff":"single"),Ul=M(Gl.value),Yl=M(!1),Jl=M(!1),Xl=M(!1),Kl=M(!1),Ql=M(null),Zl=M(0),et=M(0),lt=M(!1);let tt=null,nt=!1,ot=null,at=!1;const rt=v(()=>{var e;return!!$l.value&&"unified"===(null==(e=ql.value)?void 0:e.diffStyle)}),it=v(()=>Y(ql.value));function ut(e){return!0===(null==ge?void 0:ge.value)||!!e&&(!!e.closest('[data-markstream-virtual-timeline="1"], .markstream-virtual-timeline')||Boolean(e.closest(".vue-recycle-scroller, [data-virtualizer], [data-virtual-scroll-root]")))}const dt=v(()=>ut(De.value)),st=v(()=>!(Yl.value||!Kl.value&&Jl.value)),vt=v(()=>st.value),ct=v(()=>st.value&&!Xl.value),ft=v(()=>!Yl.value&&!Kl.value&&st.value),mt=v(()=>Jl.value&&!Yl.value?"ready":Kl.value?"fallback":"pending"),ht=M(!1),pt=v(()=>_l(s.node.code)),gt=v(()=>$l.value?!0===s.node.diff?s.node:u(i({},s.node),{diff:!0}):pt.value===s.node.code?s.node:u(i({},s.node),{code:pt.value}));function yt(e){const l=e.detectLanguage;"function"==typeof l&&(Bl=l),Dl=e,El=Bo();const t=e.createCodeBlockRuntime(El);return!!t&&(sl=t.createEditor||sl,vl=t.createDiffEditor||vl,cl=t.updateCode||cl,fl=t.updateDiff||fl,ml=t.finalizeCode||ml,hl=t.finalizeDiff||hl,pl=t.getEditor||pl,gl=t.getEditorView||gl,yl=t.getDiffEditorView||yl,bl=t.cleanupEditor||bl,wl=t.safeClean||t.cleanupEditor||wl,kl=t.refreshDiffPresentation||kl,Pl=t.setTheme||Pl,xl=t.whenVisualReady||null,We.value=!0,!0)}const bt=J,wt=X,kt=M("number"==typeof(null==(r=s.codeBlockOptions)?void 0:r.fontSize)?s.codeBlockOptions.fontSize:Number.NaN),xt=M(kt.value),St=M(null),Ct=M(null),Mt=M(null),Bt=M(null),Pt=v(()=>{const e=kt.value,l=xt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof l&&Number.isFinite(l)&&l>0}),Ht=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.fontSize;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l;const t=xt.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:bt}),Ot=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.lineHeight;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:Ht.value===bt?wt:Math.max(12,Math.round(1.5*Ht.value))}),Ft=v(()=>Ot.value),Nt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.tabSize;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:4}),Et=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding,t="number"==typeof l&&Number.isFinite(l)&&l>=0?l:8;return{top:t,bottom:t}}),Dt=v(()=>{const e=K(s.codeBlockOptions);return u(i({},e),{fontSize:Ht.value,lineHeight:Ft.value,maxHeight:Yn(),padding:Et.value.top,paddingBottom:Et.value.bottom,tabSize:Nt.value})}),$t=v(()=>{const e=s.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function Tt(e){if(null==e)return null;const l=Math.ceil(e);return!Number.isFinite(l)||l<=0?null:Math.min(l,Math.ceil(Yn()))}function zt(){return!$l.value&&!1!==s.stream&&!1!==s.loading}const Lt=M(zt());function _t(){return zt()||Lt.value}const Rt=v(()=>$l.value?null:null==$t.value||_t()?Math.ceil((e=>{const l=String(null!=e?e:"");if(!l)return 1;let t=1;for(let n=0;n<l.length;n++)"\n"===l[n]?t++:"\r"===l[n]&&(t++,"\n"===l[n+1]&&n++);return t})(pt.value)*Ft.value+1):null),jt=v(()=>{if($l.value)return null;const e=$t.value;return null==e||_t()?Tt(Rt.value):Tt(e)}),qt=v(()=>{const e=s.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),It=M(null);function Vt(){const e=It.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}const Wt=v(()=>{const e=Vt();return null!=e?e:!$l.value&<.value?null:st.value||!Jl.value?jt.value:null});function At(e){const l=e?"hsl(152 42% 60%)":"var(--diff-added-fg)",t=e?"hsl(0 58% 58%)":"var(--diff-removed-fg)",n=e?"color-mix(in lab, #121212 80%, #4d9375)":"color-mix(in lab, #ffffff 88%, #1e754f)",o=e?"color-mix(in lab, #121212 80%, #cb7676)":"color-mix(in lab, #ffffff 88%, #ab5959)";return{"--markstream-diff-line-number-bg":"var(--markstream-diff-editor-bg)","--markstream-diff-added-fg":l,"--markstream-diff-removed-fg":t,"--markstream-diff-added-line":n,"--markstream-diff-removed-line":o,"--markstream-diff-added-line-fill":n,"--markstream-diff-added-number-fill":e?"color-mix(in lab, #121212 85%, #4d9375)":"color-mix(in lab, #ffffff 91%, #1e754f)","--markstream-diff-removed-line-fill":o,"--markstream-diff-removed-number-fill":e?"color-mix(in lab, #121212 85%, #cb7676)":"color-mix(in lab, #ffffff 91%, #ab5959)","--markstream-diff-added-gutter":`linear-gradient(90deg, ${l} 0 4px, transparent 4px 100%)`,"--markstream-diff-removed-gutter":`linear-gradient(90deg, ${t} 0 4px, transparent 4px 100%)`,"--markstream-diff-added-inline":e?"hsl(152 42% 60% / 0.28)":"var(--diff-added-inline-bg)","--markstream-diff-removed-inline":e?"hsl(0 58% 58% / 0.28)":"var(--diff-removed-inline-bg)"}}const Gt=v(()=>{const e=Tt($t.value),l=Tt(Rt.value),t=_t(),n=i({},$l.value||null==e||t?$l.value||null==l?{}:{minHeight:`${l}px`}:{height:`${e}px`,minHeight:`${e}px`});if(n["--markstream-code-fallback-bg"]=Al.value.background,n["--markstream-code-fallback-fg"]=Al.value.foreground,Al.value.builtin&&(n["--markstream-code-theme-bg"]=Al.value.background,n["--markstream-code-theme-fg"]=Al.value.foreground,n["--markstream-code-theme-line-number"]=Al.value.lineNumber),n["--markstream-pre-line-number-top"]=`${Et.value.top}px`,n["--markstream-pre-line-number-left"]="0px",n["--markstream-pre-line-number-padding-left"]="2ch",n["--markstream-pre-line-number-padding-right"]="1ch",n["--markstream-pre-line-number-separator-width"]="2px",$l.value){n["--markstream-pre-diff-line-height"]=`${Ft.value}px`,n["--markstream-pre-diff-pane-bottom-padding"]=(rt.value,"0px");const e=Bt.value;null!=e&&e>0&&(n.height=`${e}px`,n.minHeight=`${e}px`,n.maxHeight=`${e}px`),Object.assign(n,At(Wl.value))}return n}),Ut=v(()=>null!=Wt.value&&(!Jl.value||null!=Vt())),Yt=v(()=>{const e=Wt.value;if(null==e)return null;if($l.value)return Math.ceil(e);const l=qt.value,t=$t.value;if(null==l||null==t)return Math.ceil(e);const n=Math.max(0,Math.ceil(l)-Math.ceil(t));return Math.ceil(e+n)}),Jt=v(()=>{if($l.value&&st.value)return{};const e=Wt.value;return Ut.value&&null!=e?{minHeight:`${e}px`}:{}});function Xt(){It.value=null}function Kt(){var e,l,t,n,o,a,r,i;const u=null==(e=De.value)?void 0:e.querySelector("pre.code-pre-fallback"),d=yl(),s=null!=(l=null==u?void 0:u.scrollTop)?l:0;null==(o=null==(n=null==(t=null==d?void 0:d.getOriginalEditor)?void 0:t.call(d))?void 0:n.setScrollTop)||o.call(n,s),null==(i=null==(r=null==(a=null==d?void 0:d.getModifiedEditor)?void 0:a.call(d))?void 0:r.setScrollTop)||i.call(r,s)}function Qt(){return d(this,null,function*(){return $l.value?(xn(),ln(),Dn(!0),Kt(),$n(),Xl.value=!0,yield O(),Dn(!0),yield nn(),Dn(!0),wn(),ln(),!!(yield function(){return d(this,null,function*(){var e;if(!$l.value)return!0;for(let l=0;l<4;l++){const l=ln();Dn(!0),Zt(l),en(l),yield O(),yield nn();const t=null==(e=De.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!t)return!1;if(null==l)return jn();const n=t.getBoundingClientRect().height;if(n>0&&Math.abs(n-l)<=2)return!0}return!1})}())&&(Jl.value=!0,yield O(),ln(),Dn(!0),wn(),$n(),fe(()=>{Ae||fe(()=>{Ae||(function(){var e,l;const t=null==(e=De.value)?void 0:e.querySelector(".code-block-shell-content"),n=null==(l=De.value)?void 0:l.querySelector(".code-editor-layer");t&&n&&(n.style.removeProperty("height"),n.style.removeProperty("min-height"),t.style.removeProperty("height"),t.style.removeProperty("min-height"))}(),Tn(!0))})}),Tn(),!0)):!(xl&&!(yield xl())||(xn(),Dn(!0),Xl.value=!0,yield O(),xn(),Dn(!0),yield nn(),xn(),Dn(!0),Jl.value=!0,yield O(),Tn(),0))})}function Zt(e){var l;if(!$l.value)return;const t=Ee.value,n=null==(l=De.value)?void 0:l.querySelector("pre.code-pre-fallback");if(!t||!n)return;const o=null!=e?e:Number.parseFloat(t.style.height||"");if(!Number.isFinite(o)||o<=0)return;const a=Math.ceil(o),r=`${a}px`;Bt.value=a;const i=De.value;i&&(i.dataset.markstreamDiffHandoffHeight=r),n.dataset.markstreamDiffHandoffHeight=r,n.style.setProperty("height",r),n.style.setProperty("min-height",r)}function en(e){var l,t,n;if(!$l.value)return;const o=null==(l=De.value)?void 0:l.querySelector(".code-block-shell-content"),a=null==(t=De.value)?void 0:t.querySelector(".code-editor-layer");if(!o||!a)return;const r="number"==typeof e&&Number.isFinite(e)&&e>0?Math.ceil(e):Number.parseFloat((null==(n=Ee.value)?void 0:n.style.height)||"");if(!Number.isFinite(r)||r<=0)return;const i=`${r}px`;a.style.height=i,a.style.minHeight=i,o.style.height=i,o.style.minHeight=i}function ln(){const e=Ee.value;if(e&&jn(e)){$n();const l=yn(e);if(null!=l&&l>0){const t=Math.ceil(l),n=Math.ceil(Yn()),o=Math.min(t,n),a=`${o}px`;return e.style.height=a,e.style.minHeight="0px",e.style.maxHeight=`${n}px`,e.style.overflow=t>n+1?"auto":"hidden",st.value&&(Bt.value=o,Zt(o)),zn(),o}return Nn({preferModelDiffHeight:!0}),Zt(),zn(),Number.parseFloat(e.style.height||"")||null}return xn()}function tn(e,l=!1,t={}){const n=Math.ceil(e),o=Vt();if(null==o)return n;const a=!0===t.allowBelowEstimatedFloor;return n>=o||a?((l||a)&&Ve.value&&Xt(),n):o}function nn(){return new Promise(e=>{let l=!1,t=null,n=null;const o=()=>{l||(l=!0,null!=n&&globalThis.clearTimeout(n),null!=t&&me(t),e())};n=globalThis.setTimeout(o,50),t=fe(o)})}function on(){var e;try{const l=Ee.value;if(!l)return null;const t=null!=(e=l.querySelector(".stream-diffs-shell .stream-diffs-surface"))?e:l.querySelector(".stream-diffs-shell");if(t){const e=Math.ceil(t.getBoundingClientRect().height);if(e>0)return e}}catch(l){}return null}function an(){var e,l,t,n,o,a;try{const a=$l.value?null!=(t=null==(l=null==(e=yl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:yl():gl(),r=pl(),i=null==(n=null==r?void 0:r.EditorOption)?void 0:n.fontInfo;if(a&&null!=i){const e=null==(o=a.getOption)?void 0:o.call(a,i),l=null==e?void 0:e.fontSize;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l}}catch(r){}try{const e=Ee.value;if(e){const l=null!=(a=e.querySelector(".stream-diffs-shell .stream-diffs-surface"))?a:e.querySelector(".stream-diffs-shell");if(l)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(l).fontSize,t=e&&e.match(/^(\d+(?:\.\d+)?)/);if(t)return Number.parseFloat(t[1])}}catch(r){}}}catch(r){}return null}function rn(e){var l,t;try{const n=pl(),o=null==(l=null==n?void 0:n.EditorOption)?void 0:l.lineHeight;if(null!=o){const l=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o);if("number"==typeof l&&l>0)return l}}catch(a){}const n=on();if(n&&n>0)return n;const o=Number.isFinite(xt.value)&&xt.value>0?xt.value:14;return Math.max(12,Math.round(1.35*o))}function un(){var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding;return"number"==typeof l&&Number.isFinite(l)?2*Math.max(0,l):$l.value?24:0}function dn(e){return!!_e.value||!!e&&(Vn(e)||null!=xl)}function sn(){var e,l;$l.value?Tl.value=le(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:"")):Tl.value={removed:0,added:0}}function vn(){sn()}function cn(){var e;if(Number.isFinite(xt.value)&&xt.value>0&&Number.isFinite(kt.value))return xt.value;if("number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize))return kt.value=s.codeBlockOptions.fontSize,xt.value=s.codeBlockOptions.fontSize,s.codeBlockOptions.fontSize;const l=an();return l&&l>0?(kt.value=l,xt.value=l,l):(kt.value=12,xt.value=12,12)}function fn(){const e=cn(),l=Math.min(36,e+1);xt.value=l}function mn(){const e=cn(),l=Math.max(10,e-1);xt.value=l}function hn(){cn(),Number.isFinite(kt.value)&&(xt.value=kt.value)}function pn(){var e,l,t,n,o,a,r,i,u,d,s,v,c,f;try{const m=$l.value?yl():null,h=$l.value?m:gl();if(!h)return null;if((null==m?void 0:m.getOriginalEditor)&&(null==m?void 0:m.getModifiedEditor)){const c=null==(e=m.getOriginalEditor)?void 0:e.call(m),f=null==(l=m.getModifiedEditor)?void 0:l.call(m);null==(t=null==c?void 0:c.layout)||t.call(c),null==(n=null==f?void 0:f.layout)||n.call(f);const h=(null==(o=null==c?void 0:c.getContentHeight)?void 0:o.call(c))||0,p=(null==(a=null==f?void 0:f.getContentHeight)?void 0:a.call(f))||0,g=Math.max(h,p);if(g>0)return Math.ceil(g);const y=(null==(u=null==(i=null==(r=null==c?void 0:c.getModel)?void 0:r.call(c))?void 0:i.getLineCount)?void 0:u.call(i))||1,b=(null==(v=null==(s=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:s.getLineCount)?void 0:v.call(s))||1,w=Math.max(y,b),k=Math.max(rn(c),rn(f)),x=un();return Math.ceil(w*k+x+0)}if(null==h?void 0:h.getContentHeight){null==(c=null==h?void 0:h.layout)||c.call(h);const e=h.getContentHeight();if(e>0)return $l.value||(lt.value=!0),Math.ceil(e)}const p=null==(f=null==h?void 0:h.getModel)?void 0:f.call(h);let g=1;p&&"function"==typeof p.getLineCount&&(g=p.getLineCount());const y=rn(h);return Math.ceil(g*(y+1.5)+0)}catch(m){return null}}function gn(){var e,l;if($l.value)return!1;try{const t=null==(l=null==(e=gl())?void 0:e.getContentHeight)?void 0:l.call(e),n="number"==typeof t&&Number.isFinite(t)&&t>0;return n&&(lt.value=!0),n}catch(t){return!1}}function yn(e){if("undefined"==typeof window)return null;try{if("none"===window.getComputedStyle(e).display)return null;const l=e.querySelector("diffs-container");if(l instanceof HTMLElement){const e=l.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}const t=e.querySelector(".stream-diffs-shell");if(t){const e=t.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}return null}catch(l){return null}}function bn(e){var l;const t=String(null!=e?e:"").trim(),n=null==(l=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?void 0:l[1];if(n){const e=3===n.length?n.split("").map(e=>`${e}${e}`).join(""):n;return.2126*Number.parseInt(e.slice(0,2),16)+.7152*Number.parseInt(e.slice(2,4),16)+.0722*Number.parseInt(e.slice(4,6),16)}const o=t.match(/\d+(?:\.\d+)?/g);if(!o||o.length<3)return null;const[a,r,i]=o.slice(0,3).map(Number);return.2126*a+.7152*r+.0722*i}function wn(){var e,l,t;if(kn())return;const n=an();n&&n>0&&(St.value=n,xt.value=n,kt.value=n);try{const n=rn($l.value?null!=(t=null==(l=null==(e=yl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:yl():gl());n&&n>0&&(Ct.value=n)}catch(o){}try{const e=on();e&&e>0&&(Ct.value=e)}catch(o){}}function kn(){return $l.value&&vt.value}function xn(){var e;if(!st.value)return null;const l=Ee.value,t=null==(e=De.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l||!t)return null;const n=Math.ceil(t.getBoundingClientRect().height),o=$l.value?yn(l):null,a=Math.max(n,null!=o&&o>0?Math.ceil(o):0),r=Math.ceil(Yn()),i=Math.min(a,r);return!Number.isFinite(i)||i<=0?null:($l.value&&i>n&&(Bt.value=i),l.style.height=`${i}px`,l.style.minHeight=`${i}px`,l.style.maxHeight=`${r}px`,l.style.overflow=a>r+1?"auto":"hidden",i)}function Sn(){var e,l,t,n,o,a,r,i,u;const d=Ee.value,v=De.value;if(!d||!v)return;const c=d;c.style.setProperty("--markstream-diff-metadata-bg",Al.value.background),c.style.setProperty("--markstream-diff-metadata-fg",Al.value.lineNumber),c.style.setProperty("--diffs-tab-size",String(Nt.value)),c.style.setProperty("--diffs-scrollbar-gutter-override","0px"),"number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.padding)?c.style.setProperty("--diffs-gap-block",`${Et.value.top}px`):c.style.removeProperty("--diffs-gap-block");const f=d.querySelector(".stream-diffs-shell")||d,m=f,h=f;let p=null,g=null,y=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(p=window.getComputedStyle(f),g=m===f?p:window.getComputedStyle(m),y=h===f?p:window.getComputedStyle(h))}catch(M){p=null,g=null,y=null}const b=String(null!=(l=null==p?void 0:p.getPropertyValue("--vscode-editor-foreground"))?l:"").trim(),w=String(null!=(t=null==p?void 0:p.getPropertyValue("--vscode-editor-background"))?t:"").trim(),k=String(null!=(o=null!=(n=null==p?void 0:p.getPropertyValue("--vscode-editor-selectionBackground"))?n:null==p?void 0:p.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?o:"").trim(),x=b||String(null!=(r=null!=(a=null==y?void 0:y.color)?a:null==p?void 0:p.color)?r:"").trim(),S=w||String(null!=(u=null!=(i=null==g?void 0:g.backgroundColor)?i:null==p?void 0:p.backgroundColor)?u:"").trim(),C=function(){var e,l,t,n,o;try{const a=$l.value?null!=(t=null==(l=null==(e=yl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:yl():gl(),r=pl(),i=null==(n=null==r?void 0:r.EditorOption)?void 0:n.fontInfo;if(a&&null!=i){const e=null==(o=a.getOption)?void 0:o.call(a,i),l=null==e?void 0:e.typicalHalfwidthCharacterWidth;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l}}catch(M){}return null}();if(null!=C&&(Mt.value=C),$l.value){const e=(e,l)=>{l?(v.style.setProperty(e,l),c.style.setProperty(e,l)):(v.style.removeProperty(e),c.style.removeProperty(e))};for(const[l,t]of Object.entries(At(v.classList.contains("is-dark"))))e(l,t);return x?(v.style.setProperty("--markstream-diff-editor-fg",x),c.style.setProperty("--vscode-editor-foreground",x)):(v.style.removeProperty("--markstream-diff-editor-fg"),c.style.removeProperty("--vscode-editor-foreground")),S?(v.style.setProperty("--markstream-diff-editor-bg",S),v.style.setProperty("--markstream-diff-panel-bg",S),v.style.setProperty("--markstream-diff-panel-bg-soft",S),v.style.setProperty("--markstream-diff-panel-bg-strong",S),c.style.setProperty("--vscode-editor-background",S),c.style.backgroundColor=S):(v.style.removeProperty("--markstream-diff-editor-bg"),v.style.removeProperty("--markstream-diff-panel-bg"),v.style.removeProperty("--markstream-diff-panel-bg-soft"),v.style.removeProperty("--markstream-diff-panel-bg-strong"),c.style.removeProperty("--vscode-editor-background"),c.style.backgroundColor=""),void(k?c.style.setProperty("--vscode-editor-selectionBackground",k):c.style.removeProperty("--vscode-editor-selectionBackground"))}if(function(e,l,t){if(!_e.value)return!1;const n=bn(e),o=bn(l);return t?null!=n&&n>170||null!=o&&o<110:null!=n&&n<85||null!=o&&o>190}(S,x,v.classList.contains("is-dark")))return c.style.removeProperty("--vscode-editor-foreground"),c.style.removeProperty("--vscode-editor-background"),void c.style.removeProperty("--vscode-editor-selectionBackground");x&&c.style.setProperty("--vscode-editor-foreground",x),S&&c.style.setProperty("--vscode-editor-background",S),k&&c.style.setProperty("--vscode-editor-selectionBackground",k)}P(()=>[s.stream,s.loading,s.node.loading,$l.value],([e,l,t,n])=>{n||!1===e||!1===l||Lt.value?(n||!1===e)&&Lt.value&&(Lt.value=!1):(Lt.value=!0,Xt())},{immediate:!0});let Cn=0,Mn=0;const Bn=/auto|scroll|overlay/i;function Pn(e,l,t){var n;if("undefined"==typeof window)return;if($l.value)return;if(function(e){return dt.value||ut(e)}(e))return;const o=Math.ceil(l),a=Math.ceil(t)-o;if(Math.abs(a)<=1)return;const r=function(e){var l,t;if("undefined"==typeof window)return null;const n=null!=(l=null==e?void 0:e.ownerDocument)?l:document,o=n.scrollingElement||n.documentElement||n.body;let a=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;a&&a!==n.body&&a!==o;){const e=window.getComputedStyle(a),l=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(Bn.test(l)||Bn.test(t))return a;a=a.parentElement}return o}(e);if(!r)return;const i=null!=(n=e.ownerDocument)?n:document,u=r===i.body||r===i.documentElement||r===i.scrollingElement,d=u?0:r.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,a):r.scrollTop+=a)}function Hn(){try{const e=Ee.value;if(!e)return;const l=e.getBoundingClientRect().height,t=pn();if(null!=t&&t>0){const n=tn(t,!0,{allowBelowEstimatedFloor:!$l.value&&Ve.value&&gn()}),o=Vt();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",void Pn(e,l,n)}const n=Vt();null!=n&&(e.style.minHeight=`${n}px`,e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",Pn(e,l,n))}catch(e){}}function On(){for(var e,l;Fl.length>0;)try{null==(l=null==(e=Fl.pop())?void 0:e.dispose)||l.call(e)}catch(t){}null!=Ue&&(me(Ue),Ue=null),null!=Ye&&(me(Ye),Ye=null),null!=Je&&(me(Je),Je=null),Xe=0,Ke=!1}function Fn(){for(var e;Nl.length>0;)try{null==(e=Nl.pop())||e()}catch(l){}}function Nn(e=!1){je.value||(Re.value?Hn():function(e={}){var l;try{const t=Ee.value;if(!t)return;const n=t.getBoundingClientRect().height,o=Yn(),a=Math.ceil((null==(l=t.getBoundingClientRect)?void 0:l.call(t).height)||0),r=Number.parseFloat(t.style.height||""),i=a>0?a:Number.isFinite(r)&&r>0?Math.ceil(r):0,u=$l.value?function(){var e,l,t,n,o,a,r,i,u,d,s,v;if(Vn())return null;try{const c=yl(),f=null==(e=null==c?void 0:c.getOriginalEditor)?void 0:e.call(c),m=null==(l=null==c?void 0:c.getModifiedEditor)?void 0:l.call(c);if(!f||!m)return null;const h=(null==(o=null==(n=null==(t=f.getModel)?void 0:t.call(f))?void 0:n.getLineCount)?void 0:o.call(n))||1,p=(null==(i=null==(r=null==(a=m.getModel)?void 0:a.call(m))?void 0:r.getLineCount)?void 0:i.call(r))||1,g=Math.max(h,p),y=Math.max(rn(f),rn(m)),b=un(),w=Math.max(null!=(d=null==(u=f.getContentHeight)?void 0:u.call(f))?d:0,null!=(v=null==(s=m.getContentHeight)?void 0:s.call(m))?v:0);return Math.ceil(Math.max(w,g*y+b+0))}catch(c){return null}}():null,d=$l.value&&jn(t);if(el>0&&(el--,null!=Ze.value))return void Pn(t,n,Ln(t,Ze.value,o,{preserveScrollableOverflow:Rn(t)}));if($l.value&&!d&&st.value){const e=xn();if(null!=e){const l=Ln(t,e,o,{allowBelowEstimatedFloor:!0});return Dn(!0),void Pn(t,n,l)}}const v=$l.value&&!0===e.preferModelDiffHeight,c=$l.value?yn(t):null,f=!$l.value&&Ve.value&&gn(),m=$l.value&&!1!==s.loading&&(null!=c||null!=u&&a>0&&u<a-1),h=null!=u;let p;if($l.value)if(v){const e=null!=u&&!1===s.loading&&i>0&&u<i-1;p=!1===s.loading&&null!=c?null==u?c:Math.max(c,u):e?u:null!=c&&null!=u?Math.max(c,u,!1!==s.loading?i:0):Math.max(null!=c?c:0,null!=u?u:0,!1!==s.loading?i:0)||null}else p=rt.value&&null!=c||null!=c?h?Math.max(c,u):c:$l.value&&!1!==s.loading?null!=u&&i>0&&u<i-1?u:i>0?i:null:u;else p=pn();if($l.value&&null!=p&&i>0&&(!1!==s.loading||!0===e.holdCurrentDiffHeight)&&(p=Math.max(p,i)),null!=p&&p>0)return void Pn(t,n,Ln(t,p,o,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:f||m,preserveScrollableOverflow:Rn(t)}));if(null!=Ze.value)return void Pn(t,n,Ln(t,Ze.value,o,{preserveScrollableOverflow:Rn(t)}));const g=$l.value&&!1!==s.loading?a:Math.max(a,null!=u&&u>0?u:0);if(g>0)return void Pn(t,n,Ln(t,g,o));const y=Vt();if(!(null==y||$l.value&&!1!==s.loading&&d))return void Pn(t,n,Ln(t,y,o));const b=Number.parseFloat(t.style.height);!Number.isNaN(b)&&b>0?Pn(t,n,Ln(t,b,o)):$l.value||Pn(t,n,Ln(t,o,o))}catch(t){}}("object"==typeof e?e:{}))}function En(){Cn=0,Mn=0}function Dn(e=!1){var l,t,n;if(je.value)return;const o=Ee.value;if(!o)return;const a=$l.value?yl():gl();if(a&&"function"==typeof a.layout)try{const r=null==(l=o.getBoundingClientRect)?void 0:l.call(o),i=Math.ceil((null!=(t=null==r?void 0:r.width)?t:0)||o.clientWidth||0),u=Math.ceil((null!=(n=null==r?void 0:r.height)?n:0)||o.clientHeight||Number.parseFloat(o.style.height||"")||0);if(i>0&&u>0){if(!e&&i===Cn&&u===Mn)return;Cn=i,Mn=u,a.layout({width:i,height:u})}else En(),a.layout()}catch(r){}}function $n(){Fn()}function Tn(e=!1){if(Ae||null!=Ue)return;const l=()=>{Ae||($n(),Nn(e),Dn())};Ue=fe(()=>{Ue=null,l(),Ye=fe(()=>{Ye=null,l()})}),zn()}function zn(e=!1){if(!$l.value||Ae||!e&&!1===s.loading)return;if(Ke=Ke||e,Xe=Math.max(Xe,e?18:6),null!=Je)return;const l=()=>{if(Je=null,!$l.value||Ae||Xe<=0||!Ke&&!1===s.loading)return Xe=0,void(Ke=!1);Xe--,$n(),Nn({preferModelDiffHeight:!0,holdCurrentDiffHeight:Ke}),Dn(),Xe>0?Je=fe(l):Ke=!1};Je=fe(l)}function Ln(e,l,t,n={}){const o=$l.value&&!1!==s.loading?yn(e):null,a=null!=o&&o>l+1?o:l,r=Math.min(a,t),i=!0===n.allowBelowEstimatedFloor,u=tn(r,!0===n.clearEstimatedFloor,{allowBelowEstimatedFloor:i}),d=Vt();e.style.minHeight=null==d||i?"0px":`${Math.min(d,Math.ceil(t))}px`,e.style.height=`${u}px`,e.style.maxHeight=`${Math.ceil(t)}px`;const v=!0===n.preserveScrollableOverflow||a>t+1||_n(e,u);return e.style.overflow=v?"auto":"hidden",u}function _n(e,l=0){var t;const n=Math.ceil((null==(t=e.getBoundingClientRect)?void 0:t.call(e).height)||0),o=Math.max(l,e.clientHeight||0,n);return o>0&&e.scrollHeight>o+1}function Rn(e){var l;return ll||_n(e,null!=(l=Ze.value)?l:0)}function jn(e=Ee.value){return Vn(e)}function qn(e=Ee.value){return Vn(e)}function In(){var e,l;if(Vn())return!0;const t=null==(l=null==(e=gl())?void 0:e.getModel)?void 0:l.call(e);return"function"==typeof(null==t?void 0:t.getValue)&&t.getValue()===pt.value}function Vn(e=Ee.value){return Boolean(null==e?void 0:e.querySelector("diffs-container"))}function Wn(){return!1!==s.loading||Jl.value}function An(){const e=yl();return Boolean("function"==typeof(null==e?void 0:e.getOriginalEditor)||"function"==typeof(null==e?void 0:e.getModifiedEditor)||"function"==typeof(null==e?void 0:e.getLineChanges))}function Gn(){return d(this,null,function*(){if(!$l.value)return!0;for(let e=0;e<30;e++){if(Ae)return!1;if(Vn())return yield O(),yield nn(),!Ae&&Vn();yield O(),yield nn()}return!1})}function Un(e,l,t){return d(this,null,function*(){try{return void(yield fl(e,l,t))}catch(n){if(!Rl(n))throw n}if(yield O(),yield nn(),!Ae&&$l.value)try{yield fl(e,l,t)}catch(n){if(!Rl(n))throw n}})}function Yn(){var e,l;return null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500}const Jn=v(()=>s.isShowPreview&&("html"===Te.value||"svg"===Te.value));function Xn(){return"boolean"==typeof s.node.loading?s.node.loading:!0===s.loading}function Kn(e,l,t){return!t||function(){var e,l,t;if(!Xn())return!0;const n=String(null!=(e=s.node.raw)?e:""),o=null!=(t=null==(l=n.split(/\r\n|\n|\r/,1)[0])?void 0:l.trimStart())?t:"";return!/^(?:`{3,}|~{3,})/.test(o)||/\r\n|\n|\r/.test(n)}()&&String(null!=l?l:"")?ie(String(null!=e?e:"")):"plain"}function Qn(){return Xn()}let Zn=null,eo=!1,lo=0;function to(){Zn=null,lo++}function no(){return d(this,arguments,function*(e=lo){if(!eo){eo=!0;try{for(;Zn&&!Ae&&!$l.value&&e===lo;){const e=Zn;Zn=null;try{yield Promise.resolve(cl(e.code,e.language)),yield O(),Ae||$l.value||(Nn(!1),Dn())}catch(l){He()}}}finally{eo=!1,!Zn||Ae||$l.value||no()}}})}function oo(e,l){Zn={code:e,language:l},no(lo)}P(()=>[s.node.language,s.node.code,s.node.raw,s.node.loading,s.loading],([e,l,t,n,o])=>{Te.value=Kn(e,l,"boolean"==typeof n?n:!0===o)}),P(()=>[s.node.originalCode,s.node.updatedCode,$l.value],()=>{sn(),fe(()=>vn())},{immediate:!0});let ao=0;P(()=>[s.node.originalCode,s.node.updatedCode,Le.value,$l.value,s.stream],e=>d(null,[e],function*([,,,e,l]){var t,n;const o=++ao;if(!e)return;if(Xn())return;if(!1===l&&!qe.value)return;if(!1!==l&&sl&&!qe.value&&Ee.value)try{yield yo(Ee.value)}catch(u){}const a=Cl;if(a&&!Ie.value){try{yield a}catch(u){}if(Ae||!$l.value||o!==ao)return}if(o!==ao)return;const r=Ll(String(null!=(t=s.node.originalCode)?t:""),String(null!=(n=s.node.updatedCode)?n:"")),i=!1===s.loading;i&&Po();try{if(yield Un(r.original,r.updated,Le.value),Ae||!$l.value||o!==ao)return;yield O(),Dn(!0),$n(),Nn(!1===s.loading||{preferModelDiffHeight:!0}),Dn(!0),Tn(!0)}catch(d){return}if(i){if(Ae||!$l.value)return;jl(),$n(),vn(),Tn(),zn(!0)}Re.value&&fe(()=>Hn())})),P(()=>s.node.code,e=>d(null,null,function*(){if(Xn())return;if(!1===s.stream)return;if(Te.value||(Te.value=ie(Bl(e))),$l.value)return;const l=Cl;if(l&&!Ie.value){try{yield l}catch(t){}if(Ae||$l.value)return}if(sl&&!qe.value&&Ee.value)try{yield yo(Ee.value)}catch(t){}oo(_l(s.node.code),Le.value),Re.value&&fe(()=>Hn())}));const ro=v(()=>{const e=Te.value;return e?ue[e]||e.charAt(0).toUpperCase()+e.slice(1):ue[""]||"Plain Text"}),io=v(()=>{var e;return Q(String(null!=(e=s.node.raw)?e:""),ro.value,$l.value)}),uo=v(()=>io.value.title),so=v(()=>io.value.caption),vo=v(()=>(de.value,se(Te.value||"",ye))),co=v(()=>{const e={};e["--markstream-code-layout-character-width"]=null==Mt.value?"1ch":`${Mt.value}px`,e["--markstream-code-fallback-bg"]=Al.value.background,e["--markstream-code-fallback-fg"]=Al.value.foreground,Al.value.builtin&&(e["--markstream-code-theme-bg"]=Al.value.background,e["--markstream-code-theme-fg"]=Al.value.foreground,e["--markstream-code-theme-line-number"]=Al.value.lineNumber),e["--markstream-diff-added-line-fill"]=Al.value.diffAddedLine,e["--markstream-diff-added-number-fill"]=Al.value.diffAddedNumber,e["--markstream-diff-editor-bg"]=Al.value.background,e["--markstream-diff-removed-line-fill"]=Al.value.diffRemovedLine,e["--markstream-diff-removed-number-fill"]=Al.value.diffRemovedNumber,e["--markstream-diff-shell-bg"]=Al.value.background,e["--markstream-pre-resolved-theme-bg"]=Al.value.background,e["--markstream-pre-resolved-theme-fg"]=Al.value.foreground,e["--markstream-pre-resolved-theme-line-number"]=Al.value.lineNumber;const l=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=l(s.minWidth),n=l(s.maxWidth);if(t&&(e.minWidth=t),n&&(e.maxWidth=n),Ut.value&&!$l.value&&!je.value){const l=Yt.value;null!=l&&(e.minHeight=`${l}px`)}return e.color="var(--markstream-code-fallback-fg, var(--markstream-code-theme-fg, var(--markstream-pre-resolved-theme-fg)))",e.backgroundColor="var(--markstream-code-fallback-bg, var(--markstream-code-theme-bg, var(--markstream-pre-resolved-theme-bg)))",$l.value||(e.borderColor="var(--markstream-code-border-color, var(--code-border))"),e}),fo=v(()=>!1!==s.showTooltips);function mo(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(s.node.code)),$e.value=!0,p("copy",s.node.code),setTimeout(()=>{$e.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function ho(){Re.value=!Re.value;const e=$l.value?yl():gl(),l=Ee.value;e&&l&&(Re.value?(l.style.maxHeight="none",l.style.overflow="visible",Nn(!0)):(l.style.overflow="auto",Nn(!0)))}function po(){var e,l;if(je.value=!je.value,je.value){if(ll=!1,Ee.value){const t=Math.ceil((null==(l=(e=Ee.value).getBoundingClientRect)?void 0:l.call(e).height)||0);ll=_n(Ee.value,t)||"auto"===Ee.value.style.overflow||"auto"===Ee.value.style.overflowY,t>0&&(Ze.value=t)}}else Ee.value&&null!=Ze.value&&(Ee.value.style.height=`${Ze.value}px`),el=2,O(()=>{je.value||Ae||(Nn(!0),Dn(!0))})}function go(){if(!Jn.value)return;const e=Te.value;if(Fe.value){const l="html"===e?"text/html":"image/svg+xml",t="html"===e?Ne("artifacts.htmlPreviewTitle")||"HTML Preview":Ne("artifacts.svgPreviewTitle")||"SVG Preview";return void p("previewCode",{node:s.node,artifactType:l,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(ht.value=!ht.value)}function yo(e,l={}){if(!sl||Ae)return null;if(!1===s.stream&&!1!==s.loading)return null;if(Do(),$o())return null;if(Yl.value||Ee.value!==e)return null;if(Qn())return null;if(Sl)return Sl;if(qe.value&&Ve.value)return Promise.resolve();const t=No(),n=Zl.value;let o=!1;qe.value=!0,function(){const e=be.value;pe&&e&&Qe!==e&&(Qe&&pe.markSettled(Qe),Qe=e,pe.markPending(e))}();const a=d(null,null,function*(){try{yield function(e){return d(this,null,function*(){var l,t;if(!sl||Ae)return;Ge=!1;const n=Gl.value;if(at=!1,Kl.value=!1,Ql.value=null,Ie.value=!1,Jl.value=!1,Xl.value=!1,St.value=null,Ct.value=null,Mt.value=null,Bt.value=null,En(),function(){if(lt.value=!1,_t())return void(It.value=null);const e=jt.value;It.value=Ve.value||null==e?null:e}(),On(),Fn(),function(e){e.replaceChildren()}(e),Po(),yield ne(Mo()),Ae)return;const o=d(null,null,function*(){var l,t;if("diff"===n){!function(){if(Hl||"undefined"==typeof window)return;Hl=!0;const e=e=>{var l;Rl("reason"in e?e.reason:null!=(l=e.error)?l:e.message)&&(e.preventDefault(),e.stopImmediatePropagation())};window.addEventListener("error",e,!0),window.addEventListener("unhandledrejection",e,!0),Ol=()=>{window.removeEventListener("error",e,!0),window.removeEventListener("unhandledrejection",e,!0),Hl=!1,Ol=null}}(),wl();const n=Ll(String(null!=(l=s.node.originalCode)?l:""),String(null!=(t=s.node.updatedCode)?t:""));vl?yield vl(e,n.original,n.updated,Le.value):yield sl(e,s.node.code,Le.value)}else yield sl(e,pt.value,Le.value);Ie.value=!0}),a=o.finally(()=>{Cl===a&&(Cl=null)});if(Cl=a,yield function(e){return d(this,null,function*(){if(!$l.value)return void(yield e);let l,t=!1;for(e.then(()=>{t=!0},e=>{t=!0,l=e});;){if(Ae)return;if(t){if(l)throw l;return}if(jn()&&An())return;yield O(),yield nn()}})}(a),Ae)return;if(Gl.value!==n)return;Ie.value=!0;const r=null==(l=s.codeBlockOptions)?void 0:l.fontSize;if("number"==typeof r&&Number.isFinite(r)&&r>0){const e="diff"===n?yl():gl();null==(t=null==e?void 0:e.updateOptions)||t.call(e,{fontSize:r}),kt.value=r,xt.value=r}else if(!kn()){const e=an();e&&e>0?(kt.value=e,xt.value=e):(kt.value=12,xt.value=12)}for(wn();Ge;)if(Ge=!1,yield Co(),Ae)return;Re.value||je.value||Nn(!1),Ve.value=!0,Ul.value=n,function(){var e,l,t,n,o;if(On(),$l.value){const n=yl(),o=null==(e=null==n?void 0:n.getOriginalEditor)?void 0:e.call(n),a=null==(l=null==n?void 0:n.getModifiedEditor)?void 0:l.call(n),i=(e,l)=>{try{const t=null==e?void 0:e[l];if("function"!=typeof t)return;const n=t.call(e,()=>Tn());n&&Fl.push(n)}catch(t){}};try{const e=null==(t=null==n?void 0:n.onDidUpdateDiff)?void 0:t.call(n,()=>{Tn(),fe(()=>vn())});e&&Fl.push(e)}catch(r){}i(o,"onDidContentSizeChange"),i(a,"onDidContentSizeChange");const u=Ee.value;if(u&&"undefined"!=typeof MutationObserver){const e=["diffs-container",".stream-diffs-shell",".stream-diffs-surface"].join(","),l=l=>{var t;const n=l instanceof HTMLElement?l:l.parentElement;return Boolean(null==(t=null==n?void 0:n.closest)?void 0:t.call(n,e))},t=l=>{var t,n;const o=l instanceof HTMLElement?l:l.parentElement;return Boolean((null==(t=null==o?void 0:o.closest)?void 0:t.call(o,e))||(null==(n=null==o?void 0:o.querySelector)?void 0:n.call(o,e)))},n=new MutationObserver(e=>{$l.value&&Wn()&&e.some(e=>l(e.target)||Array.from(e.addedNodes).some(t)||Array.from(e.removedNodes).some(l))&&($n(),Nn({preferModelDiffHeight:!0}),Dn(),zn())});n.observe(u,{attributeFilter:["class"],attributes:!0,childList:!0,characterData:!0,subtree:!0}),Fl.push({dispose:()=>n.disconnect()})}if(u&&"undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{if(!$l.value)return;if(Dn(),!Wn())return;const e=yn(u);null!=e&&(Math.ceil(u.getBoundingClientRect().height||0)<=e+1||($n(),Nn({preferModelDiffHeight:!0}),Dn()))});e.observe(u),Fl.push({dispose:()=>e.disconnect()})}return}const a=gl();try{const e=null==(n=null==a?void 0:a.onDidContentSizeChange)?void 0:n.call(a,()=>Tn());e&&Fl.push(e)}catch(r){}try{const e=null==(o=null==a?void 0:a.onDidLayoutChange)?void 0:o.call(a,()=>Tn());e&&Fl.push(e)}catch(r){}}(),Sn(),wn(),$n(),vn(),Tn(),yield O();let i=null;xl&&(i=yield xl(),i&&(yield O(),yield nn()));const u=null==i?"diff"===n?yield Gn():yield function(){return d(this,null,function*(){if(Vn())return yield O(),yield nn(),Vn();for(let e=0;e<30;e++){if(Ae||$l.value)return!1;const e=Ee.value,l=In(),t=qn(e),n=!pt.value.trim()||dn(e);if(l&&t&&n&&(yield O(),yield nn(),!Ae&&!$l.value&&In()&&qn(Ee.value)&&(!pt.value.trim()||dn(Ee.value))))return!0;yield O(),yield nn()}return!1})}():i;Ae||(u?(wn(),ln(),(yield Qt())||To()):To())})}(e),tt=null}catch(a){const e=No(),r=n!==Zl.value,i=!1!==l.allowStaleContentRetry&&r&&tt!==e;if(t!==e||i)return i&&(tt=e),o=!0,qe.value=!1,Ve.value=!1,Ie.value=!1,void(Jl.value=!1);throw To(t),a}}).finally(()=>{Sl===a&&(Sl=null),function(){const e=Qe;pe&&e&&(Qe="",O(()=>{var l,t;if(!Ae){const n=null!=(t=null==(l=De.value)?void 0:l.offsetHeight)?t:0;n>0&&pe.reportHeight(e,n)}pe.markSettled(e)}))}(),o&&!Ae&&queueMicrotask(()=>{var e;const l=Ee.value;l&&!Ae&&(null==(e=yo(l))||e.catch(e=>{Ve.value=!1,Jl.value=!1,To()}))})});return Sl=a,a}P(fo,e=>{e||Z()}),P(()=>xt.value,(e,l)=>{var t;const n=$l.value?yl():gl();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(null==(t=n.updateOptions)||t.call(n,{fontSize:e}),je.value||Nn(!0))},{flush:"post",immediate:!1});let bo=0;const wo=P(()=>[Ee.value,$l.value,s.stream,s.loading,We.value,rl.value,s.node.language,s.node.raw,s.node.code,s.node.loading],e=>d(null,[e],function*([e,l,t,n,o,a]){const r=++bo;if(!e)return;if(!a)return;if(Xn())return;if(nt)return;if(!1===t&&!1!==n)return;if(!sl){if(yield function(){return d(this,null,function*(){if("undefined"==typeof window||Ae)return;if(We.value||Yl.value)return;if(Ml)return Ml;const e=d(null,null,function*(){try{const e=yield he();if(Ae)return;if(!e)return void(Yl.value=!0);yt(e)}catch(e){if(Ae)return;Yl.value=!0}}).finally(()=>{Ml===e&&(Ml=null)});return Ml=e,e})}(),r!==bo)return;if(!1===s.stream&&!1!==s.loading)return;if(Qn())return;if(!rl.value)return;if(!sl||Yl.value||qe.value||$o()||Ae||Ee.value!==e)return}if(Qn())return;const i=yo(e);if(i){try{yield i}catch(u){Ve.value=!1,Jl.value=!1,To()}Ve.value&&Jl.value&&wo()}}));function ko(e){return"string"==typeof e?e:null}function xo(e,l){if(e===l)return!0;const t=ko(e),n=ko(l);return!!t&&t===n}function So(){return te({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})}function Co(){return d(this,arguments,function*(e={}){Po();const l=()=>{$l.value&&jl(),fe(()=>{Sn(),Tn()})};if(e.appearanceOnly)return void l();const t=So();if(t)try{yield ne(Mo()),yield Pl(t),l()}catch(n){}else l()})}function Mo(){const e=s.themes;return e&&"string"==typeof e[0]&&"string"==typeof e[1]?{dark:e[0],light:e[1]}:So()}function Bo(){var e,l,t,n,o;const a=Dt.value,r=u(i({},ql.value||{}),{wordWrap:"wrap"===a.overflow?"on":"off",overflow:a.overflow,themes:s.themes,stream:!1,MAX_HEIGHT:null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500,fontSize:Ht.value,lineHeight:Ft.value,theme:So(),themeType:s.isDark?"dark":"light",disableLineNumbers:!b.value,disableFileHeader:!0,workerManager:null!=(o=null!=(n=null==(t=ql.value)?void 0:t.workerManager)?n:oe())?o:void 0,onThemeChange(){Sn()}}),d=function(){var e;const l=null==(e=ql.value)?void 0:e.fontFamily;return"string"==typeof l&&l.trim()?l.trim():$l.value?function(){var e;if("undefined"==typeof window)return;const l=null==(e=De.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l)return;return window.getComputedStyle(l).fontFamily.trim()||void 0}():void 0}();d&&(null!=r.fontFamily||(r.fontFamily=d));const v="string"==typeof r.unsafeCSS?r.unsafeCSS:"",c=`\n[data-file] [data-line],\n[data-diff] [data-line] {\n white-space: ${"wrap"===(f=a.overflow)?"pre-wrap":"pre"} !important;\n overflow-wrap: ${"wrap"===f?"anywhere":"normal"} !important;\n word-break: normal !important;\n}`;var f;return r.unsafeCSS=`[data-file], [data-diff] { --diffs-min-number-column-width-default: 2ch !important; }\n${c}\n\n[data-no-newline],\n[data-gutter-buffer="metadata"] {\n --diffs-computed-decoration-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-computed-diff-line-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-computed-selected-line-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-line-bg: var(--markstream-diff-metadata-bg) !important;\n color: var(--markstream-diff-metadata-fg) !important;\n background-color: var(--markstream-diff-metadata-bg) !important;\n}\n${v}`.trim(),r}function Po(){const e=Bo();if(!El)return El=e,El;for(const l of Object.keys(El))l in e||delete El[l];return Object.assign(El,e),El}P(Gl,(e,l)=>d(null,null,function*(){if(e===l)return;if(Kl.value||nt)return;if(to(),!sl||!Ee.value)return;if(!qe.value)return;if(!1===s.stream&&!1!==s.loading)return;if(!rl.value)return;const t=Sl;if(t){try{yield t}catch(n){}if(Ae||!Ee.value)return}if(Ul.value!==e||!qe.value||!Ve.value)try{Ve.value=!1,Jl.value=!1,qe.value=!1,Ie.value=!1,On(),Fn(),wl(),yield O(),yield yo(Ee.value)}catch(o){Ve.value=!1,Jl.value=!1,To()}}));const Ho=M(0),Oo=v(()=>String(Ho.value));let Fo=!1;function No(){var e;const l=So();return JSON.stringify({kind:Gl.value,language:Le.value,structural:Oo.value,optionsRevision:Ho.value,settledContentGeneration:et.value,theme:null!=(e=ko(l))?e:null==l?null:"custom",isDark:s.isDark})}P(()=>{var e;return null==(e=s.codeBlockOptions)?void 0:e.fontSize},e=>{const l="number"==typeof e&&Number.isFinite(e)&&e>0?e:bt;kt.value=l,xt.value=l,St.value=null,Ct.value=null,Mt.value=null}),P(()=>[s.codeBlockOptions,s.showLineNumbers],()=>{Ho.value+=1,!1===s.stream&&!1!==s.loading&&(Fo=!0)},{deep:!0}),P(()=>[pt.value,s.node.originalCode,s.node.updatedCode],()=>{Zl.value+=1,Xn()||(et.value+=1)});const Eo=v(()=>No());function Do(){Kl.value&&Ql.value!==Eo.value&&(Kl.value=!1,Ql.value=null,tt=null,ot=null,qe.value=!1,Ve.value=!1,Ie.value=!1,Jl.value=!1,Xl.value=!1)}function $o(){return Do(),Kl.value&&Ql.value===Eo.value}function To(e=Eo.value){Ql.value=e,Kl.value=!0,Xl.value=!1}return P(Eo,()=>d(null,null,function*(){if(nt)return;if(!Kl.value)return;if(Ql.value===Eo.value)return;if(!sl||!Ee.value||Yl.value||Ae||!rl.value)return;if(!1===s.stream&&!1!==s.loading)return;if(Qn())return;const e=Eo.value;nt=!0;try{if(Do(),Kl.value)return;yield yo(Ee.value)}catch(l){Ve.value=!1,Jl.value=!1,To()}finally{ot=e,yield O(),nt=!1}})),P(()=>[s.codeBlockOptions,rl.value],()=>{var e,l;if(Po(),!sl||!rl.value)return;const t=$l.value?yl():gl(),n="number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize)?s.codeBlockOptions.fontSize:Number.isFinite(xt.value)?xt.value:void 0;"number"==typeof n&&Number.isFinite(n)&&n>0&&(null==(l=null==t?void 0:t.updateOptions)||l.call(t,{fontSize:n})),Nn(!1)},{deep:!0}),P(()=>[So(),Vl.value,We.value,qe.value,rl.value],([e,l],t)=>{if(!We.value||!rl.value)return;const n=null!=t&&xo(e,t[0]),o=null!=t&&l!==t[1];Ve.value?(Ge=!1,Co({appearanceOnly:n})):n&&!o||(Ge=!0)},{flush:"post"}),P(()=>[Oo.value,We.value,rl.value],(e,l)=>d(null,[e,l],function*([e,l,t],[n]){if(Po(),!l||!t)return;if(!sl||!Ee.value)return;if(!qe.value)return;if(e===n)return;if(!1===s.stream&&!1!==s.loading)return void(Fo=!0);Fo=!1;const o=Sl;if(o){try{yield o}catch(a){}if(Ae||!Ee.value)return}try{Ve.value=!1,Jl.value=!1,qe.value=!1,Ie.value=!1,On(),Fn(),wl(),Dl&&yt(Dl),yield O(),yield yo(Ee.value,{allowStaleContentRetry:!1})}catch(r){Ve.value=!1,Jl.value=!1,To()}}),{flush:"post"}),P(()=>[s.loading,rl.value],([e,l])=>{!1===e&&l&&Fo&&(Fo=!1,Ho.value+=1)},{flush:"post"}),P(()=>[s.loading,rl.value],(e,l)=>d(null,[e,l],function*([e,l],t){if(!l)return;const n=null==t?void 0:t[0];if(!1===n&&!1!==e&&$l.value&&qe.value&&(yield O(),fe(()=>{d(null,null,function*(){const e=Sl;if(e)try{yield e}catch(l){}!Ae&&$l.value&&!1!==s.loading&&(Po(),jl(),Tn())})})),e)return;const o=void 0!==n&&!1!==n;yield O(),fe(()=>{d(null,null,function*(){var e,l;try{if(o&&(yield function(){return d(this,null,function*(){if(!Kl.value)return!1;if(!sl||!Ee.value||Yl.value||Ae||!rl.value)return!1;if(ot===Eo.value)return!0;nt=!0;try{Kl.value=!1,Ql.value=null,tt=null,qe.value=!1,Ve.value=!1,Ie.value=!1,Jl.value=!1,On(),Fn(),wl(),Dl&&yt(Dl),yield O();try{yield yo(Ee.value)}catch(e){Ve.value=!1,Jl.value=!1,To()}}finally{yield O(),nt=!1}return!0})}()))return void Nn(!1);if(o&&$l.value&&qe.value&&at&&Ee.value)return at=!1,Ve.value=!1,Jl.value=!1,qe.value=!1,Ie.value=!1,On(),Fn(),wl(),yield O(),yield yo(Ee.value,{allowStaleContentRetry:!1}),void zn(!0);if(o&&qe.value)if($l.value&&Ee.value){const n=Sl;if(n)try{yield n}catch(t){}Po();const o=Ll(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:""));if(yield Un(o.original,o.updated,Le.value),Ae||!$l.value)return;yield Promise.resolve(hl()),jl(),Dn(!0),Kt(),$n(),vn();const a=yield Gn();Ae||!a||Jl.value||(yield Qt()),Tn(),zn(!0)}else to(),oo(pt.value,Le.value),yield new Promise(e=>{const l=()=>{Ae?e():eo||Zn?setTimeout(l,16):e()};l()}),Ae||$l.value||(yield Promise.resolve(ml()));o&&$l.value?(Nn({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),zn(!0)):Nn(!1)}catch(n){}})})}),{immediate:!0,flush:"post"}),f(()=>{On(),Fn(),bl(),null==Ol||Ol()}),(l,t)=>{var n;return Yl.value?(m(),h(ve,{key:0,style:F(Gt.value),node:gt.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":rt.value,"diff-hide-unchanged-regions":it.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Dt.value,"reserved-height-px":$l.value&&null!=(n=Bt.value)?n:void 0,"is-dark":s.isDark,theme:s.theme,"dark-theme":s.darkTheme,"light-theme":s.lightTheme,themes:s.themes,"show-header":s.showHeader,"show-copy-button":s.showCopyButton,"show-tooltips":s.showTooltips},N({_:2},[l.$slots["header-left"]?{name:"header-left",fn:E(()=>[D(l.$slots,"header-left",{},void 0,!0)]),key:"0"}:void 0,l.$slots["header-right"]?{name:"header-right",fn:E(()=>[D(l.$slots,"header-right",{},void 0,!0)]),key:"1"}:void 0]),1032,["style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","code-block-options","resolved-visual-options","reserved-height-px","is-dark","theme","dark-theme","light-theme","themes","show-header","show-copy-button","show-tooltips"])):(m(),$("div",{key:1,ref_key:"container",ref:De,style:F(co.value),class:y(["code-block-container rounded-lg border",[{dark:s.isDark,"is-rendering":s.loading,"is-dark":Wl.value,"is-diff":$l.value,"is-plain-text":_e.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":Jl.value&&!Yl.value?"true":"false","data-markstream-enhancement-state":mt.value,"data-markstream-code-block-state":Xn()?"streaming":"settled","data-markstream-pending":ft.value?"true":void 0,"data-markstream-viewport-pending":dl.value&&k(ol)&&!rl.value?"true":void 0},[T(ce,{"show-header":s.showHeader,"show-collapse-button":s.showCollapseButton,"show-font-size-buttons":s.showFontSizeButtons,"enable-font-size-control":s.enableFontSizeControl,"show-copy-button":s.showCopyButton,"show-expand-button":s.showExpandButton,"show-preview-button":s.showPreviewButton,"show-tooltips":s.showTooltips,"is-dark":s.isDark,loading:s.loading,stream:e.stream,"is-collapsed":je.value,"is-expanded":Re.value,"copy-text":$e.value,"is-previewable":Jn.value,"code-font-size":xt.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":kt.value,"font-baseline-ready":Pt.value,"diff-stats":$l.value?Tl.value:null,"diff-stats-aria-label":zl.value,onToggleCollapse:po,onDecreaseFont:mn,onResetFont:hn,onIncreaseFont:fn,onCopy:mo,onToggleExpand:ho,onPreview:go},N({"header-left":E(()=>[D(l.$slots,"header-left",{},()=>[g("div",xe,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:vo.value},null,8,Se),g("div",Ce,[g("div",Me,w(uo.value),1),so.value?(m(),$("div",Be,w(so.value),1)):L("",!0)])])],!0)]),loading:E(()=>[D(l.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[t[0]||(t[0]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))],!0)]),default:E(()=>{var l;return[z(g("div",{class:y(["code-editor-layer",{"code-editor-layer--collapsed":je.value}])},[g("div",{ref_key:"codeEditor",ref:Ee,class:y(["code-editor-container",e.stream?"":"code-height-placeholder"]),"data-markstream-host-hidden":ct.value?"true":void 0,style:F(Jt.value)},null,14,Pe),vt.value?(m(),h(ve,{key:0,style:F(Gt.value),node:gt.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":rt.value,"diff-hide-unchanged-regions":it.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Dt.value,"reserved-height-px":$l.value&&null!=(l=Bt.value)?l:void 0,"is-dark":s.isDark,theme:s.theme,"dark-theme":s.darkTheme,"light-theme":s.lightTheme,themes:s.themes,"show-toolbar":!1},null,8,["style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","code-block-options","resolved-visual-options","reserved-height-px","is-dark","theme","dark-theme","light-theme","themes"])):L("",!0)],2),[[_,!!e.stream||!e.loading]]),ht.value&&!Fe.value&&Jn.value&&"html"===Te.value?(m(),h(we,{key:0,code:s.node.code,"html-preview-allow-scripts":s.htmlPreviewAllowScripts,"html-preview-sandbox":s.htmlPreviewSandbox,"is-dark":s.isDark,"on-close":()=>ht.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):L("",!0)]}),_:2},[l.$slots["header-right"]?{name:"header-right",fn:E(()=>[D(l.$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,ke))}}}),[["__scopeId","data-v-88f3c04a"]]);export{He as default};
|
|
1
|
+
var e=Object.defineProperty,l=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,r=(l,t,n)=>t in l?e(l,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[t]=n,i=(e,l)=>{for(var t in l||(l={}))o.call(l,t)&&r(e,t,l[t]);if(n)for(var t of n(l))a.call(l,t)&&r(e,t,l[t]);return e},u=(e,n)=>l(e,t(n)),d=(e,l,t)=>new Promise((n,o)=>{var a=e=>{try{i(t.next(e))}catch(l){o(l)}},r=e=>{try{i(t.throw(e))}catch(l){o(l)}},i=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,r);i((t=t.apply(e,l)).next())});import{defineComponent as s,computed as v,onMounted as c,onUnmounted as f,openBlock as m,createBlock as h,Teleport as p,createElementVNode as g,normalizeClass as y,withModifiers as b,toDisplayString as w,unref as k,useAttrs as x,inject as S,getCurrentInstance as C,ref as M,shallowRef as B,watch as P,onBeforeUnmount as H,nextTick as O,normalizeStyle as F,createSlots as N,withCtx as D,renderSlot as E,createElementBlock as $,createVNode as T,withDirectives as z,createCommentVNode as L,vShow as _}from"vue";import{az as R,G as j,M as q,ak as I,aB as V,aC as W,ay as A,ab as G,am as U,ai as Y,b as J,c as X,an as K,ah as Q,a9 as Z,ae as ee,al as le,au as te,a8 as ne,Y as oe}from"./exports.js";import{M as ae,f as re,n as ie,c as ue,l as de}from"./index2.js";import{r as se,_ as ve,a as ce}from"./PreCodeBlock.vue_vue_type_style_index_0_lang.js";import{safeRaf as fe,safeCancelRaf as me}from"./utils/safeRaf.js";import{getStreamDiffsRuntime as he}from"./streamDiffs.js";const pe={class:"html-preview-frame__header"},ge={class:"html-preview-frame__title"},ye={class:"html-preview-frame__label"},be=["sandbox","srcdoc"],we=/* @__PURE__ */j(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){const l=e,t=void 0!==import.meta&&Boolean(!1);let n=null;const{t:o}=R(),a=v(()=>{const e=l.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${l.isDark?"#020617":"#ffffff"};\n color: ${l.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`}),r=v(()=>{return e=l.htmlPreviewSandbox,o=l.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!t||"undefined"==typeof console||n===e)return;const l=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);l.has("allow-scripts")&&l.has("allow-same-origin")&&(n=e,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."))}(e),e):void 0!==e?"":!0===o?"allow-scripts":"";var e,o});function i(e){var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=l.onClose)||t.call(l)}return c(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",i)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",i)}),(e,t)=>(m(),h(p,{to:"body"},[g("div",{class:y(["markstream-vue",{dark:l.isDark}])},[g("div",{class:"html-preview-frame__backdrop",onClick:t[2]||(t[2]=e=>{var t;return null==(t=l.onClose)?void 0:t.call(l)})},[g("div",{class:"html-preview-frame",onClick:t[1]||(t[1]=b(()=>{},["stop"]))},[g("div",pe,[g("div",ge,[t[3]||(t[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",ye,w(l.title||k(o)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:"html-preview-frame__close",onClick:t[0]||(t[0]=e=>{var t;return null==(t=l.onClose)?void 0:t.call(l)})}," × ")]),g("iframe",{class:"html-preview-frame__iframe",sandbox:r.value,referrerpolicy:"no-referrer",srcdoc:a.value},null,8,be)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]),ke=["data-markstream-enhanced","data-markstream-enhancement-state","data-markstream-code-block-state","data-markstream-pending","data-markstream-viewport-pending"],xe={class:"code-header-main"},Se=["innerHTML"],Ce={class:"code-header-copy"},Me={class:"code-header-title"},Be={key:0,class:"code-header-caption"},Pe=["data-markstream-host-hidden"],He=/* @__PURE__ */j(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},codeBlockOptions:{},showLineNumbers:{type:Boolean,default:void 0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:void 0},lightTheme:{default:void 0},isShowPreview:{type:Boolean,default:!0},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:{},estimatedDiffInline:{type:Boolean}},emits:["previewCode","copy"],setup(e,{emit:l}){var t,n,o,a,r;const s=e,p=l,b=v(()=>{var e,l;return null!=(l=s.showLineNumbers)?l:!0!==(null==(e=s.codeBlockOptions)?void 0:e.disableLineNumbers)}),j=x(),pe=S(ae,null),ge=S("markstreamHostScrollManaged",null),ye=S(q,void 0),be=v(()=>I(s,j));function He(e,l){}const Oe=C(),Fe=v(()=>{const e=null==Oe?void 0:Oe.vnode.props;return!(!e||!e.onPreviewCode&&!e["onPreview-code"])}),{t:Ne}=R(),De=M(null),Ee=M(null),$e=M(!1),Te=M(Kn(s.node.language,s.node.code,Xn())),ze=v(()=>re(Te.value)),Le=v(()=>"plaintext"===ze.value?"text":ze.value),_e=v(()=>"plaintext"===ze.value),Re=M(!1),je=M(!1),qe=M(!1),Ie=M(!1),Ve=M(!1),We=M(!1);let Ae=!1,Ge=!1,Ue=null,Ye=null,Je=null,Xe=0,Ke=!1,Qe="";const Ze=M(null);let el=0,ll=!1;const tl=V(),nl=W(),ol=A(),al=B(null),rl=M("undefined"==typeof window||!ol.value),il=null!=(o=null==(n=null==(t=C())?void 0:t.vnode.el)?void 0:n.textContent)?o:"",ul="undefined"!=typeof window&&String(null!=(a=s.node.code)?a:"").length>0&&il.includes(String(s.node.code)),dl=M(!ul);c(()=>{dl.value=!0}),"undefined"!=typeof window&&P([()=>Ee.value,ol],([e,l],t,n)=>{var o,a,r;if(null==(o=al.value)||o.destroy(),al.value=null,!l||rl.value)return void(rl.value=!0);if(!e)return void(rl.value=!1);let i=!0;const u=null!=(r=null!=(a=null==nl?void 0:nl.value.heavyBlockMargin)?a:null==nl?void 0:nl.value.rootMargin)?r:"0px",d=tl(e,{rootMargin:u,allowIdle:!1});al.value=d,rl.value=rl.value||d.isVisible.value,d.whenVisible.then(()=>{i&&al.value===d&&(rl.value=!0)}).catch(()=>{}),n(()=>{i=!1,d.destroy(),al.value===d&&(al.value=null)})},{immediate:!0}),H(()=>{var e;Ae=!0,function(){const e=Qe;pe&&e&&(Qe="",pe.markSettled(e))}(),null==(e=al.value)||e.destroy(),al.value=null});let sl=null,vl=null,cl=()=>{},fl=()=>{},ml=()=>{},hl=()=>{},pl=()=>null,gl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),yl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),bl=()=>{},wl=()=>{},kl=()=>{},xl=null,Sl=null,Cl=null,Ml=null,Bl=()=>{var e;return String(null!=(e=s.node.language)?e:"plaintext")},Pl=()=>d(null,null,function*(){}),Hl=!1,Ol=null;const Fl=[],Nl=[];let Dl=null,El=null;const $l=v(()=>G(s.node)),Tl=M({removed:0,added:0}),zl=v(()=>`-${Tl.value.removed} +${Tl.value.added}`);function Ll(e,l){return{original:e,updated:l}}function _l(e){return String(null!=e?e:"").replace(/\r\n$|\n$|\r$/,"")}function Rl(e){var l;return String(null!=(l=null==e?void 0:e.message)?l:e).includes("no diff result available")}function jl(){if(!In())try{const e=kl();e&&"function"==typeof e.catch&&e.catch(e=>{Rl(e)})}catch(e){Rl(e)}}const ql=v(()=>{const e=i({},s.codeBlockOptions||{});for(const n of["theme","themes","themeType","language","languages","stream","disableFileHeader","onThemeChange","renderCustomHeader","renderHeaderMetadata","renderHeaderPrefix","maxHeight","padding","tabSize"])delete e[n];if(!$l.value)return e;const l=e.parseDiffOptions&&"object"==typeof e.parseDiffOptions?e.parseDiffOptions:{},t={diffStyle:"split",expandUnchanged:!1,collapsedContextThreshold:5,hunkSeparators:"line-info",parseDiffOptions:{context:2}};return u(i(i({},t),e),{parseDiffOptions:i(i({},t.parseDiffOptions),l)})}),Il=v(()=>{return(void 0!==s.theme?(e=s.theme)&&"object"==typeof e&&"light"in e&&"dark"in e:!xo(s.darkTheme,s.lightTheme))?!!s.isDark:function(e){var l;const t=null!=(l=ko(e))?l:"";return ee(t,!0===s.isDark)}(So());var e}),Vl=v(()=>($l.value,Il.value?"dark":"light")),Wl=v(()=>$l.value?"dark"===Vl.value:Il.value),Al=v(()=>U({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})),Gl=v(()=>$l.value?"diff":"single"),Ul=M(Gl.value),Yl=M(!1),Jl=M(!1),Xl=M(!1),Kl=M(!1),Ql=M(null),Zl=M(0),et=M(0),lt=M(!1);let tt=null,nt=!1,ot=null,at=!1;const rt=v(()=>{var e;return!!$l.value&&"unified"===(null==(e=ql.value)?void 0:e.diffStyle)}),it=v(()=>Y(ql.value));function ut(e){return!0===(null==ge?void 0:ge.value)||!!e&&(!!e.closest('[data-markstream-virtual-timeline="1"], .markstream-virtual-timeline')||Boolean(e.closest(".vue-recycle-scroller, [data-virtualizer], [data-virtual-scroll-root]")))}const dt=v(()=>ut(Ee.value)),st=v(()=>!(Yl.value||!Kl.value&&Jl.value)),vt=v(()=>st.value),ct=v(()=>st.value&&!Xl.value),ft=v(()=>!Yl.value&&!Kl.value&&st.value),mt=v(()=>Jl.value&&!Yl.value?"ready":Kl.value?"fallback":"pending"),ht=M(!1),pt=v(()=>_l(s.node.code)),gt=v(()=>$l.value?!0===s.node.diff?s.node:u(i({},s.node),{diff:!0}):pt.value===s.node.code?s.node:u(i({},s.node),{code:pt.value}));function yt(e){const l=e.detectLanguage;"function"==typeof l&&(Bl=l),El=e,Dl=Bo();const t=e.createCodeBlockRuntime(Dl);return!!t&&(sl=t.createEditor||sl,vl=t.createDiffEditor||vl,cl=t.updateCode||cl,fl=t.updateDiff||fl,ml=t.finalizeCode||ml,hl=t.finalizeDiff||hl,pl=t.getEditor||pl,gl=t.getEditorView||gl,yl=t.getDiffEditorView||yl,bl=t.cleanupEditor||bl,wl=t.safeClean||t.cleanupEditor||wl,kl=t.refreshDiffPresentation||kl,Pl=t.setTheme||Pl,xl=t.whenVisualReady||null,We.value=!0,!0)}const bt=J,wt=X,kt=M("number"==typeof(null==(r=s.codeBlockOptions)?void 0:r.fontSize)?s.codeBlockOptions.fontSize:Number.NaN),xt=M(kt.value),St=M(null),Ct=M(null),Mt=M(null),Bt=M(null),Pt=v(()=>{const e=kt.value,l=xt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof l&&Number.isFinite(l)&&l>0}),Ht=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.fontSize;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l;const t=xt.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:bt}),Ot=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.lineHeight;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:Ht.value===bt?wt:Math.max(12,Math.round(1.5*Ht.value))}),Ft=v(()=>Ot.value),Nt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.tabSize;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:4}),Dt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding,t="number"==typeof l&&Number.isFinite(l)&&l>=0?l:8;return{top:t,bottom:t}}),Et=v(()=>{const e=K(s.codeBlockOptions);return u(i({},e),{fontSize:Ht.value,lineHeight:Ft.value,maxHeight:Yn(),padding:Dt.value.top,paddingBottom:Dt.value.bottom,tabSize:Nt.value})}),$t=v(()=>{const e=s.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function Tt(e){if(null==e)return null;const l=Math.ceil(e);return!Number.isFinite(l)||l<=0?null:Math.min(l,Math.ceil(Yn()))}function zt(){return!$l.value&&!1!==s.stream&&!1!==s.loading}const Lt=M(zt());function _t(){return zt()||Lt.value}const Rt=v(()=>$l.value?null:null==$t.value||_t()?Math.ceil((e=>{const l=String(null!=e?e:"");if(!l)return 1;let t=1;for(let n=0;n<l.length;n++)"\n"===l[n]?t++:"\r"===l[n]&&(t++,"\n"===l[n+1]&&n++);return t})(pt.value)*Ft.value+1):null),jt=v(()=>{if($l.value)return null;const e=$t.value;return null==e||_t()?Tt(Rt.value):Tt(e)}),qt=v(()=>{const e=s.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),It=M(null);function Vt(){const e=It.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}const Wt=v(()=>{const e=Vt();return null!=e?e:!$l.value&<.value?null:st.value||!Jl.value?jt.value:null});function At(e){const l=e?"hsl(152 42% 60%)":"var(--diff-added-fg)",t=e?"hsl(0 58% 58%)":"var(--diff-removed-fg)",n=e?"color-mix(in lab, #121212 80%, #4d9375)":"color-mix(in lab, #ffffff 88%, #1e754f)",o=e?"color-mix(in lab, #121212 80%, #cb7676)":"color-mix(in lab, #ffffff 88%, #ab5959)";return{"--markstream-diff-line-number-bg":"var(--markstream-diff-editor-bg)","--markstream-diff-added-fg":l,"--markstream-diff-removed-fg":t,"--markstream-diff-added-line":n,"--markstream-diff-removed-line":o,"--markstream-diff-added-line-fill":n,"--markstream-diff-added-number-fill":e?"color-mix(in lab, #121212 85%, #4d9375)":"color-mix(in lab, #ffffff 91%, #1e754f)","--markstream-diff-removed-line-fill":o,"--markstream-diff-removed-number-fill":e?"color-mix(in lab, #121212 85%, #cb7676)":"color-mix(in lab, #ffffff 91%, #ab5959)","--markstream-diff-added-gutter":`linear-gradient(90deg, ${l} 0 4px, transparent 4px 100%)`,"--markstream-diff-removed-gutter":`linear-gradient(90deg, ${t} 0 4px, transparent 4px 100%)`,"--markstream-diff-added-inline":e?"hsl(152 42% 60% / 0.28)":"var(--diff-added-inline-bg)","--markstream-diff-removed-inline":e?"hsl(0 58% 58% / 0.28)":"var(--diff-removed-inline-bg)"}}const Gt=v(()=>{const e=Tt($t.value),l=Tt(Rt.value),t=_t(),n=i({},$l.value||null==e||t?$l.value||null==l?{}:{minHeight:`${l}px`}:{height:`${e}px`,minHeight:`${e}px`});if(n["--markstream-code-fallback-bg"]=Al.value.background,n["--markstream-code-fallback-fg"]=Al.value.foreground,Al.value.builtin&&(n["--markstream-code-theme-bg"]=Al.value.background,n["--markstream-code-theme-fg"]=Al.value.foreground,n["--markstream-code-theme-line-number"]=Al.value.lineNumber),n["--markstream-pre-line-number-top"]=`${Dt.value.top}px`,n["--markstream-pre-line-number-left"]="0px",n["--markstream-pre-line-number-padding-left"]="2ch",n["--markstream-pre-line-number-padding-right"]="1ch",n["--markstream-pre-line-number-separator-width"]="2px",$l.value){n["--markstream-pre-diff-line-height"]=`${Ft.value}px`,n["--markstream-pre-diff-pane-bottom-padding"]=(rt.value,"0px");const e=Bt.value;null!=e&&e>0&&(n.height=`${e}px`,n.minHeight=`${e}px`,n.maxHeight=`${e}px`),Object.assign(n,At(Wl.value))}return n}),Ut=v(()=>null!=Wt.value&&(!Jl.value||null!=Vt())),Yt=v(()=>{const e=Wt.value;if(null==e)return null;if($l.value)return Math.ceil(e);const l=qt.value,t=$t.value;if(null==l||null==t)return Math.ceil(e);const n=Math.max(0,Math.ceil(l)-Math.ceil(t));return Math.ceil(e+n)}),Jt=v(()=>{if($l.value&&st.value)return{};const e=Wt.value;return Ut.value&&null!=e?{minHeight:`${e}px`}:{}});function Xt(){It.value=null}function Kt(){var e,l,t,n,o,a,r,i;const u=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback"),d=yl(),s=null!=(l=null==u?void 0:u.scrollTop)?l:0;null==(o=null==(n=null==(t=null==d?void 0:d.getOriginalEditor)?void 0:t.call(d))?void 0:n.setScrollTop)||o.call(n,s),null==(i=null==(r=null==(a=null==d?void 0:d.getModifiedEditor)?void 0:a.call(d))?void 0:r.setScrollTop)||i.call(r,s)}function Qt(){return d(this,null,function*(){return $l.value?(kn(),ln(),Dn(!0),Kt(),En(),Xl.value=!0,yield O(),Dn(!0),yield nn(),Dn(!0),bn(),ln(),!!(yield function(){return d(this,null,function*(){var e;if(!$l.value)return!0;for(let l=0;l<4;l++){const l=ln();Dn(!0),Zt(l),en(l),yield O(),yield nn();const t=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!t)return!1;if(null==l)return Rn();const n=t.getBoundingClientRect().height;if(n>0&&Math.abs(n-l)<=2)return!0}return!1})}())&&(Jl.value=!0,yield O(),ln(),Dn(!0),bn(),En(),fe(()=>{Ae||fe(()=>{Ae||(function(){var e,l;const t=null==(e=Ee.value)?void 0:e.querySelector(".code-block-shell-content"),n=null==(l=Ee.value)?void 0:l.querySelector(".code-editor-layer");t&&n&&(n.style.removeProperty("height"),n.style.removeProperty("min-height"),t.style.removeProperty("height"),t.style.removeProperty("min-height"))}(),$n(!0))})}),$n(),!0)):!(xl&&!(yield xl())||(kn(),Dn(!0),Xl.value=!0,yield O(),kn(),Dn(!0),yield nn(),kn(),Dn(!0),Jl.value=!0,yield O(),$n(),0))})}function Zt(e){var l;if(!$l.value)return;const t=De.value,n=null==(l=Ee.value)?void 0:l.querySelector("pre.code-pre-fallback");if(!t||!n)return;const o=null!=e?e:Number.parseFloat(t.style.height||"");if(!Number.isFinite(o)||o<=0)return;const a=Math.ceil(o),r=`${a}px`;Bt.value=a;const i=Ee.value;i&&(i.dataset.markstreamDiffHandoffHeight=r),n.dataset.markstreamDiffHandoffHeight=r,n.style.setProperty("height",r),n.style.setProperty("min-height",r)}function en(e){var l,t,n;if(!$l.value)return;const o=null==(l=Ee.value)?void 0:l.querySelector(".code-block-shell-content"),a=null==(t=Ee.value)?void 0:t.querySelector(".code-editor-layer");if(!o||!a)return;const r="number"==typeof e&&Number.isFinite(e)&&e>0?Math.ceil(e):Number.parseFloat((null==(n=De.value)?void 0:n.style.height)||"");if(!Number.isFinite(r)||r<=0)return;const i=`${r}px`;a.style.height=i,a.style.minHeight=i,o.style.height=i,o.style.minHeight=i}function ln(){const e=De.value;if(e&&Rn(e)){En();const l=gn(e);if(null!=l&&l>0){const t=Math.ceil(l),n=Math.ceil(Yn()),o=Math.min(t,n),a=`${o}px`;return e.style.height=a,e.style.minHeight="0px",e.style.maxHeight=`${n}px`,e.style.overflow=t>n+1?"auto":"hidden",st.value&&(Bt.value=o,Zt(o)),Tn(),o}return Fn({preferModelDiffHeight:!0}),Zt(),Tn(),Number.parseFloat(e.style.height||"")||null}return kn()}function tn(e,l=!1,t={}){const n=Math.ceil(e),o=Vt();if(null==o)return n;const a=!0===t.allowBelowEstimatedFloor;return n>=o||a?((l||a)&&Ve.value&&Xt(),n):o}function nn(){return new Promise(e=>{let l=!1,t=null,n=null;const o=()=>{l||(l=!0,null!=n&&globalThis.clearTimeout(n),null!=t&&me(t),e())};n=globalThis.setTimeout(o,50),t=fe(o)})}function on(){var e;try{const l=De.value;if(!l)return null;const t=null!=(e=l.querySelector(".stream-diffs-shell .stream-diffs-surface"))?e:l.querySelector(".stream-diffs-shell");if(t){const e=Math.ceil(t.getBoundingClientRect().height);if(e>0)return e}}catch(l){}return null}function an(){var e,l,t,n,o,a;try{const a=$l.value?null!=(t=null==(l=null==(e=yl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:yl():gl(),r=pl(),i=null==(n=null==r?void 0:r.EditorOption)?void 0:n.fontInfo;if(a&&null!=i){const e=null==(o=a.getOption)?void 0:o.call(a,i),l=null==e?void 0:e.fontSize;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l}}catch(r){}try{const e=De.value;if(e){const l=null!=(a=e.querySelector(".stream-diffs-shell .stream-diffs-surface"))?a:e.querySelector(".stream-diffs-shell");if(l)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(l).fontSize,t=e&&e.match(/^(\d+(?:\.\d+)?)/);if(t)return Number.parseFloat(t[1])}}catch(r){}}}catch(r){}return null}function rn(e){var l,t;try{const n=pl(),o=null==(l=null==n?void 0:n.EditorOption)?void 0:l.lineHeight;if(null!=o){const l=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o);if("number"==typeof l&&l>0)return l}}catch(a){}const n=on();if(n&&n>0)return n;const o=Number.isFinite(xt.value)&&xt.value>0?xt.value:14;return Math.max(12,Math.round(1.35*o))}function un(){var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding;return"number"==typeof l&&Number.isFinite(l)?2*Math.max(0,l):$l.value?24:0}function dn(e){return!!_e.value||!!e&&(In(e)||null!=xl)}function sn(){var e,l;$l.value?Tl.value=oe(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:"")):Tl.value={removed:0,added:0}}function vn(){var e;if(Number.isFinite(xt.value)&&xt.value>0&&Number.isFinite(kt.value))return xt.value;if("number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize))return kt.value=s.codeBlockOptions.fontSize,xt.value=s.codeBlockOptions.fontSize,s.codeBlockOptions.fontSize;const l=an();return l&&l>0?(kt.value=l,xt.value=l,l):(kt.value=12,xt.value=12,12)}function cn(){const e=vn(),l=Math.min(36,e+1);xt.value=l}function fn(){const e=vn(),l=Math.max(10,e-1);xt.value=l}function mn(){vn(),Number.isFinite(kt.value)&&(xt.value=kt.value)}function hn(){var e,l,t,n,o,a,r,i,u,d,s,v,c,f;try{const m=$l.value?yl():null,h=$l.value?m:gl();if(!h)return null;if((null==m?void 0:m.getOriginalEditor)&&(null==m?void 0:m.getModifiedEditor)){const c=null==(e=m.getOriginalEditor)?void 0:e.call(m),f=null==(l=m.getModifiedEditor)?void 0:l.call(m);null==(t=null==c?void 0:c.layout)||t.call(c),null==(n=null==f?void 0:f.layout)||n.call(f);const h=(null==(o=null==c?void 0:c.getContentHeight)?void 0:o.call(c))||0,p=(null==(a=null==f?void 0:f.getContentHeight)?void 0:a.call(f))||0,g=Math.max(h,p);if(g>0)return Math.ceil(g);const y=(null==(u=null==(i=null==(r=null==c?void 0:c.getModel)?void 0:r.call(c))?void 0:i.getLineCount)?void 0:u.call(i))||1,b=(null==(v=null==(s=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:s.getLineCount)?void 0:v.call(s))||1,w=Math.max(y,b),k=Math.max(rn(c),rn(f)),x=un();return Math.ceil(w*k+x+0)}if(null==h?void 0:h.getContentHeight){null==(c=null==h?void 0:h.layout)||c.call(h);const e=h.getContentHeight();if(e>0)return $l.value||(lt.value=!0),Math.ceil(e)}const p=null==(f=null==h?void 0:h.getModel)?void 0:f.call(h);let g=1;p&&"function"==typeof p.getLineCount&&(g=p.getLineCount());const y=rn(h);return Math.ceil(g*(y+1.5)+0)}catch(m){return null}}function pn(){var e,l;if($l.value)return!1;try{const t=null==(l=null==(e=gl())?void 0:e.getContentHeight)?void 0:l.call(e),n="number"==typeof t&&Number.isFinite(t)&&t>0;return n&&(lt.value=!0),n}catch(t){return!1}}function gn(e){if("undefined"==typeof window)return null;try{if("none"===window.getComputedStyle(e).display)return null;const l=e.querySelector("diffs-container");if(l instanceof HTMLElement){const e=l.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}const t=e.querySelector(".stream-diffs-shell");if(t){const e=t.getBoundingClientRect();if(e.height>0)return Math.ceil(e.height)}return null}catch(l){return null}}function yn(e){var l;const t=String(null!=e?e:"").trim(),n=null==(l=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?void 0:l[1];if(n){const e=3===n.length?n.split("").map(e=>`${e}${e}`).join(""):n;return.2126*Number.parseInt(e.slice(0,2),16)+.7152*Number.parseInt(e.slice(2,4),16)+.0722*Number.parseInt(e.slice(4,6),16)}const o=t.match(/\d+(?:\.\d+)?/g);if(!o||o.length<3)return null;const[a,r,i]=o.slice(0,3).map(Number);return.2126*a+.7152*r+.0722*i}function bn(){var e,l,t;if(wn())return;const n=an();n&&n>0&&(St.value=n,xt.value=n,kt.value=n);try{const n=rn($l.value?null!=(t=null==(l=null==(e=yl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:yl():gl());n&&n>0&&(Ct.value=n)}catch(o){}try{const e=on();e&&e>0&&(Ct.value=e)}catch(o){}}function wn(){return $l.value&&vt.value}function kn(){var e;if(!st.value)return null;const l=De.value,t=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l||!t)return null;const n=Math.ceil(t.getBoundingClientRect().height),o=$l.value?gn(l):null,a=Math.max(n,null!=o&&o>0?Math.ceil(o):0),r=Math.ceil(Yn()),i=Math.min(a,r);return!Number.isFinite(i)||i<=0?null:($l.value&&i>n&&(Bt.value=i),l.style.height=`${i}px`,l.style.minHeight=`${i}px`,l.style.maxHeight=`${r}px`,l.style.overflow=a>r+1?"auto":"hidden",i)}function xn(){var e,l,t,n,o,a,r,i,u;const d=De.value,v=Ee.value;if(!d||!v)return;const c=d;c.style.setProperty("--markstream-diff-metadata-bg",Al.value.background),c.style.setProperty("--markstream-diff-metadata-fg",Al.value.lineNumber),c.style.setProperty("--diffs-tab-size",String(Nt.value)),c.style.setProperty("--diffs-scrollbar-gutter-override","0px"),"number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.padding)?c.style.setProperty("--diffs-gap-block",`${Dt.value.top}px`):c.style.removeProperty("--diffs-gap-block");const f=d.querySelector(".stream-diffs-shell")||d,m=f,h=f;let p=null,g=null,y=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(p=window.getComputedStyle(f),g=m===f?p:window.getComputedStyle(m),y=h===f?p:window.getComputedStyle(h))}catch(M){p=null,g=null,y=null}const b=String(null!=(l=null==p?void 0:p.getPropertyValue("--vscode-editor-foreground"))?l:"").trim(),w=String(null!=(t=null==p?void 0:p.getPropertyValue("--vscode-editor-background"))?t:"").trim(),k=String(null!=(o=null!=(n=null==p?void 0:p.getPropertyValue("--vscode-editor-selectionBackground"))?n:null==p?void 0:p.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?o:"").trim(),x=b||String(null!=(r=null!=(a=null==y?void 0:y.color)?a:null==p?void 0:p.color)?r:"").trim(),S=w||String(null!=(u=null!=(i=null==g?void 0:g.backgroundColor)?i:null==p?void 0:p.backgroundColor)?u:"").trim(),C=function(){var e,l,t,n,o;try{const a=$l.value?null!=(t=null==(l=null==(e=yl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:yl():gl(),r=pl(),i=null==(n=null==r?void 0:r.EditorOption)?void 0:n.fontInfo;if(a&&null!=i){const e=null==(o=a.getOption)?void 0:o.call(a,i),l=null==e?void 0:e.typicalHalfwidthCharacterWidth;if("number"==typeof l&&Number.isFinite(l)&&l>0)return l}}catch(M){}return null}();if(null!=C&&(Mt.value=C),$l.value){const e=(e,l)=>{l?(v.style.setProperty(e,l),c.style.setProperty(e,l)):(v.style.removeProperty(e),c.style.removeProperty(e))};for(const[l,t]of Object.entries(At(v.classList.contains("is-dark"))))e(l,t);return x?(v.style.setProperty("--markstream-diff-editor-fg",x),c.style.setProperty("--vscode-editor-foreground",x)):(v.style.removeProperty("--markstream-diff-editor-fg"),c.style.removeProperty("--vscode-editor-foreground")),S?(v.style.setProperty("--markstream-diff-editor-bg",S),v.style.setProperty("--markstream-diff-panel-bg",S),v.style.setProperty("--markstream-diff-panel-bg-soft",S),v.style.setProperty("--markstream-diff-panel-bg-strong",S),c.style.setProperty("--vscode-editor-background",S),c.style.backgroundColor=S):(v.style.removeProperty("--markstream-diff-editor-bg"),v.style.removeProperty("--markstream-diff-panel-bg"),v.style.removeProperty("--markstream-diff-panel-bg-soft"),v.style.removeProperty("--markstream-diff-panel-bg-strong"),c.style.removeProperty("--vscode-editor-background"),c.style.backgroundColor=""),void(k?c.style.setProperty("--vscode-editor-selectionBackground",k):c.style.removeProperty("--vscode-editor-selectionBackground"))}if(function(e,l,t){if(!_e.value)return!1;const n=yn(e),o=yn(l);return t?null!=n&&n>170||null!=o&&o<110:null!=n&&n<85||null!=o&&o>190}(S,x,v.classList.contains("is-dark")))return c.style.removeProperty("--vscode-editor-foreground"),c.style.removeProperty("--vscode-editor-background"),void c.style.removeProperty("--vscode-editor-selectionBackground");x&&c.style.setProperty("--vscode-editor-foreground",x),S&&c.style.setProperty("--vscode-editor-background",S),k&&c.style.setProperty("--vscode-editor-selectionBackground",k)}P(()=>[s.stream,s.loading,s.node.loading,$l.value],([e,l,t,n])=>{n||!1===e||!1===l||Lt.value?(n||!1===e)&&Lt.value&&(Lt.value=!1):(Lt.value=!0,Xt())},{immediate:!0});let Sn=0,Cn=0;const Mn=/auto|scroll|overlay/i;function Bn(e,l,t){var n;if("undefined"==typeof window)return;if($l.value)return;if(function(e){return dt.value||ut(e)}(e))return;const o=Math.ceil(l),a=Math.ceil(t)-o;if(Math.abs(a)<=1)return;const r=function(e){var l,t;if("undefined"==typeof window)return null;const n=null!=(l=null==e?void 0:e.ownerDocument)?l:document,o=n.scrollingElement||n.documentElement||n.body;let a=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;a&&a!==n.body&&a!==o;){const e=window.getComputedStyle(a),l=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(Mn.test(l)||Mn.test(t))return a;a=a.parentElement}return o}(e);if(!r)return;const i=null!=(n=e.ownerDocument)?n:document,u=r===i.body||r===i.documentElement||r===i.scrollingElement,d=u?0:r.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,a):r.scrollTop+=a)}function Pn(){try{const e=De.value;if(!e)return;const l=e.getBoundingClientRect().height,t=hn();if(null!=t&&t>0){const n=tn(t,!0,{allowBelowEstimatedFloor:!$l.value&&Ve.value&&pn()}),o=Vt();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",void Bn(e,l,n)}const n=Vt();null!=n&&(e.style.minHeight=`${n}px`,e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",Bn(e,l,n))}catch(e){}}function Hn(){for(var e,l;Fl.length>0;)try{null==(l=null==(e=Fl.pop())?void 0:e.dispose)||l.call(e)}catch(t){}null!=Ue&&(me(Ue),Ue=null),null!=Ye&&(me(Ye),Ye=null),null!=Je&&(me(Je),Je=null),Xe=0,Ke=!1}function On(){for(var e;Nl.length>0;)try{null==(e=Nl.pop())||e()}catch(l){}}function Fn(e=!1){je.value||(Re.value?Pn():function(e={}){try{const l=De.value;if(!l)return;const t=l.getBoundingClientRect().height,n=Math.ceil(t||0),o=Yn(),a=n,r=Number.parseFloat(l.style.height||""),i=a>0?a:Number.isFinite(r)&&r>0?Math.ceil(r):0,u=$l.value?function(){var e,l,t,n,o,a,r,i,u,d,s,v;if(In())return null;try{const c=yl(),f=null==(e=null==c?void 0:c.getOriginalEditor)?void 0:e.call(c),m=null==(l=null==c?void 0:c.getModifiedEditor)?void 0:l.call(c);if(!f||!m)return null;const h=(null==(o=null==(n=null==(t=f.getModel)?void 0:t.call(f))?void 0:n.getLineCount)?void 0:o.call(n))||1,p=(null==(i=null==(r=null==(a=m.getModel)?void 0:a.call(m))?void 0:r.getLineCount)?void 0:i.call(r))||1,g=Math.max(h,p),y=Math.max(rn(f),rn(m)),b=un(),w=Math.max(null!=(d=null==(u=f.getContentHeight)?void 0:u.call(f))?d:0,null!=(v=null==(s=m.getContentHeight)?void 0:s.call(m))?v:0);return Math.ceil(Math.max(w,g*y+b+0))}catch(c){return null}}():null,d=$l.value&&Rn(l);if(el>0&&(el--,null!=Ze.value))return void Bn(l,t,zn(l,Ze.value,o,{preserveScrollableOverflow:_n(l)}));if($l.value&&!d&&st.value){const e=kn();if(null!=e){const n=zn(l,e,o,{allowBelowEstimatedFloor:!0});return Dn(!0),void Bn(l,t,n)}}const v=$l.value&&!0===e.preferModelDiffHeight,c=$l.value?gn(l):null,f=!$l.value&&Ve.value&&pn(),m=$l.value&&!1!==s.loading&&(null!=c||null!=u&&a>0&&u<a-1),h=null!=u;let p;if($l.value)if(v){const e=null!=u&&!1===s.loading&&i>0&&u<i-1;p=!1===s.loading&&null!=c?null==u?c:Math.max(c,u):e?u:null!=c&&null!=u?Math.max(c,u,!1!==s.loading?i:0):Math.max(null!=c?c:0,null!=u?u:0,!1!==s.loading?i:0)||null}else p=rt.value&&null!=c||null!=c?h?Math.max(c,u):c:$l.value&&!1!==s.loading?null!=u&&i>0&&u<i-1?u:i>0?i:null:u;else p=hn();if($l.value&&null!=p&&i>0&&(!1!==s.loading||!0===e.holdCurrentDiffHeight)&&(p=Math.max(p,i)),null!=p&&p>0)return void Bn(l,t,zn(l,p,o,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:f||m,preserveScrollableOverflow:_n(l),renderedStreamingDiffHeight:c}));if(null!=Ze.value)return void Bn(l,t,zn(l,Ze.value,o,{preserveScrollableOverflow:_n(l)}));const g=$l.value&&!1!==s.loading?a:Math.max(a,null!=u&&u>0?u:0);if(g>0)return void Bn(l,t,zn(l,g,o));const y=Vt();if(!(null==y||$l.value&&!1!==s.loading&&d))return void Bn(l,t,zn(l,y,o));const b=Number.parseFloat(l.style.height);!Number.isNaN(b)&&b>0?Bn(l,t,zn(l,b,o)):$l.value||Bn(l,t,zn(l,o,o))}catch(l){}}("object"==typeof e?e:{}))}function Nn(){Sn=0,Cn=0}function Dn(e=!1){var l,t,n;if(je.value)return;const o=De.value;if(!o)return;const a=$l.value?yl():gl();if(a&&"function"==typeof a.layout)try{const r=null==(l=o.getBoundingClientRect)?void 0:l.call(o),i=Math.ceil((null!=(t=null==r?void 0:r.width)?t:0)||o.clientWidth||0),u=Math.ceil((null!=(n=null==r?void 0:r.height)?n:0)||o.clientHeight||Number.parseFloat(o.style.height||"")||0);if(i>0&&u>0){if(!e&&i===Sn&&u===Cn)return;Sn=i,Cn=u,a.layout({width:i,height:u})}else Nn(),a.layout()}catch(r){}}function En(){On()}function $n(e=!1){if(Ae||null!=Ue)return;const l=()=>{Ae||(En(),Fn(e),Dn())};Ue=fe(()=>{Ue=null,l(),Ye=fe(()=>{Ye=null,l()})}),Tn()}function Tn(e=!1){if(!$l.value||Ae||!e&&!1===s.loading)return;if(Ke=Ke||e,Xe=Math.max(Xe,e?18:6),null!=Je)return;const l=()=>{if(Je=null,!$l.value||Ae||Xe<=0||!Ke&&!1===s.loading)return Xe=0,void(Ke=!1);Xe--,En(),Fn({preferModelDiffHeight:!0,holdCurrentDiffHeight:Ke}),Dn(),Xe>0?Je=fe(l):Ke=!1};Je=fe(l)}function zn(e,l,t,n={}){var o;const a=$l.value&&!1!==s.loading,r="renderedStreamingDiffHeight"in n?a&&null!=(o=n.renderedStreamingDiffHeight)?o:null:a?gn(e):null,i=null!=r&&r>l+1?r:l,u=Math.min(i,t),d=!0===n.allowBelowEstimatedFloor,v=tn(u,!0===n.clearEstimatedFloor,{allowBelowEstimatedFloor:d}),c=Vt();e.style.minHeight=null==c||d?"0px":`${Math.min(c,Math.ceil(t))}px`,e.style.height=`${v}px`,e.style.maxHeight=`${Math.ceil(t)}px`;const f=!0===n.preserveScrollableOverflow||i>t+1||Ln(e,v);return e.style.overflow=f?"auto":"hidden",v}function Ln(e,l=0){var t;const n=Math.ceil((null==(t=e.getBoundingClientRect)?void 0:t.call(e).height)||0),o=Math.max(l,e.clientHeight||0,n);return o>0&&e.scrollHeight>o+1}function _n(e){var l;return ll||Ln(e,null!=(l=Ze.value)?l:0)}function Rn(e=De.value){return In(e)}function jn(e=De.value){return In(e)}function qn(){var e,l;if(In())return!0;const t=null==(l=null==(e=gl())?void 0:e.getModel)?void 0:l.call(e);return"function"==typeof(null==t?void 0:t.getValue)&&t.getValue()===pt.value}function In(e=De.value){return Boolean(null==e?void 0:e.querySelector("diffs-container"))}function Vn(){return!1!==s.loading||Jl.value}function Wn(){const e=yl();return Boolean("function"==typeof(null==e?void 0:e.getOriginalEditor)||"function"==typeof(null==e?void 0:e.getModifiedEditor)||"function"==typeof(null==e?void 0:e.getLineChanges))}function An(){return d(this,null,function*(){if(!$l.value)return!0;for(let e=0;e<30;e++){if(Ae)return!1;if(In())return yield O(),yield nn(),!Ae&&In();yield O(),yield nn()}return!1})}let Gn="";function Un(e,l,t){return d(this,null,function*(){const n=`${e}\0${l}\0${t}`;if(Gn!==n){try{return yield fl(e,l,t),void(Gn=n)}catch(o){if(!Rl(o))throw o}if(yield O(),yield nn(),!Ae&&$l.value)try{yield fl(e,l,t),Gn=n}catch(o){if(!Rl(o))throw o}}})}function Yn(){var e,l;return null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500}const Jn=v(()=>s.isShowPreview&&("html"===Te.value||"svg"===Te.value));function Xn(){return"boolean"==typeof s.node.loading?s.node.loading:!0===s.loading}function Kn(e,l,t){return!t||function(){var e,l,t;if(!Xn())return!0;const n=String(null!=(e=s.node.raw)?e:""),o=null!=(t=null==(l=n.split(/\r\n|\n|\r/,1)[0])?void 0:l.trimStart())?t:"";return!/^(?:`{3,}|~{3,})/.test(o)||/\r\n|\n|\r/.test(n)}()&&String(null!=l?l:"")?ie(String(null!=e?e:"")):"plain"}function Qn(){return Xn()}let Zn=null,eo=!1,lo=0;function to(){Zn=null,lo++}function no(){return d(this,arguments,function*(e=lo){if(!eo){eo=!0;try{for(;Zn&&!Ae&&!$l.value&&e===lo;){const e=Zn;Zn=null;try{yield Promise.resolve(cl(e.code,e.language)),yield O(),Ae||$l.value||(Fn(!1),Dn())}catch(l){He()}}}finally{eo=!1,!Zn||Ae||$l.value||no()}}})}function oo(e,l){Zn={code:e,language:l},no(lo)}P(()=>[s.node.language,s.node.code,s.node.raw,s.node.loading,s.loading],([e,l,t,n,o])=>{Te.value=Kn(e,l,"boolean"==typeof n?n:!0===o)}),P(()=>[s.node.originalCode,s.node.updatedCode,$l.value],()=>{fe(()=>sn())},{immediate:!0});let ao=0;P(()=>[s.node.originalCode,s.node.updatedCode,Le.value,$l.value,s.stream],e=>d(null,[e],function*([,,,e,l]){var t,n;const o=++ao;if(!e)return;if(Xn())return;if(!1===l&&!qe.value)return;if(!1!==l&&sl&&!qe.value&&De.value)try{yield yo(De.value)}catch(u){}const a=Cl;if(a&&!Ie.value){try{yield a}catch(u){}if(Ae||!$l.value||o!==ao)return}if(o!==ao)return;const r=Ll(String(null!=(t=s.node.originalCode)?t:""),String(null!=(n=s.node.updatedCode)?n:"")),i=!1===s.loading;i&&Po();try{if(yield Un(r.original,r.updated,Le.value),Ae||!$l.value||o!==ao)return;yield O(),Dn(!0),En(),Fn(!1===s.loading||{preferModelDiffHeight:!0}),Dn(!0),$n(!0)}catch(d){return}if(i){if(Ae||!$l.value)return;jl(),En(),sn(),$n(),Tn(!0)}Re.value&&fe(()=>Pn())})),P(()=>s.node.code,e=>d(null,null,function*(){if(Xn())return;if(!1===s.stream)return;if(Te.value||(Te.value=ie(Bl(e))),$l.value)return;const l=Cl;if(l&&!Ie.value){try{yield l}catch(t){}if(Ae||$l.value)return}if(sl&&!qe.value&&De.value)try{yield yo(De.value)}catch(t){}oo(_l(s.node.code),Le.value),Re.value&&fe(()=>Pn())}));const ro=v(()=>{const e=Te.value;return e?ue[e]||e.charAt(0).toUpperCase()+e.slice(1):ue[""]||"Plain Text"}),io=v(()=>{var e;return Q(String(null!=(e=s.node.raw)?e:""),ro.value,$l.value)}),uo=v(()=>io.value.title),so=v(()=>io.value.caption),vo=v(()=>(de.value,se(Te.value||"",ye))),co=v(()=>{const e={};e["--markstream-code-layout-character-width"]=null==Mt.value?"1ch":`${Mt.value}px`,e["--markstream-code-fallback-bg"]=Al.value.background,e["--markstream-code-fallback-fg"]=Al.value.foreground,Al.value.builtin&&(e["--markstream-code-theme-bg"]=Al.value.background,e["--markstream-code-theme-fg"]=Al.value.foreground,e["--markstream-code-theme-line-number"]=Al.value.lineNumber),e["--markstream-diff-added-line-fill"]=Al.value.diffAddedLine,e["--markstream-diff-added-number-fill"]=Al.value.diffAddedNumber,e["--markstream-diff-editor-bg"]=Al.value.background,e["--markstream-diff-removed-line-fill"]=Al.value.diffRemovedLine,e["--markstream-diff-removed-number-fill"]=Al.value.diffRemovedNumber,e["--markstream-diff-shell-bg"]=Al.value.background,e["--markstream-pre-resolved-theme-bg"]=Al.value.background,e["--markstream-pre-resolved-theme-fg"]=Al.value.foreground,e["--markstream-pre-resolved-theme-line-number"]=Al.value.lineNumber;const l=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},t=l(s.minWidth),n=l(s.maxWidth);if(t&&(e.minWidth=t),n&&(e.maxWidth=n),Ut.value&&!$l.value&&!je.value){const l=Yt.value;null!=l&&(e.minHeight=`${l}px`)}return e.color="var(--markstream-code-fallback-fg, var(--markstream-code-theme-fg, var(--markstream-pre-resolved-theme-fg)))",e.backgroundColor="var(--markstream-code-fallback-bg, var(--markstream-code-theme-bg, var(--markstream-pre-resolved-theme-bg)))",$l.value||(e.borderColor="var(--markstream-code-border-color, var(--code-border))"),e}),fo=v(()=>!1!==s.showTooltips);function mo(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(s.node.code)),$e.value=!0,p("copy",s.node.code),setTimeout(()=>{$e.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function ho(){Re.value=!Re.value;const e=$l.value?yl():gl(),l=De.value;e&&l&&(Re.value?(l.style.maxHeight="none",l.style.overflow="visible",Fn(!0)):(l.style.overflow="auto",Fn(!0)))}function po(){var e,l;if(je.value=!je.value,je.value){if(ll=!1,De.value){const t=Math.ceil((null==(l=(e=De.value).getBoundingClientRect)?void 0:l.call(e).height)||0);ll=Ln(De.value,t)||"auto"===De.value.style.overflow||"auto"===De.value.style.overflowY,t>0&&(Ze.value=t)}}else De.value&&null!=Ze.value&&(De.value.style.height=`${Ze.value}px`),el=2,O(()=>{je.value||Ae||(Fn(!0),Dn(!0))})}function go(){if(!Jn.value)return;const e=Te.value;if(Fe.value){const l="html"===e?"text/html":"image/svg+xml",t="html"===e?Ne("artifacts.htmlPreviewTitle")||"HTML Preview":Ne("artifacts.svgPreviewTitle")||"SVG Preview";return void p("previewCode",{node:s.node,artifactType:l,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(ht.value=!ht.value)}function yo(e,l={}){if(!sl||Ae)return null;if(!1===s.stream&&!1!==s.loading)return null;if(Eo(),$o())return null;if(Yl.value||De.value!==e)return null;if(Qn())return null;if(Sl)return Sl;if(qe.value&&Ve.value)return Promise.resolve();const t=No(),n=Zl.value;let o=!1;qe.value=!0,function(){const e=be.value;pe&&e&&Qe!==e&&(Qe&&pe.markSettled(Qe),Qe=e,pe.markPending(e))}();const a=d(null,null,function*(){try{yield function(e){return d(this,null,function*(){var l,t;if(!sl||Ae)return;Ge=!1;const n=Gl.value;if(at=!1,Kl.value=!1,Ql.value=null,Ie.value=!1,Jl.value=!1,Xl.value=!1,St.value=null,Ct.value=null,Mt.value=null,Bt.value=null,Nn(),function(){if(lt.value=!1,_t())return void(It.value=null);const e=jt.value;It.value=Ve.value||null==e?null:e}(),Hn(),On(),function(e){e.replaceChildren()}(e),Po(),yield te(Mo()),Ae)return;const o=d(null,null,function*(){var l,t;if("diff"===n){!function(){if(Hl||"undefined"==typeof window)return;Hl=!0;const e=e=>{var l;Rl("reason"in e?e.reason:null!=(l=e.error)?l:e.message)&&(e.preventDefault(),e.stopImmediatePropagation())};window.addEventListener("error",e,!0),window.addEventListener("unhandledrejection",e,!0),Ol=()=>{window.removeEventListener("error",e,!0),window.removeEventListener("unhandledrejection",e,!0),Hl=!1,Ol=null}}(),wl();const n=Ll(String(null!=(l=s.node.originalCode)?l:""),String(null!=(t=s.node.updatedCode)?t:""));vl?yield vl(e,n.original,n.updated,Le.value):yield sl(e,s.node.code,Le.value)}else yield sl(e,pt.value,Le.value);Ie.value=!0}),a=o.finally(()=>{Cl===a&&(Cl=null)});if(Cl=a,yield function(e){return d(this,null,function*(){if(!$l.value)return void(yield e);let l,t=!1;for(e.then(()=>{t=!0},e=>{t=!0,l=e});;){if(Ae)return;if(t){if(l)throw l;return}if(Rn()&&Wn())return;yield O(),yield nn()}})}(a),Ae)return;if(Gl.value!==n)return;Ie.value=!0;const r=null==(l=s.codeBlockOptions)?void 0:l.fontSize;if("number"==typeof r&&Number.isFinite(r)&&r>0){const e="diff"===n?yl():gl();null==(t=null==e?void 0:e.updateOptions)||t.call(e,{fontSize:r}),kt.value=r,xt.value=r}else if(!wn()){const e=an();e&&e>0?(kt.value=e,xt.value=e):(kt.value=12,xt.value=12)}for(bn();Ge;)if(Ge=!1,yield Co(),Ae)return;Re.value||je.value||Fn(!1),Ve.value=!0,Ul.value=n,function(){var e,l,t,n,o;if(Hn(),$l.value){const n=yl(),o=null==(e=null==n?void 0:n.getOriginalEditor)?void 0:e.call(n),a=null==(l=null==n?void 0:n.getModifiedEditor)?void 0:l.call(n),i=(e,l)=>{try{const t=null==e?void 0:e[l];if("function"!=typeof t)return;const n=t.call(e,()=>$n());n&&Fl.push(n)}catch(t){}};try{const e=null==(t=null==n?void 0:n.onDidUpdateDiff)?void 0:t.call(n,()=>{$n(),fe(()=>sn())});e&&Fl.push(e)}catch(r){}i(o,"onDidContentSizeChange"),i(a,"onDidContentSizeChange");const u=De.value;if(u&&"undefined"!=typeof MutationObserver){const e=["diffs-container",".stream-diffs-shell",".stream-diffs-surface"].join(","),l=l=>{var t;const n=l instanceof HTMLElement?l:l.parentElement;return Boolean(null==(t=null==n?void 0:n.closest)?void 0:t.call(n,e))},t=l=>{var t,n;const o=l instanceof HTMLElement?l:l.parentElement;return Boolean((null==(t=null==o?void 0:o.closest)?void 0:t.call(o,e))||(null==(n=null==o?void 0:o.querySelector)?void 0:n.call(o,e)))},n=new MutationObserver(e=>{$l.value&&Vn()&&e.some(e=>l(e.target)||Array.from(e.addedNodes).some(t)||Array.from(e.removedNodes).some(l))&&(En(),Fn({preferModelDiffHeight:!0}),Dn(),Tn())});n.observe(u,{attributeFilter:["class"],attributes:!0,childList:!0,characterData:!0,subtree:!0}),Fl.push({dispose:()=>n.disconnect()})}if(u&&"undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{if(!$l.value)return;if(Dn(),!Vn())return;const e=gn(u);null!=e&&(Math.ceil(u.getBoundingClientRect().height||0)<=e+1||(En(),Fn({preferModelDiffHeight:!0}),Dn()))});e.observe(u),Fl.push({dispose:()=>e.disconnect()})}return}const a=gl();try{const e=null==(n=null==a?void 0:a.onDidContentSizeChange)?void 0:n.call(a,()=>$n());e&&Fl.push(e)}catch(r){}try{const e=null==(o=null==a?void 0:a.onDidLayoutChange)?void 0:o.call(a,()=>$n());e&&Fl.push(e)}catch(r){}}(),xn(),bn(),En(),sn(),$n(),yield O();let i=null;xl&&(i=yield xl(),i&&(yield O(),yield nn()));const u=null==i?"diff"===n?yield An():yield function(){return d(this,null,function*(){if(In())return yield O(),yield nn(),In();for(let e=0;e<30;e++){if(Ae||$l.value)return!1;const e=De.value,l=qn(),t=jn(e),n=!pt.value.trim()||dn(e);if(l&&t&&n&&(yield O(),yield nn(),!Ae&&!$l.value&&qn()&&jn(De.value)&&(!pt.value.trim()||dn(De.value))))return!0;yield O(),yield nn()}return!1})}():i;Ae||(u?(bn(),ln(),(yield Qt())||To()):To())})}(e),tt=null}catch(a){const e=No(),r=n!==Zl.value,i=!1!==l.allowStaleContentRetry&&r&&tt!==e;if(t!==e||i)return i&&(tt=e),o=!0,qe.value=!1,Ve.value=!1,Ie.value=!1,void(Jl.value=!1);throw To(t),a}}).finally(()=>{Sl===a&&(Sl=null),function(){const e=Qe;pe&&e&&(Qe="",O(()=>{var l,t;if(!Ae){const n=null!=(t=null==(l=Ee.value)?void 0:l.offsetHeight)?t:0;n>0&&pe.reportHeight(e,n)}pe.markSettled(e)}))}(),o&&!Ae&&queueMicrotask(()=>{var e;const l=De.value;l&&!Ae&&(null==(e=yo(l))||e.catch(e=>{Ve.value=!1,Jl.value=!1,To()}))})});return Sl=a,a}P(fo,e=>{e||Z()}),P(()=>xt.value,(e,l)=>{var t;const n=$l.value?yl():gl();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(null==(t=n.updateOptions)||t.call(n,{fontSize:e}),je.value||Fn(!0))},{flush:"post",immediate:!1});let bo=0;const wo=P(()=>[De.value,$l.value,s.stream,s.loading,We.value,rl.value,s.node.language,s.node.raw,s.node.code,s.node.loading],e=>d(null,[e],function*([e,l,t,n,o,a]){const r=++bo;if(!e)return;if(!a)return;if(Xn())return;if(nt)return;if(!1===t&&!1!==n)return;if(!sl){if(yield function(){return d(this,null,function*(){if("undefined"==typeof window||Ae)return;if(We.value||Yl.value)return;if(Ml)return Ml;const e=d(null,null,function*(){try{const e=yield he();if(Ae)return;if(!e)return void(Yl.value=!0);yt(e)}catch(e){if(Ae)return;Yl.value=!0}}).finally(()=>{Ml===e&&(Ml=null)});return Ml=e,e})}(),r!==bo)return;if(!1===s.stream&&!1!==s.loading)return;if(Qn())return;if(!rl.value)return;if(!sl||Yl.value||qe.value||$o()||Ae||De.value!==e)return}if(Qn())return;const i=yo(e);if(i){try{yield i}catch(u){Ve.value=!1,Jl.value=!1,To()}Ve.value&&Jl.value&&wo()}}));function ko(e){return"string"==typeof e?e:null}function xo(e,l){if(e===l)return!0;const t=ko(e),n=ko(l);return!!t&&t===n}function So(){return le({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})}function Co(){return d(this,arguments,function*(e={}){Po();const l=()=>{$l.value&&jl(),fe(()=>{xn(),$n()})};if(e.appearanceOnly)return void l();const t=So();if(t)try{yield te(Mo()),yield Pl(t),l()}catch(n){}else l()})}function Mo(){const e=s.themes;return e&&"string"==typeof e[0]&&"string"==typeof e[1]?{dark:e[0],light:e[1]}:So()}function Bo(){var e,l,t,n,o;const a=Et.value,r=u(i({},ql.value||{}),{wordWrap:"wrap"===a.overflow?"on":"off",overflow:a.overflow,themes:s.themes,stream:!1,MAX_HEIGHT:null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500,fontSize:Ht.value,lineHeight:Ft.value,theme:So(),themeType:s.isDark?"dark":"light",disableLineNumbers:!b.value,disableFileHeader:!0,workerManager:null!=(o=null!=(n=null==(t=ql.value)?void 0:t.workerManager)?n:ne())?o:void 0,onThemeChange(){xn()}}),d=function(){var e;const l=null==(e=ql.value)?void 0:e.fontFamily;return"string"==typeof l&&l.trim()?l.trim():$l.value?function(){var e;if("undefined"==typeof window)return;const l=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l)return;return window.getComputedStyle(l).fontFamily.trim()||void 0}():void 0}();d&&(null!=r.fontFamily||(r.fontFamily=d));const v="string"==typeof r.unsafeCSS?r.unsafeCSS:"",c=`\n[data-file] [data-line],\n[data-diff] [data-line] {\n white-space: ${"wrap"===(f=a.overflow)?"pre-wrap":"pre"} !important;\n overflow-wrap: ${"wrap"===f?"anywhere":"normal"} !important;\n word-break: normal !important;\n}`;var f;return r.unsafeCSS=`[data-file], [data-diff] { --diffs-min-number-column-width-default: 2ch !important; }\n${c}\n\n[data-no-newline],\n[data-gutter-buffer="metadata"] {\n --diffs-computed-decoration-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-computed-diff-line-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-computed-selected-line-bg: var(--markstream-diff-metadata-bg) !important;\n --diffs-line-bg: var(--markstream-diff-metadata-bg) !important;\n color: var(--markstream-diff-metadata-fg) !important;\n background-color: var(--markstream-diff-metadata-bg) !important;\n}\n${v}`.trim(),r}function Po(){const e=Bo();if(!Dl)return Dl=e,Dl;for(const l of Object.keys(Dl))l in e||delete Dl[l];return Object.assign(Dl,e),Dl}P(Gl,(e,l)=>d(null,null,function*(){if(e===l)return;if(Kl.value||nt)return;if(to(),!sl||!De.value)return;if(!qe.value)return;if(!1===s.stream&&!1!==s.loading)return;if(!rl.value)return;const t=Sl;if(t){try{yield t}catch(n){}if(Ae||!De.value)return}if(Ul.value!==e||!qe.value||!Ve.value)try{Ve.value=!1,Jl.value=!1,qe.value=!1,Ie.value=!1,Hn(),On(),wl(),yield O(),yield yo(De.value)}catch(o){Ve.value=!1,Jl.value=!1,To()}}));const Ho=M(0),Oo=v(()=>String(Ho.value));let Fo=!1;function No(){var e;const l=So();return JSON.stringify({kind:Gl.value,language:Le.value,structural:Oo.value,optionsRevision:Ho.value,settledContentGeneration:et.value,theme:null!=(e=ko(l))?e:null==l?null:"custom",isDark:s.isDark})}P(()=>{var e;return null==(e=s.codeBlockOptions)?void 0:e.fontSize},e=>{const l="number"==typeof e&&Number.isFinite(e)&&e>0?e:bt;kt.value=l,xt.value=l,St.value=null,Ct.value=null,Mt.value=null}),P(()=>[s.codeBlockOptions,s.showLineNumbers],()=>{Ho.value+=1,!1===s.stream&&!1!==s.loading&&(Fo=!0)},{deep:!0}),P(()=>[pt.value,s.node.originalCode,s.node.updatedCode],()=>{Zl.value+=1,Xn()||(et.value+=1)});const Do=v(()=>No());function Eo(){Kl.value&&Ql.value!==Do.value&&(Kl.value=!1,Ql.value=null,tt=null,ot=null,qe.value=!1,Ve.value=!1,Ie.value=!1,Jl.value=!1,Xl.value=!1)}function $o(){return Eo(),Kl.value&&Ql.value===Do.value}function To(e=Do.value){Ql.value=e,Kl.value=!0,Xl.value=!1}return P(Do,()=>d(null,null,function*(){if(nt)return;if(!Kl.value)return;if(Ql.value===Do.value)return;if(!sl||!De.value||Yl.value||Ae||!rl.value)return;if(!1===s.stream&&!1!==s.loading)return;if(Qn())return;const e=Do.value;nt=!0;try{if(Eo(),Kl.value)return;yield yo(De.value)}catch(l){Ve.value=!1,Jl.value=!1,To()}finally{ot=e,yield O(),nt=!1}})),P(()=>[s.codeBlockOptions,rl.value],()=>{var e,l;if(Po(),!sl||!rl.value)return;const t=$l.value?yl():gl(),n="number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize)?s.codeBlockOptions.fontSize:Number.isFinite(xt.value)?xt.value:void 0;"number"==typeof n&&Number.isFinite(n)&&n>0&&(null==(l=null==t?void 0:t.updateOptions)||l.call(t,{fontSize:n})),Fn(!1)},{deep:!0}),P(()=>[So(),Vl.value,We.value,qe.value,rl.value],([e,l],t)=>{if(!We.value||!rl.value)return;const n=null!=t&&xo(e,t[0]),o=null!=t&&l!==t[1];Ve.value?(Ge=!1,Co({appearanceOnly:n})):n&&!o||(Ge=!0)},{flush:"post"}),P(()=>[Oo.value,We.value,rl.value],(e,l)=>d(null,[e,l],function*([e,l,t],[n]){if(Po(),!l||!t)return;if(!sl||!De.value)return;if(!qe.value)return;if(e===n)return;if(!1===s.stream&&!1!==s.loading)return void(Fo=!0);Fo=!1;const o=Sl;if(o){try{yield o}catch(a){}if(Ae||!De.value)return}try{Ve.value=!1,Jl.value=!1,qe.value=!1,Ie.value=!1,Hn(),On(),wl(),El&&yt(El),yield O(),yield yo(De.value,{allowStaleContentRetry:!1})}catch(r){Ve.value=!1,Jl.value=!1,To()}}),{flush:"post"}),P(()=>[s.loading,rl.value],([e,l])=>{!1===e&&l&&Fo&&(Fo=!1,Ho.value+=1)},{flush:"post"}),P(()=>[s.loading,rl.value],(e,l)=>d(null,[e,l],function*([e,l],t){if(!l)return;const n=null==t?void 0:t[0];if(!1===n&&!1!==e&&$l.value&&qe.value&&(yield O(),fe(()=>{d(null,null,function*(){const e=Sl;if(e)try{yield e}catch(l){}!Ae&&$l.value&&!1!==s.loading&&(Po(),jl(),$n())})})),e)return;const o=void 0!==n&&!1!==n;yield O(),fe(()=>{d(null,null,function*(){var e,l;try{if(o&&(yield function(){return d(this,null,function*(){if(!Kl.value)return!1;if(!sl||!De.value||Yl.value||Ae||!rl.value)return!1;if(ot===Do.value)return!0;nt=!0;try{Kl.value=!1,Ql.value=null,tt=null,qe.value=!1,Ve.value=!1,Ie.value=!1,Jl.value=!1,Hn(),On(),wl(),El&&yt(El),yield O();try{yield yo(De.value)}catch(e){Ve.value=!1,Jl.value=!1,To()}}finally{yield O(),nt=!1}return!0})}()))return void Fn(!1);if(o&&$l.value&&qe.value&&at&&De.value)return at=!1,Ve.value=!1,Jl.value=!1,qe.value=!1,Ie.value=!1,Hn(),On(),wl(),yield O(),yield yo(De.value,{allowStaleContentRetry:!1}),void Tn(!0);if(o&&qe.value)if($l.value&&De.value){const n=Sl;if(n)try{yield n}catch(t){}Po();const o=Ll(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:""));if(yield Un(o.original,o.updated,Le.value),Ae||!$l.value)return;yield Promise.resolve(hl()),jl(),Dn(!0),Kt(),En(),sn();const a=yield An();Ae||!a||Jl.value||(yield Qt()),$n(),Tn(!0)}else to(),oo(pt.value,Le.value),yield new Promise(e=>{const l=()=>{Ae?e():eo||Zn?setTimeout(l,16):e()};l()}),Ae||$l.value||(yield Promise.resolve(ml()));o&&$l.value?(Fn({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),Tn(!0)):Fn(!1)}catch(n){}})})}),{immediate:!0,flush:"post"}),f(()=>{Hn(),On(),bl(),null==Ol||Ol()}),(l,t)=>{var n;return Yl.value?(m(),h(ve,{key:0,style:F(Gt.value),node:gt.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":rt.value,"diff-hide-unchanged-regions":it.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Et.value,"reserved-height-px":$l.value&&null!=(n=Bt.value)?n:void 0,"is-dark":s.isDark,theme:s.theme,"dark-theme":s.darkTheme,"light-theme":s.lightTheme,themes:s.themes,"show-header":s.showHeader,"show-copy-button":s.showCopyButton,"show-tooltips":s.showTooltips},N({_:2},[l.$slots["header-left"]?{name:"header-left",fn:D(()=>[E(l.$slots,"header-left",{},void 0,!0)]),key:"0"}:void 0,l.$slots["header-right"]?{name:"header-right",fn:D(()=>[E(l.$slots,"header-right",{},void 0,!0)]),key:"1"}:void 0]),1032,["style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","code-block-options","resolved-visual-options","reserved-height-px","is-dark","theme","dark-theme","light-theme","themes","show-header","show-copy-button","show-tooltips"])):(m(),$("div",{key:1,ref_key:"container",ref:Ee,style:F(co.value),class:y(["code-block-container rounded-lg border",[{dark:s.isDark,"is-rendering":s.loading,"is-dark":Wl.value,"is-diff":$l.value,"is-plain-text":_e.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":Jl.value&&!Yl.value?"true":"false","data-markstream-enhancement-state":mt.value,"data-markstream-code-block-state":Xn()?"streaming":"settled","data-markstream-pending":ft.value?"true":void 0,"data-markstream-viewport-pending":dl.value&&k(ol)&&!rl.value?"true":void 0},[T(ce,{"show-header":s.showHeader,"show-collapse-button":s.showCollapseButton,"show-font-size-buttons":s.showFontSizeButtons,"enable-font-size-control":s.enableFontSizeControl,"show-copy-button":s.showCopyButton,"show-expand-button":s.showExpandButton,"show-preview-button":s.showPreviewButton,"show-tooltips":s.showTooltips,"is-dark":s.isDark,loading:s.loading,stream:e.stream,"is-collapsed":je.value,"is-expanded":Re.value,"copy-text":$e.value,"is-previewable":Jn.value,"code-font-size":xt.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":kt.value,"font-baseline-ready":Pt.value,"diff-stats":$l.value?Tl.value:null,"diff-stats-aria-label":zl.value,onToggleCollapse:po,onDecreaseFont:fn,onResetFont:mn,onIncreaseFont:cn,onCopy:mo,onToggleExpand:ho,onPreview:go},N({"header-left":D(()=>[E(l.$slots,"header-left",{},()=>[g("div",xe,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:vo.value},null,8,Se),g("div",Ce,[g("div",Me,w(uo.value),1),so.value?(m(),$("div",Be,w(so.value),1)):L("",!0)])])],!0)]),loading:D(()=>[E(l.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[t[0]||(t[0]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))],!0)]),default:D(()=>{var l;return[z(g("div",{class:y(["code-editor-layer",{"code-editor-layer--collapsed":je.value}])},[g("div",{ref_key:"codeEditor",ref:De,class:y(["code-editor-container",e.stream?"":"code-height-placeholder"]),"data-markstream-host-hidden":ct.value?"true":void 0,style:F(Jt.value)},null,14,Pe),vt.value?(m(),h(ve,{key:0,style:F(Gt.value),node:gt.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":rt.value,"diff-hide-unchanged-regions":it.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Et.value,"reserved-height-px":$l.value&&null!=(l=Bt.value)?l:void 0,"is-dark":s.isDark,theme:s.theme,"dark-theme":s.darkTheme,"light-theme":s.lightTheme,themes:s.themes,"show-toolbar":!1},null,8,["style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","code-block-options","resolved-visual-options","reserved-height-px","is-dark","theme","dark-theme","light-theme","themes"])):L("",!0)],2),[[_,!!e.stream||!e.loading]]),ht.value&&!Fe.value&&Jn.value&&"html"===Te.value?(m(),h(we,{key:0,code:s.node.code,"html-preview-allow-scripts":s.htmlPreviewAllowScripts,"html-preview-sandbox":s.htmlPreviewSandbox,"is-dark":s.isDark,"on-close":()=>ht.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):L("",!0)]}),_:2},[l.$slots["header-right"]?{name:"header-right",fn:D(()=>[E(l.$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,ke))}}}),[["__scopeId","data-v-79db2e8f"]]);export{He as default};
|