markstream-vue 0.0.14-beta.8 → 1.0.0

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.
Files changed (68) hide show
  1. package/README.md +22 -13
  2. package/README.zh-CN.md +6 -8
  3. package/dist/CodeBlockNode.js +1 -1
  4. package/dist/exports.js +1 -1
  5. package/dist/index.css +1 -1
  6. package/dist/index.d.ts +68 -366
  7. package/dist/index.js +1 -1
  8. package/dist/index.px.css +1 -1
  9. package/dist/index.tailwind.css +1 -1
  10. package/dist/index2.js +1 -1
  11. package/dist/index3.js +1 -1
  12. package/dist/index4.js +1 -1
  13. package/dist/index5.js +1 -1
  14. package/dist/index6.js +1 -1
  15. package/dist/index7.js +1 -1
  16. package/dist/tailwind.d.ts +2 -0
  17. package/dist/tailwind.js +0 -0
  18. package/dist/utils/katex-threshold.d.ts +22 -0
  19. package/dist/utils/katex-threshold.js +1 -0
  20. package/dist/utils/performance-monitor.d.ts +122 -0
  21. package/dist/utils/performance-monitor.js +1 -0
  22. package/dist/utils/safeRaf.d.ts +4 -0
  23. package/dist/utils/safeRaf.js +1 -0
  24. package/dist/workers/katexCdnWorker.d.ts +54 -0
  25. package/dist/workers/katexCdnWorker.js +1 -0
  26. package/dist/workers/katexWorkerClient.d.ts +49 -0
  27. package/dist/workers/katexWorkerClient.js +1 -0
  28. package/dist/workers/mermaidCdnWorker.d.ts +37 -0
  29. package/dist/workers/mermaidCdnWorker.js +1 -0
  30. package/dist/workers/mermaidWorkerClient.d.ts +22 -0
  31. package/dist/workers/mermaidWorkerClient.js +1 -0
  32. package/dist/workers-katexWorkerClient.js +1 -0
  33. package/dist/workers-mermaidWorkerClient.js +1 -0
  34. package/package.json +58 -40
  35. package/.agents/skills/markstream-angular/SKILL.md +0 -42
  36. package/.agents/skills/markstream-angular/agents/openai.yaml +0 -4
  37. package/.agents/skills/markstream-custom-components/SKILL.md +0 -48
  38. package/.agents/skills/markstream-custom-components/agents/openai.yaml +0 -4
  39. package/.agents/skills/markstream-custom-components/references/patterns.md +0 -31
  40. package/.agents/skills/markstream-install/SKILL.md +0 -59
  41. package/.agents/skills/markstream-install/agents/openai.yaml +0 -4
  42. package/.agents/skills/markstream-install/references/scenarios.md +0 -39
  43. package/.agents/skills/markstream-migration/SKILL.md +0 -56
  44. package/.agents/skills/markstream-migration/agents/openai.yaml +0 -4
  45. package/.agents/skills/markstream-migration/references/adoption-checklist.md +0 -30
  46. package/.agents/skills/markstream-nuxt/SKILL.md +0 -40
  47. package/.agents/skills/markstream-nuxt/agents/openai.yaml +0 -4
  48. package/.agents/skills/markstream-react/SKILL.md +0 -43
  49. package/.agents/skills/markstream-react/agents/openai.yaml +0 -4
  50. package/.agents/skills/markstream-svelte/SKILL.md +0 -20
  51. package/.agents/skills/markstream-svelte/agents/openai.yaml +0 -4
  52. package/.agents/skills/markstream-vue/SKILL.md +0 -44
  53. package/.agents/skills/markstream-vue/agents/openai.yaml +0 -4
  54. package/.agents/skills/markstream-vue2/SKILL.md +0 -40
  55. package/.agents/skills/markstream-vue2/agents/openai.yaml +0 -4
  56. package/.agents/skills/markstream-vue2-cli/SKILL.md +0 -39
  57. package/.agents/skills/markstream-vue2-cli/agents/openai.yaml +0 -4
  58. package/.agents/skills/markstream-vue2-vite/SKILL.md +0 -39
  59. package/.agents/skills/markstream-vue2-vite/agents/openai.yaml +0 -4
  60. package/bin/markstream-vue.mjs +0 -116
  61. package/bin/prompts-lib.mjs +0 -49
  62. package/bin/skills-lib.mjs +0 -214
  63. package/dist/tailwind.ts +0 -0
  64. package/prompts/add-custom-tag-thinking.md +0 -25
  65. package/prompts/audit-markstream-integration.md +0 -23
  66. package/prompts/install-markstream.md +0 -27
  67. package/prompts/migrate-react-markdown.md +0 -25
  68. package/prompts/override-built-in-components.md +0 -25
