open-lyric-plugin-km-kh 0.1.15 → 0.1.17

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/README.md CHANGED
@@ -1,140 +1,140 @@
1
- # Open Lyric Plugin Khmer (km-KH)
2
-
3
- Khmer (km-KH) support for the [`open-lyric`](../open-lyric) components: the
4
- NiDA on-screen keyboard, Hunspell spellcheck with Khmer word segmentation, and
5
- Khmer-capable font faces.
6
-
7
- One class per surface, because each surface consumes a different subset:
8
-
9
- | Class | Surface | Contributes |
10
- | ------------------------------------ | ---------- | --------------------------------------------------------------- |
11
- | `EditorPluginKmKh` | `editor` | Fonts, the Hunspell spellcheck spec, the NiDA keyboard (Ctrl+Alt+K), keyboard CSS |
12
- | `OpenLyricMarkdownManagerPluginKmKh` | `markdown` | Khmer-capable fonts + preview font styling |
13
- | `OpenLyricPluginKmKh` | `lyric` | Khmer-capable fonts + preview font styling |
14
-
15
- ## Install
16
-
17
- ```bash
18
- npm i open-lyric open-lyric-plugin-km-kh
19
- ```
20
-
21
- `open-lyric` is a peer dependency — this package contains no copy of it.
22
-
23
- ## Use
24
-
25
- ```js
26
- import { Editor, OpenLyric, OpenLyricMarkdownManager } from 'open-lyric';
27
- import {
28
- EditorPluginKmKh,
29
- OpenLyricMarkdownManagerPluginKmKh,
30
- OpenLyricPluginKmKh,
31
- } from 'open-lyric-plugin-km-kh';
32
-
33
- editor.addPlugin('km-KH', new EditorPluginKmKh());
34
- markdownManager.addPlugin('km-KH', new OpenLyricMarkdownManagerPluginKmKh());
35
- lyricPreview.addPlugin('km-KH', new OpenLyricPluginKmKh());
36
- ```
37
-
38
- `addPlugin` on a surface the class does not declare throws, so a mix-up
39
- surfaces immediately rather than silently doing nothing.
40
-
41
- `EditorPluginKmKh` also exposes `toggleKeyboard()` / `closeKeyboard()` /
42
- `isKeyboardMounted`, mirroring the Ctrl+Alt+K Monaco actions.
43
-
44
- `version` is this package's own version, taken from its `package.json` at build
45
- time. It bumps independently of the core's, so alias one of them when reporting
46
- both:
47
-
48
- ```js
49
- import { version as kmKhVersion } from 'open-lyric-plugin-km-kh';
50
- ```
51
-
52
- ## Module formats
53
-
54
- Ships **ESM and CommonJS**, with per-condition TypeScript declarations:
55
-
56
- | Condition | Code | Types |
57
- | --------- | ---------------- | ------------------ |
58
- | `import` | `dist/index.js` | `dist/index.d.ts` |
59
- | `require` | `dist/index.cjs` | `dist/index.d.cts` |
60
-
61
- Resolve this package through the same condition as `open-lyric` itself. The
62
- core still keeps module-level state, so mixing `import` and `require` across
63
- the two would load two copies of it — see the dual-package note in the
64
- [`open-lyric` README](../open-lyric/README.md#requirements-and-caveats).
65
-
66
- ## What this package bundles
67
-
68
- Everything Khmer ships here, not in `open-lyric`: the Hunspell dictionaries
69
- (`km_KH.aff`/`km_KH.dic` + the suggestion `.aff`), the segmentation-aware
70
- spellcheck worker, the NiDA keyboard and its stylesheet, and the Battambang
71
- `@font-face` sheet with the font files. `EditorPluginKmKh.install()` publishes
72
- the registry data itself, so attaching the plugin is the only thing that
73
- enables Khmer on a host — the core bundle carries none of it.
74
-
75
- What is *not* bundled is the core's stateful shared modules
76
- (`EditorPreferencesStore`, the plugin registry, the dictionary machinery):
77
- `EditorPreferencesStore` must be the same class the application uses, or
78
- keyboard and spellcheck preferences stop being shared. The build redirects
79
- those imports to `open-lyric/internal` (`packages/build-support.ts`). The
80
- redirect list is checked at build time — if an upstream import is renamed and
81
- a mapping stops matching, the build fails rather than silently bundling a
82
- duplicate.
83
-
84
- ## Caveats
85
-
86
- - **Fonts are declarative on preview surfaces.** `contributes.language.fontFaces`
87
- is data the host can read; the previews' font picker is driven by the
88
- component's own `fontFaces` property, which a host assigns.
89
- - **The editor surface contributes no `fontFaces` at all.** Composing km-KH on
90
- an `Editor` must not restyle the text being edited, so Monaco and the
91
- textareas keep their own font and Khmer falls through to the browser's
92
- default face for the script. A host that wants Battambang in the editor asks
93
- for it explicitly: `editor.fontFamily = KM_KH_WEBFONT_FACE` — the face name is
94
- a named export of this package, so no host has to spell `'editor-Battambang'`
95
- itself. (It is also readable from the plugin's `fonts` data, or from the
96
- `--ol-plugin-km-kh-font-family` custom property its stylesheet publishes.)
97
- - **The `@font-face` rules ship with THIS package** (`km_KH_fonts.scss`,
98
- emitted with the Battambang `.ttf` files into `dist/assets`). Every plugin
99
- class contributes the sheet through its `style` slot, so any surface that
100
- composes km-KH — bare embeds included — gets `editor-Battambang` without
101
- loading anything else.
102
- - **`installShellStyle()` declares the faces without attaching the plugin.** A
103
- `style` contribution is scoped to the component it is attached to and goes
104
- away with it, which makes the faces conditional on an attach. A page that
105
- only wants to NAME the face — assigning `fontFamily`/`fontFaces` so the
106
- settings popup offers it, as the standalone preview page entries do — would
107
- otherwise select a face the document never declared and get a silent fallback
108
- to a system Khmer face. So each class also exposes a static:
109
-
110
- ```ts
111
- OpenLyricPluginKmKh.installShellStyle(); // once, at page boot
112
- ```
113
-
114
- Page-lifetime, into `document.head`, no teardown, idempotent — and it shares
115
- a marker with the attach path, so composing the plugin as well still yields
116
- one sheet. It declares the `@font-face` rules and nothing else: a face styles
117
- no element until something names it, whereas `EditorPluginKmKh`'s other sheet
118
- (the NiDA keyboard chrome) does style elements and stays attach-scoped.
119
- - **The spellcheck engine is still page-global** — see the standalone-chrome
120
- notes in `research/editor-structure-implemented.md`.
121
-
122
- ## Build
123
-
124
- From the repo root: `npm run pack -- open-lyric-plugin-km-kh` (build
125
- `open-lyric` first — this package resolves against its `./internal` subpath).
126
-
127
-
128
- ### Releasing to npm
129
-
130
- For maintainers, from a clean `main`:
131
-
132
- ```bash
133
- npm test
134
- npm pack --dry-run # check which files go in the package
135
- npm whoami # run `npm login` if this fails
136
- npm version patch --tag-version-prefix="" # or minor / major
137
- npm publish
138
- git push origin main --follow-tags
139
- npm view open-lyric-plugin-km-kh version # confirm the new version is live
1
+ # Open Lyric Plugin Khmer (km-KH)
2
+
3
+ Khmer (km-KH) support for the [`Open Lyric`](https://github.com/raksa/open-lyric-dist#readme) components: the
4
+ NiDA on-screen keyboard, Hunspell spellcheck with Khmer word segmentation, and
5
+ Khmer-capable font faces.
6
+
7
+ One class per surface, because each surface consumes a different subset:
8
+
9
+ | Class | Surface | Contributes |
10
+ | ------------------------------------ | ---------- | --------------------------------------------------------------- |
11
+ | `EditorPluginKmKh` | `editor` | Fonts, the Hunspell spellcheck spec, the NiDA keyboard (Ctrl+Alt+K), keyboard CSS |
12
+ | `OpenLyricMarkdownManagerPluginKmKh` | `markdown` | Khmer-capable fonts + preview font styling |
13
+ | `OpenLyricPluginKmKh` | `lyric` | Khmer-capable fonts + preview font styling |
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm i open-lyric open-lyric-plugin-km-kh
19
+ ```
20
+
21
+ `open-lyric` is a peer dependency — this package contains no copy of it.
22
+
23
+ ## Use
24
+
25
+ ```js
26
+ import { Editor, OpenLyric, OpenLyricMarkdownManager } from 'open-lyric';
27
+ import {
28
+ EditorPluginKmKh,
29
+ OpenLyricMarkdownManagerPluginKmKh,
30
+ OpenLyricPluginKmKh,
31
+ } from 'open-lyric-plugin-km-kh';
32
+
33
+ editor.addPlugin('km-KH', new EditorPluginKmKh());
34
+ markdownManager.addPlugin('km-KH', new OpenLyricMarkdownManagerPluginKmKh());
35
+ lyricPreview.addPlugin('km-KH', new OpenLyricPluginKmKh());
36
+ ```
37
+
38
+ `addPlugin` on a surface the class does not declare throws, so a mix-up
39
+ surfaces immediately rather than silently doing nothing.
40
+
41
+ `EditorPluginKmKh` also exposes `toggleKeyboard()` / `closeKeyboard()` /
42
+ `isKeyboardMounted`, mirroring the Ctrl+Alt+K Monaco actions.
43
+
44
+ `version` is this package's own version, taken from its `package.json` at build
45
+ time. It bumps independently of the core's, so alias one of them when reporting
46
+ both:
47
+
48
+ ```js
49
+ import { version as kmKhVersion } from 'open-lyric-plugin-km-kh';
50
+ ```
51
+
52
+ ## Module formats
53
+
54
+ Ships **ESM and CommonJS**, with per-condition TypeScript declarations:
55
+
56
+ | Condition | Code | Types |
57
+ | --------- | ---------------- | ------------------ |
58
+ | `import` | `dist/index.js` | `dist/index.d.ts` |
59
+ | `require` | `dist/index.cjs` | `dist/index.d.cts` |
60
+
61
+ Resolve this package through the same condition as `open-lyric` itself. The
62
+ core still keeps module-level state, so mixing `import` and `require` across
63
+ the two would load two copies of it — see the dual-package note in the
64
+ [`Open Lyric` README](https://github.com/raksa/open-lyric-dist#requirements-and-caveats).
65
+
66
+ ## What this package bundles
67
+
68
+ Everything Khmer ships here, not in `open-lyric`: the Hunspell dictionaries
69
+ (`km_KH.aff`/`km_KH.dic` + the suggestion `.aff`), the segmentation-aware
70
+ spellcheck worker, the NiDA keyboard and its stylesheet, and the Battambang
71
+ `@font-face` sheet with the font files. `EditorPluginKmKh.install()` publishes
72
+ the registry data itself, so attaching the plugin is the only thing that
73
+ enables Khmer on a host — the core bundle carries none of it.
74
+
75
+ What is *not* bundled is the core's stateful shared modules
76
+ (`EditorPreferencesStore`, the plugin registry, the dictionary machinery):
77
+ `EditorPreferencesStore` must be the same class the application uses, or
78
+ keyboard and spellcheck preferences stop being shared. The build redirects
79
+ those imports to `open-lyric/internal` (`packages/build-support.ts`). The
80
+ redirect list is checked at build time — if an upstream import is renamed and
81
+ a mapping stops matching, the build fails rather than silently bundling a
82
+ duplicate.
83
+
84
+ ## Caveats
85
+
86
+ - **Fonts are declarative on preview surfaces.** `contributes.language.fontFaces`
87
+ is data the host can read; the previews' font picker is driven by the
88
+ component's own `fontFaces` property, which a host assigns.
89
+ - **The editor surface contributes no `fontFaces` at all.** Composing km-KH on
90
+ an `Editor` must not restyle the text being edited, so Monaco and the
91
+ textareas keep their own font and Khmer falls through to the browser's
92
+ default face for the script. A host that wants Battambang in the editor asks
93
+ for it explicitly: `editor.fontFamily = KM_KH_WEBFONT_FACE` — the face name is
94
+ a named export of this package, so no host has to spell `'editor-Battambang'`
95
+ itself. (It is also readable from the plugin's `fonts` data, or from the
96
+ `--ol-plugin-km-kh-font-family` custom property its stylesheet publishes.)
97
+ - **The `@font-face` rules ship with THIS package** (`km_KH_fonts.scss`,
98
+ emitted with the Battambang `.ttf` files into `dist/assets`). Every plugin
99
+ class contributes the sheet through its `style` slot, so any surface that
100
+ composes km-KH — bare embeds included — gets `editor-Battambang` without
101
+ loading anything else.
102
+ - **`installShellStyle()` declares the faces without attaching the plugin.** A
103
+ `style` contribution is scoped to the component it is attached to and goes
104
+ away with it, which makes the faces conditional on an attach. A page that
105
+ only wants to NAME the face — assigning `fontFamily`/`fontFaces` so the
106
+ settings popup offers it, as the standalone preview page entries do — would
107
+ otherwise select a face the document never declared and get a silent fallback
108
+ to a system Khmer face. So each class also exposes a static:
109
+
110
+ ```ts
111
+ OpenLyricPluginKmKh.installShellStyle(); // once, at page boot
112
+ ```
113
+
114
+ Page-lifetime, into `document.head`, no teardown, idempotent — and it shares
115
+ a marker with the attach path, so composing the plugin as well still yields
116
+ one sheet. It declares the `@font-face` rules and nothing else: a face styles
117
+ no element until something names it, whereas `EditorPluginKmKh`'s other sheet
118
+ (the NiDA keyboard chrome) does style elements and stays attach-scoped.
119
+ - **The spellcheck engine is still page-global** — see the standalone-chrome
120
+ notes in `research/editor-structure-implemented.md`.
121
+
122
+ ## Build
123
+
124
+ From the repo root: `npm run pack -- open-lyric-plugin-km-kh` (build
125
+ `open-lyric` first — this package resolves against its `./internal` subpath).
126
+
127
+
128
+ ### Releasing to npm
129
+
130
+ For maintainers, from a clean `main`:
131
+
132
+ ```bash
133
+ npm test
134
+ npm pack --dry-run # check which files go in the package
135
+ npm whoami # run `npm login` if this fails
136
+ npm version patch --tag-version-prefix="" # or minor / major
137
+ npm publish
138
+ git push origin main --follow-tags
139
+ npm view open-lyric-plugin-km-kh version # confirm the new version is live
140
140
  ```
package/dist/index.cjs CHANGED
@@ -37,79 +37,79 @@ Use this example to test Khmer and English line pairs in the same Open Lyric dra
37
37
  \`\`\`ol:Outro
38
38
  | D | A/C# | Bm7 | G | D |
39
39
  \`\`\`
40
- `,s=`# ព្រះគុណនៅព្រឹកនេះ\r
41
- \r
42
- Use this example to test Khmer-only Open Lyric sections with a simple worship flow.\r
43
- \r
44
- \`\`\`ol:Config\r
45
- - Title: ព្រះគុណនៅព្រឹកនេះ\r
46
- - Subtitle: ព្រឹកនេះ Sub-Title\r
47
- - Artist: Open Lyric Khmer Plugin\r
48
- - Copyright: 2026 Open Lyric\r
49
- - Key: G\r
50
- - Tempo: 76bpm\r
51
- - Locales: en-US, km-KH\r
52
- - Time: 4/4\r
53
- - Structure: IV1CV2CO\r
54
- - Strumming Patterns:\r
55
- // Slow rolling pulse\r
56
- d--u-- | d-u-d-\r
57
- // Lift on the chorus\r
58
- ddu--u | d-d-du\r
59
- - Attachments:\r
60
- https://example.com/audio/quiet-river-demo.mp3\r
61
- [Piano Chart](file:///C:/Charts/quiet-river-at-dawn.pdf)\r
62
- https://youtu.be/ZSsOrph7rJs?list=RDZSsOrph7rJs\r
63
- https://youtu.be/ZSsOrph7rJs?list=RDZSsOrph7rJs\r
64
- https://www.openworship.app/shared/images/Blue.png\r
65
- https://www.openworship.app/shared/videos/Pink%20motion.mp4\r
66
- https://www.openworship.app/shared/audios/Doxology%2021&22.mp3\r
67
- https://davesguitarplanet.com/wp-content/uploads/-lyrics/PDFs/Blackbird.pdf\r
68
- https://www.openworship.app/shared\r
69
- \`\`\`\r
70
- \r
71
- \`\`\`ol:Intro\r
72
- {: #1 } | G | D/F# | Em | C | (2x)\r
73
- \r
74
- \r
75
- ពេលខ្ញុំអស់កម្លាំងទ្រង់ជាកម្លាំងថ្មី\r
76
- ពេលខ្ញុំភ័យខ្លាចទ្រង់នាំឲ្យមានសង្ឃឹម\r
77
- \r
78
- \`\`\`\r
79
- \r
80
- \`\`\`ol:Verse 1\r
81
- ព្រះគុណទ្រង់ថ្មីរៀងរាល់ព្រឹក\r
82
- ចិត្តខ្ញុំសរសើរព្រះនាមទ្រង់\r
83
- \r
84
- // this is comment\r
85
- \`\`\`\r
86
- \r
87
- \`\`\`ol:Chorus\r
88
- |[G]ព្រះអង្គល្អគ្រប់[D/F#]ពេលវេលា\r
89
- |[Em]ខ្ញុំសូមថ្វាយសិរី[C]ល្អដល់ទ្រង់\r
90
- |[G]សេចក្ដីស្រឡាញ់មិន[D/F#]ចេះបញ្ចប់\r
91
- |[Em]ព្រះយេស៊ូវទ្រង់នៅជា[C]មួយខ្ញុំ\r
92
- \`\`\`\r
93
- \r
94
- \`\`\`ol:Verse 2\r
95
- ពេលខ្ញុំអស់កម្លាំងទ្រង់ជាកម្លាំងថ្មី\r
96
- ពេលខ្ញុំភ័យខ្លាចទ្រង់នាំឲ្យមានសង្ឃឹម\r
97
- \`\`\`\r
98
- \r
99
- \`\`\`ol:Note 1\r
100
- |[C#m]Jesus, You carried my [B/D#]burden\r
101
- |[E]far beyond the reach of night\r
102
- |[C#m]Jesus, You opened my [B/D#]future\r
103
- |[E]with resurrection light\r
104
- \`\`\`\r
105
- \r
106
- \`\`\`ol:Outro\r
107
- | G | D/F# | Em | C | G |\r
108
- \`\`\`\r
40
+ `,s=`# ព្រះគុណនៅព្រឹកនេះ
41
+
42
+ Use this example to test Khmer-only Open Lyric sections with a simple worship flow.
43
+
44
+ \`\`\`ol:Config
45
+ - Title: ព្រះគុណនៅព្រឹកនេះ
46
+ - Subtitle: ព្រឹកនេះ Sub-Title
47
+ - Artist: Open Lyric Khmer Plugin
48
+ - Copyright: 2026 Open Lyric
49
+ - Key: G
50
+ - Tempo: 76bpm
51
+ - Locales: en-US, km-KH
52
+ - Time: 4/4
53
+ - Structure: IV1CV2CO
54
+ - Strumming Patterns:
55
+ // Slow rolling pulse
56
+ d--u-- | d-u-d-
57
+ // Lift on the chorus
58
+ ddu--u | d-d-du
59
+ - Attachments:
60
+ https://example.com/audio/quiet-river-demo.mp3
61
+ [Piano Chart](file:///C:/Charts/quiet-river-at-dawn.pdf)
62
+ https://youtu.be/ZSsOrph7rJs?list=RDZSsOrph7rJs
63
+ https://youtu.be/ZSsOrph7rJs?list=RDZSsOrph7rJs
64
+ https://www.openworship.app/shared/images/Blue.png
65
+ https://www.openworship.app/shared/videos/Pink%20motion.mp4
66
+ https://www.openworship.app/shared/audios/Doxology%2021&22.mp3
67
+ https://davesguitarplanet.com/wp-content/uploads/-lyrics/PDFs/Blackbird.pdf
68
+ https://www.openworship.app/shared
69
+ \`\`\`
70
+
71
+ \`\`\`ol:Intro
72
+ {p: #1} | G | D/F# | Em | C | (2x)
73
+
74
+
75
+ ពេលខ្ញុំអស់កម្លាំងទ្រង់ជាកម្លាំងថ្មី
76
+ ពេលខ្ញុំភ័យខ្លាចទ្រង់នាំឲ្យមានសង្ឃឹម
77
+
78
+ \`\`\`
79
+
80
+ \`\`\`ol:Verse 1
81
+ ព្រះគុណទ្រង់ថ្មីរៀងរាល់ព្រឹក
82
+ ចិត្តខ្ញុំសរសើរព្រះនាមទ្រង់
83
+
84
+ // this is comment
85
+ \`\`\`
86
+
87
+ \`\`\`ol:Chorus
88
+ |[G]ព្រះអង្គល្អគ្រប់[D/F#]ពេលវេលា
89
+ |[Em]ខ្ញុំសូមថ្វាយសិរី[C]ល្អដល់ទ្រង់
90
+ |[G]សេចក្ដីស្រឡាញ់មិន[D/F#]ចេះបញ្ចប់
91
+ |[Em]ព្រះយេស៊ូវទ្រង់នៅជា[C]មួយខ្ញុំ
92
+ \`\`\`
93
+
94
+ \`\`\`ol:Verse 2
95
+ ពេលខ្ញុំអស់កម្លាំងទ្រង់ជាកម្លាំងថ្មី
96
+ ពេលខ្ញុំភ័យខ្លាចទ្រង់នាំឲ្យមានសង្ឃឹម
97
+ \`\`\`
98
+
99
+ \`\`\`ol:Note 1
100
+ |[C#m]Jesus, You carried my [B/D#]burden
101
+ |[E]far beyond the reach of night
102
+ |[C#m]Jesus, You opened my [B/D#]future
103
+ |[E]with resurrection light
104
+ \`\`\`
105
+
106
+ \`\`\`ol:Outro
107
+ | G | D/F# | Em | C | G |
108
+ \`\`\`
109
109
  `,c=o,l=`debug`,u=globalThis;function d(){return new URLSearchParams(globalThis.location?.search||``).get(l)?.trim().toLowerCase()===`true`}function f(){return!!u.__openLyricE2E||d()}function p(e,...t){if(!f()||!t.length)return;let[n,...r]=t;if(typeof n==`string`){let t=n.startsWith(`[Editor timing]`)?n:`[Editor timing] ${n}`;e.call(console,t,...r);return}e.call(console,`[Editor timing]`,n,...r)}var m=new Map,h=`​`,g=/android|ios|iphone|ipad|ipod/iu,_=/android|iphone|ipad|ipod/iu,v=/macintosh/iu,y=/\u1780\*\*/gu,b=`ក្ត`;function x(){return typeof globalThis.performance?.now==`function`?globalThis.performance.now():Date.now()}function S(e,t,n=``){let r=x()-t;return p(console.info,`provider ${e}: ${r.toFixed(1)}ms${n?` ${n}`:``}`),r}function C(e=globalThis.navigator){if(!e)return!1;let t=String(e.userAgentData?.platform||e.platform||``);if(g.test(t))return!0;let n=String(e.userAgent||``);if(_.test(n))return!0;let r=Number(e.maxTouchPoints||0);return v.test(n)&&r>1}function ee(e){let t=String(e||``);return!t||!C()?t:t.replace(y,b)}function w(e){return e?[e.dictionaryName,e.affUrl,e.dicUrl].join(`::`):``}function T(t){let n=w(t);return n?(m.has(n)||m.set(n,(0,e.loadDictionary)(t).then(t=>{let r=(0,e.createDictionarySnapshot)(t);return r||m.delete(n),r}).catch(e=>{throw m.delete(n),e})),m.get(n)||Promise.resolve(null)):Promise.resolve(null)}function te(t={}){let n=new Map,r=typeof t.createWorker==`function`?t.createWorker:null,i=(0,e.getDictionaryConfig)(t),a=(0,e.getSuggestionDictionaryConfigs)(t),o=new Map,s=new Map,c=null,l=new Map,u=new Map,d=y(`validation`,{dictionaryConfig:i,useDictionarySnapshot:!0}),f=y(`auxiliary`,{dictionaryConfig:i,suggestDictionaryConfigs:a}),p=y(`segmentation`,{dictionaryConfig:i});function m(t){return(0,e.normalizeWord)(t,`km`)}function g(e){let t=e.flags.includes(`g`)?e.flags:`${e.flags}g`;return new RegExp(e.source,t)}function _(e){return String(e||``).split(h).filter(Boolean).map(e=>`${e}${h}`).join(``)}function v(t){let n=m(t);return!!(n&&(0,e.hasAnyWordBaseCharacter)(n))}function y(e,t={}){return{channelLabel:e,dictionaryConfig:t.dictionaryConfig||null,errorHandler:null,initializePromise:null,messageHandler:null,pendingRequests:new Map,ready:!1,requestId:0,suggestDictionaryConfigs:Array.isArray(t.suggestDictionaryConfigs)?t.suggestDictionaryConfigs:[],useDictionarySnapshot:!!t.useDictionarySnapshot,worker:null}}function b(e,t){e.pendingRequests.forEach(({reject:e})=>e(t)),e.pendingRequests.clear()}function C(e){e?.worker&&(e.worker.removeEventListener(`message`,e.messageHandler),e.worker.removeEventListener(`error`,e.errorHandler),e.worker.terminate(),e.worker=null,e.messageHandler=null,e.errorHandler=null,e.initializePromise=null,e.ready=!1)}function w(e,t){let{id:n,result:r,error:i}=t?.data||{},a=e.pendingRequests.get(n);if(a){if(e.pendingRequests.delete(n),i){a.reject(Error(i));return}a.resolve(r)}}function te(e,t){let n=t?.error instanceof Error?t.error:Error(t?.message||`Khmer spellcheck worker failed.`);console.error(`Khmer spellcheck worker failed (${e.channelLabel}).`,n),C(e),b(e,n)}function E(e){if(e.worker)return e.worker;let t=r?.(e.channelLabel)||new Worker(new URL(``+(typeof document>`u`?require("url").pathToFileURL(__dirname+`/assets/spellcheck-khmer.worker-CRDoN93Y.js`).href:new URL(`assets/spellcheck-khmer.worker-CRDoN93Y.js`,document.currentScript&&document.currentScript.tagName.toUpperCase()===`SCRIPT`&&document.currentScript.src||document.baseURI).href),``+{}.url),{type:`module`});if(!t||typeof t.postMessage!=`function`||typeof t.addEventListener!=`function`||typeof t.removeEventListener!=`function`||typeof t.terminate!=`function`)throw TypeError(`Khmer spellcheck worker factory must return a Worker-like object for ${e.channelLabel}.`);return e.messageHandler=t=>{w(e,t)},e.errorHandler=t=>{te(e,t)},t.addEventListener(`message`,e.messageHandler),t.addEventListener(`error`,e.errorHandler),e.worker=t,e.worker}function D(e,t,n={}){let r=E(e),i=`khmer-spellcheck-${e.channelLabel}-${e.requestId+1}`;return e.requestId+=1,new Promise((a,o)=>{e.pendingRequests.set(i,{resolve:a,reject:o}),r.postMessage({id:i,payload:n,type:t})})}async function ne(e){if(e.ready)return!0;if(!e.dictionaryConfig)return console.error(`Khmer spellcheck dictionary configuration is missing.`),!1;if(!e.initializePromise){let t=x(),n=0,r=0;e.initializePromise=Promise.resolve().then(async()=>{if(!e.useDictionarySnapshot)return null;let t=x(),r=await T(e.dictionaryConfig);return n=x()-t,r||(console.error(`Khmer spellcheck dictionary snapshot could not be prepared.`),null)}).then(t=>{if(e.useDictionarySnapshot&&!t)return{ready:!1};let n=x(),i={dictionaryConfig:e.dictionaryConfig};t&&(i.dictionaryData=t),e.suggestDictionaryConfigs.length&&(i.suggestDictionaryConfigs=e.suggestDictionaryConfigs);let a=D(e,`initialize`,i);return r=x()-n,a}).then(i=>(e.ready=!!i?.ready,e.ready||(e.initializePromise=null),S(`initialize`,t,`channel=${e.channelLabel} ready=${String(e.ready)} payload=${e.useDictionarySnapshot?`snapshot`:`config`} snapshotLoad=${n.toFixed(1)}ms dispatch=${r.toFixed(1)}ms`),e.ready)).catch(i=>(console.error(`Failed to initialize Khmer spellcheck worker (${e.channelLabel}).`,i),S(`initialize`,t,`channel=${e.channelLabel} ready=false payload=${e.useDictionarySnapshot?`snapshot`:`config`} snapshotLoad=${n.toFixed(1)}ms dispatch=${r.toFixed(1)}ms`),e.initializePromise=null,e.ready=!1,!1))}return e.initializePromise}function O(){return ne(d)}function re(){return ne(f)}function ie(){return ne(p)}async function ae(){if(c)return c;let e=(a.length?a:[i]).filter(Boolean);return c=Promise.allSettled(e.map(e=>T(e))).then(e=>e.filter(e=>e.status===`fulfilled`&&e.value?.loaded).map(e=>e.value)),c}async function oe(t){let r=x(),i=new Map,a=Array.from(new Set(t)),o=new Set,s=new Map,c=0;if(!a.length)return S(`checkWords`,r,`words=0`),i;a.forEach(t=>{let r=m(t);if(s.set(t,r),!r||!(0,e.hasAnyWordBaseCharacter)(r)){i.set(t,!0),c+=1;return}if(n.has(r)){i.set(t,n.get(r)??!0);return}o.add(r)});let l=a.length-c-o.size;if(!o.size)return S(`checkWords`,r,`words=${a.length} lookup=0 cacheHits=${l} skipped=${c}`),i;if(!await O())return a.forEach(e=>{i.has(e)||i.set(e,!0)}),S(`checkWords`,r,`words=${a.length} lookup=${o.size} cacheHits=${l} skipped=${c} ready=false`),i;let u=await D(d,`checkWords`,{words:Array.from(o)});return Object.entries(u||{}).forEach(([e,t])=>{n.set(e,!!t)}),a.forEach(e=>{if(i.has(e))return;let t=s.get(e);i.set(e,n.get(t)??!0)}),S(`checkWords`,r,`words=${a.length} lookup=${o.size} cacheHits=${l} skipped=${c}`),i}async function se(t){let n=m(t),r=x(),i=Array.from(n||``).length;if(!n||!(0,e.hasAnyWordBaseCharacter)(n))return[];if(u.has(n)){let e=u.get(n)||[];return S(`suggest`,r,`channel=${f.channelLabel} cache=hit suggestions=${e.length} chars=${i}`),e}if(!await re())return S(`suggest`,r,`channel=${f.channelLabel} cache=miss suggestions=0 chars=${i} ready=false`),[];let a=await D(f,`suggest`,{limit:3,word:n}),o=Array.isArray(a)?a:[];return u.set(n,o),S(`suggest`,r,`channel=${f.channelLabel} cache=miss suggestions=${o.length} chars=${i}`),o}async function ce(t,n=8){let r=m(t),i=Math.max(1,Number(n)||8);if(!r||!(0,e.hasAnyWordBaseCharacter)(r))return[];let a=`${r}::${i}`;if(l.has(a))return l.get(a)||[];let o=await ae(),s=(0,e.getDictionaryPrefixSuggestions)(o,r,i);return l.set(a,s),s}async function k(t){let n=m(t),r=x(),i=Array.from(n||``).length;if(!n||!(0,e.hasAnyWordBaseCharacter)(n))return``;if(s.has(n)){let e=s.get(n)||``;return S(`segment`,r,`channel=${p.channelLabel} cache=hit found=${String(!!e)} chars=${i}`),e}if(o.has(n)){let e=o.get(n);return S(`segment`,r,`channel=${p.channelLabel} cache=pending chars=${i}`),e}let a=(async()=>{if(!await ie())return S(`segment`,r,`channel=${p.channelLabel} cache=miss found=false chars=${i} ready=false`),``;let e=await D(p,`segment`,{word:n}),t=typeof e==`string`?e:``;return s.set(n,t),S(`segment`,r,`channel=${p.channelLabel} cache=miss found=${String(!!t)} chars=${i}`),t})();o.set(n,a);try{return await a}finally{o.delete(n)}}async function le(e,n={}){let r=ee(e),i=n?.specification?.wordPattern instanceof RegExp?n.specification.wordPattern:t.wordPattern instanceof RegExp?t.wordPattern:null;if(!r||!(i instanceof RegExp))return r;let a=Array.from(r.matchAll(g(i)));if(!a.length)return r;let o=Array.from(new Set(a.map(e=>e?.[0]??``).filter(Boolean))),s=await oe(o),c=new Map;await Promise.all(o.map(async e=>{let t=e;if(!(s.get(e)??!0)){let n=await k(e);n&&(t=n)}c.set(e,_(t)||e)}));let l=``,u=0;return a.forEach(e=>{let t=e?.[0]??``,n=Number(e?.index);if(!t||!Number.isInteger(n)||n<u)return;let i=c.get(t)||t,a=n+t.length;l+=r.slice(u,n),l+=i,i.endsWith(h)&&r.charAt(a)===h&&(a+=1),u=a}),l+=r.slice(u),l}function ue(){let e=Error(`Khmer spellcheck provider disposed.`);b(d,e),b(f,e),b(p,e),C(d),C(f),C(p),o.clear(),n.clear(),l.clear(),c=null,s.clear(),u.clear()}return{languageCode:`km`,checkWords:oe,dispose:ue,getPrefixSuggestions:ce,getSegmentationSuggestion:k,getSuggestions:se,initialize:O,isReady:()=>d.ready,postProcessTranscriptText:le,shouldCheckWord:v}}var E=typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},D={base:`Normal`,shift:`Shift`,alt:`Alt / Option`,altShift:`Alt + Shift`},ne=[{mode:`base`,prefix:``},{mode:`shift`,prefix:`⇧`},{mode:`alt`,prefix:`Alt`},{mode:`altShift`,prefix:`Alt+⇧`}],O=`editor.action.triggerSuggest`,re=4,ie=.12,ae=`◌`,oe=/[\u1780-\u17B3]/u,se=/[\u17B4-\u17D3]/u,ce={"​":`ZWSP`,"\xA0":`NBSP`," ":`Space`," ":`Tab`,"\n":`Enter`},k={Backquote:"`",Digit1:`1`,Digit2:`2`,Digit3:`3`,Digit4:`4`,Digit5:`5`,Digit6:`6`,Digit7:`7`,Digit8:`8`,Digit9:`9`,Digit0:`0`,Minus:`-`,Equal:`=`,KeyQ:`Q`,KeyW:`W`,KeyE:`E`,KeyR:`R`,KeyT:`T`,KeyY:`Y`,KeyU:`U`,KeyI:`I`,KeyO:`O`,KeyP:`P`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,KeyA:`A`,KeyS:`S`,KeyD:`D`,KeyF:`F`,KeyG:`G`,KeyH:`H`,KeyJ:`J`,KeyK:`K`,KeyL:`L`,Semicolon:`;`,Quote:`'`,KeyZ:`Z`,KeyX:`X`,KeyC:`C`,KeyV:`V`,KeyB:`B`,KeyN:`N`,KeyM:`M`,Comma:`,`,Period:`.`,Slash:`/`,Space:`Space`},le={base:{Backquote:`«`,Digit1:`១`,Digit2:`២`,Digit3:`៣`,Digit4:`៤`,Digit5:`៥`,Digit6:`៦`,Digit7:`៧`,Digit8:`៨`,Digit9:`៩`,Digit0:`០`,Minus:`ឥ`,Equal:`ឲ`,KeyQ:`ឆ`,KeyW:`ឹ`,KeyE:`េ`,KeyR:`រ`,KeyT:`ត`,KeyY:`យ`,KeyU:`ុ`,KeyI:`ិ`,KeyO:`ោ`,KeyP:`ផ`,BracketLeft:`ៀ`,BracketRight:`ឪ`,Backslash:`ឮ`,KeyA:`ា`,KeyS:`ស`,KeyD:`ដ`,KeyF:`ថ`,KeyG:`ង`,KeyH:`ហ`,KeyJ:`្`,KeyK:`ក`,KeyL:`ល`,Semicolon:`ើ`,Quote:`់`,KeyZ:`ឋ`,KeyX:`ខ`,KeyC:`ច`,KeyV:`វ`,KeyB:`ប`,KeyN:`ន`,KeyM:`ម`,Comma:`ុំ`,Period:`។`,Slash:`៊`,Space:`​`},shift:{Backquote:`»`,Digit1:`!`,Digit2:`ៗ`,Digit3:`"`,Digit4:`៛`,Digit5:`%`,Digit6:`៍`,Digit7:`័`,Digit8:`៏`,Digit9:`(`,Digit0:`)`,Minus:`៌`,Equal:`ឱ`,KeyQ:`ឈ`,KeyW:`ឺ`,KeyE:`ែ`,KeyR:`ឬ`,KeyT:`ទ`,KeyY:`ួ`,KeyU:`ូ`,KeyI:`ី`,KeyO:`ៅ`,KeyP:`ភ`,BracketLeft:`ឿ`,BracketRight:`ឧ`,Backslash:`ឭ`,KeyA:`ាំ`,KeyS:`ៃ`,KeyD:`ឌ`,KeyF:`ធ`,KeyG:`អ`,KeyH:`ះ`,KeyJ:`ញ`,KeyK:`គ`,KeyL:`ឡ`,Semicolon:`ោះ`,Quote:`៉`,KeyZ:`ឍ`,KeyX:`ឃ`,KeyC:`ជ`,KeyV:`េះ`,KeyB:`ព`,KeyN:`ណ`,KeyM:`ំ`,Comma:`ុះ`,Period:`៕`,Slash:`?`,Space:` `},alt:{Backquote:`។ល។`,Digit1:`‌`,Digit2:`@`,Digit3:`៑`,Digit4:`$`,Digit5:`ៜ`,Digit6:`៙`,Digit7:`៚`,Digit8:`*`,Digit9:`{`,Digit0:`}`,Minus:`៝`,Equal:`៎`,KeyE:`ឯ`,KeyR:`ឫ`,BracketLeft:`ឩ`,BracketRight:`ឳ`,KeyI:`ឦ`,KeyP:`ឰ`,Backslash:`\\`,KeyK:`ឝ`,KeyL:`:`,Semicolon:`៖`,Quote:`ៈ`,KeyB:`ឞ`,Comma:`,`,Period:`.`,Slash:`/`,Space:`\xA0`},altShift:{KeyQ:`᧠`,KeyW:`᧡`,KeyE:`᧢`,KeyR:`᧣`,KeyT:`᧤`,KeyY:`᧥`,KeyU:`᧦`,KeyI:`᧧`,KeyO:`᧨`,KeyP:`᧩`,BracketLeft:`᧪`,KeyA:`᧫`,KeyS:`᧬`,KeyD:`᧭`,KeyF:`᧮`,KeyG:`᧯`,KeyH:`᧰`,KeyJ:`᧱`,KeyK:`᧲`,KeyL:`᧳`,Semicolon:`᧴`,Quote:`᧵`,KeyZ:`᧶`,KeyX:`᧷`,KeyC:`᧸`,KeyV:`᧹`,KeyB:`᧺`,KeyN:`᧻`,KeyM:`᧼`,Comma:`᧽`,Period:`᧾`,Slash:`᧿`,Space:`\xA0`}},ue={Backquote:"`",Digit1:`1`,Digit2:`2`,Digit3:`3`,Digit4:`4`,Digit5:`5`,Digit6:`6`,Digit7:`7`,Digit8:`8`,Digit9:`9`,Digit0:`0`,Minus:`-`,Equal:`=`,KeyQ:`q`,KeyW:`w`,KeyE:`e`,KeyR:`r`,KeyT:`t`,KeyY:`y`,KeyU:`u`,KeyI:`i`,KeyO:`o`,KeyP:`p`,BracketLeft:`[`,BracketRight:`]`,Backslash:`\\`,KeyA:`a`,KeyS:`s`,KeyD:`d`,KeyF:`f`,KeyG:`g`,KeyH:`h`,KeyJ:`j`,KeyK:`k`,KeyL:`l`,Semicolon:`;`,Quote:`'`,KeyZ:`z`,KeyX:`x`,KeyC:`c`,KeyV:`v`,KeyB:`b`,KeyN:`n`,KeyM:`m`,Comma:`,`,Period:`.`,Slash:`/`,Space:` `},de={Backquote:`~`,Digit1:`!`,Digit2:`@`,Digit3:`#`,Digit4:`$`,Digit5:`%`,Digit6:`^`,Digit7:`&`,Digit8:`*`,Digit9:`(`,Digit0:`)`,Minus:`_`,Equal:`+`,KeyQ:`Q`,KeyW:`W`,KeyE:`E`,KeyR:`R`,KeyT:`T`,KeyY:`Y`,KeyU:`U`,KeyI:`I`,KeyO:`O`,KeyP:`P`,BracketLeft:`{`,BracketRight:`}`,Backslash:`|`,KeyA:`A`,KeyS:`S`,KeyD:`D`,KeyF:`F`,KeyG:`G`,KeyH:`H`,KeyJ:`J`,KeyK:`K`,KeyL:`L`,Semicolon:`:`,Quote:`"`,KeyZ:`Z`,KeyX:`X`,KeyC:`C`,KeyV:`V`,KeyB:`B`,KeyN:`N`,KeyM:`M`,Comma:`<`,Period:`>`,Slash:`?`,Space:` `},fe={base:ue,shift:de,alt:{...ue},altShift:{...de}},pe=[{id:`khmer`,footerText:`NiDA layout with default zero-width space behavior for Khmer word breaks.`,menuLabel:`Khmer NiDA`,title:`អក្សរខ្មែរ NiDA`,titleLang:`km`,triggerLabel:`Khmer`,usesNativePhysicalKeyboard:!1,visibleZwspLabel:`ចន្លោះមើលមិនឃើញ`,keyLayouts:le},{id:`english`,footerText:`US layout on-screen. Physical typing uses your system's US-International behavior.`,menuLabel:`English (US)`,title:`English (US)`,titleLang:`en`,triggerLabel:`English`,usesNativePhysicalKeyboard:!0,keyLayouts:fe}],me=pe[0].id,A=Object.freeze(Object.fromEntries(pe.map(e=>[e.id,e]))),he=[[{code:`Backquote`},{code:`Digit1`},{code:`Digit2`},{code:`Digit3`},{code:`Digit4`},{code:`Digit5`},{code:`Digit6`},{code:`Digit7`},{code:`Digit8`},{code:`Digit9`},{code:`Digit0`},{code:`Minus`},{code:`Equal`},{action:`Backspace`,label:`⌫`,ariaLabel:`Backspace`,width:`backspace`}],[{spacer:`indent`},{code:`KeyQ`},{code:`KeyW`},{code:`KeyE`},{code:`KeyR`},{code:`KeyT`},{code:`KeyY`},{code:`KeyU`},{code:`KeyI`},{code:`KeyO`},{code:`KeyP`},{code:`BracketLeft`},{code:`BracketRight`},{code:`Backslash`}],[{toggle:`Caps`,label:`⌂`,ariaLabel:`Caps lock`,width:`caps`},{code:`KeyA`},{code:`KeyS`},{code:`KeyD`},{code:`KeyF`},{code:`KeyG`},{code:`KeyH`},{code:`KeyJ`},{code:`KeyK`},{code:`KeyL`},{code:`Semicolon`},{code:`Quote`},{action:`Enter`,label:`Enter`,ariaLabel:`Enter`,width:`enter`}],[{toggle:`Shift`,label:`⇧`,ariaLabel:`Shift`,width:`shift`},{code:`KeyZ`},{code:`KeyX`},{code:`KeyC`},{code:`KeyV`},{code:`KeyB`},{code:`KeyN`},{code:`KeyM`},{code:`Comma`},{code:`Period`},{code:`Slash`},{toggle:`Shift`,label:`⇧`,ariaLabel:`Shift`,width:`shift`}],[{toggle:`Alt`,label:`Alt`,ariaLabel:`Alt`,width:`alt`},{code:`Space`,width:`space`,variant:`spacebar`},{toggle:`Alt`,label:`Alt`,ariaLabel:`Alt`,width:`alt`}]],ge=new Set(he.flatMap(e=>e.map(e=>e.code).filter(Boolean)).concat([`Backspace`,`Enter`,`Tab`]));function j(e,t,n){return Math.min(Math.max(e,t),n)}function M(e,t){return!!(e&&typeof e.closest==`function`&&e.closest(t))}function N(e,t){return!!(e&&t&&typeof e.contains==`function`&&e.contains(t))}function _e(e){return typeof e?.requestAnimationFrame==`function`?e.requestAnimationFrame.bind(e):t=>e.setTimeout(t,0)}function P(e,t){if(!t)throw Error(`Khmer NiDA keyboard requires ${e}.`);return t}function ve(e=me){return A[e]??A[me]}function ye(e){let t=e&&typeof e==`object`?e:{},n=t.position&&typeof t.position==`object`?t.position:null,r=t.size&&typeof t.size==`object`?t.size:null,i=Number(n?.left),a=Number(n?.top),o=Number(r?.width),s=Number(r?.height);return{isMinimized:!!t.isMinimized,isOpen:!!t.isOpen,position:Number.isFinite(i)&&Number.isFinite(a)?{left:Math.round(i),top:Math.round(a)}:null,size:Number.isFinite(o)&&o>0&&Number.isFinite(s)&&s>0?{height:Math.round(s),width:Math.round(o)}:null}}function be(){return{isOpen:!1,isMinimized:!1,isLayoutMenuOpen:!1,layoutId:me,armedShift:!1,latchedCaps:!1,physicalCapsLock:!1,latchedAlt:!1,pressedShift:!1,pressedAlt:!1,pressedCodes:new Set,position:null,size:{initialized:!1,baseWidth:0,baseHeight:0,expandedWidth:0,expandedHeight:0},resize:{pointerId:null,startX:0,startY:0,startWidth:0,startHeight:0,hasMoved:!1},drag:{pointerId:null,startX:0,startY:0,originLeft:0,originTop:0,hasMoved:!1}}}function xe(e){let t=P(`inputElement`,e),n=t.ownerDocument,r=n?.defaultView??E;function i(){if(typeof t.selectionStart!=`number`&&typeof t.setSelectionRange==`function`){let e=String(t.value??``).length;t.setSelectionRange(e,e)}}function a(){t.focus({preventScroll:!0}),i()}function o(e=`insertText`,n=null){if(typeof r.InputEvent==`function`){t.dispatchEvent(new r.InputEvent(`input`,{bubbles:!0,inputType:e,data:n}));return}t.dispatchEvent(new r.Event(`input`,{bubbles:!0}))}function s(e,t=null){if(typeof n?.execCommand!=`function`)return!1;try{return n.execCommand(e,!1,t)}catch{return!1}}function c(e,n,r,i,a=null){t.setRangeText(e,n,r,`end`),o(i,a)}function l(){let e=String(t.value??``).length;return{direction:typeof t.selectionDirection==`string`?t.selectionDirection:`none`,start:t.selectionStart??e,end:t.selectionEnd??e}}function u(e,t,n,r){return t===n?{activePosition:t,anchorPosition:t}:r===`forward`?{activePosition:n,anchorPosition:t}:r===`backward`||e===`left`||e===`up`?{activePosition:t,anchorPosition:n}:{activePosition:n,anchorPosition:t}}function d(e,t){if(t<=0)return 0;let n=e.lastIndexOf(`
110
110
  `,t-1);return n===-1?0:n+1}function f(e,t){let n=e.indexOf(`
111
111
  `,t);return n===-1?e.length:n}function p(e,n){let r=t.selectionStart??String(t.value??``).length,i=t.selectionEnd??String(t.value??``).length;return t.setSelectionRange(e,n),s(`delete`)?!0:(t.setSelectionRange(r,i),!1)}function m(e){a(),!s(`insertText`,e)&&c(e,t.selectionStart??String(t.value??``).length,t.selectionEnd??String(t.value??``).length,e===`
112
112
  `?`insertLineBreak`:`insertText`,e)}function h(){a();let e=t.selectionStart??String(t.value??``).length,n=t.selectionEnd??String(t.value??``).length;if(e!==n){if(p(e,n))return;c(``,e,n,`deleteContentBackward`);return}e<=0||p(e-1,e)||c(``,e-1,e,`deleteContentBackward`)}function g(e,t,n){if(t===`left`)return Math.max(0,n-1);if(t===`right`)return Math.min(e.length,n+1);if(t!==`up`&&t!==`down`)return n;let r=d(e,n),i=f(e,n),a=n-r;if(t===`up`){if(r===0)return n;let t=r-1,i=d(e,t);return i+Math.min(a,t-i)}if(i===e.length)return n;let o=i+1,s=f(e,o);return o+Math.min(a,s-o)}function _(e,n={}){a();let r=String(t.value??``),{direction:i,start:o,end:s}=l(),c=o!==s;if(n.selectRange){let{activePosition:n,anchorPosition:a}=u(e,o,s,i),c=g(r,e,n);if(c===a){t.setSelectionRange(a,a,`none`);return}t.setSelectionRange(Math.min(a,c),Math.max(a,c),c<a?`backward`:`forward`);return}let d=o;e===`left`?d=c?Math.min(o,s):Math.max(0,o-1):e===`right`?d=c?Math.max(o,s):Math.min(r.length,s+1):(e===`up`||e===`down`)&&(d=g(r,e,c&&e===`down`?Math.max(o,s):Math.min(o,s))),t.setSelectionRange(d,d,`none`)}function v(){return n?.activeElement===t}function y(e){return v()||e.target===t}function b(e){return e===t}return{kind:`native-text-input`,acceptSelectedSuggestionIfVisible(){return!1},focus:a,insertText:m,deleteBackward:h,moveCursor:_,isFocused:v,ownsPhysicalKeyboardEvent:y,containsNode:b,destroy(){}}}function Se(e,t={}){if(!e||typeof e.focus!=`function`||typeof e.trigger!=`function`)throw Error(`Khmer NiDA Monaco adapter requires a Monaco editor instance.`);let n=t.source??`khmer-nida-keyboard`,r=t.domNode??e.getDomNode?.()??null,i=r?.ownerDocument?.defaultView??E,a=typeof t.shouldTriggerSuggestOnInsert==`function`?t.shouldTriggerSuggestOnInsert:null;function o(){e.focus()}function s(){return!!r?.ownerDocument?.querySelector?.(`.suggest-widget.visible`)}function c(){return s()?(o(),e.trigger(n,`acceptSelectedSuggestion`,null),!0):!1}function l(){let t=()=>{o(),e.trigger(n,O,null)};if(typeof i?.requestAnimationFrame==`function`){i.requestAnimationFrame(t);return}if(typeof i?.setTimeout==`function`){i.setTimeout(t,0);return}t()}function u(t){o(),e.trigger(n,`type`,{text:t}),a?.(t)&&l()}function d(){o(),e.trigger(n,`deleteLeft`,null)}function f(t,r={}){let i=!!r.selectRange,a=t===`left`?i?`cursorLeftSelect`:`cursorLeft`:t===`right`?i?`cursorRightSelect`:`cursorRight`:t===`up`?i?`cursorUpSelect`:`cursorUp`:t===`down`?i?`cursorDownSelect`:`cursorDown`:null;a&&(o(),e.trigger(n,a,null))}function p(){return typeof e.hasTextFocus==`function`&&e.hasTextFocus()}function m(e){return N(r,e)}function h(e){return p()||m(e.target)}return{kind:`monaco`,acceptSelectedSuggestionIfVisible:c,focus:o,insertText:u,deleteBackward:d,moveCursor:f,isFocused:p,ownsPhysicalKeyboardEvent:h,containsNode:m,destroy(){}}}function Ce(e){let t=e.elements??e;return{anchorElement:e.anchorElement??t.anchorElement??t.shell??t.toggleButton??null,input:t.input??null,toggleButton:t.toggleButton??null,closeButton:t.closeButton??null,minimizeButton:t.minimizeButton??null,keyboard:P(`keyboard`,t.keyboard),keyboardFooter:t.keyboardFooter??null,keyboardTitle:t.keyboardTitle??null,keyboardRows:P(`keyboardRows`,t.keyboardRows),keyboardMode:t.keyboardMode??null,layoutMenu:t.layoutMenu??null,layoutTrigger:t.layoutTrigger??null,spaceMode:t.spaceMode??null,navigationButtons:t.navigationButtons??null,resizeHandle:t.resizeHandle??null}}function F(e){let t=Ce(e),n=t.keyboard,r=e.ownerDocument??n.ownerDocument??E.document,i=e.ownerWindow??r.defaultView??E,a=typeof e.onStateChange==`function`?e.onStateChange:null,o=_e(i),s=[],c=be(),l=e.closeOnOutsidePointerDown??!0,u=e.mountToBody??!0,d=Object.values(t.navigationButtons??{}).filter(Boolean),f=e.target??(t.input?xe(t.input):null),p=null,m=null,h=null;if(!f)throw Error(`Khmer NiDA keyboard requires a target adapter or a native input element.`);function g(){let e=ve(c.layoutId),t=c.size.expandedWidth||c.size.baseWidth||0,n=c.size.expandedHeight||c.size.baseHeight||0;return{isOpen:c.isOpen,isMinimized:c.isMinimized,layoutId:e.id,layoutLabel:e.triggerLabel,mode:B(),position:c.position?{left:c.position.left,top:c.position.top}:null,size:t>0&&n>0?{height:n,width:t}:null,targetKind:f.kind??`custom`}}function _(){a?.(g())}u&&r.body&&n.parentNode!==r.body&&r.body.appendChild(n);function v(e,t,n,r){e.addEventListener(t,n,r),s.push(()=>{e.removeEventListener(t,n,r)})}function y(){f.focus()}function b(e){if(!e)throw Error(`Khmer NiDA keyboard target cannot be empty.`);f=e,He(),c.isOpen&&y(),_()}function x(e){return typeof f.containsNode==`function`&&f.containsNode(e)}function S(e){return typeof f.ownsPhysicalKeyboardEvent!=`function`||f.ownsPhysicalKeyboardEvent(e)}function C(e=c.layoutId){return ve(e)}function ee(e=C()){return!!e.usesNativePhysicalKeyboard}function w(){let e=C();n.classList.toggle(`is-layout-menu-open`,c.isLayoutMenuOpen),t.keyboardTitle&&(t.keyboardTitle.textContent=e.title,e.titleLang?t.keyboardTitle.lang=e.titleLang:t.keyboardTitle.removeAttribute(`lang`)),t.keyboardFooter&&(t.keyboardFooter.textContent=e.footerText),t.layoutTrigger&&(t.layoutTrigger.textContent=e.triggerLabel,t.layoutTrigger.setAttribute(`aria-expanded`,String(c.isLayoutMenuOpen)),t.layoutTrigger.setAttribute(`aria-label`,`Choose keyboard layout (current: ${e.menuLabel})`),t.layoutTrigger.setAttribute(`title`,`Choose keyboard layout (current: ${e.menuLabel})`)),t.layoutMenu&&(t.layoutMenu.hidden=!c.isLayoutMenuOpen,t.layoutMenu.parentElement&&(t.layoutMenu.parentElement.dataset.open=String(c.isLayoutMenuOpen)),t.layoutMenu.querySelectorAll(`[data-layout-id]`).forEach(t=>{let n=t.dataset.layoutId===e.id;t.classList.toggle(`is-active`,n),t.setAttribute(`aria-checked`,String(n))}))}function T(){n.style.setProperty(`--keyboard-scale`,`1`),n.style.setProperty(`--keyboard-viewport-scale`,`1`)}function te(){let e=n.classList.contains(`is-minimized`);e&&n.classList.remove(`is-minimized`),T(),n.style.width=`max-content`,n.style.height=`auto`,n.style.minWidth=`0`,n.style.minHeight=`0`;let t=n.getBoundingClientRect(),r={width:Math.ceil(Math.max(n.scrollWidth||0,n.offsetWidth||0,t.width)),height:Math.ceil(Math.max(n.scrollHeight||0,n.offsetHeight||0,t.height))};return e&&n.classList.add(`is-minimized`),r}function O(e={}){let t=e.preserveExpandedSize??!1,r=c.size.expandedWidth||c.size.baseWidth||0,i=c.size.expandedHeight||c.size.baseHeight||0,a=te();c.size.initialized=!0,c.size.baseWidth=a.width,c.size.baseHeight=a.height,c.size.expandedWidth=t?Math.max(r,a.width):a.width,c.size.expandedHeight=t?Math.max(i,a.height):a.height,n.style.width=`${c.size.expandedWidth}px`,n.style.height=`${c.size.expandedHeight}px`,n.style.minWidth=`0`,n.style.minHeight=`0`}function le(){O({preserveExpandedSize:c.size.expandedWidth>0&&c.size.expandedHeight>0})}function ue(e,t){let n=Math.max(1,i.innerWidth-8),r=Math.max(1,i.innerHeight-8);return j(Math.min(n/Math.max(e,1),r/Math.max(t,1),1),.1,1)}function de(){if(!c.size.initialized||c.isMinimized){T();return}let e=n.clientWidth||c.size.expandedWidth||c.size.baseWidth,t=n.clientHeight||c.size.expandedHeight||c.size.baseHeight,r=e/c.size.baseWidth,i=t/c.size.baseHeight,a=j(Math.min(r,i),1,2.4),o=ue(e,t);c.size.expandedWidth=e,c.size.expandedHeight=t,n.style.setProperty(`--keyboard-scale`,a.toFixed(3)),n.style.setProperty(`--keyboard-viewport-scale`,o.toFixed(3))}function fe(){c.size.initialized&&(F(c.size.expandedWidth||c.size.baseWidth,c.size.expandedHeight||c.size.baseHeight),n.style.minWidth=`0`,n.style.minHeight=`0`)}function pe(){n.style.height=`auto`,n.style.minWidth=`230px`,n.style.width=`230px`,n.style.minHeight=`0`,T()}function A(){if(c.isMinimized){pe();return}fe()}function P(){let e=r.fonts?.ready;m||!e||typeof e.then!=`function`||(m=e.then(()=>{m=null,!(!c.isOpen||!c.size.initialized)&&o(()=>{if(O({preserveExpandedSize:!0}),A(),c.position){L(c.position),_();return}R(!0),_()})}).catch(()=>{m=null}))}function Se(e,t){let r=n.getBoundingClientRect(),a=c.size.baseWidth||Math.ceil(r.width),o=c.size.baseHeight||Math.ceil(r.height),s=Math.max(a,i.innerWidth),l=Math.max(o,i.innerHeight),u=c.size.baseWidth||a,d=c.size.baseHeight||o,f=j(Math.max(e/u,t/d),1,Math.min(s/u,l/d,2.4));return{width:Math.round(u*f),height:Math.round(d*f)}}function F(e,t){let r=Se(e,t);return n.style.width=`${r.width}px`,n.style.height=`${r.height}px`,c.size.expandedWidth=r.width,c.size.expandedHeight=r.height,de(),r}function we(){if(!c.size.initialized||c.isMinimized)return null;let e=Math.max(c.size.baseWidth,1),t=Math.max(c.size.baseHeight,1),r=n.clientWidth||c.size.expandedWidth||e,i=n.clientHeight||c.size.expandedHeight||t,a=Math.max(r/e,i/t,1)+ie,o=F(e*a,t*a);return c.position&&L(c.position),_(),o}function Te(){p||typeof i.ResizeObserver!=`function`||(p=new i.ResizeObserver(()=>{c.isOpen&&(de(),c.position&&L(c.position))}),p.observe(n))}function I(e,t){let r=n.getBoundingClientRect(),a=r.width||Math.min(920,i.innerWidth),o=r.height||0,s=Math.max(0,i.innerWidth-a),c=Math.max(0,i.innerHeight-o);return{left:j(e,0,s),top:j(t,0,c)}}function L(e){let t=I(e.left,e.top);n.style.left=`${t.left}px`,n.style.top=`${t.top}px`,c.position=t}function R(e=!1){if(c.position&&!e){L(c.position);return}let t=n.getBoundingClientRect();L({left:Math.max(16,i.innerWidth-t.width-16),top:16})}function Ee(){return c.armedShift||z()||c.pressedShift}function De(){return c.armedShift||c.pressedShift}function z(){return c.latchedCaps||c.physicalCapsLock}function Oe(){return c.latchedAlt||c.pressedAlt}function B(e={}){let t=e.shift??Ee(),n=e.alt??Oe();return t&&n?`altShift`:n?`alt`:t?`shift`:`base`}function V(e,t,n=C()){return n.keyLayouts[e]?.[t]??``}function H(e,t){return ce[t]?ce[t]:!t&&e===`Space`?`Space`:t}function ke(e,t){return!!(t.id===`khmer`&&e&&se.test(e)&&!oe.test(e))}function Ae(e,t,n,r=C()){if(n===`spacebar`&&t===`​`)return r.visibleZwspLabel??`ចន្លោះមើលមិនឃើញ`;let i=H(e,t);return ke(t,r)?`${ae}${i}`:i}function je(e,t=C()){let n=new Set,r=k[e]??e,i=ne.flatMap(({mode:r,prefix:i})=>{let a=H(e,V(r,e,t));return!a||n.has(a)?[]:(n.add(a),[i?`${i} ${a}`:a])}).join(` | `);return i?`${r}: ${i}`:r}function U(e,t){let n=String(t||``).trim();if(!n){delete e.dataset.keyTooltip,e.removeAttribute(`title`);return}delete e.dataset.keyTooltip,e.title=n}function W(e){f.insertText(e)}function G(){return f.acceptSelectedSuggestionIfVisible?.()||!1}function Me(){f.deleteBackward()}function Ne(e,t={}){f.moveCursor?.(e,t)}function K(){c.pressedShift=!1,c.pressedAlt=!1,c.pressedCodes.clear()}function Pe(){return c.armedShift?(c.armedShift=!1,!0):!1}function Fe(){return c.latchedAlt?(c.latchedAlt=!1,!0):!1}function q(){let e=Pe(),t=Fe();return e||t}function J(){c.isLayoutMenuOpen&&(c.isLayoutMenuOpen=!1,w())}function Ie(){!t.layoutTrigger||!t.layoutMenu||(c.isLayoutMenuOpen=!0,w())}function Le(){if(c.isLayoutMenuOpen){J();return}Ie()}function Y(e){let t=C(e);c.layoutId=t.id,c.armedShift=!1,c.latchedCaps=!1,c.latchedAlt=!1,K(),c.isLayoutMenuOpen=!1,Q(),y(),_()}function Re(){c.layoutId=me,c.isLayoutMenuOpen=!1}function X(){r.removeEventListener(`pointermove`,tt),r.removeEventListener(`pointerup`,nt),r.removeEventListener(`pointercancel`,nt),c.drag.pointerId=null,c.drag.hasMoved=!1,n.classList.remove(`is-dragging`),r.body.classList.remove(`is-dragging-keyboard`)}function ze(){r.removeEventListener(`pointermove`,it),r.removeEventListener(`pointerup`,at),r.removeEventListener(`pointercancel`,at),c.resize.pointerId=null,c.resize.hasMoved=!1,n.classList.remove(`is-resizing`),r.body.classList.remove(`is-resizing-keyboard`)}function Be(e){return!M(e,`button, .keyboard-layout-menu, .keyboard-resize-handle`)}function Ve(){t.toggleButton&&(t.toggleButton.textContent=c.isOpen?`Hide Khmer keyboard`:`Open Khmer keyboard`,t.toggleButton.setAttribute(`aria-expanded`,String(c.isOpen))),n.hidden=!c.isOpen}function He(){let e=typeof f.moveCursor==`function`;d.forEach(t=>{t.disabled=!e})}function Z(){n.classList.toggle(`is-minimized`,c.isMinimized),t.minimizeButton&&(t.minimizeButton.textContent=c.isMinimized?`▸`:`▾`,t.minimizeButton.setAttribute(`aria-label`,c.isMinimized?`Expand keyboard`:`Minimize keyboard`),t.minimizeButton.setAttribute(`aria-pressed`,String(c.isMinimized)))}function Ue(){h=null,c.isMinimized=!1,c.position=null,c.size.initialized=!1,c.size.baseWidth=0,c.size.baseHeight=0,c.size.expandedWidth=0,c.size.expandedHeight=0,n.style.width=``,n.style.height=``,n.style.minWidth=``,n.style.minHeight=``,n.style.left=``,n.style.top=``,T()}function Q(){let e=C(),n=B();t.keyboardMode&&(t.keyboardMode.textContent=D[n]),t.spaceMode&&(t.spaceMode.textContent=`Space: ${H(`Space`,V(n,`Space`,e))}`),w(),t.keyboardRows.querySelectorAll(`[data-code]`).forEach(t=>{let r=t.dataset.code,i=t.dataset.variant,a=V(n,r,e),o=t.querySelector(`.kb-key-value`),s=t.querySelector(`.kb-key-hint`);o.textContent=Ae(r,a,i,e),s.textContent=k[r]??``,t.classList.toggle(`is-empty`,a===``),t.classList.toggle(`is-pressed`,c.pressedCodes.has(r)),U(t,je(r,e)),t.setAttribute(`aria-label`,`${k[r]??r} ${H(r,a)||`empty`}`.trim())}),t.keyboardRows.querySelectorAll(`[data-toggle]`).forEach(e=>{let t=e.dataset.toggle,n=t===`Alt`?Oe():t===`Caps`?z():De();e.classList.toggle(`is-active`,n),e.setAttribute(`aria-pressed`,String(n))})}function $(e,t={}){let n=t.resetWindowStateOnClose??!1,r=c.isOpen;c.isOpen=e,c.isOpen||(c.isLayoutMenuOpen=!1,c.armedShift=!1,c.latchedCaps=!1,c.latchedAlt=!1,K(),X(),ze(),n&&Ue()),c.isOpen&&!r&&Re(),Ve(),Z(),Q(),c.isOpen&&o(()=>{let e=h;c.size.initialized||(le(),Te()),P(),A(),e?.size&&!c.isMinimized&&e.size.width>0&&e.size.height>0&&F(e.size.width,e.size.height),e?.position?L(e.position):c.position?L(c.position):R(),y(),h=null,_()}),_()}function We(){if(c.isLayoutMenuOpen=!1,!c.size.initialized){c.isMinimized=!c.isMinimized,Z(),w(),_();return}c.isMinimized||(c.size.expandedWidth=n.clientWidth||c.size.expandedWidth||c.size.baseWidth,c.size.expandedHeight=n.clientHeight||c.size.expandedHeight||c.size.baseHeight,n.style.height=`auto`,n.style.minWidth=n.style.width=`230px`,n.style.minHeight=`0`),c.isMinimized=!c.isMinimized,Z(),w(),o(()=>{A();let e=n.getBoundingClientRect();L({left:c.position?.left??e.left,top:c.position?.top??e.top}),_()})}function Ge(e){e===`Shift`&&(c.latchedCaps=!1,c.armedShift=!c.armedShift),e===`Caps`&&(c.latchedCaps=!c.latchedCaps,c.armedShift=!1),e===`Alt`&&(c.latchedAlt=!c.latchedAlt),Q(),y()}function Ke(e){if(e===`Backspace`){Me();return}if(e===`Enter`){if(G())return;W(`
113
113
  `);return}if(e===`Tab`){if(G())return;W(` `)}}function qe(){let e=C();t.keyboardRows.textContent=``;let n=r.createDocumentFragment();he.forEach(t=>{let i=r.createElement(`div`);i.className=`kb-row`,t.forEach(t=>{if(t.spacer){let e=r.createElement(`div`);e.className=`kb-spacer`,i.appendChild(e);return}let n=r.createElement(`button`);n.type=`button`,n.className=`kb-key`,t.width&&n.classList.add(`is-${t.width}`),t.variant&&(n.dataset.variant=t.variant);let a=r.createElement(`span`);a.className=`kb-key-value`;let o=r.createElement(`span`);o.className=`kb-key-hint`,t.code?(n.dataset.code=t.code,a.textContent=Ae(t.code,V(`base`,t.code,e),t.variant,e),o.textContent=k[t.code]??``,U(n,je(t.code,e))):t.action?(n.dataset.action=t.action,n.classList.add(`is-action`),a.textContent=t.label,o.textContent=``,n.setAttribute(`aria-label`,t.ariaLabel??t.label),U(n,t.ariaLabel??t.label)):t.toggle&&(n.dataset.toggle=t.toggle,n.classList.add(`is-toggle`),a.textContent=t.label,o.textContent=``,n.setAttribute(`aria-pressed`,`false`),n.setAttribute(`aria-label`,t.ariaLabel??t.label),U(n,t.ariaLabel??t.label)),n.append(a,o),i.appendChild(n)}),n.appendChild(i)}),t.keyboardRows.appendChild(n)}function Je(e){let t=M(e.target,`button`)?e.target.closest(`button`):null;if(!t)return;let n=t.dataset.toggle,r=t.dataset.action,i=t.dataset.code;if(n){Ge(n);return}if(r){Ke(r),q()&&Q(),y();return}if(!i)return;let a=V(B(),i);if(!a){q()&&Q(),y();return}W(a),q()&&Q()}function Ye(e){let t=M(e.target,`button[data-direction]`)?e.target.closest(`button[data-direction]`):null;t?.dataset.direction&&(Ne(t.dataset.direction,{selectRange:Ee()}),q()&&Q())}function Xe(e){c.physicalCapsLock=!!e.getModifierState?.(`CapsLock`),c.pressedShift=!!e.shiftKey,c.pressedAlt=!!(e.altKey||e.getModifierState?.(`AltGraph`))}function Ze(e){return c.pressedCodes.has(e.code)||e.key===`CapsLock`||e.key===`Shift`||e.key===`Alt`||e.key===`AltGraph`}function Qe(e){if(!c.isOpen||!S(e))return;if(e.key===`Escape`){q()&&Q(),c.isLayoutMenuOpen&&(e.preventDefault(),e.stopPropagation(),J(),y());return}if(e.metaKey)return;let t=!!e.getModifierState?.(`AltGraph`);if(e.ctrlKey&&!e.altKey&&!t)return;Xe(e);let n=ee(C());if((e.code===`Enter`||e.code===`Tab`)&&G()){e.preventDefault(),e.stopPropagation(),Q();return}if(e.key===`CapsLock`||e.key===`Shift`||e.key===`Alt`||e.key===`AltGraph`){e.key!==`CapsLock`&&!n&&(e.preventDefault(),e.stopPropagation()),Q();return}let r=Pe(),i=Fe();if(!ge.has(e.code)){(r||i)&&Q();return}if(n){c.pressedCodes.add(e.code),Q();return}e.preventDefault(),e.stopPropagation();let a=B({shift:z()||r||e.shiftKey,alt:i||e.altKey||t});if(e.code===`Backspace`){Me(),Q();return}if(e.code===`Enter`){if(G()){Q();return}W(`
114
- `),Q();return}if(e.code===`Tab`){if(G()){Q();return}W(` `),Q();return}c.pressedCodes.add(e.code);let o=V(a,e.code);o&&W(o),Q()}function $e(e){if(!c.isOpen)return;let t=ee(C());!S(e)&&!Ze(e)||(e.code&&c.pressedCodes.delete(e.code),Xe(e),(ge.has(e.code)||e.key===`CapsLock`||e.key===`Shift`||e.key===`Alt`||e.key===`AltGraph`)&&(e.key!==`CapsLock`&&!t&&(e.preventDefault(),e.stopPropagation()),Q()))}function et(e){if(!c.isOpen||!Be(e.target)||e.button!==0)return;let t=n.getBoundingClientRect();c.drag.pointerId=e.pointerId,c.drag.startX=e.clientX,c.drag.startY=e.clientY,c.drag.originLeft=c.position?.left??t.left,c.drag.originTop=c.position?.top??t.top,c.drag.hasMoved=!1,r.addEventListener(`pointermove`,tt),r.addEventListener(`pointerup`,nt),r.addEventListener(`pointercancel`,nt),e.preventDefault()}function tt(e){if(c.drag.pointerId!==e.pointerId)return;let t=e.clientX-c.drag.startX,i=e.clientY-c.drag.startY;if(!c.drag.hasMoved){if(Math.abs(t)+Math.abs(i)<4)return;c.drag.hasMoved=!0,n.classList.add(`is-dragging`),r.body.classList.add(`is-dragging-keyboard`)}L({left:c.drag.originLeft+t,top:c.drag.originTop+i}),e.preventDefault()}function nt(e){c.drag.pointerId===e.pointerId&&(e.preventDefault(),X(),_())}function rt(e){!c.isOpen||c.isMinimized||!t.resizeHandle||e.button!==0||(c.resize.pointerId=e.pointerId,c.resize.startX=e.clientX,c.resize.startY=e.clientY,c.resize.startWidth=n.offsetWidth,c.resize.startHeight=n.offsetHeight,c.resize.hasMoved=!1,r.addEventListener(`pointermove`,it),r.addEventListener(`pointerup`,at),r.addEventListener(`pointercancel`,at),e.preventDefault(),e.stopPropagation())}function it(e){if(c.resize.pointerId!==e.pointerId)return;let t=e.clientX-c.resize.startX,i=e.clientY-c.resize.startY;if(!c.resize.hasMoved){if(Math.abs(t)+Math.abs(i)<re)return;c.resize.hasMoved=!0,n.classList.add(`is-resizing`),r.body.classList.add(`is-resizing-keyboard`)}F(c.resize.startWidth+t,c.resize.startHeight+i),c.position&&L(c.position),e.preventDefault()}function at(e){if(c.resize.pointerId!==e.pointerId)return;let t=c.resize.hasMoved;if(e.preventDefault(),ze(),!t){we();return}_()}function ot(){J(),K(),X(),ze(),Q()}function st(){c.isOpen&&o(()=>{if(c.size.initialized&&!c.isMinimized&&F(c.size.expandedWidth||c.size.baseWidth,c.size.expandedHeight||c.size.baseHeight),c.position){L(c.position),_();return}R(!0),_()})}function ct(e){if(!c.isOpen)return;let r=e.target;c.isLayoutMenuOpen&&r!==t.layoutTrigger&&!N(t.layoutMenu,r)&&J(),l&&(N(t.anchorElement,r)||N(n,r)||x(r)||$(!1,{resetWindowStateOnClose:!0}))}return t.toggleButton&&v(t.toggleButton,`click`,()=>{if(c.isOpen){$(!1,{resetWindowStateOnClose:!0});return}$(!0)}),t.minimizeButton&&v(t.minimizeButton,`click`,()=>{We()}),t.layoutTrigger&&v(t.layoutTrigger,`click`,e=>{e.preventDefault(),e.stopPropagation(),Le()}),t.layoutMenu&&v(t.layoutMenu,`click`,e=>{let t=M(e.target,`button[data-layout-id]`)?e.target.closest(`button[data-layout-id]`):null;t?.dataset.layoutId&&(e.preventDefault(),e.stopPropagation(),Y(t.dataset.layoutId))}),t.closeButton&&v(t.closeButton,`click`,()=>{$(!1,{resetWindowStateOnClose:!0})}),d.forEach(e=>{v(e,`mousedown`,e=>{e.preventDefault()}),v(e,`click`,Ye)}),n.classList.add(`is-draggable`),v(n,`pointerdown`,et),t.resizeHandle&&v(t.resizeHandle,`pointerdown`,rt),v(t.keyboardRows,`mousedown`,e=>{M(e.target,`button`)&&e.preventDefault()}),v(t.keyboardRows,`click`,Je),v(r,`keydown`,Qe,!0),v(r,`keyup`,$e,!0),v(i,`blur`,ot),v(i,`resize`,st),v(r,`pointerdown`,ct),qe(),Ve(),He(),Q(),_(),{elements:t,focusTarget:y,open(){$(!0)},close(){$(!1,{resetWindowStateOnClose:!0})},toggle(){if(c.isOpen){$(!1,{resetWindowStateOnClose:!0});return}$(!0)},setTarget:b,render(){Q()},restoreState(e){let t=ye(e);if(h=t,c.isMinimized=t.isMinimized,c.position=t.position,t.size&&(c.size.expandedWidth=t.size.width,c.size.expandedHeight=t.size.height),t.isOpen!==c.isOpen){$(t.isOpen);return}Z(),_()},getState(){return g()},destroy(){$(!1),p?.disconnect(),s.splice(0).reverse().forEach(e=>e())}}}function we(e=E.document){return e?{anchorElement:e.getElementById(`keyboard-shell`),input:e.getElementById(`khmer-input`),toggleButton:e.getElementById(`toggle-keyboard`),closeButton:e.getElementById(`close-keyboard`),minimizeButton:e.getElementById(`minimize-keyboard`),keyboard:e.getElementById(`khmer-keyboard`),keyboardRows:e.getElementById(`keyboard-rows`),keyboardMode:e.getElementById(`keyboard-mode`),spaceMode:e.getElementById(`space-mode`),resizeHandle:e.getElementById(`keyboard-resize-handle`)}:null}function Te(e=E.document){let t=we(e);return!t?.input||!t.keyboard||!t.keyboardRows?null:F({elements:t,target:xe(t.input)})}if(E.OpenLyricKhmerNidaKeyboard={bootstrapKhmerNidaDemo:Te,createKhmerNidaKeyboard:F,createMonacoInputAdapter:Se,createNativeTextInputAdapter:xe},E.document){let e=Te(E.document);e&&(E.khmerNidaDemoKeyboard=e)}var I=`openLyricKhmerNidaKeyboardVisible`,L=`open-lyric-editor-auto-suggest`,R=`km-kh-nida-keyboard`;function Ee(t){let n=t?.documentElement;if(!(n instanceof HTMLElement)||n.dataset.editorShell!==e.EDITOR_ONLY_SHELL_MODE)return!1;try{return t.defaultView?.localStorage?.getItem(L)!==`0`}catch{return!0}}function De(e,t,n,r){let i=e.createElement(`button`);return i.className=`window-button`,i.id=t,i.type=`button`,i.textContent=n,i.setAttribute(`aria-label`,r),i}function z(e,t,n,r,i){let a=e.createElement(`button`);return a.className=`keyboard-navigation-button`,a.id=`khmer-keyboard-nav-${n}-${t}`,a.type=`button`,a.dataset.direction=n,a.textContent=r,a.setAttribute(`aria-label`,i),a.setAttribute(`title`,i),a}function Oe(e,t,n,r,i){let a=e.createElement(`button`);return a.className=`keyboard-layout-option`,a.id=`keyboard-layout-option-${n}-${t}`,a.type=`button`,a.dataset.layoutId=n,a.textContent=r,a.setAttribute(`aria-checked`,`false`),a.setAttribute(`aria-label`,i),a.setAttribute(`role`,`menuitemradio`),a}function B(e,t){let n=e.createElement(`section`);n.className=`keyboard-popover ol-editor-khmer-keyboard`,n.hidden=!0,n.id=`khmer-keyboard-${t}`;let r=e.createElement(`div`);r.className=`keyboard-header`;let i=De(e,`close-khmer-keyboard-${t}`,`✕`,`Close keyboard`),a=e.createElement(`div`);a.className=`keyboard-title`;let o=e.createElement(`strong`);o.lang=`km`,o.textContent=`អក្សរខ្មែរ NiDA`;let s={up:z(e,t,`up`,`↑`,`Move cursor up`),left:z(e,t,`left`,`←`,`Move cursor left`),down:z(e,t,`down`,`↓`,`Move cursor down`),right:z(e,t,`right`,`→`,`Move cursor right`)},c=e.createElement(`div`);c.className=`keyboard-navigation`,c.setAttribute(`role`,`group`),c.setAttribute(`aria-label`,`Move cursor`),c.append(s.left,s.right,s.up,s.down),a.append(o,c);let l=e.createElement(`div`);l.className=`keyboard-layout-picker`,l.dataset.open=`false`;let u=e.createElement(`button`);u.className=`keyboard-layout-trigger`,u.id=`keyboard-layout-trigger-${t}`,u.type=`button`,u.textContent=`Khmer`,u.setAttribute(`aria-controls`,`keyboard-layout-menu-${t}`),u.setAttribute(`aria-expanded`,`false`),u.setAttribute(`aria-haspopup`,`menu`),u.setAttribute(`aria-label`,`Choose keyboard layout`),u.setAttribute(`title`,`Choose keyboard layout`);let d=e.createElement(`div`);d.className=`keyboard-layout-menu`,d.hidden=!0,d.id=`keyboard-layout-menu-${t}`,d.setAttribute(`aria-label`,`Keyboard layout choices`),d.setAttribute(`role`,`menu`),d.append(Oe(e,t,`khmer`,`Khmer NiDA`,`Use Khmer NiDA keyboard layout`),Oe(e,t,`english`,`English (US)`,`Use English keyboard layout`)),l.append(u,d);let f=e.createElement(`div`);f.className=`keyboard-status`;let p=e.createElement(`span`);p.className=`visually-hidden`,p.id=`keyboard-mode-${t}`,p.textContent=`Normal`;let m=e.createElement(`span`);m.className=`visually-hidden`,m.id=`space-mode-${t}`,m.textContent=`Space: ZWSP`;let h=De(e,`minimize-khmer-keyboard-${t}`,`▾`,`Minimize keyboard`);h.setAttribute(`aria-pressed`,`false`),f.append(p,m,h),r.append(i,a,l,f);let g=e.createElement(`div`);g.className=`keyboard-grid`,g.id=`keyboard-rows-${t}`;let _=e.createElement(`div`);_.className=`keyboard-footer`,_.textContent=`NiDA layout with default zero-width space behavior for Khmer word breaks.`;let v=e.createElement(`div`);return v.className=`keyboard-resize-handle`,v.id=`keyboard-resize-handle-${t}`,v.setAttribute(`aria-hidden`,`true`),n.append(r,g,_,v),{closeButton:i,keyboard:n,keyboardFooter:_,keyboardMode:p,keyboardRows:g,keyboardTitle:o,layoutMenu:d,layoutTrigger:u,minimizeButton:h,navigationButtons:s,resizeHandle:v,spaceMode:m}}function V({editor:e,monaco:t,onStateChange:n,ownerDocument:r,ownerWindow:i,preferences:a,refs:o}){if(!e)throw Error(`Khmer NiDA keyboard plugin requires an editor instance.`);let s=e.getDomNode?.()||o?.editorHost||r.querySelector(`[data-ol-ref="editor"]`);if(!s)throw Error(`Khmer NiDA keyboard plugin could not find the editor host.`);let c=B(r,`editor-khmer-nida`),l=Se(e,{source:`open-lyric-khmer-nida-keyboard`,shouldTriggerSuggestOnInsert(e){return!!String(e??``).trim()&&Ee(r)}}),u=e.createContextKey(I,!1),d=a?.loadKeyboardWindowPreference?.(R)??null,f=t?.KeyMod&&t?.KeyCode?[t.KeyMod.CtrlCmd|t.KeyMod.Alt|t.KeyCode.KeyK]:[],p=!1,m=F({...c,anchorElement:s,closeOnOutsidePointerDown:!1,mountToBody:!0,onStateChange(e){u.set(!!e?.isOpen),p&&a?.saveKeyboardWindowPreference?.(R,e),n?.(e)},ownerDocument:r,ownerWindow:i,target:l});p=!0,d&&m.restoreState?.(d);let h=e.addAction({id:`open-lyric.open-khmer-keyboard`,label:`Open Khmer Keyboard`,precondition:`!${I}`,contextMenuGroupId:`9_cutcopypaste`,contextMenuOrder:7,keybindings:f,run:()=>{m.open()}}),g=e.addAction({id:`open-lyric.close-khmer-keyboard`,label:`Hide Khmer Keyboard`,precondition:I,contextMenuGroupId:`9_cutcopypaste`,contextMenuOrder:7,keybindings:f,run:()=>{m.close()}});return{close(){m.close()},destroy(){h.dispose(),g.dispose(),m.destroy(),c.keyboard.remove(),l.destroy?.()},getState(){return m.getState()},open(){m.open()},toggle(){m.toggle()}}}var H={actionLabel:`Khmer Keyboard`,create:V,displayName:`Khmer NiDA Keyboard`,id:R,openActionId:`open-lyric.open-khmer-keyboard`,closeActionId:`open-lyric.close-khmer-keyboard`},ke=/[\u1780-\u17D3\u17D7\u17DC\u17DD\u200C\u200D.]+/gu,Ae=/^[\u1780-\u17D3\u17D7\u17DC\u17DD\u200C\u200D.]+$/u,je=/[\u1780-\u17B3]/u,U=`​`,W=/([\u1780-\u17D3])[\t\f\v \u00AD\u00A0\u1680\u2000-\u200A\u200C\u202F\u205F\u3000]+(?=[\u1780-\u17B3])/gu,G=Array.from({length:52},(e,t)=>String.fromCharCode(6016+t)),Me=`editor-Battambang`,Ne=[],K=[Me,...Ne],Pe=`ចម្រៀងសាកល្បង`;function Fe(e){return String(e||``).replace(/^[\u200C\u200D]+|[\u200C\u200D]+$/gu,``)}var q={id:`km_KH_ol_editor`,exampleGroupTitle:`Khmer .md Examples`,examples:[{id:`khmer-call-to-worship`,fileName:`khmer-call-to-worship.md`,title:`ព្រះគុណនៅព្រឹកនេះ`,description:`Khmer-only worship draft with a simple intro, verses, and chorus.`,content:s},{id:`khmer-bilingual-prayer`,fileName:`khmer-bilingual-prayer.md`,title:`អធិស្ឋានដោយសេចក្ដីសង្ឃឹម`,description:`Khmer and English line pairs for a prayer-focused Open Lyric draft.`,content:c}],keyboard:H,spellChecker:{actionLabel:`Khmer Spell Checker`,af:r,aliases:[`km-kh`,`km_kh`],baseLetterPattern:je,defaultEnabled:!0,dictionaryName:`km_KH`,dict:i,displayName:`Khmer`,exactWordPattern:Ae,languageCode:`km`,normalizeWord:Fe,providerFactory:te,suggestAffUrls:[a],wordPattern:ke,wordSeparator:U,wordSeparatorPattern:W,suggestTriggerCharacters:G,segmentationActionLabel:`Try Khmer Segmentation`},style:[t,n],fonts:{faces:K,stack:`${K.map(e=>`'${e}'`).join(`, `)}, sans-serif`,sampleText:Pe},transcriptLocales:[`km-KH`],pptxStyle:{fontFamilyChoices:Ne,fontDetectionSampleText:`WWWWmmmm1234567890${Pe}`,fontSize:24}},J=q.fonts.faces,Ie=q.fonts.stack,Le={href:t},Y=[Le],Re=[Le,{href:n}],X=`data-open-lyric-plugin-id`;function ze(e,t){let n=e.querySelectorAll(`[${X}="km-KH"]`);for(let e of Array.from(n))if(t.href&&e.getAttribute(`href`)===t.href||t.cssText&&e.textContent===t.cssText)return!0;return!1}function Be(e){let t=globalThis.document?.head;if(t)for(let n of e){if(!n.href&&!n.cssText||ze(t,n))continue;let e=n.href?Object.assign(document.createElement(`link`),{rel:`stylesheet`,href:n.href}):Object.assign(document.createElement(`style`),{textContent:n.cssText??``});n.media&&(e.media=n.media),e.setAttribute(X,`km-KH`),t.append(e)}}var Ve={fontFaces:J,fontFamily:Ie},He={spellcheck:q.spellChecker,keyboard:{id:q.keyboard.id,displayName:q.keyboard.displayName,create:q.keyboard.create,openActionId:q.keyboard.openActionId,closeActionId:q.keyboard.closeActionId}},Z=class{id=`km-KH`;apiVersion=1;surfaces=[`editor`];contributes={language:He,style:Re};static installShellStyle(){Be(Y)}keyboardController=null;preferences=new e.EditorPreferencesStore;registryRegistration=null;install(){let t=!!(0,e.getRegisteredSpellcheckSpecification)(q.spellChecker.languageCode),n=(0,e.getRegisteredKeyboardSpecifications)().some(e=>e.id===q.keyboard.id);!t&&!n&&(this.registryRegistration=(0,e.registerPlugin)(q))}uninstall(){this.destroyKeyboard(),this.registryRegistration&&=((0,e.unregisterPlugin)(this.registryRegistration),null)}onMount(e){let t=e,n=t.monacoEditor,r=t.monacoNamespace;if(!n||!r)return;let i=e.container?.ownerDocument??document;try{this.keyboardController=q.keyboard.create({editor:n,monaco:r,onStateChange:()=>{},ownerDocument:i,ownerWindow:i.defaultView??window,preferences:this.preferences,refs:null})}catch(e){console.error(`km-KH keyboard failed to mount.`,e),this.keyboardController=null}}onUnmount(){this.destroyKeyboard()}toggleKeyboard(){this.keyboardController?.toggle()}closeKeyboard(){this.keyboardController?.close()}get isKeyboardMounted(){return this.keyboardController!==null}destroyKeyboard(){try{this.keyboardController?.destroy()}catch(e){console.error(`km-KH keyboard failed to dispose.`,e)}this.keyboardController=null}},Ue=class{id=`km-KH`;apiVersion=1;surfaces=[`markdown`];contributes={language:Ve,style:Y};static installShellStyle(){Be(Y)}install(){}uninstall(){}},Q=class{id=`km-KH`;apiVersion=1;surfaces=[`lyric`];contributes={language:Ve,style:Y};static installShellStyle(){Be(Y)}install(){}uninstall(){}},$=`0.1.15`;exports.EditorPluginKmKh=Z,exports.KHMER_BILINGUAL_PRAYER_EXAMPLE=c,exports.KHMER_CALL_TO_WORSHIP_EXAMPLE=s,exports.KM_KH_WEBFONT_FACE=Me,exports.OpenLyricMarkdownManagerPluginKmKh=Ue,exports.OpenLyricPluginKmKh=Q,exports.version=$;
114
+ `),Q();return}if(e.code===`Tab`){if(G()){Q();return}W(` `),Q();return}c.pressedCodes.add(e.code);let o=V(a,e.code);o&&W(o),Q()}function $e(e){if(!c.isOpen)return;let t=ee(C());!S(e)&&!Ze(e)||(e.code&&c.pressedCodes.delete(e.code),Xe(e),(ge.has(e.code)||e.key===`CapsLock`||e.key===`Shift`||e.key===`Alt`||e.key===`AltGraph`)&&(e.key!==`CapsLock`&&!t&&(e.preventDefault(),e.stopPropagation()),Q()))}function et(e){if(!c.isOpen||!Be(e.target)||e.button!==0)return;let t=n.getBoundingClientRect();c.drag.pointerId=e.pointerId,c.drag.startX=e.clientX,c.drag.startY=e.clientY,c.drag.originLeft=c.position?.left??t.left,c.drag.originTop=c.position?.top??t.top,c.drag.hasMoved=!1,r.addEventListener(`pointermove`,tt),r.addEventListener(`pointerup`,nt),r.addEventListener(`pointercancel`,nt),e.preventDefault()}function tt(e){if(c.drag.pointerId!==e.pointerId)return;let t=e.clientX-c.drag.startX,i=e.clientY-c.drag.startY;if(!c.drag.hasMoved){if(Math.abs(t)+Math.abs(i)<4)return;c.drag.hasMoved=!0,n.classList.add(`is-dragging`),r.body.classList.add(`is-dragging-keyboard`)}L({left:c.drag.originLeft+t,top:c.drag.originTop+i}),e.preventDefault()}function nt(e){c.drag.pointerId===e.pointerId&&(e.preventDefault(),X(),_())}function rt(e){!c.isOpen||c.isMinimized||!t.resizeHandle||e.button!==0||(c.resize.pointerId=e.pointerId,c.resize.startX=e.clientX,c.resize.startY=e.clientY,c.resize.startWidth=n.offsetWidth,c.resize.startHeight=n.offsetHeight,c.resize.hasMoved=!1,r.addEventListener(`pointermove`,it),r.addEventListener(`pointerup`,at),r.addEventListener(`pointercancel`,at),e.preventDefault(),e.stopPropagation())}function it(e){if(c.resize.pointerId!==e.pointerId)return;let t=e.clientX-c.resize.startX,i=e.clientY-c.resize.startY;if(!c.resize.hasMoved){if(Math.abs(t)+Math.abs(i)<re)return;c.resize.hasMoved=!0,n.classList.add(`is-resizing`),r.body.classList.add(`is-resizing-keyboard`)}F(c.resize.startWidth+t,c.resize.startHeight+i),c.position&&L(c.position),e.preventDefault()}function at(e){if(c.resize.pointerId!==e.pointerId)return;let t=c.resize.hasMoved;if(e.preventDefault(),ze(),!t){we();return}_()}function ot(){J(),K(),X(),ze(),Q()}function st(){c.isOpen&&o(()=>{if(c.size.initialized&&!c.isMinimized&&F(c.size.expandedWidth||c.size.baseWidth,c.size.expandedHeight||c.size.baseHeight),c.position){L(c.position),_();return}R(!0),_()})}function ct(e){if(!c.isOpen)return;let r=e.target;c.isLayoutMenuOpen&&r!==t.layoutTrigger&&!N(t.layoutMenu,r)&&J(),l&&(N(t.anchorElement,r)||N(n,r)||x(r)||$(!1,{resetWindowStateOnClose:!0}))}return t.toggleButton&&v(t.toggleButton,`click`,()=>{if(c.isOpen){$(!1,{resetWindowStateOnClose:!0});return}$(!0)}),t.minimizeButton&&v(t.minimizeButton,`click`,()=>{We()}),t.layoutTrigger&&v(t.layoutTrigger,`click`,e=>{e.preventDefault(),e.stopPropagation(),Le()}),t.layoutMenu&&v(t.layoutMenu,`click`,e=>{let t=M(e.target,`button[data-layout-id]`)?e.target.closest(`button[data-layout-id]`):null;t?.dataset.layoutId&&(e.preventDefault(),e.stopPropagation(),Y(t.dataset.layoutId))}),t.closeButton&&v(t.closeButton,`click`,()=>{$(!1,{resetWindowStateOnClose:!0})}),d.forEach(e=>{v(e,`mousedown`,e=>{e.preventDefault()}),v(e,`click`,Ye)}),n.classList.add(`is-draggable`),v(n,`pointerdown`,et),t.resizeHandle&&v(t.resizeHandle,`pointerdown`,rt),v(t.keyboardRows,`mousedown`,e=>{M(e.target,`button`)&&e.preventDefault()}),v(t.keyboardRows,`click`,Je),v(r,`keydown`,Qe,!0),v(r,`keyup`,$e,!0),v(i,`blur`,ot),v(i,`resize`,st),v(r,`pointerdown`,ct),qe(),Ve(),He(),Q(),_(),{elements:t,focusTarget:y,open(){$(!0)},close(){$(!1,{resetWindowStateOnClose:!0})},toggle(){if(c.isOpen){$(!1,{resetWindowStateOnClose:!0});return}$(!0)},setTarget:b,render(){Q()},restoreState(e){let t=ye(e);if(h=t,c.isMinimized=t.isMinimized,c.position=t.position,t.size&&(c.size.expandedWidth=t.size.width,c.size.expandedHeight=t.size.height),t.isOpen!==c.isOpen){$(t.isOpen);return}Z(),_()},getState(){return g()},destroy(){$(!1),p?.disconnect(),s.splice(0).reverse().forEach(e=>e())}}}function we(e=E.document){return e?{anchorElement:e.getElementById(`keyboard-shell`),input:e.getElementById(`khmer-input`),toggleButton:e.getElementById(`toggle-keyboard`),closeButton:e.getElementById(`close-keyboard`),minimizeButton:e.getElementById(`minimize-keyboard`),keyboard:e.getElementById(`khmer-keyboard`),keyboardRows:e.getElementById(`keyboard-rows`),keyboardMode:e.getElementById(`keyboard-mode`),spaceMode:e.getElementById(`space-mode`),resizeHandle:e.getElementById(`keyboard-resize-handle`)}:null}function Te(e=E.document){let t=we(e);return!t?.input||!t.keyboard||!t.keyboardRows?null:F({elements:t,target:xe(t.input)})}if(E.OpenLyricKhmerNidaKeyboard={bootstrapKhmerNidaDemo:Te,createKhmerNidaKeyboard:F,createMonacoInputAdapter:Se,createNativeTextInputAdapter:xe},E.document){let e=Te(E.document);e&&(E.khmerNidaDemoKeyboard=e)}var I=`openLyricKhmerNidaKeyboardVisible`,L=`open-lyric-editor-auto-suggest`,R=`km-kh-nida-keyboard`;function Ee(t){let n=t?.documentElement;if(!(n instanceof HTMLElement)||n.dataset.editorShell!==e.EDITOR_ONLY_SHELL_MODE)return!1;try{return t.defaultView?.localStorage?.getItem(L)!==`0`}catch{return!0}}function De(e,t,n,r){let i=e.createElement(`button`);return i.className=`window-button`,i.id=t,i.type=`button`,i.textContent=n,i.setAttribute(`aria-label`,r),i}function z(e,t,n,r,i){let a=e.createElement(`button`);return a.className=`keyboard-navigation-button`,a.id=`khmer-keyboard-nav-${n}-${t}`,a.type=`button`,a.dataset.direction=n,a.textContent=r,a.setAttribute(`aria-label`,i),a.setAttribute(`title`,i),a}function Oe(e,t,n,r,i){let a=e.createElement(`button`);return a.className=`keyboard-layout-option`,a.id=`keyboard-layout-option-${n}-${t}`,a.type=`button`,a.dataset.layoutId=n,a.textContent=r,a.setAttribute(`aria-checked`,`false`),a.setAttribute(`aria-label`,i),a.setAttribute(`role`,`menuitemradio`),a}function B(e,t){let n=e.createElement(`section`);n.className=`keyboard-popover ol-editor-khmer-keyboard`,n.hidden=!0,n.id=`khmer-keyboard-${t}`;let r=e.createElement(`div`);r.className=`keyboard-header`;let i=De(e,`close-khmer-keyboard-${t}`,`✕`,`Close keyboard`),a=e.createElement(`div`);a.className=`keyboard-title`;let o=e.createElement(`strong`);o.lang=`km`,o.textContent=`អក្សរខ្មែរ NiDA`;let s={up:z(e,t,`up`,`↑`,`Move cursor up`),left:z(e,t,`left`,`←`,`Move cursor left`),down:z(e,t,`down`,`↓`,`Move cursor down`),right:z(e,t,`right`,`→`,`Move cursor right`)},c=e.createElement(`div`);c.className=`keyboard-navigation`,c.setAttribute(`role`,`group`),c.setAttribute(`aria-label`,`Move cursor`),c.append(s.left,s.right,s.up,s.down),a.append(o,c);let l=e.createElement(`div`);l.className=`keyboard-layout-picker`,l.dataset.open=`false`;let u=e.createElement(`button`);u.className=`keyboard-layout-trigger`,u.id=`keyboard-layout-trigger-${t}`,u.type=`button`,u.textContent=`Khmer`,u.setAttribute(`aria-controls`,`keyboard-layout-menu-${t}`),u.setAttribute(`aria-expanded`,`false`),u.setAttribute(`aria-haspopup`,`menu`),u.setAttribute(`aria-label`,`Choose keyboard layout`),u.setAttribute(`title`,`Choose keyboard layout`);let d=e.createElement(`div`);d.className=`keyboard-layout-menu`,d.hidden=!0,d.id=`keyboard-layout-menu-${t}`,d.setAttribute(`aria-label`,`Keyboard layout choices`),d.setAttribute(`role`,`menu`),d.append(Oe(e,t,`khmer`,`Khmer NiDA`,`Use Khmer NiDA keyboard layout`),Oe(e,t,`english`,`English (US)`,`Use English keyboard layout`)),l.append(u,d);let f=e.createElement(`div`);f.className=`keyboard-status`;let p=e.createElement(`span`);p.className=`visually-hidden`,p.id=`keyboard-mode-${t}`,p.textContent=`Normal`;let m=e.createElement(`span`);m.className=`visually-hidden`,m.id=`space-mode-${t}`,m.textContent=`Space: ZWSP`;let h=De(e,`minimize-khmer-keyboard-${t}`,`▾`,`Minimize keyboard`);h.setAttribute(`aria-pressed`,`false`),f.append(p,m,h),r.append(i,a,l,f);let g=e.createElement(`div`);g.className=`keyboard-grid`,g.id=`keyboard-rows-${t}`;let _=e.createElement(`div`);_.className=`keyboard-footer`,_.textContent=`NiDA layout with default zero-width space behavior for Khmer word breaks.`;let v=e.createElement(`div`);return v.className=`keyboard-resize-handle`,v.id=`keyboard-resize-handle-${t}`,v.setAttribute(`aria-hidden`,`true`),n.append(r,g,_,v),{closeButton:i,keyboard:n,keyboardFooter:_,keyboardMode:p,keyboardRows:g,keyboardTitle:o,layoutMenu:d,layoutTrigger:u,minimizeButton:h,navigationButtons:s,resizeHandle:v,spaceMode:m}}function V({editor:e,monaco:t,onStateChange:n,ownerDocument:r,ownerWindow:i,preferences:a,refs:o}){if(!e)throw Error(`Khmer NiDA keyboard plugin requires an editor instance.`);let s=e.getDomNode?.()||o?.editorHost||r.querySelector(`[data-ol-ref="editor"]`);if(!s)throw Error(`Khmer NiDA keyboard plugin could not find the editor host.`);let c=B(r,`editor-khmer-nida`),l=Se(e,{source:`open-lyric-khmer-nida-keyboard`,shouldTriggerSuggestOnInsert(e){return!!String(e??``).trim()&&Ee(r)}}),u=e.createContextKey(I,!1),d=a?.loadKeyboardWindowPreference?.(R)??null,f=t?.KeyMod&&t?.KeyCode?[t.KeyMod.CtrlCmd|t.KeyMod.Alt|t.KeyCode.KeyK]:[],p=!1,m=F({...c,anchorElement:s,closeOnOutsidePointerDown:!1,mountToBody:!0,onStateChange(e){u.set(!!e?.isOpen),p&&a?.saveKeyboardWindowPreference?.(R,e),n?.(e)},ownerDocument:r,ownerWindow:i,target:l});p=!0,d&&m.restoreState?.(d);let h=e.addAction({id:`open-lyric.open-khmer-keyboard`,label:`Open Khmer Keyboard`,precondition:`!${I}`,contextMenuGroupId:`9_cutcopypaste`,contextMenuOrder:7,keybindings:f,run:()=>{m.open()}}),g=e.addAction({id:`open-lyric.close-khmer-keyboard`,label:`Hide Khmer Keyboard`,precondition:I,contextMenuGroupId:`9_cutcopypaste`,contextMenuOrder:7,keybindings:f,run:()=>{m.close()}});return{close(){m.close()},destroy(){h.dispose(),g.dispose(),m.destroy(),c.keyboard.remove(),l.destroy?.()},getState(){return m.getState()},open(){m.open()},toggle(){m.toggle()}}}var H={actionLabel:`Khmer Keyboard`,create:V,displayName:`Khmer NiDA Keyboard`,id:R,openActionId:`open-lyric.open-khmer-keyboard`,closeActionId:`open-lyric.close-khmer-keyboard`},ke=/[\u1780-\u17D3\u17D7\u17DC\u17DD\u200C\u200D.]+/gu,Ae=/^[\u1780-\u17D3\u17D7\u17DC\u17DD\u200C\u200D.]+$/u,je=/[\u1780-\u17B3]/u,U=`​`,W=/([\u1780-\u17D3])[\t\f\v \u00AD\u00A0\u1680\u2000-\u200A\u200C\u202F\u205F\u3000]+(?=[\u1780-\u17B3])/gu,G=Array.from({length:52},(e,t)=>String.fromCharCode(6016+t)),Me=`editor-Battambang`,Ne=[],K=[Me,...Ne],Pe=`ចម្រៀងសាកល្បង`;function Fe(e){return String(e||``).replace(/^[\u200C\u200D]+|[\u200C\u200D]+$/gu,``)}var q={id:`km_KH_ol_editor`,exampleGroupTitle:`Khmer .md Examples`,examples:[{id:`khmer-call-to-worship`,fileName:`khmer-call-to-worship.md`,title:`ព្រះគុណនៅព្រឹកនេះ`,description:`Khmer-only worship draft with a simple intro, verses, and chorus.`,content:s},{id:`khmer-bilingual-prayer`,fileName:`khmer-bilingual-prayer.md`,title:`អធិស្ឋានដោយសេចក្ដីសង្ឃឹម`,description:`Khmer and English line pairs for a prayer-focused Open Lyric draft.`,content:c}],keyboard:H,spellChecker:{actionLabel:`Khmer Spell Checker`,af:r,aliases:[`km-kh`,`km_kh`],baseLetterPattern:je,defaultEnabled:!0,dictionaryName:`km_KH`,dict:i,displayName:`Khmer`,exactWordPattern:Ae,languageCode:`km`,normalizeWord:Fe,providerFactory:te,suggestAffUrls:[a],wordPattern:ke,wordSeparator:U,wordSeparatorPattern:W,suggestTriggerCharacters:G,segmentationActionLabel:`Try Khmer Segmentation`},style:[t,n],fonts:{faces:K,stack:`${K.map(e=>`'${e}'`).join(`, `)}, sans-serif`,sampleText:Pe},transcriptLocales:[`km-KH`],pptxStyle:{fontFamilyChoices:Ne,fontDetectionSampleText:`WWWWmmmm1234567890${Pe}`,fontSize:24}},J=q.fonts.faces,Ie=q.fonts.stack,Le={href:t},Y=[Le],Re=[Le,{href:n}],X=`data-open-lyric-plugin-id`;function ze(e,t){let n=e.querySelectorAll(`[${X}="km-KH"]`);for(let e of Array.from(n))if(t.href&&e.getAttribute(`href`)===t.href||t.cssText&&e.textContent===t.cssText)return!0;return!1}function Be(e){let t=globalThis.document?.head;if(t)for(let n of e){if(!n.href&&!n.cssText||ze(t,n))continue;let e=n.href?Object.assign(document.createElement(`link`),{rel:`stylesheet`,href:n.href}):Object.assign(document.createElement(`style`),{textContent:n.cssText??``});n.media&&(e.media=n.media),e.setAttribute(X,`km-KH`),t.append(e)}}var Ve={fontFaces:J,fontFamily:Ie},He={spellcheck:q.spellChecker,keyboard:{id:q.keyboard.id,displayName:q.keyboard.displayName,create:q.keyboard.create,openActionId:q.keyboard.openActionId,closeActionId:q.keyboard.closeActionId}},Z=class{id=`km-KH`;apiVersion=1;surfaces=[`editor`];contributes={language:He,style:Re};static installShellStyle(){Be(Y)}keyboardController=null;preferences=new e.EditorPreferencesStore;registryRegistration=null;install(){let t=!!(0,e.getRegisteredSpellcheckSpecification)(q.spellChecker.languageCode),n=(0,e.getRegisteredKeyboardSpecifications)().some(e=>e.id===q.keyboard.id);!t&&!n&&(this.registryRegistration=(0,e.registerPlugin)(q))}uninstall(){this.destroyKeyboard(),this.registryRegistration&&=((0,e.unregisterPlugin)(this.registryRegistration),null)}onMount(e){let t=e,n=t.monacoEditor,r=t.monacoNamespace;if(!n||!r)return;let i=e.container?.ownerDocument??document;try{this.keyboardController=q.keyboard.create({editor:n,monaco:r,onStateChange:()=>{},ownerDocument:i,ownerWindow:i.defaultView??window,preferences:this.preferences,refs:null})}catch(e){console.error(`km-KH keyboard failed to mount.`,e),this.keyboardController=null}}onUnmount(){this.destroyKeyboard()}toggleKeyboard(){this.keyboardController?.toggle()}closeKeyboard(){this.keyboardController?.close()}get isKeyboardMounted(){return this.keyboardController!==null}destroyKeyboard(){try{this.keyboardController?.destroy()}catch(e){console.error(`km-KH keyboard failed to dispose.`,e)}this.keyboardController=null}},Ue=class{id=`km-KH`;apiVersion=1;surfaces=[`markdown`];contributes={language:Ve,style:Y};static installShellStyle(){Be(Y)}install(){}uninstall(){}},Q=class{id=`km-KH`;apiVersion=1;surfaces=[`lyric`];contributes={language:Ve,style:Y};static installShellStyle(){Be(Y)}install(){}uninstall(){}},$=`0.1.17`;exports.EditorPluginKmKh=Z,exports.KHMER_BILINGUAL_PRAYER_EXAMPLE=c,exports.KHMER_CALL_TO_WORSHIP_EXAMPLE=s,exports.KM_KH_WEBFONT_FACE=Me,exports.OpenLyricMarkdownManagerPluginKmKh=Ue,exports.OpenLyricPluginKmKh=Q,exports.version=$;
115
115
  //# sourceMappingURL=index.cjs.map