lipilekhika 0.0.0-alpha.3 → 0.0.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/cjs/{Assamese-Dv2Uz5Ga.cjs → Assamese-dhmn-cG5.cjs} +1 -1
  2. package/dist/cjs/{Bengali-CP-jqwb3.cjs → Bengali-AyHDa9CB.cjs} +1 -1
  3. package/dist/cjs/{Brahmi-BOnETq6u.cjs → Brahmi-CsYQszNg.cjs} +1 -1
  4. package/dist/cjs/{Devanagari-DogoRXY8.cjs → Devanagari-Bj9p6oAo.cjs} +1 -1
  5. package/dist/cjs/{Granth-9Z5eCctH.cjs → Granth-C5QS6-4F.cjs} +1 -1
  6. package/dist/cjs/{Gujarati-CUm-ZsKN.cjs → Gujarati-DDgp0rgc.cjs} +1 -1
  7. package/dist/cjs/{Gurumukhi-CsObr-GI.cjs → Gurumukhi-CgwjI-2-.cjs} +1 -1
  8. package/dist/cjs/{Kannada-SXQdSng_.cjs → Kannada-BehuRkBy.cjs} +1 -1
  9. package/dist/cjs/{Malayalam-IcKWWsaB.cjs → Malayalam-DNkMBOZJ.cjs} +1 -1
  10. package/dist/cjs/{Modi-C3Chvoab.cjs → Modi-BKej9fr4.cjs} +1 -1
  11. package/dist/cjs/Normal-CzCJsK17.cjs +1 -0
  12. package/dist/cjs/{Odia-C_-bjsx6.cjs → Odia-D6VWCjnW.cjs} +1 -1
  13. package/dist/cjs/{Purna-Devanagari-BkPRDmig.cjs → Purna-Devanagari-cd6tmmTa.cjs} +1 -1
  14. package/dist/cjs/Romanized-BLiLojEU.cjs +1 -0
  15. package/dist/cjs/{Sharada-DfQQFnhQ.cjs → Sharada-k8TWsbw8.cjs} +1 -1
  16. package/dist/cjs/{Siddham-D4xax5q5.cjs → Siddham-Dp-RBN4a.cjs} +1 -1
  17. package/dist/cjs/{Sinhala-oz5fU6-H.cjs → Sinhala-efDwwfSI.cjs} +1 -1
  18. package/dist/cjs/{Tamil-pc27DGFa.cjs → Tamil-CDg-utf6.cjs} +1 -1
  19. package/dist/cjs/{Tamil-Extended-Bg0_zDSf.cjs → Tamil-Extended-DplAd4jx.cjs} +1 -1
  20. package/dist/cjs/{Telugu-C9jvVXuj.cjs → Telugu-QjXiBHN5.cjs} +1 -1
  21. package/dist/cjs/index.cjs +1 -1
  22. package/dist/cjs/script_normalization-g6-8nPBr.cjs +2 -0
  23. package/dist/cjs/typing.cjs +1 -1
  24. package/dist/esm/{Assamese-C2ZNJvdv.js → Assamese-amSJytUJ.js} +17 -13
  25. package/dist/esm/{Bengali-B4lwiGw-.js → Bengali-luePe7NL.js} +17 -13
  26. package/dist/esm/{Brahmi-P_BhbEU1.js → Brahmi-CYSJHtY2.js} +17 -13
  27. package/dist/esm/{Devanagari-CU6oiaDU.js → Devanagari-WIICcXL0.js} +18 -14
  28. package/dist/esm/{Granth-v69SsV6n.js → Granth-Bel804bU.js} +18 -14
  29. package/dist/esm/{Gujarati-GMDcD3zf.js → Gujarati-C_NXpIK3.js} +17 -13
  30. package/dist/esm/{Gurumukhi-cSQGlqXa.js → Gurumukhi-TSEVFjjO.js} +17 -13
  31. package/dist/esm/{Kannada-BC0s2WZG.js → Kannada-b7EKI5xZ.js} +17 -13
  32. package/dist/esm/{Malayalam-R6qN3iwf.js → Malayalam-CxZ-wJJz.js} +17 -13
  33. package/dist/esm/{Modi-B8YiZBXf.js → Modi-yCyyBSg8.js} +17 -13
  34. package/dist/esm/Normal-BjzUDmwr.js +25 -0
  35. package/dist/esm/{Odia-DphK-sRO.js → Odia-DtN-b0Vg.js} +17 -13
  36. package/dist/esm/{Purna-Devanagari-iW765mfa.js → Purna-Devanagari-BlnoDFVP.js} +18 -14
  37. package/dist/esm/Romanized-s8IwxQgs.js +25 -0
  38. package/dist/esm/{Sharada-DOmuoJ5u.js → Sharada-BTRkqc7S.js} +18 -14
  39. package/dist/esm/{Siddham-CZ7F2rJg.js → Siddham-BGkh5RRu.js} +18 -14
  40. package/dist/esm/{Sinhala-BKPrzGBh.js → Sinhala-CO83B8vR.js} +17 -13
  41. package/dist/esm/{Tamil-B_Q1LP6g.js → Tamil-ByILtq3J.js} +17 -13
  42. package/dist/esm/{Tamil-Extended-8h88s1_g.js → Tamil-Extended-DwseqnA4.js} +17 -13
  43. package/dist/esm/{Telugu-w-eiYYTU.js → Telugu-DDGs0-Mo.js} +17 -13
  44. package/dist/esm/index.mjs +13 -14
  45. package/dist/esm/script_normalization-DfUrrCEZ.js +712 -0
  46. package/dist/esm/typing.mjs +150 -4
  47. package/dist/index.d.ts +91 -54
  48. package/dist/lipilekhika.umd.js +2 -2
  49. package/dist/typing.d.ts +50 -3
  50. package/dist/umd_json/script_data/Assamese.json +1 -1
  51. package/dist/umd_json/script_data/Bengali.json +1 -1
  52. package/dist/umd_json/script_data/Brahmi.json +1 -1
  53. package/dist/umd_json/script_data/Devanagari.json +1 -1
  54. package/dist/umd_json/script_data/Granth.json +1 -1
  55. package/dist/umd_json/script_data/Gujarati.json +1 -1
  56. package/dist/umd_json/script_data/Gurumukhi.json +1 -1
  57. package/dist/umd_json/script_data/Kannada.json +1 -1
  58. package/dist/umd_json/script_data/Malayalam.json +1 -1
  59. package/dist/umd_json/script_data/Modi.json +1 -1
  60. package/dist/umd_json/script_data/Normal.json +1 -1
  61. package/dist/umd_json/script_data/Odia.json +1 -1
  62. package/dist/umd_json/script_data/Purna-Devanagari.json +1 -1
  63. package/dist/umd_json/script_data/Romanized.json +1 -1
  64. package/dist/umd_json/script_data/Sharada.json +1 -1
  65. package/dist/umd_json/script_data/Siddham.json +1 -1
  66. package/dist/umd_json/script_data/Sinhala.json +1 -1
  67. package/dist/umd_json/script_data/Tamil-Extended.json +1 -1
  68. package/dist/umd_json/script_data/Tamil.json +1 -1
  69. package/dist/umd_json/script_data/Telugu.json +1 -1
  70. package/package.json +6 -2
  71. package/dist/cjs/Normal-BZe6xAux.cjs +0 -1
  72. package/dist/cjs/Romanized-B_o6BaP0.cjs +0 -1
  73. package/dist/cjs/typing-BLcGlYhq.cjs +0 -2
  74. package/dist/esm/Normal-DH6dfVGR.js +0 -21
  75. package/dist/esm/Romanized-BQU9AmMX.js +0 -21
  76. package/dist/esm/typing-BglIxYDV.js +0 -748
@@ -1,6 +1,152 @@
1
- import { f as t, e as a, h as o } from "./typing-BglIxYDV.js";
1
+ import { g as U, a as x, r as K, d as R } from "./script_normalization-DfUrrCEZ.js";
2
+ const b = 4500, D = !0, N = !1;
3
+ function C(r, n) {
4
+ const { autoContextTClearTimeMs: t } = n ?? {};
5
+ let i = n?.useNativeNumerals ?? D, m = n?.includeInherentVowel ?? N;
6
+ const s = U(r);
7
+ if (!s)
8
+ throw new Error(`Invalid script name: ${r}`);
9
+ let a = "", e = "";
10
+ const c = t ?? b;
11
+ let o = null, _ = null, f = null, p = {}, l = [];
12
+ const E = (async () => {
13
+ const [u, y] = await Promise.all([
14
+ x("Normal"),
15
+ x(s)
16
+ ]);
17
+ _ = u, f = y;
18
+ const T = K(u, y);
19
+ p = T.trans_options, l = T.custom_rules;
20
+ })();
21
+ function w() {
22
+ o = null, a = "", e = "";
23
+ }
24
+ function S(u) {
25
+ if (!_ || !f)
26
+ throw new Error(
27
+ "Typing context not ready. Await `ctx.ready` before calling takeKeyInputSync."
28
+ );
29
+ const y = Date.now();
30
+ o && y - o > c && w();
31
+ let T = u?.[0] ?? "";
32
+ a += T;
33
+ let g = e;
34
+ const { context_length: h, output: v } = R(
35
+ a,
36
+ "Normal",
37
+ s,
38
+ _,
39
+ f,
40
+ p,
41
+ l,
42
+ {
43
+ typing_mode: !0,
44
+ useNativeNumerals: i,
45
+ includeInherentVowel: m
46
+ }
47
+ );
48
+ h > 0 ? e = v : h === 0 && w();
49
+ let d = 0;
50
+ for (; d < v.length && d < g.length && v[d] === g[d]; )
51
+ d++;
52
+ let I = v.substring(d), A = g.length - d;
53
+ return o = Date.now(), {
54
+ /** These number of characters need to be deleted from the current "app" input state */
55
+ to_delete_chars_count: A,
56
+ /** These characters need to be added to the current "app" input state */
57
+ diff_add_text: I
58
+ };
59
+ }
60
+ return {
61
+ /** Await once, then use `takeKeyInputSync` for best typing latency. */
62
+ ready: E,
63
+ clearContext: w,
64
+ takeKeyInput: S,
65
+ updateUseNativeNumerals: (u) => {
66
+ i = u ?? D;
67
+ },
68
+ updateIncludeInherentVowel: (u) => {
69
+ m = u ?? N;
70
+ }
71
+ };
72
+ }
73
+ async function M(r, n, t, i) {
74
+ if (!(i ?? !0)) {
75
+ t?.(n?.currentTarget?.value);
76
+ return;
77
+ }
78
+ const s = n?.nativeEvent ?? n, a = "nativeEvent" in n, e = n?.currentTarget ?? s?.target;
79
+ if (!s || !e || s.isComposing) return;
80
+ if (s.inputType !== "insertText") {
81
+ t?.(e.value), r.clearContext();
82
+ return;
83
+ }
84
+ const c = s.data;
85
+ if (typeof c != "string" || c.length !== 1) {
86
+ t?.(e.value), r.clearContext();
87
+ return;
88
+ }
89
+ const o = e.selectionStart ?? 0, _ = e.selectionEnd ?? o;
90
+ if (o !== _) {
91
+ t?.(e.value), r.clearContext();
92
+ return;
93
+ }
94
+ a && t && t(n.currentTarget.value), await r.ready;
95
+ const { diff_add_text: f, to_delete_chars_count: p } = r.takeKeyInput(c), l = o, E = Math.max(0, l - p - c.length);
96
+ e.setRangeText(f, E, l, "end"), t?.(e.value);
97
+ }
98
+ async function O(r, n, t, i) {
99
+ if (!(i ?? !0))
100
+ return;
101
+ const a = "nativeEvent" in n ? n.nativeEvent : n, e = n?.currentTarget ?? a?.target;
102
+ if (!a || !e || a.isComposing || (!a.inputType || a.inputType !== "insertText") && (!a.type || a.type !== "textInput"))
103
+ return;
104
+ const c = a.data;
105
+ if (typeof c != "string" || c.length === 0) return;
106
+ if (c.length !== 1) {
107
+ r.clearContext();
108
+ return;
109
+ }
110
+ const o = e.selectionStart ?? 0, _ = e.selectionEnd ?? o;
111
+ if (o !== _) {
112
+ r.clearContext();
113
+ return;
114
+ }
115
+ a.preventDefault?.(), await r.ready;
116
+ const { diff_add_text: f, to_delete_chars_count: p } = r.takeKeyInput(c), l = o, E = Math.max(0, l - p);
117
+ e.setRangeText(f, E, l, "end"), t?.(e.value);
118
+ }
119
+ const k = /* @__PURE__ */ new Set([
120
+ "Backspace",
121
+ "Delete",
122
+ "Enter",
123
+ "Tab",
124
+ "Escape",
125
+ "ArrowLeft",
126
+ "ArrowRight",
127
+ "ArrowUp",
128
+ "ArrowDown",
129
+ "Home",
130
+ "End",
131
+ "PageUp",
132
+ "PageDown"
133
+ ]);
134
+ function P(r, n) {
135
+ const t = r?.nativeEvent ?? r;
136
+ if (t instanceof KeyboardEvent) {
137
+ if (t.isComposing) return !1;
138
+ const i = t.key;
139
+ if (!i || i === "Unidentified" || i === "Process" || i === "Dead" || t.ctrlKey || t.metaKey || t.altKey) return !1;
140
+ if (k.has(i))
141
+ return n.clearContext(), !0;
142
+ }
143
+ return !1;
144
+ }
2
145
  export {
3
- t as clearTypingContextOnKeyDown,
4
- a as createTypingContext,
5
- o as handleTypingInputEvent
146
+ N as DEFAULT_INCLUDE_INHERENT_VOWEL,
147
+ D as DEFAULT_USE_NATIVE_NUMERALS,
148
+ P as clearTypingContextOnKeyDown,
149
+ C as createTypingContext,
150
+ O as handleTypingBeforeInputEvent,
151
+ M as handleTypingInputEvent
6
152
  };
