markstream-vue 0.0.14-beta.1 → 0.0.14-beta.3

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.
@@ -17,6 +17,7 @@ Use this skill when the host app is Angular and the task is to adopt the Angular
17
17
  - Use `MarkstreamAngularComponent` in `imports` and keep examples signal-friendly.
18
18
  5. Start with `[content]`.
19
19
  - Use `[final]`, `[codeBlockStream]`, and other streaming inputs only when the UI actually streams.
20
+ - Remember that `[htmlPolicy]` now defaults to `'safe'`, and Mermaid strict mode is on by default through `[mermaidProps]`.
20
21
  6. Use `[customHtmlTags]` and `[customComponents]` for trusted tag workflows.
21
22
  7. Validate with the smallest useful Angular dev or build command.
22
23
 
@@ -25,6 +26,8 @@ Use this skill when the host app is Angular and the task is to adopt the Angular
25
26
  - Standalone Angular first, NgModule-era patterns only when the repo still depends on them.
26
27
  - Treat streaming flags as opt-in.
27
28
  - Keep optional peers minimal and explicit.
29
+ - Keep `[htmlPolicy]="'safe'"` and Mermaid strict mode unless the task is preserving trusted legacy rendering.
30
+ - If a trusted surface needs broader old behavior, opt out locally with `[htmlPolicy]="'trusted'"` and `[mermaidProps]="{ isStrict: false }"`, and document that trust boundary.
28
31
 
29
32
  ## Useful Doc Targets
30
33
 
@@ -26,6 +26,7 @@ Read [references/patterns.md](references/patterns.md) before choosing an overrid
26
26
  - Pass the same custom-tag allowlist to nested renderers.
27
27
  5. Keep props and cleanup intact.
28
28
  - Preserve `node`, `loading`, `indexKey`, `customId`, and `isDark`.
29
+ - For `mermaid` and `infographic` overrides, preserve `estimatedPreviewHeightPx` so async preview shells keep stable height during remounts.
29
30
  - Remove temporary scoped mappings with `removeCustomComponents(customId)` when the scope is no longer needed.
30
31
  6. Validate with the smallest useful check.
31
32
  - Prefer a local demo, targeted test, or docs build.
@@ -17,15 +17,17 @@ Read [references/scenarios.md](references/scenarios.md) before making dependency
17
17
  2. Install the smallest peer set that matches the requested features.
18
18
  - Add peers only for features the user actually needs: Monaco, Mermaid, D2, KaTeX, or lightweight highlighting via `stream-markdown`.
19
19
  - Do not install every optional peer by default.
20
+ - For Vue 3 Monaco preloading, use `preloadCodeBlockRuntime` from `markstream-vue` so the renderer runtime knows Monaco is warm. Existing `getUseMonaco()` calls are still compatible.
20
21
  3. Fix CSS order.
21
22
  - Put reset styles before Markstream styles.
22
23
  - In Tailwind or UnoCSS projects, place `markstream-*/index.css` inside `@layer components`.
23
24
  - Import `katex/dist/katex.min.css` when math is enabled.
24
25
  4. Add the smallest working render example.
25
- - Use `content` for static or low-frequency rendering.
26
- - Use `nodes` plus `final` when the app receives streaming updates.
26
+ - Use `content` for static or low-frequency rendering.
27
+ - Use `nodes` plus `final` when the app receives streaming updates.
28
+ - Preserve the default hardening: HTML policies now default to `safe`, and Mermaid runs in strict mode by default.
27
29
  5. Keep customization scoped.
28
- - If the task requires overrides, prefer `customId` / `custom-id` plus scoped `setCustomComponents(...)`.
30
+ - If the task requires overrides, prefer `customId` / `custom-id` plus scoped `setCustomComponents(...)`.
29
31
  6. Validate.
30
32
  - Run the smallest relevant build, typecheck, test, or docs build command.
31
33
  - Report which peers were installed, where CSS lives, and whether the repo should later adopt `nodes`.
@@ -36,6 +38,8 @@ Read [references/scenarios.md](references/scenarios.md) before making dependency
36
38
  - Prefer `content` unless the app is clearly SSE, chat, token-streaming, or worker-preparsed.
37
39
  - Treat CSS order as a first-class part of installation, not a later cleanup.
38
40
  - When the request includes SSR, explicitly gate browser-only peers behind client-only boundaries.
41
+ - Do not widen HTML or Mermaid security defaults unless the user explicitly needs trusted legacy compatibility.
42
+ - If compatibility requires it, scope the opt-out to the trusted surface with `htmlPolicy` / `html-policy="trusted"` and `mermaidProps.isStrict = false` instead of changing app-wide defaults blindly.
39
43
 
40
44
  ## Useful Doc Targets
41
45
 
@@ -20,8 +20,9 @@ Read [references/adoption-checklist.md](references/adoption-checklist.md) before
20
20
  - `plugin-heavy`: remark, rehype, markdown-it, or other transform-heavy pipelines.
21
21
  - `security-heavy`: allow or deny lists, URL rewriting, sanitization, or raw HTML policies.
22
22
  3. Swap the renderer first.
23
- - Introduce the correct Markstream package and CSS.
24
- - Preserve user-visible behavior before adding richer Markstream-only features.
23
+ - Introduce the correct Markstream package and CSS.
24
+ - Preserve user-visible behavior before adding richer Markstream-only features.
25
+ - Audit whether the old renderer allowed broad raw HTML or Mermaid loose-mode HTML labels before claiming parity.
25
26
  4. Migrate custom renderers.
26
27
  - Convert tag-based renderers into node-type overrides with scoped `setCustomComponents`.
27
28
  - For trusted tag-like content, prefer `customHtmlTags`.
@@ -40,6 +41,7 @@ Read [references/adoption-checklist.md](references/adoption-checklist.md) before
40
41
  - Preserve safety over feature parity when HTML or security rules are involved.
41
42
  - Prefer explicit TODOs over vague claims.
42
43
  - Recommend against migration when the current stack depends heavily on transforms that Markstream does not mirror directly.
44
+ - When preserving trusted legacy behavior is necessary, use scoped `htmlPolicy` / `html-policy="trusted"` and `mermaidProps.isStrict = false` instead of weakening defaults everywhere.
43
45
 
44
46
  ## Useful Doc Targets
45
47
 
@@ -15,6 +15,7 @@ Use this skill when the host app is Nuxt and SSR boundaries matter.
15
15
  - Prefer `<client-only>` wrappers, `.client` plugins, or guarded setup paths.
16
16
  4. Import `markstream-vue/index.css` from a client-safe app shell or plugin.
17
17
  5. Start with `content`, and move to `nodes` plus `final` only when the UI is streaming.
18
+ - Remember that `html-policy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaid-props`.
18
19
  6. Validate with the smallest relevant Nuxt dev, build, or typecheck command.
19
20
 
20
21
  ## Default Decisions
@@ -22,6 +23,8 @@ Use this skill when the host app is Nuxt and SSR boundaries matter.
22
23
  - SSR safety comes before feature completeness.
23
24
  - Avoid import-time access to browser globals from server code paths.
24
25
  - Treat Monaco, Mermaid workers, and similar heavy peers as client-only unless the repo already has a proven SSR pattern.
26
+ - Keep `html-policy="safe"` and Mermaid strict mode unless the task is preserving trusted legacy rendering.
27
+ - If a trusted client-only surface needs older behavior, opt out locally with `html-policy="trusted"` and `:mermaid-props="{ isStrict: false }"`, and document why that surface is trusted.
25
28
 
26
29
  ## Useful Doc Targets
27
30
 
@@ -14,6 +14,7 @@ Use this skill when the host app is React or Next and the task is to wire Markst
14
14
  3. Import `markstream-react/index.css` from the app shell or client entry.
15
15
  4. Start with `content`.
16
16
  - Move to `nodes` plus `final` only when the UI receives streaming or high-frequency updates.
17
+ - Remember that `htmlPolicy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaidProps`.
17
18
  5. Respect SSR boundaries in Next.
18
19
  - Prefer `use client`, dynamic imports with `ssr: false`, or other client-only boundaries when browser-only peers are involved.
19
20
  6. Use scoped Markstream overrides before custom parser work.
@@ -24,6 +25,8 @@ Use this skill when the host app is React or Next and the task is to wire Markst
24
25
  - Renderer wiring first, migration cleanup second.
25
26
  - If the repo already uses `react-markdown`, pair this skill with `markstream-migration`.
26
27
  - Prefer the smallest client-only boundary that solves the SSR issue.
28
+ - Keep `htmlPolicy="safe"` and Mermaid strict mode unless the request is preserving trusted legacy rendering.
29
+ - If a trusted surface needs older behavior, use `htmlPolicy="trusted"` and `mermaidProps={{ isStrict: false }}` only on that surface and explain why.
27
30
 
28
31
  ## Useful Doc Targets
29
32
 
@@ -15,6 +15,7 @@ Use this skill when the host app is plain Vue 3, typically Vite-based, and not N
15
15
  - In Tailwind or UnoCSS projects, keep Markstream styles inside `@layer components`.
16
16
  4. Start with `<MarkdownRender :content="markdown" />`.
17
17
  - Switch to `nodes` plus `final` only for streaming, SSE, or high-frequency updates.
18
+ - Remember that `html-policy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaid-props`.
18
19
  5. Use `custom-id` plus scoped `setCustomComponents(...)` for overrides.
19
20
  6. Validate with the smallest useful dev, build, or typecheck command.
20
21
 
@@ -22,6 +23,9 @@ Use this skill when the host app is plain Vue 3, typically Vite-based, and not N
22
23
 
23
24
  - Vue 3 apps default to `content`.
24
25
  - Prefer local component registration unless the repo already uses a shared plugin entry.
26
+ - When Monaco code blocks need app-level preloading, import `preloadCodeBlockRuntime` from `markstream-vue`. Existing `getUseMonaco()` preloads remain valid; do not import `stream-monaco` directly just to warm workers.
27
+ - Keep `html-policy="safe"` and Mermaid strict mode unless the task is explicitly preserving trusted legacy behavior.
28
+ - If a trusted surface needs pre-hardening behavior, opt out locally with `html-policy="trusted"` and `:mermaid-props="{ isStrict: false }"`, and call out the trust boundary in the final handoff.
25
29
  - If the host is actually Nuxt, leave SSR-specific setup to `markstream-nuxt`.
26
30
 
27
31
  ## Useful Doc Targets
@@ -14,6 +14,7 @@ Use this skill when the host app is Vue 2 and not specifically a Vue CLI / Webpa
14
14
  - Add `@vue/composition-api` only when the repo is Vue 2.6 and uses Composition API patterns.
15
15
  3. Import `markstream-vue2/index.css` after resets.
16
16
  4. Start with `<MarkdownRender :content="markdown" />`.
17
+ - Remember that `html-policy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaid-props`.
17
18
  5. Use scoped custom component mappings when the task needs overrides or trusted tags.
18
19
  6. Validate with the smallest useful dev or build command.
19
20
 
@@ -23,6 +24,8 @@ Use this skill when the host app is Vue 2 and not specifically a Vue CLI / Webpa
23
24
  - Vue 2.6 needs `@vue/composition-api` only when the codebase actually relies on Composition API.
24
25
  - If the repo is Vue CLI / Webpack 4, prefer `markstream-vue2-cli`.
25
26
  - If the repo is Vue 2 plus Vite worker imports, prefer `markstream-vue2-vite`.
27
+ - Keep `html-policy="safe"` and Mermaid strict mode unless the task is preserving trusted legacy rendering.
28
+ - If a trusted surface needs older behavior, use `html-policy="trusted"` and `:mermaid-props="{ isStrict: false }"` only on that surface and explain why.
26
29
 
27
30
  ## Useful Doc Targets
28
31
 
@@ -16,6 +16,7 @@ Use this skill when the host app is Vue 2 on Vue CLI or another Webpack 4-style
16
16
  - Use `createKaTeXWorkerFromCDN(...)` and `createMermaidWorkerFromCDN(...)` when workers are needed.
17
17
  5. Prefer stable code block defaults over brittle Monaco wiring.
18
18
  - `MarkdownCodeBlockNode` plus `stream-markdown` is safer than Monaco in Webpack 4-era repos.
19
+ - Remember that `html-policy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaid-props`.
19
20
  6. Validate with the smallest useful local dev or build command.
20
21
 
21
22
  ## Default Decisions
@@ -23,6 +24,8 @@ Use this skill when the host app is Vue 2 on Vue CLI or another Webpack 4-style
23
24
  - Treat Monaco and worker-heavy setups as opt-in and fragile on Webpack 4.
24
25
  - Prefer CDN workers over bundler workers for Mermaid and KaTeX.
25
26
  - Keep the Vue 2 composition-api shim explicit when the repo is on Vue 2.6.
27
+ - Keep `html-policy="safe"` and Mermaid strict mode unless the task is preserving trusted legacy rendering.
28
+ - If a trusted surface needs older behavior, use `html-policy="trusted"` and `:mermaid-props="{ isStrict: false }"` only on that surface and explain why.
26
29
 