package/README.md CHANGED
@@ -22,6 +22,14 @@ Looking for other frameworks?
22
22
  - Vue 2.6: use [`markstream-vue2`](./packages/markstream-vue2/README.md) (a baseline port with fewer advanced features)
23
23
  - React: see `packages/markstream-react` at [`packages/markstream-react/README.md`](./packages/markstream-react/README.md) (first-pass port)
24
24
 
25
+ ## 1.0 stability scope
26
+
27
+ `markstream-vue@1.0` is scoped to the Vue 3 renderer package. The stable surface is `MarkdownRender`, streaming content rendering, pre-parsed node rendering, the safe HTML policy, optional Mermaid / KaTeX / Monaco / D2 / Infographic integrations, CSS exports, worker client subpaths, and SSR imports for Vite / Nuxt / VitePress.
28
+
29
+ Experimental surfaces are the cross-framework adapters, repository skills/prompts, low-level worker entrypoints beyond documented clients, and internal performance/debug props such as `indexKey`, `renderAsFragment`, `debugPerformance`, batch budget internals, and height-estimation experiments.
30
+
31
+ For the full release contract and Go / No-Go checklist, see [1.0 Release Readiness](./docs/guide/release-1-0.md). For reproducible performance evidence, run `pnpm benchmark:1.0` and use the generated [1.0 Benchmark Report](./docs/guide/benchmark-1-0.md).
32
+
25
33
  ## Contents
26
34
 