package/dist/index.d.ts CHANGED
@@ -4,14 +4,6 @@ declare type alternate_script_type = (typeof ALTERNATES)[number];
4
4
 
5
5
  declare const ALTERNATES: readonly ["dev", "te", "tel", "tam", "tam-ex", "ben", "be", "ka", "kan", "gu", "guj", "mal", "or", "od", "oriya", "si", "sinh", "sin", "en", "eng", "la", "lat", "nor", "norm", "rom", "gur", "as", "sa", "san", "hin", "hi", "mar", "ne", "nep", "pun"];
6
6
 
7
- /**
8
- * Checks if the keydown event should clear the typing context
9
- * @param e - The keydown event
10
- * @param ctx - The typing context
11
- * @returns True if the keydown event should clear the typing context, false otherwise
12
- */
13
- declare function clearTypingContextOnKeyDown(e: any, ctx: ReturnType<typeof createTypingContext>): boolean;
14
-
15
7
  declare type CommonListTypeAttributes = {
16
8
  text: string;
17
9
  /** In the post processing step the keys for which it is not mapped shall be left empty.
@@ -69,33 +61,48 @@ declare type CommonScriptData = {
69
61
  krama_ref: number[];
70
62
  type: NonNullable<NonNullable<InputOtherScriptType['list']>[number]['type']>;
71
63
  }[];
72
- };
73
-
74
- /**
75
- * Creates a stateful isolated context for character by character input typing.
76
- * This is the main function which returns the `diff`, different realtime schems can be implemented using this.
77
- *
78
- * **Note** :- Script Data is loaded in background but it would still be good to await `ready` before using the context.
79
- * @param typing_lang - The script/language to type in
80
- * @returns A closed over context object with the following methods:
81
- */
82
- declare function createTypingContext(typing_lang: ScriptLangType): {
83
- /** Await once, then use `takeKeyInputSync` for best typing latency. */
84
- ready: Promise<void>;
85
- clearContext: () => void;
86
- takeKeyInput: (key: string) => {
87
- /** These number of characters need to be deleted from the current "app" input state */
88
- to_delete_chars_count: number;
89
- /** These characters need to be added to the current "app" input state */
90
- diff_add_text: string;
91
- };
64
+ /**
65
+ * This map is a alternate map to be used instead of Normal's `text_to_krama_map` for typing mode.
66
+ * It contains references to both `list` (for `type` info) and also to `custom_script_chars`
67
+ *
68
+ * This will be a sorted array
69
+ */
70
+ typing_text_to_krama_map: [
71
+ text: string,
72
+ {
73
+ next?: string[] | null;
74
+ krama?: number[] | null;
75
+ /** Reference to a custom script character of that script */
76
+ custom_back_ref?: number | null;
77
+ /** This will not be actually there, but there for type compatibility */
78
+ fallback_list_ref?: number | null;
79
+ }
80
+ ][];
81
+ /** Custom Script Characters not present in the common krama key data
82
+ *
83
+ * This will be a sorted array.
84
+ *
85
+ * For list_ref the element should also be a duplicate in the target script.
86
+ * Check in text_to_krama_map if not display a warning.
87
+ * And for backreferencing in the list use the krama_ref of the base form.
88
+ * Eg :- Malayalam k1 is a duplicate of k, so in back_ref use k's krama_ref
89
+ */
90
+ custom_script_chars_arr: [
91
+ text: string,
92
+ /** This will be used to deterime the type of the custom script character
93
+ * eg:- Malayalam chillu ka is a vyanjana */
94
+ list_ref: number | null,
95
+ /** This will be used to get the Normal text key of the custom script character.
96
+ *
97
+ * This is needed here as there is no equivalent of it present in the krama data
98
+ */
99
+ custom_ref: number | null
100
+ ][];
92
101
  };
93
102
 
94
103
  declare type CustomOptionList = keyof typeof _default;
95
104
 
96
- declare type CustomOptionType = {
97
- [key in CustomOptionList]?: boolean;
98
- };
105
+ declare type CustomOptionType = Partial<Record<CustomOptionList, boolean>>;
99
106
 
100
107
  declare const _default: {
101
108
  "all_to_normal:replace_pancham_varga_varna_with_n": {
@@ -313,6 +320,22 @@ declare const _default: {
313
320
  ]
314
321
  }
315
322
  ]
323
+ },
324
+ "normal_to_all:use_typing_chars": {
325
+ "from_script_name": [
326
+ "Normal"
327
+ ],
328
+ "to_script_type": "all",
329
+ "check_in": "output",
330
+ "rules": []
331
+ },
332
+ "all_to_normal:preserve_specific_chars": {
333
+ "from_script_type": "all",
334
+ "to_script_name": [
335
+ "Normal"
336
+ ],
337
+ "check_in": "output",
338
+ "rules": []
316
339
  }
317
340
  };
318
341
 
@@ -323,16 +346,7 @@ declare const _default: {
323
346
  * @param to_script_name - The script/language to transliterate to
324
347
  * @returns The list of all supported custom options for the provided script pair
325
348
  */
326
- export declare function getAllOptions(from_script_name: ScriptLangType, to_script_name: ScriptLangType): Promise<("all_to_normal:replace_pancham_varga_varna_with_n" | "brahmic_to_brahmic:replace_pancham_varga_varna_with_anuvsvAra" | "all_to_sinhala:use_conjuct_enabling_halant" | "all_to_normal:remove_virAma_and_double_virAma" | "all_to_normal:replace_avagraha_with_a")[]>;
327
-
328
- /**
329
- * Handles input events for transliteration typing in `input` and `textarea` elements
330
- *
331
- * @param typingContext - The typing context created for the element
332
- * @param event - Input Event
333
- * @param onValueChange - Optional callback function invoked when the value changes
334
- */
335
- declare function handleTypingInputEvent(typingContext: ReturnType<typeof createTypingContext>, event: any, onValueChange?: (updatedValue: string) => void, enabled_?: boolean): Promise<void>;
349
+ export declare function getAllOptions(from_script_name: ScriptLangType, to_script_name: ScriptLangType): Promise<("all_to_normal:replace_pancham_varga_varna_with_n" | "brahmic_to_brahmic:replace_pancham_varga_varna_with_anuvsvAra" | "all_to_sinhala:use_conjuct_enabling_halant" | "all_to_normal:remove_virAma_and_double_virAma" | "all_to_normal:replace_avagraha_with_a" | "normal_to_all:use_typing_chars" | "all_to_normal:preserve_specific_chars")[]>;
336
350
 
337
351
  declare type InputBrahmicScriptType = {
338
352
  script_name: script_list_type;
@@ -383,6 +397,7 @@ declare type InputBrahmicScriptType = {
383
397
  } | {
384
398
  type: 'vyanjana' | 'anya';
385
399
  }))[];
400
+ typing_list: InputTypingListDataType[];
386
401
  };
387
402
 
388
403
  declare type InputOtherScriptType = {
@@ -399,6 +414,32 @@ declare type InputOtherScriptType = {
399
414
  /** `type` is kind of redundant here as other scripts don't have a concept of svara and vyanjana */
400
415
  type?: 'anya';
401
416
  })[];
417
+ typing_list: InputTypingListDataType[];
418
+ };
419
+
420
+ /**
421
+ * Custom Structure which will be used for typing mode, _`normal_to_all:use_typing_chars`_
422
+ * and _`all_to_normal:preserve_specific_chars`_
423
+ *
424
+ * Eg. :- U -> uu, oo, I -> ii, ee
425
+ */
426
+ declare type InputTypingListDataType = {
427
+ type: 'duplicates';
428
+ /** This is Normal key for which duplicates have to be defined */
429
+ ref_krama_key: KramaKeysLabelType;
430
+ duplicates: string[];
431
+ } | {
432
+ type: 'custom_script_char';
433
+ /** This is the specific text which has to be mapped.
434
+ *
435
+ * Eg. :- Tamil and Malayalam :- 10, 100 and 1000 |
436
+ * Malayalam :- Specific versions of a new characters (Chillu versions nz, N, rz, l, lz and k)
437
+ */
438
+ specific_text: string;
439
+ /** This is the custom normal mapping that will be used for reverse mapping also
440
+ * as for this no equivalent krama key mapping exists
441
+ */
442
+ custom_normal_key: string;
402
443
  };
403
444
 
404
445
  declare const KramaKeysArray: (keyof typeof KramaKeysMap)[];
