open-lyric-plugin-km-kh 0.1.16 → 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
@@ -111,5 +111,5 @@ Use this example to test Khmer-only Open Lyric sections with a simple worship fl
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.16`;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