27
30
  ## Useful Doc Targets
28
31
 
@@ -15,6 +15,7 @@ Use this skill when the host app is Vue 2 and the bundler is Vite.
15
15
  4. Use Vite worker imports when the repo needs bundled workers.
16
16
  - `markstream-vue2/workers/... ?worker` or `?worker&inline` patterns are allowed here.
17
17
  5. Keep Composition API decisions explicit for Vue 2.6 repos.
18
+ - Remember that `html-policy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaid-props`.
18
19
  6. Validate with the smallest useful Vite dev or build command.
19
20
 
20
21
  ## Default Decisions
@@ -22,6 +23,8 @@ Use this skill when the host app is Vue 2 and the bundler is Vite.
22
23
  - Prefer bundled workers over CDN workers in Vite-based Vue 2 repos.
23
24
  - Keep UnoCSS or Tailwind resets before Markstream CSS.
24
25
  - Use the generic `markstream-vue2` skill only when the bundler-specific choice does not matter.
26
+ - Keep `html-policy="safe"` and Mermaid strict mode unless the task is preserving trusted legacy rendering.
27
+ - If a trusted surface needs older behavior, use `html-policy="trusted"` and `:mermaid-props="{ isStrict: false }"` only on that surface and explain why.
25
28
 
26
29
  ## Useful Doc Targets
27
30
 