@@ -522,9 +563,9 @@ declare const KramaKeysMap: {
522
563
  readonly श: "sh";
523
564
  readonly ष: "Sh";
524
565
  readonly '\u0952': "anudAttA";
525
- readonly '\u0951': "udAtta-1";
526
- readonly '\u1CDA': "udAtta-2";
527
- readonly '\u1CDB': "udAtta-3";
566
+ readonly '\u0951': "svarita-1";
567
+ readonly '\u1CDA': "svarita-2";
568
+ readonly '\u1CDB': "svarita-3";
528
569
  readonly '\u0966': "0";
529
570
  readonly '\u0967': "1";
530
571
  readonly '\u0968': "2";
@@ -592,6 +633,10 @@ declare type OutputScriptData = OutputBrahmicScriptData | OutputOtherScriptData;
592
633
  */
593
634
  export declare const preloadScriptData: (name: script_input_name_type) => Promise<OutputScriptData>;
594
635
 
636
+ export declare type Prettify<T> = {
637
+ [K in keyof T]: T[K];
638
+ } & {};
639
+
595
640
  declare type script_and_lang_list_type = script_list_type | lang_list_type;
596
641
 
597
642
  declare type script_input_name_type = alternate_script_type | script_and_lang_list_type;
@@ -639,22 +684,14 @@ export declare type ScriptListType = script_list_type;
639
684
  * @param text - The text to transliterate
640
685
  * @param from - The script/language to transliterate from
641
686
  * @param to - The script/language to transliterate to
642
- * @param options - The custom options to use for the transliteration
687
+ * @param trans_options - The custom transliteration options to use for the transliteration
643
688
  * @returns The transliterated text
644
689
  */
645
- export declare function transliterate(text: string, from: ScriptLangType, to: ScriptLangType, options?: CustomOptionType): Promise<string>;
690
+ export declare function transliterate(text: string, from: ScriptLangType, to: ScriptLangType, trans_options?: CustomOptionType): Promise<string>;
646
691
 
647
692
  /**
648
693
  * Custom Transliteration Options
649
694
  */
650
695
  export declare type TransliterationOptions = CustomOptionType;
651
696
 
652
- export declare namespace typing {
653
- export {
654
- createTypingContext,
655
- handleTypingInputEvent,
656
- clearTypingContextOnKeyDown
657
- }
658
- }
659
-
660
697
  export { }
@@ -1,2 +1,2 @@
1
- (function(w,L){typeof exports=="object"&&typeof module<"u"?L(exports):typeof define=="function"&&define.amd?define(["exports"],L):(w=typeof globalThis<"u"?globalThis:w||self,L(w.lipilekhika={}))})(this,(function(w){"use strict";function L(t,e,r,a){const{accessor:n,compareFn:o}=a??{},c=n??((i,l)=>i[l]);let s=0,p=e.length-1,u=-1;for(;s<=p;){const i=Math.floor((s+p)/2),l=e[i],_=c(t,l);let f;o?f=o(r,_):f=r<_?-1:r>_?1:0,f===0?(u=l,p=i-1):f<0?p=i-1:s=i+1}return u}function ne(t,e,r){const{accessor:a,compareFn:n}=r??{},o=a??((u,i)=>u[i]);let c=0,s=t.length-1,p=-1;for(;c<=s;){const u=Math.floor((c+s)/2),i=o(t,u);let l;n?l=n(e,i):l=e<i?-1:e>i?1:0,l===0?(p=u,s=u-1):l<0?s=u-1:c=u+1}return p}const ae={},M=async t=>{{if(ae[t])return ae[t];const r=`https://cdn.jsdelivr.net/npm/lipilekhika@0.0.0-alpha.3/dist/umd_json/script_data/${t}.json`,n=(await fetch(r)).json();return ae[t]=n,n}},V={"all_to_normal:replace_pancham_varga_varna_with_n":{from_script_type:"all",to_script_name:["Normal"],check_in:"output",rules:[{type:"replace_prev_krama_keys",check_in:"output",prev:[60],following:[52,53,54,55,56,57,58,59],replace_with:[72]},{type:"replace_prev_krama_keys",check_in:"output",prev:[67],following:[61,62,63,64,65,66],replace_with:[72]}]},"brahmic_to_brahmic:replace_pancham_varga_varna_with_anuvsvAra":{from_script_type:"brahmic",to_script_type:"brahmic",check_in:"input",rules:[{type:"replace_prev_krama_keys",check_in:"input",prev:[60,49],following:[52,53,54,55,56,57,58,59],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[67,49],following:[61,62,63,64,65,66],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[81,49],following:[74,75,76,77,78,79,80],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[72,49],following:[68,69,70,71],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[88,49],following:[82,83,85,86,87],replace_with:[45]}]},"all_to_sinhala:use_conjuct_enabling_halant":{from_script_type:"all",to_script_name:["Sinhala"],check_in:"output",rules:[{type:"direct_replace",check_in:"output",to_replace:[[49]],replace_text:"්‍",replace_with:[]}]},"all_to_normal:remove_virAma_and_double_virAma":{from_script_type:"all",to_script_name:["Normal","Romanized"],check_in:"output",rules:[{type:"direct_replace",check_in:"output",to_replace:[[116],[115]],replace_with:[-1]}]},"all_to_normal:replace_avagraha_with_a":{from_script_type:"all",to_script_name:["Normal","Romanized"],check_in:"output",rules:[{type:"direct_replace",check_in:"output",to_replace:[[48]],replace_with:[1]}]}},ke=(t,e)=>{const r=t.krama_text_arr[e]?.[0];return typeof r=="string"?r:null},P=(t,e)=>ke(t,e)??"",ee=(t,e)=>L(t.krama_text_arr,t.krama_text_arr_index,e,{accessor:(r,a)=>r[a][0]}),ge=()=>{let t=[];function e(i){i&&t.push(i)}function r(i){for(const l of i)e(l)}function a(){return t.at(-1)}function n(){return a()?.at(-1)}function o(){const i=a();if(!i)return;const l=i.at(-1),_=i.slice(0,-1);return _?t[t.length-1]=_:t.pop(),l}function c(i,l){t.splice(-i,i,...l.filter(Boolean))}function s(i,l){const _=o();if(!_){r(i),r(l);return}r(i),e(_),r(l)}function p(i){const l=t.at(i);return l?{cp:i,ch:l,width:l.length}:null}function u(i,l){i<0&&(i=t.length+i),!(i<0||i>=t.length)&&(t[i]=l)}return{emit:e,emitPieces:r,lastPiece:a,lastChar:n,popLastChar:o,rewriteTailPieces:c,withLastCharMovedAfter:s,toString:()=>t.join(""),rewriteAt:u,peekAt:p}},ve=t=>{let e=[];function r(){e=[]}function a(){return e.length}function n(_){return e.at(_)}function o(){return e.at(-1)}function c(){return o()?.[0]}function s(){return o()?.[1]?.type}function p(_){return n(_)?.[1]?.type}function u(_){return n(_)?.[0]}function i(_){return s()===_}function l(_){const f=_[0];f!==void 0&&f.length>0&&e.push(_),e.length>t&&e.shift()}return{clear:r,length:a,at:n,last:o,lastText:c,lastType:s,typeAt:p,textAt:u,isLastType:i,push:l}},xe=t=>{let e=0;function r(s){const p=t.codePointAt(s);if(p===void 0)return null;const u=String.fromCodePoint(p);return{cp:p,ch:u,width:u.length}}function a(){return r(e)}function n(s){return r(e+s)}function o(s){e+=s}function c(s,p){return t.substring(s,p)}return{get pos(){return e},peek:a,peekAt:r,peekAtOffsetUnits:n,advance:o,slice:c}},re=(t,e,r,a)=>{for(let n=0;n<r.length;n++){const o=r[r.length-1-n],c=t(e-n);if(c===null)return{matched:!1,matchedLen:0};const s=ee(a,c.ch);if(s===-1||s!==o)return{matched:!1,matchedLen:0}}return{matched:!0,matchedLen:r.length}},ie=(t,e)=>t.map(r=>P(e,r)).filter(Boolean),Ae=["²","³","⁴"],I=t=>!!t&&Ae.indexOf(t)!==-1,C=t=>t==="Tamil-Extended",B=(t,e,r,a)=>{if(e.length===0)return;if(!a){t.emitPieces(e);return}const n=e[0]??"";if(n[0]===r){const o=n.slice(1),c=[];o&&c.push(o);for(let s=1;s<e.length;s++)c.push(e[s]);t.withLastCharMovedAfter([r],c)}else t.withLastCharMovedAfter(e,[])},we=[" ",`
2
- `,"\r"," ",",",";","!","@","?","%"],Te=3;function b(t,e,r){const{from_script_name:a,to_script_name:n,from_script_data:o,to_script_data:c,trans_options:s,result:p,prev_context:u,BRAHMIC_HALANT:i,BRAHMIC_NUQTA:l,typing_mode:_}=t,{next:f,last_extra_call:k}=r??{};let g=!1;if((l&&u.typeAt(-3)==="vyanjana"&&u.textAt(-2)===l&&u.typeAt(-1)==="mAtrA"||u.typeAt(-2)==="vyanjana"&&u.typeAt(-1)==="mAtrA")&&(!e||e[1]?.type==="anya")&&u.clear(),o.script_type==="brahmic"&&c.script_type==="other")e[0]!==i&&(!(C(a)&&e[0]&&e[0].length>0)||e[0].charAt(0)!==i)&&(!l||e[0]!==l)&&(u.typeAt(-1)==="vyanjana"||l&&u.typeAt(-2)==="vyanjana"&&u.textAt(-1)===l)&&(e[1]?.type!=="mAtrA"&&e[0]!==i||e[1]?.type==="anya"||e[1]===null||e[1]===void 0)&&p.emit(c.schwa_character);else if(o.script_type==="other"&&c.script_type==="brahmic")if(u.typeAt(-1)==="vyanjana"&&(e[1]?.type==="mAtrA"||e[1]?.type==="svara")){const d=e[1].type==="svara"?P(c,e[1].mAtrA_krama_ref?.[0]??-1):e[0];C(n)&&I(p.lastChar())?B(p,[d],c.halant,!0):B(p,[d],c.halant,!1),g=!0}else u.typeAt(-1)==="vyanjana"&&!(e[0]===i||e[1]?.type==="mAtrA")&&(C(n)&&I(p.lastChar())?B(p,[i],c.halant,!0):(B(p,[i],c.halant,!1),n==="Sinhala"&&s["all_to_sinhala:use_conjuct_enabling_halant"]&&p.rewriteAt(-1,p.lastPiece()+"‍")));let m=!1;return _&&(f===void 0||f.length===0)&&!k&&(m=!0,e[1]?.type==="vyanjana"&&(m=!1),m&&u.clear()),(!_||!k&&!m)&&u.push(e),g}function ue(t,e,r){const{custom_rules:a,cursor:n,result:o,from_script_data:c,to_script_data:s}=t,p=e+r;for(let u=0;u<a.length;u++){if(a[u].use_replace===!0)continue;const i=a[u];if(i.type==="replace_prev_krama_keys"){if(i.check_in==="input"){const l=re(n.peekAt,p,i.prev,c),_=n.peekAt(e);if(l.matched&&_!==null){const f=_.ch,k=ee(c,f);if(k!==-1&&i.following.indexOf(k)!==-1){const g=ie(i.replace_with,s);o.rewriteTailPieces(l.matchedLen,g)}}}else if(i.check_in==="output"){const l=o.lastPiece();if(!l)continue;const _=ee(s,l);if(_!==-1&&i.following.indexOf(_)!==-1){const f=re(o.peekAt,-2,i.prev,s);if(f.matched){const k=ie(i.replace_with,s);o.rewriteTailPieces(f.matchedLen+1,[...k,l])}}}}else if(i.type==="direct_replace"){const l=i.check_in==="output"?s:c;for(const _ of i.to_replace){const f=re(o.peekAt,-1,_,l);if(!f.matched)continue;if(i.replace_text){o.rewriteTailPieces(f.matchedLen,[i.replace_text]);break}const k=ie(i.replace_with,l);o.rewriteTailPieces(f.matchedLen,k);break}}}}const _e=(t,e,r)=>{if(!r)return{};const a={};for(const[n,o]of Object.entries(r??{})){if(!o||!(n in V))continue;const c=V[n];(c.from_script_type!==void 0&&(c.from_script_type==="all"||c.from_script_type===t.script_type)||c.from_script_name!==void 0&&c.from_script_name.includes(t.script_name))&&(c.to_script_type!==void 0&&(c.to_script_type==="all"||c.to_script_type===e.script_type)||c.to_script_name!==void 0&&c.to_script_name.includes(e.script_name))&&(a[n]=!0)}return a},pe=(t,e,r)=>{const a=_e(t,e,r),n=Object.keys(a).flatMap(o=>V[o].rules);return{trans_options:a,custom_rules:n}},he=(t,e)=>t.replace_with.map(r=>P(e,r)).join(""),fe=(t,e,r,a)=>{if(r.length===0)return t;for(const n of r)if(!(n.use_replace!==!0||n.check_in!==a)){if(n.type==="replace_prev_krama_keys"){const o=n.prev.map(c=>P(e,c)).join("");for(let c of n.following){const s=P(e,c);if(!s)continue;const p=he(n,e)+s;t=t.replaceAll(o+s,p)}}else if(n.type==="direct_replace"){const o=n.to_replace.map(c=>c.map(s=>P(e,s)).join(""));for(let c of o)t=t.replaceAll(c,he(n,e))}}return t},me=(t,e,r,a,n,o,c,s)=>{const p=s?.typing_mode??!1;if(p&&e!=="Normal")throw new Error("Typing mode is only supported with Normal script as the input");t=fe(t,a,c,"input");const u=ge();let i=0;const l=xe(t),_=ve(Te),f=a.script_type==="brahmic"&&n.script_type==="other"||a.script_type==="other"&&n.script_type==="brahmic"||p&&e==="Normal"&&n.script_type==="other",k=a.script_type==="brahmic"&&n.script_type==="other"?a.nuqta??null:a.script_type==="other"&&n.script_type==="brahmic"?n.nuqta??null:null,g=a.script_type==="brahmic"&&n.script_type==="other"?a.halant:a.script_type==="other"&&n.script_type==="brahmic"?n.halant:null,m={from_script_name:e,to_script_name:r,from_script_data:a,to_script_data:n,trans_options:o,custom_rules:c,cursor:l,result:u,prev_context:_,BRAHMIC_NUQTA:k,BRAHMIC_HALANT:g,typing_mode:p};let d=-1;for(;l.pos<t.length;){i=l.pos;const U=l.peek();if(!U)break;const $=U.ch,X=U.width,de=X===2?1:X;if(d!==-1&&i>=d){d=-1,l.advance(X);continue}if(we.indexOf($)!==-1){l.advance(X),f&&(b(m,[" ",null]),_.clear()),u.emit($);continue}let G=-1;{let S=0,q=-1;const E=f&&a.script_type==="other"&&n.script_type==="brahmic"&&(_.typeAt(-1)==="vyanjana"||k&&_.typeAt(-2)==="vyanjana"&&_.textAt(-1)===k);for(;;){const te=l.peekAt(i+de+S),O=te?.ch??"";d!==-1&&O&&I(O)&&(S+=te?.width??0);const y=i+de+S,T=d!==-1?l.slice(i,d)+(y>d?l.slice(d+1,y):""):l.slice(i,y),v=ne(a.text_to_krama_map,T,{accessor:(x,j)=>x[j][0]});if(v===-1){G=-1;break}const D=a.text_to_krama_map[v];if(E&&D[1].krama&&D[1].krama.length>=1){const x=D[1].krama,j=x[0],N=n.krama_text_arr[j]?.[1],se=n.list[N??-1]?.type;if(x.length===1&&N!==null&&N!==void 0&&(se==="svara"||se==="mAtrA"))q=v;else if(q!==-1){G=q;break}}if(D[1].next&&D[1].next.length>0){const x=l.peekAt(y),j=x?.ch;if(C(e)&&a.script_type==="brahmic"){const Q=x?l.peekAt(y+x.width):null,N=Q?.ch,Y=(x&&Q?l.peekAt(y+x.width+Q.width):null)?.ch;if(d===-1&&N!==void 0&&I(N)&&D[1].next.indexOf(N)!==-1){const J=ne(a.text_to_krama_map,T+N,{accessor:(R,A)=>R[A][0]}),Z=L(a.krama_text_arr,a.krama_text_arr_index,j??"",{accessor:(R,A)=>R[A][0]});if(J!==-1&&Z!==-1){G=J;const R=a.krama_text_arr[Z],A=a.list[R[1]??-1]?.type;if(j===a.halant||A==="mAtrA"){d=y+(x?.width??0);break}}}else if(d===-1&&Y!==void 0&&I(Y)&&D[1].next.indexOf(Y)!==-1){const J=ne(a.text_to_krama_map,T+Y,{accessor:(A,K)=>A[K][0]}),Z=L(a.krama_text_arr,a.krama_text_arr_index,j??"",{accessor:(A,K)=>A[K][0]}),R=L(a.krama_text_arr,a.krama_text_arr_index,N??"",{accessor:(A,K)=>A[K][0]});if(J!==-1&&Z!==-1&&R!==-1){const A=a.krama_text_arr[Z],K=a.krama_text_arr[R];G=J;const Be=a.list[A[1]??-1]?.type,ze=a.list[K[1]??-1]?.type;if(Be==="mAtrA"&&ze==="mAtrA"){d=y+(x?.width??0)+(Q?.width??0);break}}}}if(j!==void 0&&D[1].next.indexOf(j)!==-1){S+=x?.width??0;continue}}G=v;break}}const h=G!==-1?a.text_to_krama_map[G]:null;if(h!==null){const S=d!==-1&&h[0].length>1&&a.list[a.krama_text_arr[h[1].krama?.[0]??-1]?.[1]??-1]?.type==="vyanjana"&&I(h[0].at(-1)??void 0)?1:0,q=h[0].length-S;if(l.advance(q),i=l.pos,h[1].krama!==null&&h[1].krama!==void 0&&h[1].krama.some(E=>E!==-1)){const E=h[1].krama.map(y=>P(n,y)),te=E.join("");let O=!1;if(f)if(a.script_type==="brahmic"&&n.script_type==="other"){let y=null;if(h[1].fallback_list_ref!==void 0&&h[1].fallback_list_ref!==null)y=a.list[h[1].fallback_list_ref];else if(!h[1].krama||h[1].krama.length===0)y=null;else{const T=h[1].krama.map(v=>a.list[a.krama_text_arr[v][1]??-1]);C(e)&&T.some(v=>v?.type==="mAtrA")&&T.some(v=>v?.type==="vyanjana")?y={...T[0],type:"anya"}:C(e)&&T.length>1&&T.some(v=>v==null)?y=T.at(-1):y=T[0]}O=b(m,[h[0],y])}else if(n.script_type==="brahmic"&&a.script_type==="other"){let y=null;h[1].fallback_list_ref!==void 0&&h[1].fallback_list_ref!==null?y=n.list[h[1].fallback_list_ref]:y=h[1].krama&&h[1].krama.length>0?n.list[n.krama_text_arr[h[1].krama[0]]?.[1]??-1]??null:null,p&&e==="Normal"?O=b(m,[h[0],y],{next:h[1].next??void 0}):O=b(m,[h[0],y])}else p&&e==="Normal"&&n.script_type==="other"&&(O=b(m,[h[0],null],{next:h[1].next??void 0}));O||(n.script_type==="brahmic"&&C(r)&&(n.list[h[1].krama?.at(-1)??-1]?.type==="mAtrA"||te===n.halant)&&I(u.lastChar())?B(u,E,n.halant,!0):u.emitPieces(E)),ue(m,i,-q);continue}else if(h[1].krama!==null&&h[1].krama!==void 0&&h[1].krama.some(E=>E===-1)){u.emit(h[0]),p&&b(m,[h[0],null],{next:h[1].next??void 0});continue}}else l.advance(X),i=l.pos;const F=h===null?$:h[0],W=ee(a,F);if(W===-1){f&&(b(m,[F,null]),_.clear()),u.emit(F);continue}let oe=!1;if(f&&(a.script_type==="brahmic"?oe=b(m,[F,a.list[a.krama_text_arr[W][1]??-1]]):n.script_type==="brahmic"&&(oe=b(m,[F,n.list[n.krama_text_arr[W][1]??-1]]))),!oe){const S=P(n,W);n.script_type==="brahmic"&&C(r)&&(n.list[n.krama_text_arr[W][1]??-1]?.type==="mAtrA"||S===n.halant)&&I(u.lastChar())?B(u,[S],n.halant,!0):u.emit(S)}ue(m,i,-X)}f&&b(m,[void 0,null],{last_extra_call:!0});let H=u.toString();return H=fe(H,n,c,"output"),{output:H,context_length:_.length()}},be=async(t,e,r,a,n)=>{const[o,c]=await Promise.all([M(e),M(r)]),{trans_options:s,custom_rules:p}=pe(o,c,a);return me(t,e,r,o,c,s,p,n)},Se={script_list:{Devanagari:1,Telugu:2,Tamil:3,"Tamil-Extended":4,Bengali:5,Kannada:6,Gujarati:7,Malayalam:8,Odia:9,Sinhala:10,Normal:11,Romanized:12,Gurumukhi:13,Assamese:14,"Purna-Devanagari":15,Brahmi:16,Granth:17,Modi:18,Sharada:20,Siddham:21},lang_list:{English:1,Sanskrit:2,Hindi:3,Telugu:4,Tamil:5,Bengali:6,Kannada:7,Gujarati:8,Malayalam:9,Odia:10,Sinhala:11,Marathi:12,Nepali:13,Punjabi:14,Assamese:15}},{script_list:Ee,lang_list:je}=Se,le=Object.keys(Ee),ce=Object.keys(je),Ne=Array.from(new Set([...ce,...le])),Le={Bengali:"Bengali",Gujarati:"Gujarati",Hindi:"Devanagari",Kannada:"Kannada",Malayalam:"Malayalam",Odia:"Odia",Sinhala:"Sinhala",Tamil:"Tamil",Telugu:"Telugu",English:"Normal",Sanskrit:"Devanagari",Marathi:"Devanagari",Nepali:"Devanagari",Punjabi:"Gurumukhi",Assamese:"Assamese"},ye={dev:"Devanagari",te:"Telugu",tel:"Telugu",tam:"Tamil","tam-ex":"Tamil-Extended",ben:"Bengali",be:"Bengali",ka:"Kannada",kan:"Kannada",gu:"Gujarati",guj:"Gujarati",mal:"Malayalam",or:"Odia",od:"Odia",oriya:"Odia",si:"Sinhala",sinh:"Sinhala",sin:"Sinhala",en:"Normal",eng:"Normal",la:"Normal",lat:"Normal",nor:"Normal",norm:"Normal",rom:"Romanized",gur:"Gurumukhi",as:"Assamese",sa:"Devanagari",san:"Devanagari",hin:"Devanagari",hi:"Devanagari",mar:"Devanagari",ne:"Devanagari",nep:"Devanagari",pun:"Gurumukhi"};function Pe(t){return t.toLowerCase().replace(/(^|-)([a-z])/g,(e,r,a)=>r+a.toUpperCase())}const z=t=>{const e=Pe(t);return le.includes(e)?e:ce.includes(e)?Le[e]:t.toLocaleLowerCase()in ye?ye[t.toLocaleLowerCase()]:null};function Ie(t){const e=z(t);if(!e)throw new Error(`Invalid script name: ${t}`);let r="",a="",n=null,o=null,c={},s=[];const p=(async()=>{const[l,_]=await Promise.all([M("Normal"),M(e)]);n=l,o=_;const f=pe(l,_);c=f.trans_options,s=f.custom_rules})();function u(){r="",a=""}function i(l){if(!n||!o)throw new Error("Typing context not ready. Await `ctx.ready` before calling takeKeyInputSync.");let _=l?.[0]??"";r+=_;let f=a;const{context_length:k,output:g}=me(r,"Normal",e,n,o,c,s,{typing_mode:!0});k>0?a=g:k===0&&(r="",a="");let m=0;for(;m<g.length&&m<f.length&&g[m]===f[m];)m++;let d=g.substring(m);return{to_delete_chars_count:f.length-m,diff_add_text:d}}return{ready:p,clearContext:u,takeKeyInput:i}}async function Ce(t,e,r,a){if(!(a??!0)){r?.(e.currentTarget.value);return}const o="nativeEvent"in e,c=o?typeof InputEvent<"u"&&e?.nativeEvent instanceof InputEvent&&e.nativeEvent.data!==null:typeof InputEvent<"u"&&e instanceof InputEvent&&e.data!==null,s=o?e.nativeEvent.target:e.currentTarget;if(c){o&&r&&r(e.currentTarget.value),await t.ready;const p=o?e.nativeEvent.data:e.data,{diff_add_text:u,to_delete_chars_count:i}=t.takeKeyInput(p),l=s.value,_=(s.selectionStart??0)+1,f=_-i-2,k=l.substring(0,f),g=u;let m="";const d=l.length+1===_,H=l.length+1!==_;d?m=l.substring(_+1):H&&(m=l.substring(_-1));const U=k.length+g.length,$=k+g+m;s.value=$,s.focus(),s.selectionStart=U,s.selectionEnd=U,r?.($)}else r?.(s.value),t.clearContext()}const Oe=new Set(["Backspace","Delete","Enter","Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function De(t,e){if(t instanceof KeyboardEvent){if(t.isComposing)return!1;const r=t.key;if(!r||r==="Unidentified"||r==="Process"||r==="Dead"||t.ctrlKey||t.metaKey||t.altKey)return!1;if(Oe.has(r))return e.clearContext(),!0}return!1}const Re=Object.freeze(Object.defineProperty({__proto__:null,clearTypingContextOnKeyDown:De,createTypingContext:Ie,handleTypingInputEvent:Ce},Symbol.toStringTag,{value:"Module"})),Me=async t=>{const e=z(t);if(!e)throw new Error(`Invalid script name: ${t}`);return await M(e)};async function Ge(t,e,r,a){const n=z(e);if(!n)throw new Error(`Invalid script name: ${e}`);const o=z(r);if(!o)throw new Error(`Invalid script name: ${r}`);return n===o?t:(await be(t,n,o,a)).output}async function Ke(t,e){const r=z(t);if(!r)throw new Error(`Invalid script name: ${t}`);const a=z(e);if(!a)throw new Error(`Invalid script name: ${e}`);const n=await M(r),o=await M(a);return Object.keys(_e(n,o,Object.fromEntries(Object.keys(V).map(c=>[c,!0]))))}w.ALL_LANG_SCRIPT_LIST=Ne,w.LANG_LIST=ce,w.SCRIPT_LIST=le,w.getAllOptions=Ke,w.preloadScriptData=Me,w.transliterate=Ge,w.typing=Re,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(O,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(O=typeof globalThis<"u"?globalThis:O||self,M(O.lipilekhika={}))})(this,(function(O){"use strict";function M(t,e,r,n){const{accessor:a,compareFn:o}=n??{},i=a??((c,l)=>c[l]);let s=0,u=e.length-1,_=-1;for(;s<=u;){const c=Math.floor((s+u)/2),l=e[c],p=i(t,l);let h;o?h=o(r,p):h=r<p?-1:r>p?1:0,h===0?(_=l,u=c-1):h<0?u=c-1:s=c+1}return _}function ee(t,e,r){const{accessor:n,compareFn:a}=r??{},o=n??((_,c)=>_[c]);let i=0,s=t.length-1,u=-1;for(;i<=s;){const _=Math.floor((i+s)/2),c=o(t,_);let l;a?l=a(e,c):l=e<c?-1:e>c?1:0,l===0?(u=_,s=_-1):l<0?s=_-1:i=_+1}return u}const ce={},q=async t=>{{if(ce[t])return ce[t];const r=`https://cdn.jsdelivr.net/npm/lipilekhika@0.0.0-alpha.4/dist/umd_json/script_data/${t}.json`,a=(await fetch(r)).json();return ce[t]=a,a}},te={"all_to_normal:replace_pancham_varga_varna_with_n":{from_script_type:"all",to_script_name:["Normal"],check_in:"output",rules:[{type:"replace_prev_krama_keys",check_in:"output",prev:[60],following:[52,53,54,55,56,57,58,59],replace_with:[72]},{type:"replace_prev_krama_keys",check_in:"output",prev:[67],following:[61,62,63,64,65,66],replace_with:[72]}]},"brahmic_to_brahmic:replace_pancham_varga_varna_with_anuvsvAra":{from_script_type:"brahmic",to_script_type:"brahmic",check_in:"input",rules:[{type:"replace_prev_krama_keys",check_in:"input",prev:[60,49],following:[52,53,54,55,56,57,58,59],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[67,49],following:[61,62,63,64,65,66],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[81,49],following:[74,75,76,77,78,79,80],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[72,49],following:[68,69,70,71],replace_with:[45]},{type:"replace_prev_krama_keys",check_in:"input",prev:[88,49],following:[82,83,85,86,87],replace_with:[45]}]},"all_to_sinhala:use_conjuct_enabling_halant":{from_script_type:"all",to_script_name:["Sinhala"],check_in:"output",rules:[{type:"direct_replace",check_in:"output",to_replace:[[49]],replace_text:"්‍",replace_with:[]}]},"all_to_normal:remove_virAma_and_double_virAma":{from_script_type:"all",to_script_name:["Normal","Romanized"],check_in:"output",rules:[{type:"direct_replace",check_in:"output",to_replace:[[116],[115]],replace_with:[-1]}]},"all_to_normal:replace_avagraha_with_a":{from_script_type:"all",to_script_name:["Normal","Romanized"],check_in:"output",rules:[{type:"direct_replace",check_in:"output",to_replace:[[48]],replace_with:[1]}]},"normal_to_all:use_typing_chars":{from_script_name:["Normal"],to_script_type:"all",check_in:"output",rules:[]},"all_to_normal:preserve_specific_chars":{from_script_type:"all",to_script_name:["Normal"],check_in:"output",rules:[]}},Se=(t,e)=>{const r=t.krama_text_arr[e]?.[0];return typeof r=="string"?r:null},z=(t,e)=>Se(t,e)??"",re=(t,e)=>M(t.krama_text_arr,t.krama_text_arr_index,e,{accessor:(r,n)=>r[n][0]}),be=()=>{let t=[];function e(c){c&&t.push(c)}function r(c){for(const l of c)e(l)}function n(){return t.at(-1)}function a(){return n()?.at(-1)}function o(){const c=n();if(!c)return;const l=c.at(-1),p=c.slice(0,-1);return p?t[t.length-1]=p:t.pop(),l}function i(c,l){t.splice(-c,c,...l.filter(Boolean))}function s(c,l){const p=o();if(!p){r(c),r(l);return}r(c),e(p),r(l)}function u(c){const l=t.at(c);return l?{cp:c,ch:l,width:l.length}:null}function _(c,l){c<0&&(c=t.length+c),!(c<0||c>=t.length)&&(t[c]=l)}return{emit:e,emitPieces:r,lastPiece:n,lastChar:a,popLastChar:o,rewriteTailPieces:i,withLastCharMovedAfter:s,toString:()=>t.join(""),rewriteAt:_,peekAt:u}},Ne=t=>{let e=[];function r(){e=[]}function n(){return e.length}function a(p){return e.at(p)}function o(){return e.at(-1)}function i(){return o()?.[0]}function s(){return o()?.[1]?.type}function u(p){return a(p)?.[1]?.type}function _(p){return a(p)?.[0]}function c(p){return s()===p}function l(p){const h=p[0];h!==void 0&&h.length>0&&e.push(p),e.length>t&&e.shift()}return{clear:r,length:n,at:a,last:o,lastText:i,lastType:s,typeAt:u,textAt:_,isLastType:c,push:l}},Le=t=>{let e=0;function r(s){const u=t.codePointAt(s);if(u===void 0)return null;const _=String.fromCodePoint(u);return{cp:u,ch:_,width:_.length}}function n(){return r(e)}function a(s){return r(e+s)}function o(s){e+=s}function i(s,u){return t.substring(s,u)}return{get pos(){return e},peek:n,peekAt:r,peekAtOffsetUnits:a,advance:o,slice:i}},se=(t,e,r,n)=>{for(let a=0;a<r.length;a++){const o=r[r.length-1-a],i=t(e-a);if(i===null)return{matched:!1,matchedLen:0};const s=re(n,i.ch);if(s===-1||s!==o)return{matched:!1,matchedLen:0}}return{matched:!0,matchedLen:r.length}},oe=(t,e)=>t.map(r=>z(e,r)).filter(Boolean),Ie=["²","³","⁴"],N=t=>!!t&&Ie.indexOf(t)!==-1,Oe=["॒","॑","᳚","᳛"],_e=t=>!!t&&Oe.indexOf(t)!==-1,D=t=>t==="Tamil-Extended",H=(t,e,r,n)=>{if(e.length===0)return;if(!n){t.emitPieces(e);return}const a=e[0]??"";if(a[0]===r){const o=a.slice(1),i=[];o&&i.push(o);for(let s=1;s<e.length;s++)i.push(e[s]);t.withLastCharMovedAfter([r],i)}else t.withLastCharMovedAfter(e,[])},ke=["#an","#sss","#ss","#s"],De=["↓","↑↑↑","↑↑","↑"],Ce=(t,e)=>{if(!t)return t;if(t.indexOf("x")!==-1&&(t=t.replaceAll("x","kSh")),e==="Tamil-Extended")for(let r=0;r<ke.length;r++){const n=ke[r];t.indexOf(n)!==-1&&(t=t.replaceAll(n,De[r]))}return t},je=[" ",`
2
+ `,"\r"," ",",",";","!","@","?","%"],Pe=3;function L(t,e,r){const{from_script_name:n,to_script_name:a,from_script_data:o,to_script_data:i,trans_options:s,result:u,prev_context:_,BRAHMIC_HALANT:c,BRAHMIC_NUQTA:l,typing_mode:p,include_inherent_vowel:h}=t,{next:m,last_extra_call:A}=r??{};let $=!1;if((l&&_.typeAt(-3)==="vyanjana"&&_.textAt(-2)===l&&_.typeAt(-1)==="mAtrA"||_.typeAt(-2)==="vyanjana"&&_.typeAt(-1)==="mAtrA")&&(!e||e[1]?.type==="anya")&&_.clear(),o.script_type==="brahmic"&&i.script_type==="other")e[0]!==c&&(!(D(n)&&e[0]&&e[0].length>0)||e[0].charAt(0)!==c)&&(!l||e[0]!==l)&&(_.typeAt(-1)==="vyanjana"||l&&_.typeAt(-2)==="vyanjana"&&_.textAt(-1)===l)&&(e[1]?.type!=="mAtrA"&&e[0]!==c||e[1]?.type==="anya"||e[1]===null||e[1]===void 0)&&u.emit(i.schwa_character);else if(o.script_type==="other"&&i.script_type==="brahmic")if(_.typeAt(-1)==="vyanjana"&&(e[1]?.type==="mAtrA"||e[1]?.type==="svara")){const y=e[1].type==="svara"?z(i,e[1].mAtrA_krama_ref?.[0]??-1):e[0];D(a)&&N(u.lastChar())?H(u,[y],i.halant,!0):H(u,[y],i.halant,!1),$=!0}else!h&&_.typeAt(-1)==="vyanjana"&&!(e[0]===c||e[1]?.type==="mAtrA")?D(a)&&N(u.lastChar())?H(u,[c],i.halant,!0):(H(u,[c],i.halant,!1),a==="Sinhala"&&s["all_to_sinhala:use_conjuct_enabling_halant"]&&u.rewriteAt(-1,u.lastPiece()+"‍")):h&&e&&e[1]?.type==="vyanjana"&&(_.typeAt(-1)==="vyanjana"||l&&_.typeAt(-2)==="vyanjana"&&_.textAt(-1)===l)&&(D(a)&&N(u.lastChar())?H(u,[c],i.halant,!0):(H(u,[c],i.halant,!1),a==="Sinhala"&&s["all_to_sinhala:use_conjuct_enabling_halant"]&&u.rewriteAt(-1,u.lastPiece()+"‍")));let x=!1;return p&&(m===void 0||m.length===0)&&!A&&!(D(a)&&N(u.lastChar()))&&(x=!0,e[1]?.type==="vyanjana"&&(x=!1),x&&_.clear()),(!p||!A&&!x)&&_.push(e),$}function ve(t,e,r){const{custom_rules:n,cursor:a,result:o,from_script_data:i,to_script_data:s}=t,u=e+r;for(let _=0;_<n.length;_++){if(n[_].use_replace===!0)continue;const c=n[_];if(c.type==="replace_prev_krama_keys"){if(c.check_in==="input"){const l=se(a.peekAt,u,c.prev,i),p=a.peekAt(e);if(l.matched&&p!==null){const h=p.ch,m=re(i,h);if(m!==-1&&c.following.indexOf(m)!==-1){const A=oe(c.replace_with,s);o.rewriteTailPieces(l.matchedLen,A)}}}else if(c.check_in==="output"){const l=o.lastPiece();if(!l)continue;const p=re(s,l);if(p!==-1&&c.following.indexOf(p)!==-1){const h=se(o.peekAt,-2,c.prev,s);if(h.matched){const m=oe(c.replace_with,s);o.rewriteTailPieces(h.matchedLen+1,[...m,l])}}}}else if(c.type==="direct_replace"){const l=c.check_in==="output"?s:i;for(const p of c.to_replace){const h=se(o.peekAt,-1,p,l);if(!h.matched)continue;if(c.replace_text){o.rewriteTailPieces(h.matchedLen,[c.replace_text]);break}const m=oe(c.replace_with,l);o.rewriteTailPieces(h.matchedLen,m);break}}}}const ge=(t,e,r)=>{if(!r)return{};const n={};for(const[a,o]of Object.entries(r??{})){if(!(a in te))continue;const i=te[a];(i.from_script_type==="all"&&i.to_script_type==="all"||(i.from_script_type!==void 0&&(i.from_script_type==="all"||i.from_script_type===t.script_type)||i.from_script_name!==void 0&&i.from_script_name.includes(t.script_name))&&(i.to_script_type!==void 0&&(i.to_script_type==="all"||i.to_script_type===e.script_type)||i.to_script_name!==void 0&&i.to_script_name.includes(e.script_name)))&&(n[a]=o)}return n},Ae=(t,e,r)=>{const n=ge(t,e,r),a=Object.keys(n).flatMap(o=>n[o]===!0?te[o].rules:[]);return{trans_options:n,custom_rules:a}},xe=(t,e)=>t.replace_with.map(r=>z(e,r)).join(""),we=(t,e,r,n)=>{if(r.length===0)return t;for(const a of r)if(!(a.use_replace!==!0||a.check_in!==n)){if(a.type==="replace_prev_krama_keys"){const o=a.prev.map(i=>z(e,i)).join("");for(let i of a.following){const s=z(e,i);if(!s)continue;const u=xe(a,e)+s;t=t.replaceAll(o+s,u)}}else if(a.type==="direct_replace"){const o=a.to_replace.map(i=>i.map(s=>z(e,s)).join(""));for(let i of o)t=t.replaceAll(i,xe(a,e))}}return t},Re=!0,Me=!1,Te=(t,e,r,n,a,o,i,s)=>{const u=s?.useNativeNumerals??Re,_=s?.typing_mode??!1,c=s?.includeInherentVowel??Me;if(_&&e!=="Normal")throw new Error("Typing mode is only supported with Normal script as the input");_&&(o["normal_to_all:use_typing_chars"]=!0),_&&e==="Normal"&&(t=Ce(t,r)),t=we(t,n,i,"input");const l=be();let p=0;const h=Le(t),m=Ne(Pe),A=n.script_type==="brahmic"&&a.script_type==="other"||n.script_type==="other"&&a.script_type==="brahmic"||_&&e==="Normal"&&a.script_type==="other",$=n.script_type==="brahmic"&&a.script_type==="other"?n.nuqta??null:n.script_type==="other"&&a.script_type==="brahmic"?a.nuqta??null:null,x=n.script_type==="brahmic"&&a.script_type==="other"?n.halant:n.script_type==="other"&&a.script_type==="brahmic"?a.halant:null,y={from_script_name:e,to_script_name:r,from_script_data:n,to_script_data:a,trans_options:o,custom_rules:i,cursor:h,result:l,prev_context:m,BRAHMIC_NUQTA:$,BRAHMIC_HALANT:x,typing_mode:_,include_inherent_vowel:c},V=(o["normal_to_all:use_typing_chars"]||_)&&e==="Normal"?a.typing_text_to_krama_map:n.text_to_krama_map;let k=-1;for(;h.pos<t.length;){p=h.pos;const F=h.peek();if(!F)break;const w=F.ch,U=F.width,ie=U===2?1:U;if(k!==-1&&p>=k){k=-1,h.advance(U);continue}if(je.indexOf(w)!==-1){h.advance(U),A&&(L(y,[" ",null]),m.clear()),l.emit(w);continue}if(w.match(/^\d$/)&&!u){l.emit(w),h.advance(U),L(y,[w,null]);continue}if(o["all_to_normal:preserve_specific_chars"]&&r==="Normal"){const T=ee(n.custom_script_chars_arr,w,{accessor:(E,I)=>E[I][0]});if(T!==-1){const E=n.custom_script_chars_arr[T];L(y,[E[0],n.list[E[1]??-1]??null]);const I=n.typing_text_to_krama_map[E[2]??-1]?.[0];l.emit(I??""),h.advance(E[0].length);continue}}let X=-1;{let T=0,E=-1;const I=A&&n.script_type==="other"&&a.script_type==="brahmic"&&(m.typeAt(-1)==="vyanjana"||$&&m.typeAt(-2)==="vyanjana"&&m.textAt(-1)===$);for(;;){const W=h.peekAt(p+ie+T),le=W?.ch??"";k!==-1&&le&&N(le)&&(T+=W?.width??0);const S=p+ie+T,d=k!==-1?h.slice(p,k)+(S>k?h.slice(k+1,S):""):h.slice(p,S),C=ee(V,d,{accessor:(b,j)=>b[j][0]});if(C===-1){X=-1;break}const v=V[C];if(I&&v[1].krama&&v[1].krama.length>=1){const b=v[1].krama,j=b[0],P=a.krama_text_arr[j]?.[1],ye=a.list[P??-1]?.type;if(b.length===1&&P!==null&&P!==void 0&&(ye==="svara"||ye==="mAtrA"))E=C;else if(E!==-1){X=E;break}}if(v[1].next&&v[1].next.length>0){const b=h.peekAt(S),j=b?.ch;if(D(e)&&n.script_type==="brahmic"){const Z=b?h.peekAt(S+b.width):null,P=Z?.ch,B=(b&&Z?h.peekAt(S+b.width+Z.width):null)?.ch;if(k===-1&&P!==void 0&&N(P)&&v[1].next.indexOf(P)!==-1){const Y=ee(n.text_to_krama_map,d+P,{accessor:(R,g)=>R[g][0]}),G=M(n.krama_text_arr,n.krama_text_arr_index,j??"",{accessor:(R,g)=>R[g][0]});if(Y!==-1&&G!==-1){X=Y;const R=n.krama_text_arr[G],g=n.list[R[1]??-1]?.type;if(j===n.halant||g==="mAtrA"){k=S+(b?.width??0);break}}}else if(k===-1&&B!==void 0&&N(B)&&v[1].next.indexOf(B)!==-1){const Y=ee(n.text_to_krama_map,d+B,{accessor:(g,K)=>g[K][0]}),G=M(n.krama_text_arr,n.krama_text_arr_index,j??"",{accessor:(g,K)=>g[K][0]}),R=M(n.krama_text_arr,n.krama_text_arr_index,P??"",{accessor:(g,K)=>g[K][0]});if(Y!==-1&&G!==-1&&R!==-1){const g=n.krama_text_arr[G],K=n.krama_text_arr[R];X=Y;const de=n.list[g[1]??-1]?.type,tt=n.list[K[1]??-1]?.type;if(de==="mAtrA"&&tt==="mAtrA"){k=S+(b?.width??0)+(Z?.width??0);break}}}if(k===-1&&j!==void 0&&P!==void 0&&_e(P)&&B!==void 0&&N(B)&&v[1].next.indexOf(B)!==-1){const Y=M(n.krama_text_arr,n.krama_text_arr_index,j??"",{accessor:(G,R)=>G[R][0]});if(Y!==-1){const G=n.krama_text_arr[Y];if(n.list[G[1]??-1]?.type==="mAtrA"){const g=ee(n.text_to_krama_map,d+B,{accessor:(K,de)=>K[de][0]});if(g!==-1){X=g,k=S+(b?.width??0)+(Z?.width??0);break}}}}}if(j!==void 0&&v[1].next.indexOf(j)!==-1){T+=b?.width??0;continue}}X=C;break}}const f=X!==-1?V[X]:null;if(f!==null){const T=k!==-1&&f[0].length>1&&n.list[n.krama_text_arr[f[1].krama?.[0]??-1]?.[1]??-1]?.type==="vyanjana"&&N(f[0].at(-1)??void 0)?1:0,E=f[0].length-T;if(h.advance(E),p=h.pos,o["normal_to_all:use_typing_chars"]&&"custom_back_ref"in f[1]&&f[1].custom_back_ref!==void 0&&f[1].custom_back_ref!==null){const I=a.custom_script_chars_arr[f[1].custom_back_ref]??null;te!==null&&(l.emit(I[0]),L(y,[f[0],a.list[I[1]??-1]??null],{next:f[1].next??void 0}));continue}if(f[1].krama!==null&&f[1].krama!==void 0&&f[1].krama.some(I=>I!==-1)){const W=f[1].krama.map(d=>z(a,d)),le=W.join("");let S=!1;if(A)if(n.script_type==="brahmic"&&a.script_type==="other"){let d=null;if(!o["normal_to_all:use_typing_chars"]&&f[1].fallback_list_ref!==void 0&&f[1].fallback_list_ref!==null)d=n.list[f[1].fallback_list_ref];else if(!f[1].krama||f[1].krama.length===0)d=null;else{const C=f[1].krama.map(v=>n.list[n.krama_text_arr[v][1]??-1]);D(e)&&C.some(v=>v?.type==="mAtrA")&&C.some(v=>v?.type==="vyanjana")?d={...C[0],type:"anya"}:D(e)&&C.length>1&&C.some(v=>v==null)?d=C.at(-1):d=C[0]}S=L(y,[f[0],d])}else if(a.script_type==="brahmic"&&n.script_type==="other"){let d=null;f[1].fallback_list_ref!==void 0&&f[1].fallback_list_ref!==null?d=a.list[f[1].fallback_list_ref]:d=f[1].krama&&f[1].krama.length>0?a.list[a.krama_text_arr[f[1].krama[0]]?.[1]??-1]??null:null,_&&e==="Normal"?S=L(y,[f[0],d],{next:f[1].next??void 0}):S=L(y,[f[0],d])}else _&&e==="Normal"&&a.script_type==="other"&&(S=L(y,[f[0],null],{next:f[1].next??void 0}));if(!S)if(a.script_type==="brahmic"&&D(r)&&(a.list[f[1].krama?.at(-1)??-1]?.type==="mAtrA"||le===a.halant)&&N(l.lastChar()))H(l,W,a.halant,!0);else if(D(r)&&_e(W.at(-1)?.at(-1)??"")&&N(l.lastChar())){const d=l.popLastChar();l.emitPieces(W),l.emit(d??"")}else l.emitPieces(W);ve(y,p,-E);continue}else if(f[1].krama!==null&&f[1].krama!==void 0&&f[1].krama.some(I=>I===-1)){l.emit(f[0]),_&&L(y,[f[0],null],{next:f[1].next??void 0});continue}}else h.advance(U),p=h.pos;const ne=f===null?w:f[0],ae=re(n,ne);if(ae===-1){A&&(L(y,[ne,null]),m.clear()),l.emit(ne);continue}let me=!1;if(A&&(n.script_type==="brahmic"?me=L(y,[ne,n.list[n.krama_text_arr[ae][1]??-1]]):a.script_type==="brahmic"&&(me=L(y,[ne,a.list[a.krama_text_arr[ae][1]??-1]]))),!me){const T=z(a,ae);if(a.script_type==="brahmic"&&D(r)&&(a.list[a.krama_text_arr[ae][1]??-1]?.type==="mAtrA"||T===a.halant)&&N(l.lastChar()))H(l,[T],a.halant,!0);else if(D(r)&&_e(T)&&N(l.lastChar())){const E=l.popLastChar();l.emit(T),l.emit(E??"")}else l.emit(T)}ve(y,p,-U)}A&&L(y,[void 0,null],{last_extra_call:!0});let J=l.toString();return J=we(J,a,i,"output"),{output:J,context_length:m.length()}},Ue=async(t,e,r,n,a)=>{const[o,i]=await Promise.all([q(e),q(r)]),{trans_options:s,custom_rules:u}=Ae(o,i,n);return Te(t,e,r,o,i,s,u,a)},Be={script_list:{Devanagari:1,Telugu:2,Tamil:3,"Tamil-Extended":4,Bengali:5,Kannada:6,Gujarati:7,Malayalam:8,Odia:9,Sinhala:10,Normal:11,Romanized:12,Gurumukhi:13,Assamese:14,"Purna-Devanagari":15,Brahmi:16,Granth:17,Modi:18,Sharada:20,Siddham:21},lang_list:{English:1,Sanskrit:2,Hindi:3,Telugu:4,Tamil:5,Bengali:6,Kannada:7,Gujarati:8,Malayalam:9,Odia:10,Sinhala:11,Marathi:12,Nepali:13,Punjabi:14,Assamese:15}},{script_list:Ge,lang_list:Ke}=Be,ue=Object.keys(Ge),pe=Object.keys(Ke),ze=Array.from(new Set([...pe,...ue])),He={Bengali:"Bengali",Gujarati:"Gujarati",Hindi:"Devanagari",Kannada:"Kannada",Malayalam:"Malayalam",Odia:"Odia",Sinhala:"Sinhala",Tamil:"Tamil",Telugu:"Telugu",English:"Normal",Sanskrit:"Devanagari",Marathi:"Devanagari",Nepali:"Devanagari",Punjabi:"Gurumukhi",Assamese:"Assamese"},Ee={dev:"Devanagari",te:"Telugu",tel:"Telugu",tam:"Tamil","tam-ex":"Tamil-Extended",ben:"Bengali",be:"Bengali",ka:"Kannada",kan:"Kannada",gu:"Gujarati",guj:"Gujarati",mal:"Malayalam",or:"Odia",od:"Odia",oriya:"Odia",si:"Sinhala",sinh:"Sinhala",sin:"Sinhala",en:"Normal",eng:"Normal",la:"Normal",lat:"Normal",nor:"Normal",norm:"Normal",rom:"Romanized",gur:"Gurumukhi",as:"Assamese",sa:"Devanagari",san:"Devanagari",hin:"Devanagari",hi:"Devanagari",mar:"Devanagari",ne:"Devanagari",nep:"Devanagari",pun:"Gurumukhi"};function $e(t){return t.toLowerCase().replace(/(^|-)([a-z])/g,(e,r,n)=>r+n.toUpperCase())}const Q=t=>{const e=$e(t);return ue.includes(e)?e:pe.includes(e)?He[e]:t.toLocaleLowerCase()in Ee?Ee[t.toLocaleLowerCase()]:null},Ve=async t=>{const e=Q(t);if(!e)throw new Error(`Invalid script name: ${t}`);return await q(e)};async function Fe(t,e,r,n){const a=Q(e);if(!a)throw new Error(`Invalid script name: ${e}`);const o=Q(r);if(!o)throw new Error(`Invalid script name: ${r}`);return a===o?t:(await Ue(t,a,o,n)).output}async function Xe(t,e){const r=Q(t);if(!r)throw new Error(`Invalid script name: ${t}`);const n=Q(e);if(!n)throw new Error(`Invalid script name: ${e}`);const a=await q(r),o=await q(n);return Object.keys(ge(a,o,Object.fromEntries(Object.keys(te).map(i=>[i,!0]))))}const We=4500,he=!0,fe=!1;function Ye(t,e){const{autoContextTClearTimeMs:r}=e??{};let n=e?.useNativeNumerals??he,a=e?.includeInherentVowel??fe;const o=Q(t);if(!o)throw new Error(`Invalid script name: ${t}`);let i="",s="";const u=r??We;let _=null,c=null,l=null,p={},h=[];const m=(async()=>{const[x,y]=await Promise.all([q("Normal"),q(o)]);c=x,l=y;const V=Ae(x,y);p=V.trans_options,h=V.custom_rules})();function A(){_=null,i="",s=""}function $(x){if(!c||!l)throw new Error("Typing context not ready. Await `ctx.ready` before calling takeKeyInputSync.");const y=Date.now();_&&y-_>u&&A();let V=x?.[0]??"";i+=V;let k=s;const{context_length:J,output:F}=Te(i,"Normal",o,c,l,p,h,{typing_mode:!0,useNativeNumerals:n,includeInherentVowel:a});J>0?s=F:J===0&&A();let w=0;for(;w<F.length&&w<k.length&&F[w]===k[w];)w++;let U=F.substring(w),ie=k.length-w;return _=Date.now(),{to_delete_chars_count:ie,diff_add_text:U}}return{ready:m,clearContext:A,takeKeyInput:$,updateUseNativeNumerals:x=>{n=x??he},updateIncludeInherentVowel:x=>{a=x??fe}}}async function qe(t,e,r,n){if(!(n??!0)){r?.(e?.currentTarget?.value);return}const o=e?.nativeEvent??e,i="nativeEvent"in e,s=e?.currentTarget??o?.target;if(!o||!s||o.isComposing)return;if(o.inputType!=="insertText"){r?.(s.value),t.clearContext();return}const u=o.data;if(typeof u!="string"||u.length!==1){r?.(s.value),t.clearContext();return}const _=s.selectionStart??0,c=s.selectionEnd??_;if(_!==c){r?.(s.value),t.clearContext();return}i&&r&&r(e.currentTarget.value),await t.ready;const{diff_add_text:l,to_delete_chars_count:p}=t.takeKeyInput(u),h=_,m=Math.max(0,h-p-u.length);s.setRangeText(l,m,h,"end"),r?.(s.value)}async function Qe(t,e,r,n){if(!(n??!0))return;const i="nativeEvent"in e?e.nativeEvent:e,s=e?.currentTarget??i?.target;if(!i||!s||i.isComposing||(!i.inputType||i.inputType!=="insertText")&&(!i.type||i.type!=="textInput"))return;const u=i.data;if(typeof u!="string"||u.length===0)return;if(u.length!==1){t.clearContext();return}const _=s.selectionStart??0,c=s.selectionEnd??_;if(_!==c){t.clearContext();return}i.preventDefault?.(),await t.ready;const{diff_add_text:l,to_delete_chars_count:p}=t.takeKeyInput(u),h=_,m=Math.max(0,h-p);s.setRangeText(l,m,h,"end"),r?.(s.value)}const Je=new Set(["Backspace","Delete","Enter","Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function Ze(t,e){const r=t?.nativeEvent??t;if(r instanceof KeyboardEvent){if(r.isComposing)return!1;const n=r.key;if(!n||n==="Unidentified"||n==="Process"||n==="Dead"||r.ctrlKey||r.metaKey||r.altKey)return!1;if(Je.has(n))return e.clearContext(),!0}return!1}const et=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_INCLUDE_INHERENT_VOWEL:fe,DEFAULT_USE_NATIVE_NUMERALS:he,clearTypingContextOnKeyDown:Ze,createTypingContext:Ye,handleTypingBeforeInputEvent:Qe,handleTypingInputEvent:qe},Symbol.toStringTag,{value:"Module"}));O.ALL_LANG_SCRIPT_LIST=ze,O.LANG_LIST=pe,O.SCRIPT_LIST=ue,O.getAllOptions=Xe,O.preloadScriptData=Ve,O.transliterate=Fe,O.typing=et,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})}));
package/dist/typing.d.ts CHANGED
@@ -8,7 +8,7 @@ declare const ALTERNATES: readonly ["dev", "te", "tel", "tam", "tam-ex", "ben",
8
8
  * @param ctx - The typing context
9
9
  * @returns True if the keydown event should clear the typing context, false otherwise
10
10
  */
11
- export declare function clearTypingContextOnKeyDown(e: any, ctx: ReturnType<typeof createTypingContext>): boolean;
11
+ export declare function clearTypingContextOnKeyDown(event: any, ctx: ReturnType<typeof createTypingContext>): boolean;
12
12
 
13
13
  /**
14
14
  * Creates a stateful isolated context for character by character input typing.
@@ -16,9 +16,10 @@ export declare function clearTypingContextOnKeyDown(e: any, ctx: ReturnType<type
16
16
  *
17
17
  * **Note** :- Script Data is loaded in background but it would still be good to await `ready` before using the context.
18
18
  * @param typing_lang - The script/language to type in
19
+ * @param options - The options for the typing context
19
20
  * @returns A closed over context object with the following methods:
20
21
  */
21
- export declare function createTypingContext(typing_lang: ScriptLangType): {
22
+ export declare function createTypingContext(typing_lang: ScriptLangType, options?: TypingContextOptions): {
22
23
  /** Await once, then use `takeKeyInputSync` for best typing latency. */
23
24
  ready: Promise<void>;
24
25
  clearContext: () => void;
@@ -28,14 +29,40 @@ export declare function createTypingContext(typing_lang: ScriptLangType): {
28
29
  /** These characters need to be added to the current "app" input state */
29
30
  diff_add_text: string;
30
31
  };
32
+ updateUseNativeNumerals: (useNativeNumerals: boolean) => void;
33
+ updateIncludeInherentVowel: (includeInherentVowel: boolean) => void;
31
34
  };
32
35
 
36
+ /** Default value for the include inherent vowel option.
37
+ * By default avoids schwa deletion
38
+ */
39
+ export declare const DEFAULT_INCLUDE_INHERENT_VOWEL = false;
40
+
41
+ /** Default values for the typing context options */
42
+ export declare const DEFAULT_USE_NATIVE_NUMERALS = true;
43
+
33
44
  /**
34
- * Handles input events for transliteration typing in `input` and `textarea` elements
45
+ * Handles `beforeinput` events for transliteration typing in `input` and `textarea` elements.
46
+ *
47
+ * @param typingContext - The typing context created for the element
48
+ * @param event - BeforeInput event (native or React synthetic)
49
+ * @param onValueChange - Optional callback function invoked when the value changes
50
+ * @param enabled_ - Optional flag to enable/disable transliteration (defaults to true)
51
+ */
52
+ export declare function handleTypingBeforeInputEvent(typingContext: ReturnType<typeof createTypingContext>, event: any, onValueChange?: (updatedValue: string) => void, enabled_?: boolean): Promise<void>;
53
+
54
+ /**
55
+ * @deprecated This function is deprecated.
56
+ * Prefer using `handleTypingBeforeInputEvent` instead, which handles transliteration typing via the native `beforeinput` event in both React and Svelte.
57
+ *
58
+ * Handles input events for transliteration typing in `input` and `textarea` elements.
59
+ *
60
+ * Use this function with **React** only if the `onbeforeinput` approach does not work.
35
61
  *
36
62
  * @param typingContext - The typing context created for the element
37
63
  * @param event - Input Event
38
64
  * @param onValueChange - Optional callback function invoked when the value changes
65
+ * @param enabled_ - Optional flag to enable/disable transliteration (defaults to true)
39
66
  */
40
67
  export declare function handleTypingInputEvent(typingContext: ReturnType<typeof createTypingContext>, event: any, onValueChange?: (updatedValue: string) => void, enabled_?: boolean): Promise<void>;
41
68
 
@@ -93,4 +120,24 @@ declare type script_list_type = keyof typeof script_list;
93
120
  */
94
121
  declare type ScriptLangType = script_input_name_type;
95
122
 
123
+ declare type TypingContextOptions = {
124
+ /** The time in milliseconds after which the context will be cleared automatically
125
+ * @default 4500ms
126
+ */
127
+ autoContextTClearTimeMs?: number;
128
+ /** Use native numerals in transliteration/typing
129
+ * @default true
130
+ */
131
+ useNativeNumerals?: boolean;
132
+ /** Include inherent vowels(schwa character) in transliteration/typing
133
+ *
134
+ * `true` : `k` -> `क` (Eg. Hindi, Bengali, Gujarati, etc.)
135
+ *
136
+ * `false` : `k` -> `क्` (Default Behavior in transliteration. Eg. Sanskrit, Telugu, Tamil, Kannada, etc)
137
+ *
138
+ * @default false
139
+ */
140
+ includeInherentVowel?: boolean;
141
+ };
142
+
96
143
  export { }
@@ -1 +1 @@
1
- {"script_type":"brahmic","script_name":"Assamese","script_id":14,"halant":"্","nuqta":"়","schwa_property":true,"text_to_krama_map":[["ॐ",{"krama":[0]}],["ও",{"krama":[29],"next":["ঁ"]}],["ওঁ",{"krama":[0]}],["ক",{"krama":[52],"next":["়"]}],["ক়",{"krama":[53]}],["খ",{"krama":[54],"next":["়"]}],["খ়",{"krama":[55]}],["গ",{"krama":[56],"next":["়"]}],["গ়",{"krama":[57]}],["জ",{"krama":[63],"next":["়"]}],["জ়",{"krama":[64]}],["ড",{"next":["়"]}],["ড়",{"krama":[77]}],["ঢ",{"next":["়"]}],["ঢ়",{"krama":[80]}],["ন",{"krama":[72],"next":["়"]}],["ন়",{"krama":[73]}],["ফ",{"krama":[83],"next":["়"]}],["ফ়",{"krama":[84]}],["য",{"next":["়"]}],["য়",{"krama":[90]}],["র",{"krama":[92],"next":["়"]}],["র়",{"krama":[93]}],["ল",{"krama":[94],"next":["়"]}],["ল়",{"krama":[95]}],["ে",{"next":["া","ৗ"]}],["ো",{"krama":[30]}],["ৌ",{"krama":[34]}],["ৰ",{"krama":[92],"next":["়"]}],["ৰ়",{"krama":[93]}]],"list":[{"krama_ref":[1,3],"type":"svara","mAtrA_krama_ref":[2,4]},{"krama_ref":[2,4],"type":"mAtrA"},{"krama_ref":[5,7],"type":"svara","mAtrA_krama_ref":[6,8]},{"krama_ref":[6,8],"type":"mAtrA"},{"krama_ref":[9],"type":"svara","mAtrA_krama_ref":[10]},{"krama_ref":[10],"type":"mAtrA"},{"krama_ref":[11],"type":"svara","mAtrA_krama_ref":[12]},{"krama_ref":[12],"type":"mAtrA"},{"krama_ref":[13,15],"type":"svara","mAtrA_krama_ref":[14,16]},{"krama_ref":[14,16],"type":"mAtrA"},{"krama_ref":[17,19],"type":"svara","mAtrA_krama_ref":[18,20]},{"krama_ref":[18,20],"type":"mAtrA"},{"krama_ref":[37],"type":"svara","mAtrA_krama_ref":[38]},{"krama_ref":[38],"type":"mAtrA"},{"krama_ref":[39],"type":"svara","mAtrA_krama_ref":[40]},{"krama_ref":[40],"type":"mAtrA"},{"krama_ref":[41],"type":"svara","mAtrA_krama_ref":[42]},{"krama_ref":[42],"type":"mAtrA"},{"krama_ref":[43],"type":"svara","mAtrA_krama_ref":[44]},{"krama_ref":[44],"type":"mAtrA"},{"krama_ref":[21,23],"type":"svara","mAtrA_krama_ref":[22,24]},{"krama_ref":[22,24],"type":"mAtrA"},{"krama_ref":[25,27],"type":"svara","mAtrA_krama_ref":[26,28]},{"krama_ref":[26,28],"type":"mAtrA"},{"krama_ref":[29,31],"type":"svara","mAtrA_krama_ref":[30,32]},{"krama_ref":[30,32],"type":"mAtrA"},{"krama_ref":[33,35],"type":"svara","mAtrA_krama_ref":[34,36]},{"krama_ref":[34,36],"type":"mAtrA"},{"krama_ref":[52],"type":"vyanjana"},{"krama_ref":[53],"type":"vyanjana"},{"krama_ref":[54],"type":"vyanjana"},{"krama_ref":[55],"type":"vyanjana"},{"krama_ref":[56,58],"type":"vyanjana"},{"krama_ref":[57],"type":"vyanjana"},{"krama_ref":[59],"type":"vyanjana"},{"krama_ref":[60],"type":"vyanjana"},{"krama_ref":[61],"type":"vyanjana"},{"krama_ref":[62],"type":"vyanjana"},{"krama_ref":[63,65],"type":"vyanjana"},{"krama_ref":[64],"type":"vyanjana"},{"krama_ref":[66],"type":"vyanjana"},{"krama_ref":[67],"type":"vyanjana"},{"krama_ref":[74],"type":"vyanjana"},{"krama_ref":[75],"type":"vyanjana"},{"krama_ref":[76,78],"type":"vyanjana"},{"krama_ref":[77],"type":"vyanjana"},{"krama_ref":[79],"type":"vyanjana"},{"krama_ref":[80],"type":"vyanjana"},{"krama_ref":[81],"type":"vyanjana"},{"krama_ref":[68],"type":"vyanjana"},{"krama_ref":[69],"type":"vyanjana"},{"krama_ref":[70],"type":"vyanjana"},{"krama_ref":[71],"type":"vyanjana"},{"krama_ref":[72],"type":"vyanjana"},{"krama_ref":[73],"type":"vyanjana"},{"krama_ref":[82],"type":"vyanjana"},{"krama_ref":[83],"type":"vyanjana"},{"krama_ref":[84],"type":"vyanjana"},{"krama_ref":[85,86],"type":"vyanjana"},{"krama_ref":[87],"type":"vyanjana"},{"krama_ref":[88],"type":"vyanjana"},{"krama_ref":[89],"type":"vyanjana"},{"krama_ref":[90],"type":"vyanjana"},{"krama_ref":[92],"type":"vyanjana"},{"krama_ref":[93],"type":"vyanjana"},{"krama_ref":[94],"type":"vyanjana"},{"krama_ref":[95,96],"type":"vyanjana"},{"krama_ref":[99],"type":"vyanjana"},{"krama_ref":[100],"type":"vyanjana"},{"krama_ref":[98],"type":"vyanjana"},{"krama_ref":[97],"type":"vyanjana"},{"krama_ref":[91],"type":"vyanjana"}],"krama_text_arr":[["ওঁ",null],["অ",0],["",1],["অ",0],["",1],["আ",2],["া",3],["আ",2],["া",3],["ই",4],["ি",5],["ঈ",6],["ী",7],["উ",8],["ু",9],["উ",8],["ু",9],["ঊ",10],["ূ",11],["ঊ",10],["ূ",11],["এ",20],["ে",21],["এ",20],["ে",21],["ঐ",22],["ৈ",23],["ঐ",22],["ৈ",23],["ও",24],["ো",25],["ও",24],["ো",25],["ঔ",26],["ৌ",27],["ঔ",26],["ৌ",27],["ঋ",12],["ৃ",13],["ৠ",14],["ৄ",15],["ঌ",16],["ৢ",17],["ৡ",18],["ৣ",19],["ং",null],["ঁ",null],["ঃ",null],["ঽ",null],["্",null],["়",null],["॰",null],["ক",28],["ক়",29],["খ",30],["খ়",31],["গ",32],["গ়",33],["গ",32],["ঘ",34],["ঙ",35],["চ",36],["ছ",37],["জ",38],["জ়",39],["জ",38],["ঝ",40],["ঞ",41],["ত",49],["থ",50],["দ",51],["ধ",52],["ন",53],["ন়",54],["ট",42],["ঠ",43],["ড",44],["ড়",45],["ড",44],["ঢ",46],["ঢ়",47],["ণ",48],["প",55],["ফ",56],["ফ়",57],["ব",58],["ব",58],["ভ",59],["ম",60],["য",61],["য়",62],["ৱ",71],["ৰ",63],["ৰ়",64],["ল",65],["ল়",66],["ল়",66],["হ",70],["স",69],["শ",67],["ষ",68],["॒",null],["॑",null],["᳚",null],["᳛",null],["০",null],["১",null],["২",null],["৩",null],["৪",null],["৫",null],["৬",null],["৭",null],["৮",null],["৯",null],["।",null],["॥",null]],"krama_text_arr_index":[2,4,102,101,115,116,51,46,45,47,1,3,5,7,9,11,13,15,17,19,37,41,21,23,25,27,29,31,0,33,35,52,53,54,55,56,58,57,59,60,61,62,63,65,64,66,67,74,75,76,78,79,81,68,69,70,71,72,73,82,83,84,85,86,87,88,89,94,95,96,99,100,98,97,50,48,6,8,10,12,14,16,18,20,38,40,22,24,26,28,30,32,34,36,49,77,80,90,39,43,42,44,105,106,107,108,109,110,111,112,113,114,92,93,91,103,104]}
1
+ {"script_type":"brahmic","script_name":"Assamese","script_id":14,"halant":"্","nuqta":"়","schwa_property":true,"text_to_krama_map":[["ॐ",{"krama":[0]}],["ও",{"krama":[29],"next":["ঁ"]}],["ওঁ",{"krama":[0]}],["ক",{"krama":[52],"next":["়"]}],["ক়",{"krama":[53]}],["খ",{"krama":[54],"next":["়"]}],["খ়",{"krama":[55]}],["গ",{"krama":[56],"next":["়"]}],["গ়",{"krama":[57]}],["জ",{"krama":[63],"next":["়"]}],["জ়",{"krama":[64]}],["ড",{"next":["়"]}],["ড়",{"krama":[77]}],["ঢ",{"next":["়"]}],["ঢ়",{"krama":[80]}],["ন",{"krama":[72],"next":["়"]}],["ন়",{"krama":[73]}],["ফ",{"krama":[83],"next":["়"]}],["ফ়",{"krama":[84]}],["য",{"next":["়"]}],["য়",{"krama":[90]}],["র",{"krama":[92],"next":["়"]}],["র়",{"krama":[93]}],["ল",{"krama":[94],"next":["়"]}],["ল়",{"krama":[95]}],["ে",{"next":["া","ৗ"]}],["ো",{"krama":[30]}],["ৌ",{"krama":[34]}],["ৰ",{"krama":[92],"next":["়"]}],["ৰ়",{"krama":[93]}]],"list":[{"krama_ref":[1,3],"type":"svara","mAtrA_krama_ref":[2,4]},{"krama_ref":[2,4],"type":"mAtrA"},{"krama_ref":[5,7],"type":"svara","mAtrA_krama_ref":[6,8]},{"krama_ref":[6,8],"type":"mAtrA"},{"krama_ref":[9],"type":"svara","mAtrA_krama_ref":[10]},{"krama_ref":[10],"type":"mAtrA"},{"krama_ref":[11],"type":"svara","mAtrA_krama_ref":[12]},{"krama_ref":[12],"type":"mAtrA"},{"krama_ref":[13,15],"type":"svara","mAtrA_krama_ref":[14,16]},{"krama_ref":[14,16],"type":"mAtrA"},{"krama_ref":[17,19],"type":"svara","mAtrA_krama_ref":[18,20]},{"krama_ref":[18,20],"type":"mAtrA"},{"krama_ref":[37],"type":"svara","mAtrA_krama_ref":[38]},{"krama_ref":[38],"type":"mAtrA"},{"krama_ref":[39],"type":"svara","mAtrA_krama_ref":[40]},{"krama_ref":[40],"type":"mAtrA"},{"krama_ref":[41],"type":"svara","mAtrA_krama_ref":[42]},{"krama_ref":[42],"type":"mAtrA"},{"krama_ref":[43],"type":"svara","mAtrA_krama_ref":[44]},{"krama_ref":[44],"type":"mAtrA"},{"krama_ref":[21,23],"type":"svara","mAtrA_krama_ref":[22,24]},{"krama_ref":[22,24],"type":"mAtrA"},{"krama_ref":[25,27],"type":"svara","mAtrA_krama_ref":[26,28]},{"krama_ref":[26,28],"type":"mAtrA"},{"krama_ref":[29,31],"type":"svara","mAtrA_krama_ref":[30,32]},{"krama_ref":[30,32],"type":"mAtrA"},{"krama_ref":[33,35],"type":"svara","mAtrA_krama_ref":[34,36]},{"krama_ref":[34,36],"type":"mAtrA"},{"krama_ref":[52],"type":"vyanjana"},{"krama_ref":[53],"type":"vyanjana"},{"krama_ref":[54],"type":"vyanjana"},{"krama_ref":[55],"type":"vyanjana"},{"krama_ref":[56,58],"type":"vyanjana"},{"krama_ref":[57],"type":"vyanjana"},{"krama_ref":[59],"type":"vyanjana"},{"krama_ref":[60],"type":"vyanjana"},{"krama_ref":[61],"type":"vyanjana"},{"krama_ref":[62],"type":"vyanjana"},{"krama_ref":[63,65],"type":"vyanjana"},{"krama_ref":[64],"type":"vyanjana"},{"krama_ref":[66],"type":"vyanjana"},{"krama_ref":[67],"type":"vyanjana"},{"krama_ref":[74],"type":"vyanjana"},{"krama_ref":[75],"type":"vyanjana"},{"krama_ref":[76,78],"type":"vyanjana"},{"krama_ref":[77],"type":"vyanjana"},{"krama_ref":[79],"type":"vyanjana"},{"krama_ref":[80],"type":"vyanjana"},{"krama_ref":[81],"type":"vyanjana"},{"krama_ref":[68],"type":"vyanjana"},{"krama_ref":[69],"type":"vyanjana"},{"krama_ref":[70],"type":"vyanjana"},{"krama_ref":[71],"type":"vyanjana"},{"krama_ref":[72],"type":"vyanjana"},{"krama_ref":[73],"type":"vyanjana"},{"krama_ref":[82],"type":"vyanjana"},{"krama_ref":[83],"type":"vyanjana"},{"krama_ref":[84],"type":"vyanjana"},{"krama_ref":[85,86],"type":"vyanjana"},{"krama_ref":[87],"type":"vyanjana"},{"krama_ref":[88],"type":"vyanjana"},{"krama_ref":[89],"type":"vyanjana"},{"krama_ref":[90],"type":"vyanjana"},{"krama_ref":[92],"type":"vyanjana"},{"krama_ref":[93],"type":"vyanjana"},{"krama_ref":[94],"type":"vyanjana"},{"krama_ref":[95,96],"type":"vyanjana"},{"krama_ref":[99],"type":"vyanjana"},{"krama_ref":[100],"type":"vyanjana"},{"krama_ref":[98],"type":"vyanjana"},{"krama_ref":[97],"type":"vyanjana"},{"krama_ref":[91],"type":"vyanjana"}],"krama_text_arr":[["ওঁ",null],["অ",0],["",1],["অ",0],["",1],["আ",2],["া",3],["আ",2],["া",3],["ই",4],["ি",5],["ঈ",6],["ী",7],["উ",8],["ু",9],["উ",8],["ু",9],["ঊ",10],["ূ",11],["ঊ",10],["ূ",11],["এ",20],["ে",21],["এ",20],["ে",21],["ঐ",22],["ৈ",23],["ঐ",22],["ৈ",23],["ও",24],["ো",25],["ও",24],["ো",25],["ঔ",26],["ৌ",27],["ঔ",26],["ৌ",27],["ঋ",12],["ৃ",13],["ৠ",14],["ৄ",15],["ঌ",16],["ৢ",17],["ৡ",18],["ৣ",19],["ং",null],["ঁ",null],["ঃ",null],["ঽ",null],["্",null],["়",null],["॰",null],["ক",28],["ক়",29],["খ",30],["খ়",31],["গ",32],["গ়",33],["গ",32],["ঘ",34],["ঙ",35],["চ",36],["ছ",37],["জ",38],["জ়",39],["জ",38],["ঝ",40],["ঞ",41],["ত",49],["থ",50],["দ",51],["ধ",52],["ন",53],["ন়",54],["ট",42],["ঠ",43],["ড",44],["ড়",45],["ড",44],["ঢ",46],["ঢ়",47],["ণ",48],["প",55],["ফ",56],["ফ়",57],["ব",58],["ব",58],["ভ",59],["ম",60],["য",61],["য়",62],["ৱ",71],["ৰ",63],["ৰ়",64],["ল",65],["ল়",66],["ল়",66],["হ",70],["স",69],["শ",67],["ষ",68],["॒",null],["॑",null],["᳚",null],["᳛",null],["০",null],["১",null],["২",null],["৩",null],["৪",null],["৫",null],["৬",null],["৭",null],["৮",null],["৯",null],["।",null],["॥",null]],"krama_text_arr_index":[2,4,102,101,115,116,51,46,45,47,1,3,5,7,9,11,13,15,17,19,37,41,21,23,25,27,29,31,0,33,35,52,53,54,55,56,58,57,59,60,61,62,63,65,64,66,67,74,75,76,78,79,81,68,69,70,71,72,73,82,83,84,85,86,87,88,89,94,95,96,99,100,98,97,50,48,6,8,10,12,14,16,18,20,38,40,22,24,26,28,30,32,34,36,49,77,80,90,39,43,42,44,105,106,107,108,109,110,111,112,113,114,92,93,91,103,104],"typing_text_to_krama_map":[["'",{"next":["'"],"krama":[102]}],["''",{"next":["'"],"krama":[103]}],["'''",{"krama":[104]}],[".",{"krama":[115],"next":[".","q","h","0","1","2","3","4","5","6","7","8","9","A","i","I","u","U","e","E","a","O","o","R","L"]}],["..",{"krama":[116]}],[".0",{"krama":[105]}],[".1",{"krama":[106]}],[".2",{"krama":[107]}],[".3",{"krama":[108]}],[".4",{"krama":[109]}],[".5",{"krama":[110]}],[".6",{"krama":[111]}],[".7",{"krama":[112]}],[".8",{"krama":[113]}],[".9",{"krama":[114]}],[".A",{"krama":[6],"next":["1"]}],[".A1",{"krama":[8]}],[".E",{"krama":[22]}],[".I",{"krama":[12]}],[".L",{"next":["R"],"krama":[2,95]}],[".LR",{"krama":[42],"next":["R"]}],[".LRR",{"krama":[44]}],[".O",{"krama":[30]}],[".R",{"krama":[38],"next":["R"]}],[".RR",{"krama":[40]}],[".U",{"krama":[18],"next":["1"]}],[".U1",{"krama":[20]}],[".a",{"next":["i","u"],"krama":[2,2]}],[".ai",{"next":["I"],"krama":[2,2,2]}],[".aiI",{"krama":[28]}],[".au",{"next":["U"],"krama":[2,2,2]}],[".auU",{"krama":[36]}],[".e",{"krama":[24]}],[".h",{"krama":[49]}],[".i",{"krama":[10]}],[".o",{"krama":[32]}],[".q",{"custom_back_ref":3}],[".u",{"krama":[14],"next":["1"]}],[".u1",{"krama":[16]}],["A",{"krama":[5],"next":["U"]}],["AU",{"krama":[5,17],"next":["M"]}],["AUM",{"krama":[0]}],["C",{"krama":[61],"next":["h"]}],["Ch",{"krama":[62]}],["D",{"krama":[76],"next":["z","h"]}],["Dh",{"krama":[79],"next":["z"]}],["Dhz",{"krama":[80]}],["Dz",{"krama":[77]}],["L",{"krama":[95],"next":["R","z"]}],["LR",{"krama":[41],"next":["R"]}],["LRR",{"krama":[43]}],["Lz",{"krama":[96]}],["M",{"krama":[45],"next":["M"]}],["MM",{"krama":[46]}],["Q",{"krama":[51],"next":["Q"]}],["QQ",{"custom_back_ref":1}],["R",{"krama":[37],"next":["R"]}],["RR",{"krama":[39]}],["S",{"krama":[-1],"next":["h"]}],["Sh",{"krama":[100]}],["T",{"krama":[74],"next":["h"]}],["Th",{"krama":[75]}],["_",{"krama":[101]}],["a",{"krama":[1],"next":["i","u","a"]}],["aa",{"krama":[5]}],["ai",{"krama":[25]}],["au",{"krama":[33]}],["b",{"krama":[85],"next":["h"]}],["bh",{"krama":[87]}],["c",{"next":["h"]}],["ch",{"krama":[61],"next":["h"]}],["chh",{"krama":[62]}],["d",{"krama":[70],"next":["h"]}],["dh",{"krama":[71]}],["e",{"next":["e"],"krama":[23]}],["ee",{"krama":[11]}],["f",{"krama":[84]}],["g",{"krama":[56],"next":["z","h"]}],["gh",{"krama":[59]}],["gz",{"krama":[57]}],["i",{"next":["i"],"krama":[9]}],["ii",{"krama":[11]}],["j",{"krama":[63],"next":["z","h"]}],["jh",{"krama":[66]}],["jz",{"krama":[64]}],["k",{"krama":[52],"next":["z","h"]}],["kh",{"krama":[54],"next":["z"]}],["khz",{"krama":[55]}],["kz",{"krama":[53]}],["n",{"krama":[72],"next":["z","1"]}],["n1",{"krama":[73]}],["nz",{"krama":[73]}],["o",{"next":["o"],"krama":[31]}],["oo",{"krama":[17]}],["p",{"krama":[82],"next":["h"]}],["ph",{"krama":[83],"next":["z"]}],["phz",{"krama":[84]}],["q",{"custom_back_ref":0,"next":["q"]}],["qq",{"custom_back_ref":2}],["r",{"krama":[92],"next":["z","1"]}],["r1",{"krama":[93]}],["rz",{"krama":[93]}],["s",{"krama":[98],"next":["h"]}],["sh",{"krama":[99]}],["t",{"krama":[68],"next":["h"]}],["th",{"krama":[69]}],["u",{"next":["u"],"krama":[13]}],["uu",{"krama":[17]}],["z",{"krama":[64],"next":["h"]}],["zh",{"krama":[96]}],["↑",{"krama":[102],"next":["↑"]}],["↑↑",{"krama":[103],"next":["↑"]}],["↑↑↑",{"krama":[104]}]],"custom_script_chars_arr":[["",null,97],["Q",null,55],["q",null,98],["‍",null,36]]}