@bagelink/vue 1.20.87 → 1.20.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.20.87",
4
+ "version": "1.20.93",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -63,7 +63,7 @@
63
63
  "@types/signature_pad": "^4.0.0",
64
64
  "vue": "^3.5.43",
65
65
  "vue-component-type-helpers": "^2.2.12",
66
- "@bagelink/sdk": "1.20.87"
66
+ "@bagelink/sdk": "1.20.93"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@bagelink/sdk": "*",
@@ -32,6 +32,11 @@ interface ImageProps {
32
32
  rounded?: boolean | number
33
33
  /** Defer the download until the image nears the viewport. */
34
34
  lazy?: boolean
35
+ /**
36
+ * Mark as the LCP / above-the-fold candidate. Sets `fetchpriority="high"`
37
+ * and disables lazy loading so the browser fetches it immediately.
38
+ */
39
+ priority?: boolean
35
40
  }
36
41
 
37
42
  const props = defineProps<ImageProps>()
@@ -95,6 +100,9 @@ const radiusStyle = computed(() => {
95
100
  return typeof props.rounded === 'number' ? `${props.rounded}px` : 'var(--bgl-card-radius, 12px)'
96
101
  })
97
102
  const imgFit = computed(() => props.fit ?? 'cover')
103
+ /** Priority images must never lazy-load — that delays LCP. */
104
+ const isLazy = computed(() => !!props.lazy && !props.priority)
105
+ const fetchPriority = computed(() => (props.priority ? 'high' as const : undefined))
98
106
  </script>
99
107
 
100
108
  <template>
@@ -118,7 +126,8 @@ const imgFit = computed(() => props.fit ?? 'cover')
118
126
  v-if="imageSrc"
119
127
  :src="deliveredSrc"
120
128
  :alt="alt"
121
- :loading="lazy ? 'lazy' : undefined"
129
+ :loading="isLazy ? 'lazy' : undefined"
130
+ :fetchpriority="fetchPriority"
122
131
  decoding="async"
123
132
  class="bgl-image-frame-img h-100p"
124
133
  :class="[frameHasHeight ? 'absolute-fill' : 'bgl-image-frame-img--flow', { 'opacity-0': !imageLoaded }]"
@@ -140,7 +149,8 @@ const imgFit = computed(() => props.fit ?? 'cover')
140
149
  :src="deliveredSrc"
141
150
  v-bind="$attrs"
142
151
  :alt="alt"
143
- :loading="lazy ? 'lazy' : undefined"
152
+ :loading="isLazy ? 'lazy' : undefined"
153
+ :fetchpriority="fetchPriority"
144
154
  decoding="async"
145
155
  :width="normalizeDimension(width)"
146
156
  :height="normalizeDimension(height)"
@@ -167,7 +177,8 @@ const imgFit = computed(() => props.fit ?? 'cover')
167
177
  v-if="imageSrc"
168
178
  :src="deliveredSrc"
169
179
  :alt="alt"
170
- :loading="lazy ? 'lazy' : undefined"
180
+ :loading="isLazy ? 'lazy' : undefined"
181
+ :fetchpriority="fetchPriority"
171
182
  decoding="async"
172
183
  class="w-100p h-100p"
173
184
  :class="{ 'opacity-0': !imageLoaded }"
