markstream-vue 2.0.1-beta.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var e=Object.defineProperty,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{as as R,G as j,M as q,ah as I,au as A,av as V,ar as W,a8 as U,af as G,b as Y,c as J,aj as X,ae as K,a6 as Q,ab as Z,ai as ee}from"./exports.js";import{M as le,f as te,n as ne,c as oe,l as ae}from"./index2.js";import{r as re,_ as ie,a as ue}from"./PreCodeBlock.vue_vue_type_style_index_0_lang.js";import{safeRaf as de,safeCancelRaf as se}from"./utils/safeRaf.js";import{r as ve}from"./preCodeTheme.js";import{getStreamDiffsRuntime as ce}from"./streamDiffs.js";const fe={class:"html-preview-frame__header"},me={class:"html-preview-frame__title"},he={class:"html-preview-frame__label"},pe=["sandbox","srcdoc"],ge=/* @__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",fe,[g("div",me,[t[3]||(t[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",he,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,pe)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]),ye=["data-markstream-enhanced","data-markstream-enhancement-state","data-markstream-code-block-state","data-markstream-pending","data-markstream-viewport-pending"],be={class:"code-header-main"},we=["innerHTML"],ke={class:"code-header-copy"},xe={class:"code-header-title"},Se={key:0,class:"code-header-caption"},Ce=["data-markstream-host-hidden"],Me=/* @__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(),fe=S(le,null),me=S("markstreamHostScrollManaged",null),he=S(q,void 0),pe=v(()=>I(s,j));function Me(e,l){}const Be=C(),Pe=v(()=>{const e=null==Be?void 0:Be.vnode.props;return!(!e||!e.onPreviewCode&&!e["onPreview-code"])}),{t:He}=R(),Oe=M(null),Fe=M(null),Ne=M(!1),Ee=M(Yn(s.node.language,s.node.code,Gn())),De=v(()=>te(Ee.value)),$e=v(()=>"plaintext"===De.value?"text":De.value),Te=v(()=>"plaintext"===De.value),ze=M(!1),Le=M(!1),_e=M(!1),Re=M(!1),je=M(!1),qe=M(!1);let Ie=!1,Ae=null,Ve=null,We=null,Ue=0,Ge=!1,Ye="";const Je=M(null);let Xe=0,Ke=!1;const Qe=A(),Ze=V(),el=W(),ll=B(null),tl=M("undefined"==typeof window||!el.value),nl=null!=(o=null==(n=null==(t=C())?void 0:t.vnode.el)?void 0:n.textContent)?o:"",ol="undefined"!=typeof window&&String(null!=(a=s.node.code)?a:"").length>0&&nl.includes(String(s.node.code)),al=M(!ol);c(()=>{al.value=!0}),"undefined"!=typeof window&&P([()=>Fe.value,el],([e,l],t,n)=>{var o,a,r;if(null==(o=ll.value)||o.destroy(),ll.value=null,!l||tl.value)return void(tl.value=!0);if(!e)return void(tl.value=!1);let i=!0;const u=null!=(r=null!=(a=null==Ze?void 0:Ze.value.heavyBlockMargin)?a:null==Ze?void 0:Ze.value.rootMargin)?r:"0px",d=Qe(e,{rootMargin:u,allowIdle:!1});ll.value=d,tl.value=tl.value||d.isVisible.value,d.whenVisible.then(()=>{i&&ll.value===d&&(tl.value=!0)}).catch(()=>{}),n(()=>{i=!1,d.destroy(),ll.value===d&&(ll.value=null)})},{immediate:!0}),H(()=>{var e;Ie=!0,function(){const e=Ye;fe&&e&&(Ye="",fe.markSettled(e))}(),null==(e=ll.value)||e.destroy(),ll.value=null});let rl=null,il=null,ul=()=>{},dl=()=>{},sl=()=>{},vl=()=>{},cl=()=>null,fl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),ml=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),hl=()=>{},pl=()=>{},gl=()=>{},yl=null,bl=null,wl=null,kl=null,xl=()=>{var e;return String(null!=(e=s.node.language)?e:"plaintext")},Sl=()=>d(null,null,function*(){}),Cl=!1,Ml=null;const Bl=[],Pl=[];let Hl=null,Ol=null;const Fl=v(()=>U(s.node)),Nl=M({removed:0,added:0}),El=v(()=>`-${Nl.value.removed} +${Nl.value.added}`);function Dl(e,l){return{original:e,updated:l}}function $l(e){return String(null!=e?e:"").replace(/\r\n$|\n$|\r$/,"")}function Tl(e){var l;return String(null!=(l=null==e?void 0:e.message)?l:e).includes("no diff result available")}function zl(){if(!jn())try{const e=gl();e&&"function"==typeof e.catch&&e.catch(e=>{Tl(e)})}catch(e){Tl(e)}}const Ll=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(!Fl.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)})}),_l=v(()=>{return(void 0!==s.theme?(e=s.theme)&&"object"==typeof e&&"light"in e&&"dark"in e:!bo(s.darkTheme,s.lightTheme))?!!s.isDark:function(e){var l;const t=null!=(l=yo(e))?l:"";return Z(t,!0===s.isDark)}(wo());var e}),Rl=v(()=>(Fl.value,_l.value?"dark":"light")),jl=v(()=>Fl.value?"dark"===Rl.value:_l.value),ql=v(()=>ve({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})),Il=v(()=>Fl.value?"diff":"single"),Al=M(Il.value),Vl=M(!1),Wl=M(!1),Ul=M(!1),Gl=M(!1),Yl=M(null),Jl=M(0),Xl=M(0),Kl=M(!1);let Ql=null,Zl=!1,et=null,lt=!1;const tt=v(()=>{var e;return!!Fl.value&&"unified"===(null==(e=Ll.value)?void 0:e.diffStyle)}),nt=v(()=>G(Ll.value));function ot(e){return!0===(null==me?void 0:me.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 at=v(()=>ot(Fe.value)),rt=v(()=>!(Vl.value||!Gl.value&&Wl.value)),it=v(()=>rt.value),ut=v(()=>rt.value&&!Ul.value),dt=v(()=>!Vl.value&&!Gl.value&&rt.value),st=v(()=>Wl.value&&!Vl.value?"ready":Gl.value?"fallback":"pending"),vt=M(!1),ct=v(()=>$l(s.node.code)),ft=v(()=>Fl.value?!0===s.node.diff?s.node:u(i({},s.node),{diff:!0}):ct.value===s.node.code?s.node:u(i({},s.node),{code:ct.value}));function mt(e){const l=e.detectLanguage;"function"==typeof l&&(xl=l),Ol=e,Hl=xo();const t=e.createCodeBlockRuntime(Hl);return!!t&&(rl=t.createEditor||rl,il=t.createDiffEditor||il,ul=t.updateCode||ul,dl=t.updateDiff||dl,sl=t.finalizeCode||sl,vl=t.finalizeDiff||vl,cl=t.getEditor||cl,fl=t.getEditorView||fl,ml=t.getDiffEditorView||ml,hl=t.cleanupEditor||hl,pl=t.safeClean||t.cleanupEditor||pl,gl=t.refreshDiffPresentation||gl,Sl=t.setTheme||Sl,yl=t.whenVisualReady||null,qe.value=!0,!0)}const ht=Y,pt=J,gt=M("number"==typeof(null==(r=s.codeBlockOptions)?void 0:r.fontSize)?s.codeBlockOptions.fontSize:Number.NaN),yt=M(gt.value),bt=M(null),wt=M(null),kt=M(null),xt=M(null),St=v(()=>{const e=gt.value,l=yt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof l&&Number.isFinite(l)&&l>0}),Ct=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=yt.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:ht}),Mt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.lineHeight;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:Ct.value===ht?pt:Math.max(12,Math.round(1.5*Ct.value))}),Bt=v(()=>Mt.value),Pt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.tabSize;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:4}),Ht=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}}),Ot=v(()=>{const e=X(s.codeBlockOptions);return u(i({},e),{fontSize:Ct.value,lineHeight:Bt.value,maxHeight:Wn(),padding:Ht.value.top,paddingBottom:Ht.value.bottom,tabSize:Pt.value})}),Ft=v(()=>{const e=s.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function Nt(e){if(null==e)return null;const l=Math.ceil(e);return!Number.isFinite(l)||l<=0?null:Math.min(l,Math.ceil(Wn()))}function Et(){return!Fl.value&&!1!==s.stream&&!1!==s.loading}const Dt=M(Et());function $t(){return Et()||Dt.value}const Tt=v(()=>Fl.value?null:null==Ft.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})(ct.value)*Bt.value+1):null),zt=v(()=>{if(Fl.value)return null;const e=Ft.value;return null==e||$t()?Nt(Tt.value):Nt(e)}),Lt=v(()=>{const e=s.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),_t=M(null);function Rt(){const e=_t.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}const jt=v(()=>{const e=Rt();return null!=e?e:!Fl.value&&Kl.value?null:rt.value||!Wl.value?zt.value:null});function qt(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":e?"hsl(0 0% 7% / 0.98)":"hsl(var(--ms-muted) / 0.45)","--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 It=v(()=>{const e=Nt(Ft.value),l=Nt(Tt.value),t=$t(),n=i({},Fl.value||null==e||t?Fl.value||null==l?{}:{minHeight:`${l}px`}:{height:`${e}px`,minHeight:`${e}px`});if(n["--markstream-code-fallback-bg"]=ql.value.background,n["--markstream-code-fallback-fg"]=ql.value.foreground,ql.value.builtin&&(n["--markstream-code-theme-bg"]=ql.value.background,n["--markstream-code-theme-fg"]=ql.value.foreground,n["--markstream-code-theme-line-number"]=ql.value.lineNumber),n["--markstream-pre-line-number-top"]=`${Ht.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",Fl.value){n["--markstream-pre-diff-line-height"]=`${Bt.value}px`,n["--markstream-pre-diff-pane-bottom-padding"]=(tt.value,"0px");const e=xt.value;null!=e&&e>0&&(n.height=`${e}px`,n.minHeight=`${e}px`,n.maxHeight=`${e}px`),Object.assign(n,qt(jl.value))}return n}),At=v(()=>null!=jt.value&&(!Wl.value||null!=Rt())),Vt=v(()=>{const e=jt.value;if(null==e)return null;if(Fl.value)return Math.ceil(e);const l=Lt.value,t=Ft.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)}),Wt=v(()=>{if(Fl.value&&rt.value)return{};const e=jt.value;return At.value&&null!=e?{minHeight:`${e}px`}:{}});function Ut(){_t.value=null}function Gt(){var e,l,t,n,o,a,r,i;const u=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback"),d=ml(),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 Yt(){return d(this,null,function*(){return Fl.value?(bn(),Kt(),Fn(!0),Gt(),Nn(),Ul.value=!0,yield O(),Fn(!0),yield Zt(),Fn(!0),gn(),Kt(),!!(yield function(){return d(this,null,function*(){var e;if(!Fl.value)return!0;for(let l=0;l<4;l++){const l=Kt();Fn(!0),Jt(l),Xt(l),yield O(),yield Zt();const t=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!t)return!1;if(null==l)return Ln();const n=t.getBoundingClientRect().height;if(n>0&&Math.abs(n-l)<=2)return!0}return!1})}())&&(Wl.value=!0,yield O(),Kt(),Fn(!0),gn(),Nn(),de(()=>{Ie||de(()=>{Ie||(function(){var e,l;const t=null==(e=Fe.value)?void 0:e.querySelector(".code-block-shell-content"),n=null==(l=Fe.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"))}(),En(!0))})}),En(),!0)):!(yl&&!(yield yl())||(bn(),Fn(!0),Ul.value=!0,yield O(),bn(),Fn(!0),yield Zt(),bn(),Fn(!0),Wl.value=!0,yield O(),En(),0))})}function Jt(e){var l;if(!Fl.value)return;const t=Oe.value,n=null==(l=Fe.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`;xt.value=a;const i=Fe.value;i&&(i.dataset.markstreamDiffHandoffHeight=r),n.dataset.markstreamDiffHandoffHeight=r,n.style.setProperty("height",r),n.style.setProperty("min-height",r)}function Xt(e){var l,t,n;if(!Fl.value)return;const o=null==(l=Fe.value)?void 0:l.querySelector(".code-block-shell-content"),a=null==(t=Fe.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=Oe.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 Kt(){const e=Oe.value;if(e&&Ln(e)){Nn();const l=hn(e);if(null!=l&&l>0){const t=Math.ceil(l),n=Math.ceil(Wn()),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",rt.value&&(xt.value=o,Jt(o)),Dn(),o}return Hn({preferModelDiffHeight:!0}),Jt(),Dn(),Number.parseFloat(e.style.height||"")||null}return bn()}function Qt(e,l=!1,t={}){const n=Math.ceil(e),o=Rt();if(null==o)return n;const a=!0===t.allowBelowEstimatedFloor;return n>=o||a?((l||a)&&je.value&&Ut(),n):o}function Zt(){return new Promise(e=>{let l=!1,t=null,n=null;const o=()=>{l||(l=!0,null!=n&&globalThis.clearTimeout(n),null!=t&&se(t),e())};n=globalThis.setTimeout(o,50),t=de(o)})}function en(){var e;try{const l=Oe.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 ln(){var e,l,t,n,o,a;try{const a=Fl.value?null!=(t=null==(l=null==(e=ml())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:ml():fl(),r=cl(),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=Oe.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 tn(e){var l,t;try{const n=cl(),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=en();if(n&&n>0)return n;const o=Number.isFinite(yt.value)&&yt.value>0?yt.value:14;return Math.max(12,Math.round(1.35*o))}function nn(){var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding;return"number"==typeof l&&Number.isFinite(l)?2*Math.max(0,l):Fl.value?24:0}function on(e){const l=$l(e);return l?l.split(/\r\n|\n|\r/):[]}function an(e){return!!Te.value||!!e&&(jn(e)||null!=yl)}function rn(){var e,l;Fl.value?Nl.value=function(e,l){const t=on(e),n=on(l);let o=0,a=t.length-1,r=n.length-1;for(;o<=a&&o<=r&&t[o]===n[o];)o++;for(;a>=o&&r>=o&&t[a]===n[r];)a--,r--;const i=Math.max(0,a-o+1),u=Math.max(0,r-o+1);if(0===i||0===u)return{removed:i,added:u};if((i+1)*(u+1)<=15e5){const e=u+1;let l=new Uint32Array(e),a=new Uint32Array(e);for(let d=i-1;d>=0;d--){a[u]=0;for(let r=u-1;r>=0;r--)a[r]=t[o+d]===n[o+r]?l[r+1]+1:Math.max(l[r],a[r+1]);const e=l;l=a,a=e}const r=l[0];return{removed:i-r,added:u-r}}return{removed:i,added:u}}(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:"")):Nl.value={removed:0,added:0}}function un(){rn()}function dn(){var e;if(Number.isFinite(yt.value)&&yt.value>0&&Number.isFinite(gt.value))return yt.value;if("number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize))return gt.value=s.codeBlockOptions.fontSize,yt.value=s.codeBlockOptions.fontSize,s.codeBlockOptions.fontSize;const l=ln();return l&&l>0?(gt.value=l,yt.value=l,l):(gt.value=12,yt.value=12,12)}function sn(){const e=dn(),l=Math.min(36,e+1);yt.value=l}function vn(){const e=dn(),l=Math.max(10,e-1);yt.value=l}function cn(){dn(),Number.isFinite(gt.value)&&(yt.value=gt.value)}function fn(){var e,l,t,n,o,a,r,i,u,d,s,v,c,f;try{const m=Fl.value?ml():null,h=Fl.value?m:fl();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(tn(c),tn(f)),x=nn();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 Fl.value||(Kl.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=tn(h);return Math.ceil(g*(y+1.5)+0)}catch(m){return null}}function mn(){var e,l;if(Fl.value)return!1;try{const t=null==(l=null==(e=fl())?void 0:e.getContentHeight)?void 0:l.call(e),n="number"==typeof t&&Number.isFinite(t)&&t>0;return n&&(Kl.value=!0),n}catch(t){return!1}}function hn(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 pn(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 gn(){var e,l,t;if(yn())return;const n=ln();n&&n>0&&(bt.value=n,yt.value=n,gt.value=n);try{const n=tn(Fl.value?null!=(t=null==(l=null==(e=ml())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:ml():fl());n&&n>0&&(wt.value=n)}catch(o){}try{const e=en();e&&e>0&&(wt.value=e)}catch(o){}}function yn(){return Fl.value&&it.value}function bn(){var e;if(!rt.value)return null;const l=Oe.value,t=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l||!t)return null;const n=Math.ceil(t.getBoundingClientRect().height),o=Fl.value?hn(l):null,a=Math.max(n,null!=o&&o>0?Math.ceil(o):0),r=Math.ceil(Wn()),i=Math.min(a,r);return!Number.isFinite(i)||i<=0?null:(Fl.value&&i>n&&(xt.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 wn(){var e,l,t,n,o,a,r,i,u;const d=Oe.value,v=Fe.value;if(!d||!v)return;const c=d;c.style.setProperty("--markstream-diff-metadata-bg",ql.value.background),c.style.setProperty("--markstream-diff-metadata-fg",ql.value.lineNumber),c.style.setProperty("--diffs-tab-size",String(Pt.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",`${Ht.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=Fl.value?null!=(t=null==(l=null==(e=ml())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:ml():fl(),r=cl(),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&&(kt.value=C),Fl.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(qt(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(!Te.value)return!1;const n=pn(e),o=pn(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,Fl.value],([e,l,t,n])=>{n||!1===e||!1===l||Dt.value?(n||!1===e)&&Dt.value&&(Dt.value=!1):(Dt.value=!0,Ut())},{immediate:!0});let kn=0,xn=0;const Sn=/auto|scroll|overlay/i;function Cn(e,l,t){var n;if("undefined"==typeof window)return;if(Fl.value)return;if(function(e){return at.value||ot(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(Sn.test(l)||Sn.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 Mn(){try{const e=Oe.value;if(!e)return;const l=e.getBoundingClientRect().height,t=fn();if(null!=t&&t>0){const n=Qt(t,!0,{allowBelowEstimatedFloor:!Fl.value&&je.value&&mn()}),o=Rt();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",void Cn(e,l,n)}const n=Rt();null!=n&&(e.style.minHeight=`${n}px`,e.style.height=`${n}px`,e.style.maxHeight="none",e.style.overflow="visible",Cn(e,l,n))}catch(e){}}function Bn(){for(var e,l;Bl.length>0;)try{null==(l=null==(e=Bl.pop())?void 0:e.dispose)||l.call(e)}catch(t){}null!=Ae&&(se(Ae),Ae=null),null!=Ve&&(se(Ve),Ve=null),null!=We&&(se(We),We=null),Ue=0,Ge=!1}function Pn(){for(var e;Pl.length>0;)try{null==(e=Pl.pop())||e()}catch(l){}}function Hn(e=!1){Le.value||(ze.value?Mn():function(e={}){var l;try{const t=Oe.value;if(!t)return;const n=t.getBoundingClientRect().height,o=Wn(),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=Fl.value?function(){var e,l,t,n,o,a,r,i,u,d,s,v;if(jn())return null;try{const c=ml(),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(tn(f),tn(m)),b=nn(),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=Fl.value&&Ln(t);if(Xe>0&&(Xe--,null!=Je.value))return void Cn(t,n,$n(t,Je.value,o,{preserveScrollableOverflow:zn(t)}));if(Fl.value&&!d&&rt.value){const e=bn();if(null!=e){const l=$n(t,e,o,{allowBelowEstimatedFloor:!0});return Fn(!0),void Cn(t,n,l)}}const v=Fl.value&&!0===e.preferModelDiffHeight,c=Fl.value?hn(t):null,f=!Fl.value&&je.value&&mn(),m=Fl.value&&!1!==s.loading&&(null!=c||null!=u&&a>0&&u<a-1),h=null!=u;let p;if(Fl.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=tt.value&&null!=c||null!=c?h?Math.max(c,u):c:Fl.value&&!1!==s.loading?null!=u&&i>0&&u<i-1?u:i>0?i:null:u;else p=fn();if(Fl.value&&null!=p&&i>0&&(!1!==s.loading||!0===e.holdCurrentDiffHeight)&&(p=Math.max(p,i)),null!=p&&p>0)return void Cn(t,n,$n(t,p,o,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:f||m,preserveScrollableOverflow:zn(t)}));if(null!=Je.value)return void Cn(t,n,$n(t,Je.value,o,{preserveScrollableOverflow:zn(t)}));const g=Fl.value&&!1!==s.loading?a:Math.max(a,null!=u&&u>0?u:0);if(g>0)return void Cn(t,n,$n(t,g,o));const y=Rt();if(!(null==y||Fl.value&&!1!==s.loading&&d))return void Cn(t,n,$n(t,y,o));const b=Number.parseFloat(t.style.height);!Number.isNaN(b)&&b>0?Cn(t,n,$n(t,b,o)):Fl.value||Cn(t,n,$n(t,o,o))}catch(t){}}("object"==typeof e?e:{}))}function On(){kn=0,xn=0}function Fn(e=!1){var l,t,n;if(Le.value)return;const o=Oe.value;if(!o)return;const a=Fl.value?ml():fl();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===kn&&u===xn)return;kn=i,xn=u,a.layout({width:i,height:u})}else On(),a.layout()}catch(r){}}function Nn(){Pn()}function En(e=!1){if(Ie||null!=Ae)return;const l=()=>{Ie||(Nn(),Hn(e),Fn())};Ae=de(()=>{Ae=null,l(),Ve=de(()=>{Ve=null,l()})}),Dn()}function Dn(e=!1){if(!Fl.value||Ie||!e&&!1===s.loading)return;if(Ge=Ge||e,Ue=Math.max(Ue,e?18:6),null!=We)return;const l=()=>{if(We=null,!Fl.value||Ie||Ue<=0||!Ge&&!1===s.loading)return Ue=0,void(Ge=!1);Ue--,Nn(),Hn({preferModelDiffHeight:!0,holdCurrentDiffHeight:Ge}),Fn(),Ue>0?We=de(l):Ge=!1};We=de(l)}function $n(e,l,t,n={}){const o=Fl.value&&!1!==s.loading?hn(e):null,a=null!=o&&o>l+1?o:l,r=Math.min(a,t),i=!0===n.allowBelowEstimatedFloor,u=Qt(r,!0===n.clearEstimatedFloor,{allowBelowEstimatedFloor:i}),d=Rt();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||Tn(e,u);return e.style.overflow=v?"auto":"hidden",u}function Tn(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 zn(e){var l;return Ke||Tn(e,null!=(l=Je.value)?l:0)}function Ln(e=Oe.value){return jn(e)}function _n(e=Oe.value){return jn(e)}function Rn(){var e,l;if(jn())return!0;const t=null==(l=null==(e=fl())?void 0:e.getModel)?void 0:l.call(e);return"function"==typeof(null==t?void 0:t.getValue)&&t.getValue()===ct.value}function jn(e=Oe.value){return Boolean(null==e?void 0:e.querySelector("diffs-container"))}function qn(){return!1!==s.loading||Wl.value}function In(){const e=ml();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(!Fl.value)return!0;for(let e=0;e<30;e++){if(Ie)return!1;if(jn())return yield O(),yield Zt(),!Ie&&jn();yield O(),yield Zt()}return!1})}function Vn(e,l,t){return d(this,null,function*(){try{return void(yield dl(e,l,t))}catch(n){if(!Tl(n))throw n}if(yield O(),yield Zt(),!Ie&&Fl.value)try{yield dl(e,l,t)}catch(n){if(!Tl(n))throw n}})}function Wn(){var e,l;return null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500}const Un=v(()=>s.isShowPreview&&("html"===Ee.value||"svg"===Ee.value));function Gn(){return"boolean"==typeof s.node.loading?s.node.loading:!0===s.loading}function Yn(e,l,t){return!t||function(){var e,l,t;if(!Gn())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:"")?ne(String(null!=e?e:"")):"plain"}function Jn(){return Gn()}let Xn=null,Kn=!1,Qn=0;function Zn(){Xn=null,Qn++}function eo(){return d(this,arguments,function*(e=Qn){if(!Kn){Kn=!0;try{for(;Xn&&!Ie&&!Fl.value&&e===Qn;){const e=Xn;Xn=null;try{yield Promise.resolve(ul(e.code,e.language)),yield O(),Ie||Fl.value||(Hn(!1),Fn())}catch(l){Me()}}}finally{Kn=!1,!Xn||Ie||Fl.value||eo()}}})}function lo(e,l){Xn={code:e,language:l},eo(Qn)}P(()=>[s.node.language,s.node.code,s.node.raw,s.node.loading,s.loading],([e,l,t,n,o])=>{Ee.value=Yn(e,l,"boolean"==typeof n?n:!0===o)}),P(()=>[s.node.originalCode,s.node.updatedCode,Fl.value],()=>{rn(),de(()=>un())},{immediate:!0});let to=0;P(()=>[s.node.originalCode,s.node.updatedCode,$e.value,Fl.value,s.stream],e=>d(null,[e],function*([,,,e,l]){var t,n;const o=++to;if(!e)return;if(Gn())return;if(!1===l&&!_e.value)return;if(!1!==l&&rl&&!_e.value&&Oe.value)try{yield ho(Oe.value)}catch(u){}const a=wl;if(a&&!Re.value){try{yield a}catch(u){}if(Ie||!Fl.value||o!==to)return}if(o!==to)return;const r=Dl(String(null!=(t=s.node.originalCode)?t:""),String(null!=(n=s.node.updatedCode)?n:"")),i=!1===s.loading;i&&So();try{if(yield Vn(r.original,r.updated,$e.value),Ie||!Fl.value||o!==to)return;yield O(),Fn(!0),Nn(),Hn(!1===s.loading||{preferModelDiffHeight:!0}),Fn(!0),En(!0)}catch(d){return}if(i){if(Ie||!Fl.value)return;zl(),Nn(),un(),En(),Dn(!0)}ze.value&&de(()=>Mn())})),P(()=>s.node.code,e=>d(null,null,function*(){if(Gn())return;if(!1===s.stream)return;if(Ee.value||(Ee.value=ne(xl(e))),Fl.value)return;const l=wl;if(l&&!Re.value){try{yield l}catch(t){}if(Ie||Fl.value)return}if(rl&&!_e.value&&Oe.value)try{yield ho(Oe.value)}catch(t){}lo($l(s.node.code),$e.value),ze.value&&de(()=>Mn())}));const no=v(()=>{const e=Ee.value;return e?oe[e]||e.charAt(0).toUpperCase()+e.slice(1):oe[""]||"Plain Text"}),oo=v(()=>{var e;return K(String(null!=(e=s.node.raw)?e:""),no.value,Fl.value)}),ao=v(()=>oo.value.title),ro=v(()=>oo.value.caption),io=v(()=>(ae.value,re(Ee.value||"",he))),uo=v(()=>{const e={};e["--markstream-code-layout-character-width"]=null==kt.value?"1ch":`${kt.value}px`,e["--markstream-code-fallback-bg"]=ql.value.background,e["--markstream-code-fallback-fg"]=ql.value.foreground,ql.value.builtin&&(e["--markstream-code-theme-bg"]=ql.value.background,e["--markstream-code-theme-fg"]=ql.value.foreground,e["--markstream-code-theme-line-number"]=ql.value.lineNumber),e["--markstream-diff-added-line-fill"]=ql.value.diffAddedLine,e["--markstream-diff-added-number-fill"]=ql.value.diffAddedNumber,e["--markstream-diff-editor-bg"]=ql.value.background,e["--markstream-diff-removed-line-fill"]=ql.value.diffRemovedLine,e["--markstream-diff-removed-number-fill"]=ql.value.diffRemovedNumber,e["--markstream-diff-shell-bg"]=ql.value.background,e["--markstream-pre-resolved-theme-bg"]=ql.value.background,e["--markstream-pre-resolved-theme-fg"]=ql.value.foreground,e["--markstream-pre-resolved-theme-line-number"]=ql.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),At.value&&!Fl.value&&!Le.value){const l=Vt.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)))",Fl.value||(e.borderColor="var(--markstream-code-border-color, var(--code-border))"),e}),so=v(()=>!1!==s.showTooltips);function vo(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(s.node.code)),Ne.value=!0,p("copy",s.node.code),setTimeout(()=>{Ne.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function co(){ze.value=!ze.value;const e=Fl.value?ml():fl(),l=Oe.value;e&&l&&(ze.value?(l.style.maxHeight="none",l.style.overflow="visible",Hn(!0)):(l.style.overflow="auto",Hn(!0)))}function fo(){var e,l;if(Le.value=!Le.value,Le.value){if(Ke=!1,Oe.value){const t=Math.ceil((null==(l=(e=Oe.value).getBoundingClientRect)?void 0:l.call(e).height)||0);Ke=Tn(Oe.value,t)||"auto"===Oe.value.style.overflow||"auto"===Oe.value.style.overflowY,t>0&&(Je.value=t)}}else Oe.value&&null!=Je.value&&(Oe.value.style.height=`${Je.value}px`),Xe=2,O(()=>{Le.value||Ie||(Hn(!0),Fn(!0))})}function mo(){if(!Un.value)return;const e=Ee.value;if(Pe.value){const l="html"===e?"text/html":"image/svg+xml",t="html"===e?He("artifacts.htmlPreviewTitle")||"HTML Preview":He("artifacts.svgPreviewTitle")||"SVG Preview";return void p("previewCode",{node:s.node,artifactType:l,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(vt.value=!vt.value)}function ho(e,l={}){if(!rl||Ie)return null;if(!1===s.stream&&!1!==s.loading)return null;if(Oo(),Fo())return null;if(Vl.value||Oe.value!==e)return null;if(Jn())return null;if(bl)return bl;if(_e.value&&je.value)return Promise.resolve();const t=Po(),n=Jl.value;let o=!1;_e.value=!0,function(){const e=pe.value;fe&&e&&Ye!==e&&(Ye&&fe.markSettled(Ye),Ye=e,fe.markPending(e))}();const a=d(null,null,function*(){try{yield function(e){return d(this,null,function*(){var l,t;if(!rl||Ie)return;const n=Il.value;if(lt=!1,Gl.value=!1,Yl.value=null,Re.value=!1,Wl.value=!1,Ul.value=!1,bt.value=null,wt.value=null,kt.value=null,xt.value=null,On(),function(){if(Kl.value=!1,$t())return void(_t.value=null);const e=zt.value;_t.value=je.value||null==e?null:e}(),Bn(),Pn(),function(e){e.replaceChildren()}(e),So(),Ie)return;const o=d(null,null,function*(){var l,t;if("diff"===n){!function(){if(Cl||"undefined"==typeof window)return;Cl=!0;const e=e=>{var l;Tl("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),Ml=()=>{window.removeEventListener("error",e,!0),window.removeEventListener("unhandledrejection",e,!0),Cl=!1,Ml=null}}(),pl();const n=Dl(String(null!=(l=s.node.originalCode)?l:""),String(null!=(t=s.node.updatedCode)?t:""));il?yield il(e,n.original,n.updated,$e.value):yield rl(e,s.node.code,$e.value)}else yield rl(e,ct.value,$e.value);Re.value=!0}),a=o.finally(()=>{wl===a&&(wl=null)});if(wl=a,yield function(e){return d(this,null,function*(){if(!Fl.value)return void(yield e);let l,t=!1;for(e.then(()=>{t=!0},e=>{t=!0,l=e});;){if(Ie)return;if(t){if(l)throw l;return}if(Ln()&&In())return;yield O(),yield Zt()}})}(a),Ie)return;if(Il.value!==n)return;Re.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?ml():fl();null==(t=null==e?void 0:e.updateOptions)||t.call(e,{fontSize:r}),gt.value=r,yt.value=r}else if(!yn()){const e=ln();e&&e>0?(gt.value=e,yt.value=e):(gt.value=12,yt.value=12)}gn(),yield ko(),ze.value||Le.value||Hn(!1),je.value=!0,Al.value=n,function(){var e,l,t,n,o;if(Bn(),Fl.value){const n=ml(),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,()=>En());n&&Bl.push(n)}catch(t){}};try{const e=null==(t=null==n?void 0:n.onDidUpdateDiff)?void 0:t.call(n,()=>{En(),de(()=>un())});e&&Bl.push(e)}catch(r){}i(o,"onDidContentSizeChange"),i(a,"onDidContentSizeChange");const u=Oe.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=>{Fl.value&&qn()&&e.some(e=>l(e.target)||Array.from(e.addedNodes).some(t)||Array.from(e.removedNodes).some(l))&&(Nn(),Hn({preferModelDiffHeight:!0}),Fn(),Dn())});n.observe(u,{attributeFilter:["class"],attributes:!0,childList:!0,characterData:!0,subtree:!0}),Bl.push({dispose:()=>n.disconnect()})}if(u&&"undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{if(!Fl.value)return;if(Fn(),!qn())return;const e=hn(u);null!=e&&(Math.ceil(u.getBoundingClientRect().height||0)<=e+1||(Nn(),Hn({preferModelDiffHeight:!0}),Fn()))});e.observe(u),Bl.push({dispose:()=>e.disconnect()})}return}const a=fl();try{const e=null==(n=null==a?void 0:a.onDidContentSizeChange)?void 0:n.call(a,()=>En());e&&Bl.push(e)}catch(r){}try{const e=null==(o=null==a?void 0:a.onDidLayoutChange)?void 0:o.call(a,()=>En());e&&Bl.push(e)}catch(r){}}(),wn(),gn(),Nn(),un(),En(),yield O();let i=null;yl&&(i=yield yl(),i&&(yield O(),yield Zt()));const u=null==i?"diff"===n?yield An():yield function(){return d(this,null,function*(){if(jn())return yield O(),yield Zt(),jn();for(let e=0;e<30;e++){if(Ie||Fl.value)return!1;const e=Oe.value,l=Rn(),t=_n(e),n=!ct.value.trim()||an(e);if(l&&t&&n&&(yield O(),yield Zt(),!Ie&&!Fl.value&&Rn()&&_n(Oe.value)&&(!ct.value.trim()||an(Oe.value))))return!0;yield O(),yield Zt()}return!1})}():i;Ie||(u?(gn(),Kt(),(yield Yt())||No()):No())})}(e),Ql=null}catch(a){const e=Po(),r=n!==Jl.value,i=!1!==l.allowStaleContentRetry&&r&&Ql!==e;if(t!==e||i)return i&&(Ql=e),o=!0,_e.value=!1,je.value=!1,Re.value=!1,void(Wl.value=!1);throw No(t),a}}).finally(()=>{bl===a&&(bl=null),function(){const e=Ye;fe&&e&&(Ye="",O(()=>{var l,t;if(!Ie){const n=null!=(t=null==(l=Fe.value)?void 0:l.offsetHeight)?t:0;n>0&&fe.reportHeight(e,n)}fe.markSettled(e)}))}(),o&&!Ie&&queueMicrotask(()=>{var e;const l=Oe.value;l&&!Ie&&(null==(e=ho(l))||e.catch(e=>{je.value=!1,Wl.value=!1,No()}))})});return bl=a,a}P(so,e=>{e||Q()}),P(()=>yt.value,(e,l)=>{var t;const n=Fl.value?ml():fl();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(null==(t=n.updateOptions)||t.call(n,{fontSize:e}),Le.value||Hn(!0))},{flush:"post",immediate:!1});let po=0;const go=P(()=>[Oe.value,Fl.value,s.stream,s.loading,qe.value,tl.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=++po;if(!e)return;if(!a)return;if(Gn())return;if(Zl)return;if(!1===t&&!1!==n)return;if(!rl){if(yield function(){return d(this,null,function*(){if("undefined"==typeof window||Ie)return;if(qe.value||Vl.value)return;if(kl)return kl;const e=d(null,null,function*(){try{const e=yield ce();if(Ie)return;if(!e)return void(Vl.value=!0);mt(e)}catch(e){if(Ie)return;Vl.value=!0}}).finally(()=>{kl===e&&(kl=null)});return kl=e,e})}(),r!==po)return;if(!1===s.stream&&!1!==s.loading)return;if(Jn())return;if(!tl.value)return;if(!rl||Vl.value||_e.value||Fo()||Ie||Oe.value!==e)return}if(Jn())return;const i=ho(e);if(i){try{yield i}catch(u){je.value=!1,Wl.value=!1,No()}je.value&&Wl.value&&go()}}));function yo(e){return"string"==typeof e?e:null}function bo(e,l){if(e===l)return!0;const t=yo(e),n=yo(l);return!!t&&t===n}function wo(){return ee({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})}function ko(){return d(this,arguments,function*(e={}){So();const l=()=>{Fl.value&&zl(),de(()=>{wn(),En()})};if(e.appearanceOnly)return void l();const t=wo();if(t)try{yield Sl(t),l()}catch(n){}else l()})}function xo(){var e,l;const t=Ot.value,n=u(i({},Ll.value||{}),{wordWrap:"wrap"===t.overflow?"on":"off",overflow:t.overflow,themes:s.themes,stream:!1,MAX_HEIGHT:null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500,fontSize:Ct.value,lineHeight:Bt.value,theme:wo(),themeType:s.isDark?"dark":"light",disableLineNumbers:!b.value,disableFileHeader:!0,onThemeChange(){wn()}}),o=function(){var e;const l=null==(e=Ll.value)?void 0:e.fontFamily;return"string"==typeof l&&l.trim()?l.trim():Fl.value?function(){var e;if("undefined"==typeof window)return;const l=null==(e=Fe.value)?void 0:e.querySelector("pre.code-pre-fallback");if(!l)return;return window.getComputedStyle(l).fontFamily.trim()||void 0}():void 0}();o&&(null!=n.fontFamily||(n.fontFamily=o));const a="string"==typeof n.unsafeCSS?n.unsafeCSS:"",r=`\n[data-file] [data-line],\n[data-diff] [data-line] {\n white-space: ${"wrap"===(d=t.overflow)?"pre-wrap":"pre"} !important;\n overflow-wrap: ${"wrap"===d?"anywhere":"normal"} !important;\n word-break: normal !important;\n}`;var d;return n.unsafeCSS=`[data-file], [data-diff] { --diffs-min-number-column-width-default: 2ch !important; }\n${r}\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${a}`.trim(),n}function So(){const e=xo();if(!Hl)return Hl=e,Hl;for(const l of Object.keys(Hl))l in e||delete Hl[l];return Object.assign(Hl,e),Hl}P(Il,(e,l)=>d(null,null,function*(){if(e===l)return;if(Gl.value||Zl)return;if(Zn(),!rl||!Oe.value)return;if(!_e.value)return;if(!1===s.stream&&!1!==s.loading)return;if(!tl.value)return;const t=bl;if(t){try{yield t}catch(n){}if(Ie||!Oe.value)return}if(Al.value!==e||!_e.value||!je.value)try{je.value=!1,Wl.value=!1,_e.value=!1,Re.value=!1,Bn(),Pn(),pl(),yield O(),yield ho(Oe.value)}catch(o){je.value=!1,Wl.value=!1,No()}}));const Co=M(0),Mo=v(()=>String(Co.value));let Bo=!1;function Po(){var e;const l=wo();return JSON.stringify({kind:Il.value,language:$e.value,structural:Mo.value,optionsRevision:Co.value,settledContentGeneration:Xl.value,theme:null!=(e=yo(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:ht;gt.value=l,yt.value=l,bt.value=null,wt.value=null,kt.value=null}),P(()=>[s.codeBlockOptions,s.showLineNumbers],()=>{Co.value+=1,!1===s.stream&&!1!==s.loading&&(Bo=!0)},{deep:!0}),P(()=>[ct.value,s.node.originalCode,s.node.updatedCode],()=>{Jl.value+=1,Gn()||(Xl.value+=1)});const Ho=v(()=>Po());function Oo(){Gl.value&&Yl.value!==Ho.value&&(Gl.value=!1,Yl.value=null,Ql=null,et=null,_e.value=!1,je.value=!1,Re.value=!1,Wl.value=!1,Ul.value=!1)}function Fo(){return Oo(),Gl.value&&Yl.value===Ho.value}function No(e=Ho.value){Yl.value=e,Gl.value=!0,Ul.value=!1}return P(Ho,()=>d(null,null,function*(){if(Zl)return;if(!Gl.value)return;if(Yl.value===Ho.value)return;if(!rl||!Oe.value||Vl.value||Ie||!tl.value)return;if(!1===s.stream&&!1!==s.loading)return;if(Jn())return;const e=Ho.value;Zl=!0;try{if(Oo(),Gl.value)return;yield ho(Oe.value)}catch(l){je.value=!1,Wl.value=!1,No()}finally{et=e,yield O(),Zl=!1}})),P(()=>[s.codeBlockOptions,tl.value],()=>{var e,l;if(So(),!rl||!tl.value)return;const t=Fl.value?ml():fl(),n="number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize)?s.codeBlockOptions.fontSize:Number.isFinite(yt.value)?yt.value:void 0;"number"==typeof n&&Number.isFinite(n)&&n>0&&(null==(l=null==t?void 0:t.updateOptions)||l.call(t,{fontSize:n})),Hn(!1)},{deep:!0}),P(()=>[wo(),Rl.value,qe.value,_e.value,tl.value],([e],l)=>{qe.value&&je.value&&tl.value&&ko({appearanceOnly:null!=l&&bo(e,l[0])})},{flush:"post"}),P(()=>[Mo.value,qe.value,tl.value],(e,l)=>d(null,[e,l],function*([e,l,t],[n]){if(So(),!l||!t)return;if(!rl||!Oe.value)return;if(!_e.value)return;if(e===n)return;if(!1===s.stream&&!1!==s.loading)return void(Bo=!0);Bo=!1;const o=bl;if(o){try{yield o}catch(a){}if(Ie||!Oe.value)return}try{je.value=!1,Wl.value=!1,_e.value=!1,Re.value=!1,Bn(),Pn(),pl(),Ol&&mt(Ol),yield O(),yield ho(Oe.value,{allowStaleContentRetry:!1})}catch(r){je.value=!1,Wl.value=!1,No()}}),{flush:"post"}),P(()=>[s.loading,tl.value],([e,l])=>{!1===e&&l&&Bo&&(Bo=!1,Co.value+=1)},{flush:"post"}),P(()=>[s.loading,tl.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&&Fl.value&&_e.value&&(yield O(),de(()=>{d(null,null,function*(){const e=bl;if(e)try{yield e}catch(l){}!Ie&&Fl.value&&!1!==s.loading&&(So(),zl(),En())})})),e)return;const o=void 0!==n&&!1!==n;yield O(),de(()=>{d(null,null,function*(){var e,l;try{if(o&&(yield function(){return d(this,null,function*(){if(!Gl.value)return!1;if(!rl||!Oe.value||Vl.value||Ie||!tl.value)return!1;if(et===Ho.value)return!0;Zl=!0;try{Gl.value=!1,Yl.value=null,Ql=null,_e.value=!1,je.value=!1,Re.value=!1,Wl.value=!1,Bn(),Pn(),pl(),Ol&&mt(Ol),yield O();try{yield ho(Oe.value)}catch(e){je.value=!1,Wl.value=!1,No()}}finally{yield O(),Zl=!1}return!0})}()))return void Hn(!1);if(o&&Fl.value&&_e.value&&lt&&Oe.value)return lt=!1,je.value=!1,Wl.value=!1,_e.value=!1,Re.value=!1,Bn(),Pn(),pl(),yield O(),yield ho(Oe.value,{allowStaleContentRetry:!1}),void Dn(!0);if(o&&_e.value)if(Fl.value&&Oe.value){const n=bl;if(n)try{yield n}catch(t){}So();const o=Dl(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:""));if(yield Vn(o.original,o.updated,$e.value),Ie||!Fl.value)return;yield Promise.resolve(vl()),zl(),Fn(!0),Gt(),Nn(),un();const a=yield An();Ie||!a||Wl.value||(yield Yt()),En(),Dn(!0)}else Zn(),lo(ct.value,$e.value),yield new Promise(e=>{const l=()=>{Ie?e():Kn||Xn?setTimeout(l,16):e()};l()}),Ie||Fl.value||(yield Promise.resolve(sl()));o&&Fl.value?(Hn({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),Dn(!0)):Hn(!1)}catch(n){}})})}),{immediate:!0,flush:"post"}),f(()=>{Bn(),Pn(),hl(),null==Ml||Ml()}),(l,t)=>{var n;return Vl.value?(m(),h(ie,{key:0,style:F(It.value),node:ft.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":tt.value,"diff-hide-unchanged-regions":nt.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Ot.value,"reserved-height-px":Fl.value&&null!=(n=xt.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:Fe,style:F(uo.value),class:y(["code-block-container rounded-lg border",[{dark:s.isDark,"is-rendering":s.loading,"is-dark":jl.value,"is-diff":Fl.value,"is-plain-text":Te.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":Wl.value&&!Vl.value?"true":"false","data-markstream-enhancement-state":st.value,"data-markstream-code-block-state":Gn()?"streaming":"settled","data-markstream-pending":dt.value?"true":void 0,"data-markstream-viewport-pending":al.value&&k(el)&&!tl.value?"true":void 0},[T(ue,{"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":Le.value,"is-expanded":ze.value,"copy-text":Ne.value,"is-previewable":Un.value,"code-font-size":yt.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":gt.value,"font-baseline-ready":St.value,"diff-stats":Fl.value?Nl.value:null,"diff-stats-aria-label":El.value,onToggleCollapse:fo,onDecreaseFont:vn,onResetFont:cn,onIncreaseFont:sn,onCopy:vo,onToggleExpand:co,onPreview:mo},N({"header-left":E(()=>[D(l.$slots,"header-left",{},()=>[g("div",be,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:io.value},null,8,we),g("div",ke,[g("div",xe,w(ao.value),1),ro.value?(m(),$("div",Se,w(ro.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":Le.value}])},[g("div",{ref_key:"codeEditor",ref:Oe,class:y(["code-editor-container",e.stream?"":"code-height-placeholder"]),"data-markstream-host-hidden":ut.value?"true":void 0,style:F(Wt.value)},null,14,Ce),it.value?(m(),h(ie,{key:0,style:F(It.value),node:ft.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":tt.value,"diff-hide-unchanged-regions":nt.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Ot.value,"reserved-height-px":Fl.value&&null!=(l=xt.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]]),vt.value&&!Pe.value&&Un.value&&"html"===Ee.value?(m(),h(ge,{key:0,code:s.node.code,"html-preview-allow-scripts":s.htmlPreviewAllowScripts,"html-preview-sandbox":s.htmlPreviewSandbox,"is-dark":s.isDark,"on-close":()=>vt.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,ye))}}}),[["__scopeId","data-v-7f563cd3"]]);export{Me 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 E,renderSlot as D,createElementBlock as $,createVNode as T,withDirectives as z,createCommentVNode as L,vShow as _}from"vue";import{ax as R,G as j,M as q,aj as I,az as A,aA as V,aw as W,aa as U,ah as G,b as Y,c as J,al as X,ag as K,a8 as Q,ad as Z,ak as ee,as as le,a7 as te}from"./exports.js";import{M as ne,f as oe,n as ae,c as re,l as ie}from"./index2.js";import{r as ue,_ as de,a as se}from"./PreCodeBlock.vue_vue_type_style_index_0_lang.js";import{safeRaf as ve,safeCancelRaf as ce}from"./utils/safeRaf.js";import{r as fe}from"./preCodeTheme.js";import{getStreamDiffsRuntime as me}from"./streamDiffs.js";const he={class:"html-preview-frame__header"},pe={class:"html-preview-frame__title"},ge={class:"html-preview-frame__label"},ye=["sandbox","srcdoc"],be=/* @__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",he,[g("div",pe,[t[3]||(t[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",ge,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,ye)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]),we=["data-markstream-enhanced","data-markstream-enhancement-state","data-markstream-code-block-state","data-markstream-pending","data-markstream-viewport-pending"],ke={class:"code-header-main"},xe=["innerHTML"],Se={class:"code-header-copy"},Ce={class:"code-header-title"},Me={key:0,class:"code-header-caption"},Be=["data-markstream-host-hidden"],Pe=/* @__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(),he=S(ne,null),pe=S("markstreamHostScrollManaged",null),ge=S(q,void 0),ye=v(()=>I(s,j));function Pe(e,l){}const He=C(),Oe=v(()=>{const e=null==He?void 0:He.vnode.props;return!(!e||!e.onPreviewCode&&!e["onPreview-code"])}),{t:Fe}=R(),Ne=M(null),Ee=M(null),De=M(!1),$e=M(Xn(s.node.language,s.node.code,Jn())),Te=v(()=>oe($e.value)),ze=v(()=>"plaintext"===Te.value?"text":Te.value),Le=v(()=>"plaintext"===Te.value),_e=M(!1),Re=M(!1),je=M(!1),qe=M(!1),Ie=M(!1),Ae=M(!1);let Ve=!1,We=null,Ue=null,Ge=null,Ye=0,Je=!1,Xe="";const Ke=M(null);let Qe=0,Ze=!1;const el=A(),ll=V(),tl=W(),nl=B(null),ol=M("undefined"==typeof window||!tl.value),al=null!=(o=null==(n=null==(t=C())?void 0:t.vnode.el)?void 0:n.textContent)?o:"",rl="undefined"!=typeof window&&String(null!=(a=s.node.code)?a:"").length>0&&al.includes(String(s.node.code)),il=M(!rl);c(()=>{il.value=!0}),"undefined"!=typeof window&&P([()=>Ee.value,tl],([e,l],t,n)=>{var o,a,r;if(null==(o=nl.value)||o.destroy(),nl.value=null,!l||ol.value)return void(ol.value=!0);if(!e)return void(ol.value=!1);let i=!0;const u=null!=(r=null!=(a=null==ll?void 0:ll.value.heavyBlockMargin)?a:null==ll?void 0:ll.value.rootMargin)?r:"0px",d=el(e,{rootMargin:u,allowIdle:!1});nl.value=d,ol.value=ol.value||d.isVisible.value,d.whenVisible.then(()=>{i&&nl.value===d&&(ol.value=!0)}).catch(()=>{}),n(()=>{i=!1,d.destroy(),nl.value===d&&(nl.value=null)})},{immediate:!0}),H(()=>{var e;Ve=!0,function(){const e=Xe;he&&e&&(Xe="",he.markSettled(e))}(),null==(e=nl.value)||e.destroy(),nl.value=null});let ul=null,dl=null,sl=()=>{},vl=()=>{},cl=()=>{},fl=()=>{},ml=()=>null,hl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),pl=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),gl=()=>{},yl=()=>{},bl=()=>{},wl=null,kl=null,xl=null,Sl=null,Cl=()=>{var e;return String(null!=(e=s.node.language)?e:"plaintext")},Ml=()=>d(null,null,function*(){}),Bl=!1,Pl=null;const Hl=[],Ol=[];let Fl=null,Nl=null;const El=v(()=>U(s.node)),Dl=M({removed:0,added:0}),$l=v(()=>`-${Dl.value.removed} +${Dl.value.added}`);function Tl(e,l){return{original:e,updated:l}}function zl(e){return String(null!=e?e:"").replace(/\r\n$|\n$|\r$/,"")}function Ll(e){var l;return String(null!=(l=null==e?void 0:e.message)?l:e).includes("no diff result available")}function _l(){if(!In())try{const e=bl();e&&"function"==typeof e.catch&&e.catch(e=>{Ll(e)})}catch(e){Ll(e)}}const Rl=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(!El.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)})}),jl=v(()=>{return(void 0!==s.theme?(e=s.theme)&&"object"==typeof e&&"light"in e&&"dark"in e:!ko(s.darkTheme,s.lightTheme))?!!s.isDark:function(e){var l;const t=null!=(l=wo(e))?l:"";return Z(t,!0===s.isDark)}(xo());var e}),ql=v(()=>(El.value,jl.value?"dark":"light")),Il=v(()=>El.value?"dark"===ql.value:jl.value),Al=v(()=>fe({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})),Vl=v(()=>El.value?"diff":"single"),Wl=M(Vl.value),Ul=M(!1),Gl=M(!1),Yl=M(!1),Jl=M(!1),Xl=M(null),Kl=M(0),Ql=M(0),Zl=M(!1);let et=null,lt=!1,tt=null,nt=!1;const ot=v(()=>{var e;return!!El.value&&"unified"===(null==(e=Rl.value)?void 0:e.diffStyle)}),at=v(()=>G(Rl.value));function rt(e){return!0===(null==pe?void 0:pe.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 it=v(()=>rt(Ee.value)),ut=v(()=>!(Ul.value||!Jl.value&&Gl.value)),dt=v(()=>ut.value),st=v(()=>ut.value&&!Yl.value),vt=v(()=>!Ul.value&&!Jl.value&&ut.value),ct=v(()=>Gl.value&&!Ul.value?"ready":Jl.value?"fallback":"pending"),ft=M(!1),mt=v(()=>zl(s.node.code)),ht=v(()=>El.value?!0===s.node.diff?s.node:u(i({},s.node),{diff:!0}):mt.value===s.node.code?s.node:u(i({},s.node),{code:mt.value}));function pt(e){const l=e.detectLanguage;"function"==typeof l&&(Cl=l),Nl=e,Fl=Co();const t=e.createCodeBlockRuntime(Fl);return!!t&&(ul=t.createEditor||ul,dl=t.createDiffEditor||dl,sl=t.updateCode||sl,vl=t.updateDiff||vl,cl=t.finalizeCode||cl,fl=t.finalizeDiff||fl,ml=t.getEditor||ml,hl=t.getEditorView||hl,pl=t.getDiffEditorView||pl,gl=t.cleanupEditor||gl,yl=t.safeClean||t.cleanupEditor||yl,bl=t.refreshDiffPresentation||bl,Ml=t.setTheme||Ml,wl=t.whenVisualReady||null,Ae.value=!0,!0)}const gt=Y,yt=J,bt=M("number"==typeof(null==(r=s.codeBlockOptions)?void 0:r.fontSize)?s.codeBlockOptions.fontSize:Number.NaN),wt=M(bt.value),kt=M(null),xt=M(null),St=M(null),Ct=M(null),Mt=v(()=>{const e=bt.value,l=wt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof l&&Number.isFinite(l)&&l>0}),Bt=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=wt.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:gt}),Pt=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.lineHeight;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:Bt.value===gt?yt:Math.max(12,Math.round(1.5*Bt.value))}),Ht=v(()=>Pt.value),Ot=v(()=>{var e;const l=null==(e=s.codeBlockOptions)?void 0:e.tabSize;return"number"==typeof l&&Number.isFinite(l)&&l>0?l:4}),Ft=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}}),Nt=v(()=>{const e=X(s.codeBlockOptions);return u(i({},e),{fontSize:Bt.value,lineHeight:Ht.value,maxHeight:Gn(),padding:Ft.value.top,paddingBottom:Ft.value.bottom,tabSize:Ot.value})}),Et=v(()=>{const e=s.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null});function Dt(e){if(null==e)return null;const l=Math.ceil(e);return!Number.isFinite(l)||l<=0?null:Math.min(l,Math.ceil(Gn()))}function $t(){return!El.value&&!1!==s.stream&&!1!==s.loading}const Tt=M($t());function zt(){return $t()||Tt.value}const Lt=v(()=>El.value?null:null==Et.value||zt()?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})(mt.value)*Ht.value+1):null),_t=v(()=>{if(El.value)return null;const e=Et.value;return null==e||zt()?Dt(Lt.value):Dt(e)}),Rt=v(()=>{const e=s.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),jt=M(null);function qt(){const e=jt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}const It=v(()=>{const e=qt();return null!=e?e:!El.value&&Zl.value?null:ut.value||!Gl.value?_t.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":e?"hsl(0 0% 7% / 0.98)":"hsl(var(--ms-muted) / 0.45)","--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 Vt=v(()=>{const e=Dt(Et.value),l=Dt(Lt.value),t=zt(),n=i({},El.value||null==e||t?El.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"]=`${Ft.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",El.value){n["--markstream-pre-diff-line-height"]=`${Ht.value}px`,n["--markstream-pre-diff-pane-bottom-padding"]=(ot.value,"0px");const e=Ct.value;null!=e&&e>0&&(n.height=`${e}px`,n.minHeight=`${e}px`,n.maxHeight=`${e}px`),Object.assign(n,At(Il.value))}return n}),Wt=v(()=>null!=It.value&&(!Gl.value||null!=qt())),Ut=v(()=>{const e=It.value;if(null==e)return null;if(El.value)return Math.ceil(e);const l=Rt.value,t=Et.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)}),Gt=v(()=>{if(El.value&&ut.value)return{};const e=It.value;return Wt.value&&null!=e?{minHeight:`${e}px`}:{}});function Yt(){jt.value=null}function Jt(){var e,l,t,n,o,a,r,i;const u=null==(e=Ee.value)?void 0:e.querySelector("pre.code-pre-fallback"),d=pl(),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 Xt(){return d(this,null,function*(){return El.value?(kn(),Zt(),En(!0),Jt(),Dn(),Yl.value=!0,yield O(),En(!0),yield ln(),En(!0),bn(),Zt(),!!(yield function(){return d(this,null,function*(){var e;if(!El.value)return!0;for(let l=0;l<4;l++){const l=Zt();En(!0),Kt(l),Qt(l),yield O(),yield ln();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})}())&&(Gl.value=!0,yield O(),Zt(),En(!0),bn(),Dn(),ve(()=>{Ve||ve(()=>{Ve||(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)):!(wl&&!(yield wl())||(kn(),En(!0),Yl.value=!0,yield O(),kn(),En(!0),yield ln(),kn(),En(!0),Gl.value=!0,yield O(),$n(),0))})}function Kt(e){var l;if(!El.value)return;const t=Ne.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`;Ct.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 Qt(e){var l,t,n;if(!El.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=Ne.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 Zt(){const e=Ne.value;if(e&&Rn(e)){Dn();const l=gn(e);if(null!=l&&l>0){const t=Math.ceil(l),n=Math.ceil(Gn()),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",ut.value&&(Ct.value=o,Kt(o)),Tn(),o}return Fn({preferModelDiffHeight:!0}),Kt(),Tn(),Number.parseFloat(e.style.height||"")||null}return kn()}function en(e,l=!1,t={}){const n=Math.ceil(e),o=qt();if(null==o)return n;const a=!0===t.allowBelowEstimatedFloor;return n>=o||a?((l||a)&&Ie.value&&Yt(),n):o}function ln(){return new Promise(e=>{let l=!1,t=null,n=null;const o=()=>{l||(l=!0,null!=n&&globalThis.clearTimeout(n),null!=t&&ce(t),e())};n=globalThis.setTimeout(o,50),t=ve(o)})}function tn(){var e;try{const l=Ne.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 nn(){var e,l,t,n,o,a;try{const a=El.value?null!=(t=null==(l=null==(e=pl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:pl():hl(),r=ml(),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=Ne.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 on(e){var l,t;try{const n=ml(),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=tn();if(n&&n>0)return n;const o=Number.isFinite(wt.value)&&wt.value>0?wt.value:14;return Math.max(12,Math.round(1.35*o))}function an(){var e;const l=null==(e=s.codeBlockOptions)?void 0:e.padding;return"number"==typeof l&&Number.isFinite(l)?2*Math.max(0,l):El.value?24:0}function rn(e){const l=zl(e);return l?l.split(/\r\n|\n|\r/):[]}function un(e){return!!Le.value||!!e&&(In(e)||null!=wl)}function dn(){var e,l;El.value?Dl.value=function(e,l){const t=rn(e),n=rn(l);let o=0,a=t.length-1,r=n.length-1;for(;o<=a&&o<=r&&t[o]===n[o];)o++;for(;a>=o&&r>=o&&t[a]===n[r];)a--,r--;const i=Math.max(0,a-o+1),u=Math.max(0,r-o+1);if(0===i||0===u)return{removed:i,added:u};if((i+1)*(u+1)<=15e5){const e=u+1;let l=new Uint32Array(e),a=new Uint32Array(e);for(let d=i-1;d>=0;d--){a[u]=0;for(let r=u-1;r>=0;r--)a[r]=t[o+d]===n[o+r]?l[r+1]+1:Math.max(l[r],a[r+1]);const e=l;l=a,a=e}const r=l[0];return{removed:i-r,added:u-r}}return{removed:i,added:u}}(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:"")):Dl.value={removed:0,added:0}}function sn(){dn()}function vn(){var e;if(Number.isFinite(wt.value)&&wt.value>0&&Number.isFinite(bt.value))return wt.value;if("number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize))return bt.value=s.codeBlockOptions.fontSize,wt.value=s.codeBlockOptions.fontSize,s.codeBlockOptions.fontSize;const l=nn();return l&&l>0?(bt.value=l,wt.value=l,l):(bt.value=12,wt.value=12,12)}function cn(){const e=vn(),l=Math.min(36,e+1);wt.value=l}function fn(){const e=vn(),l=Math.max(10,e-1);wt.value=l}function mn(){vn(),Number.isFinite(bt.value)&&(wt.value=bt.value)}function hn(){var e,l,t,n,o,a,r,i,u,d,s,v,c,f;try{const m=El.value?pl():null,h=El.value?m:hl();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(on(c),on(f)),x=an();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 El.value||(Zl.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=on(h);return Math.ceil(g*(y+1.5)+0)}catch(m){return null}}function pn(){var e,l;if(El.value)return!1;try{const t=null==(l=null==(e=hl())?void 0:e.getContentHeight)?void 0:l.call(e),n="number"==typeof t&&Number.isFinite(t)&&t>0;return n&&(Zl.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=nn();n&&n>0&&(kt.value=n,wt.value=n,bt.value=n);try{const n=on(El.value?null!=(t=null==(l=null==(e=pl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:pl():hl());n&&n>0&&(xt.value=n)}catch(o){}try{const e=tn();e&&e>0&&(xt.value=e)}catch(o){}}function wn(){return El.value&&dt.value}function kn(){var e;if(!ut.value)return null;const l=Ne.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=El.value?gn(l):null,a=Math.max(n,null!=o&&o>0?Math.ceil(o):0),r=Math.ceil(Gn()),i=Math.min(a,r);return!Number.isFinite(i)||i<=0?null:(El.value&&i>n&&(Ct.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=Ne.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(Ot.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",`${Ft.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=El.value?null!=(t=null==(l=null==(e=pl())?void 0:e.getModifiedEditor)?void 0:l.call(e))?t:pl():hl(),r=ml(),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&&(St.value=C),El.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(!Le.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,El.value],([e,l,t,n])=>{n||!1===e||!1===l||Tt.value?(n||!1===e)&&Tt.value&&(Tt.value=!1):(Tt.value=!0,Yt())},{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(El.value)return;if(function(e){return it.value||rt(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=Ne.value;if(!e)return;const l=e.getBoundingClientRect().height,t=hn();if(null!=t&&t>0){const n=en(t,!0,{allowBelowEstimatedFloor:!El.value&&Ie.value&&pn()}),o=qt();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=qt();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;Hl.length>0;)try{null==(l=null==(e=Hl.pop())?void 0:e.dispose)||l.call(e)}catch(t){}null!=We&&(ce(We),We=null),null!=Ue&&(ce(Ue),Ue=null),null!=Ge&&(ce(Ge),Ge=null),Ye=0,Je=!1}function On(){for(var e;Ol.length>0;)try{null==(e=Ol.pop())||e()}catch(l){}}function Fn(e=!1){Re.value||(_e.value?Pn():function(e={}){var l;try{const t=Ne.value;if(!t)return;const n=t.getBoundingClientRect().height,o=Gn(),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=El.value?function(){var e,l,t,n,o,a,r,i,u,d,s,v;if(In())return null;try{const c=pl(),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(on(f),on(m)),b=an(),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=El.value&&Rn(t);if(Qe>0&&(Qe--,null!=Ke.value))return void Bn(t,n,zn(t,Ke.value,o,{preserveScrollableOverflow:_n(t)}));if(El.value&&!d&&ut.value){const e=kn();if(null!=e){const l=zn(t,e,o,{allowBelowEstimatedFloor:!0});return En(!0),void Bn(t,n,l)}}const v=El.value&&!0===e.preferModelDiffHeight,c=El.value?gn(t):null,f=!El.value&&Ie.value&&pn(),m=El.value&&!1!==s.loading&&(null!=c||null!=u&&a>0&&u<a-1),h=null!=u;let p;if(El.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=ot.value&&null!=c||null!=c?h?Math.max(c,u):c:El.value&&!1!==s.loading?null!=u&&i>0&&u<i-1?u:i>0?i:null:u;else p=hn();if(El.value&&null!=p&&i>0&&(!1!==s.loading||!0===e.holdCurrentDiffHeight)&&(p=Math.max(p,i)),null!=p&&p>0)return void Bn(t,n,zn(t,p,o,{clearEstimatedFloor:!0,allowBelowEstimatedFloor:f||m,preserveScrollableOverflow:_n(t)}));if(null!=Ke.value)return void Bn(t,n,zn(t,Ke.value,o,{preserveScrollableOverflow:_n(t)}));const g=El.value&&!1!==s.loading?a:Math.max(a,null!=u&&u>0?u:0);if(g>0)return void Bn(t,n,zn(t,g,o));const y=qt();if(!(null==y||El.value&&!1!==s.loading&&d))return void Bn(t,n,zn(t,y,o));const b=Number.parseFloat(t.style.height);!Number.isNaN(b)&&b>0?Bn(t,n,zn(t,b,o)):El.value||Bn(t,n,zn(t,o,o))}catch(t){}}("object"==typeof e?e:{}))}function Nn(){Sn=0,Cn=0}function En(e=!1){var l,t,n;if(Re.value)return;const o=Ne.value;if(!o)return;const a=El.value?pl():hl();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 Dn(){On()}function $n(e=!1){if(Ve||null!=We)return;const l=()=>{Ve||(Dn(),Fn(e),En())};We=ve(()=>{We=null,l(),Ue=ve(()=>{Ue=null,l()})}),Tn()}function Tn(e=!1){if(!El.value||Ve||!e&&!1===s.loading)return;if(Je=Je||e,Ye=Math.max(Ye,e?18:6),null!=Ge)return;const l=()=>{if(Ge=null,!El.value||Ve||Ye<=0||!Je&&!1===s.loading)return Ye=0,void(Je=!1);Ye--,Dn(),Fn({preferModelDiffHeight:!0,holdCurrentDiffHeight:Je}),En(),Ye>0?Ge=ve(l):Je=!1};Ge=ve(l)}function zn(e,l,t,n={}){const o=El.value&&!1!==s.loading?gn(e):null,a=null!=o&&o>l+1?o:l,r=Math.min(a,t),i=!0===n.allowBelowEstimatedFloor,u=en(r,!0===n.clearEstimatedFloor,{allowBelowEstimatedFloor:i}),d=qt();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||Ln(e,u);return e.style.overflow=v?"auto":"hidden",u}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 Ze||Ln(e,null!=(l=Ke.value)?l:0)}function Rn(e=Ne.value){return In(e)}function jn(e=Ne.value){return In(e)}function qn(){var e,l;if(In())return!0;const t=null==(l=null==(e=hl())?void 0:e.getModel)?void 0:l.call(e);return"function"==typeof(null==t?void 0:t.getValue)&&t.getValue()===mt.value}function In(e=Ne.value){return Boolean(null==e?void 0:e.querySelector("diffs-container"))}function An(){return!1!==s.loading||Gl.value}function Vn(){const e=pl();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 Wn(){return d(this,null,function*(){if(!El.value)return!0;for(let e=0;e<30;e++){if(Ve)return!1;if(In())return yield O(),yield ln(),!Ve&&In();yield O(),yield ln()}return!1})}function Un(e,l,t){return d(this,null,function*(){try{return void(yield vl(e,l,t))}catch(n){if(!Ll(n))throw n}if(yield O(),yield ln(),!Ve&&El.value)try{yield vl(e,l,t)}catch(n){if(!Ll(n))throw n}})}function Gn(){var e,l;return null!=(l=null==(e=s.codeBlockOptions)?void 0:e.maxHeight)?l:500}const Yn=v(()=>s.isShowPreview&&("html"===$e.value||"svg"===$e.value));function Jn(){return"boolean"==typeof s.node.loading?s.node.loading:!0===s.loading}function Xn(e,l,t){return!t||function(){var e,l,t;if(!Jn())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:"")?ae(String(null!=e?e:"")):"plain"}function Kn(){return Jn()}let Qn=null,Zn=!1,eo=0;function lo(){Qn=null,eo++}function to(){return d(this,arguments,function*(e=eo){if(!Zn){Zn=!0;try{for(;Qn&&!Ve&&!El.value&&e===eo;){const e=Qn;Qn=null;try{yield Promise.resolve(sl(e.code,e.language)),yield O(),Ve||El.value||(Fn(!1),En())}catch(l){Pe()}}}finally{Zn=!1,!Qn||Ve||El.value||to()}}})}function no(e,l){Qn={code:e,language:l},to(eo)}P(()=>[s.node.language,s.node.code,s.node.raw,s.node.loading,s.loading],([e,l,t,n,o])=>{$e.value=Xn(e,l,"boolean"==typeof n?n:!0===o)}),P(()=>[s.node.originalCode,s.node.updatedCode,El.value],()=>{dn(),ve(()=>sn())},{immediate:!0});let oo=0;P(()=>[s.node.originalCode,s.node.updatedCode,ze.value,El.value,s.stream],e=>d(null,[e],function*([,,,e,l]){var t,n;const o=++oo;if(!e)return;if(Jn())return;if(!1===l&&!je.value)return;if(!1!==l&&ul&&!je.value&&Ne.value)try{yield go(Ne.value)}catch(u){}const a=xl;if(a&&!qe.value){try{yield a}catch(u){}if(Ve||!El.value||o!==oo)return}if(o!==oo)return;const r=Tl(String(null!=(t=s.node.originalCode)?t:""),String(null!=(n=s.node.updatedCode)?n:"")),i=!1===s.loading;i&&Mo();try{if(yield Un(r.original,r.updated,ze.value),Ve||!El.value||o!==oo)return;yield O(),En(!0),Dn(),Fn(!1===s.loading||{preferModelDiffHeight:!0}),En(!0),$n(!0)}catch(d){return}if(i){if(Ve||!El.value)return;_l(),Dn(),sn(),$n(),Tn(!0)}_e.value&&ve(()=>Pn())})),P(()=>s.node.code,e=>d(null,null,function*(){if(Jn())return;if(!1===s.stream)return;if($e.value||($e.value=ae(Cl(e))),El.value)return;const l=xl;if(l&&!qe.value){try{yield l}catch(t){}if(Ve||El.value)return}if(ul&&!je.value&&Ne.value)try{yield go(Ne.value)}catch(t){}no(zl(s.node.code),ze.value),_e.value&&ve(()=>Pn())}));const ao=v(()=>{const e=$e.value;return e?re[e]||e.charAt(0).toUpperCase()+e.slice(1):re[""]||"Plain Text"}),ro=v(()=>{var e;return K(String(null!=(e=s.node.raw)?e:""),ao.value,El.value)}),io=v(()=>ro.value.title),uo=v(()=>ro.value.caption),so=v(()=>(ie.value,ue($e.value||"",ge))),vo=v(()=>{const e={};e["--markstream-code-layout-character-width"]=null==St.value?"1ch":`${St.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),Wt.value&&!El.value&&!Re.value){const l=Ut.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)))",El.value||(e.borderColor="var(--markstream-code-border-color, var(--code-border))"),e}),co=v(()=>!1!==s.showTooltips);function fo(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(s.node.code)),De.value=!0,p("copy",s.node.code),setTimeout(()=>{De.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function mo(){_e.value=!_e.value;const e=El.value?pl():hl(),l=Ne.value;e&&l&&(_e.value?(l.style.maxHeight="none",l.style.overflow="visible",Fn(!0)):(l.style.overflow="auto",Fn(!0)))}function ho(){var e,l;if(Re.value=!Re.value,Re.value){if(Ze=!1,Ne.value){const t=Math.ceil((null==(l=(e=Ne.value).getBoundingClientRect)?void 0:l.call(e).height)||0);Ze=Ln(Ne.value,t)||"auto"===Ne.value.style.overflow||"auto"===Ne.value.style.overflowY,t>0&&(Ke.value=t)}}else Ne.value&&null!=Ke.value&&(Ne.value.style.height=`${Ke.value}px`),Qe=2,O(()=>{Re.value||Ve||(Fn(!0),En(!0))})}function po(){if(!Yn.value)return;const e=$e.value;if(Oe.value){const l="html"===e?"text/html":"image/svg+xml",t="html"===e?Fe("artifacts.htmlPreviewTitle")||"HTML Preview":Fe("artifacts.svgPreviewTitle")||"SVG Preview";return void p("previewCode",{node:s.node,artifactType:l,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(ft.value=!ft.value)}function go(e,l={}){if(!ul||Ve)return null;if(!1===s.stream&&!1!==s.loading)return null;if(No(),Eo())return null;if(Ul.value||Ne.value!==e)return null;if(Kn())return null;if(kl)return kl;if(je.value&&Ie.value)return Promise.resolve();const t=Oo(),n=Kl.value;let o=!1;je.value=!0,function(){const e=ye.value;he&&e&&Xe!==e&&(Xe&&he.markSettled(Xe),Xe=e,he.markPending(e))}();const a=d(null,null,function*(){try{yield function(e){return d(this,null,function*(){var l,t;if(!ul||Ve)return;const n=Vl.value;if(nt=!1,Jl.value=!1,Xl.value=null,qe.value=!1,Gl.value=!1,Yl.value=!1,kt.value=null,xt.value=null,St.value=null,Ct.value=null,Nn(),function(){if(Zl.value=!1,zt())return void(jt.value=null);const e=_t.value;jt.value=Ie.value||null==e?null:e}(),Hn(),On(),function(e){e.replaceChildren()}(e),Mo(),Ve)return;const o=d(null,null,function*(){var l,t;if("diff"===n){!function(){if(Bl||"undefined"==typeof window)return;Bl=!0;const e=e=>{var l;Ll("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),Pl=()=>{window.removeEventListener("error",e,!0),window.removeEventListener("unhandledrejection",e,!0),Bl=!1,Pl=null}}(),yl();const n=Tl(String(null!=(l=s.node.originalCode)?l:""),String(null!=(t=s.node.updatedCode)?t:""));dl?yield dl(e,n.original,n.updated,ze.value):yield ul(e,s.node.code,ze.value)}else yield ul(e,mt.value,ze.value);qe.value=!0}),a=o.finally(()=>{xl===a&&(xl=null)});if(xl=a,yield function(e){return d(this,null,function*(){if(!El.value)return void(yield e);let l,t=!1;for(e.then(()=>{t=!0},e=>{t=!0,l=e});;){if(Ve)return;if(t){if(l)throw l;return}if(Rn()&&Vn())return;yield O(),yield ln()}})}(a),Ve)return;if(Vl.value!==n)return;qe.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?pl():hl();null==(t=null==e?void 0:e.updateOptions)||t.call(e,{fontSize:r}),bt.value=r,wt.value=r}else if(!wn()){const e=nn();e&&e>0?(bt.value=e,wt.value=e):(bt.value=12,wt.value=12)}bn(),yield So(),_e.value||Re.value||Fn(!1),Ie.value=!0,Wl.value=n,function(){var e,l,t,n,o;if(Hn(),El.value){const n=pl(),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&&Hl.push(n)}catch(t){}};try{const e=null==(t=null==n?void 0:n.onDidUpdateDiff)?void 0:t.call(n,()=>{$n(),ve(()=>sn())});e&&Hl.push(e)}catch(r){}i(o,"onDidContentSizeChange"),i(a,"onDidContentSizeChange");const u=Ne.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=>{El.value&&An()&&e.some(e=>l(e.target)||Array.from(e.addedNodes).some(t)||Array.from(e.removedNodes).some(l))&&(Dn(),Fn({preferModelDiffHeight:!0}),En(),Tn())});n.observe(u,{attributeFilter:["class"],attributes:!0,childList:!0,characterData:!0,subtree:!0}),Hl.push({dispose:()=>n.disconnect()})}if(u&&"undefined"!=typeof ResizeObserver){const e=new ResizeObserver(()=>{if(!El.value)return;if(En(),!An())return;const e=gn(u);null!=e&&(Math.ceil(u.getBoundingClientRect().height||0)<=e+1||(Dn(),Fn({preferModelDiffHeight:!0}),En()))});e.observe(u),Hl.push({dispose:()=>e.disconnect()})}return}const a=hl();try{const e=null==(n=null==a?void 0:a.onDidContentSizeChange)?void 0:n.call(a,()=>$n());e&&Hl.push(e)}catch(r){}try{const e=null==(o=null==a?void 0:a.onDidLayoutChange)?void 0:o.call(a,()=>$n());e&&Hl.push(e)}catch(r){}}(),xn(),bn(),Dn(),sn(),$n(),yield O();let i=null;wl&&(i=yield wl(),i&&(yield O(),yield ln()));const u=null==i?"diff"===n?yield Wn():yield function(){return d(this,null,function*(){if(In())return yield O(),yield ln(),In();for(let e=0;e<30;e++){if(Ve||El.value)return!1;const e=Ne.value,l=qn(),t=jn(e),n=!mt.value.trim()||un(e);if(l&&t&&n&&(yield O(),yield ln(),!Ve&&!El.value&&qn()&&jn(Ne.value)&&(!mt.value.trim()||un(Ne.value))))return!0;yield O(),yield ln()}return!1})}():i;Ve||(u?(bn(),Zt(),(yield Xt())||Do()):Do())})}(e),et=null}catch(a){const e=Oo(),r=n!==Kl.value,i=!1!==l.allowStaleContentRetry&&r&&et!==e;if(t!==e||i)return i&&(et=e),o=!0,je.value=!1,Ie.value=!1,qe.value=!1,void(Gl.value=!1);throw Do(t),a}}).finally(()=>{kl===a&&(kl=null),function(){const e=Xe;he&&e&&(Xe="",O(()=>{var l,t;if(!Ve){const n=null!=(t=null==(l=Ee.value)?void 0:l.offsetHeight)?t:0;n>0&&he.reportHeight(e,n)}he.markSettled(e)}))}(),o&&!Ve&&queueMicrotask(()=>{var e;const l=Ne.value;l&&!Ve&&(null==(e=go(l))||e.catch(e=>{Ie.value=!1,Gl.value=!1,Do()}))})});return kl=a,a}P(co,e=>{e||Q()}),P(()=>wt.value,(e,l)=>{var t;const n=El.value?pl():hl();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(null==(t=n.updateOptions)||t.call(n,{fontSize:e}),Re.value||Fn(!0))},{flush:"post",immediate:!1});let yo=0;const bo=P(()=>[Ne.value,El.value,s.stream,s.loading,Ae.value,ol.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=++yo;if(!e)return;if(!a)return;if(Jn())return;if(lt)return;if(!1===t&&!1!==n)return;if(!ul){if(yield function(){return d(this,null,function*(){if("undefined"==typeof window||Ve)return;if(Ae.value||Ul.value)return;if(Sl)return Sl;const e=d(null,null,function*(){try{const e=yield me();if(Ve)return;if(!e)return void(Ul.value=!0);pt(e)}catch(e){if(Ve)return;Ul.value=!0}}).finally(()=>{Sl===e&&(Sl=null)});return Sl=e,e})}(),r!==yo)return;if(!1===s.stream&&!1!==s.loading)return;if(Kn())return;if(!ol.value)return;if(!ul||Ul.value||je.value||Eo()||Ve||Ne.value!==e)return}if(Kn())return;const i=go(e);if(i){try{yield i}catch(u){Ie.value=!1,Gl.value=!1,Do()}Ie.value&&Gl.value&&bo()}}));function wo(e){return"string"==typeof e?e:null}function ko(e,l){if(e===l)return!0;const t=wo(e),n=wo(l);return!!t&&t===n}function xo(){return ee({darkTheme:s.darkTheme,isDark:s.isDark,lightTheme:s.lightTheme,theme:s.theme,themes:s.themes})}function So(){return d(this,arguments,function*(e={}){Mo();const l=()=>{El.value&&_l(),ve(()=>{xn(),$n()})};if(e.appearanceOnly)return void l();const t=xo();if(t)try{yield le(function(){const e=s.themes;return e&&"string"==typeof e[0]&&"string"==typeof e[1]?{dark:e[0],light:e[1]}:xo()}()),yield Ml(t),l()}catch(n){}else l()})}function Co(){var e,l,t,n,o;const a=Nt.value,r=u(i({},Rl.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:Bt.value,lineHeight:Ht.value,theme:xo(),themeType:s.isDark?"dark":"light",disableLineNumbers:!b.value,disableFileHeader:!0,workerManager:null!=(o=null!=(n=null==(t=Rl.value)?void 0:t.workerManager)?n:te())?o:void 0,onThemeChange(){xn()}}),d=function(){var e;const l=null==(e=Rl.value)?void 0:e.fontFamily;return"string"==typeof l&&l.trim()?l.trim():El.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 Mo(){const e=Co();if(!Fl)return Fl=e,Fl;for(const l of Object.keys(Fl))l in e||delete Fl[l];return Object.assign(Fl,e),Fl}P(Vl,(e,l)=>d(null,null,function*(){if(e===l)return;if(Jl.value||lt)return;if(lo(),!ul||!Ne.value)return;if(!je.value)return;if(!1===s.stream&&!1!==s.loading)return;if(!ol.value)return;const t=kl;if(t){try{yield t}catch(n){}if(Ve||!Ne.value)return}if(Wl.value!==e||!je.value||!Ie.value)try{Ie.value=!1,Gl.value=!1,je.value=!1,qe.value=!1,Hn(),On(),yl(),yield O(),yield go(Ne.value)}catch(o){Ie.value=!1,Gl.value=!1,Do()}}));const Bo=M(0),Po=v(()=>String(Bo.value));let Ho=!1;function Oo(){var e;const l=xo();return JSON.stringify({kind:Vl.value,language:ze.value,structural:Po.value,optionsRevision:Bo.value,settledContentGeneration:Ql.value,theme:null!=(e=wo(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:gt;bt.value=l,wt.value=l,kt.value=null,xt.value=null,St.value=null}),P(()=>[s.codeBlockOptions,s.showLineNumbers],()=>{Bo.value+=1,!1===s.stream&&!1!==s.loading&&(Ho=!0)},{deep:!0}),P(()=>[mt.value,s.node.originalCode,s.node.updatedCode],()=>{Kl.value+=1,Jn()||(Ql.value+=1)});const Fo=v(()=>Oo());function No(){Jl.value&&Xl.value!==Fo.value&&(Jl.value=!1,Xl.value=null,et=null,tt=null,je.value=!1,Ie.value=!1,qe.value=!1,Gl.value=!1,Yl.value=!1)}function Eo(){return No(),Jl.value&&Xl.value===Fo.value}function Do(e=Fo.value){Xl.value=e,Jl.value=!0,Yl.value=!1}return P(Fo,()=>d(null,null,function*(){if(lt)return;if(!Jl.value)return;if(Xl.value===Fo.value)return;if(!ul||!Ne.value||Ul.value||Ve||!ol.value)return;if(!1===s.stream&&!1!==s.loading)return;if(Kn())return;const e=Fo.value;lt=!0;try{if(No(),Jl.value)return;yield go(Ne.value)}catch(l){Ie.value=!1,Gl.value=!1,Do()}finally{tt=e,yield O(),lt=!1}})),P(()=>[s.codeBlockOptions,ol.value],()=>{var e,l;if(Mo(),!ul||!ol.value)return;const t=El.value?pl():hl(),n="number"==typeof(null==(e=s.codeBlockOptions)?void 0:e.fontSize)?s.codeBlockOptions.fontSize:Number.isFinite(wt.value)?wt.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(()=>[xo(),ql.value,Ae.value,je.value,ol.value],([e],l)=>{Ae.value&&Ie.value&&ol.value&&So({appearanceOnly:null!=l&&ko(e,l[0])})},{flush:"post"}),P(()=>[Po.value,Ae.value,ol.value],(e,l)=>d(null,[e,l],function*([e,l,t],[n]){if(Mo(),!l||!t)return;if(!ul||!Ne.value)return;if(!je.value)return;if(e===n)return;if(!1===s.stream&&!1!==s.loading)return void(Ho=!0);Ho=!1;const o=kl;if(o){try{yield o}catch(a){}if(Ve||!Ne.value)return}try{Ie.value=!1,Gl.value=!1,je.value=!1,qe.value=!1,Hn(),On(),yl(),Nl&&pt(Nl),yield O(),yield go(Ne.value,{allowStaleContentRetry:!1})}catch(r){Ie.value=!1,Gl.value=!1,Do()}}),{flush:"post"}),P(()=>[s.loading,ol.value],([e,l])=>{!1===e&&l&&Ho&&(Ho=!1,Bo.value+=1)},{flush:"post"}),P(()=>[s.loading,ol.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&&El.value&&je.value&&(yield O(),ve(()=>{d(null,null,function*(){const e=kl;if(e)try{yield e}catch(l){}!Ve&&El.value&&!1!==s.loading&&(Mo(),_l(),$n())})})),e)return;const o=void 0!==n&&!1!==n;yield O(),ve(()=>{d(null,null,function*(){var e,l;try{if(o&&(yield function(){return d(this,null,function*(){if(!Jl.value)return!1;if(!ul||!Ne.value||Ul.value||Ve||!ol.value)return!1;if(tt===Fo.value)return!0;lt=!0;try{Jl.value=!1,Xl.value=null,et=null,je.value=!1,Ie.value=!1,qe.value=!1,Gl.value=!1,Hn(),On(),yl(),Nl&&pt(Nl),yield O();try{yield go(Ne.value)}catch(e){Ie.value=!1,Gl.value=!1,Do()}}finally{yield O(),lt=!1}return!0})}()))return void Fn(!1);if(o&&El.value&&je.value&&nt&&Ne.value)return nt=!1,Ie.value=!1,Gl.value=!1,je.value=!1,qe.value=!1,Hn(),On(),yl(),yield O(),yield go(Ne.value,{allowStaleContentRetry:!1}),void Tn(!0);if(o&&je.value)if(El.value&&Ne.value){const n=kl;if(n)try{yield n}catch(t){}Mo();const o=Tl(String(null!=(e=s.node.originalCode)?e:""),String(null!=(l=s.node.updatedCode)?l:""));if(yield Un(o.original,o.updated,ze.value),Ve||!El.value)return;yield Promise.resolve(fl()),_l(),En(!0),Jt(),Dn(),sn();const a=yield Wn();Ve||!a||Gl.value||(yield Xt()),$n(),Tn(!0)}else lo(),no(mt.value,ze.value),yield new Promise(e=>{const l=()=>{Ve?e():Zn||Qn?setTimeout(l,16):e()};l()}),Ve||El.value||(yield Promise.resolve(cl()));o&&El.value?(Fn({preferModelDiffHeight:!0,holdCurrentDiffHeight:!0}),Tn(!0)):Fn(!1)}catch(n){}})})}),{immediate:!0,flush:"post"}),f(()=>{Hn(),On(),gl(),null==Pl||Pl()}),(l,t)=>{var n;return Ul.value?(m(),h(de,{key:0,style:F(Vt.value),node:ht.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":ot.value,"diff-hide-unchanged-regions":at.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Nt.value,"reserved-height-px":El.value&&null!=(n=Ct.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:Ee,style:F(vo.value),class:y(["code-block-container rounded-lg border",[{dark:s.isDark,"is-rendering":s.loading,"is-dark":Il.value,"is-diff":El.value,"is-plain-text":Le.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":Gl.value&&!Ul.value?"true":"false","data-markstream-enhancement-state":ct.value,"data-markstream-code-block-state":Jn()?"streaming":"settled","data-markstream-pending":vt.value?"true":void 0,"data-markstream-viewport-pending":il.value&&k(tl)&&!ol.value?"true":void 0},[T(se,{"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":Re.value,"is-expanded":_e.value,"copy-text":De.value,"is-previewable":Yn.value,"code-font-size":wt.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":bt.value,"font-baseline-ready":Mt.value,"diff-stats":El.value?Dl.value:null,"diff-stats-aria-label":$l.value,onToggleCollapse:ho,onDecreaseFont:fn,onResetFont:mn,onIncreaseFont:cn,onCopy:fo,onToggleExpand:mo,onPreview:po},N({"header-left":E(()=>[D(l.$slots,"header-left",{},()=>[g("div",ke,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:so.value},null,8,xe),g("div",Se,[g("div",Ce,w(io.value),1),uo.value?(m(),$("div",Me,w(uo.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":Re.value}])},[g("div",{ref_key:"codeEditor",ref:Ne,class:y(["code-editor-container",e.stream?"":"code-height-placeholder"]),"data-markstream-host-hidden":st.value?"true":void 0,style:F(Gt.value)},null,14,Be),dt.value?(m(),h(de,{key:0,style:F(Vt.value),node:ht.value,loading:s.loading,"show-line-numbers":b.value,"diff-inline":ot.value,"diff-hide-unchanged-regions":at.value,"code-block-options":s.codeBlockOptions,"resolved-visual-options":Nt.value,"reserved-height-px":El.value&&null!=(l=Ct.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]]),ft.value&&!Oe.value&&Yn.value&&"html"===$e.value?(m(),h(be,{key:0,code:s.node.code,"html-preview-allow-scripts":s.htmlPreviewAllowScripts,"html-preview-sandbox":s.htmlPreviewSandbox,"is-dark":s.isDark,"on-close":()=>ft.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,we))}}}),[["__scopeId","data-v-359f3d4c"]]);export{Pe as default};
@@ -1 +1 @@
1
- var e=Object.defineProperty,a=Object.defineProperties,r=Object.getOwnPropertyDescriptors,t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,d=(a,r,t)=>r in a?e(a,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[r]=t,n=(e,a)=>{for(var r in a||(a={}))o.call(a,r)&&d(e,r,a[r]);if(t)for(var r of t(a))i.call(a,r)&&d(e,r,a[r]);return e},l=(e,t)=>a(e,r(t));import{defineComponent as s,h as m}from"vue";import{a8 as c,ae as f,ag as h,aj as p,J as g,af as u}from"./exports.js";import{r as b}from"./preCodeTheme.js";import{n as k,c as v}from"./index2.js";const w=s({name:"CodeBlockNodeLoadingContent",inheritAttrs:!1,props:["node","isDark","loading","stream","codeBlockOptions","showLineNumbers","theme","darkTheme","lightTheme","isShowPreview","enableFontSizeControl","minWidth","maxWidth","themes","showHeader","showCopyButton","showExpandButton","showPreviewButton","showCollapseButton","showFontSizeButtons","showTooltips","htmlPreviewAllowScripts","htmlPreviewSandbox","customId","estimatedHeightPx","estimatedContentHeightPx","estimatedDiffInline"],emits:["previewCode","copy"],setup(e,{attrs:a}){const r=e;return()=>{var e,t,o,i,d,s,w;const x=k(String(null!=(t=null==(e=r.node)?void 0:e.language)?t:"")),y=v[x]||(x?x.charAt(0).toUpperCase()+x.slice(1):v[""]),S=c(r.node),C=f(String(null!=(i=null==(o=r.node)?void 0:o.raw)?i:""),y,S),P=null!=(d=r.codeBlockOptions)?d:{},H=S&&(null!=(s=r.estimatedDiffInline)?s:h(P)),B=p(P),N=b({darkTheme:r.darkTheme,isDark:r.isDark,lightTheme:r.lightTheme,theme:r.theme,themes:r.themes}),O=!S&&"number"==typeof r.estimatedContentHeightPx&&Number.isFinite(r.estimatedContentHeightPx)?Math.min(B.maxHeight,Math.ceil(r.estimatedContentHeightPx)):B.maxHeight,j=null!=(w=r.showLineNumbers)?w:!0!==P.disableLineNumbers,W=l(n(l(n({fontSize:`${B.fontSize}px`,lineHeight:`${B.lineHeight}px`,tabSize:B.tabSize,paddingTop:`${B.padding}px`,paddingBottom:`${B.paddingBottom}px`,maxHeight:`${O}px`,overflow:"auto",overflowX:"wrap"===B.overflow?"hidden":"auto",overflowY:"auto",whiteSpace:"scroll"===B.overflow?"pre":"pre-wrap",overflowWrap:"wrap"===B.overflow?"anywhere":"normal",wordBreak:"normal","--markstream-pre-line-number-top":`${B.padding}px`},S?{"--markstream-pre-diff-line-height":`${B.lineHeight}px`}:{}),{"--markstream-code-font-family":B.fontFamily,"--markstream-code-fallback-bg":N.background,"--markstream-code-fallback-fg":N.foreground}),N.builtin?{"--markstream-code-theme-bg":N.background,"--markstream-code-theme-fg":N.foreground,"--markstream-code-theme-line-number":N.lineNumber}:{}),{"--markstream-diff-added-line-fill":N.diffAddedLine,"--markstream-diff-added-number-fill":N.diffAddedNumber,"--markstream-diff-metadata-bg":N.background,"--markstream-diff-metadata-fg":N.lineNumber,"--markstream-diff-removed-line-fill":N.diffRemovedLine,"--markstream-diff-removed-number-fill":N.diffRemovedNumber,"--markstream-pre-resolved-theme-bg":N.background,"--markstream-pre-resolved-theme-fg":N.foreground,"--markstream-pre-resolved-theme-line-number":N.lineNumber,backgroundColor:N.background,color:N.foreground,fontFamily:B.fontFamily}),z=()=>m("button",{class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0","aria-hidden":"true",disabled:!0,tabindex:-1,type:"button"},[m("svg",{class:"action-icon",width:"14",height:"14"})]),L=!1!==r.isShowPreview&&("html"===x||"svg"===x),T=!1!==r.showFontSizeButtons&&!1!==r.enableFontSizeControl||!1!==r.showExpandButton||L&&!1!==r.showPreviewButton,F=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},$=n(n(n(l(n({"--markstream-code-layout-character-width":"1ch","--markstream-code-fallback-bg":N.background,"--markstream-code-fallback-fg":N.foreground},N.builtin?{"--markstream-code-theme-bg":N.background,"--markstream-code-theme-fg":N.foreground,"--markstream-code-theme-line-number":N.lineNumber}:{}),{"--markstream-diff-added-line-fill":N.diffAddedLine,"--markstream-diff-added-number-fill":N.diffAddedNumber,"--markstream-diff-editor-bg":N.background,"--markstream-diff-removed-line-fill":N.diffRemovedLine,"--markstream-diff-removed-number-fill":N.diffRemovedNumber,"--markstream-diff-shell-bg":N.background,"--markstream-pre-resolved-theme-bg":N.background,"--markstream-pre-resolved-theme-fg":N.foreground,"--markstream-pre-resolved-theme-line-number":N.lineNumber,color:N.foreground,backgroundColor:N.background}),F(r.minWidth)?{minWidth:F(r.minWidth)}:{}),F(r.maxWidth)?{maxWidth:F(r.maxWidth)}:{}),S?{}:{borderColor:"var(--markstream-code-border-color, var(--code-border))"});return m("div",l(n({},a),{class:["code-block-container","rounded-lg","border",{dark:!0===r.isDark,"is-rendering":!1!==r.loading,"is-dark":N.dark,"is-diff":S,"is-plain-text":""===x||"plaintext"===x||"text"===x},a.class],style:[$,a.style],"data-markstream-code-block":"1","data-markstream-enhanced":"false","data-markstream-code-block-state":r.loading?"streaming":"settled","data-markstream-code-loading":"1"}),[!1===r.showHeader?null:m("div",{class:"code-block-header flex justify-between items-center border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)] border-[var(--code-border)] bg-[var(--code-header-bg)] text-[var(--code-fg)]"},[m("div",{class:"code-header-main",style:{minWidth:0,flex:"1 1 auto",display:"flex",alignItems:"center",gap:"var(--ms-gap-header-main, 0.625rem)",overflow:"hidden"}},[m("span",{class:"icon-slot h-4 w-4 flex-shrink-0","aria-hidden":"true",style:{display:"inline-flex",width:"1rem",height:"1rem",flex:"0 0 auto"}}),m("div",{class:"code-header-copy",style:{minWidth:0,display:"grid",gap:"2px"}},[m("div",{class:"code-header-title",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"var(--ms-text-label, 0.75rem)",fontWeight:"500",color:"var(--code-action-fg)"}},C.title),C.caption?m("div",{class:"code-header-caption",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.75rem",color:"var(--code-line-number)"}},C.caption):null])]),m("div",{class:"flex items-center gap-0.5",style:{visibility:"hidden"}},[S?m("div",{class:"code-diff-stats","aria-hidden":"true"},[m("span",{class:"code-diff-stat removed"},"-0"),m("span",{class:"code-diff-stat added"},"+0")]):null,!1===r.showCopyButton?null:z(),!1===r.showCollapseButton?null:z(),T?m("div",{class:"relative"},[z()]):null])]),m("div",{class:"code-block-shell-content",style:!1!==r.stream||!1===r.loading?void 0:{display:"none"}},[m(g,{node:r.node,loading:r.loading,showLineNumbers:j,reservedHeightPx:S||null==r.estimatedContentHeightPx?void 0:Math.min(r.estimatedContentHeightPx,B.maxHeight),diffInline:H,diffHideUnchangedRegions:S?u(P):void 0,class:["code-pre-fallback",{"is-wrap":"wrap"===B.overflow}],style:W,"data-markstream-code-theme":N.name,"data-markstream-code-loading":"1"})]),m("div",{class:"code-loading-placeholder",style:!1===r.stream&&!1!==r.loading?void 0:{display:"none"}},[m("div",{class:"loading-skeleton"},[m("div",{class:"skeleton-line"}),m("div",{class:"skeleton-line"}),m("div",{class:"skeleton-line short"})])]),m("span",{class:"sr-only","aria-live":"polite",role:"status"})])}}});export{w as default};
1
+ var e=Object.defineProperty,a=Object.defineProperties,r=Object.getOwnPropertyDescriptors,t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,d=(a,r,t)=>r in a?e(a,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[r]=t,n=(e,a)=>{for(var r in a||(a={}))o.call(a,r)&&d(e,r,a[r]);if(t)for(var r of t(a))i.call(a,r)&&d(e,r,a[r]);return e},l=(e,t)=>a(e,r(t));import{defineComponent as s,h as m}from"vue";import{aa as c,ag as f,ai as h,al as p,J as g,ah as u}from"./exports.js";import{r as b}from"./preCodeTheme.js";import{n as k,c as v}from"./index2.js";const w=s({name:"CodeBlockNodeLoadingContent",inheritAttrs:!1,props:["node","isDark","loading","stream","codeBlockOptions","showLineNumbers","theme","darkTheme","lightTheme","isShowPreview","enableFontSizeControl","minWidth","maxWidth","themes","showHeader","showCopyButton","showExpandButton","showPreviewButton","showCollapseButton","showFontSizeButtons","showTooltips","htmlPreviewAllowScripts","htmlPreviewSandbox","customId","estimatedHeightPx","estimatedContentHeightPx","estimatedDiffInline"],emits:["previewCode","copy"],setup(e,{attrs:a}){const r=e;return()=>{var e,t,o,i,d,s,w;const x=k(String(null!=(t=null==(e=r.node)?void 0:e.language)?t:"")),y=v[x]||(x?x.charAt(0).toUpperCase()+x.slice(1):v[""]),S=c(r.node),C=f(String(null!=(i=null==(o=r.node)?void 0:o.raw)?i:""),y,S),P=null!=(d=r.codeBlockOptions)?d:{},H=S&&(null!=(s=r.estimatedDiffInline)?s:h(P)),B=p(P),N=b({darkTheme:r.darkTheme,isDark:r.isDark,lightTheme:r.lightTheme,theme:r.theme,themes:r.themes}),O=!S&&"number"==typeof r.estimatedContentHeightPx&&Number.isFinite(r.estimatedContentHeightPx)?Math.min(B.maxHeight,Math.ceil(r.estimatedContentHeightPx)):B.maxHeight,W=null!=(w=r.showLineNumbers)?w:!0!==P.disableLineNumbers,j=l(n(l(n({fontSize:`${B.fontSize}px`,lineHeight:`${B.lineHeight}px`,tabSize:B.tabSize,paddingTop:`${B.padding}px`,paddingBottom:`${B.paddingBottom}px`,maxHeight:`${O}px`,overflow:"auto",overflowX:"wrap"===B.overflow?"hidden":"auto",overflowY:"auto",whiteSpace:"scroll"===B.overflow?"pre":"pre-wrap",overflowWrap:"wrap"===B.overflow?"anywhere":"normal",wordBreak:"normal","--markstream-pre-line-number-top":`${B.padding}px`},S?{"--markstream-pre-diff-line-height":`${B.lineHeight}px`}:{}),{"--markstream-code-font-family":B.fontFamily,"--markstream-code-fallback-bg":N.background,"--markstream-code-fallback-fg":N.foreground}),N.builtin?{"--markstream-code-theme-bg":N.background,"--markstream-code-theme-fg":N.foreground,"--markstream-code-theme-line-number":N.lineNumber}:{}),{"--markstream-diff-added-line-fill":N.diffAddedLine,"--markstream-diff-added-number-fill":N.diffAddedNumber,"--markstream-diff-metadata-bg":N.background,"--markstream-diff-metadata-fg":N.lineNumber,"--markstream-diff-removed-line-fill":N.diffRemovedLine,"--markstream-diff-removed-number-fill":N.diffRemovedNumber,"--markstream-pre-resolved-theme-bg":N.background,"--markstream-pre-resolved-theme-fg":N.foreground,"--markstream-pre-resolved-theme-line-number":N.lineNumber,backgroundColor:N.background,color:N.foreground,fontFamily:B.fontFamily}),z=()=>m("button",{class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0","aria-hidden":"true",disabled:!0,tabindex:-1,type:"button"},[m("svg",{class:"action-icon",width:"14",height:"14"})]),L=!1!==r.isShowPreview&&("html"===x||"svg"===x),T=!1!==r.showFontSizeButtons&&!1!==r.enableFontSizeControl||!1!==r.showExpandButton||L&&!1!==r.showPreviewButton,F=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},$=n(n(n(l(n({"--markstream-code-layout-character-width":"1ch","--markstream-code-fallback-bg":N.background,"--markstream-code-fallback-fg":N.foreground},N.builtin?{"--markstream-code-theme-bg":N.background,"--markstream-code-theme-fg":N.foreground,"--markstream-code-theme-line-number":N.lineNumber}:{}),{"--markstream-diff-added-line-fill":N.diffAddedLine,"--markstream-diff-added-number-fill":N.diffAddedNumber,"--markstream-diff-editor-bg":N.background,"--markstream-diff-removed-line-fill":N.diffRemovedLine,"--markstream-diff-removed-number-fill":N.diffRemovedNumber,"--markstream-diff-shell-bg":N.background,"--markstream-pre-resolved-theme-bg":N.background,"--markstream-pre-resolved-theme-fg":N.foreground,"--markstream-pre-resolved-theme-line-number":N.lineNumber,color:N.foreground,backgroundColor:N.background}),F(r.minWidth)?{minWidth:F(r.minWidth)}:{}),F(r.maxWidth)?{maxWidth:F(r.maxWidth)}:{}),S?{}:{borderColor:"var(--markstream-code-border-color, var(--code-border))"});return m("div",l(n({},a),{class:["code-block-container","rounded-lg","border",{dark:!0===r.isDark,"is-rendering":!1!==r.loading,"is-dark":N.dark,"is-diff":S,"is-plain-text":""===x||"plaintext"===x||"text"===x},a.class],style:[$,a.style],"data-markstream-code-block":"1","data-markstream-enhanced":"false","data-markstream-code-block-state":r.loading?"streaming":"settled","data-markstream-code-loading":"1"}),[!1===r.showHeader?null:m("div",{class:"code-block-header flex justify-between items-center border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)] border-[var(--code-border)] bg-[var(--code-header-bg)] text-[var(--code-fg)]"},[m("div",{class:"code-header-main",style:{minWidth:0,flex:"1 1 auto",display:"flex",alignItems:"center",gap:"var(--ms-gap-header-main, 0.625rem)",overflow:"hidden"}},[m("span",{class:"icon-slot h-4 w-4 flex-shrink-0","aria-hidden":"true",style:{display:"inline-flex",width:"1rem",height:"1rem",flex:"0 0 auto"}}),m("div",{class:"code-header-copy",style:{minWidth:0,display:"grid",gap:"2px"}},[m("div",{class:"code-header-title",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"var(--ms-text-label, 0.75rem)",fontWeight:"500",color:"var(--code-action-fg)"}},C.title),C.caption?m("div",{class:"code-header-caption",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.75rem",color:"var(--code-line-number)"}},C.caption):null])]),m("div",{class:"flex items-center gap-0.5",style:{visibility:"hidden"}},[S?m("div",{class:"code-diff-stats","aria-hidden":"true"},[m("span",{class:"code-diff-stat removed"},"-0"),m("span",{class:"code-diff-stat added"},"+0")]):null,!1===r.showCopyButton?null:z(),!1===r.showCollapseButton?null:z(),T?m("div",{class:"relative"},[z()]):null])]),m("div",{class:"code-block-shell-content",style:!1!==r.stream||!1===r.loading?void 0:{display:"none"}},[m(g,{node:r.node,loading:r.loading,showLineNumbers:W,reservedHeightPx:S||null==r.estimatedContentHeightPx?void 0:Math.min(r.estimatedContentHeightPx,B.maxHeight),diffInline:H,diffHideUnchangedRegions:S?u(P):void 0,class:["code-pre-fallback",{"is-wrap":"wrap"===B.overflow}],style:j,"data-markstream-code-theme":N.name,"data-markstream-code-loading":"1"})]),m("div",{class:"code-loading-placeholder",style:!1===r.stream&&!1!==r.loading?void 0:{display:"none"}},[m("div",{class:"loading-skeleton"},[m("div",{class:"skeleton-line"}),m("div",{class:"skeleton-line"}),m("div",{class:"skeleton-line short"})])]),m("span",{class:"sr-only","aria-live":"polite",role:"status"})])}}});export{w as default};
@@ -1 +1 @@
1
- var e=Object.defineProperty,o=Object.defineProperties,t=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,l=(o,t,a)=>t in o?e(o,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[t]=a,i=(e,o)=>{for(var t in o||(o={}))r.call(o,t)&&l(e,t,o[t]);if(a)for(var t of a(o))n.call(o,t)&&l(e,t,o[t]);return e},d=(e,a)=>o(e,t(a)),s=(e,o,t)=>new Promise((a,r)=>{var n=e=>{try{i(t.next(e))}catch(o){r(o)}},l=e=>{try{i(t.throw(e))}catch(o){r(o)}},i=e=>e.done?a(e.value):Promise.resolve(e.value).then(n,l);i((t=t.apply(e,o)).next())});import{defineComponent as c,ref as u,computed as m,openBlock as p,createElementBlock as v,Fragment as h,renderSlot as f,createElementVNode as g,toDisplayString as b,createCommentVNode as w,unref as k,normalizeStyle as y,withModifiers as x,createStaticVNode as B,createVNode as C,Transition as F,withCtx as S,withDirectives as T,normalizeClass as M,vShow as z,useAttrs as j,inject as H,onBeforeUnmount as P,createSlots as O,mergeProps as $,createBlock as E}from"vue";import{as as L,a6 as N,ao as R,M as _,a8 as A,ag as D,ae as I,aj as U,J as V}from"./exports.js";import{g as G,n as J,e as W,b as X,c as Y,l as q}from"./index2.js";import{r as K}from"./preCodeTheme.js";function Q(e,o){if(void 0===o)return G(e);if(o){const t=o(e);if(null!=t&&""!==t)return t}const t=J(e);return W(t)||X()}const Z={key:0,class:"code-block-header flex justify-between items-center border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)] border-[var(--code-border)] bg-[var(--code-header-bg)] text-[var(--code-fg)]"},ee={class:"flex items-center gap-0.5"},oe=["aria-label"],te={class:"code-diff-stat removed"},ae={class:"code-diff-stat added"},re=["aria-label"],ne={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},le={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},ie=["aria-pressed"],de={key:3,class:"relative"},se=["aria-expanded"],ce=["disabled"],ue=["disabled"],me=["disabled"],pe={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},ve={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},he={class:"code-loading-placeholder"},fe={class:"sr-only","aria-live":"polite",role:"status"},ge=/* @__PURE__ */c({__name:"CodeBlockShell",props:{showHeader:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showTooltips:{type:Boolean,default:!0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},stream:{type:Boolean,default:!1},isCollapsed:{type:Boolean,default:!1},isExpanded:{type:Boolean,default:!1},copyText:{type:Boolean,default:!1},isPreviewable:{type:Boolean,default:!1},codeFontSize:{},codeFontMin:{},codeFontMax:{},defaultCodeFontSize:{},fontBaselineReady:{type:Boolean,default:!1},diffStats:{},diffStatsAriaLabel:{}},emits:["toggleCollapse","decreaseFont","resetFont","increaseFont","copy","toggleExpand","preview"],setup(e,{emit:o}){const t=e,a=o,r=u(!1),n=u(null),l=u(null);function i(){N(!0),r.value=!r.value,r.value&&document.addEventListener("click",s,{once:!0,capture:!0})}function d(){N(!0),r.value=!1}function s(e){var o,t;const a=e.target;(null==(o=n.value)?void 0:o.contains(a))||(null==(t=l.value)?void 0:t.contains(a))?document.addEventListener("click",s,{once:!0,capture:!0}):d()}const c=m(()=>t.showFontSizeButtons&&t.enableFontSizeControl||t.showExpandButton||t.isPreviewable&&t.showPreviewButton),{t:j}=L(),H=m(()=>!1!==t.showTooltips);function P(e,o){H.value&&R(e.currentTarget,o,"top",!1,void 0,t.isDark)}function O(){H.value&&N()}function $(e){P(e,t.copyText?j("common.copied")||"Copied":j("common.copy")||"Copy")}const E=m(()=>{var e,o;return!!Number.isFinite(t.codeFontSize)&&(null!=(e=t.codeFontSize)?e:0)<=(null!=(o=t.codeFontMin)?o:0)}),_=m(()=>!t.fontBaselineReady||t.codeFontSize===t.defaultCodeFontSize),A=m(()=>{var e,o;return!!Number.isFinite(t.codeFontSize)&&(null!=(e=t.codeFontSize)?e:0)>=(null!=(o=t.codeFontMax)?o:100)});return(o,s)=>(p(),v(h,null,[t.showHeader?(p(),v("div",Z,[f(o.$slots,"header-left"),f(o.$slots,"header-right",{},()=>[g("div",ee,[e.diffStats?(p(),v("div",{key:0,class:"code-diff-stats","aria-label":e.diffStatsAriaLabel},[g("span",te,"-"+b(e.diffStats.removed),1),g("span",ae,"+"+b(e.diffStats.added),1)],8,oe)):w("",!0),t.showCopyButton?(p(),v("button",{key:1,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] disabled:opacity-40 disabled:cursor-not-allowed transition-colors","aria-label":e.copyText?k(j)("common.copied")||"Copied":k(j)("common.copy")||"Copy",onClick:s[0]||(s[0]=e=>a("copy")),onMouseenter:s[1]||(s[1]=e=>$(e)),onFocus:s[2]||(s[2]=e=>$(e)),onMouseleave:O,onBlur:O},[e.copyText?(p(),v("svg",le,[...s[14]||(s[14]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(p(),v("svg",ne,[...s[13]||(s[13]=[g("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[g("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),g("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],40,re)):w("",!0),t.showCollapseButton?(p(),v("button",{key:2,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] disabled:opacity-40 disabled:cursor-not-allowed transition-colors","aria-pressed":e.isCollapsed,onClick:s[3]||(s[3]=e=>a("toggleCollapse")),onMouseenter:s[4]||(s[4]=o=>P(o,e.isCollapsed?k(j)("common.expand")||"Expand":k(j)("common.collapse")||"Collapse")),onFocus:s[5]||(s[5]=o=>P(o,e.isCollapsed?k(j)("common.expand")||"Expand":k(j)("common.collapse")||"Collapse")),onMouseleave:O,onBlur:O},[(p(),v("svg",{style:y({rotate:e.isCollapsed?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[...s[15]||(s[15]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,ie)):w("",!0),c.value?(p(),v("div",de,[g("button",{ref_key:"moreBtnRef",ref:l,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] transition-colors","aria-expanded":r.value,"aria-haspopup":"true",onClick:x(i,["stop"]),onMouseenter:s[6]||(s[6]=e=>P(e,k(j)("common.more")||"More")),onFocus:s[7]||(s[7]=e=>P(e,k(j)("common.more")||"More")),onMouseleave:O,onBlur:O},[...s[16]||(s[16]=[B('<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="1em" height="1em" viewBox="0 0 24 24" class="action-icon"><g fill="currentColor"><circle cx="12" cy="5" r="1.5"></circle><circle cx="12" cy="12" r="1.5"></circle><circle cx="12" cy="19" r="1.5"></circle></g></svg>',1)])],40,se),C(F,{name:"code-menu"},{default:S(()=>[r.value?(p(),v("div",{key:0,ref_key:"moreMenuRef",ref:n,class:"code-more-menu min-w-[10rem] p-1 bg-[hsl(var(--ms-popover))] text-[hsl(var(--ms-popover-foreground))] border border-[var(--code-border)] shadow-[var(--ms-shadow-popover)]",role:"menu"},[t.showFontSizeButtons&&t.enableFontSizeControl?(p(),v(h,{key:0},[g("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:E.value,onClick:s[8]||(s[8]=e=>{k(N)(!0),a("decreaseFont")})},[s[17]||(s[17]=g("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14"})],-1)),g("span",null,b(k(j)("common.fontSmaller")||"Font size −"),1)],8,ce),g("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:_.value,onClick:s[9]||(s[9]=e=>{k(N)(!0),a("resetFont")})},[s[18]||(s[18]=g("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[g("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[g("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),g("path",{d:"M3 3v5h5"})])],-1)),g("span",null,b(k(j)("common.fontReset")||"Font size reset"),1)],8,ue),g("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:A.value,onClick:s[10]||(s[10]=e=>{k(N)(!0),a("increaseFont")})},[s[19]||(s[19]=g("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"})],-1)),g("span",null,b(k(j)("common.fontLarger")||"Font size +"),1)],8,me)],64)):w("",!0),t.showExpandButton?(p(),v("button",{key:1,type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] transition-colors",onClick:s[11]||(s[11]=e=>{d(),a("toggleExpand")})},[e.isExpanded?(p(),v("svg",pe,[...s[20]||(s[20]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])])):(p(),v("svg",ve,[...s[21]||(s[21]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])])),g("span",null,b(e.isExpanded?k(j)("common.collapse")||"Collapse":k(j)("common.expand")||"Expand"),1)])):w("",!0),e.isPreviewable&&t.showPreviewButton?(p(),v("button",{key:2,type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] transition-colors",onClick:s[12]||(s[12]=e=>{d(),a("preview")})},[s[22]||(s[22]=g("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[g("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[g("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),g("circle",{cx:"12",cy:"12",r:"3"})])],-1)),g("span",null,b(k(j)("common.preview")||"Preview"),1)])):w("",!0)],512)):w("",!0)]),_:1})])):w("",!0)])])])):w("",!0),T(g("div",{class:M(["code-block-shell-content",{"code-block-shell-content--collapsed":e.isCollapsed}])},[f(o.$slots,"default")],2),[[z,!!e.stream||!e.loading]]),T(g("div",he,[f(o.$slots,"loading",{},()=>[s[23]||(s[23]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))])],512),[[z,!e.stream&&e.loading]]),g("span",fe,b(e.copyText?k(j)("common.copied")||"Copied":""),1)],64))}}),be={class:"code-header-main"},we=["innerHTML"],ke={class:"code-header-copy"},ye={class:"code-header-title"},xe={key:0,class:"code-header-caption"},Be=/* @__PURE__ */c(d(i({},{inheritAttrs:!1}),{__name:"PreCodeBlock",props:{codeBlockOptions:{},darkTheme:{},isDark:{type:Boolean,default:!1},lightTheme:{},resolvedVisualOptions:{},showCopyButton:{type:Boolean,default:!0},showHeader:{type:Boolean,default:!0},showToolbar:{type:Boolean,default:!0},showTooltips:{type:Boolean,default:!0},theme:{},themes:{},node:{},loading:{type:Boolean},showLineNumbers:{type:Boolean,default:!0},diffInline:{type:Boolean},diffHideUnchangedRegions:{type:[Boolean,Object]},reservedHeightPx:{}},emits:["copy"],setup(e,{emit:o}){const t=e,l=o,c=j(),h=m(()=>{const e=c,{class:o,style:t}=e;return((e,o)=>{var t={};for(var l in e)r.call(e,l)&&o.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&a)for(var l of a(e))o.indexOf(l)<0&&n.call(e,l)&&(t[l]=e[l]);return t})(e,["class","style"])}),x=u(null),B=u(!1);let F;const T=H(_,void 0),M=m(()=>{var e,o;return null!=(o=t.showLineNumbers)?o:!0!==(null==(e=t.codeBlockOptions)?void 0:e.disableLineNumbers)}),z=m(()=>A(t.node)),L=m(()=>{var e;return!0===t.diffInline||z.value&&D(null!=(e=t.codeBlockOptions)?e:{})}),N=m(()=>{var e,o;return J(String(null!=(o=null==(e=t.node)?void 0:e.language)?o:""))}),R=m(()=>{const e=N.value;return e?Y[e]||e.charAt(0).toUpperCase()+e.slice(1):Y[""]||"Plain Text"}),G=m(()=>{var e,o;return I(String(null!=(o=null==(e=t.node)?void 0:e.raw)?o:""),R.value,A(t.node))}),W=m(()=>(q.value,Q(N.value,T))),X=m(()=>{var e;return null!=(e=t.resolvedVisualOptions)?e:U(t.codeBlockOptions)}),Z=m(()=>K({darkTheme:t.darkTheme,isDark:t.isDark,lightTheme:t.lightTheme,theme:t.theme,themes:t.themes})),ee=m(()=>d(i({"--markstream-code-fallback-bg":Z.value.background,"--markstream-code-fallback-fg":Z.value.foreground},Z.value.builtin?{"--markstream-code-theme-bg":Z.value.background,"--markstream-code-theme-fg":Z.value.foreground,"--markstream-code-theme-line-number":Z.value.lineNumber}:{}),{"--markstream-diff-added-line-fill":Z.value.diffAddedLine,"--markstream-diff-added-number-fill":Z.value.diffAddedNumber,"--markstream-diff-editor-bg":Z.value.background,"--markstream-diff-removed-line-fill":Z.value.diffRemovedLine,"--markstream-diff-removed-number-fill":Z.value.diffRemovedNumber,"--markstream-diff-shell-bg":Z.value.background,"--markstream-pre-resolved-theme-bg":Z.value.background,"--markstream-pre-resolved-theme-fg":Z.value.foreground,"--markstream-pre-resolved-theme-line-number":Z.value.lineNumber,backgroundColor:Z.value.background,color:Z.value.foreground})),oe=m(()=>["code-pre-fallback",c.class,{"is-wrap":"wrap"===X.value.overflow}]),te=m(()=>{var e;const o=X.value,a=null==(null==(e=t.codeBlockOptions)?void 0:e.padding)?"1ch":`${o.padding}px`,r=z.value&&"number"==typeof t.reservedHeightPx&&Number.isFinite(t.reservedHeightPx)&&t.reservedHeightPx>0?`${Math.ceil(t.reservedHeightPx)}px`:void 0;return i(d(i(d(i({"--markstream-code-font-family":o.fontFamily,"--markstream-code-padding-x":a,"--markstream-code-padding-y":`${o.padding}px`,"--markstream-code-padding-bottom":`${o.paddingBottom}px`,"--markstream-code-scrollbar-gutter":`${o.scrollbarGutter}px`,"--markstream-code-tab-size":String(o.tabSize)},z.value?{"--markstream-pre-diff-line-height":`${o.lineHeight}px`}:{}),{"--markstream-pre-line-number-top":`${o.padding}px`,"--markstream-pre-line-number-left":"0px","--markstream-pre-line-number-padding-left":"2ch","--markstream-pre-line-number-padding-right":"1ch","--markstream-pre-line-number-separator-width":"2px"}),Z.value.builtin?{"--markstream-code-theme-bg":Z.value.background,"--markstream-code-theme-fg":Z.value.foreground,"--markstream-code-theme-line-number":Z.value.lineNumber}:{}),{"--markstream-diff-added-line-fill":Z.value.diffAddedLine,"--markstream-diff-added-number-fill":Z.value.diffAddedNumber,"--markstream-diff-metadata-bg":Z.value.background,"--markstream-diff-metadata-fg":Z.value.lineNumber,"--markstream-diff-removed-line-fill":Z.value.diffRemovedLine,"--markstream-diff-removed-number-fill":Z.value.diffRemovedNumber,"--markstream-pre-resolved-theme-bg":Z.value.background,"--markstream-pre-resolved-theme-fg":Z.value.foreground,"--markstream-pre-resolved-theme-line-number":Z.value.lineNumber,"--markstream-pre-line-number-gap-to-code":a,"--markstream-diff-fallback-handoff-height":null!=r?r:"auto",backgroundColor:"var(--markstream-code-fallback-bg, var(--markstream-code-theme-bg, var(--markstream-pre-resolved-theme-bg)))",boxSizing:"border-box",color:"var(--markstream-code-fallback-fg, var(--markstream-code-theme-fg, var(--markstream-pre-resolved-theme-fg)))",fontFamily:o.fontFamily,fontSize:`${o.fontSize}px`,lineHeight:`${o.lineHeight}px`,margin:"0",maxHeight:`${o.maxHeight}px`,overflow:"auto",overflowX:"wrap"===o.overflow?"hidden":"auto",overflowY:"auto",paddingBottom:`${o.paddingBottom}px`,paddingLeft:M.value?"var(--markstream-code-padding-left)":a,paddingRight:a,paddingTop:`${o.padding}px`,scrollbarGutter:z.value?"auto":"stable",tabSize:o.tabSize,whiteSpace:"scroll"===o.overflow?"pre":"pre-wrap",overflowWrap:"wrap"===o.overflow?"anywhere":"normal",wordBreak:"normal",width:"100%"}),r?{height:r,minHeight:r,maxHeight:r}:{})});function ae(){return s(this,null,function*(){const e=String(null!=(a=null==(o=t.node)?void 0:o.code)?a:"");var o,a;try{yield function(e){return s(this,null,function*(){if("undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return void(yield navigator.clipboard.writeText(e));if("undefined"==typeof document||!document.body)throw new Error("Clipboard API is unavailable");const o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style.position="fixed",o.style.opacity="0",document.body.appendChild(o),o.select();try{if(!document.execCommand("copy"))throw new Error("Clipboard copy command failed")}finally{o.remove()}})}(e),B.value=!0,l("copy",e),F&&clearTimeout(F),F=setTimeout(()=>{B.value=!1,F=void 0},1e3)}catch(r){B.value=!1,console.error("[markstream-vue] Failed to copy preformatted code.",r)}})}return P(()=>{F&&clearTimeout(F)}),(e,o)=>t.showToolbar?(p(),v("div",{key:0,style:y(ee.value),class:"code-block-container rounded-lg border"},[C(ge,{"show-header":t.showHeader,"show-copy-button":t.showCopyButton,"show-collapse-button":!1,"show-font-size-buttons":!1,"show-expand-button":!1,"show-preview-button":!1,"show-tooltips":t.showTooltips,"copy-text":B.value,stream:"",onCopy:ae},O({"header-left":S(()=>[f(e.$slots,"header-left",{},()=>[g("div",be,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:W.value},null,8,we),g("div",ke,[g("div",ye,b(G.value.title),1),G.value.caption?(p(),v("div",xe,b(G.value.caption),1)):w("",!0)])])])]),default:S(()=>[C(V,$({ref_key:"preNodeRef",ref:x},h.value,{class:oe.value,style:[k(c).style,te.value],node:t.node,loading:t.loading,"show-line-numbers":M.value,"diff-inline":L.value,"diff-hide-unchanged-regions":t.diffHideUnchangedRegions,"reserved-height-px":t.reservedHeightPx,"data-markstream-code-theme":Z.value.name}),null,16,["class","style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","reserved-height-px","data-markstream-code-theme"])]),_:2},[e.$slots["header-right"]?{name:"header-right",fn:S(()=>[f(e.$slots,"header-right")]),key:"0"}:void 0]),1032,["show-header","show-copy-button","show-tooltips","copy-text"])],4)):(p(),E(V,$({key:1,ref_key:"preNodeRef",ref:x},h.value,{class:oe.value,style:[k(c).style,te.value],node:t.node,loading:t.loading,"show-line-numbers":M.value,"diff-inline":L.value,"diff-hide-unchanged-regions":t.diffHideUnchangedRegions,"reserved-height-px":t.reservedHeightPx,"data-markstream-code-theme":Z.value.name}),null,16,["class","style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","reserved-height-px","data-markstream-code-theme"]))}}));export{Be as _,ge as a,Q as r};
1
+ var e=Object.defineProperty,o=Object.defineProperties,t=Object.getOwnPropertyDescriptors,a=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,l=(o,t,a)=>t in o?e(o,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[t]=a,i=(e,o)=>{for(var t in o||(o={}))r.call(o,t)&&l(e,t,o[t]);if(a)for(var t of a(o))n.call(o,t)&&l(e,t,o[t]);return e},d=(e,a)=>o(e,t(a)),s=(e,o,t)=>new Promise((a,r)=>{var n=e=>{try{i(t.next(e))}catch(o){r(o)}},l=e=>{try{i(t.throw(e))}catch(o){r(o)}},i=e=>e.done?a(e.value):Promise.resolve(e.value).then(n,l);i((t=t.apply(e,o)).next())});import{defineComponent as c,ref as u,computed as m,openBlock as p,createElementBlock as v,Fragment as h,renderSlot as f,createElementVNode as g,toDisplayString as b,createCommentVNode as w,unref as k,normalizeStyle as y,withModifiers as x,createStaticVNode as B,createVNode as C,Transition as F,withCtx as S,withDirectives as T,normalizeClass as M,vShow as z,useAttrs as H,inject as P,onBeforeUnmount as j,createSlots as O,mergeProps as $,createBlock as E}from"vue";import{ax as L,a8 as N,ar as R,M as _,aa as A,ai as D,ag as I,al as U,J as V}from"./exports.js";import{g as G,n as J,e as W,b as X,c as Y,l as q}from"./index2.js";import{r as K}from"./preCodeTheme.js";function Q(e,o){if(void 0===o)return G(e);if(o){const t=o(e);if(null!=t&&""!==t)return t}const t=J(e);return W(t)||X()}const Z={key:0,class:"code-block-header flex justify-between items-center border-b px-[var(--ms-inset-panel-x)] py-[var(--ms-inset-panel-y)] border-[var(--code-border)] bg-[var(--code-header-bg)] text-[var(--code-fg)]"},ee={class:"flex items-center gap-0.5"},oe=["aria-label"],te={class:"code-diff-stat removed"},ae={class:"code-diff-stat added"},re=["aria-label"],ne={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},le={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},ie=["aria-pressed"],de={key:3,class:"relative"},se=["aria-expanded"],ce=["disabled"],ue=["disabled"],me=["disabled"],pe={key:0,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},ve={key:1,xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},he={class:"code-loading-placeholder"},fe={class:"sr-only","aria-live":"polite",role:"status"},ge=/* @__PURE__ */c({__name:"CodeBlockShell",props:{showHeader:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},enableFontSizeControl:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showTooltips:{type:Boolean,default:!0},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},stream:{type:Boolean,default:!1},isCollapsed:{type:Boolean,default:!1},isExpanded:{type:Boolean,default:!1},copyText:{type:Boolean,default:!1},isPreviewable:{type:Boolean,default:!1},codeFontSize:{},codeFontMin:{},codeFontMax:{},defaultCodeFontSize:{},fontBaselineReady:{type:Boolean,default:!1},diffStats:{},diffStatsAriaLabel:{}},emits:["toggleCollapse","decreaseFont","resetFont","increaseFont","copy","toggleExpand","preview"],setup(e,{emit:o}){const t=e,a=o,r=u(!1),n=u(null),l=u(null);function i(){N(!0),r.value=!r.value,r.value&&document.addEventListener("click",s,{once:!0,capture:!0})}function d(){N(!0),r.value=!1}function s(e){var o,t;const a=e.target;(null==(o=n.value)?void 0:o.contains(a))||(null==(t=l.value)?void 0:t.contains(a))?document.addEventListener("click",s,{once:!0,capture:!0}):d()}const c=m(()=>t.showFontSizeButtons&&t.enableFontSizeControl||t.showExpandButton||t.isPreviewable&&t.showPreviewButton),{t:H}=L(),P=m(()=>!1!==t.showTooltips);function j(e,o){P.value&&R(e.currentTarget,o,"top",!1,void 0,t.isDark)}function O(){P.value&&N()}function $(e){j(e,t.copyText?H("common.copied")||"Copied":H("common.copy")||"Copy")}const E=m(()=>{var e,o;return!!Number.isFinite(t.codeFontSize)&&(null!=(e=t.codeFontSize)?e:0)<=(null!=(o=t.codeFontMin)?o:0)}),_=m(()=>!t.fontBaselineReady||t.codeFontSize===t.defaultCodeFontSize),A=m(()=>{var e,o;return!!Number.isFinite(t.codeFontSize)&&(null!=(e=t.codeFontSize)?e:0)>=(null!=(o=t.codeFontMax)?o:100)});return(o,s)=>(p(),v(h,null,[t.showHeader?(p(),v("div",Z,[f(o.$slots,"header-left"),f(o.$slots,"header-right",{},()=>[g("div",ee,[e.diffStats?(p(),v("div",{key:0,class:"code-diff-stats","aria-label":e.diffStatsAriaLabel},[g("span",te,"-"+b(e.diffStats.removed),1),g("span",ae,"+"+b(e.diffStats.added),1)],8,oe)):w("",!0),t.showCopyButton?(p(),v("button",{key:1,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] disabled:opacity-40 disabled:cursor-not-allowed transition-colors","aria-label":e.copyText?k(H)("common.copied")||"Copied":k(H)("common.copy")||"Copy",onClick:s[0]||(s[0]=e=>a("copy")),onMouseenter:s[1]||(s[1]=e=>$(e)),onFocus:s[2]||(s[2]=e=>$(e)),onMouseleave:O,onBlur:O},[e.copyText?(p(),v("svg",le,[...s[14]||(s[14]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(p(),v("svg",ne,[...s[13]||(s[13]=[g("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[g("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),g("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],40,re)):w("",!0),t.showCollapseButton?(p(),v("button",{key:2,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] disabled:opacity-40 disabled:cursor-not-allowed transition-colors","aria-pressed":e.isCollapsed,onClick:s[3]||(s[3]=e=>a("toggleCollapse")),onMouseenter:s[4]||(s[4]=o=>j(o,e.isCollapsed?k(H)("common.expand")||"Expand":k(H)("common.collapse")||"Collapse")),onFocus:s[5]||(s[5]=o=>j(o,e.isCollapsed?k(H)("common.expand")||"Expand":k(H)("common.collapse")||"Collapse")),onMouseleave:O,onBlur:O},[(p(),v("svg",{style:y({rotate:e.isCollapsed?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[...s[15]||(s[15]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],40,ie)):w("",!0),c.value?(p(),v("div",de,[g("button",{ref_key:"moreBtnRef",ref:l,type:"button",class:"code-action-btn inline-flex items-center justify-center p-[var(--ms-action-btn-padding)] rounded leading-none shrink-0 cursor-pointer text-[var(--code-action-fg)] hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] active:scale-[0.96] transition-colors","aria-expanded":r.value,"aria-haspopup":"true",onClick:x(i,["stop"]),onMouseenter:s[6]||(s[6]=e=>j(e,k(H)("common.more")||"More")),onFocus:s[7]||(s[7]=e=>j(e,k(H)("common.more")||"More")),onMouseleave:O,onBlur:O},[...s[16]||(s[16]=[B('<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="1em" height="1em" viewBox="0 0 24 24" class="action-icon"><g fill="currentColor"><circle cx="12" cy="5" r="1.5"></circle><circle cx="12" cy="12" r="1.5"></circle><circle cx="12" cy="19" r="1.5"></circle></g></svg>',1)])],40,se),C(F,{name:"code-menu"},{default:S(()=>[r.value?(p(),v("div",{key:0,ref_key:"moreMenuRef",ref:n,class:"code-more-menu min-w-[10rem] p-1 bg-[hsl(var(--ms-popover))] text-[hsl(var(--ms-popover-foreground))] border border-[var(--code-border)] shadow-[var(--ms-shadow-popover)]",role:"menu"},[t.showFontSizeButtons&&t.enableFontSizeControl?(p(),v(h,{key:0},[g("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:E.value,onClick:s[8]||(s[8]=e=>{k(N)(!0),a("decreaseFont")})},[s[17]||(s[17]=g("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14"})],-1)),g("span",null,b(k(H)("common.fontSmaller")||"Font size −"),1)],8,ce),g("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:_.value,onClick:s[9]||(s[9]=e=>{k(N)(!0),a("resetFont")})},[s[18]||(s[18]=g("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[g("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[g("path",{d:"M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8"}),g("path",{d:"M3 3v5h5"})])],-1)),g("span",null,b(k(H)("common.fontReset")||"Font size reset"),1)],8,ue),g("button",{type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors",disabled:A.value,onClick:s[10]||(s[10]=e=>{k(N)(!0),a("increaseFont")})},[s[19]||(s[19]=g("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"})],-1)),g("span",null,b(k(H)("common.fontLarger")||"Font size +"),1)],8,me)],64)):w("",!0),t.showExpandButton?(p(),v("button",{key:1,type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] transition-colors",onClick:s[11]||(s[11]=e=>{d(),a("toggleExpand")})},[e.isExpanded?(p(),v("svg",pe,[...s[20]||(s[20]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])])):(p(),v("svg",ve,[...s[21]||(s[21]=[g("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])])),g("span",null,b(e.isExpanded?k(H)("common.collapse")||"Collapse":k(H)("common.expand")||"Expand"),1)])):w("",!0),e.isPreviewable&&t.showPreviewButton?(p(),v("button",{key:2,type:"button",role:"menuitem",class:"flex items-center gap-2 w-full py-1.5 px-2 rounded text-xs text-[var(--code-action-fg)] cursor-pointer whitespace-nowrap hover:bg-[var(--code-action-hover-bg)] hover:text-[var(--code-action-hover-fg)] transition-colors",onClick:s[12]||(s[12]=e=>{d(),a("preview")})},[s[22]||(s[22]=g("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"action-icon"},[g("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[g("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),g("circle",{cx:"12",cy:"12",r:"3"})])],-1)),g("span",null,b(k(H)("common.preview")||"Preview"),1)])):w("",!0)],512)):w("",!0)]),_:1})])):w("",!0)])])])):w("",!0),T(g("div",{class:M(["code-block-shell-content",{"code-block-shell-content--collapsed":e.isCollapsed}])},[f(o.$slots,"default")],2),[[z,!!e.stream||!e.loading]]),T(g("div",he,[f(o.$slots,"loading",{},()=>[s[23]||(s[23]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))])],512),[[z,!e.stream&&e.loading]]),g("span",fe,b(e.copyText?k(H)("common.copied")||"Copied":""),1)],64))}}),be={class:"code-header-main"},we=["innerHTML"],ke={class:"code-header-copy"},ye={class:"code-header-title"},xe={key:0,class:"code-header-caption"},Be=/* @__PURE__ */c(d(i({},{inheritAttrs:!1}),{__name:"PreCodeBlock",props:{codeBlockOptions:{},darkTheme:{},isDark:{type:Boolean,default:!1},lightTheme:{},resolvedVisualOptions:{},showCopyButton:{type:Boolean,default:!0},showHeader:{type:Boolean,default:!0},showToolbar:{type:Boolean,default:!0},showTooltips:{type:Boolean,default:!0},theme:{},themes:{},node:{},loading:{type:Boolean},showLineNumbers:{type:Boolean,default:!0},diffInline:{type:Boolean},diffHideUnchangedRegions:{type:[Boolean,Object]},reservedHeightPx:{}},emits:["copy"],setup(e,{emit:o}){const t=e,l=o,c=H(),h=m(()=>{const e=c,{class:o,style:t}=e;return((e,o)=>{var t={};for(var l in e)r.call(e,l)&&o.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&a)for(var l of a(e))o.indexOf(l)<0&&n.call(e,l)&&(t[l]=e[l]);return t})(e,["class","style"])}),x=u(null),B=u(!1);let F;const T=P(_,void 0),M=m(()=>{var e,o;return null!=(o=t.showLineNumbers)?o:!0!==(null==(e=t.codeBlockOptions)?void 0:e.disableLineNumbers)}),z=m(()=>A(t.node)),L=m(()=>{var e;return!0===t.diffInline||z.value&&D(null!=(e=t.codeBlockOptions)?e:{})}),N=m(()=>{var e,o;return J(String(null!=(o=null==(e=t.node)?void 0:e.language)?o:""))}),R=m(()=>{const e=N.value;return e?Y[e]||e.charAt(0).toUpperCase()+e.slice(1):Y[""]||"Plain Text"}),G=m(()=>{var e,o;return I(String(null!=(o=null==(e=t.node)?void 0:e.raw)?o:""),R.value,A(t.node))}),W=m(()=>(q.value,Q(N.value,T))),X=m(()=>{var e;return null!=(e=t.resolvedVisualOptions)?e:U(t.codeBlockOptions)}),Z=m(()=>K({darkTheme:t.darkTheme,isDark:t.isDark,lightTheme:t.lightTheme,theme:t.theme,themes:t.themes})),ee=m(()=>d(i({"--markstream-code-fallback-bg":Z.value.background,"--markstream-code-fallback-fg":Z.value.foreground},Z.value.builtin?{"--markstream-code-theme-bg":Z.value.background,"--markstream-code-theme-fg":Z.value.foreground,"--markstream-code-theme-line-number":Z.value.lineNumber}:{}),{"--markstream-diff-added-line-fill":Z.value.diffAddedLine,"--markstream-diff-added-number-fill":Z.value.diffAddedNumber,"--markstream-diff-editor-bg":Z.value.background,"--markstream-diff-removed-line-fill":Z.value.diffRemovedLine,"--markstream-diff-removed-number-fill":Z.value.diffRemovedNumber,"--markstream-diff-shell-bg":Z.value.background,"--markstream-pre-resolved-theme-bg":Z.value.background,"--markstream-pre-resolved-theme-fg":Z.value.foreground,"--markstream-pre-resolved-theme-line-number":Z.value.lineNumber,backgroundColor:Z.value.background,color:Z.value.foreground})),oe=m(()=>["code-pre-fallback",c.class,{"is-wrap":"wrap"===X.value.overflow}]),te=m(()=>{var e;const o=X.value,a=null==(null==(e=t.codeBlockOptions)?void 0:e.padding)?"1ch":`${o.padding}px`,r=z.value&&"number"==typeof t.reservedHeightPx&&Number.isFinite(t.reservedHeightPx)&&t.reservedHeightPx>0?`${Math.ceil(t.reservedHeightPx)}px`:void 0;return i(d(i(d(i({"--markstream-code-font-family":o.fontFamily,"--markstream-code-padding-x":a,"--markstream-code-padding-y":`${o.padding}px`,"--markstream-code-padding-bottom":`${o.paddingBottom}px`,"--markstream-code-scrollbar-gutter":`${o.scrollbarGutter}px`,"--markstream-code-tab-size":String(o.tabSize)},z.value?{"--markstream-pre-diff-line-height":`${o.lineHeight}px`}:{}),{"--markstream-pre-line-number-top":`${o.padding}px`,"--markstream-pre-line-number-left":"0px","--markstream-pre-line-number-padding-left":"2ch","--markstream-pre-line-number-padding-right":"1ch","--markstream-pre-line-number-separator-width":"2px"}),Z.value.builtin?{"--markstream-code-theme-bg":Z.value.background,"--markstream-code-theme-fg":Z.value.foreground,"--markstream-code-theme-line-number":Z.value.lineNumber}:{}),{"--markstream-diff-added-line-fill":Z.value.diffAddedLine,"--markstream-diff-added-number-fill":Z.value.diffAddedNumber,"--markstream-diff-metadata-bg":Z.value.background,"--markstream-diff-metadata-fg":Z.value.lineNumber,"--markstream-diff-removed-line-fill":Z.value.diffRemovedLine,"--markstream-diff-removed-number-fill":Z.value.diffRemovedNumber,"--markstream-pre-resolved-theme-bg":Z.value.background,"--markstream-pre-resolved-theme-fg":Z.value.foreground,"--markstream-pre-resolved-theme-line-number":Z.value.lineNumber,"--markstream-pre-line-number-gap-to-code":a,"--markstream-diff-fallback-handoff-height":null!=r?r:"auto",backgroundColor:"var(--markstream-code-fallback-bg, var(--markstream-code-theme-bg, var(--markstream-pre-resolved-theme-bg)))",boxSizing:"border-box",color:"var(--markstream-code-fallback-fg, var(--markstream-code-theme-fg, var(--markstream-pre-resolved-theme-fg)))",fontFamily:o.fontFamily,fontSize:`${o.fontSize}px`,lineHeight:`${o.lineHeight}px`,margin:"0",maxHeight:`${o.maxHeight}px`,overflow:"auto",overflowX:"wrap"===o.overflow?"hidden":"auto",overflowY:"auto",paddingBottom:`${o.paddingBottom}px`,paddingLeft:M.value?"var(--markstream-code-padding-left)":a,paddingRight:a,paddingTop:`${o.padding}px`,scrollbarGutter:z.value?"auto":"stable",tabSize:o.tabSize,whiteSpace:"scroll"===o.overflow?"pre":"pre-wrap",overflowWrap:"wrap"===o.overflow?"anywhere":"normal",wordBreak:"normal",width:"100%"}),r?{height:r,minHeight:r,maxHeight:r}:{})});function ae(){return s(this,null,function*(){const e=String(null!=(a=null==(o=t.node)?void 0:o.code)?a:"");var o,a;try{yield function(e){return s(this,null,function*(){if("undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return void(yield navigator.clipboard.writeText(e));if("undefined"==typeof document||!document.body)throw new Error("Clipboard API is unavailable");const o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style.position="fixed",o.style.opacity="0",document.body.appendChild(o),o.select();try{if(!document.execCommand("copy"))throw new Error("Clipboard copy command failed")}finally{o.remove()}})}(e),B.value=!0,l("copy",e),F&&clearTimeout(F),F=setTimeout(()=>{B.value=!1,F=void 0},1e3)}catch(r){B.value=!1,console.error("[markstream-vue] Failed to copy preformatted code.",r)}})}return j(()=>{F&&clearTimeout(F)}),(e,o)=>t.showToolbar?(p(),v("div",{key:0,style:y(ee.value),class:"code-block-container rounded-lg border"},[C(ge,{"show-header":t.showHeader,"show-copy-button":t.showCopyButton,"show-collapse-button":!1,"show-font-size-buttons":!1,"show-expand-button":!1,"show-preview-button":!1,"show-tooltips":t.showTooltips,"copy-text":B.value,stream:"",onCopy:ae},O({"header-left":S(()=>[f(e.$slots,"header-left",{},()=>[g("div",be,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:W.value},null,8,we),g("div",ke,[g("div",ye,b(G.value.title),1),G.value.caption?(p(),v("div",xe,b(G.value.caption),1)):w("",!0)])])])]),default:S(()=>[C(V,$({ref_key:"preNodeRef",ref:x},h.value,{class:oe.value,style:[k(c).style,te.value],node:t.node,loading:t.loading,"show-line-numbers":M.value,"diff-inline":L.value,"diff-hide-unchanged-regions":t.diffHideUnchangedRegions,"reserved-height-px":t.reservedHeightPx,"data-markstream-code-theme":Z.value.name}),null,16,["class","style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","reserved-height-px","data-markstream-code-theme"])]),_:2},[e.$slots["header-right"]?{name:"header-right",fn:S(()=>[f(e.$slots,"header-right")]),key:"0"}:void 0]),1032,["show-header","show-copy-button","show-tooltips","copy-text"])],4)):(p(),E(V,$({key:1,ref_key:"preNodeRef",ref:x},h.value,{class:oe.value,style:[k(c).style,te.value],node:t.node,loading:t.loading,"show-line-numbers":M.value,"diff-inline":L.value,"diff-hide-unchanged-regions":t.diffHideUnchangedRegions,"reserved-height-px":t.reservedHeightPx,"data-markstream-code-theme":Z.value.name}),null,16,["class","style","node","loading","show-line-numbers","diff-inline","diff-hide-unchanged-regions","reserved-height-px","data-markstream-code-theme"]))}}));export{Be as _,ge as a,Q as r};