markstream-vue 0.0.14-beta.5 → 0.0.14-beta.7

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.
@@ -16,7 +16,12 @@ Use this skill when the host app is Angular and the task is to adopt the Angular
16
16
  4. Prefer standalone Angular integration.
17
17
  - Use `MarkstreamAngularComponent` in `imports` and keep examples signal-friendly.
18
18
  5. Start with `[content]`.
19
- - Use `[final]`, `[codeBlockStream]`, and other streaming inputs only when the UI actually streams.
19
+ - For streaming AI chat, keep `[content]` and use built-in smooth streaming first.
20
+ - `[smoothStreaming]="'auto'"` is the default and activates when `[typewriter]="true"` or `[maxLiveNodes]="0"`.
21
+ - `[typewriter]` only controls the blinking cursor and defaults to `false`.
22
+ - `[fade]` controls node enter and streamed-text fade animations and defaults to `true`.
23
+ - Use `[final]` for end-of-stream state; final parsing is gated until visible content catches up when smooth streaming is active.
24
+ - Move to `nodes` + `final` only for worker-preparsed content, shared AST stores, or custom AST control.
20
25
  - Remember that `[htmlPolicy]` now defaults to `'safe'`, and Mermaid strict mode is on by default through `[mermaidProps]`.
21
26
  6. Use `[customHtmlTags]` and `[customComponents]` for trusted tag workflows.
22
27
  7. Validate with the smallest useful Angular dev or build command.
@@ -24,7 +29,7 @@ Use this skill when the host app is Angular and the task is to adopt the Angular
24
29
  ## Default Decisions
25
30
 
26
31
  - Standalone Angular first, NgModule-era patterns only when the repo still depends on them.
27
- - Treat streaming flags as opt-in.
32
+ - Treat the cursor as opt-in (`typewriter=false` by default), but keep fade animations enabled by default (`fade=true`).
28
33
  - Keep optional peers minimal and explicit.
29
34
  - Keep `[htmlPolicy]="'safe'"` and Mermaid strict mode unless the task is preserving trusted legacy rendering.
30
35
  - If a trusted surface needs broader old behavior, opt out locally with `[htmlPolicy]="'trusted'"` and `[mermaidProps]="{ isStrict: false }"`, and document that trust boundary.
@@ -24,6 +24,7 @@ Read [references/patterns.md](references/patterns.md) before choosing an overrid
24
24
  4. Preserve nested Markdown when needed.
25
25
  - For trusted custom tags with inner Markdown, render `node.content` with a nested renderer.
26
26
  - Pass the same custom-tag allowlist to nested renderers.
27
+ - Nested renderers inside a smooth-streaming parent are automatically suppressed from double pacing — do not add `smooth-streaming` to child renderers.
27
28
  5. Keep props and cleanup intact.
28
29
  - Preserve `node`, `loading`, `indexKey`, `customId`, and `isDark`.
29
30
  - For `mermaid` and `infographic` overrides, preserve `estimatedPreviewHeightPx` so async preview shells keep stable height during remounts.
@@ -25,7 +25,14 @@ Read [references/scenarios.md](references/scenarios.md) before making dependency
25
25
  - Import `katex/dist/katex.min.css` when math is enabled.
26
26
  4. Add the smallest working render example.
27
27
  - Use `content` for static or low-frequency rendering.
28
- - Use `nodes` plus `final` when the app receives streaming updates.
28
+ - For streaming AI chat, start with `content` and built-in smooth streaming.
29
+ - Auto mode is the default: `smoothStreaming="auto"` / `smooth-streaming="auto"`.
30
+ - Auto pacing activates when `typewriter=true` or `maxLiveNodes <= 0` / `max-live-nodes <= 0`.
31
+ - `typewriter` only controls the blinking cursor and defaults to `false`.
32
+ - `fade` controls node enter and streamed-text fade animations and defaults to `true`.
33
+ - For high-frequency smooth streams, consider `fade=false` / `:fade="false"` / `[fade]="false"` to avoid fade stacking.
34
+ - Use `nodes` + `final` only for worker preparsing, shared AST stores, or custom AST control.
35
+ - For manual pacing with `nodes`, use `useSmoothMarkdownStream`: `enqueue()` chunks, `finish()` when done, render from `visible`, wait for `caughtUp` before final parsing.
29
36
  - Preserve the default hardening: HTML policies now default to `safe`, and Mermaid runs in strict mode by default.
30
37
  5. Keep customization scoped.
31
38
  - If the task requires overrides, prefer `customId` / `custom-id` plus scoped `setCustomComponents(...)`.
@@ -36,7 +43,9 @@ Read [references/scenarios.md](references/scenarios.md) before making dependency
36
43
  ## Default Decisions
37
44
 
38
45
  - Prefer the minimal peer set over "install everything".
39
- - Prefer `content` unless the app is clearly SSE, chat, token-streaming, or worker-preparsed.
46
+ - Prefer `content` for most streaming chat now that built-in smooth streaming is available across Vue 3, Vue 2, React, Svelte, and Angular.
47
+ - Move to `nodes` only when another layer owns parsing or AST transforms.
48
+ - When using `content` for streaming, smooth streaming (`smooth-streaming="auto"`) is on by default for `typewriter` or `max-live-nodes <= 0`. Set `:smooth-streaming="false"` to preserve raw chunk cadence.
40
49
  - Treat CSS order as a first-class part of installation, not a later cleanup.
41
50
  - When the request includes SSR, explicitly gate browser-only peers behind client-only boundaries.
42
51
  - Do not widen HTML or Mermaid security defaults unless the user explicitly needs trusted legacy compatibility.
@@ -30,5 +30,10 @@
30
30
 
31
31
  ## Input choice
32
32
 
33
- - `content`: docs pages, static articles, low-frequency updates
34
- - `nodes` + `final`: SSE, token streaming, AI chat, worker-preparsed content
33
+ - `content`: docs pages, static articles, low-frequency updates, and most SSE / token streaming / AI chat surfaces.
34
+ - `content` + built-in smooth streaming: jittery AI streams where visible output should be paced independently from raw chunk cadence.
35
+ - `smoothStreaming="auto"` / `smooth-streaming="auto"` is the default.
36
+ - Auto mode enables pacing when `typewriter=true` or `maxLiveNodes <= 0` / `max-live-nodes <= 0`.
37
+ - `typewriter` only controls the blinking cursor and defaults to `false`.
38
+ - `fade` controls node enter and streamed-text fade animations and defaults to `true`.
39
+ - `nodes` + `final`: worker-preparsed content, shared AST stores, custom AST transforms, or cases where another layer already owns parsing.
@@ -29,8 +29,10 @@ Read [references/adoption-checklist.md](references/adoption-checklist.md) before
29
29
  5. Review gaps honestly.
30
30
  - Do not claim 1:1 parity where none exists.
31
31
  - Call out parser, plugin, security, or HTML behavior that still needs manual review.
32
- 6. Treat streaming as a second pass unless clearly required now.
33
- - Move to `nodes` only when the app receives streaming or high-frequency updates.
32
+ 6. Consider smooth streaming before jumping to `nodes`.
33
+ - If the app streams `content` and only needs pacing, `smooth-streaming="auto"` (the default) handles it without requiring `nodes`.
34
+ - Move to `nodes` only when the app needs custom AST control, worker preparsing, or high-frequency structural updates.
35
+ - When smooth streaming is on, pair it with `:fade="false"`.
34
36
  7. Validate and summarize.
35
37
  - Run the smallest relevant tests or build.
36
38
  - Report direct mappings, TODOs, and remaining verification work.
@@ -38,6 +40,7 @@ Read [references/adoption-checklist.md](references/adoption-checklist.md) before
38
40
  ## Default Decisions
39
41
 
40
42
  - Renderer swap first, streaming optimization second.
43
+ - Smooth streaming is an intermediate option between "just content" and "full nodes migration": it paces visible output without requiring AST control.
41
44
  - Preserve safety over feature parity when HTML or security rules are involved.
42
45
  - Prefer explicit TODOs over vague claims.
43
46
  - Recommend against migration when the current stack depends heavily on transforms that Markstream does not mirror directly.
@@ -47,6 +50,7 @@ Read [references/adoption-checklist.md](references/adoption-checklist.md) before
47
50
 
48
51
  - `docs/guide/react-markdown-migration.md`
49
52
  - `docs/guide/react-markdown-migration-cookbook.md`
53
+ - `docs/guide/ai-chat-streaming.md`
50
54
  - `docs/guide/installation.md`
51
55
  - `docs/guide/component-overrides.md`
52
56
  - `docs/guide/advanced.md`
@@ -14,13 +14,19 @@ Use this skill when the host app is Nuxt and SSR boundaries matter.
14
14
  3. Keep browser-only peers behind client-only boundaries.
15
15
  - Prefer `<client-only>` wrappers, `.client` plugins, or guarded setup paths.
16
16
  4. Import `markstream-vue/index.css` from a client-safe app shell or plugin.
17
- 5. Start with `content`, and move to `nodes` plus `final` only when the UI is streaming.
17
+ 5. Start with `content`, and move to `nodes` plus `final` only when the UI needs custom AST control.
18
+ - For streaming AI chat, use `typewriter` or `:max-live-nodes="0"` — smooth streaming (`smooth-streaming="auto"`) paces visible output automatically.
19
+ - `typewriter` only controls the blinking cursor and defaults to `false`.
20
+ - `fade` controls node enter and streamed-text fade animations and defaults to `true`.
21
+ - When smooth streaming is on, pair it with `:fade="false"` to avoid delta fade stacking with high-commit pacing.
22
+ - In SSR, avoid `smooth-streaming="true"` on first-screen content; the mounted gate inside `auto` prevents hydration mismatch.
18
23
  - Remember that `html-policy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaid-props`.