@@ -31,6 +31,11 @@ const props = defineProps({
31
31
  folding: { type: Boolean, default: false },
32
32
  /** Show an explicit Format action; downloads the formatter only when clicked. */
33
33
  formatting: { type: Boolean, default: false },
34
+ /**
35
+ * Toolbar chrome: `bar` keeps language + actions above the editor;
36
+ * `hover` reveals them on hover/focus. Terminal mode always uses the title bar.
37
+ */
38
+ toolbarMode: { type: String as PropType<'bar' | 'hover'>, default: 'bar' },
34
39
  singleLine: { type: Boolean, default: false },
35
40
  /** Legacy highlight.js theme names now map to light/dark appearance. */
36
41
  theme: { type: String as PropType<HighlightTheme>, default: 'dark' },
@@ -67,6 +72,8 @@ const isLightTheme = computed(() => {
67
72
  'school-book', 'routeros', 'purebasic',
68
73
  ].includes(theme)
69
74
  })
75
+ /** Terminal shells are always dark — force matching syntax colors. */
76
+ const editorDark = computed(() => props.terminal || !isLightTheme.value)
70
77
 
71
78
  function updateCode(value: string) {
72
79
  code.value = value
@@ -96,19 +103,12 @@ watch(() => props.modelValue, value => {
96
103
 
97
104
  <template>
98
105
  <div
99
- class="bagel-input code-editor-container ltr flex flex-column"
106
+ class="bagel-input code-editor-container ltr display-flex flex-column"
100
107
  :class="[shellClass, { 'has-value': hasCodeValue, 'single-line': singleLine, terminal }]"
101
108
  :style="[{ height: editorHeight, '--code-max-height': maxHeight }, shellStyle]"
102
109
  >
103
- <label v-if="label" class="code-label">{{ label }}</label>
104
- <div v-if="terminal" class="code-terminal-bar monospace flex flex-shrink-0 gap-05 py-05 px-075 txt11 line-height-1 border-bottom">
105
- <span class="inline-flex gap-025 flex-shrink-0" aria-hidden="true">
106
- <span class="square-10 round bg-red" />
107
- <span class="square-10 round bg-yellow" />
108
- <span class="square-10 round bg-green" />
109
- </span>
110
- <span v-if="title" class="opacity-5 ellipsis-1">{{ title }}</span>
111
- </div>
110
+ <!-- Bar mode puts the form label on the toolbar row; other modes keep it above. -->
111
+ <label v-if="label && (toolbarMode === 'hover' || singleLine || terminal)" class="label">{{ label }}</label>
112
112
  <StructuredEditor
113
113
  :model-value="code"
114
114
  :language="objectMode && language === 'html' ? 'json' : language"
@@ -121,7 +121,10 @@ watch(() => props.modelValue, value => {
121
121
  :single-line="singleLine"
122
122
  :placeholder="placeholder"
123
123
  :label="label"
124
- :dark="!isLightTheme"
124
+ :dark="editorDark"
125
+ :terminal="terminal"
126
+ :title="title"
127
+ :toolbar-mode="toolbarMode"
125
128
  @update:model-value="updateCode"
126
129
  @focus="isFocused = true"
127
130
  @blur="handleBlur"
@@ -137,11 +140,13 @@ watch(() => props.modelValue, value => {
137
140
  }
138
141
  .code-editor-container > :deep(.structured-editor) {
139
142
  flex: 1;
143
+ min-height: 0;
140
144
  }
141
- .code-label {
142
- flex-shrink: 0;
143
- margin-bottom: 0.25rem;
144
- text-align: left;
145
+ /* Focus ring only while the CodeMirror surface is focused — not toolbar buttons (e.g. Copy). */
146
+ .code-editor-container:not(.frame):not(.bgl-outline):not(.terminal):not(.single-line) > :deep(.structured-editor:not(.toolbar-hover):has(.cm-focused) .structured-editor-host),
147
+ .code-editor-container:not(.frame):not(.bgl-outline):not(.terminal):not(.single-line) > :deep(.structured-editor.toolbar-hover:has(.cm-focused)) {
148
+ outline: solid 1px var(--bgl-border-color, #4f575f);
149
+ box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.13);
145
150
  }
146
151
  .code-editor-container.single-line {
147
152
  height: auto;
@@ -156,6 +161,7 @@ watch(() => props.modelValue, value => {
156
161
  }
157
162
  .single-line :deep(.cm-content) {
158
163
  padding-block: 0;
164
+ padding-inline: 0.7rem;
159
165
  line-height: var(--bgl-input-height);
160
166
  }
161
167
  .code-editor-container.terminal {
@@ -167,7 +173,19 @@ watch(() => props.modelValue, value => {
167
173
  border: 1px solid var(--bgl-border-color);
168
174
  border-radius: calc(var(--bgl-radius, 6px) * 2);
169
175
  }
170
- .code-terminal-bar {
171
- background: rgba(255, 255, 255, 0.04);
176
+ /* Let the terminal shell paint the surface — don't leave Atom One's panel bg. */
177
+ .terminal > :deep(.structured-editor),
178
+ .terminal :deep(.cm-editor),
179
+ .terminal :deep(.cm-gutters),
180
+ .terminal :deep(.cm-gutterElement),
181
+ .terminal :deep(.cm-activeLineGutter) {
182
+ background: transparent !important;
183
+ }
184
+ .terminal > :deep(.structured-editor) {
185
+ border-radius: 0;
186
+ color: inherit;
187
+ }
188
+ .terminal :deep(.cm-content) {
189
+ padding: 0.75rem;
172
190
  }
173
191
  </style>
@@ -24,6 +24,15 @@ const props = defineProps<{
24
24
  placeholder: string
25
25
  label: string
26
26
  dark: boolean
27
+ terminal?: boolean
28
+ /** Shown in the terminal title bar. */
29
+ title?: string
30
+ /**
31
+ * `bar` (default) — language label + actions always visible above the editor.
32
+ * `hover` — immersive surface; chrome appears on hover/focus.
33
+ * Terminal mode always uses the title-bar row for chrome.
34
+ */
35
+ toolbarMode?: 'bar' | 'hover'
27
36
  }>()
28
37
  const emit = defineEmits<{
29
38
  'update:modelValue': [value: string]
@@ -40,6 +49,10 @@ let copyTimer: ReturnType<typeof setTimeout> | undefined
40
49
  const languageNames: Record<string, string> = { javascript: 'JS', typescript: 'TS' }
41
50
  const languageLabel = computed(() => languageNames[props.language] || props.language.toUpperCase())
42
51
  const canFormat = computed(() => props.formatting && !props.singleLine && supportsFormatting(props.language))
52
+ const toolbarMode = computed(() => props.toolbarMode ?? 'bar')
53
+ const hoverToolbar = computed(() => !props.terminal && toolbarMode.value === 'hover')
54
+ const toolbarPinned = computed(() => formattingBusy.value || copied.value || Boolean(formatError.value || copyError.value))
55
+ const showToolbar = computed(() => !props.singleLine)
43
56
  const config = new Compartment()
44
57
  const languageConfig = new Compartment()
45
58
  const externalUpdate = Annotation.define<boolean>()
@@ -94,6 +107,7 @@ function createSearchPanel(editor: EditorView) {
94
107
  }
95
108
 
96
109
  function extensions(): Extension[] {
110
+ const contentPad = props.singleLine ? '0' : '0.75em 1ch 1.5em 2ch'
97
111
  return [
98
112
  props.dark ? atomone : atomLight,
99
113
  props.lineNumbers && !props.singleLine ? numberGutter() : [],
@@ -107,10 +121,30 @@ function extensions(): Extension[] {
107
121
  }),
108
122
  editorPlaceholder(props.placeholder),
109
123
  EditorView.theme({
110
- '&': { height: '100%' },
111
- '.cm-scroller': { overflow: 'auto', fontFamily: 'inherit', lineHeight: '1.5' },
112
- '.cm-content': { padding: '8px 0' },
124
+ '&': {
125
+ height: '100%',
126
+ ...(props.terminal ? { backgroundColor: 'transparent' } : {}),
127
+ },
128
+ '.cm-scroller': {
129
+ overflow: 'auto',
130
+ fontFamily: 'inherit',
131
+ lineHeight: '1.5',
132
+ overscrollBehavior: 'contain',
133
+ },
134
+ '.cm-content': {
135
+ padding: contentPad,
136
+ fontVariantLigatures: 'none',
137
+ tabSize: 2,
138
+ caretColor: props.dark ? '#fff' : '#1b1f23',
139
+ },
140
+ '.cm-gutters': props.terminal
141
+ ? { backgroundColor: 'transparent', border: 'none' }
142
+ : {},
143
+ '.cm-activeLineGutter': props.terminal ? { backgroundColor: 'transparent' } : {},
113
144
  '&.cm-focused': { outline: 'none' },
145
+ '.cm-selectionBackground, &.cm-focused .cm-selectionBackground': {
146
+ backgroundColor: props.dark ? 'rgba(36, 102, 188, 0.35)' : 'rgba(36, 102, 188, 0.3)',
147
+ },
114
148
  }, { dark: props.dark }),
115
149
  ]
116
150
  }
@@ -215,7 +249,7 @@ watch(() => props.modelValue, value => {
215
249
  })
216
250
  })
217
251
  watch(() => props.language, requestLanguage)
218
- watch(() => [props.lineNumbers, props.folding, props.readonly, props.disabled, props.wrap, props.singleLine, props.placeholder, props.label, props.dark], () => {
252
+ watch(() => [props.lineNumbers, props.folding, props.readonly, props.disabled, props.wrap, props.singleLine, props.placeholder, props.label, props.dark, props.terminal], () => {
219
253
  view?.dispatch({ effects: config.reconfigure(extensions()) })
220
254
  })
221
255
  onBeforeUnmount(() => {
@@ -227,40 +261,144 @@ onBeforeUnmount(() => {
227
261
  </script>
228
262
 
229
263
  <template>
230
- <div class="structured-editor monospace">
231
- <div v-if="!singleLine" class="flex flex-shrink-0 align-items-center space-between gap-05 px-075 py-025">
232
- <span class="txt11 opacity-5" aria-label="Code language">{{ languageLabel }}</span>
233
- <div class="flex align-items-center gap-025">
264
+ <div
265
+ class="structured-editor"
266
+ :class="{
267
+ terminal,
268
+ 'toolbar-hover': hoverToolbar,
269
+ 'toolbar-pinned': toolbarPinned,
270
+ 'single-line': singleLine,
271
+ }"
272
+ >
273
+ <!-- Terminal: language + actions live in the title bar -->
274
+ <div
275
+ v-if="terminal && showToolbar"
276
+ class="code-terminal-bar monospace flex flex-shrink-0 space-between gap-05 py-025 px-075 txt11 line-height-1 border-bottom"
277
+ >
278
+ <div class="flex gap-05 min-w-0">
279
+ <span class="inline-flex gap-025 flex-shrink-0" aria-hidden="true">
280
+ <span class="square-10 round bg-red" />
281
+ <span class="square-10 round bg-yellow" />
282
+ <span class="square-10 round bg-green" />
283
+ </span>
284
+ <span v-if="title" class="opacity-5 ellipsis-1">{{ title }}</span>
285
+ </div>
286
+ <div class="flex align-items-center gap-025 flex-shrink-0">
287
+ <span class="opacity-5 px-05" aria-label="Code language">{{ languageLabel }}</span>
234
288
  <Btn
235
289
  v-if="canFormat" v-tooltip="formattingBusy ? 'Formatting…' : 'Format code'" thin flat
290
+ icon-size="1"
236
291
  icon="format_align_left" aria-label="Format code" :aria-busy="formattingBusy"
237
292
  :disabled="readonly || disabled || formattingBusy" @click="format"
238
293
  />
239
294
  <Btn
240
295
  v-tooltip="copied ? 'Copied!' : 'Copy code'" thin flat
296
+ icon-size="1"
241
297
  :icon="copied ? 'check' : 'content_copy'" :aria-label="copied ? 'Copied!' : 'Copy code'"
242
298
  @click="copy"
243
299
  />
244
300
  <span class="hide" role="status">{{ copied ? 'Copied to clipboard' : '' }}</span>
245
301
  </div>
246
302
  </div>
247
- <span v-if="formatError || copyError" role="alert" class="txt12 color-red px-075">{{ formatError || copyError }}</span>
303
+
304
+ <!-- Bar / hover chrome. With a form label: label · language · actions share one row above the input. -->
305
+ <div
306
+ v-else-if="showToolbar"
307
+ class="code-toolbar flex flex-shrink-0 align-items-center space-between gap-05 py-025"
308
+ >
309
+ <label v-if="label && !hoverToolbar" class="label mb-0">{{ label }}</label>
310
+ <span v-else class="txt11 opacity-5" aria-label="Code language">{{ languageLabel }}</span>
311
+ <div class="flex align-items-center gap-025 ms-auto">
312
+ <span v-if="label && !hoverToolbar" class="txt11 opacity-5 px-05" aria-label="Code language">{{ languageLabel }}</span>
313
+ <Btn
314
+ v-if="canFormat" v-tooltip="formattingBusy ? 'Formatting…' : 'Format code'" thin flat
315
+ icon-size="1"
316
+ icon="format_align_left" aria-label="Format code" :aria-busy="formattingBusy"
317
+ :disabled="readonly || disabled || formattingBusy" @click="format"
318
+ />
319
+ <Btn
320
+ v-tooltip="copied ? 'Copied!' : 'Copy code'" thin flat icon-size="1"
321
+ :icon="copied ? 'check' : 'content_copy'" :aria-label="copied ? 'Copied!' : 'Copy code'"
322
+ @click="copy"
323
+ />
324
+ <span class="hide" role="status">{{ copied ? 'Copied to clipboard' : '' }}</span>
325
+ </div>
326
+ </div>
327
+
328
+ <span v-if="formatError || copyError" role="alert" class="code-alert txt12 color-red px-075">{{ formatError || copyError }}</span>
248
329
  <div ref="host" class="structured-editor-host" />
249
330
  </div>
250
331
  </template>
251
332
 
252
333
  <style scoped>
253
334
  .structured-editor {
335
+ position: relative;
254
336
  display: flex;
255
337
  flex-direction: column;
256
338
  height: 100%;
257
339
  min-height: 0;
258
340
  max-height: var(--code-max-height, none);
259
341
  overflow: hidden;
342
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
343
+ font-variant-ligatures: none;
260
344
  }
261
345
  .structured-editor-host {
262
346
  flex: 1;
263
347
  min-height: 0;
264
348
  overflow: auto;
265
349
  }
350
+ /* Bar mode: chrome (label/language/actions) sits above; the code surface is the rounded input. */
351
+ .structured-editor:not(.toolbar-hover):not(.terminal):not(.single-line) .structured-editor-host {
352
+ border-radius: var(--code-border-radius, 0.25rem);
353
+ overflow: hidden;
354
+ }
355
+ /* Hover / single-line: round the whole editor shell (chrome overlays or is absent). */
356
+ .toolbar-hover,
357
+ .structured-editor.single-line {
358
+ border-radius: var(--code-border-radius, 0.25rem);
359
+ }
360
+ .structured-editor.single-line {
361
+ border-radius: var(--bgl-input-border-radius);
362
+ }
363
+ .code-terminal-bar {
364
+ background: rgba(255, 255, 255, 0.04);
365
+ }
366
+ /* Default: always-visible chrome above the editor. */
367
+ .code-toolbar {
368
+ position: relative;
369
+ z-index: 1;
370
+ }
371
+ /* Optional immersive mode: overlay chrome until hover/focus. */
372
+ .toolbar-hover .code-toolbar {
373
+ position: absolute;
374
+ inset-block-start: 0;
375
+ inset-inline: 0;
376
+ z-index: 3;
377
+ opacity: 0;
378
+ padding-inline: 0.5rem;
379
+ pointer-events: none;
380
+ transition: opacity 0.15s ease;
381
+ background: linear-gradient(
382
+ to bottom,
383
+ color-mix(in srgb, var(--bgl-box-bg, #fff) 92%, transparent),
384
+ color-mix(in srgb, var(--bgl-box-bg, #fff) 55%, transparent),
385
+ transparent
386
+ );
387
+ }
388
+ .toolbar-hover:hover .code-toolbar,
389
+ .toolbar-hover:focus-within .code-toolbar,
390
+ .toolbar-hover.toolbar-pinned .code-toolbar {
391
+ opacity: 1;
392
+ pointer-events: auto;
393
+ }
394
+ .code-alert {
395
+ position: relative;
396
+ z-index: 2;
397
+ }
398
+ .toolbar-hover .code-alert {
399
+ position: absolute;
400
+ inset-block-start: 2rem;
401
+ inset-inline: 0;
402
+ z-index: 3;
403
+ }
266
404
  </style>
@@ -372,9 +372,10 @@
372
372
  .bgl-dark-mode .bagel-input.underlined textarea,
373
373
  .bgl-dark-mode .bagel-input.underlined select,
374
374
  .bgl-dark-mode .bagel-input.frame .selectinput-btn,
375
- /* CodeEditor: the inner textarea is transparent/overlaid — its frame must
376
- come only from .code-editor-grandpa, not from the generic input ring. */
377
- .bgl-dark-mode .bagel-input .code-input {
375
+ /* CodeEditor: legacy overlay textarea + new CodeMirror surface — frame/focus
376
+ come from .code-editor-grandpa / .structured-editor, not the generic input ring. */
377
+ .bgl-dark-mode .bagel-input .code-input,
378
+ .bgl-dark-mode .bagel-input .cm-editor {
378
379
  box-shadow: none;
379
380
  }
380
381
 
@@ -303,14 +303,23 @@ select {
303
303
 
304
304
  /* colorInputPickWrap variants handled in ColorInput.vue */
305
305
 
306
- .bagel-input.frame .code-editor-grandpa {
306
+ .bagel-input.frame .code-editor-grandpa,
307
+ .bagel-input.frame .structured-editor.toolbar-hover,
308
+ .bagel-input.frame .structured-editor.single-line,
309
+ .bagel-input.frame .structured-editor:not(.toolbar-hover):not(.terminal):not(.single-line) .structured-editor-host {
307
310
  outline: 1.5px solid var(--bgl-border-color);
308
311
  outline-offset: -1px;
309
312
  border-radius: var(--bgl-input-border-radius);
313
+ transition: outline-color 0.2s ease, box-shadow 0.2s ease;
310
314
  }
311
315
 
312
- .bagel-input.frame:focus-within .code-editor-grandpa {
316
+ /* Legacy overlay textarea still uses :focus-within; CodeMirror uses .cm-focused so Copy/Format don't light the ring. */
317
+ .bagel-input.frame:focus-within .code-editor-grandpa,
318
+ .bagel-input.frame:has(.cm-focused) .structured-editor.toolbar-hover,
319
+ .bagel-input.frame:has(.cm-focused) .structured-editor.single-line,
320
+ .bagel-input.frame:has(.cm-focused) .structured-editor:not(.toolbar-hover):not(.terminal):not(.single-line) .structured-editor-host {
313
321
  outline-color: var(--bgl-input-label-active-color, var(--bgl-primary));
322
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--bgl-input-label-active-color, var(--bgl-primary)) 12%, transparent);
314
323
  }
315
324
 
316
325
  .bagel-input.frame .rich-text-editor {
@@ -1,2 +0,0 @@
1
- const In=require("./chunk-Bt6Bclq5.cjs"),S=require("./src-CxSyib2S.cjs"),s=require("./dist-B-MCiFKR.cjs");let u=require("vue");var It=e=>{let{state:t}=e,r=t.doc.lineAt(t.selection.main.from),n=Se(e.state,r.from);return n.line?qt(e):n.block?_t(e):!1};function ye(e,t){return({state:r,dispatch:n})=>{if(r.readOnly)return!1;let l=e(t,r);return l?(n(r.update(l)),!0):!1}}var qt=ye(Wt,0),Pt=ye($e,0),_t=ye((e,t)=>$e(e,t,$t(t)),0);function Se(e,t){let r=e.languageDataAt("commentTokens",t,1);return r.length?r[0]:{}}var O=50;function Ot(e,{open:t,close:r},n,l){let o=e.sliceDoc(n-O,n),i=e.sliceDoc(l,l+O),a=/\s*$/.exec(o)[0].length,c=/^\s*/.exec(i)[0].length,h=o.length-a;if(o.slice(h-t.length,h)==t&&i.slice(c,c+r.length)==r)return{open:{pos:n-a,margin:a&&1},close:{pos:l+c,margin:c&&1}};let f,d;l-n<=2*O?f=d=e.sliceDoc(n,l):(f=e.sliceDoc(n,n+O),d=e.sliceDoc(l-O,l));let m=/^\s*/.exec(f)[0].length,v=/\s*$/.exec(d)[0].length,p=d.length-v-r.length;return f.slice(m,m+t.length)==t&&d.slice(p,p+r.length)==r?{open:{pos:n+m+t.length,margin:/\s/.test(f.charAt(m+t.length))?1:0},close:{pos:l-v-r.length,margin:/\s/.test(d.charAt(p-1))?1:0}}:null}function $t(e){let t=[];for(let r of e.selection.ranges){let n=e.doc.lineAt(r.from),l=r.to<=n.to?n:e.doc.lineAt(r.to);l.from>n.from&&l.from==r.to&&(l=r.to==n.to+1?n:e.doc.lineAt(r.to-1));let o=t.length-1;o>=0&&t[o].to>n.from?t[o].to=l.to:t.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:l.to})}return t}function $e(e,t,r=t.selection.ranges){let n=r.map(o=>Se(t,o.from).block);if(!n.every(o=>o))return null;let l=r.map((o,i)=>Ot(t,n[i],o.from,o.to));if(e!=2&&!l.every(o=>o))return{changes:t.changes(r.map((o,i)=>l[i]?[]:[{from:o.from,insert:n[i].open+" "},{from:o.to,insert:" "+n[i].close}]))};if(e!=1&&l.some(o=>o)){let o=[];for(let i=0,a;i<l.length;i++)if(a=l[i]){let c=n[i],{open:h,close:f}=a;o.push({from:h.pos-c.open.length,to:h.pos+h.margin},{from:f.pos-f.margin,to:f.pos+c.close.length})}return{changes:o}}return null}function Wt(e,t,r=t.selection.ranges){let n=[],l=-1;e:for(let{from:o,to:i}of r){let a=n.length,c=1e9,h;for(let f=o;f<=i;){let d=t.doc.lineAt(f);if(h==null&&(h=Se(t,d.from).line,!h))continue e;if(d.from>l&&(o==i||i>d.from)){l=d.from;let m=/^\s*/.exec(d.text)[0].length,v=m==d.length,p=d.text.slice(m,m+h.length)==h?m:-1;m<d.text.length&&m<c&&(c=m),n.push({line:d,comment:p,token:h,indent:m,empty:v,single:!1})}f=d.to+1}if(c<1e9)for(let f=a;f<n.length;f++)n[f].indent<n[f].line.text.length&&(n[f].indent=c);n.length==a+1&&(n[a].single=!0)}if(e!=2&&n.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:c,indent:h,empty:f,single:d}of n)(d||!f)&&o.push({from:a.from+h,insert:c+" "});let i=t.changes(o);return{changes:i,selection:t.selection.map(i,1)}}else if(e!=1&&n.some(o=>o.comment>=0)){let o=[];for(let{line:i,comment:a,token:c}of n)if(a>=0){let h=i.from+a,f=h+c.length;i.text[f-i.from]==" "&&f++,o.push({from:h,to:f})}return{changes:o}}return null}var he=s.Annotation.define(),Ht=s.Annotation.define(),Ut=s.Facet.define(),We=s.Facet.define({combine(e){return s.combineConfig(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,r)=>r},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,r)=>(n,l)=>t(n,l)||r(n,l)})}}),He=s.StateField.define({create(){return H.empty},update(e,t){let r=t.state.facet(We),n=t.annotation(he);if(n){let c=M.fromTransaction(t,n.selection),h=n.side,f=h==0?e.undone:e.done;return c?f=X(f,f.length,r.minDepth,c):f=Je(f,t.startState.selection),new H(h==0?n.rest:f,h==0?f:n.rest)}let l=t.annotation(Ht);if((l=="full"||l=="before")&&(e=e.isolate()),t.annotation(s.Transaction.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=M.fromTransaction(t),i=t.annotation(s.Transaction.time),a=t.annotation(s.Transaction.userEvent);return o?e=e.addChanges(o,i,a,r,t):t.selection&&(e=e.addSelection(t.startState.selection,i,a,r.newGroupDelay)),(l=="full"||l=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new H(e.done.map(M.fromJSON),e.undone.map(M.fromJSON))}});function Gt(e={}){return[He,We.of(e),s.EditorView.domEventHandlers({beforeinput(t,r){let n=t.inputType=="historyUndo"?Ue:t.inputType=="historyRedo"?fe:null;return n?(t.preventDefault(),n(r)):!1}})]}function ne(e,t){return function({state:r,dispatch:n}){if(!t&&r.readOnly)return!1;let l=r.field(He,!1);if(!l)return!1;let o=l.pop(e,r,t);return o?(n(o),!0):!1}}var Ue=ne(0,!1),fe=ne(1,!1),Jt=ne(0,!0),zt=ne(1,!0),M=class ${constructor(t,r,n,l,o){this.changes=t,this.effects=r,this.mapped=n,this.startSelection=l,this.selectionsAfter=o}setSelAfter(t){return new $(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,r,n;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(r=this.mapped)===null||r===void 0?void 0:r.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(t){return new $(t.changes&&s.ChangeSet.fromJSON(t.changes),[],t.mapped&&s.ChangeDesc.fromJSON(t.mapped),t.startSelection&&s.EditorSelection.fromJSON(t.startSelection),t.selectionsAfter.map(s.EditorSelection.fromJSON))}static fromTransaction(t,r){let n=b;for(let l of t.startState.facet(Ut)){let o=l(t);o.length&&(n=n.concat(o))}return!n.length&&t.changes.empty?null:new $(t.changes.invert(t.startState.doc),n,void 0,r||t.startState.selection,b)}static selection(t){return new $(void 0,b,void 0,void 0,t)}};function X(e,t,r,n){let l=t+1>r+20?t-r-1:0,o=e.slice(l,t);return o.push(n),o}function jt(e,t){let r=[],n=!1;return e.iterChangedRanges((l,o)=>r.push(l,o)),t.iterChangedRanges((l,o,i,a)=>{for(let c=0;c<r.length;){let h=r[c++],f=r[c++];a>=h&&i<=f&&(n=!0)}}),n}function Kt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((r,n)=>r.empty!=t.ranges[n].empty).length===0}function Ge(e,t){return e.length?t.length?e.concat(t):e:t}var b=[],Qt=200;function Je(e,t){if(e.length){let r=e[e.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-Qt));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),X(e,e.length-1,1e9,r.setSelAfter(n)))}else return[M.selection([t])]}function Xt(e){let t=e[e.length-1],r=e.slice();return r[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),r}function se(e,t){if(!e.length)return e;let r=e.length,n=b;for(;r;){let l=Yt(e[r-1],t,n);if(l.changes&&!l.changes.empty||l.effects.length){let o=e.slice(0,r);return o[r-1]=l,o}else t=l.mapped,r--,n=l.selectionsAfter}return n.length?[M.selection(n)]:b}function Yt(e,t,r){let n=Ge(e.selectionsAfter.length?e.selectionsAfter.map(a=>a.map(t)):b,r);if(!e.changes)return M.selection(n);let l=e.changes.map(t),o=t.mapDesc(e.changes,!0),i=e.mapped?e.mapped.composeDesc(o):o;return new M(l,s.StateEffect.mapEffects(e.effects,t),i,e.startSelection.map(o),n)}var Zt=/^(input\.type|delete)($|\.)/,H=class W{constructor(t,r,n=0,l=void 0){this.done=t,this.undone=r,this.prevTime=n,this.prevUserEvent=l}isolate(){return this.prevTime?new W(this.done,this.undone):this}addChanges(t,r,n,l,o){let i=this.done,a=i[i.length-1];return a&&a.changes&&!a.changes.empty&&t.changes&&(!n||Zt.test(n))&&(!a.selectionsAfter.length&&r-this.prevTime<l.newGroupDelay&&l.joinToEvent(o,jt(a.changes,t.changes))||n=="input.type.compose")?i=X(i,i.length-1,l.minDepth,new M(t.changes.compose(a.changes),Ge(s.StateEffect.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,b)):i=X(i,i.length,l.minDepth,t),new W(i,b,r,n)}addSelection(t,r,n,l){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:b;return o.length>0&&r-this.prevTime<l&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&Kt(o[o.length-1],t)?this:new W(Je(this.done,t),this.undone,r,n)}addMapping(t){return new W(se(this.done,t),se(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,r,n){let l=t==0?this.done:this.undone;if(l.length==0)return null;let o=l[l.length-1],i=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):r.selection);if(n&&o.selectionsAfter.length)return r.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:he.of({side:t,rest:Xt(l),selection:i}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let a=l.length==1?b:l.slice(0,l.length-1);return o.mapped&&(a=se(a,o.mapped)),r.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:he.of({side:t,rest:a,selection:i}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};H.empty=new H(b,b);var er=[{key:"Mod-z",run:Ue,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:fe,preventDefault:!0},{linux:"Ctrl-Shift-z",run:fe,preventDefault:!0},{key:"Mod-u",run:Jt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:zt,preventDefault:!0}];function P(e,t){return s.EditorSelection.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function A({state:e,dispatch:t},r){let n=P(e.selection,r);return n.eq(e.selection,!0)?!1:(t(B(e,n)),!0)}function le(e,t){return s.EditorSelection.cursor(t?e.to:e.from)}function ze(e,t){return A(e,r=>r.empty?e.moveByChar(r,t):le(r,t))}function x(e){return e.textDirectionAt(e.state.selection.main.head)==s.Direction.LTR}var je=e=>ze(e,!x(e)),Ke=e=>ze(e,x(e));function Qe(e,t){return A(e,r=>r.empty?e.moveByGroup(r,t):le(r,t))}var tr=e=>Qe(e,!x(e)),rr=e=>Qe(e,x(e)),qn=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function nr(e,t,r){if(t.type.prop(r))return!0;let n=t.to-t.from;return n&&(n>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function oe(e,t,r){let n=s.syntaxTree(e).resolveInner(t.head),l=r?s.NodeProp.closedBy:s.NodeProp.openedBy;for(let c=t.head;;){let h=r?n.childAfter(c):n.childBefore(c);if(!h)break;nr(e,h,l)?n=h:c=r?h.to:h.from}let o=n.type.prop(l),i,a;return o&&(i=r?s.matchBrackets(e,n.from,1):s.matchBrackets(e,n.to,-1))&&i.matched?a=r?i.end.to:i.end.from:a=r?n.to:n.from,s.EditorSelection.cursor(a,r?-1:1)}var lr=e=>A(e,t=>oe(e.state,t,!x(e))),or=e=>A(e,t=>oe(e.state,t,x(e)));function Xe(e,t){return A(e,r=>{if(!r.empty)return le(r,t);let n=e.moveVertically(r,t);return n.head!=r.head?n:e.moveToLineBoundary(r,t)})}var Ye=e=>Xe(e,!1),Ze=e=>Xe(e,!0);function et(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,n=0,l;if(t){for(let o of e.state.facet(s.EditorView.scrollMargins)){let i=o(e);i?.top&&(r=Math.max(i?.top,r)),i?.bottom&&(n=Math.max(i?.bottom,n))}l=e.scrollDOM.clientHeight-r-n}else l=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:n,selfScroll:t,height:Math.max(e.defaultLineHeight,l-5)}}function tt(e,t){let r=et(e),{state:n}=e,l=P(n.selection,i=>i.empty?e.moveVertically(i,t,r.height):le(i,t));if(l.eq(n.selection))return!1;let o;if(r.selfScroll){let i=e.coordsAtPos(n.selection.main.head),a=e.scrollDOM.getBoundingClientRect(),c=a.top+r.marginTop,h=a.bottom-r.marginBottom;i&&i.top>c&&i.bottom<h&&(o=s.EditorView.scrollIntoView(l.main.head,{y:"start",yMargin:i.top-c}))}return e.dispatch(B(n,l),{effects:o}),!0}var we=e=>tt(e,!1),de=e=>tt(e,!0);function D(e,t,r){let n=e.lineBlockAt(t.head),l=e.moveToLineBoundary(t,r);if(l.head==t.head&&l.head!=(r?n.to:n.from)&&(l=e.moveToLineBoundary(t,r,!1)),!r&&l.head==n.from&&n.length){let o=/^\s*/.exec(e.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;o&&t.head!=n.from+o&&(l=s.EditorSelection.cursor(n.from+o))}return l}var ir=e=>A(e,t=>D(e,t,!0)),ar=e=>A(e,t=>D(e,t,!1)),sr=e=>A(e,t=>D(e,t,!x(e))),cr=e=>A(e,t=>D(e,t,x(e))),ur=e=>A(e,t=>e.moveToLineBoundary(t,!1,!1)),hr=e=>A(e,t=>e.moveToLineBoundary(t,!0,!1));function fr(e,t,r){let n=!1,l=P(e.selection,o=>{let i=s.matchBrackets(e,o.head,-1)||s.matchBrackets(e,o.head,1)||o.head>0&&s.matchBrackets(e,o.head-1,1)||o.head<e.doc.length&&s.matchBrackets(e,o.head+1,-1);if(!i||!i.end)return o;n=!0;let a=i.start.from==o.head?i.end.to:i.end.from;return r?s.EditorSelection.range(o.anchor,a):s.EditorSelection.cursor(a)});return n?(t(B(e,l)),!0):!1}var dr=({state:e,dispatch:t})=>fr(e,t,!1);function E(e,t,r){let n=P(e.state.selection,l=>{l.undirectional&&l.head>=l.anchor!=t&&(l=s.EditorSelection.range(l.head,l.anchor));let o=r(l);return s.EditorSelection.range(l.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(B(e.state,n)),!0)}function rt(e,t){return E(e,t,r=>e.moveByChar(r,t))}var nt=e=>rt(e,!x(e)),lt=e=>rt(e,x(e));function ot(e,t){return E(e,t,r=>e.moveByGroup(r,t))}var mr=e=>ot(e,!x(e)),pr=e=>ot(e,x(e)),gr=e=>{let t=!x(e);return E(e,t,r=>oe(e.state,r,t))},vr=e=>{let t=x(e);return E(e,t,r=>oe(e.state,r,t))};function it(e,t){return E(e,t,r=>e.moveVertically(r,t))}var at=e=>it(e,!1),st=e=>it(e,!0);function ct(e,t){return E(e,t,r=>e.moveVertically(r,t,et(e).height))}var Ve=e=>ct(e,!1),Te=e=>ct(e,!0),yr=e=>E(e,!0,t=>D(e,t,!0)),Sr=e=>E(e,!1,t=>D(e,t,!1)),xr=e=>{let t=!x(e);return E(e,t,r=>D(e,r,t))},kr=e=>{let t=x(e);return E(e,t,r=>D(e,r,t))},Cr=e=>E(e,!1,t=>s.EditorSelection.cursor(e.lineBlockAt(t.head).from)),br=e=>E(e,!0,t=>s.EditorSelection.cursor(e.lineBlockAt(t.head).to)),Ne=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),Re=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),Fe=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),Ie=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Er=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Br=({state:e,dispatch:t})=>{let r=ie(e).map(({from:n,to:l})=>s.EditorSelection.undirectionalRange(n,Math.min(l+1,e.doc.length)));return t(e.update({selection:s.EditorSelection.create(r),userEvent:"select"})),!0},Ar=({state:e,dispatch:t})=>{let r=P(e.selection,n=>{let l=s.syntaxTree(e),o=l.resolveStack(n.from,1);if(n.empty){let i=l.resolveStack(n.from,-1);i.node.from>=o.node.from&&i.node.to<=o.node.to&&(o=i)}for(let i=o;i;i=i.next){let{node:a}=i;if((a.from<n.from&&a.to>=n.to||a.to>n.to&&a.from<=n.from)&&i.next)return s.EditorSelection.undirectionalRange(a.from,a.to)}return n});return r.eq(e.selection)?!1:(t(B(e,r)),!0)};function ut(e,t){let{state:r}=e,n=r.selection,l=r.selection.ranges.slice();for(let o of r.selection.ranges){let i=r.doc.lineAt(o.head);if(t?i.to<e.state.doc.length:i.from>0)for(let a=o;;){let c=e.moveVertically(a,t);if(c.head<i.from||c.head>i.to){l.some(h=>h.head==c.head)||l.push(c);break}else{if(c.head==a.head)break;a=c}}}return l.length==n.ranges.length?!1:(e.dispatch(B(r,s.EditorSelection.create(l,l.length-1))),!0)}var Mr=e=>ut(e,!1),Lr=e=>ut(e,!0),Dr=({state:e,dispatch:t})=>{let r=e.selection,n=null;return r.ranges.length>1?n=s.EditorSelection.create([r.main]):r.main.empty||(n=s.EditorSelection.create([s.EditorSelection.cursor(r.main.head)])),n?(t(B(e,n)),!0):!1};function G(e,t){if(e.state.readOnly)return!1;let r="delete.selection",{state:n}=e,l=n.changeByRange(o=>{let{from:i,to:a}=o;if(i==a){let c=t(o);c<i?(r="delete.backward",c=z(e,c,!1)):c>i&&(r="delete.forward",c=z(e,c,!0)),i=Math.min(i,c),a=Math.max(a,c)}else i=z(e,i,!1),a=z(e,a,!0);return i==a?{range:o}:{changes:{from:i,to:a},range:s.EditorSelection.cursor(i,i<o.head?-1:1)}});return l.changes.empty?!1:(e.dispatch(n.update(l,{scrollIntoView:!0,userEvent:r,effects:r=="delete.selection"?s.EditorView.announce.of(n.phrase("Selection deleted")):void 0})),!0)}function z(e,t,r){if(e instanceof s.EditorView)for(let n of e.state.facet(s.EditorView.atomicRanges).map(l=>l(e)))n.between(t,t,(l,o)=>{l<t&&o>t&&(t=r?o:l)});return t}var ht=(e,t,r)=>G(e,n=>{let l=n.from,{state:o}=e,i=o.doc.lineAt(l),a,c;if(r&&!t&&l>i.from&&l<i.from+200&&!/[^ \t]/.test(a=i.text.slice(0,l-i.from))){if(a[a.length-1]==" ")return l-1;let h=s.countColumn(a,o.tabSize)%s.getIndentUnit(o)||s.getIndentUnit(o);for(let f=0;f<h&&a[a.length-1-f]==" ";f++)l--;c=l}else c=s.findClusterBreak(i.text,l-i.from,t,t)+i.from,c==l&&i.number!=(t?o.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(i.text.slice(c-i.from,l-i.from))&&(c=s.findClusterBreak(i.text,c-i.from,!1,!1)+i.from);return c}),me=e=>ht(e,!1,!0),ft=e=>ht(e,!0,!1),dt=(e,t)=>G(e,r=>{let n=r.head,{state:l}=e,o=l.doc.lineAt(n),i=l.charCategorizer(n);for(let a=null;;){if(n==(t?o.to:o.from)){n==r.head&&o.number!=(t?l.doc.lines:1)&&(n+=t?1:-1);break}let c=s.findClusterBreak(o.text,n-o.from,t)+o.from,h=o.text.slice(Math.min(n,c)-o.from,Math.max(n,c)-o.from),f=i(h);if(a!=null&&f!=a)break;(h!=" "||n!=r.head)&&(a=f),n=c}return n}),mt=e=>dt(e,!1),wr=e=>dt(e,!0),Vr=e=>G(e,t=>{let r=e.lineBlockAt(t.head).to;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),Tr=e=>G(e,t=>{let r=e.moveToLineBoundary(t,!1).head;return t.head>r?r:Math.max(0,t.head-1)}),Nr=e=>G(e,t=>{let r=e.moveToLineBoundary(t,!0).head;return t.head<r?r:Math.min(e.state.doc.length,t.head+1)}),Rr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:s.Text.of(["",""])},range:s.EditorSelection.cursor(n.from)}));return t(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0},Fr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=e.changeByRange(n=>{if(!n.empty||n.from==0||n.from==e.doc.length)return{range:n};let l=n.from,o=e.doc.lineAt(l),i=l==o.from?l-1:s.findClusterBreak(o.text,l-o.from,!1)+o.from,a=l==o.to?l+1:s.findClusterBreak(o.text,l-o.from,!0)+o.from;return{changes:{from:i,to:a,insert:e.doc.slice(l,a).append(e.doc.slice(i,l))},range:s.EditorSelection.cursor(a)}});return r.changes.empty?!1:(t(e.update(r,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ie(e){let t=[],r=-1;for(let n of e.selection.ranges){let l=e.doc.lineAt(n.from),o=e.doc.lineAt(n.to);if(!n.empty&&n.to==o.from&&(o=e.doc.lineAt(n.to-1)),r>=l.number){let i=t[t.length-1];i.to=o.to,i.ranges.push(n)}else t.push({from:l.from,to:o.to,ranges:[n]});r=o.number+1}return t}function pt(e,t,r){if(e.readOnly)return!1;let n=[],l=[];for(let o of ie(e)){if(r?o.to==e.doc.length:o.from==0)continue;let i=e.doc.lineAt(r?o.to+1:o.from-1),a=i.length+1;if(r){n.push({from:o.to,to:i.to},{from:o.from,insert:i.text+e.lineBreak});for(let c of o.ranges)l.push(s.EditorSelection.range(Math.min(e.doc.length,c.anchor+a),Math.min(e.doc.length,c.head+a)))}else{n.push({from:i.from,to:o.from},{from:o.to,insert:e.lineBreak+i.text});for(let c of o.ranges)l.push(s.EditorSelection.range(c.anchor-a,c.head-a))}}return n.length?(t(e.update({changes:n,scrollIntoView:!0,selection:s.EditorSelection.create(l,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}var Ir=({state:e,dispatch:t})=>pt(e,t,!1),qr=({state:e,dispatch:t})=>pt(e,t,!0);function gt(e,t,r){if(e.readOnly)return!1;let n=[];for(let o of ie(e))r?n.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):n.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let l=e.changes(n);return t(e.update({changes:l,selection:e.selection.map(l,r?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var Pr=({state:e,dispatch:t})=>gt(e,t,!1),_r=({state:e,dispatch:t})=>gt(e,t,!0),Or=e=>{if(e.state.readOnly)return!1;let{state:t}=e,r=t.changes(ie(t).map(({from:l,to:o})=>(l>0?l--:o<t.doc.length&&o++,{from:l,to:o}))),n=P(t.selection,l=>{let o;if(e.lineWrapping){let i=e.lineBlockAt(l.head),a=e.coordsAtPos(l.head,l.assoc||1);a&&(o=i.bottom+e.documentTop-a.bottom+e.defaultLineHeight/2)}return e.moveVertically(l,!0,o)}).map(r);return e.dispatch({changes:r,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function $r(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let r=s.syntaxTree(e).resolveInner(t),n=r.childBefore(t),l=r.childAfter(t),o;return n&&l&&n.to<=t&&l.from>=t&&(o=n.type.prop(s.NodeProp.closedBy))&&o.indexOf(l.name)>-1&&e.doc.lineAt(n.to).from==e.doc.lineAt(l.from).from&&!/\S/.test(e.sliceDoc(n.to,l.from))?{from:n.to,to:l.from}:null}var qe=vt(!1),Wr=vt(!0);function vt(e){return({state:t,dispatch:r})=>{if(t.readOnly)return!1;let n=t.changeByRange(l=>{let{from:o,to:i}=l,a=t.doc.lineAt(o),c=!e&&o==i&&$r(t,o);e&&(o=i=(i<=a.to?a:t.doc.lineAt(i)).to);let h=new s.IndentContext(t,{simulateBreak:o,simulateDoubleBreak:!!c}),f=s.getIndentation(h,o);for(f==null&&(f=s.countColumn(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));i<a.to&&/\s/.test(a.text[i-a.from]);)i++;c?{from:o,to:i}=c:o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let d=["",s.indentString(t,f)];return c&&d.push(s.indentString(t,h.lineIndent(a.from,-1))),{changes:{from:o,to:i,insert:s.Text.of(d)},range:s.EditorSelection.cursor(o+1+d[1].length)}});return r(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}}function xe(e,t){let r=-1;return e.changeByRange(n=>{let l=[];for(let i=n.from;i<=n.to;){let a=e.doc.lineAt(i);a.number>r&&(n.empty||n.to>a.from)&&(t(a,l,n),r=a.number),i=a.to+1}let o=e.changes(l);return{changes:l,range:s.EditorSelection.range(o.mapPos(n.anchor,1),o.mapPos(n.head,1))}})}var Hr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Object.create(null),n=new s.IndentContext(e,{overrideIndentation:o=>{let i=r[o];return i??-1}}),l=xe(e,(o,i,a)=>{let c=s.getIndentation(n,o.from);if(c==null)return;/\S/.test(o.text)||(c=0);let h=/^\s*/.exec(o.text)[0],f=s.indentString(e,c);(h!=f||a.from<o.from+h.length)&&(r[o.from]=c,i.push({from:o.from,to:o.from+h.length,insert:f}))});return l.changes.empty||t(e.update(l,{userEvent:"indent"})),!0},yt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(xe(e,(r,n)=>{n.push({from:r.from,insert:e.facet(s.indentUnit)})}),{userEvent:"input.indent"})),!0),St=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(xe(e,(r,n)=>{let l=/^\s*/.exec(r.text)[0];if(!l)return;let o=s.countColumn(l,e.tabSize),i=0,a=s.indentString(e,Math.max(0,o-s.getIndentUnit(e)));for(;i<l.length&&i<a.length&&l.charCodeAt(i)==a.charCodeAt(i);)i++;n.push({from:r.from+i,to:r.from+l.length,insert:a.slice(i)})}),{userEvent:"delete.dedent"})),!0),Ur=e=>(e.setTabFocusMode(),!0),Gr=[{key:"Ctrl-b",run:je,shift:nt,preventDefault:!0},{key:"Ctrl-f",run:Ke,shift:lt},{key:"Ctrl-p",run:Ye,shift:at},{key:"Ctrl-n",run:Ze,shift:st},{key:"Ctrl-a",run:ur,shift:Cr},{key:"Ctrl-e",run:hr,shift:br},{key:"Ctrl-d",run:ft},{key:"Ctrl-h",run:me},{key:"Ctrl-k",run:Vr},{key:"Ctrl-Alt-h",run:mt},{key:"Ctrl-o",run:Rr},{key:"Ctrl-t",run:Fr},{key:"Ctrl-v",run:de}],Jr=[{key:"ArrowLeft",run:je,shift:nt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:tr,shift:mr,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:sr,shift:xr,preventDefault:!0},{key:"ArrowRight",run:Ke,shift:lt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:rr,shift:pr,preventDefault:!0},{mac:"Cmd-ArrowRight",run:cr,shift:kr,preventDefault:!0},{key:"ArrowUp",run:Ye,shift:at,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Ne,shift:Fe},{mac:"Ctrl-ArrowUp",run:we,shift:Ve},{key:"ArrowDown",run:Ze,shift:st,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Re,shift:Ie},{mac:"Ctrl-ArrowDown",run:de,shift:Te},{key:"PageUp",run:we,shift:Ve},{key:"PageDown",run:de,shift:Te},{key:"Home",run:ar,shift:Sr,preventDefault:!0},{key:"Mod-Home",run:Ne,shift:Fe},{key:"End",run:ir,shift:yr,preventDefault:!0},{key:"Mod-End",run:Re,shift:Ie},{key:"Enter",run:qe,shift:qe},{key:"Mod-a",run:Er},{key:"Backspace",run:me,shift:me,preventDefault:!0},{key:"Delete",run:ft,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:mt,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:wr,preventDefault:!0},{mac:"Mod-Backspace",run:Tr,preventDefault:!0},{mac:"Mod-Delete",run:Nr,preventDefault:!0}].concat(Gr.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),zr=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:lr,shift:gr},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:or,shift:vr},{key:"Alt-ArrowUp",run:Ir},{key:"Shift-Alt-ArrowUp",run:Pr},{key:"Alt-ArrowDown",run:qr},{key:"Shift-Alt-ArrowDown",run:_r},{key:"Mod-Alt-ArrowUp",run:Mr},{key:"Mod-Alt-ArrowDown",run:Lr},{key:"Escape",run:Dr},{key:"Mod-Enter",run:Wr},{key:"Alt-l",mac:"Ctrl-l",run:Br},{key:"Mod-i",run:Ar,preventDefault:!0},{key:"Mod-[",run:St},{key:"Mod-]",run:yt},{key:"Mod-Alt-\\",run:Hr},{key:"Shift-Mod-k",run:Or},{key:"Shift-Mod-\\",run:dr},{key:"Mod-/",run:It},{key:"Alt-A",mac:"Ctrl-A",run:Pt},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Ur}].concat(Jr),jr={key:"Tab",run:yt,shift:St};function pe(){return pe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},pe.apply(null,arguments)}var Kr=e=>{var t=e.theme,r=e.settings,n=r===void 0?{}:r,l=e.styles,o=l===void 0?[]:l,i={".cm-gutters":{}},a={};n.background&&(a.backgroundColor=n.background),n.backgroundImage&&(a.backgroundImage=n.backgroundImage),n.foreground&&(a.color=n.foreground),n.fontSize&&(a.fontSize=n.fontSize),(n.background||n.foreground)&&(i["&"]=a),n.fontFamily&&(i["&.cm-editor .cm-scroller"]={fontFamily:n.fontFamily}),n.gutterBackground&&(i[".cm-gutters"].backgroundColor=n.gutterBackground),n.gutterForeground&&(i[".cm-gutters"].color=n.gutterForeground),n.gutterBorder&&(i[".cm-gutters"].borderRightColor=n.gutterBorder),n.caret&&(i[".cm-content"]={caretColor:n.caret},i[".cm-cursor, .cm-dropCursor"]={borderLeftColor:n.caret});var c={};return n.gutterActiveForeground&&(c.color=n.gutterActiveForeground),n.lineHighlight&&(i[".cm-activeLine"]={backgroundColor:n.lineHighlight},c.backgroundColor=n.lineHighlight),i[".cm-activeLineGutter"]=c,n.selection&&(i["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:n.selection+" !important"}),n.selectionMatch&&(i["& .cm-selectionMatch"]={backgroundColor:n.selectionMatch}),[s.EditorView.theme(i,{dark:t==="dark"}),s.syntaxHighlighting(s.HighlightStyle.define(o))]},Qr={background:"#272C35",foreground:"#9d9b97",caret:"#797977",selection:"#3d4c64",selectionMatch:"#3d4c64",gutterBackground:"#272C35",gutterForeground:"#465063",gutterBorder:"transparent",lineHighlight:"#2e3f5940"},Xr=[{tag:[s.tags.function(s.tags.variableName),s.tags.function(s.tags.propertyName),s.tags.url,s.tags.processingInstruction],color:"hsl(207, 82%, 66%)"},{tag:[s.tags.tagName,s.tags.heading],color:"#e06c75"},{tag:s.tags.comment,color:"#54636D"},{tag:[s.tags.propertyName],color:"hsl(220, 14%, 71%)"},{tag:[s.tags.attributeName,s.tags.number],color:"hsl( 29, 54%, 61%)"},{tag:s.tags.className,color:"hsl( 39, 67%, 69%)"},{tag:s.tags.keyword,color:"hsl(286, 60%, 67%)"},{tag:[s.tags.string,s.tags.regexp,s.tags.special(s.tags.propertyName)],color:"#98c379"}],xt=e=>{var t=e||{},r=t.theme,n=r===void 0?"dark":r,l=t.settings,o=l===void 0?{}:l,i=t.styles,a=i===void 0?[]:i;return Kr({theme:n,settings:pe({},Qr,o),styles:[...Xr,...a]})},Yr=xt(),Pe=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e,U=class{constructor(e,t,r=0,n=e.length,l,o){this.test=o,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,n),this.bufferStart=r,this.normalize=l?i=>l(Pe(i)):Pe,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return s.codePointAt(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=s.fromCodePoint(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=s.codePointSize(e);let n=this.normalize(t);if(n.length)for(let l=0,o=r,i=!0;;l++){let a=n.charCodeAt(l),c=this.match(a,o,i,this.bufferPos+this.bufferStart,l==n.length-1);if(c)return this.value=c,this;if(l==n.length-1)break;i&&l<t.length&&t.charCodeAt(l)==a?o++:i=!1}}}match(e,t,r,n,l){let o=null;for(let i=0;i<this.matches.length;){let a=this.matches[i],c=!1;this.query.charCodeAt(a.index)==e&&(a.index==this.query.length-1?o={from:a.from,to:n,precise:l&&a.precise}:(a.index++,c=!0)),c?i++:this.matches.splice(i,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?o={from:t,to:n,precise:r&&l}:this.matches.push({from:t,index:1,precise:r})),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}};typeof Symbol<"u"&&(U.prototype[Symbol.iterator]=function(){return this});var kt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},ke="gm"+(/x/.unicode==null?"":"u"),Ct=class{constructor(e,t,r,n=0,l=e.length){if(this.text=e,this.to=l,this.curLine="",this.done=!1,this.value=kt,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new bt(e,t,r,n,l);this.re=new RegExp(t,ke+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(n).from,this.matchPos=Y(e,n),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let r=this.curLineStart+t.index,n=r+t[0].length;if(this.matchPos=Y(this.text,n+(r==n?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<n||r>this.value.to)&&(!this.test||this.test(r,n,t)))return this.value={from:r,to:n,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},ce=new WeakMap,_e=class Q{constructor(t,r){this.from=t,this.text=r}get to(){return this.from+this.text.length}static get(t,r,n){let l=ce.get(t);if(!l||l.from>=n||l.to<=r){let a=new Q(r,t.sliceString(r,n));return ce.set(t,a),a}if(l.from==r&&l.to==n)return l;let{text:o,from:i}=l;return i>r&&(o=t.sliceString(r,i)+o,i=r),l.to<n&&(o+=t.sliceString(l.to,n)),ce.set(t,new Q(i,o)),new Q(r,o.slice(r-i,n-i))}},bt=class{constructor(e,t,r,n,l){this.text=e,this.to=l,this.done=!1,this.value=kt,this.matchPos=Y(e,n),this.re=new RegExp(t,ke+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=_e.get(e,n,this.chunkEnd(n+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let r=this.flat.from+t.index,n=r+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,n,t)))return this.value={from:r,to:n,precise:!0,match:t},this.matchPos=Y(this.text,n+(r==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=_e.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(Ct.prototype[Symbol.iterator]=bt.prototype[Symbol.iterator]=function(){return this});function Zr(e){try{return new RegExp(e,ke),!0}catch{return!1}}function Y(e,t){if(t>=e.length)return t;let r=e.lineAt(t),n;for(;t<r.to&&(n=r.text.charCodeAt(t-r.from))>=56320&&n<57344;)t++;return t}var en=e=>{let t=s.getDialog(e,"cm-goto-line");if(t){let i=t.dom.querySelector("input[type=text]");return i&&i.select(),!0}let{state:r}=e,n=String(r.doc.lineAt(e.state.selection.main.head).number),{close:l,result:o}=s.showDialog(e,{class:"cm-goto-line",label:r.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:r.phrase("go")});return o.then(i=>{let a=i&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.elements.line.value);if(!a){e.dispatch({effects:l});return}let c=r.doc.lineAt(r.selection.main.head),[,h,f,d,m]=a,v=d?+d.slice(1):0,p=f?+f:c.number;if(f&&m){let T=p/100;h&&(T=T*(h=="-"?-1:1)+c.number/r.doc.lines),p=Math.round(r.doc.lines*T)}else f&&h&&(p=p*(h=="-"?-1:1)+c.number);let _=r.doc.line(Math.max(1,Math.min(r.doc.lines,p))),y=s.EditorSelection.cursor(_.from+Math.max(0,Math.min(v,_.length)));e.dispatch({effects:[l,s.EditorView.scrollIntoView(y.from,{y:"center"})],selection:y})}),!0},tn=({state:e,dispatch:t})=>{let{selection:r}=e,n=s.EditorSelection.create(r.ranges.map(l=>e.wordAt(l.head)||s.EditorSelection.cursor(l.head)),r.mainIndex);return n.eq(r)?!1:(t(e.update({selection:n})),!0)};function rn(e,t){let{main:r,ranges:n}=e.selection,l=e.wordAt(r.head),o=l&&l.from==r.from&&l.to==r.to;for(let i=!1,a=new U(e.doc,t,n[n.length-1].to);;)if(a.next(),a.done){if(i)return null;a=new U(e.doc,t,0,Math.max(0,n[n.length-1].from-1)),i=!0}else{if(i&&n.some(c=>c.from==a.value.from))continue;if(o){let c=e.wordAt(a.value.from);if(!c||c.from!=a.value.from||c.to!=a.value.to)continue}return a.value}}var nn=({state:e,dispatch:t})=>{let{ranges:r}=e.selection;if(r.some(o=>o.from===o.to))return tn({state:e,dispatch:t});let n=e.sliceDoc(r[0].from,r[0].to);if(e.selection.ranges.some(o=>e.sliceDoc(o.from,o.to)!=n))return!1;let l=rn(e,n);return l?(t(e.update({selection:e.selection.addRange(s.EditorSelection.range(l.from,l.to),!1),effects:s.EditorView.scrollIntoView(l.to)})),!0):!1},V=s.Facet.define({combine(e){return s.combineConfig(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new vn(t),scrollToMatch:t=>s.EditorView.scrollIntoView(t)})}});function ln(e){return e?[V.of(e),ve]:ve}var Ce=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Zr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,r)=>r=="n"?`
2
- `:r=="r"?"\r":r=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new hn(this):new sn(this)}getCursor(e,t=0,r){let n=e.doc?e:s.EditorState.create({doc:e});return r==null&&(r=n.doc.length),this.regexp?R(this,n,t,r):N(this,n,t,r)}},Et=class{constructor(e){this.spec=e}};function on(e,t,r){return(n,l,o,i)=>r&&!r(n,l,o,i)?!1:e(n>=i&&l<=i+o.length?o.slice(n-i,l-i):t.doc.sliceString(n,l),t,n,l)}function N(e,t,r,n){let l;return e.wholeWord&&(l=an(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(l=on(e.test,t,l)),new U(t.doc,e.unquoted,r,n,e.caseSensitive?void 0:o=>o.toLowerCase(),l)}function an(e,t){return(r,n,l,o)=>((o>r||o+l.length<n)&&(o=Math.max(0,r-2),l=e.sliceString(o,Math.min(e.length,n+2))),(t(Z(l,r-o))!=s.CharCategory.Word||t(ee(l,r-o))!=s.CharCategory.Word)&&(t(ee(l,n-o))!=s.CharCategory.Word||t(Z(l,n-o))!=s.CharCategory.Word))}var sn=class extends Et{constructor(e){super(e)}nextMatch(e,t,r){let n=N(this.spec,e,r,e.doc.length).nextOverlapping();if(n.done){let l=Math.min(e.doc.length,t+this.spec.unquoted.length);n=N(this.spec,e,0,l).nextOverlapping()}return n.done||n.value.from==t&&n.value.to==r?null:n.value}prevMatchInRange(e,t,r){for(let n=r;;){let l=Math.max(t,n-1e4-this.spec.unquoted.length),o=N(this.spec,e,l,n),i=null;for(;!o.nextOverlapping().done;)i=o.value;if(i)return i;if(l==t)return null;n-=1e4}}prevMatch(e,t,r){let n=this.prevMatchInRange(e,0,t);return n||(n=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),n&&(n.from!=t||n.to!=r)?n:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let r=N(this.spec,e,0,e.doc.length),n=[];for(;!r.next().done;){if(n.length>=t)return null;n.push(r.value)}return n}highlight(e,t,r,n){let l=N(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!l.next().done;)n(l.value.from,l.value.to)}};function cn(e,t,r){return(n,l,o)=>(!r||r(n,l,o))&&e(o[0],t,n,l)}function R(e,t,r,n){let l;return e.wholeWord&&(l=un(t.charCategorizer(t.selection.main.head))),e.test&&(l=cn(e.test,t,l)),new Ct(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:l},r,n)}function Z(e,t){return e.slice(s.findClusterBreak(e,t,!1),t)}function ee(e,t){return e.slice(t,s.findClusterBreak(e,t))}function un(e){return(t,r,n)=>!n[0].length||(e(Z(n.input,n.index))!=s.CharCategory.Word||e(ee(n.input,n.index))!=s.CharCategory.Word)&&(e(ee(n.input,n.index+n[0].length))!=s.CharCategory.Word||e(Z(n.input,n.index+n[0].length))!=s.CharCategory.Word)}var hn=class extends Et{nextMatch(e,t,r){let n=R(this.spec,e,r,e.doc.length).next();return n.done&&(n=R(this.spec,e,0,t).next()),n.done?null:n.value}prevMatchInRange(e,t,r){for(let n=1;;n++){let l=Math.max(t,r-n*1e4),o=R(this.spec,e,l,r),i=null;for(;!o.next().done;)i=o.value;if(i&&(l==t||i.from>l+10))return i;if(l==t)return null}}prevMatch(e,t,r){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let n=r.length;n>0;n--){let l=+r.slice(0,n);if(l>0&&l<e.match.length)return e.match[l]+r.slice(n)}return t})}matchAll(e,t){let r=R(this.spec,e,0,e.doc.length),n=[];for(;!r.next().done;){if(n.length>=t)return null;n.push(r.value)}return n}highlight(e,t,r,n){let l=R(this.spec,e,Math.max(0,t-250),Math.min(r+250,e.doc.length));for(;!l.next().done;)n(l.value.from,l.value.to)}},F=s.StateEffect.define(),be=s.StateEffect.define(),L=s.StateField.define({create(e){return new ue(te(e).create(),null)},update(e,t){for(let r of t.effects)r.is(F)?e=new ue(r.value.create(),e.panel):r.is(be)&&(e=new ue(e.query,r.value?Ee:null));return e},provide:e=>s.showPanel.from(e,t=>t.panel)});function Oe(e){let t=e.field(L,!1);return t?t.query.spec:te(e)}var ue=class{constructor(e,t){this.query=e,this.panel=t}},fn=s.Decoration.mark({class:"cm-searchMatch"}),dn=s.Decoration.mark({class:"cm-searchMatch cm-searchMatch-selected"}),mn=s.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(L))}update(e){let t=e.state.field(L);(t!=e.startState.field(L)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return s.Decoration.none;let{view:r}=this,n=new s.RangeSetBuilder;for(let l=0,o=r.visibleRanges,i=o.length;l<i;l++){let{from:a,to:c}=o[l];for(;l<i-1&&c>o[l+1].from-500;)c=o[++l].to;e.highlight(r.state,a,c,(h,f)=>{let d=r.state.selection.ranges.some(m=>m.from==h&&m.to==f);n.add(h,f,d?dn:fn)})}return n.finish()}},{decorations:e=>e.decorations});function J(e){return t=>{let r=t.state.field(L,!1);return r&&r.query.spec.valid?e(t,r):Dt(t)}}var I=J((e,{query:t})=>{let{to:r}=e.state.selection.main,n=t.nextMatch(e.state,r,r);if(!n)return!1;let l=s.EditorSelection.single(n.from,n.to),o=e.state.facet(V);return e.dispatch({selection:l,effects:[Be(e,n),o.scrollToMatch(l.main,e)],userEvent:"select.search"}),Lt(e),!0}),q=J((e,{query:t})=>{let{state:r}=e,{from:n}=r.selection.main,l=t.prevMatch(r,n,n);if(!l)return!1;let o=s.EditorSelection.single(l.from,l.to),i=e.state.facet(V);return e.dispatch({selection:o,effects:[Be(e,l),i.scrollToMatch(o.main,e)],userEvent:"select.search"}),Lt(e),!0}),Bt=J((e,{query:t})=>{let r=t.matchAll(e.state,1e3);return!r||!r.length?!1:(e.dispatch({selection:s.EditorSelection.create(r.map(n=>s.EditorSelection.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),pn=({state:e,dispatch:t})=>{let r=e.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:l}=r.main,o=[],i=0;for(let a=new U(e.doc,e.sliceDoc(n,l));!a.next().done;){if(o.length>1e3)return!1;a.value.from==n&&(i=o.length),o.push(s.EditorSelection.range(a.value.from,a.value.to))}return t(e.update({selection:s.EditorSelection.create(o,i),userEvent:"select.search.matches"})),!0},ge=J((e,{query:t})=>{let{state:r}=e,{from:n,to:l}=r.selection.main;if(r.readOnly)return!1;let o=t.nextMatch(r,n,n);if(!o)return!1;let i=o,a=[],c,h,f=[];i.precise?i.from==n&&i.to==l&&(h=r.toText(t.getReplacement(i)),a.push({from:i.from,to:i.to,insert:h}),i=t.nextMatch(r,i.from,i.to),f.push(s.EditorView.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(n).number)+"."))):i=t.nextMatch(r,i.from,i.to);let d=e.state.changes(a);return i&&(c=s.EditorSelection.single(i.from,i.to).map(d),f.push(Be(e,i)),f.push(r.facet(V).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:f,userEvent:"input.replace"}),!0}),At=J((e,{query:t})=>{if(e.state.readOnly)return!1;let r=[];for(let l of t.matchAll(e.state,1e9)){let{from:o,to:i,precise:a}=l;a&&r.push({from:o,to:i,insert:t.getReplacement(l)})}if(!r.length)return!1;let n=e.state.phrase("replaced $ matches",r.length)+".";return e.dispatch({changes:r,effects:s.EditorView.announce.of(n),userEvent:"input.replace.all"}),!0});function Ee(e){return e.state.facet(V).createPanel(e)}function te(e,t){var r,n,l,o,i;let a=e.selection.main,c=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!c)return t;let h=e.facet(V);return new Ce({search:((r=t?.literal)!==null&&r!==void 0?r:h.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(n=t?.caseSensitive)!==null&&n!==void 0?n:h.caseSensitive,literal:(l=t?.literal)!==null&&l!==void 0?l:h.literal,regexp:(o=t?.regexp)!==null&&o!==void 0?o:h.regexp,wholeWord:(i=t?.wholeWord)!==null&&i!==void 0?i:h.wholeWord})}function Mt(e){let t=s.getPanel(e,Ee);return t&&t.dom.querySelector("[main-field]")}function Lt(e){let t=Mt(e);t&&t==e.root.activeElement&&t.select()}var Dt=e=>{let t=e.state.field(L,!1);if(t&&t.panel){let r=Mt(e);if(r&&r!=e.root.activeElement){let n=te(e.state,t.query.spec);n.valid&&e.dispatch({effects:F.of(n)}),r.focus(),r.select()}}else e.dispatch({effects:[be.of(!0),t?F.of(te(e.state,t.query.spec)):s.StateEffect.appendConfig.of(ve)]});return!0},re=e=>{let t=e.state.field(L,!1);if(!t||!t.panel)return!1;let r=s.getPanel(e,Ee);return r&&r.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:be.of(!1)}),!0},gn=[{key:"Mod-f",run:Dt,scope:"editor search-panel"},{key:"F3",run:I,shift:q,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:I,shift:q,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:re,scope:"editor search-panel"},{key:"Mod-Shift-l",run:pn},{key:"Mod-Alt-g",run:en},{key:"Mod-d",run:nn,preventDefault:!0}],vn=class{constructor(e){this.view=e;let t=this.query=e.state.field(L).query.spec;this.commit=this.commit.bind(this),this.searchField=s.crelt("input",{value:t.search,placeholder:C(e,"Find"),"aria-label":C(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=s.crelt("input",{value:t.replace,placeholder:C(e,"Replace"),"aria-label":C(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=s.crelt("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=s.crelt("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=s.crelt("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function r(n,l,o){return s.crelt("button",{class:"cm-button",name:n,onclick:l,type:"button"},o)}this.dom=s.crelt("div",{onkeydown:n=>this.keydown(n),class:"cm-search"},[this.searchField,r("next",()=>I(e),[C(e,"next")]),r("prev",()=>q(e),[C(e,"previous")]),r("select",()=>Bt(e),[C(e,"all")]),s.crelt("label",null,[this.caseField,C(e,"match case")]),s.crelt("label",null,[this.reField,C(e,"regexp")]),s.crelt("label",null,[this.wordField,C(e,"by word")]),...e.state.readOnly?[]:[s.crelt("br"),this.replaceField,r("replace",()=>ge(e),[C(e,"replace")]),r("replaceAll",()=>At(e),[C(e,"replace all")])],s.crelt("button",{name:"close",onclick:()=>re(e),"aria-label":C(e,"close"),type:"button"},["×"])])}commit(){let e=new Ce({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:F.of(e)}))}keydown(e){s.runScopeHandlers(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?q:I)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),ge(this.view))}update(e){for(let t of e.transactions)for(let r of t.effects)r.is(F)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(V).top}};function C(e,t){return e.state.phrase(t)}var j=30,K=/[\s\.,:;?!]/;function Be(e,{from:t,to:r}){let n=e.state.doc.lineAt(t),l=e.state.doc.lineAt(r).to,o=Math.max(n.from,t-j),i=Math.min(l,r+j),a=e.state.sliceDoc(o,i);if(o!=n.from){for(let c=0;c<j;c++)if(!K.test(a[c+1])&&K.test(a[c])){a=a.slice(c);break}}if(i!=l){for(let c=a.length-1;c>a.length-j;c--)if(!K.test(a[c-1])&&K.test(a[c])){a=a.slice(0,c);break}}return s.EditorView.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${n.number}.`)}var yn=s.EditorView.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ve=[L,s.Prec.low(mn),yn],Sn={class:"flex align-items-center gap-025"},xn={class:"code-search-field flex-1 min-w-0"},kn={class:"code-search-options flex align-items-center"},Cn=["id"],bn={key:1,class:"txt12 color-red",role:"alert"},En=(0,u.defineComponent)({__name:"SearchPanel",props:{view:{},query:{},readonly:{type:Boolean}},setup(e){const t=e,r=(0,u.ref)(t.query.search),n=(0,u.ref)(t.query.replace),l=(0,u.ref)(t.query.caseSensitive),o=(0,u.ref)(t.query.regexp),i=(0,u.ref)(t.query.wholeWord),a=(0,u.ref)(!1),c=(0,u.useId)();let h=!1;(0,u.watch)(()=>t.query,d=>{h=!0,r.value=d.search,n.value=d.replace,l.value=d.caseSensitive,o.value=d.regexp,i.value=d.wholeWord,h=!1}),(0,u.watch)([r,n,l,o,i],()=>{if(h)return;const d=new Ce({search:r.value,replace:n.value,caseSensitive:l.value,regexp:o.value,wholeWord:i.value});d.eq(t.query)||t.view.dispatch({effects:F.of(d)})},{flush:"sync"});function f(d){d.key==="Escape"?(d.preventDefault(),re(t.view),t.view.focus()):d.key==="Enter"&&(d.preventDefault(),d.shiftKey?q(t.view):I(t.view))}return(d,m)=>{const v=(0,u.resolveDirective)("tooltip");return(0,u.openBlock)(),(0,u.createElementBlock)("div",{class:"code-search-panel grid gap-025 p-05",style:{position:"absolute",right:"1rem",opacity:.9},role:"search","aria-label":"Find and replace",onKeydown:f},[(0,u.createElementVNode)("div",Sn,[e.readonly?(0,u.createCommentVNode)("",!0):(0,u.withDirectives)(((0,u.openBlock)(),(0,u.createBlock)(S.Btn_default,{key:0,thin:"",flat:"",icon:a.value?"expand_more":"chevron_right","aria-label":"Toggle replace","aria-expanded":a.value,"aria-controls":(0,u.unref)(c),onClick:m[0]||(m[0]=p=>a.value=!a.value)},null,8,["icon","aria-expanded","aria-controls"])),[[v,a.value?"Hide replace":"Show replace"]]),(0,u.createElementVNode)("div",xn,[(0,u.createVNode)(S.TextInput_default,{modelValue:r.value,"onUpdate:modelValue":m[1]||(m[1]=p=>r.value=p),small:"",placeholder:"Find",class:"min-w-0","native-input-attrs":{"aria-label":"Find","main-field":"true",name:"search"}},null,8,["modelValue"]),(0,u.createElementVNode)("div",kn,[(0,u.withDirectives)((0,u.createVNode)(S.Btn_default,{thin:"",flat:!l.value,soft:l.value,icon:"match_case","aria-label":"Match case","aria-pressed":l.value,onClick:m[2]||(m[2]=p=>l.value=!l.value)},null,8,["flat","soft","aria-pressed"]),[[v,"Match case"]]),(0,u.withDirectives)((0,u.createVNode)(S.Btn_default,{thin:"",flat:!i.value,soft:i.value,icon:"match_word","aria-label":"Match whole word","aria-pressed":i.value,onClick:m[3]||(m[3]=p=>i.value=!i.value)},null,8,["flat","soft","aria-pressed"]),[[v,"Match whole word"]]),(0,u.withDirectives)((0,u.createVNode)(S.Btn_default,{thin:"",flat:!o.value,soft:o.value,icon:"regular_expression","aria-label":"Regular expression","aria-pressed":o.value,onClick:m[4]||(m[4]=p=>o.value=!o.value)},null,8,["flat","soft","aria-pressed"]),[[v,"Regular expression"]])])]),(0,u.withDirectives)((0,u.createVNode)(S.Btn_default,{thin:"",flat:"",icon:"arrow_upward","aria-label":"Previous match",onClick:m[5]||(m[5]=p=>(0,u.unref)(q)(e.view))},null,512),[[v,"Previous match (Shift+Enter)"]]),(0,u.withDirectives)((0,u.createVNode)(S.Btn_default,{thin:"",flat:"",icon:"arrow_downward","aria-label":"Next match",onClick:m[6]||(m[6]=p=>(0,u.unref)(I)(e.view))},null,512),[[v,"Next match (Enter)"]]),(0,u.withDirectives)((0,u.createVNode)(S.Btn_default,{thin:"",flat:"",icon:"select_all","aria-label":"Select all matches",onClick:m[7]||(m[7]=p=>(0,u.unref)(Bt)(e.view))},null,512),[[v,"Select all matches"]]),(0,u.withDirectives)((0,u.createVNode)(S.Btn_default,{thin:"",flat:"",icon:"close","aria-label":"Close search",onClick:m[8]||(m[8]=p=>{(0,u.unref)(re)(e.view),e.view.focus()})},null,512),[[v,"Close (Escape)"]])]),!e.readonly&&a.value?((0,u.openBlock)(),(0,u.createElementBlock)("div",{key:0,id:(0,u.unref)(c),class:"code-replace-row flex align-items-center gap-025"},[(0,u.createVNode)(S.TextInput_default,{modelValue:n.value,"onUpdate:modelValue":m[9]||(m[9]=p=>n.value=p),small:"",dense:"",placeholder:"Replace",class:"flex-1 min-w-0","native-input-attrs":{"aria-label":"Replace",name:"replace"}},null,8,["modelValue"]),(0,u.withDirectives)((0,u.createVNode)(S.Btn_default,{thin:"",flat:"",icon:"find_replace","aria-label":"Replace next",onClick:m[10]||(m[10]=p=>(0,u.unref)(ge)(e.view))},null,512),[[v,"Replace next"]]),(0,u.withDirectives)((0,u.createVNode)(S.Btn_default,{thin:"",flat:"",icon:"published_with_changes","aria-label":"Replace all",onClick:m[11]||(m[11]=p=>(0,u.unref)(At)(e.view))},null,512),[[v,"Replace all"]])],8,Cn)):(0,u.createCommentVNode)("",!0),e.query.regexp&&e.query.search.length>0&&!e.query.valid?((0,u.openBlock)(),(0,u.createElementBlock)("span",bn,"Invalid regular expression")):(0,u.createCommentVNode)("",!0)],32)}}}),Bn=S.__plugin_vue_export_helper_default(En,[["__scopeId","data-v-c5ae435d"]]);function An(e){return["html","xml","javascript","js","typescript","ts","json","css"].includes(e)}async function Mn(e,t){const{format:r}=await Promise.resolve().then(()=>require("./standalone-CAcRm_h6.cjs")),n={tabWidth:2,useTabs:!1};switch(t){case"html":case"xml":{const l=await Promise.resolve().then(()=>require("./html-BrqW5pT-.cjs"));return r(e,{...n,parser:"html",plugins:[l],htmlWhitespaceSensitivity:"strict"})}case"css":{const l=await Promise.resolve().then(()=>require("./postcss-BxY0xtVZ.cjs"));return r(e,{...n,parser:"css",plugins:[l]})}case"json":case"javascript":case"js":case"typescript":case"ts":{const[l,o]=await Promise.all([Promise.resolve().then(()=>require("./babel-BzIDwrmk.cjs")),Promise.resolve().then(()=>require("./estree-HqeJuE3g.cjs"))]),i=t==="json"?"json":["typescript","ts"].includes(t)?"babel-ts":"babel";return r(e,{...n,parser:i,plugins:[l,o]})}default:return e}}var Ln={class:"structured-editor monospace"},Dn={key:0,class:"flex flex-shrink-0 align-items-center space-between gap-05 px-075 py-025"},wn={class:"txt11 opacity-5","aria-label":"Code language"},Vn={class:"flex align-items-center gap-025"},Tn={class:"hide",role:"status"},Nn={key:1,role:"alert",class:"txt12 color-red px-075"},Rn=(0,u.defineComponent)({__name:"StructuredEditor",props:{modelValue:{},language:{},lineNumbers:{type:Boolean},folding:{type:Boolean},formatting:{type:Boolean},readonly:{type:Boolean},disabled:{type:Boolean},wrap:{type:Boolean},singleLine:{type:Boolean},placeholder:{},label:{},dark:{type:Boolean}},emits:["update:modelValue","focus","blur"],setup(e,{emit:t}){const r=e,n=t,l=(0,u.ref)(),o=(0,u.ref)(!1),i=(0,u.ref)(""),a=(0,u.ref)(!1),c=(0,u.ref)("");let h;const f={javascript:"JS",typescript:"TS"},d=(0,u.computed)(()=>f[r.language]||r.language.toUpperCase()),m=(0,u.computed)(()=>r.formatting&&!r.singleLine&&An(r.language)),v=new s.Compartment,p=new s.Compartment,_=s.Annotation.define();let y,T=0,ae=!1;async function wt(){c.value="";try{await S.copyText(y?.state.doc.toString()??r.modelValue),a.value=!0,clearTimeout(h),h=setTimeout(()=>{a.value=!1},2e3)}catch{c.value="Could not copy. Check clipboard permissions and try again."}}const Vt=(0,u.getCurrentInstance)().appContext,Tt=xt({theme:"light",settings:{background:"#fafafa",foreground:"#383a42",caret:"#526fff",selection:"#d7d7d7",selectionMatch:"#e5e5e6",lineHighlight:"#f0f0f0",gutterBackground:"#fafafa",gutterForeground:"#9d9d9f"}});function Nt(g){const k=document.createElement("div"),w=(0,u.shallowRef)(Oe(g.state)),Le=(0,u.ref)(g.state.readOnly),De=(0,u.h)({setup:()=>()=>(0,u.h)(Bn,{view:g,query:w.value,readonly:Le.value})});return De.appContext=Vt,(0,u.render)(De,k),{dom:k,top:!0,update(){w.value=Oe(g.state),Le.value=g.state.readOnly},destroy(){(0,u.render)(null,k)}}}function Ae(){return[r.dark?Yr:Tt,r.lineNumbers&&!r.singleLine?s.lineNumbers():[],r.folding&&!r.singleLine?[s.foldGutter(),s.keymap.of(s.foldKeymap)]:[],r.wrap?s.EditorView.lineWrapping:[],s.EditorState.readOnly.of(r.readonly||r.disabled),s.EditorView.editable.of(!r.readonly&&!r.disabled),s.EditorView.contentAttributes.of({"aria-label":r.label||"Code editor","aria-disabled":String(r.disabled)}),s.placeholder(r.placeholder),s.EditorView.theme({"&":{height:"100%"},".cm-scroller":{overflow:"auto",fontFamily:"inherit",lineHeight:"1.5"},".cm-content":{padding:"8px 0"},"&.cm-focused":{outline:"none"}},{dark:r.dark})]}async function Rt(){const g=++T;let k=[];switch(r.language){case"html":case"xml":k=(await Promise.resolve().then(()=>require("./dist-CzY35u4H.cjs"))).html();break;case"javascript":case"js":case"typescript":case"ts":k=(await Promise.resolve().then(()=>require("./dist-GbVY_Jpv.cjs"))).javascript({typescript:["typescript","ts"].includes(r.language)});break;case"json":k=(await Promise.resolve().then(()=>require("./dist-CL50Ff42.cjs"))).json();break;case"css":k=(await Promise.resolve().then(()=>require("./dist-BIAEQGHn.cjs"))).css();break}!ae&&g===T&&y?.dispatch({effects:p.reconfigure(k)})}function Me(){Rt().catch(()=>{ae||(i.value="Could not load syntax support. Plain-text editing is still available.")})}async function Ft(){if(!y||!m.value||r.readonly||r.disabled||o.value)return;const g=y.state.doc,k=r.language;o.value=!0,i.value="";try{const w=await Mn(g.toString(),k);y&&y.state.doc===g&&r.language===k&&!r.readonly&&!r.disabled&&(y.dispatch({changes:{from:0,to:g.length,insert:w},userEvent:"input.format"}),y.focus())}catch{i.value="Could not format this code. Check its syntax and try again."}finally{o.value=!1}}return(0,u.onMounted)(()=>{y=new s.EditorView({parent:l.value,state:s.EditorState.create({doc:r.modelValue,extensions:[v.of(Ae()),p.of([]),Gt(),s.indentUnit.of(" "),s.indentOnInput(),s.bracketMatching(),ln({createPanel:Nt}),s.keymap.of([{key:"Enter",run:()=>r.singleLine},...zr,...er,...gn,jr]),s.EditorState.transactionFilter.of(g=>r.singleLine&&g.docChanged&&g.newDoc.lines>1?[]:g),s.EditorView.updateListener.of(g=>{g.docChanged&&!g.transactions.some(k=>k.annotation(_))&&n("update:modelValue",g.state.doc.toString()),g.focusChanged&&(g.view.hasFocus?n("focus"):n("blur"))})]})}),Me()}),(0,u.watch)(()=>r.modelValue,g=>{y&&g!==y.state.doc.toString()&&y.dispatch({changes:{from:0,to:y.state.doc.length,insert:g},annotations:_.of(!0)})}),(0,u.watch)(()=>r.language,Me),(0,u.watch)(()=>[r.lineNumbers,r.folding,r.readonly,r.disabled,r.wrap,r.singleLine,r.placeholder,r.label,r.dark],()=>{y?.dispatch({effects:v.reconfigure(Ae())})}),(0,u.onBeforeUnmount)(()=>{ae=!0,clearTimeout(h),y?.destroy(),y=void 0}),(g,k)=>{const w=(0,u.resolveDirective)("tooltip");return(0,u.openBlock)(),(0,u.createElementBlock)("div",Ln,[e.singleLine?(0,u.createCommentVNode)("",!0):((0,u.openBlock)(),(0,u.createElementBlock)("div",Dn,[(0,u.createElementVNode)("span",wn,(0,u.toDisplayString)(d.value),1),(0,u.createElementVNode)("div",Vn,[m.value?(0,u.withDirectives)(((0,u.openBlock)(),(0,u.createBlock)(S.Btn_default,{key:0,thin:"",flat:"",icon:"format_align_left","aria-label":"Format code","aria-busy":o.value,disabled:e.readonly||e.disabled||o.value,onClick:Ft},null,8,["aria-busy","disabled"])),[[w,o.value?"Formatting…":"Format code"]]):(0,u.createCommentVNode)("",!0),(0,u.withDirectives)((0,u.createVNode)(S.Btn_default,{thin:"",flat:"",icon:a.value?"check":"content_copy","aria-label":a.value?"Copied!":"Copy code",onClick:wt},null,8,["icon","aria-label"]),[[w,a.value?"Copied!":"Copy code"]]),(0,u.createElementVNode)("span",Tn,(0,u.toDisplayString)(a.value?"Copied to clipboard":""),1)])])),i.value||c.value?((0,u.openBlock)(),(0,u.createElementBlock)("span",Nn,(0,u.toDisplayString)(i.value||c.value),1)):(0,u.createCommentVNode)("",!0),(0,u.createElementVNode)("div",{ref_key:"host",ref:l,class:"structured-editor-host"},null,512)])}}}),Fn=S.__plugin_vue_export_helper_default(Rn,[["__scopeId","data-v-b553967e"]]);exports.default=Fn;