@@ -1 +1 @@
1
- var e=Object.defineProperty,n=Object.defineProperties,t=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,r=(n,t,l)=>t in n?e(n,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[t]=l,a=(e,n)=>{for(var t in n||(n={}))o.call(n,t)&&r(e,t,n[t]);if(l)for(var t of l(n))i.call(n,t)&&r(e,t,n[t]);return e},u=(e,l)=>n(e,t(l)),d=(e,n,t)=>new Promise((l,o)=>{var i=e=>{try{a(t.next(e))}catch(n){o(n)}},r=e=>{try{a(t.throw(e))}catch(n){o(n)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);a((t=t.apply(e,n)).next())});import{defineComponent as c,computed as s,onMounted as v,onUnmounted as f,openBlock as m,createBlock as p,Teleport as h,createElementVNode as g,normalizeClass as y,withModifiers as w,toDisplayString as b,unref as k,getCurrentInstance as S,ref as C,watch as x,onBeforeUnmount as M,nextTick as O,createElementBlock as E,normalizeStyle as L,createVNode as P,createSlots as B,withCtx as H,withDirectives as z,createCommentVNode as D,vShow as F,renderSlot as N}from"vue";import{b as T,_,k as R,l as $,u as A,m as j,c as W,o as I,p as U,q,h as V,v as G,w as J,e as X,x as Y}from"./exports.js";const K={class:"html-preview-frame__header"},Q={class:"html-preview-frame__title"},Z={class:"html-preview-frame__label"},ee=["srcdoc"],ne=/* @__PURE__ */_(/* @__PURE__ */c({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},onClose:{type:Function},title:{}},setup(e){const n=e,{t}=T(),l=s(()=>{const e=n.code||"",t=e.trim().toLowerCase();return t.startsWith("<!doctype")||t.startsWith("<html")||t.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${n.isDark?"#020617":"#ffffff"};\n color: ${n.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`});function o(e){var t;"Escape"!==e.key&&"Esc"!==e.key||null==(t=n.onClose)||t.call(n)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",o)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",o)}),(e,o)=>(m(),p(h,{to:"body"},[g("div",{class:y(["markstream-vue",{dark:n.isDark}])},[g("div",{class:"html-preview-frame__backdrop",onClick:o[2]||(o[2]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})},[g("div",{class:"html-preview-frame",onClick:o[1]||(o[1]=w(()=>{},["stop"]))},[g("div",K,[g("div",Q,[o[3]||(o[3]=g("span",{class:"html-preview-frame__dot"},null,-1)),g("span",Z,b(n.title||k(t)("common.preview")||"Preview"),1)]),g("button",{type:"button",class:"html-preview-frame__close",onClick:o[0]||(o[0]=e=>{var t;return null==(t=n.onClose)?void 0:t.call(n)})}," × ")]),g("iframe",{class:"html-preview-frame__iframe",sandbox:"allow-scripts allow-same-origin",srcdoc:l.value},null,8,ee)])])],2)]))}}),[["__scopeId","data-v-fd3f9c21"]]);let te=null,le=null,oe=null,ie=null,re=null,ae=null;const ue=/* @__PURE__ */new WeakMap;let de=0;const ce=["data-markstream-enhanced"],se={class:"code-header-main"},ve=["innerHTML"],fe={class:"code-header-copy"},me={class:"code-header-title"},pe={key:0,class:"code-header-caption"},he={class:"code-editor-layer"},ge="__markstreamMonacoPassiveTouchState__",ye=/* @__PURE__ */_(/* @__PURE__ */c({__name:"CodeBlockNode",props:{node:{},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isShowPreview:{type:Boolean,default:!0},monacoOptions:{},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},customId:{},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:n}){var t;const l=e,o=n;const i=S(),r=s(()=>{const e=null==i?void 0:i.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:c}=T(),v=C(null),h=C(null),w=C(!1),_=C(R(l.node.language)),K=s(()=>$(_.value)),Q=s(()=>"plaintext"===K.value),Z=C(!1),ee=C(!1),ye=C(!1),we=C(!1),be=C(!1);let ke=!1,Se=null;const Ce=C(null),xe=C(null);let Me=0,Oe=0;const Ee=A(),Le=C(null),Pe=C("undefined"==typeof window);"undefined"!=typeof window&&x(()=>h.value,e=>{var n;if(null==(n=Le.value)||n.destroy(),Le.value=null,!e)return void(Pe.value=!1);const t=Ee(e,{rootMargin:"400px"});Le.value=t,Pe.value=t.isVisible.value,t.whenVisible.then(()=>{Pe.value=!0})},{immediate:!0}),M(()=>{var e;ke=!0,null==(e=Le.value)||e.destroy(),Le.value=null});let Be=null,He=null,ze=()=>{},De=()=>{},Fe=()=>null,Ne=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),Te=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),_e=()=>{},Re=()=>{},$e=()=>{},Ae=null,je=()=>{var e;return String(null!=(e=l.node.language)?e:"plaintext")},We=()=>d(null,null,function*(){});const Ie=[],Ue=[];let qe=null;const Ve=s(()=>l.node.diff),Ge=C({removed:0,added:0}),Je=s(()=>`-${Ge.value.removed} +${Ge.value.added}`),Xe=Object.freeze({enabled:!1}),Ye=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function Ke(e){var n;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const t=e;return u(a(a({},Ye),t),{enabled:null==(n=t.enabled)||n})}return a({},Ye)}function Qe(e,n){return{original:String(null!=e?e:""),updated:String(null!=n?n:"")}}const Ze=s(()=>{var e,n,t;const o=l.monacoOptions?a({},l.monacoOptions):{};if(!Ve.value)return o;const i=void 0===o.diffHideUnchangedRegions?a({},Ye):Ke(o.diffHideUnchangedRegions),r=void 0===o.hideUnchangedRegions?void 0:Ke(o.hideUnchangedRegions),d=!1!==l.stream&&!1!==l.loading,c=d?a({},Xe):i,s=d?a({},Xe):r,v=a({},null!=(e=o.experimental)?e:{}),f=null!=(n=o.diffUnchangedRegionStyle)?n:"line-info",m={maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,diffHideUnchangedRegions:c,useInlineViewWhenSpaceIsLimited:null!=(t=o.useInlineViewWhenSpaceIsLimited)&&t,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:f,diffHunkActionsOnHover:!1,experimental:v};return u(a(u(a(a({},m),o),{experimental:v}),void 0===s?{}:{hideUnchangedRegions:s}),{diffHideUnchangedRegions:c})}),en=s(()=>Ve.value?"diff":"single"),nn=C(en.value),tn=C(!1),ln=C(!1),on=s(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.wordWrap;return null==n||"off"!==String(n)}),rn=s(()=>!tn.value&&!ln.value),an=C(!1);"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield j();if(ke)return;if(!e)return void(tn.value=!0);const n=e.useMonaco,t=e.detectLanguage;if("function"==typeof t&&(je=t),"function"==typeof n){const e=ct();if(e&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(e))throw new Error("Preferred theme not in provided themes array");qe=mt();const t=n(qe);Be=t.createEditor||Be,He=t.createDiffEditor||He,ze=t.updateCode||ze,De=t.updateDiff||De,Fe=t.getEditor||Fe,Ne=t.getEditorView||Ne,Te=t.getDiffEditorView||Te,_e=t.cleanupEditor||_e,Re=t.safeClean||t.cleanupEditor||Re,$e=t.refreshDiffPresentation||$e,We=t.setTheme||We,be.value=!0,!ke&&v.value&&(yield rt(v.value))}}catch(e){if(ke)return;tn.value=!0}});const un=C("number"==typeof(null==(t=l.monacoOptions)?void 0:t.fontSize)?l.monacoOptions.fontSize:Number.NaN),dn=C(un.value),cn=s(()=>{const e=un.value,n=dn.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof n&&Number.isFinite(n)&&n>0}),sn=s(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n;const t=dn.value;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:12}),vn=s(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.lineHeight;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:Math.round(1.5*sn.value)}),fn=s(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.tabSize;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:4}),mn=s(()=>{const e=l.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}),pn=s(()=>{const e=l.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}),hn=s(()=>{var e;const n=null==(e=l.monacoOptions)?void 0:e.fontFamily;return a(a({fontSize:`${sn.value}px`,lineHeight:`${vn.value}px`,tabSize:fn.value,boxSizing:"border-box",maxHeight:`${Vn()}px`,overflow:"auto"},null!=mn.value?{minHeight:`${mn.value}px`,"--markstream-code-padding-y":"0px"}:{}),"string"==typeof n&&n.trim()?{"--markstream-code-font-family":n.trim()}:{})}),gn=s(()=>null!=mn.value&&!ln.value),yn=s(()=>{if(gn.value)return{minHeight:`${mn.value}px`}}),wn=C(null);function bn(){const e=wn.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}function kn(e,n=!1){const t=Math.ceil(e),l=bn();return null==l?t:t>=l-1?(n&&we.value&&(wn.value=null),t):Math.max(t,l)}function Sn(){return new Promise(e=>{W(()=>e())})}function Cn(){var e,n,t,l,o;try{const i=Ve.value?null!=(t=null==(n=null==(e=Te())?void 0:e.getModifiedEditor)?void 0:n.call(e))?t:Te():Ne(),r=Fe(),a=null==(l=null==r?void 0:r.EditorOption)?void 0:l.fontInfo;if(i&&null!=a){const e=null==(o=i.getOption)?void 0:o.call(i,a),n=null==e?void 0:e.fontSize;if("number"==typeof n&&Number.isFinite(n)&&n>0)return n}}catch(i){}try{const e=v.value;if(e){const n=e.querySelector(".view-lines .view-line");if(n)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(n).fontSize,t=e&&e.match(/^(\d+(?:\.\d+)?)/);if(t)return Number.parseFloat(t[1])}}catch(i){}}}catch(i){}return null}function xn(e){var n,t;try{const l=Fe(),o=null==(n=null==l?void 0:l.EditorOption)?void 0:n.lineHeight;if(null!=o){const n=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o);if("number"==typeof n&&n>0)return n}}catch(i){}const l=function(){try{const e=v.value;if(!e)return null;const n=e.querySelector(".view-lines .view-line");if(n){const e=Math.ceil(n.getBoundingClientRect().height);if(e>0)return e}}catch(i){}return null}();if(l&&l>0)return l;const o=Number.isFinite(dn.value)&&dn.value>0?dn.value:14;return Math.max(12,Math.round(1.35*o))}function Mn(e){var n,t,l;try{const l=Fe(),o=null==(n=null==l?void 0:l.EditorOption)?void 0:n.padding;if(null!=o){const n=null==(t=null==e?void 0:e.getOption)?void 0:t.call(e,o),l="number"==typeof(null==n?void 0:n.top)?n.top:0,i="number"==typeof(null==n?void 0:n.bottom)?n.bottom:0;if(l>0||i>0)return l+i}}catch(a){}const o=null==(l=Ze.value)?void 0:l.padding,i="number"==typeof(null==o?void 0:o.top)?o.top:0,r="number"==typeof(null==o?void 0:o.bottom)?o.bottom:0;return i>0||r>0?i+r:Ve.value?24:0}function On(e,n){return"number"!=typeof e||"number"!=typeof n||e<1||n<e?0:n-e+1}function En(e){if(!e)return[];const n=e.split(/\r?\n/);return 1===n.length&&""===n[0]?[]:n}function Ln(){var e,n;Ve.value?Ge.value=function(e,n){const t=En(e),l=En(n);let o=0,i=t.length-1,r=l.length-1;for(;o<=i&&o<=r&&t[o]===l[o];)o++;for(;i>=o&&r>=o&&t[i]===l[r];)i--,r--;return{removed:Math.max(0,i-o+1),added:Math.max(0,r-o+1)}}(String(null!=(e=l.node.originalCode)?e:""),String(null!=(n=l.node.updatedCode)?n:"")):Ge.value={removed:0,added:0}}function Pn(){var e;if(Ve.value)try{const n=Te(),t=null==(e=null==n?void 0:n.getLineChanges)?void 0:e.call(n);if(!Array.isArray(t))return void Ln();let l=0,o=0;for(const e of t)l+=On(e.originalStartLineNumber,e.originalEndLineNumber),o+=On(e.modifiedStartLineNumber,e.modifiedEndLineNumber);Ge.value={removed:l,added:o}}catch(n){Ln()}else Ge.value={removed:0,added:0}}function Bn(){var e;if(Number.isFinite(dn.value)&&dn.value>0&&Number.isFinite(un.value))return dn.value;const n=Cn();return"number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?(un.value=l.monacoOptions.fontSize,dn.value=l.monacoOptions.fontSize,dn.value):n&&n>0?(un.value=n,dn.value=n,n):(un.value=12,dn.value=12,12)}function Hn(){const e=Bn(),n=Math.min(36,e+1);dn.value=n}function zn(){const e=Bn(),n=Math.max(10,e-1);dn.value=n}function Dn(){Bn(),Number.isFinite(un.value)&&(dn.value=un.value)}function Fn(){var e,n,t,l,o,i,r,a,u,d,c,s,v,f;try{const m=Ve.value?Te():null,p=Ve.value?m:Ne();if(!p)return null;if((null==m?void 0:m.getOriginalEditor)&&(null==m?void 0:m.getModifiedEditor)){const v=null==(e=m.getOriginalEditor)?void 0:e.call(m),f=null==(n=m.getModifiedEditor)?void 0:n.call(m);null==(t=null==v?void 0:v.layout)||t.call(v),null==(l=null==f?void 0:f.layout)||l.call(f);const p=(null==(o=null==v?void 0:v.getContentHeight)?void 0:o.call(v))||0,h=(null==(i=null==f?void 0:f.getContentHeight)?void 0:i.call(f))||0,g=Math.max(p,h);if(g>0)return Math.ceil(g+1);const y=(null==(u=null==(a=null==(r=null==v?void 0:v.getModel)?void 0:r.call(v))?void 0:a.getLineCount)?void 0:u.call(a))||1,w=(null==(s=null==(c=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:c.getLineCount)?void 0:s.call(c))||1,b=Math.max(y,w),k=Math.max(xn(v),xn(f));return Math.ceil(b*(k+1.5)+0+1)}if(null==p?void 0:p.getContentHeight){null==(v=null==p?void 0:p.layout)||v.call(p);const e=p.getContentHeight();if(e>0)return Math.ceil(e+1)}const h=null==(f=null==p?void 0:p.getModel)?void 0:f.call(p);let g=1;h&&"function"==typeof h.getLineCount&&(g=h.getLineCount());const y=xn(p);return Math.ceil(g*(y+1.5)+0+1)}catch(m){return null}}function Nn(e){const n=String(null!=e?e:"").match(/\d+(?:\.\d+)?/g);if(!n||n.length<3)return null;const[t,l,o]=n.slice(0,3).map(Number);return.2126*t+.7152*l+.0722*o}function Tn(){var e,n,t,l,o,i,r,a;const u=v.value,d=h.value;if(!u||!d)return;const c=u;if(Ve.value)return c.style.removeProperty("--vscode-editor-foreground"),c.style.removeProperty("--vscode-editor-background"),void c.style.removeProperty("--vscode-editor-selectionBackground");const s=u.querySelector(".monaco-editor")||u,f=s.querySelector(".monaco-editor-background")||s,m=s.querySelector(".view-lines")||s;let p=null,g=null,y=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(p=window.getComputedStyle(s),g=f===s?p:window.getComputedStyle(f),y=m===s?p:window.getComputedStyle(m))}catch(x){p=null,g=null,y=null}const w=String(null!=(e=null==p?void 0:p.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),b=String(null!=(n=null==p?void 0:p.getPropertyValue("--vscode-editor-background"))?n:"").trim(),k=String(null!=(l=null!=(t=null==p?void 0:p.getPropertyValue("--vscode-editor-selectionBackground"))?t:null==p?void 0:p.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?l:"").trim(),S=w||String(null!=(i=null!=(o=null==y?void 0:y.color)?o:null==p?void 0:p.color)?i:"").trim(),C=b||String(null!=(a=null!=(r=null==g?void 0:g.backgroundColor)?r:null==p?void 0:p.backgroundColor)?a:"").trim();if(function(e,n,t){if(!Q.value)return!1;const l=Nn(e),o=Nn(n);return t?null!=l&&l>170||null!=o&&o<110:null!=l&&l<85||null!=o&&o>190}(C,S,d.classList.contains("is-dark")))return c.style.removeProperty("--vscode-editor-foreground"),c.style.removeProperty("--vscode-editor-background"),void c.style.removeProperty("--vscode-editor-selectionBackground");S&&c.style.setProperty("--vscode-editor-foreground",S),C&&c.style.setProperty("--vscode-editor-background",C),k&&c.style.setProperty("--vscode-editor-selectionBackground",k)}const _n=/auto|scroll|overlay/i;function Rn(e,n,t){var l;if("undefined"==typeof window)return;if(Ve.value)return;const o=Math.ceil(n),i=Math.ceil(t)-o;if(!i)return;const r=function(e){var n,t;if("undefined"==typeof window)return null;const l=null!=(n=null==e?void 0:e.ownerDocument)?n:document,o=l.scrollingElement||l.documentElement||l.body;let i=null!=(t=null==e?void 0:e.parentElement)?t:null;for(;i&&i!==l.body&&i!==o;){const e=window.getComputedStyle(i),n=(e.overflowY||"").toLowerCase(),t=(e.overflow||"").toLowerCase();if(_n.test(n)||_n.test(t))return i;i=i.parentElement}return o}(e);if(!r)return;const a=null!=(l=e.ownerDocument)?l:document,u=r===a.body||r===a.documentElement||r===a.scrollingElement,d=u?0:r.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,i):r.scrollTop+=i)}function $n(){try{const e=v.value;if(!e)return;const n=e.getBoundingClientRect().height,t=Fn();if(null!=t&&t>0){const l=kn(t,!0),o=bn();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",void Rn(e,n,l)}const l=bn();null!=l&&(e.style.minHeight=`${l}px`,e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",Rn(e,n,l))}catch(e){}}function An(){for(var e,n;Ie.length>0;)try{null==(n=null==(e=Ie.pop())?void 0:e.dispose)||n.call(e)}catch(t){}null!=Se&&(Y(Se),Se=null)}function jn(){for(var e;Ue.length>0;)try{null==(e=Ue.pop())||e()}catch(n){}}function Wn(e=!1){ee.value||(Z.value?$n():function(){var e;try{const n=v.value;if(!n)return;const t=n.getBoundingClientRect().height,l=Vn(),o=Math.ceil((null==(e=n.getBoundingClientRect)?void 0:e.call(n).height)||0),i=Ve.value?function(){var e,n,t,l,o,i,r,a;try{const u=Te(),d=null==(e=null==u?void 0:u.getOriginalEditor)?void 0:e.call(u),c=null==(n=null==u?void 0:u.getModifiedEditor)?void 0:n.call(u);if(!d||!c)return null;const s=(null==(o=null==(l=null==(t=d.getModel)?void 0:t.call(d))?void 0:l.getLineCount)?void 0:o.call(l))||1,v=(null==(a=null==(r=null==(i=c.getModel)?void 0:i.call(c))?void 0:r.getLineCount)?void 0:a.call(r))||1,f=Math.max(s,v),m=Math.max(xn(d),xn(c)),p=Math.max(Mn(d),Mn(c));return Math.ceil(f*(m+1.5)+p+0+1)}catch(u){return null}}():null,r=Ve.value&&function(e){if("undefined"==typeof window)return!1;const n=e.querySelectorAll(".editor.modified .diff-hidden-lines .center, .stream-monaco-diff-unchanged-bridge");for(const t of Array.from(n)){if(!(t instanceof HTMLElement))continue;const e=window.getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const n=t.getBoundingClientRect();if(!(n.width<=0||n.height<=0))return!0}return!1}(n);if(r||(xe.value=null),Oe>0&&(Oe--,null!=Ce.value))return void Rn(n,t,qn(n,Ce.value,l));const a=Ve.value?function(e){var n,t;if("undefined"==typeof window)return null;try{const l=e.getBoundingClientRect();if(l.height<=0)return null;const o=[".editor.original .view-lines .view-line",".editor.modified .view-lines .view-line",".editor.original .view-zones > div",".editor.modified .view-zones > div",".editor.original .margin-view-zones > div",".editor.modified .margin-view-zones > div",".editor.original .diff-hidden-lines",".editor.modified .diff-hidden-lines",".stream-monaco-diff-unchanged-bridge"];let i=0;for(const n of Array.from(e.querySelectorAll(o.join(",")))){if(!(n instanceof HTMLElement))continue;const e=window.getComputedStyle(n);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const t=n.getBoundingClientRect();t.height<=0||t.bottom<=l.top||(i=Math.max(i,t.bottom-l.top))}if(i>0)return Math.ceil(i+1);const r=e.querySelector(".monaco-diff-editor"),a=null!=(t=null==(n=null==r?void 0:r.getBoundingClientRect)?void 0:n.call(r).height)?t:0;return a>0?Math.ceil(a+1):null}catch(l){return null}}(n):Fn();if(null!=a&&a>0){const e=null!=xe.value&&Date.now()<Me&&a>=l-1,i=r&&o>0&&o<l-1&&a>=l-1,u=qn(n,e?xe.value:i?o:a,l,{clearEstimatedFloor:!0});return r&&u<l-1&&(xe.value=u,Me=Date.now()+160),void Rn(n,t,u)}if(null!=Ce.value)return void Rn(n,t,qn(n,Ce.value,l));const u=r?o:Math.max(o,null!=i&&i>0?i:0);if(u>0){const e=null!=xe.value&&Date.now()<Me&&u>=l-1,i=r&&o>0&&o<l-1&&u>=l-1,a=qn(n,e?xe.value:i?o:u,l);return r&&a<l-1&&(xe.value=a,Me=Date.now()+160),void Rn(n,t,a)}const d=bn();if(null!=d)return void Rn(n,t,qn(n,d,l));const c=Number.parseFloat(n.style.height);!Number.isNaN(c)&&c>0?Rn(n,t,qn(n,c,l)):Ve.value||Rn(n,t,qn(n,l,l))}catch(n){}}())}function In(){if(!Ve.value)return void jn();const e=v.value;if(!e)return void jn();const n=e.querySelector(".monaco-diff-editor");if(!n||n.classList.contains("side-by-side"))return void jn();const t=Array.from(n.querySelectorAll(".editor.original .diff-hidden-lines")),l=Array.from(n.querySelectorAll(".editor.modified .diff-hidden-lines")),o=Math.min(t.length,l.length);for(let i=0;i<o;i++){const e=l[i],n=e.querySelector("a"),t=e.querySelector(".center > div:first-child"),o=e.querySelector(".center");if(!n||!t||!o)continue;if(o.querySelector(".markstream-inline-fold-proxy"))continue;const r=document.createElement("button");r.type="button",r.className="markstream-inline-fold-proxy",r.dataset.markstreamInlineFoldProxy="true";const a=n.getAttribute("title")||"Show Unchanged Region";r.title=a,r.setAttribute("aria-label",a);const u=e=>{e.preventDefault(),e.stopPropagation()},d=e=>{e.preventDefault(),e.stopPropagation(),n.click(),W(()=>Un())},c=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),n.click(),W(()=>Un()))};r.addEventListener("mousedown",u),r.addEventListener("click",d),r.addEventListener("keydown",c),o.appendChild(r),Ue.push(()=>{r.removeEventListener("mousedown",u),r.removeEventListener("click",d),r.removeEventListener("keydown",c),r.parentElement===o&&o.removeChild(r)})}}function Un(e=!1){null==Se&&(Se=W(()=>{Se=null,W(()=>{In(),Wn(e)})}))}function qn(e,n,t,l={}){const o=kn(Math.min(n,t),!0===l.clearEstimatedFloor),i=bn();if(e.style.minHeight=null!=i?`${Math.min(i,Math.ceil(t))}px`:"0px",e.style.height=`${o}px`,e.style.maxHeight=`${Math.ceil(t)}px`,Ve.value)e.style.overflow="hidden";else{const l=n>t+1;e.style.overflow=l?"auto":"hidden"}return o}function Vn(){var e,n;const t=null!=(n=null==(e=l.monacoOptions)?void 0:e.MAX_HEIGHT)?n:500;if("number"==typeof t)return t;const o=String(t).match(/^(\d+(?:\.\d+)?)/);return o?Number.parseFloat(o[1]):500}const Gn=s(()=>l.isShowPreview&&("html"===_.value||"svg"===_.value));x(()=>l.node.language,e=>{_.value=R(e)}),x(()=>[l.node.originalCode,l.node.updatedCode,Ve.value],()=>{Ln(),W(()=>Pn())},{immediate:!0}),x(()=>[l.node.originalCode,l.node.updatedCode,K.value,Ve.value],e=>d(null,[e],function*([e,n,t,o]){if(!1===l.stream||!o)return;if(Be&&!ye.value&&v.value)try{yield rt(v.value)}catch(r){}const i=Qe(String(null!=e?e:""),String(null!=n?n:""));!1===l.loading&&(pt(),$e()),De(i.original,i.updated,K.value),Z.value&&W(()=>$n())})),x(()=>l.node.code,e=>d(null,null,function*(){if(!1!==l.stream&&(_.value||(_.value=R(je(e))),!Ve.value)){if(Be&&!ye.value&&v.value)try{yield rt(v.value)}catch(n){}ze(e,K.value),Z.value&&W(()=>$n())}}));const Jn=s(()=>{const e=_.value;return e?I[e]||e.charAt(0).toUpperCase()+e.slice(1):I[""]||"Plain Text"});const Xn=s(()=>{var e;return function(e){const n=function(e){var n,t;const l=null!=(t=null==(n=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:n.trim())?t:"";if(l.length<3)return"";const o=l[0];if("`"!==o&&"~"!==o||l[1]!==o||l[2]!==o)return"";let i=3;for(;l[i]===o;)i+=1;return l.slice(i).trim()}(e);if(!n)return"";const t=n.split(/\s+/).filter(Boolean);if(!t.length)return"";const l="diff"===t[0]?t.slice(1):t;for(const o of l){const e=o.includes(":")?o.slice(o.indexOf(":")+1):o;if(e&&/[./\\-]/.test(e))return e}return""}(String(null!=(e=l.node.raw)?e:""))}),Yn=s(()=>Xn.value||Jn.value),Kn=s(()=>Xn.value?Ve.value?`Diff / ${Jn.value}`:Jn.value:""),Qn=s(()=>(U.value,q(_.value||""))),Zn=s(()=>{var e;const n={},t=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},o=t(l.minWidth),i=t(l.maxWidth);return o&&(n.minWidth=o),i&&(n.maxWidth=i),gn.value&&(n.minHeight=`${null!=(e=pn.value)?e:mn.value}px`),Ve.value||(n.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg))",n.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg))",n.borderColor="var(--markstream-code-border-color)"),n}),et=s(()=>!1!==l.showTooltips);function nt(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(l.node.code)),w.value=!0,o("copy",l.node.code),setTimeout(()=>{w.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function tt(e){if(Z.value=!Z.value,e&&et.value){const n=function(e){const n=e.currentTarget||e.target;return!n||n.disabled?null:n}(e);if(n){const e=Z.value?c("common.collapse")||"Collapse":c("common.expand")||"Expand";X(n,e,"top",!1,void 0,l.isDark)}}const n=Ve.value?Te():Ne(),t=v.value;n&&t&&(Z.value?(it(!0),t.style.maxHeight="none",t.style.overflow="visible",Wn(!0)):(it(!1),t.style.overflow=Ve.value?"hidden":"auto",Wn(!0)))}function lt(){var e,n,t;if(ee.value=!ee.value,ee.value){if(v.value){const t=Math.ceil((null==(n=(e=v.value).getBoundingClientRect)?void 0:n.call(e).height)||0);t>0&&(Ce.value=t)}it(!1)}else{Z.value&&it(!0),v.value&&null!=Ce.value&&(v.value.style.height=`${Ce.value}px`);const e=Ve.value?Te():Ne();try{null==(t=null==e?void 0:e.layout)||t.call(e)}catch(l){}Oe=2,W(()=>{Wn(!0)})}}function ot(){if(!Gn.value)return;const e=_.value;if(r.value){const n="html"===e?"text/html":"image/svg+xml",t="html"===e?c("artifacts.htmlPreviewTitle")||"HTML Preview":c("artifacts.svgPreviewTitle")||"SVG Preview";return void o("previewCode",{node:l.node,artifactType:n,artifactTitle:t,id:`temp-${e}-${Date.now()}`})}"html"===e&&(an.value=!an.value)}function it(e){var n,t;try{if(Ve.value){const t=Te();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}else{const n=Ne();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}}catch(l){}}function rt(e){if(!Be||ke)return null;if(Ae)return Ae;if(ye.value&&we.value)return Promise.resolve();ye.value=!0;const n=d(null,null,function*(){yield function(e){return d(this,null,function*(){var n;if("undefined"==typeof window)return yield e();try{const t=null==(n=window.Element)?void 0:n.prototype,l=null==t?void 0:t.addEventListener;if(!t||!l)return yield e();const o=function(){const e=window,n=e[ge];if(n)return n;const t={depth:0,original:null};return e[ge]=t,t}();0===o.depth&&(o.original=l,t.addEventListener=function(e,n,t){var i;const r=null!=(i=o.original)?i:l;return"touchstart"===e&&function(e,n){if(!e)return!1;const t=e;return!("function"!=typeof t.closest||!t.closest(".monaco-editor, .monaco-diff-editor")||n&&"object"==typeof n&&"passive"in n)}(this,t)?r.call(this,e,n,function(e){return null==e?{passive:!0}:"boolean"==typeof e?{capture:e,passive:!0}:"object"==typeof e?"passive"in e?e:u(a({},e),{passive:!0}):{passive:!0}}(t)):r.call(this,e,n,t)}),o.depth++;try{return yield e()}finally{o.depth=Math.max(0,o.depth-1),0===o.depth&&o.original&&t.addEventListener!==o.original&&(t.addEventListener=o.original,o.original=null)}}catch(t){return yield e()}})}(()=>function(e){return d(this,null,function*(){var n,t,o;if(!Be||ke)return;if(ln.value=!1,function(){const e=mn.value;wn.value=we.value||null==e?null:e}(),An(),jn(),function(e){e.replaceChildren()}(e),ke)return;if(Ve.value){Re();const o=Qe(String(null!=(n=l.node.originalCode)?n:""),String(null!=(t=l.node.updatedCode)?t:""));He?yield He(e,o.original,o.updated,K.value):yield Be(e,l.node.code,K.value)}else yield Be(e,l.node.code,K.value);if(ke)return;const i=Ve.value?Te():Ne();if("number"==typeof(null==(o=l.monacoOptions)?void 0:o.fontSize))null==i||i.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),un.value=l.monacoOptions.fontSize,dn.value=l.monacoOptions.fontSize;else{const e=Cn();e&&e>0?(un.value=e,dn.value=e):(un.value=12,dn.value=12)}Z.value||ee.value||Wn(!1),yield function(){return d(this,null,function*(){null!=bn()&&(In(),Wn(!1),yield O(),yield Sn(),In(),Wn(!1),yield Sn(),In(),Wn(!1))})}(),ke||(we.value=!0,function(){var e,n,t,l,o;if(An(),Ve.value){const l=Te(),o=null==(e=null==l?void 0:l.getOriginalEditor)?void 0:e.call(l),i=null==(n=null==l?void 0:l.getModifiedEditor)?void 0:n.call(l),a=(e,n)=>{try{const t=null==e?void 0:e[n];if("function"!=typeof t)return;const l=t.call(e,()=>Un());l&&Ie.push(l)}catch(t){}};try{const e=null==(t=null==l?void 0:l.onDidUpdateDiff)?void 0:t.call(l,()=>{Un(),W(()=>Pn())});e&&Ie.push(e)}catch(r){}return a(o,"onDidContentSizeChange"),a(i,"onDidContentSizeChange"),a(o,"onDidLayoutChange"),void a(i,"onDidLayoutChange")}const i=Ne();try{const e=null==(l=null==i?void 0:i.onDidContentSizeChange)?void 0:l.call(i,()=>Un());e&&Ie.push(e)}catch(r){}try{const e=null==(o=null==i?void 0:i.onDidLayoutChange)?void 0:o.call(i,()=>Un());e&&Ie.push(e)}catch(r){}}(),Tn(),In(),Pn(),Un(),yield function(){return d(this,null,function*(){In(),Wn(!1),yield O(),yield Sn(),In(),Wn(!1),yield Sn(),In(),Wn(!1)})}(),ke||(ln.value=!0))})}(e))}).finally(()=>{Ae===n&&(Ae=null)});return Ae=n,n}x(et,e=>{e||V()}),x(()=>dn.value,(e,n)=>{const t=Ve.value?Te():Ne();t&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(t.updateOptions({fontSize:e}),ee.value||Wn(!0))},{flush:"post",immediate:!1});const at=x(()=>[v.value,Ve.value,l.stream,l.loading,be.value,Pe.value],e=>d(null,[e],function*([e,n,t,l,o,i]){if(!e||!Be)return;if(!i)return;if(!1===t&&!1!==l)return;const r=rt(e);if(r){try{yield r}catch(a){we.value=!1,ln.value=!1}at()}}));function ut(e){return!!e&&"object"==typeof e&&"light"in e&&"dark"in e}function dt(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function ct(){var e;const n=function(){if(void 0!==l.theme){const e=l.theme;return ut(e)?l.isDark?e.dark:e.light:e}return l.isDark?l.darkTheme:l.lightTheme}(),t=null==(e=Ze.value)?void 0:e.theme,o=null!=n?n:t;if(null!=o&&"object"==typeof o)return o;const i=Array.isArray(l.themes)?l.themes:[];if(!i.length||null==o)return o;const r=dt(o),a=i.map(e=>dt(e)).filter(e=>!!e);if(!r||a.includes(r))return o;const u=dt(t);return null!=t&&u&&a.includes(u)?t:i[0]}x(en,(e,n)=>d(null,null,function*(){if(e===n)return;if(nn.value=e,!Be||!v.value)return;if(!ye.value)return;if(!1===l.stream&&!1!==l.loading)return;if(!Pe.value)return;const t=Ae;if(t){try{yield t}catch(o){}if(ke||!v.value)return}try{we.value=!1,ln.value=!1,ye.value=!1,An(),jn(),Re(),yield O(),yield rt(v.value)}catch(i){we.value=!1,ln.value=!1}}));const st=s(()=>void 0===l.theme||ut(l.theme)?!!l.isDark:function(e){var n,t;if(e&&"object"==typeof e&&(null==(n=e.colors)?void 0:n["editor.background"])){const n=Nn(e.colors["editor.background"]);if(null!=n)return n<128}const o=(null!=(t=dt(e))?t:"").toLowerCase();return o?["dark","night","moon","black","dracula","mocha","frappe","macchiato","palenight","ocean","poimandres","monokai","laserwave","tokyo","slack-dark","rose-pine","github-dark","material-theme","one-dark","catppuccin-mocha","catppuccin-frappe","catppuccin-macchiato"].some(e=>o.includes(e))&&!["light","latte","dawn","lotus"].some(e=>o.includes(e)):!!l.isDark}(ct())),vt=s(()=>{var e;if(!Ve.value)return st.value?"dark":"light";const n=null==(e=Ze.value)?void 0:e.diffAppearance;return"light"===n||"dark"===n?n:st.value?"dark":"light"}),ft=s(()=>Ve.value?"dark"===vt.value:st.value);function mt(){return u(a(u(a({wordWrap:"on",wrappingIndent:"same",themes:l.themes},Ze.value||{}),{theme:ct()}),Ve.value?{diffAppearance:vt.value}:{}),{onThemeChange(){Tn()}})}function pt(){const e=mt();if(!qe)return qe=e,qe;for(const n of Object.keys(qe))n in e||delete qe[n];return Object.assign(qe,e),qe}const ht=s(()=>{var e,n,t,o,i,r,u,d,c,s,v,f,m,p,h;return JSON.stringify({diffLineStyle:null!=(n=null==(e=Ze.value)?void 0:e.diffLineStyle)?n:"background",diffUnchangedRegionStyle:null!=(o=null==(t=Ze.value)?void 0:t.diffUnchangedRegionStyle)?o:"line-info",diffHideUnchangedRegions:void 0===(null==(i=l.monacoOptions)?void 0:i.diffHideUnchangedRegions)?a({},Ye):Ke(l.monacoOptions.diffHideUnchangedRegions),renderSideBySide:null==(u=null==(r=Ze.value)?void 0:r.renderSideBySide)||u,useInlineViewWhenSpaceIsLimited:null==(c=null==(d=Ze.value)?void 0:d.useInlineViewWhenSpaceIsLimited)||c,enableSplitViewResizing:null==(v=null==(s=Ze.value)?void 0:s.enableSplitViewResizing)||v,ignoreTrimWhitespace:null==(m=null==(f=Ze.value)?void 0:f.ignoreTrimWhitespace)||m,originalEditable:null!=(h=null==(p=Ze.value)?void 0:p.originalEditable)&&h})});return x(()=>[l.monacoOptions,Pe.value],()=>{var e,n;if(pt(),!Be||!Pe.value)return;const t=Ve.value?Te():Ne(),o="number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?l.monacoOptions.fontSize:Number.isFinite(dn.value)?dn.value:void 0;"number"==typeof o&&Number.isFinite(o)&&o>0&&(null==(n=null==t?void 0:t.updateOptions)||n.call(t,{fontSize:o})),Wn(!1)},{deep:!0}),x(()=>[ct(),vt.value,be.value,ye.value,Pe.value],()=>{be.value&&ye.value&&Pe.value&&function(){pt();const e=ct(),n=()=>{Ve.value&&$e(),W(()=>{Tn(),Un()})};e?function(e,n){const t=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&"name"in e)return String(e.name);if("object"==typeof e){const t=ue.get(e);if(t)return t;try{const n=JSON.stringify(e);if(n)return ue.set(e,n),n}catch(n){}const l="__theme_"+ ++de;return ue.set(e,l),l}return String(e)}(n);return t?(ae=e,te||re!==t?te?(ie===t||le===t||(oe=n,ie=t),te):(oe=n,ie=t,te=d(null,null,function*(){for(;ie&&null!=oe;){const t=oe,l=ie;if(oe=null,ie=null,re!==l)try{le=l,yield(null!=ae?ae:e)(t),re=l}catch(n){}}}).finally(()=>{te=null,le=null}),te):Promise.resolve()):Promise.resolve()}(We,e).then(n).catch(e=>{}):n()}()},{flush:"post"}),x(()=>[ht.value,be.value,Pe.value],(e,n)=>d(null,[e,n],function*([e,n,t],[o]){if(pt(),!n||!t)return;if(!Be||!v.value)return;if(!ye.value)return;if(e===o)return;if(!1===l.stream&&!1!==l.loading)return;const i=Ae;if(i){try{yield i}catch(r){}if(ke||!v.value)return}try{we.value=!1,ln.value=!1,ye.value=!1,An(),jn(),Re(),yield O(),yield rt(v.value)}catch(a){we.value=!1,ln.value=!1}}),{flush:"post"}),x(()=>[l.loading,Pe.value],(e,n)=>d(null,[e,n],function*([e,n],t){if(!n)return;if(e)return;const o=null==t?void 0:t[0],i=void 0!==o&&!1!==o;yield O(),W(()=>{d(null,null,function*(){var e;try{if(i&&ye.value)if(Ve.value&&v.value){const e=Ae;if(e)try{yield e}catch(n){}pt(),$e(),In(),Pn()}else ze(String(null!=(e=l.node.code)?e:""),K.value);Wn(!1)}catch(t){}})})}),{immediate:!0,flush:"post"}),f(()=>{An(),jn(),_e()}),(n,t)=>tn.value?(m(),p(k(G),{key:0,node:l.node,loading:l.loading},null,8,["node","loading"])):(m(),E("div",{key:1,ref_key:"container",ref:h,style:L(Zn.value),class:y(["code-block-container rounded-lg border",[{dark:l.isDark,"is-rendering":l.loading,"is-dark":ft.value,"is-diff":Ve.value,"is-plain-text":Q.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":ln.value&&!tn.value?"true":"false"},[P(J,{"show-header":l.showHeader,"show-collapse-button":l.showCollapseButton,"show-font-size-buttons":l.showFontSizeButtons,"enable-font-size-control":l.enableFontSizeControl,"show-copy-button":l.showCopyButton,"show-expand-button":l.showExpandButton,"show-preview-button":l.showPreviewButton,"show-tooltips":l.showTooltips,"is-dark":l.isDark,loading:l.loading,stream:e.stream,"is-collapsed":ee.value,"is-expanded":Z.value,"copy-text":w.value,"is-previewable":Gn.value,"code-font-size":dn.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":un.value,"font-baseline-ready":cn.value,"diff-stats":Ve.value?Ge.value:null,"diff-stats-aria-label":Je.value,onToggleCollapse:lt,onDecreaseFont:zn,onResetFont:Dn,onIncreaseFont:Hn,onCopy:nt,onToggleExpand:tt,onPreview:ot},B({"header-left":H(()=>[N(n.$slots,"header-left",{},()=>[g("div",se,[g("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:Qn.value},null,8,ve),g("div",fe,[g("div",me,b(Yn.value),1),Kn.value?(m(),E("div",pe,b(Kn.value),1)):D("",!0)])])],!0)]),loading:H(()=>[N(n.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[t[0]||(t[0]=g("div",{class:"loading-skeleton"},[g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line"}),g("div",{class:"skeleton-line short"})],-1))],!0)]),default:H(()=>[z(g("div",he,[g("div",{ref_key:"codeEditor",ref:v,class:y(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":rn.value}]]),style:L(yn.value)},null,6),rn.value?(m(),p(k(G),{key:0,class:y(["code-pre-fallback",{"is-wrap":on.value}]),style:L(hn.value),node:l.node},null,8,["class","style","node"])):D("",!0)],512),[[F,!(ee.value||!e.stream&&e.loading)]]),an.value&&!r.value&&Gn.value&&"html"===_.value?(m(),p(ne,{key:0,code:l.node.code,"is-dark":l.isDark,"on-close":()=>an.value=!1},null,8,["code","is-dark","on-close"])):D("",!0)]),_:2},[n.$slots["header-right"]?{name:"header-right",fn:H(()=>[N(n.$slots,"header-right",{},void 0,!0)]),key:"0"}:void 0]),1032,["show-header","show-collapse-button","show-font-size-buttons","enable-font-size-control","show-copy-button","show-expand-button","show-preview-button","show-tooltips","is-dark","loading","stream","is-collapsed","is-expanded","copy-text","is-previewable","code-font-size","default-code-font-size","font-baseline-ready","diff-stats","diff-stats-aria-label"])],14,ce))}}),[["__scopeId","data-v-d1b39b76"]]);export{ye as default};
1
+ var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,r=(t,n,l)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[n]=l,a=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&r(e,n,t[n]);if(l)for(var n of l(t))i.call(t,n)&&r(e,n,t[n]);return e},u=(e,l)=>t(e,n(l)),d=(e,t,n)=>new Promise((l,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},r=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=e=>e.done?l(e.value):Promise.resolve(e.value).then(i,r);a((n=n.apply(e,t)).next())});import{defineComponent as s,computed as c,onMounted as v,onUnmounted as f,openBlock as m,createBlock as p,Teleport as h,createElementVNode as y,normalizeClass as g,withModifiers as b,toDisplayString as w,unref as k,getCurrentInstance as S,ref as C,watch as x,onBeforeUnmount as P,nextTick as O,createElementBlock as M,normalizeStyle as E,createVNode as L,createSlots as B,withCtx as H,withDirectives as z,createCommentVNode as N,vShow as F,renderSlot as D}from"vue";import{b as T,_,w as $,x as R,u as A,y as j,c as I,z as W,A as U,B as q,h as V,C as G,D as J,E as X,f as Y,F as K}from"./exports.js";const Q={class:"html-preview-frame__header"},Z={class:"html-preview-frame__title"},ee={class:"html-preview-frame__label"},te=["sandbox","srcdoc"],ne=/* @__PURE__ */_(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){const t=e,n=void 0!==import.meta&&Boolean(!1);let l=null;const{t:o}=T(),i=c(()=>{const e=t.code||"",n=e.trim().toLowerCase();return n.startsWith("<!doctype")||n.startsWith("<html")||n.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: ${t.isDark?"#020617":"#ffffff"};\n color: ${t.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=c(()=>{return e=t.htmlPreviewSandbox,o=t.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!n||"undefined"==typeof console||l===e)return;const t=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);t.has("allow-scripts")&&t.has("allow-same-origin")&&(l=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 a(e){var n;"Escape"!==e.key&&"Esc"!==e.key||null==(n=t.onClose)||n.call(t)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",a)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",a)}),(e,n)=>(m(),p(h,{to:"body"},[y("div",{class:g(["markstream-vue",{dark:t.isDark}])},[y("div",{class:"html-preview-frame__backdrop",onClick:n[2]||(n[2]=e=>{var n;return null==(n=t.onClose)?void 0:n.call(t)})},[y("div",{class:"html-preview-frame",onClick:n[1]||(n[1]=b(()=>{},["stop"]))},[y("div",Q,[y("div",Z,[n[3]||(n[3]=y("span",{class:"html-preview-frame__dot"},null,-1)),y("span",ee,w(t.title||k(o)("common.preview")||"Preview"),1)]),y("button",{type:"button",class:"html-preview-frame__close",onClick:n[0]||(n[0]=e=>{var n;return null==(n=t.onClose)?void 0:n.call(t)})}," × ")]),y("iframe",{class:"html-preview-frame__iframe",sandbox:r.value,referrerpolicy:"no-referrer",srcdoc:i.value},null,8,te)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]);let le=null,oe=null,ie=null,re=null,ae=null,ue=null;const de=/* @__PURE__ */new WeakMap;let se=0;const ce=["data-markstream-enhanced"],ve={class:"code-header-main"},fe=["innerHTML"],me={class:"code-header-copy"},pe={class:"code-header-title"},he={key:0,class:"code-header-caption"},ye={class:"code-editor-layer"},ge="__markstreamMonacoPassiveTouchState__",be=/* @__PURE__ */_(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isShowPreview:{type:Boolean,default:!0},monacoOptions:{},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:t}){var n;const l=e,o=t;const i=S(),r=c(()=>{const e=null==i?void 0:i.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:s}=T(),v=C(null),h=C(null),b=C(!1),_=C($(l.node.language)),Q=c(()=>R(_.value)),Z=c(()=>"plaintext"===Q.value),ee=C(!1),te=C(!1),be=C(!1),we=C(!1),ke=C(!1);let Se=!1,Ce=null;const xe=C(null),Pe=C(null);let Oe=0,Me=0;const Ee=A(),Le=C(null),Be=C("undefined"==typeof window);"undefined"!=typeof window&&x(()=>h.value,e=>{var t;if(null==(t=Le.value)||t.destroy(),Le.value=null,!e)return void(Be.value=!1);const n=Ee(e,{rootMargin:"400px"});Le.value=n,Be.value=n.isVisible.value,n.whenVisible.then(()=>{Be.value=!0})},{immediate:!0}),P(()=>{var e;Se=!0,null==(e=Le.value)||e.destroy(),Le.value=null});let He=null,ze=null,Ne=()=>{},Fe=()=>{},De=()=>null,Te=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),_e=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),$e=()=>{},Re=()=>{},Ae=()=>{},je=null,Ie=()=>{var e;return String(null!=(e=l.node.language)?e:"plaintext")},We=()=>d(null,null,function*(){});const Ue=[],qe=[];let Ve=null;const Ge=c(()=>l.node.diff),Je=C({removed:0,added:0}),Xe=c(()=>`-${Je.value.removed} +${Je.value.added}`),Ye=Object.freeze({enabled:!1}),Ke=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function Qe(e){var t;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const n=e;return u(a(a({},Ke),n),{enabled:null==(t=n.enabled)||t})}return a({},Ke)}function Ze(e,t){return{original:String(null!=e?e:""),updated:String(null!=t?t:"")}}const et=c(()=>{var e,t,n;const o=l.monacoOptions?a({},l.monacoOptions):{};if(!Ge.value)return o;const i=void 0===o.diffHideUnchangedRegions?a({},Ke):Qe(o.diffHideUnchangedRegions),r=void 0===o.hideUnchangedRegions?void 0:Qe(o.hideUnchangedRegions),d=!1!==l.stream&&!1!==l.loading,s=d?a({},Ye):i,c=d?a({},Ye):r,v=a({},null!=(e=o.experimental)?e:{}),f=null!=(t=o.diffUnchangedRegionStyle)?t:"line-info",m={maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,diffHideUnchangedRegions:s,useInlineViewWhenSpaceIsLimited:null!=(n=o.useInlineViewWhenSpaceIsLimited)&&n,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:f,diffHunkActionsOnHover:!1,experimental:v};return u(a(u(a(a({},m),o),{experimental:v}),void 0===c?{}:{hideUnchangedRegions:c}),{diffHideUnchangedRegions:s})}),tt=c(()=>Ge.value?"diff":"single"),nt=C(tt.value),lt=C(!1),ot=C(!1),it=C(!1),rt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.wordWrap;return null==t||"off"!==String(t)}),at=c(()=>!(lt.value||!it.value&&(K()||ot.value))),ut=C(!1);"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield j();if(Se)return;if(!e)return void(lt.value=!0);const t=e.useMonaco,n=e.detectLanguage;if("function"==typeof n&&(Ie=n),"function"==typeof t){const e=mn();if(e&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(e))throw new Error("Preferred theme not in provided themes array");Ve=gn();const n=t(Ve);He=n.createEditor||He,ze=n.createDiffEditor||ze,Ne=n.updateCode||Ne,Fe=n.updateDiff||Fe,De=n.getEditor||De,Te=n.getEditorView||Te,_e=n.getDiffEditorView||_e,$e=n.cleanupEditor||$e,Re=n.safeClean||n.cleanupEditor||Re,Ae=n.refreshDiffPresentation||Ae,We=n.setTheme||We,ke.value=!0,!Se&&v.value&&(yield dn(v.value))}}catch(e){if(Se)return;lt.value=!0}});const dt=C("number"==typeof(null==(n=l.monacoOptions)?void 0:n.fontSize)?l.monacoOptions.fontSize:Number.NaN),st=C(dt.value),ct=c(()=>{const e=dt.value,t=st.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof t&&Number.isFinite(t)&&t>0}),vt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.fontSize;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const n=st.value;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:14}),ft=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.lineHeight;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:Math.max(12,Math.round(1.35*vt.value))}),mt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.tabSize;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:4}),pt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.padding;return{top:"number"==typeof(null==t?void 0:t.top)&&Number.isFinite(t.top)&&t.top>0?t.top:0,bottom:"number"==typeof(null==t?void 0:t.bottom)&&Number.isFinite(t.bottom)&&t.bottom>0?t.bottom:0}}),ht=c(()=>{const e=l.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),yt=c(()=>{const e=l.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),gt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.fontFamily;return a(a({fontSize:`${vt.value}px`,lineHeight:`${ft.value}px`,tabSize:mt.value,boxSizing:"border-box",maxHeight:`${Jt()}px`,overflow:"auto",paddingTop:`${pt.value.top}px`,paddingBottom:`${pt.value.bottom}px`},null!=ht.value?{height:`${ht.value}px`,minHeight:`${ht.value}px`}:{}),"string"==typeof t&&t.trim()?{"--markstream-code-font-family":t.trim()}:{})}),bt=c(()=>null!=ht.value&&(!ot.value||null!=St())),wt=c(()=>{if(bt.value)return{minHeight:`${ht.value}px`}}),kt=C(null);function St(){const e=kt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}function Ct(e,t=!1){const n=Math.ceil(e),l=St();return null==l?n:n>=l?(t&&we.value&&(kt.value=null),n):l}function xt(){return new Promise(e=>{I(()=>e())})}function Pt(){var e,t,n,l,o;try{const i=Ge.value?null!=(n=null==(t=null==(e=_e())?void 0:e.getModifiedEditor)?void 0:t.call(e))?n:_e():Te(),r=De(),a=null==(l=null==r?void 0:r.EditorOption)?void 0:l.fontInfo;if(i&&null!=a){const e=null==(o=i.getOption)?void 0:o.call(i,a),t=null==e?void 0:e.fontSize;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t}}catch(i){}try{const e=v.value;if(e){const t=e.querySelector(".view-lines .view-line");if(t)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(t).fontSize,n=e&&e.match(/^(\d+(?:\.\d+)?)/);if(n)return Number.parseFloat(n[1])}}catch(i){}}}catch(i){}return null}function Ot(e){var t,n;try{const l=De(),o=null==(t=null==l?void 0:l.EditorOption)?void 0:t.lineHeight;if(null!=o){const t=null==(n=null==e?void 0:e.getOption)?void 0:n.call(e,o);if("number"==typeof t&&t>0)return t}}catch(i){}const l=function(){try{const e=v.value;if(!e)return null;const t=e.querySelector(".view-lines .view-line");if(t){const e=Math.ceil(t.getBoundingClientRect().height);if(e>0)return e}}catch(i){}return null}();if(l&&l>0)return l;const o=Number.isFinite(st.value)&&st.value>0?st.value:14;return Math.max(12,Math.round(1.35*o))}function Mt(e){var t,n,l;try{const l=De(),o=null==(t=null==l?void 0:l.EditorOption)?void 0:t.padding;if(null!=o){const t=null==(n=null==e?void 0:e.getOption)?void 0:n.call(e,o),l="number"==typeof(null==t?void 0:t.top)?t.top:0,i="number"==typeof(null==t?void 0:t.bottom)?t.bottom:0;if(l>0||i>0)return l+i}}catch(a){}const o=null==(l=et.value)?void 0:l.padding,i="number"==typeof(null==o?void 0:o.top)?o.top:0,r="number"==typeof(null==o?void 0:o.bottom)?o.bottom:0;return i>0||r>0?i+r:Ge.value?24:0}function Et(e,t){return"number"!=typeof e||"number"!=typeof t||e<1||t<e?0:t-e+1}function Lt(e){if(!e)return[];const t=e.split(/\r?\n/);return 1===t.length&&""===t[0]?[]:t}function Bt(){var e,t;Ge.value?Je.value=function(e,t){const n=Lt(e),l=Lt(t);let o=0,i=n.length-1,r=l.length-1;for(;o<=i&&o<=r&&n[o]===l[o];)o++;for(;i>=o&&r>=o&&n[i]===l[r];)i--,r--;return{removed:Math.max(0,i-o+1),added:Math.max(0,r-o+1)}}(String(null!=(e=l.node.originalCode)?e:""),String(null!=(t=l.node.updatedCode)?t:"")):Je.value={removed:0,added:0}}function Ht(){var e;if(Ge.value)try{const t=_e(),n=null==(e=null==t?void 0:t.getLineChanges)?void 0:e.call(t);if(!Array.isArray(n))return void Bt();let l=0,o=0;for(const e of n)l+=Et(e.originalStartLineNumber,e.originalEndLineNumber),o+=Et(e.modifiedStartLineNumber,e.modifiedEndLineNumber);Je.value={removed:l,added:o}}catch(t){Bt()}else Je.value={removed:0,added:0}}function zt(){var e;if(Number.isFinite(st.value)&&st.value>0&&Number.isFinite(dt.value))return st.value;const t=Pt();return"number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?(dt.value=l.monacoOptions.fontSize,st.value=l.monacoOptions.fontSize,st.value):t&&t>0?(dt.value=t,st.value=t,t):(dt.value=12,st.value=12,12)}function Nt(){const e=zt(),t=Math.min(36,e+1);st.value=t}function Ft(){const e=zt(),t=Math.max(10,e-1);st.value=t}function Dt(){zt(),Number.isFinite(dt.value)&&(st.value=dt.value)}function Tt(){var e,t,n,l,o,i,r,a,u,d,s,c,v,f;try{const m=Ge.value?_e():null,p=Ge.value?m:Te();if(!p)return null;if((null==m?void 0:m.getOriginalEditor)&&(null==m?void 0:m.getModifiedEditor)){const v=null==(e=m.getOriginalEditor)?void 0:e.call(m),f=null==(t=m.getModifiedEditor)?void 0:t.call(m);null==(n=null==v?void 0:v.layout)||n.call(v),null==(l=null==f?void 0:f.layout)||l.call(f);const p=(null==(o=null==v?void 0:v.getContentHeight)?void 0:o.call(v))||0,h=(null==(i=null==f?void 0:f.getContentHeight)?void 0:i.call(f))||0,y=Math.max(p,h);if(y>0)return Math.ceil(y+1);const g=(null==(u=null==(a=null==(r=null==v?void 0:v.getModel)?void 0:r.call(v))?void 0:a.getLineCount)?void 0:u.call(a))||1,b=(null==(c=null==(s=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:s.getLineCount)?void 0:c.call(s))||1,w=Math.max(g,b),k=Math.max(Ot(v),Ot(f));return Math.ceil(w*(k+1.5)+0+1)}if(null==p?void 0:p.getContentHeight){null==(v=null==p?void 0:p.layout)||v.call(p);const e=p.getContentHeight();if(e>0)return Math.ceil(e+1)}const h=null==(f=null==p?void 0:p.getModel)?void 0:f.call(p);let y=1;h&&"function"==typeof h.getLineCount&&(y=h.getLineCount());const g=Ot(p);return Math.ceil(y*(g+1.5)+0+1)}catch(m){return null}}function _t(e){var t;const n=String(null!=e?e:"").trim(),l=null==(t=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?void 0:t[1];if(l){const e=3===l.length?l.split("").map(e=>`${e}${e}`).join(""):l;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=n.match(/\d+(?:\.\d+)?/g);if(!o||o.length<3)return null;const[i,r,a]=o.slice(0,3).map(Number);return.2126*i+.7152*r+.0722*a}function $t(){var e,t,n,l,o,i,r,a;const u=v.value,d=h.value;if(!u||!d)return;const s=u,c=u.querySelector(".monaco-editor")||u,f=c.querySelector(".monaco-editor-background")||c,m=c.querySelector(".view-lines")||c;let p=null,y=null,g=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(p=window.getComputedStyle(c),y=f===c?p:window.getComputedStyle(f),g=m===c?p:window.getComputedStyle(m))}catch(x){p=null,y=null,g=null}const b=String(null!=(e=null==p?void 0:p.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),w=String(null!=(t=null==p?void 0:p.getPropertyValue("--vscode-editor-background"))?t:"").trim(),k=String(null!=(l=null!=(n=null==p?void 0:p.getPropertyValue("--vscode-editor-selectionBackground"))?n:null==p?void 0:p.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?l:"").trim(),S=b||String(null!=(i=null!=(o=null==g?void 0:g.color)?o:null==p?void 0:p.color)?i:"").trim(),C=w||String(null!=(a=null!=(r=null==y?void 0:y.backgroundColor)?r:null==p?void 0:p.backgroundColor)?a:"").trim();return Ge.value?(S?(d.style.setProperty("--markstream-diff-editor-fg",S),s.style.setProperty("--vscode-editor-foreground",S),s.style.setProperty("--stream-monaco-editor-fg",S)):(d.style.removeProperty("--markstream-diff-editor-fg"),s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--stream-monaco-editor-fg")),C?(d.style.setProperty("--markstream-diff-editor-bg",C),d.style.setProperty("--markstream-diff-panel-bg",C),d.style.setProperty("--markstream-diff-panel-bg-soft",C),d.style.setProperty("--markstream-diff-panel-bg-strong",C),s.style.setProperty("--vscode-editor-background",C),s.style.setProperty("--stream-monaco-editor-bg",C),s.style.setProperty("--stream-monaco-fixed-editor-bg",C),s.style.setProperty("--stream-monaco-panel-bg",C),s.style.setProperty("--stream-monaco-panel-bg-soft",C),s.style.setProperty("--stream-monaco-panel-bg-strong",C),s.style.backgroundColor=C):(d.style.removeProperty("--markstream-diff-editor-bg"),d.style.removeProperty("--markstream-diff-panel-bg"),d.style.removeProperty("--markstream-diff-panel-bg-soft"),d.style.removeProperty("--markstream-diff-panel-bg-strong"),s.style.removeProperty("--vscode-editor-background"),s.style.removeProperty("--stream-monaco-editor-bg"),s.style.removeProperty("--stream-monaco-fixed-editor-bg"),s.style.removeProperty("--stream-monaco-panel-bg"),s.style.removeProperty("--stream-monaco-panel-bg-soft"),s.style.removeProperty("--stream-monaco-panel-bg-strong"),s.style.backgroundColor=""),void(k?s.style.setProperty("--vscode-editor-selectionBackground",k):s.style.removeProperty("--vscode-editor-selectionBackground"))):function(e,t,n){if(!Z.value)return!1;const l=_t(e),o=_t(t);return n?null!=l&&l>170||null!=o&&o<110:null!=l&&l<85||null!=o&&o>190}(C,S,d.classList.contains("is-dark"))?(s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--vscode-editor-background"),void s.style.removeProperty("--vscode-editor-selectionBackground")):(S&&s.style.setProperty("--vscode-editor-foreground",S),C&&s.style.setProperty("--vscode-editor-background",C),void(k&&s.style.setProperty("--vscode-editor-selectionBackground",k)))}const Rt=/auto|scroll|overlay/i;function At(e,t,n){var l;if("undefined"==typeof window)return;if(Ge.value)return;const o=Math.ceil(t),i=Math.ceil(n)-o;if(!i)return;const r=function(e){var t,n;if("undefined"==typeof window)return null;const l=null!=(t=null==e?void 0:e.ownerDocument)?t:document,o=l.scrollingElement||l.documentElement||l.body;let i=null!=(n=null==e?void 0:e.parentElement)?n:null;for(;i&&i!==l.body&&i!==o;){const e=window.getComputedStyle(i),t=(e.overflowY||"").toLowerCase(),n=(e.overflow||"").toLowerCase();if(Rt.test(t)||Rt.test(n))return i;i=i.parentElement}return o}(e);if(!r)return;const a=null!=(l=e.ownerDocument)?l:document,u=r===a.body||r===a.documentElement||r===a.scrollingElement,d=u?0:r.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,i):r.scrollTop+=i)}function jt(){try{const e=v.value;if(!e)return;const t=e.getBoundingClientRect().height,n=Tt();if(null!=n&&n>0){const l=Ct(n,!0),o=St();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",void At(e,t,l)}const l=St();null!=l&&(e.style.minHeight=`${l}px`,e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",At(e,t,l))}catch(e){}}function It(){for(var e,t;Ue.length>0;)try{null==(t=null==(e=Ue.pop())?void 0:e.dispose)||t.call(e)}catch(n){}null!=Ce&&(X(Ce),Ce=null)}function Wt(){for(var e;qe.length>0;)try{null==(e=qe.pop())||e()}catch(t){}}function Ut(e=!1){te.value||(ee.value?jt():function(){var e;try{const t=v.value;if(!t)return;const n=t.getBoundingClientRect().height,l=Jt(),o=Math.ceil((null==(e=t.getBoundingClientRect)?void 0:e.call(t).height)||0),i=Ge.value?function(){var e,t,n,l,o,i,r,a;try{const u=_e(),d=null==(e=null==u?void 0:u.getOriginalEditor)?void 0:e.call(u),s=null==(t=null==u?void 0:u.getModifiedEditor)?void 0:t.call(u);if(!d||!s)return null;const c=(null==(o=null==(l=null==(n=d.getModel)?void 0:n.call(d))?void 0:l.getLineCount)?void 0:o.call(l))||1,v=(null==(a=null==(r=null==(i=s.getModel)?void 0:i.call(s))?void 0:r.getLineCount)?void 0:a.call(r))||1,f=Math.max(c,v),m=Math.max(Ot(d),Ot(s)),p=Math.max(Mt(d),Mt(s));return Math.ceil(f*(m+1.5)+p+0+1)}catch(u){return null}}():null,r=Ge.value&&function(e){if("undefined"==typeof window)return!1;const t=e.querySelectorAll(".editor.modified .diff-hidden-lines .center, .stream-monaco-diff-unchanged-bridge");for(const n of Array.from(t)){if(!(n instanceof HTMLElement))continue;const e=window.getComputedStyle(n);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const t=n.getBoundingClientRect();if(!(t.width<=0||t.height<=0))return!0}return!1}(t);if(r||(Pe.value=null),Me>0&&(Me--,null!=xe.value))return void At(t,n,Gt(t,xe.value,l));const a=Ge.value?function(e){var t,n;if("undefined"==typeof window)return null;try{const l=e.getBoundingClientRect();if(l.height<=0)return null;const o=[".editor.original .view-lines .view-line",".editor.modified .view-lines .view-line",".editor.original .view-zones > div",".editor.modified .view-zones > div",".editor.original .margin-view-zones > div",".editor.modified .margin-view-zones > div",".editor.original .diff-hidden-lines",".editor.modified .diff-hidden-lines",".stream-monaco-diff-unchanged-bridge"];let i=0;for(const t of Array.from(e.querySelectorAll(o.join(",")))){if(!(t instanceof HTMLElement))continue;const e=window.getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const n=t.getBoundingClientRect();n.height<=0||n.bottom<=l.top||(i=Math.max(i,n.bottom-l.top))}if(i>0)return Math.ceil(i+1);const r=e.querySelector(".monaco-diff-editor"),a=null!=(n=null==(t=null==r?void 0:r.getBoundingClientRect)?void 0:t.call(r).height)?n:0;return a>0?Math.ceil(a+1):null}catch(l){return null}}(t):null,u=Ge.value?r?a:Math.max(null!=a?a:0,null!=i?i:0)||null:Tt();if(null!=u&&u>0){const e=null!=Pe.value&&Date.now()<Oe&&u>=l-1,i=r&&o>0&&o<l-1&&u>=l-1,a=Gt(t,e?Pe.value:i?o:u,l,{clearEstimatedFloor:!0});return r&&a<l-1&&(Pe.value=a,Oe=Date.now()+160),void At(t,n,a)}if(null!=xe.value)return void At(t,n,Gt(t,xe.value,l));const d=r?o:Math.max(o,null!=i&&i>0?i:0);if(d>0){const e=null!=Pe.value&&Date.now()<Oe&&d>=l-1,i=r&&o>0&&o<l-1&&d>=l-1,a=Gt(t,e?Pe.value:i?o:d,l);return r&&a<l-1&&(Pe.value=a,Oe=Date.now()+160),void At(t,n,a)}const s=St();if(null!=s)return void At(t,n,Gt(t,s,l));const c=Number.parseFloat(t.style.height);!Number.isNaN(c)&&c>0?At(t,n,Gt(t,c,l)):Ge.value||At(t,n,Gt(t,l,l))}catch(t){}}())}function qt(){if(!Ge.value)return void Wt();const e=v.value;if(!e)return void Wt();const t=e.querySelector(".monaco-diff-editor");if(!t||t.classList.contains("side-by-side"))return void Wt();const n=Array.from(t.querySelectorAll(".editor.original .diff-hidden-lines")),l=Array.from(t.querySelectorAll(".editor.modified .diff-hidden-lines")),o=Math.min(n.length,l.length);for(let i=0;i<o;i++){const e=l[i],t=e.querySelector("a"),n=e.querySelector(".center > div:first-child"),o=e.querySelector(".center");if(!t||!n||!o)continue;if(o.querySelector(".markstream-inline-fold-proxy"))continue;const r=document.createElement("button");r.type="button",r.className="markstream-inline-fold-proxy",r.dataset.markstreamInlineFoldProxy="true";const a=t.getAttribute("title")||"Show Unchanged Region";r.title=a,r.setAttribute("aria-label",a);const u=e=>{e.preventDefault(),e.stopPropagation()},d=e=>{e.preventDefault(),e.stopPropagation(),t.click(),I(()=>Vt())},s=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),t.click(),I(()=>Vt()))};r.addEventListener("mousedown",u),r.addEventListener("click",d),r.addEventListener("keydown",s),o.appendChild(r),qe.push(()=>{r.removeEventListener("mousedown",u),r.removeEventListener("click",d),r.removeEventListener("keydown",s),r.parentElement===o&&o.removeChild(r)})}}function Vt(e=!1){null==Ce&&(Ce=I(()=>{Ce=null,I(()=>{qt(),Ut(e)})}))}function Gt(e,t,n,l={}){const o=Ct(Math.min(t,n),!0===l.clearEstimatedFloor),i=St();if(e.style.minHeight=null!=i?`${Math.min(i,Math.ceil(n))}px`:"0px",e.style.height=`${o}px`,e.style.maxHeight=`${Math.ceil(n)}px`,Ge.value)e.style.overflow="hidden";else{const l=t>n+1;e.style.overflow=l?"auto":"hidden"}return o}function Jt(){var e,t;const n=null!=(t=null==(e=l.monacoOptions)?void 0:e.MAX_HEIGHT)?t:500;if("number"==typeof n)return n;const o=String(n).match(/^(\d+(?:\.\d+)?)/);return o?Number.parseFloat(o[1]):500}const Xt=c(()=>l.isShowPreview&&("html"===_.value||"svg"===_.value));x(()=>l.node.language,e=>{_.value=$(e)}),x(()=>[l.node.originalCode,l.node.updatedCode,Ge.value],()=>{Bt(),I(()=>Ht())},{immediate:!0}),x(()=>[l.node.originalCode,l.node.updatedCode,Q.value,Ge.value],e=>d(null,[e],function*([e,t,n,o]){if(!1===l.stream||!o)return;if(He&&!be.value&&v.value)try{yield dn(v.value)}catch(a){}const i=Ze(String(null!=e?e:""),String(null!=t?t:"")),r=!1===l.loading;if(r&&bn(),yield Fe(i.original,i.updated,Q.value),r){if(Se||!Ge.value)return;Ae(),qt(),Ht(),Vt()}ee.value&&I(()=>jt())})),x(()=>l.node.code,e=>d(null,null,function*(){if(!1!==l.stream&&(_.value||(_.value=$(Ie(e))),!Ge.value)){if(He&&!be.value&&v.value)try{yield dn(v.value)}catch(t){}Ne(e,Q.value),ee.value&&I(()=>jt())}}));const Yt=c(()=>{const e=_.value;return e?W[e]||e.charAt(0).toUpperCase()+e.slice(1):W[""]||"Plain Text"});const Kt=c(()=>{var e;return function(e){const t=function(e){var t,n;const l=null!=(n=null==(t=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:t.trim())?n:"";if(l.length<3)return"";const o=l[0];if("`"!==o&&"~"!==o||l[1]!==o||l[2]!==o)return"";let i=3;for(;l[i]===o;)i+=1;return l.slice(i).trim()}(e);if(!t)return"";const n=t.split(/\s+/).filter(Boolean);if(!n.length)return"";const l="diff"===n[0]?n.slice(1):n;for(const o of l){const e=o.includes(":")?o.slice(o.indexOf(":")+1):o;if(e&&/[./\\-]/.test(e))return e}return""}(String(null!=(e=l.node.raw)?e:""))}),Qt=c(()=>Kt.value||Yt.value),Zt=c(()=>Kt.value?Ge.value?`Diff / ${Yt.value}`:Yt.value:""),en=c(()=>(U.value,q(_.value||""))),tn=c(()=>{var e;const t={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},o=n(l.minWidth),i=n(l.maxWidth);return o&&(t.minWidth=o),i&&(t.maxWidth=i),bt.value&&(t.minHeight=`${null!=(e=yt.value)?e:ht.value}px`),Ge.value||(t.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg))",t.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg))",t.borderColor="var(--markstream-code-border-color)"),t}),nn=c(()=>!1!==l.showTooltips);function ln(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(l.node.code)),b.value=!0,o("copy",l.node.code),setTimeout(()=>{b.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function on(e){if(ee.value=!ee.value,e&&nn.value){const t=function(e){const t=e.currentTarget||e.target;return!t||t.disabled?null:t}(e);if(t){const e=ee.value?s("common.collapse")||"Collapse":s("common.expand")||"Expand";Y(t,e,"top",!1,void 0,l.isDark)}}const t=Ge.value?_e():Te(),n=v.value;t&&n&&(ee.value?(un(!0),n.style.maxHeight="none",n.style.overflow="visible",Ut(!0)):(un(!1),n.style.overflow=Ge.value?"hidden":"auto",Ut(!0)))}function rn(){var e,t,n;if(te.value=!te.value,te.value){if(v.value){const n=Math.ceil((null==(t=(e=v.value).getBoundingClientRect)?void 0:t.call(e).height)||0);n>0&&(xe.value=n)}un(!1)}else{ee.value&&un(!0),v.value&&null!=xe.value&&(v.value.style.height=`${xe.value}px`);const e=Ge.value?_e():Te();try{null==(n=null==e?void 0:e.layout)||n.call(e)}catch(l){}Me=2,I(()=>{Ut(!0)})}}function an(){if(!Xt.value)return;const e=_.value;if(r.value){const t="html"===e?"text/html":"image/svg+xml",n="html"===e?s("artifacts.htmlPreviewTitle")||"HTML Preview":s("artifacts.svgPreviewTitle")||"SVG Preview";return void o("previewCode",{node:l.node,artifactType:t,artifactTitle:n,id:`temp-${e}-${Date.now()}`})}"html"===e&&(ut.value=!ut.value)}function un(e){var t,n;try{if(Ge.value){const n=_e();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}else{const t=Te();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}}catch(l){}}function dn(e){if(!He||Se)return null;if(je)return je;if(be.value&&we.value)return Promise.resolve();be.value=!0;const t=d(null,null,function*(){yield function(e){return d(this,null,function*(){var t;if("undefined"==typeof window)return yield e();try{const n=null==(t=window.Element)?void 0:t.prototype,l=null==n?void 0:n.addEventListener;if(!n||!l)return yield e();const o=function(){const e=window,t=e[ge];if(t)return t;const n={depth:0,original:null};return e[ge]=n,n}();0===o.depth&&(o.original=l,n.addEventListener=function(e,t,n){var i;const r=null!=(i=o.original)?i:l;return"touchstart"===e&&function(e,t){if(!e)return!1;const n=e;return!("function"!=typeof n.closest||!n.closest(".monaco-editor, .monaco-diff-editor")||t&&"object"==typeof t&&"passive"in t)}(this,n)?r.call(this,e,t,function(e){return null==e?{passive:!0}:"boolean"==typeof e?{capture:e,passive:!0}:"object"==typeof e?"passive"in e?e:u(a({},e),{passive:!0}):{passive:!0}}(n)):r.call(this,e,t,n)}),o.depth++;try{return yield e()}finally{o.depth=Math.max(0,o.depth-1),0===o.depth&&o.original&&n.addEventListener!==o.original&&(n.addEventListener=o.original,o.original=null)}}catch(n){return yield e()}})}(()=>function(e){return d(this,null,function*(){var t,n,o;if(!He||Se)return;if(it.value=!1,ot.value=!1,function(){const e=ht.value;kt.value=we.value||null==e?null:e}(),It(),Wt(),function(e){e.replaceChildren()}(e),Se)return;if(Ge.value){Re();const o=Ze(String(null!=(t=l.node.originalCode)?t:""),String(null!=(n=l.node.updatedCode)?n:""));ze?yield ze(e,o.original,o.updated,Q.value):yield He(e,l.node.code,Q.value)}else yield He(e,l.node.code,Q.value);if(Se)return;const i=Ge.value?_e():Te();if("number"==typeof(null==(o=l.monacoOptions)?void 0:o.fontSize))null==i||i.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),dt.value=l.monacoOptions.fontSize,st.value=l.monacoOptions.fontSize;else{const e=Pt();e&&e>0?(dt.value=e,st.value=e):(dt.value=12,st.value=12)}ee.value||te.value||Ut(!1),yield function(){return d(this,null,function*(){null!=St()&&(qt(),Ut(!1),yield O(),yield xt(),qt(),Ut(!1),yield xt(),qt(),Ut(!1))})}(),Se||(we.value=!0,function(){var e,t,n,l,o;if(It(),Ge.value){const l=_e(),o=null==(e=null==l?void 0:l.getOriginalEditor)?void 0:e.call(l),i=null==(t=null==l?void 0:l.getModifiedEditor)?void 0:t.call(l),a=(e,t)=>{try{const n=null==e?void 0:e[t];if("function"!=typeof n)return;const l=n.call(e,()=>Vt());l&&Ue.push(l)}catch(n){}};try{const e=null==(n=null==l?void 0:l.onDidUpdateDiff)?void 0:n.call(l,()=>{Vt(),I(()=>Ht())});e&&Ue.push(e)}catch(r){}return a(o,"onDidContentSizeChange"),a(i,"onDidContentSizeChange"),a(o,"onDidLayoutChange"),void a(i,"onDidLayoutChange")}const i=Te();try{const e=null==(l=null==i?void 0:i.onDidContentSizeChange)?void 0:l.call(i,()=>Vt());e&&Ue.push(e)}catch(r){}try{const e=null==(o=null==i?void 0:i.onDidLayoutChange)?void 0:o.call(i,()=>Vt());e&&Ue.push(e)}catch(r){}}(),$t(),qt(),Ht(),Vt(),yield function(){return d(this,null,function*(){qt(),Ut(!1),yield O(),yield xt(),qt(),Ut(!1),yield xt(),qt(),Ut(!1)})}(),Se||(ot.value=!0))})}(e))}).finally(()=>{je===t&&(je=null)});return je=t,t}x(nn,e=>{e||V()}),x(()=>st.value,(e,t)=>{const n=Ge.value?_e():Te();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(n.updateOptions({fontSize:e}),te.value||Ut(!0))},{flush:"post",immediate:!1});const sn=x(()=>[v.value,Ge.value,l.stream,l.loading,ke.value,Be.value],e=>d(null,[e],function*([e,t,n,l,o,i]){if(!e||!He)return;if(!i)return;if(!1===n&&!1!==l)return;const r=dn(e);if(r){try{yield r}catch(a){we.value=!1,ot.value=!1,it.value=!0}sn()}}));function cn(e){return!!e&&"object"==typeof e&&"light"in e&&"dark"in e}function vn(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function fn(e,t){if(e===t)return!0;const n=vn(e),l=vn(t);return!!n&&n===l}function mn(){var e;const t=function(){if(void 0!==l.theme){const e=l.theme;return cn(e)?l.isDark?e.dark:e.light:e}return l.isDark?l.darkTheme:l.lightTheme}(),n=null==(e=et.value)?void 0:e.theme,o=null!=t?t:n;if(null!=o&&"object"==typeof o)return o;const i=Array.isArray(l.themes)?l.themes:[];if(!i.length||null==o)return o;const r=vn(o),a=i.map(e=>vn(e)).filter(e=>!!e);if(!r||a.includes(r))return o;const u=vn(n);return null!=n&&u&&a.includes(u)?n:i[0]}x(tt,(e,t)=>d(null,null,function*(){if(e===t)return;if(nt.value=e,!He||!v.value)return;if(!be.value)return;if(!1===l.stream&&!1!==l.loading)return;if(!Be.value)return;const n=je;if(n){try{yield n}catch(o){}if(Se||!v.value)return}try{we.value=!1,ot.value=!1,be.value=!1,It(),Wt(),Re(),yield O(),yield dn(v.value)}catch(i){we.value=!1,ot.value=!1,it.value=!0}}));const pn=c(()=>(void 0!==l.theme?!cn(l.theme):fn(l.darkTheme,l.lightTheme))?function(e){var t,n;if(e&&"object"==typeof e&&(null==(t=e.colors)?void 0:t["editor.background"])){const t=_t(e.colors["editor.background"]);if(null!=t)return t<128}const o=(null!=(n=vn(e))?n:"").toLowerCase();return o?["dark","night","moon","black","dracula","mocha","frappe","macchiato","palenight","ocean","poimandres","monokai","laserwave","tokyo","slack-dark","rose-pine","github-dark","material-theme","one-dark","catppuccin-mocha","catppuccin-frappe","catppuccin-macchiato"].some(e=>o.includes(e))&&!["light","latte","dawn","lotus"].some(e=>o.includes(e)):!!l.isDark}(mn()):!!l.isDark),hn=c(()=>{var e;if(!Ge.value)return pn.value?"dark":"light";const t=null==(e=et.value)?void 0:e.diffAppearance;return"light"===t||"dark"===t?t:pn.value?"dark":"light"}),yn=c(()=>Ge.value?"dark"===hn.value:pn.value);function gn(){return u(a(u(a({wordWrap:"on",wrappingIndent:"same",themes:l.themes},et.value||{}),{theme:mn()}),Ge.value?{diffAppearance:hn.value}:{}),{onThemeChange(){$t()}})}function bn(){const e=gn();if(!Ve)return Ve=e,Ve;for(const t of Object.keys(Ve))t in e||delete Ve[t];return Object.assign(Ve,e),Ve}const wn=c(()=>{var e,t,n,o,i,r,u,d,s,c,v,f,m,p,h;return JSON.stringify({diffLineStyle:null!=(t=null==(e=et.value)?void 0:e.diffLineStyle)?t:"background",diffUnchangedRegionStyle:null!=(o=null==(n=et.value)?void 0:n.diffUnchangedRegionStyle)?o:"line-info",diffHideUnchangedRegions:void 0===(null==(i=l.monacoOptions)?void 0:i.diffHideUnchangedRegions)?a({},Ke):Qe(l.monacoOptions.diffHideUnchangedRegions),renderSideBySide:null==(u=null==(r=et.value)?void 0:r.renderSideBySide)||u,useInlineViewWhenSpaceIsLimited:null==(s=null==(d=et.value)?void 0:d.useInlineViewWhenSpaceIsLimited)||s,enableSplitViewResizing:null==(v=null==(c=et.value)?void 0:c.enableSplitViewResizing)||v,ignoreTrimWhitespace:null==(m=null==(f=et.value)?void 0:f.ignoreTrimWhitespace)||m,originalEditable:null!=(h=null==(p=et.value)?void 0:p.originalEditable)&&h})});return x(()=>[l.monacoOptions,Be.value],()=>{var e,t;if(bn(),!He||!Be.value)return;const n=Ge.value?_e():Te(),o="number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?l.monacoOptions.fontSize:Number.isFinite(st.value)?st.value:void 0;"number"==typeof o&&Number.isFinite(o)&&o>0&&(null==(t=null==n?void 0:n.updateOptions)||t.call(n,{fontSize:o})),Ut(!1)},{deep:!0}),x(()=>[mn(),hn.value,ke.value,be.value,Be.value],([e],t)=>{ke.value&&be.value&&Be.value&&function(e={}){if(e.appearanceOnly)return;bn();const t=mn(),n=()=>{Ge.value&&Ae(),I(()=>{$t(),Vt()})};t?function(e,t){const n=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&"name"in e)return String(e.name);if("object"==typeof e){const n=de.get(e);if(n)return n;try{const t=JSON.stringify(e);if(t)return de.set(e,t),t}catch(t){}const l="__theme_"+ ++se;return de.set(e,l),l}return String(e)}(t);return n?(ue=e,le||ae!==n?le?(re===n||oe===n||(ie=t,re=n),le):(ie=t,re=n,le=d(null,null,function*(){for(;re&&null!=ie;){const n=ie,l=re;if(ie=null,re=null,ae!==l)try{oe=l,yield(null!=ue?ue:e)(n),ae=l}catch(t){}}}).finally(()=>{le=null,oe=null}),le):Promise.resolve()):Promise.resolve()}(We,t).then(n).catch(e=>{}):n()}({appearanceOnly:null!=t&&fn(e,t[0])})},{flush:"post"}),x(()=>[wn.value,ke.value,Be.value],(e,t)=>d(null,[e,t],function*([e,t,n],[o]){if(bn(),!t||!n)return;if(!He||!v.value)return;if(!be.value)return;if(e===o)return;if(!1===l.stream&&!1!==l.loading)return;const i=je;if(i){try{yield i}catch(r){}if(Se||!v.value)return}try{we.value=!1,ot.value=!1,be.value=!1,It(),Wt(),Re(),yield O(),yield dn(v.value)}catch(a){we.value=!1,ot.value=!1,it.value=!0}}),{flush:"post"}),x(()=>[l.loading,Be.value],(e,t)=>d(null,[e,t],function*([e,t],n){if(!t)return;if(e)return;const o=null==n?void 0:n[0],i=void 0!==o&&!1!==o;yield O(),I(()=>{d(null,null,function*(){var e,t,n;try{if(i&&be.value)if(Ge.value&&v.value){const n=je;if(n)try{yield n}catch(o){}bn();const i=Ze(String(null!=(e=l.node.originalCode)?e:""),String(null!=(t=l.node.updatedCode)?t:""));if(yield Fe(i.original,i.updated,Q.value),Se||!Ge.value)return;Ae(),qt(),Ht()}else Ne(String(null!=(n=l.node.code)?n:""),Q.value);Ut(!1)}catch(r){}})})}),{immediate:!0,flush:"post"}),f(()=>{It(),Wt(),$e()}),(t,n)=>lt.value?(m(),p(k(G),{key:0,node:l.node,loading:l.loading},null,8,["node","loading"])):(m(),M("div",{key:1,ref_key:"container",ref:h,style:E(tn.value),class:g(["code-block-container rounded-lg border",[{dark:l.isDark,"is-rendering":l.loading,"is-dark":yn.value,"is-diff":Ge.value,"is-plain-text":Z.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":ot.value&&!lt.value?"true":"false"},[L(J,{"show-header":l.showHeader,"show-collapse-button":l.showCollapseButton,"show-font-size-buttons":l.showFontSizeButtons,"enable-font-size-control":l.enableFontSizeControl,"show-copy-button":l.showCopyButton,"show-expand-button":l.showExpandButton,"show-preview-button":l.showPreviewButton,"show-tooltips":l.showTooltips,"is-dark":l.isDark,loading:l.loading,stream:e.stream,"is-collapsed":te.value,"is-expanded":ee.value,"copy-text":b.value,"is-previewable":Xt.value,"code-font-size":st.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":dt.value,"font-baseline-ready":ct.value,"diff-stats":Ge.value?Je.value:null,"diff-stats-aria-label":Xe.value,onToggleCollapse:rn,onDecreaseFont:Ft,onResetFont:Dt,onIncreaseFont:Nt,onCopy:ln,onToggleExpand:on,onPreview:an},B({"header-left":H(()=>[D(t.$slots,"header-left",{},()=>[y("div",ve,[y("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:en.value},null,8,fe),y("div",me,[y("div",pe,w(Qt.value),1),Zt.value?(m(),M("div",he,w(Zt.value),1)):N("",!0)])])],!0)]),loading:H(()=>[D(t.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[n[0]||(n[0]=y("div",{class:"loading-skeleton"},[y("div",{class:"skeleton-line"}),y("div",{class:"skeleton-line"}),y("div",{class:"skeleton-line short"})],-1))],!0)]),default:H(()=>[z(y("div",ye,[y("div",{ref_key:"codeEditor",ref:v,class:g(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":at.value}]]),style:E(wt.value)},null,6),at.value?(m(),p(k(G),{key:0,class:g(["code-pre-fallback",{"is-wrap":rt.value}]),style:E(gt.value),node:l.node},null,8,["class","style","node"])):N("",!0)],512),[[F,!(te.value||!e.stream&&e.loading)]]),ut.value&&!r.value&&Xt.value&&"html"===_.value?(m(),p(ne,{key:0,code:l.node.code,"html-preview-allow-scripts":l.htmlPreviewAllowScripts,"html-preview-sandbox":l.htmlPreviewSandbox,"is-dark":l.isDark,"on-close":()=>ut.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):N("",!0)]),_:2},[t.$slots["header-right"]?{name:"header-right",fn:H(()=>[D(t.$slots,"header-right",{},void 0,!0)]),key:"0"}:void 0]),1032,["show-header","show-collapse-button","show-font-size-buttons","enable-font-size-control","show-copy-button","show-expand-button","show-preview-button","show-tooltips","is-dark","loading","stream","is-collapsed","is-expanded","copy-text","is-previewable","code-font-size","default-code-font-size","font-baseline-ready","diff-stats","diff-stats-aria-label"])],14,ce))}}),[["__scopeId","data-v-9f975995"]]);export{be as default};