19
24
  6. Validate with the smallest relevant Nuxt dev, build, or typecheck command.
20
25
 
21
26
  ## Default Decisions
22
27
 
23
28
  - SSR safety comes before feature completeness.
29
+ - Smooth streaming is SSR-safe in `auto` mode (the default) because it gates on mount. Do not use `smooth-streaming="true"` for first-screen SSR content — it bypasses the mounted gate and can cause hydration mismatch or blank flash.
24
30
  - Avoid import-time access to browser globals from server code paths.
25
31
  - Treat Monaco, Mermaid workers, and similar heavy peers as client-only unless the repo already has a proven SSR pattern.
26
32
  - Keep `html-policy="safe"` and Mermaid strict mode unless the task is preserving trusted legacy rendering.
@@ -13,7 +13,11 @@ Use this skill when the host app is React or Next and the task is to wire Markst
13
13
  2. Install `markstream-react` plus only the requested optional peers.
14
14
  3. Import `markstream-react/index.css` from the app shell or client entry.
15
15
  4. Start with `content`.
16
- - Move to `nodes` plus `final` only when the UI receives streaming or high-frequency updates.
16
+ - For streaming or high-frequency AI output, keep `content` and use built-in smooth streaming first.
17
+ - `smoothStreaming="auto"` is the default and activates when `typewriter={true}` or `maxLiveNodes <= 0`.
18
+ - `typewriter` only controls the blinking cursor and defaults to `false`.
19
+ - `fade` controls node enter and streamed-text fade animations and defaults to `true`.
20
+ - Move to `nodes` + `final` only for worker-preparsed content, shared AST stores, or custom AST control.
17
21
  - Remember that `htmlPolicy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaidProps`.
18
22
  5. Respect SSR boundaries in Next.
19
23
  - Prefer `use client`, dynamic imports with `ssr: false`, or other client-only boundaries when browser-only peers are involved.
@@ -24,7 +28,10 @@ Use this skill when the host app is React or Next and the task is to wire Markst
24
28
 
25
29
  - Renderer wiring first, migration cleanup second.
26
30
  - If the repo already uses `react-markdown`, pair this skill with `markstream-migration`.
31
+ - Prefer `content` with built-in smooth streaming for most AI chat / token streaming surfaces.
32
+ - Move to `nodes` only when another layer owns parsing or AST transforms.
27
33
  - Prefer the smallest client-only boundary that solves the SSR issue.
34
+ - Avoid `smoothStreaming={true}` for first-screen SSR content unless intentionally starting from blank; auto mode uses the mounted gate.
28
35
  - Keep `htmlPolicy="safe"` and Mermaid strict mode unless the request is preserving trusted legacy rendering.
29
36
  - If a trusted surface needs older behavior, use `htmlPolicy="trusted"` and `mermaidProps={{ isStrict: false }}` only on that surface and explain why.
30
37
 
@@ -8,7 +8,12 @@ description: Integrate markstream-svelte in Svelte 5 apps. Svelte 4 unsupported.
8
8
  - Confirm Svelte 5; ask Svelte 4 users to upgrade.
9
9
  - Add package and only requested peers.
10
10
  - Import CSS after resets; KaTeX CSS for math.
11
- - Default to `<MarkdownRender {content} />`; use `nodes`+`final` for streaming/workers.
11
+ - Default to `<MarkdownRender {content} />`.
12
+ - For streaming AI chat, keep `content` and use built-in smooth streaming first.
13
+ - `smoothStreaming="auto"` is the default and activates when `typewriter={true}` or `maxLiveNodes <= 0`.
14
+ - `typewriter` only controls the blinking cursor and defaults to `false`.
15
+ - `fade` controls node enter and streamed-text fade animations and defaults to `true`.
16
+ - Use `nodes` + `final` for worker-preparsed content, shared AST stores, or custom AST control.
12
17
  - Use `$props()` and callbacks.
13
18
  - Workers: `setKaTeXWorker`, `setMermaidWorker`, `workers/*?worker`.
14
19
  - Custom UI: scoped `setCustomComponents`, `customId`, `customHtmlTags`.
@@ -14,7 +14,12 @@ Use this skill when the host app is plain Vue 3, typically Vite-based, and not N
14
14
  3. Import `markstream-vue/index.css` after resets.
15
15
  - In Tailwind or UnoCSS projects, keep Markstream styles inside `@layer components`.
16
16
  4. Start with `<MarkdownRender :content="markdown" />`.
17
- - Switch to `nodes` plus `final` only for streaming, SSE, or high-frequency updates.
17
+ - For AI chat or streaming UIs, use `typewriter` or `:max-live-nodes="0"` smooth streaming is auto-enabled (`smooth-streaming="auto"`, the default) and paces visible output so bursty chunks appear steadily.
18
+ - `typewriter` only controls the blinking cursor and defaults to `false`.
19
+ - `fade` controls node enter and streamed-text fade animations and defaults to `true`.
20
+ - Set `:smooth-streaming="false"` to preserve raw chunk cadence; set `:smooth-streaming="true"` to force smooth pacing even on first-screen content (may cause hydration mismatch in SSR).
21
+ - When smooth streaming is on, pair it with `:fade="false"` to avoid delta fade (280 ms) stacking with high-commit pacing.
22
+ - Switch to `nodes` plus `final` only when the app needs custom AST control, worker preparsing, or structural updates beyond pacing.
18
23
  - Remember that `html-policy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaid-props`.
19
24
  5. Use `custom-id` plus scoped `setCustomComponents(...)` for overrides.
20
25
  6. Validate with the smallest useful dev, build, or typecheck command.
@@ -22,6 +27,8 @@ Use this skill when the host app is plain Vue 3, typically Vite-based, and not N
22
27
  ## Default Decisions
23
28
 
24
29
  - Vue 3 apps default to `content`.
30
+ - Smooth streaming (`smooth-streaming="auto"`) is on by default when `typewriter` or `max-live-nodes <= 0`. It only paces the `content` path; `nodes` mode is never affected.
31
+ - For manual pacing with `nodes`, use `useSmoothMarkdownStream` directly: `enqueue()` chunks, `finish()` when done, render from `visible`, and wait for `caughtUp` before final parsing.
25
32
  - Prefer local component registration unless the repo already uses a shared plugin entry.
26
33
  - When Monaco code blocks need app-level preloading, import `preloadCodeBlockRuntime` from `markstream-vue`. Existing `getUseMonaco()` preloads remain valid; do not import `stream-monaco` directly just to warm workers.
27
34
  - Keep `html-policy="safe"` and Mermaid strict mode unless the task is explicitly preserving trusted legacy behavior.
@@ -33,4 +40,5 @@ Use this skill when the host app is plain Vue 3, typically Vite-based, and not N
33
40
  - `docs/guide/quick-start.md`
34
41
  - `docs/guide/installation.md`
35
42
  - `docs/guide/usage.md`
43
+ - `docs/guide/ai-chat-streaming.md`
36
44
  - `docs/guide/component-overrides.md`
@@ -14,6 +14,11 @@ Use this skill when the host app is Vue 2 and not specifically a Vue CLI / Webpa
14
14
  - Add `@vue/composition-api` only when the repo is Vue 2.6 and uses Composition API patterns.
15
15
  3. Import `markstream-vue2/index.css` after resets.
16
16
  4. Start with `<MarkdownRender :content="markdown" />`.
17
+ - For AI chat or streaming UIs, keep `content` and use built-in smooth streaming first.
18
+ - `smooth-streaming="auto"` is the default and activates when `typewriter=true` or `max-live-nodes <= 0`.
19
+ - `typewriter` only controls the blinking cursor and defaults to `false`.
20
+ - `fade` controls node enter and streamed-text fade animations and defaults to `true`.
21
+ - Move to `nodes` + `final` only for worker-preparsed content, shared AST stores, or custom AST control.
17
22
  - Remember that `html-policy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaid-props`.
18
23
  5. Use scoped custom component mappings when the task needs overrides or trusted tags.
19
24
  6. Validate with the smallest useful dev or build command.
@@ -16,6 +16,11 @@ Use this skill when the host app is Vue 2 on Vue CLI or another Webpack 4-style
16
16
  - Use `createKaTeXWorkerFromCDN(...)` and `createMermaidWorkerFromCDN(...)` when workers are needed.
17
17
  5. Prefer stable code block defaults over brittle Monaco wiring.
18
18
  - `MarkdownCodeBlockNode` plus `stream-markdown` is safer than Monaco in Webpack 4-era repos.
19
+ - For AI chat or streaming UIs, keep `content` and use built-in smooth streaming first.
20
+ - `smooth-streaming="auto"` is the default and activates when `typewriter=true` or `max-live-nodes <= 0`.
21
+ - `typewriter` only controls the blinking cursor and defaults to `false`.
22
+ - `fade` controls node enter and streamed-text fade animations and defaults to `true`.
23
+ - Move to `nodes` + `final` only for worker-preparsed content, shared AST stores, or custom AST control.
19
24
  - Remember that `html-policy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaid-props`.
20
25
  6. Validate with the smallest useful local dev or build command.
21
26
 
@@ -15,6 +15,11 @@ Use this skill when the host app is Vue 2 and the bundler is Vite.
15
15
  4. Use Vite worker imports when the repo needs bundled workers.