27
35
  - [TL;DR Highlights](#tldr-highlights)
@@ -73,6 +81,8 @@ Looking for other frameworks?
73
81
  - Playground (interactive demo): https://markstream-vue.simonhe.me/
74
82
  - Interactive test page (shareable links, easy reproduction): https://markstream-vue.simonhe.me/test
75
83
  - Docs: https://markstream-vue-docs.simonhe.me/guide/
84
+ - Showcase: https://markstream-vue-docs.simonhe.me/guide/showcase
85
+ - 1.0 benchmark report: run `pnpm benchmark:1.0`
76
86
  - AI/LLM context (project map): https://markstream-vue-docs.simonhe.me/llms
77
87
  - AI/LLM context (中文): https://markstream-vue-docs.simonhe.me/llms.zh-CN
78
88
  - One-click StackBlitz demo: https://stackblitz.com/github/Simon-He95/markstream-vue?file=playground/src/App.vue
@@ -80,23 +90,19 @@ Looking for other frameworks?
80
90
  - Nuxt playground: `pnpm play:nuxt`
81
91
  - Discord: https://discord.gg/vkzdkjeRCW
82
92
 
83
- ## CLI helpers for skills and prompts
93
+ ## Repository skills and prompts
84
94
 
85
- If you want the packaged AI assets without cloning the repo:
95
+ If you want the AI assets without cloning the repo:
86
96
 
87
97
  ```bash
88
98
  npx skills add Simon-He95/markstream-vue
89
- npx markstream-vue skills list
90
- npx markstream-vue skills install
91
- npx markstream-vue prompts list
92
- npx markstream-vue prompts show install-markstream
93
99
  ```
94
100
 
95
101
  Recommended usage:
96
102
 
97
103
  - `npx skills add Simon-He95/markstream-vue` is the primary path for Codex-compatible skill discovery because it reads `.agents/skills` directly from the GitHub repository
98
- - `skills install` installs the bundled skills into your agent skill directory (default: `~/.agents/skills`)
99
- - `prompts list` and `prompts show` to discover and copy maintained prompt templates
104
+ - `markstream-vue@1.0` no longer exposes the `markstream-vue` CLI or any CLI `bin`; repository scripts such as `pnpm skills:list` and `pnpm prompts:list` are contributor-only helpers for cloned checkouts
105
+ - prompts remain in the repository under `prompts/` for direct copying or future separate-package work
100
106
 
101
107
  Other `npx skills add` forms also work:
102
108
 
@@ -152,6 +158,7 @@ createApp({
152
158
  ```
153
159
 
154
160
  Import `markstream-vue/index.css` after your reset (e.g., use `@import 'markstream-vue/index.css' layer(components);` for Tailwind) so renderer styles win over utility classes. Install optional peers such as `stream-monaco`, `shiki`, `stream-markdown`, `mermaid`, and `katex` only when you need Monaco code blocks, Shiki highlighting, diagrams, or math.
161
+ For untrusted user-generated content, prefer `htmlPolicy="escape"` so raw HTML is rendered as text.
155
162
  If your app intentionally scales root font size on mobile, use `markstream-vue/index.px.css` to avoid `rem`-based global scaling side effects.
156
163
 
157
164
  Renderer CSS is scoped under an internal `.markstream-vue` container to minimize global style conflicts. If you render exported node components outside of `MarkdownRender`, wrap them in an element with class `markstream-vue`.
@@ -433,17 +440,19 @@ Parse hooks example (match server + client):
433
440
 
434
441
  - Latest: [Releases](https://github.com/Simon-He95/markstream-vue/releases) — see highlights and upgrade notes.
435
442
  - Full history: [CHANGELOG.md](./CHANGELOG.md)
436
- - Recent highlights (0.0.3-beta.1/beta.0):
437
- - Parser bumped to `stream-markdown-parser@0.0.36` for parsing fixes.
438
- - Monaco upgrades with more languages/themes + diff-friendly code block tweaks.
439
- - HTML/SVG preview dialog and AST debug view in the playground.
443
+ - 1.0 launch notes:
444
+ - Stable Vue 3 renderer API, SSR imports, CSS exports, Tailwind export, worker client exports, and safe HTML defaults.
445
+ - `markstream-vue@1.0.0`, `markstream-core@1.0.0`, and `stream-markdown-parser@1.0.0` ship together.
446
+ - Public benchmark report: run `pnpm benchmark:1.0` or use the `1.0 Benchmark` workflow artifact.
447
+ - Migration guide: [Migrating to 1.0](./docs/guide/migration-1-0.md).
440
448
 
441
449
  ## 🧭 Showcase & examples
442
450
 
443
451
  Build something with markstream-vue? Open a PR to add it here (include a link + 1 screenshot/GIF). Ideal fits: AI/chat UIs, streaming docs, diff/code-review panes, or Markdown-driven pages with embedded Vue components.
444
452
 
445
453
  - **FlowNote** — streaming Markdown note app demo (SSE + virtual window) — https://markstream-vue.simonhe.me/
446
- - **AI Chat surface** — playground “test” page showing incremental batches + share links — https://markstream-vue.simonhe.me/test
454
+ - **Diagnostic Studio** — shareable repro links, render-mode switching, diff/thinking/stress samples, annotations, PDF export — https://markstream-vue.simonhe.me/test
455
+ - **1.0 Showcase guide** — launch-ready demo matrix for chat, long docs, code review, diagrams, custom components, and safe HTML — https://markstream-vue-docs.simonhe.me/guide/showcase
447
456
 
448
457
  ## 📺 Introduction Video
449
458
 
package/README.zh-CN.md CHANGED
@@ -74,6 +74,8 @@
74
74
  - Playground(交互演示): https://markstream-vue.simonhe.me/
75
75
  - 交互测试页(可分享链接,便于复现): https://markstream-vue.simonhe.me/test
76
76
  - 文档: https://markstream-vue-docs.simonhe.me/zh/guide/
77
+ - Showcase: https://markstream-vue-docs.simonhe.me/zh/guide/showcase
78
+ - 1.0 benchmark 报告:`pnpm benchmark:1.0`
77
79
  - AI/LLM 项目索引(中文): https://markstream-vue-docs.simonhe.me/llms.zh-CN
78
80
  - AI/LLM 项目索引(英文): https://markstream-vue-docs.simonhe.me/llms
79
81
  - 一键 StackBlitz 体验: https://stackblitz.com/github/Simon-He95/markstream-vue?file=playground/src/App.vue
@@ -81,23 +83,19 @@
81
83
  - Nuxt playground:`pnpm play:nuxt`
82
84
  - Discord: https://discord.gg/vkzdkjeRCW
83
85
 
84
- ## skills 和 prompts 的 CLI
86
+ ## 仓库内的 skills 和 prompts
85
87
 
86
- 如果你想直接拿到打包后的 AI 资产,而不是先克隆仓库:
88
+ 如果你想直接拿到 AI 资产,而不是先克隆仓库:
87
89
 
88
90
  ```bash
89
91
  npx skills add Simon-He95/markstream-vue
90
- npx markstream-vue skills list
91
- npx markstream-vue skills install
92
- npx markstream-vue prompts list
93
- npx markstream-vue prompts show install-markstream
94
92
  ```
95
93
 
96
94
  推荐这样理解:
97
95
 
98
96
  - `npx skills add Simon-He95/markstream-vue` 是最推荐的安装方式,因为它会直接读取 GitHub 仓库里的 `.agents/skills`
99
- - `skills install` 会把打包好的 skills 安装到你的 agent skills 目录,默认是 `~/.agents/skills`
100
- - `prompts list` / `prompts show` 用来发现并直接复制官方维护的 prompt 模板
97
+ - `markstream-vue@1.0` 不发布 CLI `bin`;`pnpm skills:list`、`pnpm prompts:list` 这类脚本只面向克隆仓库后的维护者
98
+ - prompts 继续保留在仓库的 `prompts/` 目录下,供直接复制或后续拆成独立包
101
99
 
102
100
  `npx skills add` 也支持这些来源:
103
101
 
@@ -1 +1 @@
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{c as T,_,x as $,y as R,a as A,z as j,d as I,A as W,B as U,C as q,h as V,D as G,E as J,F as X,f as Y,G 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-b7ce948c"]]);export{be 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,_,n as R,r as $,a as A,j,l as I,k as W,m as U,h as q,o as V,q as G,s as J,t as X}from"./exports.js";import{safeRaf as Y,safeCancelRaf as K}from"./utils/safeRaf.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(R(l.node.language)),Q=c(()=>$(_.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:()=>{}}),Re=()=>{},$e=()=>{},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:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5}),Ke=Object.freeze(u(a({},Ye),{enabled:!1,revealLineCount:0}));function Qe(e){var t;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const n=e;return u(a(a({},Ye),n),{enabled:null==(t=n.enabled)||t})}return a({},Ye)}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({},Ye):Qe(o.diffHideUnchangedRegions),r=void 0===o.hideUnchangedRegions?void 0:Qe(o.hideUnchangedRegions),d=!1!==l.stream&&!1!==l.loading,s=d?a({},Ke):i,c=d?a({},Ke):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&&(X()||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,Re=n.cleanupEditor||Re,$e=n.safeClean||n.cleanupEditor||$e,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=>{Y(()=>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 Rt(){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 $t=/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($t.test(t)||$t.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&&(K(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(),Y(()=>Vt())},s=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),t.click(),Y(()=>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=Y(()=>{Ce=null,Y(()=>{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=R(e)}),x(()=>[l.node.originalCode,l.node.updatedCode,Ge.value],()=>{Bt(),Y(()=>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&&Y(()=>jt())})),x(()=>l.node.code,e=>d(null,null,function*(){if(!1!==l.stream&&(_.value||(_.value=R(Ie(e))),!Ge.value)){if(He&&!be.value&&v.value)try{yield dn(v.value)}catch(t){}Ne(e,Q.value),ee.value&&Y(()=>jt())}}));const Yt=c(()=>{const e=_.value;return e?I[e]||e.charAt(0).toUpperCase()+e.slice(1):I[""]||"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(()=>(W.value,U(_.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";J(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,Y(()=>{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){$e();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(),Y(()=>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){}}(),Rt(),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||q()}),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(),$e(),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(){Rt()}})}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({},Ye):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(),Y(()=>{Rt(),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(),$e(),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(),Y(()=>{d(null,null,function*(){var e;try{if(i&&be.value)if(Ge.value&&v.value){const e=je;if(e)try{yield e}catch(t){}if(bn(),we.value=!1,ot.value=!1,be.value=!1,It(),Wt(),$e(),yield O(),yield dn(v.value),Se||!Ge.value)return;Ae(),qt(),Ht()}else Ne(String(null!=(e=l.node.code)?e:""),Q.value);Ut(!1)}catch(n){}})})}),{immediate:!0,flush:"post"}),f(()=>{It(),Wt(),Re()}),(t,n)=>lt.value?(m(),p(k(V),{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(G,{"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(V),{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-c1313629"]]);export{be as default};