16
16
  - `markstream-vue2/workers/... ?worker` or `?worker&inline` patterns are allowed here.
17
17
  5. Keep Composition API decisions explicit for Vue 2.6 repos.
18
+ - For AI chat or streaming UIs, keep `content` and use built-in smooth streaming first.
19
+ - `smooth-streaming="auto"` is the default and activates when `typewriter=true` or `max-live-nodes <= 0`.
20
+ - `typewriter` only controls the blinking cursor and defaults to `false`.
21
+ - `fade` controls node enter and streamed-text fade animations and defaults to `true`.
22
+ - Move to `nodes` + `final` only for worker-preparsed content, shared AST stores, or custom AST control.
18
23
  - Remember that `html-policy` now defaults to `safe`, and Mermaid strict mode is on by default through `mermaid-props`.
19
24
  6. Validate with the smallest useful Vite dev or build command.
20
25
 
package/README.md CHANGED
@@ -258,36 +258,38 @@ Then use `<MarkdownRender :content="md" />` in your pages.
258
258
 
259
259
  ## ⏱️ Streaming in 30 seconds
260
260
 
261
- Render streamed Markdown (SSE/websocket) with incremental updates:
261
+ Render streamed Markdown (SSE/websocket) with built-in smooth pacing:
262
262
 
263
263
  ```ts
264
- import type { ParsedNode } from 'markstream-vue'
265
- import MarkdownRender, { getMarkdown, parseMarkdownToStructure } from 'markstream-vue'
264
+ import MarkdownRender from 'markstream-vue'
266
265
  import { ref } from 'vue'
267
266
 
268
- const nodes = ref<ParsedNode[]>([])
269
- const buffer = ref('')
270
- const md = getMarkdown()
267
+ const content = ref('')
268
+ const final = ref(false)
271
269
 
272
- function addChunk(chunk: string) {
273
- buffer.value += chunk
274
- nodes.value = parseMarkdownToStructure(buffer.value, md)
270
+ eventSource.onmessage = (event) => {
271
+ content.value += event.data
275
272
  }
276
-
277
- // e.g., inside your SSE/onmessage handler
278
- eventSource.onmessage = event => addChunk(event.data)
273
+ eventSource.addEventListener('done', () => {
274
+ final.value = true
275
+ })
279
276
 
280
277
  // template
281
278
  // <MarkdownRender
282
- // :nodes="nodes"
279
+ // :content="content"
280
+ // :final="final"
283
281
  // :max-live-nodes="0"
284
- // :batch-rendering="{
285
- // renderBatchSize: 16,
286
- // renderBatchDelay: 8,
287
- // }"
282
+ // :batch-rendering="true"
283
+ // :render-batch-size="16"
284
+ // :render-batch-delay="8"
285
+ // :render-batch-budget-ms="4"
286
+ // :fade="false"
287
+ // :typewriter="true"
288
288
  // />
289
289
  ```
290
290
 
291
+ `smooth-streaming` is enabled by default in typewriter/incremental mode (`typewriter` or `max-live-nodes <= 0`). Disable per surface with `:smooth-streaming="false"` if you want raw chunk cadence.
292
+
291
293
  Switch rendering style per surface:
292
294
 
293
295
  - Virtualized window (default): steady scrolling and memory usage for long docs.
@@ -332,7 +334,7 @@ const md = getMarkdown() // match server setup
332
334
 
333
335
  function addChunk(chunk: string) {
334
336
  buffer.value += chunk
335
- nodes.value = parseMarkdownToStructure(buffer.value, md)
337
+ nodes.value = parseMarkdownToStructure(buffer.value, md, { final: false })
336
338
  }
337
339
  ```
338
340
 
package/README.zh-CN.md CHANGED
@@ -259,36 +259,38 @@ export default defineNuxtPlugin((nuxtApp) => {
259
259
 
260
260
  ## ⏱️ 30 秒流式接入
261
261
 
262
- 用 SSE / WebSocket 增量渲染 Markdown:
262
+ 用 SSE / WebSocket 结合内置平滑节奏渲染 Markdown:
263
263
 
264
264
  ```ts
265
- import type { ParsedNode } from 'markstream-vue'
266
- import MarkdownRender, { getMarkdown, parseMarkdownToStructure } from 'markstream-vue'
265
+ import MarkdownRender from 'markstream-vue'
267
266
  import { ref } from 'vue'
268
267
 
269
- const nodes = ref<ParsedNode[]>([])
270
- const buffer = ref('')
271
- const md = getMarkdown()
268
+ const content = ref('')
269
+ const final = ref(false)
272
270
 
273
- function addChunk(chunk: string) {
274
- buffer.value += chunk
275
- nodes.value = parseMarkdownToStructure(buffer.value, md)
271
+ eventSource.onmessage = (event) => {
272
+ content.value += event.data
276
273
  }
277
-
278
- // 例如在 SSE / onmessage 处理器中
279
- eventSource.onmessage = event => addChunk(event.data)
274
+ eventSource.addEventListener('done', () => {
275
+ final.value = true
276
+ })
280
277
 
281
278
  // template
282
279
  // <MarkdownRender
283
- // :nodes="nodes"
280
+ // :content="content"
281
+ // :final="final"
284
282
  // :max-live-nodes="0"
285
- // :batch-rendering="{
286
- // renderBatchSize: 16,
287
- // renderBatchDelay: 8,
288
- // }"
283
+ // :batch-rendering="true"
284
+ // :render-batch-size="16"
285
+ // :render-batch-delay="8"
286
+ // :render-batch-budget-ms="4"
287
+ // :fade="false"
288
+ // :typewriter="true"
289
289
  // />
290
290
  ```
291
291
 
292
+ `smooth-streaming` 在打字机/增量模式(`typewriter` 或 `max-live-nodes <= 0`)默认开启;如果希望严格按原始 chunk 节奏显示,可按实例设置 `:smooth-streaming="false"`。
293
+
292
294
  按页面需要切换渲染风格:
293
295
 
294
296
  - 虚拟化窗口(默认):长文档滚动平稳、内存稳定。
@@ -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{b as T,_,w as $,x as R,u as A,y as j,c as I,z as W,A as U,B as q,h as V,C as G,D as J,E as X,f as Y,F as K}from"./exports.js";const Q={class:"html-preview-frame__header"},Z={class:"html-preview-frame__title"},ee={class:"html-preview-frame__label"},te=["sandbox","srcdoc"],ne=/* @__PURE__ */_(/* @__PURE__ */s({__name:"HtmlPreviewFrame",props:{code:{},isDark:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},onClose:{type:Function},title:{}},setup(e){const t=e,n=void 0!==import.meta&&Boolean(!1);let l=null;const{t:o}=T(),i=c(()=>{const e=t.code||"",n=e.trim().toLowerCase();return n.startsWith("<!doctype")||n.startsWith("<html")||n.startsWith("<body")?e:`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n background-color: ${t.isDark?"#020617":"#ffffff"};\n color: ${t.isDark?"#e5e7eb":"#020617"};\n }\n body {\n font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, sans-serif;\n }\n </style>\n </head>\n <body>\n ${e}\n </body>\n</html>`}),r=c(()=>{return e=t.htmlPreviewSandbox,o=t.htmlPreviewAllowScripts,"string"==typeof e?(function(e){if(!n||"undefined"==typeof console||l===e)return;const t=function(e){return new Set(e.trim().toLowerCase().split(/\s+/).filter(Boolean))}(e);t.has("allow-scripts")&&t.has("allow-same-origin")&&(l=e,console.warn("[markstream-vue] htmlPreviewSandbox contains both allow-scripts and allow-same-origin. Use this only for fully trusted content served from an isolated origin."))}(e),e):void 0!==e?"":!0===o?"allow-scripts":"";var e,o});function a(e){var n;"Escape"!==e.key&&"Esc"!==e.key||null==(n=t.onClose)||n.call(t)}return v(()=>{"undefined"!=typeof window&&window.addEventListener("keydown",a)}),f(()=>{"undefined"!=typeof window&&window.removeEventListener("keydown",a)}),(e,n)=>(m(),p(h,{to:"body"},[y("div",{class:g(["markstream-vue",{dark:t.isDark}])},[y("div",{class:"html-preview-frame__backdrop",onClick:n[2]||(n[2]=e=>{var n;return null==(n=t.onClose)?void 0:n.call(t)})},[y("div",{class:"html-preview-frame",onClick:n[1]||(n[1]=b(()=>{},["stop"]))},[y("div",Q,[y("div",Z,[n[3]||(n[3]=y("span",{class:"html-preview-frame__dot"},null,-1)),y("span",ee,w(t.title||k(o)("common.preview")||"Preview"),1)]),y("button",{type:"button",class:"html-preview-frame__close",onClick:n[0]||(n[0]=e=>{var n;return null==(n=t.onClose)?void 0:n.call(t)})}," × ")]),y("iframe",{class:"html-preview-frame__iframe",sandbox:r.value,referrerpolicy:"no-referrer",srcdoc:i.value},null,8,te)])])],2)]))}}),[["__scopeId","data-v-24e66176"]]);let le=null,oe=null,ie=null,re=null,ae=null,ue=null;const de=/* @__PURE__ */new WeakMap;let se=0;const ce=["data-markstream-enhanced"],ve={class:"code-header-main"},fe=["innerHTML"],me={class:"code-header-copy"},pe={class:"code-header-title"},he={key:0,class:"code-header-caption"},ye={class:"code-editor-layer"},ge="__markstreamMonacoPassiveTouchState__",be=/* @__PURE__ */_(/* @__PURE__ */s({__name:"CodeBlockNode",props:{node:{},isDark:{type:Boolean,default:!1},loading:{type:Boolean,default:!0},stream:{type:Boolean,default:!0},theme:{},darkTheme:{default:"vitesse-dark"},lightTheme:{default:"vitesse-light"},isShowPreview:{type:Boolean,default:!0},monacoOptions:{},enableFontSizeControl:{type:Boolean,default:!0},minWidth:{default:void 0},maxWidth:{default:void 0},themes:{},showHeader:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExpandButton:{type:Boolean,default:!0},showPreviewButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showFontSizeButtons:{type:Boolean,default:!0},showTooltips:{type:Boolean},htmlPreviewAllowScripts:{type:Boolean},htmlPreviewSandbox:{},customId:{},estimatedHeightPx:{},estimatedContentHeightPx:{}},emits:["previewCode","copy"],setup(e,{emit:t}){var n;const l=e,o=t;const i=S(),r=c(()=>{const e=null==i?void 0:i.vnode.props;return!(!e||!e.onPreviewCode&&!e.onPreviewCode)}),{t:s}=T(),v=C(null),h=C(null),b=C(!1),_=C($(l.node.language)),Q=c(()=>R(_.value)),Z=c(()=>"plaintext"===Q.value),ee=C(!1),te=C(!1),be=C(!1),we=C(!1),ke=C(!1);let Se=!1,Ce=null;const xe=C(null),Pe=C(null);let Oe=0,Me=0;const Ee=A(),Le=C(null),Be=C("undefined"==typeof window);"undefined"!=typeof window&&x(()=>h.value,e=>{var t;if(null==(t=Le.value)||t.destroy(),Le.value=null,!e)return void(Be.value=!1);const n=Ee(e,{rootMargin:"400px"});Le.value=n,Be.value=n.isVisible.value,n.whenVisible.then(()=>{Be.value=!0})},{immediate:!0}),P(()=>{var e;Se=!0,null==(e=Le.value)||e.destroy(),Le.value=null});let He=null,ze=null,Ne=()=>{},Fe=()=>{},De=()=>null,Te=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),_e=()=>({getModel:()=>({getLineCount:()=>1}),getOption:()=>14,updateOptions:()=>{}}),$e=()=>{},Re=()=>{},Ae=()=>{},je=null,Ie=()=>{var e;return String(null!=(e=l.node.language)?e:"plaintext")},We=()=>d(null,null,function*(){});const Ue=[],qe=[];let Ve=null;const Ge=c(()=>l.node.diff),Je=C({removed:0,added:0}),Xe=c(()=>`-${Je.value.removed} +${Je.value.added}`),Ye=Object.freeze({enabled:!1}),Ke=Object.freeze({enabled:!0,contextLineCount:2,minimumLineCount:4,revealLineCount:5});function Qe(e){var t;if("boolean"==typeof e)return e;if(e&&"object"==typeof e){const n=e;return u(a(a({},Ke),n),{enabled:null==(t=n.enabled)||t})}return a({},Ke)}function Ze(e,t){return{original:String(null!=e?e:""),updated:String(null!=t?t:"")}}const et=c(()=>{var e,t,n;const o=l.monacoOptions?a({},l.monacoOptions):{};if(!Ge.value)return o;const i=void 0===o.diffHideUnchangedRegions?a({},Ke):Qe(o.diffHideUnchangedRegions),r=void 0===o.hideUnchangedRegions?void 0:Qe(o.hideUnchangedRegions),d=!1!==l.stream&&!1!==l.loading,s=d?a({},Ye):i,c=d?a({},Ye):r,v=a({},null!=(e=o.experimental)?e:{}),f=null!=(t=o.diffUnchangedRegionStyle)?t:"line-info",m={maxComputationTime:0,diffAlgorithm:"legacy",ignoreTrimWhitespace:!1,renderIndicators:!0,diffUpdateThrottleMs:120,renderLineHighlight:"none",renderLineHighlightOnlyWhenFocus:!0,selectionHighlight:!1,occurrencesHighlight:"off",matchBrackets:"never",lineDecorationsWidth:4,lineNumbersMinChars:2,glyphMargin:!1,renderOverviewRuler:!1,overviewRulerBorder:!1,hideCursorInOverviewRuler:!0,scrollBeyondLastLine:!1,diffHideUnchangedRegions:s,useInlineViewWhenSpaceIsLimited:null!=(n=o.useInlineViewWhenSpaceIsLimited)&&n,diffLineStyle:"background",diffAppearance:"auto",diffUnchangedRegionStyle:f,diffHunkActionsOnHover:!1,experimental:v};return u(a(u(a(a({},m),o),{experimental:v}),void 0===c?{}:{hideUnchangedRegions:c}),{diffHideUnchangedRegions:s})}),tt=c(()=>Ge.value?"diff":"single"),nt=C(tt.value),lt=C(!1),ot=C(!1),it=C(!1),rt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.wordWrap;return null==t||"off"!==String(t)}),at=c(()=>!(lt.value||!it.value&&(K()||ot.value))),ut=C(!1);"undefined"!=typeof window&&d(null,null,function*(){try{const e=yield j();if(Se)return;if(!e)return void(lt.value=!0);const t=e.useMonaco,n=e.detectLanguage;if("function"==typeof n&&(Ie=n),"function"==typeof t){const e=mn();if(e&&l.themes&&Array.isArray(l.themes)&&!l.themes.includes(e))throw new Error("Preferred theme not in provided themes array");Ve=gn();const n=t(Ve);He=n.createEditor||He,ze=n.createDiffEditor||ze,Ne=n.updateCode||Ne,Fe=n.updateDiff||Fe,De=n.getEditor||De,Te=n.getEditorView||Te,_e=n.getDiffEditorView||_e,$e=n.cleanupEditor||$e,Re=n.safeClean||n.cleanupEditor||Re,Ae=n.refreshDiffPresentation||Ae,We=n.setTheme||We,ke.value=!0,!Se&&v.value&&(yield dn(v.value))}}catch(e){if(Se)return;lt.value=!0}});const dt=C("number"==typeof(null==(n=l.monacoOptions)?void 0:n.fontSize)?l.monacoOptions.fontSize:Number.NaN),st=C(dt.value),ct=c(()=>{const e=dt.value,t=st.value;return"number"==typeof e&&Number.isFinite(e)&&e>0&&"number"==typeof t&&Number.isFinite(t)&&t>0}),vt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.fontSize;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const n=st.value;return"number"==typeof n&&Number.isFinite(n)&&n>0?n:14}),ft=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.lineHeight;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:Math.max(12,Math.round(1.35*vt.value))}),mt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.tabSize;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:4}),pt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.padding;return{top:"number"==typeof(null==t?void 0:t.top)&&Number.isFinite(t.top)&&t.top>0?t.top:0,bottom:"number"==typeof(null==t?void 0:t.bottom)&&Number.isFinite(t.bottom)&&t.bottom>0?t.bottom:0}}),ht=c(()=>{const e=l.estimatedContentHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),yt=c(()=>{const e=l.estimatedHeightPx;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:null}),gt=c(()=>{var e;const t=null==(e=l.monacoOptions)?void 0:e.fontFamily;return a(a({fontSize:`${vt.value}px`,lineHeight:`${ft.value}px`,tabSize:mt.value,boxSizing:"border-box",maxHeight:`${Jt()}px`,overflow:"auto",paddingTop:`${pt.value.top}px`,paddingBottom:`${pt.value.bottom}px`},null!=ht.value?{height:`${ht.value}px`,minHeight:`${ht.value}px`}:{}),"string"==typeof t&&t.trim()?{"--markstream-code-font-family":t.trim()}:{})}),bt=c(()=>null!=ht.value&&(!ot.value||null!=St())),wt=c(()=>{if(bt.value)return{minHeight:`${ht.value}px`}}),kt=C(null);function St(){const e=kt.value;return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):null}function Ct(e,t=!1){const n=Math.ceil(e),l=St();return null==l?n:n>=l?(t&&we.value&&(kt.value=null),n):l}function xt(){return new Promise(e=>{I(()=>e())})}function Pt(){var e,t,n,l,o;try{const i=Ge.value?null!=(n=null==(t=null==(e=_e())?void 0:e.getModifiedEditor)?void 0:t.call(e))?n:_e():Te(),r=De(),a=null==(l=null==r?void 0:r.EditorOption)?void 0:l.fontInfo;if(i&&null!=a){const e=null==(o=i.getOption)?void 0:o.call(i,a),t=null==e?void 0:e.fontSize;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t}}catch(i){}try{const e=v.value;if(e){const t=e.querySelector(".view-lines .view-line");if(t)try{if("undefined"!=typeof window&&"function"==typeof window.getComputedStyle){const e=window.getComputedStyle(t).fontSize,n=e&&e.match(/^(\d+(?:\.\d+)?)/);if(n)return Number.parseFloat(n[1])}}catch(i){}}}catch(i){}return null}function Ot(e){var t,n;try{const l=De(),o=null==(t=null==l?void 0:l.EditorOption)?void 0:t.lineHeight;if(null!=o){const t=null==(n=null==e?void 0:e.getOption)?void 0:n.call(e,o);if("number"==typeof t&&t>0)return t}}catch(i){}const l=function(){try{const e=v.value;if(!e)return null;const t=e.querySelector(".view-lines .view-line");if(t){const e=Math.ceil(t.getBoundingClientRect().height);if(e>0)return e}}catch(i){}return null}();if(l&&l>0)return l;const o=Number.isFinite(st.value)&&st.value>0?st.value:14;return Math.max(12,Math.round(1.35*o))}function Mt(e){var t,n,l;try{const l=De(),o=null==(t=null==l?void 0:l.EditorOption)?void 0:t.padding;if(null!=o){const t=null==(n=null==e?void 0:e.getOption)?void 0:n.call(e,o),l="number"==typeof(null==t?void 0:t.top)?t.top:0,i="number"==typeof(null==t?void 0:t.bottom)?t.bottom:0;if(l>0||i>0)return l+i}}catch(a){}const o=null==(l=et.value)?void 0:l.padding,i="number"==typeof(null==o?void 0:o.top)?o.top:0,r="number"==typeof(null==o?void 0:o.bottom)?o.bottom:0;return i>0||r>0?i+r:Ge.value?24:0}function Et(e,t){return"number"!=typeof e||"number"!=typeof t||e<1||t<e?0:t-e+1}function Lt(e){if(!e)return[];const t=e.split(/\r?\n/);return 1===t.length&&""===t[0]?[]:t}function Bt(){var e,t;Ge.value?Je.value=function(e,t){const n=Lt(e),l=Lt(t);let o=0,i=n.length-1,r=l.length-1;for(;o<=i&&o<=r&&n[o]===l[o];)o++;for(;i>=o&&r>=o&&n[i]===l[r];)i--,r--;return{removed:Math.max(0,i-o+1),added:Math.max(0,r-o+1)}}(String(null!=(e=l.node.originalCode)?e:""),String(null!=(t=l.node.updatedCode)?t:"")):Je.value={removed:0,added:0}}function Ht(){var e;if(Ge.value)try{const t=_e(),n=null==(e=null==t?void 0:t.getLineChanges)?void 0:e.call(t);if(!Array.isArray(n))return void Bt();let l=0,o=0;for(const e of n)l+=Et(e.originalStartLineNumber,e.originalEndLineNumber),o+=Et(e.modifiedStartLineNumber,e.modifiedEndLineNumber);Je.value={removed:l,added:o}}catch(t){Bt()}else Je.value={removed:0,added:0}}function zt(){var e;if(Number.isFinite(st.value)&&st.value>0&&Number.isFinite(dt.value))return st.value;const t=Pt();return"number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?(dt.value=l.monacoOptions.fontSize,st.value=l.monacoOptions.fontSize,st.value):t&&t>0?(dt.value=t,st.value=t,t):(dt.value=12,st.value=12,12)}function Nt(){const e=zt(),t=Math.min(36,e+1);st.value=t}function Ft(){const e=zt(),t=Math.max(10,e-1);st.value=t}function Dt(){zt(),Number.isFinite(dt.value)&&(st.value=dt.value)}function Tt(){var e,t,n,l,o,i,r,a,u,d,s,c,v,f;try{const m=Ge.value?_e():null,p=Ge.value?m:Te();if(!p)return null;if((null==m?void 0:m.getOriginalEditor)&&(null==m?void 0:m.getModifiedEditor)){const v=null==(e=m.getOriginalEditor)?void 0:e.call(m),f=null==(t=m.getModifiedEditor)?void 0:t.call(m);null==(n=null==v?void 0:v.layout)||n.call(v),null==(l=null==f?void 0:f.layout)||l.call(f);const p=(null==(o=null==v?void 0:v.getContentHeight)?void 0:o.call(v))||0,h=(null==(i=null==f?void 0:f.getContentHeight)?void 0:i.call(f))||0,y=Math.max(p,h);if(y>0)return Math.ceil(y+1);const g=(null==(u=null==(a=null==(r=null==v?void 0:v.getModel)?void 0:r.call(v))?void 0:a.getLineCount)?void 0:u.call(a))||1,b=(null==(c=null==(s=null==(d=null==f?void 0:f.getModel)?void 0:d.call(f))?void 0:s.getLineCount)?void 0:c.call(s))||1,w=Math.max(g,b),k=Math.max(Ot(v),Ot(f));return Math.ceil(w*(k+1.5)+0+1)}if(null==p?void 0:p.getContentHeight){null==(v=null==p?void 0:p.layout)||v.call(p);const e=p.getContentHeight();if(e>0)return Math.ceil(e+1)}const h=null==(f=null==p?void 0:p.getModel)?void 0:f.call(p);let y=1;h&&"function"==typeof h.getLineCount&&(y=h.getLineCount());const g=Ot(p);return Math.ceil(y*(g+1.5)+0+1)}catch(m){return null}}function _t(e){var t;const n=String(null!=e?e:"").trim(),l=null==(t=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?void 0:t[1];if(l){const e=3===l.length?l.split("").map(e=>`${e}${e}`).join(""):l;return.2126*Number.parseInt(e.slice(0,2),16)+.7152*Number.parseInt(e.slice(2,4),16)+.0722*Number.parseInt(e.slice(4,6),16)}const o=n.match(/\d+(?:\.\d+)?/g);if(!o||o.length<3)return null;const[i,r,a]=o.slice(0,3).map(Number);return.2126*i+.7152*r+.0722*a}function $t(){var e,t,n,l,o,i,r,a;const u=v.value,d=h.value;if(!u||!d)return;const s=u,c=u.querySelector(".monaco-editor")||u,f=c.querySelector(".monaco-editor-background")||c,m=c.querySelector(".view-lines")||c;let p=null,y=null,g=null;try{"undefined"!=typeof window&&"function"==typeof window.getComputedStyle&&(p=window.getComputedStyle(c),y=f===c?p:window.getComputedStyle(f),g=m===c?p:window.getComputedStyle(m))}catch(x){p=null,y=null,g=null}const b=String(null!=(e=null==p?void 0:p.getPropertyValue("--vscode-editor-foreground"))?e:"").trim(),w=String(null!=(t=null==p?void 0:p.getPropertyValue("--vscode-editor-background"))?t:"").trim(),k=String(null!=(l=null!=(n=null==p?void 0:p.getPropertyValue("--vscode-editor-selectionBackground"))?n:null==p?void 0:p.getPropertyValue("--vscode-editor-hoverHighlightBackground"))?l:"").trim(),S=b||String(null!=(i=null!=(o=null==g?void 0:g.color)?o:null==p?void 0:p.color)?i:"").trim(),C=w||String(null!=(a=null!=(r=null==y?void 0:y.backgroundColor)?r:null==p?void 0:p.backgroundColor)?a:"").trim();return Ge.value?(S?(d.style.setProperty("--markstream-diff-editor-fg",S),s.style.setProperty("--vscode-editor-foreground",S),s.style.setProperty("--stream-monaco-editor-fg",S)):(d.style.removeProperty("--markstream-diff-editor-fg"),s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--stream-monaco-editor-fg")),C?(d.style.setProperty("--markstream-diff-editor-bg",C),d.style.setProperty("--markstream-diff-panel-bg",C),d.style.setProperty("--markstream-diff-panel-bg-soft",C),d.style.setProperty("--markstream-diff-panel-bg-strong",C),s.style.setProperty("--vscode-editor-background",C),s.style.setProperty("--stream-monaco-editor-bg",C),s.style.setProperty("--stream-monaco-fixed-editor-bg",C),s.style.setProperty("--stream-monaco-panel-bg",C),s.style.setProperty("--stream-monaco-panel-bg-soft",C),s.style.setProperty("--stream-monaco-panel-bg-strong",C),s.style.backgroundColor=C):(d.style.removeProperty("--markstream-diff-editor-bg"),d.style.removeProperty("--markstream-diff-panel-bg"),d.style.removeProperty("--markstream-diff-panel-bg-soft"),d.style.removeProperty("--markstream-diff-panel-bg-strong"),s.style.removeProperty("--vscode-editor-background"),s.style.removeProperty("--stream-monaco-editor-bg"),s.style.removeProperty("--stream-monaco-fixed-editor-bg"),s.style.removeProperty("--stream-monaco-panel-bg"),s.style.removeProperty("--stream-monaco-panel-bg-soft"),s.style.removeProperty("--stream-monaco-panel-bg-strong"),s.style.backgroundColor=""),void(k?s.style.setProperty("--vscode-editor-selectionBackground",k):s.style.removeProperty("--vscode-editor-selectionBackground"))):function(e,t,n){if(!Z.value)return!1;const l=_t(e),o=_t(t);return n?null!=l&&l>170||null!=o&&o<110:null!=l&&l<85||null!=o&&o>190}(C,S,d.classList.contains("is-dark"))?(s.style.removeProperty("--vscode-editor-foreground"),s.style.removeProperty("--vscode-editor-background"),void s.style.removeProperty("--vscode-editor-selectionBackground")):(S&&s.style.setProperty("--vscode-editor-foreground",S),C&&s.style.setProperty("--vscode-editor-background",C),void(k&&s.style.setProperty("--vscode-editor-selectionBackground",k)))}const Rt=/auto|scroll|overlay/i;function At(e,t,n){var l;if("undefined"==typeof window)return;if(Ge.value)return;const o=Math.ceil(t),i=Math.ceil(n)-o;if(!i)return;const r=function(e){var t,n;if("undefined"==typeof window)return null;const l=null!=(t=null==e?void 0:e.ownerDocument)?t:document,o=l.scrollingElement||l.documentElement||l.body;let i=null!=(n=null==e?void 0:e.parentElement)?n:null;for(;i&&i!==l.body&&i!==o;){const e=window.getComputedStyle(i),t=(e.overflowY||"").toLowerCase(),n=(e.overflow||"").toLowerCase();if(Rt.test(t)||Rt.test(n))return i;i=i.parentElement}return o}(e);if(!r)return;const a=null!=(l=e.ownerDocument)?l:document,u=r===a.body||r===a.documentElement||r===a.scrollingElement,d=u?0:r.getBoundingClientRect().top;e.getBoundingClientRect().top-d>=0||(u&&"function"==typeof window.scrollBy?window.scrollBy(0,i):r.scrollTop+=i)}function jt(){try{const e=v.value;if(!e)return;const t=e.getBoundingClientRect().height,n=Tt();if(null!=n&&n>0){const l=Ct(n,!0),o=St();return e.style.minHeight=null!=o?`${o}px`:"0px",e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",void At(e,t,l)}const l=St();null!=l&&(e.style.minHeight=`${l}px`,e.style.height=`${l}px`,e.style.maxHeight="none",e.style.overflow="visible",At(e,t,l))}catch(e){}}function It(){for(var e,t;Ue.length>0;)try{null==(t=null==(e=Ue.pop())?void 0:e.dispose)||t.call(e)}catch(n){}null!=Ce&&(X(Ce),Ce=null)}function Wt(){for(var e;qe.length>0;)try{null==(e=qe.pop())||e()}catch(t){}}function Ut(e=!1){te.value||(ee.value?jt():function(){var e;try{const t=v.value;if(!t)return;const n=t.getBoundingClientRect().height,l=Jt(),o=Math.ceil((null==(e=t.getBoundingClientRect)?void 0:e.call(t).height)||0),i=Ge.value?function(){var e,t,n,l,o,i,r,a;try{const u=_e(),d=null==(e=null==u?void 0:u.getOriginalEditor)?void 0:e.call(u),s=null==(t=null==u?void 0:u.getModifiedEditor)?void 0:t.call(u);if(!d||!s)return null;const c=(null==(o=null==(l=null==(n=d.getModel)?void 0:n.call(d))?void 0:l.getLineCount)?void 0:o.call(l))||1,v=(null==(a=null==(r=null==(i=s.getModel)?void 0:i.call(s))?void 0:r.getLineCount)?void 0:a.call(r))||1,f=Math.max(c,v),m=Math.max(Ot(d),Ot(s)),p=Math.max(Mt(d),Mt(s));return Math.ceil(f*(m+1.5)+p+0+1)}catch(u){return null}}():null,r=Ge.value&&function(e){if("undefined"==typeof window)return!1;const t=e.querySelectorAll(".editor.modified .diff-hidden-lines .center, .stream-monaco-diff-unchanged-bridge");for(const n of Array.from(t)){if(!(n instanceof HTMLElement))continue;const e=window.getComputedStyle(n);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const t=n.getBoundingClientRect();if(!(t.width<=0||t.height<=0))return!0}return!1}(t);if(r||(Pe.value=null),Me>0&&(Me--,null!=xe.value))return void At(t,n,Gt(t,xe.value,l));const a=Ge.value?function(e){var t,n;if("undefined"==typeof window)return null;try{const l=e.getBoundingClientRect();if(l.height<=0)return null;const o=[".editor.original .view-lines .view-line",".editor.modified .view-lines .view-line",".editor.original .view-zones > div",".editor.modified .view-zones > div",".editor.original .margin-view-zones > div",".editor.modified .margin-view-zones > div",".editor.original .diff-hidden-lines",".editor.modified .diff-hidden-lines",".stream-monaco-diff-unchanged-bridge"];let i=0;for(const t of Array.from(e.querySelectorAll(o.join(",")))){if(!(t instanceof HTMLElement))continue;const e=window.getComputedStyle(t);if("none"===e.display||"hidden"===e.visibility)continue;if(Number.parseFloat(e.opacity||"1")<=.01)continue;const n=t.getBoundingClientRect();n.height<=0||n.bottom<=l.top||(i=Math.max(i,n.bottom-l.top))}if(i>0)return Math.ceil(i+1);const r=e.querySelector(".monaco-diff-editor"),a=null!=(n=null==(t=null==r?void 0:r.getBoundingClientRect)?void 0:t.call(r).height)?n:0;return a>0?Math.ceil(a+1):null}catch(l){return null}}(t):null,u=Ge.value?r?a:Math.max(null!=a?a:0,null!=i?i:0)||null:Tt();if(null!=u&&u>0){const e=null!=Pe.value&&Date.now()<Oe&&u>=l-1,i=r&&o>0&&o<l-1&&u>=l-1,a=Gt(t,e?Pe.value:i?o:u,l,{clearEstimatedFloor:!0});return r&&a<l-1&&(Pe.value=a,Oe=Date.now()+160),void At(t,n,a)}if(null!=xe.value)return void At(t,n,Gt(t,xe.value,l));const d=r?o:Math.max(o,null!=i&&i>0?i:0);if(d>0){const e=null!=Pe.value&&Date.now()<Oe&&d>=l-1,i=r&&o>0&&o<l-1&&d>=l-1,a=Gt(t,e?Pe.value:i?o:d,l);return r&&a<l-1&&(Pe.value=a,Oe=Date.now()+160),void At(t,n,a)}const s=St();if(null!=s)return void At(t,n,Gt(t,s,l));const c=Number.parseFloat(t.style.height);!Number.isNaN(c)&&c>0?At(t,n,Gt(t,c,l)):Ge.value||At(t,n,Gt(t,l,l))}catch(t){}}())}function qt(){if(!Ge.value)return void Wt();const e=v.value;if(!e)return void Wt();const t=e.querySelector(".monaco-diff-editor");if(!t||t.classList.contains("side-by-side"))return void Wt();const n=Array.from(t.querySelectorAll(".editor.original .diff-hidden-lines")),l=Array.from(t.querySelectorAll(".editor.modified .diff-hidden-lines")),o=Math.min(n.length,l.length);for(let i=0;i<o;i++){const e=l[i],t=e.querySelector("a"),n=e.querySelector(".center > div:first-child"),o=e.querySelector(".center");if(!t||!n||!o)continue;if(o.querySelector(".markstream-inline-fold-proxy"))continue;const r=document.createElement("button");r.type="button",r.className="markstream-inline-fold-proxy",r.dataset.markstreamInlineFoldProxy="true";const a=t.getAttribute("title")||"Show Unchanged Region";r.title=a,r.setAttribute("aria-label",a);const u=e=>{e.preventDefault(),e.stopPropagation()},d=e=>{e.preventDefault(),e.stopPropagation(),t.click(),I(()=>Vt())},s=e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),t.click(),I(()=>Vt()))};r.addEventListener("mousedown",u),r.addEventListener("click",d),r.addEventListener("keydown",s),o.appendChild(r),qe.push(()=>{r.removeEventListener("mousedown",u),r.removeEventListener("click",d),r.removeEventListener("keydown",s),r.parentElement===o&&o.removeChild(r)})}}function Vt(e=!1){null==Ce&&(Ce=I(()=>{Ce=null,I(()=>{qt(),Ut(e)})}))}function Gt(e,t,n,l={}){const o=Ct(Math.min(t,n),!0===l.clearEstimatedFloor),i=St();if(e.style.minHeight=null!=i?`${Math.min(i,Math.ceil(n))}px`:"0px",e.style.height=`${o}px`,e.style.maxHeight=`${Math.ceil(n)}px`,Ge.value)e.style.overflow="hidden";else{const l=t>n+1;e.style.overflow=l?"auto":"hidden"}return o}function Jt(){var e,t;const n=null!=(t=null==(e=l.monacoOptions)?void 0:e.MAX_HEIGHT)?t:500;if("number"==typeof n)return n;const o=String(n).match(/^(\d+(?:\.\d+)?)/);return o?Number.parseFloat(o[1]):500}const Xt=c(()=>l.isShowPreview&&("html"===_.value||"svg"===_.value));x(()=>l.node.language,e=>{_.value=$(e)}),x(()=>[l.node.originalCode,l.node.updatedCode,Ge.value],()=>{Bt(),I(()=>Ht())},{immediate:!0}),x(()=>[l.node.originalCode,l.node.updatedCode,Q.value,Ge.value],e=>d(null,[e],function*([e,t,n,o]){if(!1===l.stream||!o)return;if(He&&!be.value&&v.value)try{yield dn(v.value)}catch(a){}const i=Ze(String(null!=e?e:""),String(null!=t?t:"")),r=!1===l.loading;if(r&&bn(),yield Fe(i.original,i.updated,Q.value),r){if(Se||!Ge.value)return;Ae(),qt(),Ht(),Vt()}ee.value&&I(()=>jt())})),x(()=>l.node.code,e=>d(null,null,function*(){if(!1!==l.stream&&(_.value||(_.value=$(Ie(e))),!Ge.value)){if(He&&!be.value&&v.value)try{yield dn(v.value)}catch(t){}Ne(e,Q.value),ee.value&&I(()=>jt())}}));const Yt=c(()=>{const e=_.value;return e?W[e]||e.charAt(0).toUpperCase()+e.slice(1):W[""]||"Plain Text"});const Kt=c(()=>{var e;return function(e){const t=function(e){var t,n;const l=null!=(n=null==(t=String(null!=e?e:"").split(/\r?\n/,1)[0])?void 0:t.trim())?n:"";if(l.length<3)return"";const o=l[0];if("`"!==o&&"~"!==o||l[1]!==o||l[2]!==o)return"";let i=3;for(;l[i]===o;)i+=1;return l.slice(i).trim()}(e);if(!t)return"";const n=t.split(/\s+/).filter(Boolean);if(!n.length)return"";const l="diff"===n[0]?n.slice(1):n;for(const o of l){const e=o.includes(":")?o.slice(o.indexOf(":")+1):o;if(e&&/[./\\-]/.test(e))return e}return""}(String(null!=(e=l.node.raw)?e:""))}),Qt=c(()=>Kt.value||Yt.value),Zt=c(()=>Kt.value?Ge.value?`Diff / ${Yt.value}`:Yt.value:""),en=c(()=>(U.value,q(_.value||""))),tn=c(()=>{var e;const t={},n=e=>{if(null!=e)return"number"==typeof e?`${e}px`:String(e)},o=n(l.minWidth),i=n(l.maxWidth);return o&&(t.minWidth=o),i&&(t.maxWidth=i),bt.value&&(t.minHeight=`${null!=(e=yt.value)?e:ht.value}px`),Ge.value||(t.color="var(--vscode-editor-foreground, var(--markstream-code-fallback-fg))",t.backgroundColor="var(--vscode-editor-background, var(--markstream-code-fallback-bg))",t.borderColor="var(--markstream-code-border-color)"),t}),nn=c(()=>!1!==l.showTooltips);function ln(){return d(this,null,function*(){try{"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(l.node.code)),b.value=!0,o("copy",l.node.code),setTimeout(()=>{b.value=!1},1e3)}catch(e){console.error("复制失败:",e)}})}function on(e){if(ee.value=!ee.value,e&&nn.value){const t=function(e){const t=e.currentTarget||e.target;return!t||t.disabled?null:t}(e);if(t){const e=ee.value?s("common.collapse")||"Collapse":s("common.expand")||"Expand";Y(t,e,"top",!1,void 0,l.isDark)}}const t=Ge.value?_e():Te(),n=v.value;t&&n&&(ee.value?(un(!0),n.style.maxHeight="none",n.style.overflow="visible",Ut(!0)):(un(!1),n.style.overflow=Ge.value?"hidden":"auto",Ut(!0)))}function rn(){var e,t,n;if(te.value=!te.value,te.value){if(v.value){const n=Math.ceil((null==(t=(e=v.value).getBoundingClientRect)?void 0:t.call(e).height)||0);n>0&&(xe.value=n)}un(!1)}else{ee.value&&un(!0),v.value&&null!=xe.value&&(v.value.style.height=`${xe.value}px`);const e=Ge.value?_e():Te();try{null==(n=null==e?void 0:e.layout)||n.call(e)}catch(l){}Me=2,I(()=>{Ut(!0)})}}function an(){if(!Xt.value)return;const e=_.value;if(r.value){const t="html"===e?"text/html":"image/svg+xml",n="html"===e?s("artifacts.htmlPreviewTitle")||"HTML Preview":s("artifacts.svgPreviewTitle")||"SVG Preview";return void o("previewCode",{node:l.node,artifactType:t,artifactTitle:n,id:`temp-${e}-${Date.now()}`})}"html"===e&&(ut.value=!ut.value)}function un(e){var t,n;try{if(Ge.value){const n=_e();null==(t=null==n?void 0:n.updateOptions)||t.call(n,{automaticLayout:e})}else{const t=Te();null==(n=null==t?void 0:t.updateOptions)||n.call(t,{automaticLayout:e})}}catch(l){}}function dn(e){if(!He||Se)return null;if(je)return je;if(be.value&&we.value)return Promise.resolve();be.value=!0;const t=d(null,null,function*(){yield function(e){return d(this,null,function*(){var t;if("undefined"==typeof window)return yield e();try{const n=null==(t=window.Element)?void 0:t.prototype,l=null==n?void 0:n.addEventListener;if(!n||!l)return yield e();const o=function(){const e=window,t=e[ge];if(t)return t;const n={depth:0,original:null};return e[ge]=n,n}();0===o.depth&&(o.original=l,n.addEventListener=function(e,t,n){var i;const r=null!=(i=o.original)?i:l;return"touchstart"===e&&function(e,t){if(!e)return!1;const n=e;return!("function"!=typeof n.closest||!n.closest(".monaco-editor, .monaco-diff-editor")||t&&"object"==typeof t&&"passive"in t)}(this,n)?r.call(this,e,t,function(e){return null==e?{passive:!0}:"boolean"==typeof e?{capture:e,passive:!0}:"object"==typeof e?"passive"in e?e:u(a({},e),{passive:!0}):{passive:!0}}(n)):r.call(this,e,t,n)}),o.depth++;try{return yield e()}finally{o.depth=Math.max(0,o.depth-1),0===o.depth&&o.original&&n.addEventListener!==o.original&&(n.addEventListener=o.original,o.original=null)}}catch(n){return yield e()}})}(()=>function(e){return d(this,null,function*(){var t,n,o;if(!He||Se)return;if(it.value=!1,ot.value=!1,function(){const e=ht.value;kt.value=we.value||null==e?null:e}(),It(),Wt(),function(e){e.replaceChildren()}(e),Se)return;if(Ge.value){Re();const o=Ze(String(null!=(t=l.node.originalCode)?t:""),String(null!=(n=l.node.updatedCode)?n:""));ze?yield ze(e,o.original,o.updated,Q.value):yield He(e,l.node.code,Q.value)}else yield He(e,l.node.code,Q.value);if(Se)return;const i=Ge.value?_e():Te();if("number"==typeof(null==(o=l.monacoOptions)?void 0:o.fontSize))null==i||i.updateOptions({fontSize:l.monacoOptions.fontSize,automaticLayout:!1}),dt.value=l.monacoOptions.fontSize,st.value=l.monacoOptions.fontSize;else{const e=Pt();e&&e>0?(dt.value=e,st.value=e):(dt.value=12,st.value=12)}ee.value||te.value||Ut(!1),yield function(){return d(this,null,function*(){null!=St()&&(qt(),Ut(!1),yield O(),yield xt(),qt(),Ut(!1),yield xt(),qt(),Ut(!1))})}(),Se||(we.value=!0,function(){var e,t,n,l,o;if(It(),Ge.value){const l=_e(),o=null==(e=null==l?void 0:l.getOriginalEditor)?void 0:e.call(l),i=null==(t=null==l?void 0:l.getModifiedEditor)?void 0:t.call(l),a=(e,t)=>{try{const n=null==e?void 0:e[t];if("function"!=typeof n)return;const l=n.call(e,()=>Vt());l&&Ue.push(l)}catch(n){}};try{const e=null==(n=null==l?void 0:l.onDidUpdateDiff)?void 0:n.call(l,()=>{Vt(),I(()=>Ht())});e&&Ue.push(e)}catch(r){}return a(o,"onDidContentSizeChange"),a(i,"onDidContentSizeChange"),a(o,"onDidLayoutChange"),void a(i,"onDidLayoutChange")}const i=Te();try{const e=null==(l=null==i?void 0:i.onDidContentSizeChange)?void 0:l.call(i,()=>Vt());e&&Ue.push(e)}catch(r){}try{const e=null==(o=null==i?void 0:i.onDidLayoutChange)?void 0:o.call(i,()=>Vt());e&&Ue.push(e)}catch(r){}}(),$t(),qt(),Ht(),Vt(),yield function(){return d(this,null,function*(){qt(),Ut(!1),yield O(),yield xt(),qt(),Ut(!1),yield xt(),qt(),Ut(!1)})}(),Se||(ot.value=!0))})}(e))}).finally(()=>{je===t&&(je=null)});return je=t,t}x(nn,e=>{e||V()}),x(()=>st.value,(e,t)=>{const n=Ge.value?_e():Te();n&&"number"==typeof e&&Number.isFinite(e)&&e>0&&(n.updateOptions({fontSize:e}),te.value||Ut(!0))},{flush:"post",immediate:!1});const sn=x(()=>[v.value,Ge.value,l.stream,l.loading,ke.value,Be.value],e=>d(null,[e],function*([e,t,n,l,o,i]){if(!e||!He)return;if(!i)return;if(!1===n&&!1!==l)return;const r=dn(e);if(r){try{yield r}catch(a){we.value=!1,ot.value=!1,it.value=!0}sn()}}));function cn(e){return!!e&&"object"==typeof e&&"light"in e&&"dark"in e}function vn(e){return"string"==typeof e?e:e&&"object"==typeof e&&"name"in e?String(e.name):null}function fn(e,t){if(e===t)return!0;const n=vn(e),l=vn(t);return!!n&&n===l}function mn(){var e;const t=function(){if(void 0!==l.theme){const e=l.theme;return cn(e)?l.isDark?e.dark:e.light:e}return l.isDark?l.darkTheme:l.lightTheme}(),n=null==(e=et.value)?void 0:e.theme,o=null!=t?t:n;if(null!=o&&"object"==typeof o)return o;const i=Array.isArray(l.themes)?l.themes:[];if(!i.length||null==o)return o;const r=vn(o),a=i.map(e=>vn(e)).filter(e=>!!e);if(!r||a.includes(r))return o;const u=vn(n);return null!=n&&u&&a.includes(u)?n:i[0]}x(tt,(e,t)=>d(null,null,function*(){if(e===t)return;if(nt.value=e,!He||!v.value)return;if(!be.value)return;if(!1===l.stream&&!1!==l.loading)return;if(!Be.value)return;const n=je;if(n){try{yield n}catch(o){}if(Se||!v.value)return}try{we.value=!1,ot.value=!1,be.value=!1,It(),Wt(),Re(),yield O(),yield dn(v.value)}catch(i){we.value=!1,ot.value=!1,it.value=!0}}));const pn=c(()=>(void 0!==l.theme?!cn(l.theme):fn(l.darkTheme,l.lightTheme))?function(e){var t,n;if(e&&"object"==typeof e&&(null==(t=e.colors)?void 0:t["editor.background"])){const t=_t(e.colors["editor.background"]);if(null!=t)return t<128}const o=(null!=(n=vn(e))?n:"").toLowerCase();return o?["dark","night","moon","black","dracula","mocha","frappe","macchiato","palenight","ocean","poimandres","monokai","laserwave","tokyo","slack-dark","rose-pine","github-dark","material-theme","one-dark","catppuccin-mocha","catppuccin-frappe","catppuccin-macchiato"].some(e=>o.includes(e))&&!["light","latte","dawn","lotus"].some(e=>o.includes(e)):!!l.isDark}(mn()):!!l.isDark),hn=c(()=>{var e;if(!Ge.value)return pn.value?"dark":"light";const t=null==(e=et.value)?void 0:e.diffAppearance;return"light"===t||"dark"===t?t:pn.value?"dark":"light"}),yn=c(()=>Ge.value?"dark"===hn.value:pn.value);function gn(){return u(a(u(a({wordWrap:"on",wrappingIndent:"same",themes:l.themes},et.value||{}),{theme:mn()}),Ge.value?{diffAppearance:hn.value}:{}),{onThemeChange(){$t()}})}function bn(){const e=gn();if(!Ve)return Ve=e,Ve;for(const t of Object.keys(Ve))t in e||delete Ve[t];return Object.assign(Ve,e),Ve}const wn=c(()=>{var e,t,n,o,i,r,u,d,s,c,v,f,m,p,h;return JSON.stringify({diffLineStyle:null!=(t=null==(e=et.value)?void 0:e.diffLineStyle)?t:"background",diffUnchangedRegionStyle:null!=(o=null==(n=et.value)?void 0:n.diffUnchangedRegionStyle)?o:"line-info",diffHideUnchangedRegions:void 0===(null==(i=l.monacoOptions)?void 0:i.diffHideUnchangedRegions)?a({},Ke):Qe(l.monacoOptions.diffHideUnchangedRegions),renderSideBySide:null==(u=null==(r=et.value)?void 0:r.renderSideBySide)||u,useInlineViewWhenSpaceIsLimited:null==(s=null==(d=et.value)?void 0:d.useInlineViewWhenSpaceIsLimited)||s,enableSplitViewResizing:null==(v=null==(c=et.value)?void 0:c.enableSplitViewResizing)||v,ignoreTrimWhitespace:null==(m=null==(f=et.value)?void 0:f.ignoreTrimWhitespace)||m,originalEditable:null!=(h=null==(p=et.value)?void 0:p.originalEditable)&&h})});return x(()=>[l.monacoOptions,Be.value],()=>{var e,t;if(bn(),!He||!Be.value)return;const n=Ge.value?_e():Te(),o="number"==typeof(null==(e=l.monacoOptions)?void 0:e.fontSize)?l.monacoOptions.fontSize:Number.isFinite(st.value)?st.value:void 0;"number"==typeof o&&Number.isFinite(o)&&o>0&&(null==(t=null==n?void 0:n.updateOptions)||t.call(n,{fontSize:o})),Ut(!1)},{deep:!0}),x(()=>[mn(),hn.value,ke.value,be.value,Be.value],([e],t)=>{ke.value&&be.value&&Be.value&&function(e={}){if(e.appearanceOnly)return;bn();const t=mn(),n=()=>{Ge.value&&Ae(),I(()=>{$t(),Vt()})};t?function(e,t){const n=function(e){if(null==e)return null;if("string"==typeof e)return e;if("object"==typeof e&&"name"in e)return String(e.name);if("object"==typeof e){const n=de.get(e);if(n)return n;try{const t=JSON.stringify(e);if(t)return de.set(e,t),t}catch(t){}const l="__theme_"+ ++se;return de.set(e,l),l}return String(e)}(t);return n?(ue=e,le||ae!==n?le?(re===n||oe===n||(ie=t,re=n),le):(ie=t,re=n,le=d(null,null,function*(){for(;re&&null!=ie;){const n=ie,l=re;if(ie=null,re=null,ae!==l)try{oe=l,yield(null!=ue?ue:e)(n),ae=l}catch(t){}}}).finally(()=>{le=null,oe=null}),le):Promise.resolve()):Promise.resolve()}(We,t).then(n).catch(e=>{}):n()}({appearanceOnly:null!=t&&fn(e,t[0])})},{flush:"post"}),x(()=>[wn.value,ke.value,Be.value],(e,t)=>d(null,[e,t],function*([e,t,n],[o]){if(bn(),!t||!n)return;if(!He||!v.value)return;if(!be.value)return;if(e===o)return;if(!1===l.stream&&!1!==l.loading)return;const i=je;if(i){try{yield i}catch(r){}if(Se||!v.value)return}try{we.value=!1,ot.value=!1,be.value=!1,It(),Wt(),Re(),yield O(),yield dn(v.value)}catch(a){we.value=!1,ot.value=!1,it.value=!0}}),{flush:"post"}),x(()=>[l.loading,Be.value],(e,t)=>d(null,[e,t],function*([e,t],n){if(!t)return;if(e)return;const o=null==n?void 0:n[0],i=void 0!==o&&!1!==o;yield O(),I(()=>{d(null,null,function*(){var e,t,n;try{if(i&&be.value)if(Ge.value&&v.value){const n=je;if(n)try{yield n}catch(o){}bn();const i=Ze(String(null!=(e=l.node.originalCode)?e:""),String(null!=(t=l.node.updatedCode)?t:""));if(yield Fe(i.original,i.updated,Q.value),Se||!Ge.value)return;Ae(),qt(),Ht()}else Ne(String(null!=(n=l.node.code)?n:""),Q.value);Ut(!1)}catch(r){}})})}),{immediate:!0,flush:"post"}),f(()=>{It(),Wt(),$e()}),(t,n)=>lt.value?(m(),p(k(G),{key:0,node:l.node,loading:l.loading},null,8,["node","loading"])):(m(),M("div",{key:1,ref_key:"container",ref:h,style:E(tn.value),class:g(["code-block-container rounded-lg border",[{dark:l.isDark,"is-rendering":l.loading,"is-dark":yn.value,"is-diff":Ge.value,"is-plain-text":Z.value}]]),"data-markstream-code-block":"1","data-markstream-enhanced":ot.value&&!lt.value?"true":"false"},[L(J,{"show-header":l.showHeader,"show-collapse-button":l.showCollapseButton,"show-font-size-buttons":l.showFontSizeButtons,"enable-font-size-control":l.enableFontSizeControl,"show-copy-button":l.showCopyButton,"show-expand-button":l.showExpandButton,"show-preview-button":l.showPreviewButton,"show-tooltips":l.showTooltips,"is-dark":l.isDark,loading:l.loading,stream:e.stream,"is-collapsed":te.value,"is-expanded":ee.value,"copy-text":b.value,"is-previewable":Xt.value,"code-font-size":st.value,"code-font-min":10,"code-font-max":36,"default-code-font-size":dt.value,"font-baseline-ready":ct.value,"diff-stats":Ge.value?Je.value:null,"diff-stats-aria-label":Xe.value,onToggleCollapse:rn,onDecreaseFont:Ft,onResetFont:Dt,onIncreaseFont:Nt,onCopy:ln,onToggleExpand:on,onPreview:an},B({"header-left":H(()=>[D(t.$slots,"header-left",{},()=>[y("div",ve,[y("span",{class:"icon-slot h-4 w-4 flex-shrink-0",innerHTML:en.value},null,8,fe),y("div",me,[y("div",pe,w(Qt.value),1),Zt.value?(m(),M("div",he,w(Zt.value),1)):N("",!0)])])],!0)]),loading:H(()=>[D(t.$slots,"loading",{loading:e.loading,stream:e.stream},()=>[n[0]||(n[0]=y("div",{class:"loading-skeleton"},[y("div",{class:"skeleton-line"}),y("div",{class:"skeleton-line"}),y("div",{class:"skeleton-line short"})],-1))],!0)]),default:H(()=>[z(y("div",ye,[y("div",{ref_key:"codeEditor",ref:v,class:g(["code-editor-container",[e.stream?"":"code-height-placeholder",{"is-hidden":at.value}]]),style:E(wt.value)},null,6),at.value?(m(),p(k(G),{key:0,class:g(["code-pre-fallback",{"is-wrap":rt.value}]),style:E(gt.value),node:l.node},null,8,["class","style","node"])):N("",!0)],512),[[F,!(te.value||!e.stream&&e.loading)]]),ut.value&&!r.value&&Xt.value&&"html"===_.value?(m(),p(ne,{key:0,code:l.node.code,"html-preview-allow-scripts":l.htmlPreviewAllowScripts,"html-preview-sandbox":l.htmlPreviewSandbox,"is-dark":l.isDark,"on-close":()=>ut.value=!1},null,8,["code","html-preview-allow-scripts","html-preview-sandbox","is-dark","on-close"])):N("",!0)]),_:2},[t.$slots["header-right"]?{name:"header-right",fn:H(()=>[D(t.$slots,"header-right",{},void 0,!0)]),key:"0"}:void 0]),1032,["show-header","show-collapse-button","show-font-size-buttons","enable-font-size-control","show-copy-button","show-expand-button","show-preview-button","show-tooltips","is-dark","loading","stream","is-collapsed","is-expanded","copy-text","is-previewable","code-font-size","default-code-font-size","font-baseline-ready","diff-stats","diff-stats-aria-label"])],14,ce))}}),[["__scopeId","data-v-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{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};