@openworkbook/react 0.0.0-stage → 0.1.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.
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/dictionaries/en-GB.ts
21
+ var en_GB_exports = {};
22
+ __export(en_GB_exports, {
23
+ EN_GB_DICTIONARY_INFO: () => EN_GB_DICTIONARY_INFO,
24
+ britishWords: () => britishWords,
25
+ createBritishEnglishSpeller: () => createBritishEnglishSpeller
26
+ });
27
+ module.exports = __toCommonJS(en_GB_exports);
28
+ var import_core = require("@openworkbook/core");
29
+ var import_en = require("./en.cjs");
30
+
31
+ // src/dictionaries/en-GB-rules.ts
32
+ var OUR = [
33
+ ["color", " s ed ing ings ful fully fulness less lessly lessness able ably ist ists fast"],
34
+ ["honor", " s ed ing able ably ableness less"],
35
+ ["favor", " s ed ing able ably ableness ite ites itism er less"],
36
+ ["flavor", " s ed ing ings ful less some"],
37
+ ["labor", " s ed ing er ers saving"],
38
+ ["neighbor", " s ed ing hood hoods ly liness less"],
39
+ ["humor", " s ed ing less"],
40
+ ["rumor", " s ed monger mongers"],
41
+ ["harbor", " s ed ing"],
42
+ ["behavior", " s al ally ism ist ists istic"],
43
+ ["vapor", " s"],
44
+ ["vigor", ""],
45
+ ["valor", ""],
46
+ ["odor", " s less"],
47
+ ["armor", " s ed er ers y"],
48
+ ["savior", " s"],
49
+ ["splendor", " s"],
50
+ ["tumor", " s"],
51
+ ["clamor", " s ed ing"],
52
+ ["candor", ""],
53
+ ["ardor", ""],
54
+ ["fervor", ""],
55
+ ["parlor", " s maid maids"],
56
+ ["endeavor", " s ed ing"],
57
+ ["demeanor", ""],
58
+ ["savor", " s ed ing less"],
59
+ // "savory" the herb is British too: "savoury" is added below
60
+ ["succor", " s ed ing"],
61
+ ["rancor", ""],
62
+ ["+rigor", " s"],
63
+ ["+arbor", " s"]
64
+ ];
65
+ var DOUBLE_L = "*travel cancel *label *model *signal fuel *level marvel *quarrel total channel counsel dial equal *jewel tunnel panel pedal shovel *snorkel spiral rival libel *enamel funnel grovel initial pencil refuel *revel shrivel swivel towel unravel *yodel bevel chisel cudgel dishevel duel gambol kennel marshal stencil".split(" ");
66
+ var PAIRS = `
67
+ center>centre centers>centres centered>centred centering>centring centerpiece>centrepiece centerpieces>centrepieces centerfold>centrefold
68
+ theater>theatre theaters>theatres theatergoer>theatregoer theatergoers>theatregoers
69
+ kilometer>kilometre kilometers>kilometres centimeter>centimetre centimeters>centimetres millimeter>millimetre millimeters>millimetres
70
+ decimeter>decimetre decimeters>decimetres nanometer>nanometre nanometers>nanometres
71
+ liter>litre liters>litres milliliter>millilitre milliliters>millilitres centiliter>centilitre centiliters>centilitres deciliter>decilitre
72
+ fiber>fibre fibers>fibres fiberglass>fibreglass fiberboard>fibreboard saber>sabre sabers>sabres somber>sombre somberly>sombrely
73
+ specter>spectre specters>spectres caliber>calibre calibers>calibres meager>meagre meagerly>meagrely miter>mitre miters>mitres mitered>mitred
74
+ ocher>ochre sepulcher>sepulchre sepulchers>sepulchres scepter>sceptre scepters>sceptres goiter>goitre niter>nitre saltpeter>saltpetre
75
+ maneuver>manoeuvre maneuvers>manoeuvres maneuvered>manoeuvred maneuvering>manoeuvring maneuverable>manoeuvrable maneuverability>manoeuvrability
76
+ louver>louvre louvers>louvres accouterment>accoutrement accouterments>accoutrements reconnoiter>reconnoitre
77
+ +meter>metre +meters>metres +micrometer>micrometre +micrometers>micrometres +luster>lustre
78
+ catalog>catalogue catalogs>catalogues cataloged>catalogued cataloging>cataloguing cataloger>cataloguer catalogers>cataloguers
79
+ monolog>monologue monologs>monologues travelog>travelogue travelogs>travelogues
80
+ +dialog>dialogue +dialogs>dialogues +analog>analogue +analogs>analogues
81
+ defense>defence defenses>defences defenseless>defenceless defenselessly>defencelessly offense>offence offenses>offences pretense>pretence pretenses>pretences
82
+ +license>licence +licenses>licences +practice>practise +practiced>practised +practicing>practising +practices>practises
83
+ aluminum>aluminium plow>plough plows>ploughs plowed>ploughed plowing>ploughing plowman>ploughman plowshare>ploughshare
84
+ skeptic>sceptic skeptics>sceptics skeptical>sceptical skeptically>sceptically skepticism>scepticism
85
+ pajamas>pyjamas pajama>pyjama jewelry>jewellery mustache>moustache mustaches>moustaches
86
+ cozy>cosy cozier>cosier coziest>cosiest coziness>cosiness cozily>cosily
87
+ fulfill>fulfil fulfills>fulfils fulfillment>fulfilment enroll>enrol enrolls>enrols enrollment>enrolment enrollments>enrolments instill>instil instills>instils
88
+ skillful>skilful skillfully>skilfully willful>wilful willfully>wilfully woolen>woollen woolens>woollens
89
+ marvelous>marvellous marvelously>marvellously counselor>counsellor counselors>counsellors duelist>duellist duelists>duellists
90
+ worshiped>worshipped worshiping>worshipping worshiper>worshipper worshipers>worshippers
91
+ +gray>grey +grayish>greyish +grays>greys +mold>mould +molds>moulds +moldy>mouldy +molded>moulded +molding>moulding
92
+ +tire>tyre +tires>tyres +check>cheque +checks>cheques +curb>kerb +curbs>kerbs +story>storey +stories>storeys
93
+ +program>programme +programs>programmes +aging>ageing +acknowledgment>acknowledgement +acknowledgments>acknowledgements +judgment>judgement +judgments>judgements
94
+ +artifact>artefact +artifacts>artefacts +sulfur>sulphur +donut>doughnut +donuts>doughnuts +ax>axe +glamor>glamour
95
+ +anemia>anaemia +anemic>anaemic +anesthesia>anaesthesia +anesthetic>anaesthetic +anesthetics>anaesthetics
96
+ +pediatric>paediatric +pediatrics>paediatrics +pediatrician>paediatrician +pediatricians>paediatricians +hemoglobin>haemoglobin
97
+ +esophagus>oesophagus +estrogen>oestrogen +archeology>archaeology +leukemia>leukaemia +diarrhea>diarrhoea +gynecology>gynaecology
98
+ +orthopedic>orthopaedic +orthopedics>orthopaedics +savory>savoury
99
+ `;
100
+ var IZE_RE = /^(.*)iz(e|ed|es|er|ers|ing|ings|ation|ations|ational|able|ability)$/;
101
+ var NOT_IZE = new Set("size capsize outsize oversize undersize resize supersize downsize upsize desize sensize kingsize assize".split(" "));
102
+ var SIZE_VERB_RE = /(?:thesize|asize|osize|opsize)$/;
103
+ var LYZE_RE = /^(.*)lyz(e|ed|es|er|ers|ing|able)$/;
104
+ function britishVariants(words2) {
105
+ const list = new Set(words2);
106
+ const add = /* @__PURE__ */ new Set(), remove = /* @__PURE__ */ new Set(), map = /* @__PURE__ */ new Map();
107
+ const replace = (us, gb) => {
108
+ add.add(gb);
109
+ map.set(us, gb);
110
+ if (list.has(us)) remove.add(us);
111
+ };
112
+ for (const w of list) {
113
+ const lz = LYZE_RE.exec(w);
114
+ if (lz && lz[1].length >= 2) {
115
+ replace(w, `${lz[1]}lys${lz[2]}`);
116
+ continue;
117
+ }
118
+ const iz = IZE_RE.exec(w);
119
+ if (!iz || iz[1].length < 3) continue;
120
+ const verb = `${iz[1]}ize`.toLowerCase();
121
+ if (NOT_IZE.has(verb) || verb.endsWith("seize") || verb.endsWith("size") && !SIZE_VERB_RE.test(verb)) continue;
122
+ add.add(`${iz[1]}is${iz[2]}`);
123
+ }
124
+ for (const [stem, endings] of OUR) {
125
+ const only = stem.startsWith("+"), us = stem.replace("+", ""), gb = `${us.slice(0, -2)}our`;
126
+ for (const e of endings.split(" ")) only ? add.add(gb + e) : replace(us + e, gb + e);
127
+ }
128
+ for (const v of DOUBLE_L) {
129
+ const verb = v.replace("*", "");
130
+ const ends = v.startsWith("*") ? ["ed", "ing", "er", "ers"] : ["ed", "ing"];
131
+ for (const e of ends) replace(verb + e, `${verb}l${e}`);
132
+ }
133
+ for (const p of PAIRS.split(/\s+/)) {
134
+ if (!p) continue;
135
+ const only = p.startsWith("+"), [us, gb] = p.replace("+", "").split(">");
136
+ if (only) add.add(gb);
137
+ else replace(us, gb);
138
+ }
139
+ for (const w of add) remove.delete(w);
140
+ return { add: [...add], remove: [...remove], map };
141
+ }
142
+
143
+ // src/dictionaries/en-GB.ts
144
+ var EN_GB_DICTIONARY_INFO = {
145
+ language: "en-GB",
146
+ source: `${import_en.EN_DICTIONARY_INFO.source}, with British spellings derived by the OpenWorkbook rules (-ise next to -ize, -lyse, -our, -re, -ogue, -ence, doubled l and a table of common pairs)`,
147
+ license: `${import_en.EN_DICTIONARY_INFO.license} Rules and tables: MIT (OpenWorkbook).`
148
+ };
149
+ var words = null;
150
+ var common = null;
151
+ var american = null;
152
+ function britishWords() {
153
+ if (words) return words;
154
+ const us = (0, import_en.englishWords)();
155
+ const v = britishVariants(us);
156
+ const drop = new Set(v.remove);
157
+ const out = us.filter((w) => !drop.has(w));
158
+ const have = new Set(out);
159
+ for (const w of v.add) if (!have.has(w)) out.push(w);
160
+ common = (0, import_en.englishCommonWords)().map((w) => v.map.get(w) ?? w);
161
+ american = v.map;
162
+ return words = out;
163
+ }
164
+ function createBritishEnglishSpeller(options = {}) {
165
+ const list = britishWords();
166
+ const us = american;
167
+ const s = (0, import_core.createWordListSpeller)(list, { ...options, inflections: "en", common, exclude: [...us.keys(), ...options.exclude ?? []] });
168
+ const max = options.maxSuggestions ?? 8;
169
+ const first = (word, found) => {
170
+ const gb = us.get(word.replace(/\u2019/g, "'").toLowerCase());
171
+ if (!gb) return [...found];
172
+ const x = (0, import_core.matchSpellingCase)(word, gb);
173
+ return [x, ...found.filter((y) => y !== x)].slice(0, max);
174
+ };
175
+ return {
176
+ get ready() {
177
+ return s.ready;
178
+ },
179
+ get size() {
180
+ return s.size;
181
+ },
182
+ add: (...ws) => s.add(...ws),
183
+ has: (w) => s.has(w),
184
+ check: (w, language) => s.check(w, language),
185
+ suggestions: (w) => first(w, s.suggestions(w)),
186
+ suggest: (w, language) => {
187
+ const r = s.suggest(w, language);
188
+ return Array.isArray(r) ? first(w, r) : Promise.resolve(r).then((l) => first(w, l));
189
+ }
190
+ };
191
+ }
192
+ // Annotate the CommonJS export names for ESM import in node:
193
+ 0 && (module.exports = {
194
+ EN_GB_DICTIONARY_INFO,
195
+ britishWords,
196
+ createBritishEnglishSpeller
197
+ });
@@ -0,0 +1,20 @@
1
+ import { WordListSpellerOptions, WordListSpeller } from '@openworkbook/core';
2
+
3
+ /** Where the British English word list comes from. */
4
+ declare const EN_GB_DICTIONARY_INFO: {
5
+ readonly language: "en-GB";
6
+ readonly source: "Webster's Second New International Dictionary (1934) word list (web2, as distributed with BSD systems), plus a supplementary list of modern words written for OpenWorkbook, with British spellings derived by the OpenWorkbook rules (-ise next to -ize, -lyse, -our, -re, -ogue, -ence, doubled l and a table of common pairs)";
7
+ readonly license: "Base list: public domain (the 1934 copyright has lapsed). Supplement and ranking list: MIT (OpenWorkbook). Rules and tables: MIT (OpenWorkbook).";
8
+ };
9
+ /** The British English word list (derived once, then shared). */
10
+ declare function britishWords(): readonly string[];
11
+ /**
12
+ * A spelling provider for British English: the American list with British spellings (`colour`, `centre`,
13
+ * `catalogue`, `defence`, `travelled`, `analyse`, `organise` and `organize`) and without the American-only forms of
14
+ * the tables (`color`, `center`, `analyze`...), with the English inflection rules and the common-word ranking. The
15
+ * British spelling of an American word of the tables is its first suggestion (`catalog` -> `catalogue`). Each call
16
+ * builds a new provider; create it once and reuse it.
17
+ */
18
+ declare function createBritishEnglishSpeller(options?: Omit<WordListSpellerOptions, 'inflections' | 'common'>): WordListSpeller;
19
+
20
+ export { EN_GB_DICTIONARY_INFO, britishWords, createBritishEnglishSpeller };
@@ -0,0 +1,20 @@
1
+ import { WordListSpellerOptions, WordListSpeller } from '@openworkbook/core';
2
+
3
+ /** Where the British English word list comes from. */
4
+ declare const EN_GB_DICTIONARY_INFO: {
5
+ readonly language: "en-GB";
6
+ readonly source: "Webster's Second New International Dictionary (1934) word list (web2, as distributed with BSD systems), plus a supplementary list of modern words written for OpenWorkbook, with British spellings derived by the OpenWorkbook rules (-ise next to -ize, -lyse, -our, -re, -ogue, -ence, doubled l and a table of common pairs)";
7
+ readonly license: "Base list: public domain (the 1934 copyright has lapsed). Supplement and ranking list: MIT (OpenWorkbook). Rules and tables: MIT (OpenWorkbook).";
8
+ };
9
+ /** The British English word list (derived once, then shared). */
10
+ declare function britishWords(): readonly string[];
11
+ /**
12
+ * A spelling provider for British English: the American list with British spellings (`colour`, `centre`,
13
+ * `catalogue`, `defence`, `travelled`, `analyse`, `organise` and `organize`) and without the American-only forms of
14
+ * the tables (`color`, `center`, `analyze`...), with the English inflection rules and the common-word ranking. The
15
+ * British spelling of an American word of the tables is its first suggestion (`catalog` -> `catalogue`). Each call
16
+ * builds a new provider; create it once and reuse it.
17
+ */
18
+ declare function createBritishEnglishSpeller(options?: Omit<WordListSpellerOptions, 'inflections' | 'common'>): WordListSpeller;
19
+
20
+ export { EN_GB_DICTIONARY_INFO, britishWords, createBritishEnglishSpeller };
@@ -0,0 +1,170 @@
1
+ // src/dictionaries/en-GB.ts
2
+ import { createWordListSpeller, matchSpellingCase } from "@openworkbook/core";
3
+ import { EN_DICTIONARY_INFO, englishCommonWords, englishWords } from "./en.js";
4
+
5
+ // src/dictionaries/en-GB-rules.ts
6
+ var OUR = [
7
+ ["color", " s ed ing ings ful fully fulness less lessly lessness able ably ist ists fast"],
8
+ ["honor", " s ed ing able ably ableness less"],
9
+ ["favor", " s ed ing able ably ableness ite ites itism er less"],
10
+ ["flavor", " s ed ing ings ful less some"],
11
+ ["labor", " s ed ing er ers saving"],
12
+ ["neighbor", " s ed ing hood hoods ly liness less"],
13
+ ["humor", " s ed ing less"],
14
+ ["rumor", " s ed monger mongers"],
15
+ ["harbor", " s ed ing"],
16
+ ["behavior", " s al ally ism ist ists istic"],
17
+ ["vapor", " s"],
18
+ ["vigor", ""],
19
+ ["valor", ""],
20
+ ["odor", " s less"],
21
+ ["armor", " s ed er ers y"],
22
+ ["savior", " s"],
23
+ ["splendor", " s"],
24
+ ["tumor", " s"],
25
+ ["clamor", " s ed ing"],
26
+ ["candor", ""],
27
+ ["ardor", ""],
28
+ ["fervor", ""],
29
+ ["parlor", " s maid maids"],
30
+ ["endeavor", " s ed ing"],
31
+ ["demeanor", ""],
32
+ ["savor", " s ed ing less"],
33
+ // "savory" the herb is British too: "savoury" is added below
34
+ ["succor", " s ed ing"],
35
+ ["rancor", ""],
36
+ ["+rigor", " s"],
37
+ ["+arbor", " s"]
38
+ ];
39
+ var DOUBLE_L = "*travel cancel *label *model *signal fuel *level marvel *quarrel total channel counsel dial equal *jewel tunnel panel pedal shovel *snorkel spiral rival libel *enamel funnel grovel initial pencil refuel *revel shrivel swivel towel unravel *yodel bevel chisel cudgel dishevel duel gambol kennel marshal stencil".split(" ");
40
+ var PAIRS = `
41
+ center>centre centers>centres centered>centred centering>centring centerpiece>centrepiece centerpieces>centrepieces centerfold>centrefold
42
+ theater>theatre theaters>theatres theatergoer>theatregoer theatergoers>theatregoers
43
+ kilometer>kilometre kilometers>kilometres centimeter>centimetre centimeters>centimetres millimeter>millimetre millimeters>millimetres
44
+ decimeter>decimetre decimeters>decimetres nanometer>nanometre nanometers>nanometres
45
+ liter>litre liters>litres milliliter>millilitre milliliters>millilitres centiliter>centilitre centiliters>centilitres deciliter>decilitre
46
+ fiber>fibre fibers>fibres fiberglass>fibreglass fiberboard>fibreboard saber>sabre sabers>sabres somber>sombre somberly>sombrely
47
+ specter>spectre specters>spectres caliber>calibre calibers>calibres meager>meagre meagerly>meagrely miter>mitre miters>mitres mitered>mitred
48
+ ocher>ochre sepulcher>sepulchre sepulchers>sepulchres scepter>sceptre scepters>sceptres goiter>goitre niter>nitre saltpeter>saltpetre
49
+ maneuver>manoeuvre maneuvers>manoeuvres maneuvered>manoeuvred maneuvering>manoeuvring maneuverable>manoeuvrable maneuverability>manoeuvrability
50
+ louver>louvre louvers>louvres accouterment>accoutrement accouterments>accoutrements reconnoiter>reconnoitre
51
+ +meter>metre +meters>metres +micrometer>micrometre +micrometers>micrometres +luster>lustre
52
+ catalog>catalogue catalogs>catalogues cataloged>catalogued cataloging>cataloguing cataloger>cataloguer catalogers>cataloguers
53
+ monolog>monologue monologs>monologues travelog>travelogue travelogs>travelogues
54
+ +dialog>dialogue +dialogs>dialogues +analog>analogue +analogs>analogues
55
+ defense>defence defenses>defences defenseless>defenceless defenselessly>defencelessly offense>offence offenses>offences pretense>pretence pretenses>pretences
56
+ +license>licence +licenses>licences +practice>practise +practiced>practised +practicing>practising +practices>practises
57
+ aluminum>aluminium plow>plough plows>ploughs plowed>ploughed plowing>ploughing plowman>ploughman plowshare>ploughshare
58
+ skeptic>sceptic skeptics>sceptics skeptical>sceptical skeptically>sceptically skepticism>scepticism
59
+ pajamas>pyjamas pajama>pyjama jewelry>jewellery mustache>moustache mustaches>moustaches
60
+ cozy>cosy cozier>cosier coziest>cosiest coziness>cosiness cozily>cosily
61
+ fulfill>fulfil fulfills>fulfils fulfillment>fulfilment enroll>enrol enrolls>enrols enrollment>enrolment enrollments>enrolments instill>instil instills>instils
62
+ skillful>skilful skillfully>skilfully willful>wilful willfully>wilfully woolen>woollen woolens>woollens
63
+ marvelous>marvellous marvelously>marvellously counselor>counsellor counselors>counsellors duelist>duellist duelists>duellists
64
+ worshiped>worshipped worshiping>worshipping worshiper>worshipper worshipers>worshippers
65
+ +gray>grey +grayish>greyish +grays>greys +mold>mould +molds>moulds +moldy>mouldy +molded>moulded +molding>moulding
66
+ +tire>tyre +tires>tyres +check>cheque +checks>cheques +curb>kerb +curbs>kerbs +story>storey +stories>storeys
67
+ +program>programme +programs>programmes +aging>ageing +acknowledgment>acknowledgement +acknowledgments>acknowledgements +judgment>judgement +judgments>judgements
68
+ +artifact>artefact +artifacts>artefacts +sulfur>sulphur +donut>doughnut +donuts>doughnuts +ax>axe +glamor>glamour
69
+ +anemia>anaemia +anemic>anaemic +anesthesia>anaesthesia +anesthetic>anaesthetic +anesthetics>anaesthetics
70
+ +pediatric>paediatric +pediatrics>paediatrics +pediatrician>paediatrician +pediatricians>paediatricians +hemoglobin>haemoglobin
71
+ +esophagus>oesophagus +estrogen>oestrogen +archeology>archaeology +leukemia>leukaemia +diarrhea>diarrhoea +gynecology>gynaecology
72
+ +orthopedic>orthopaedic +orthopedics>orthopaedics +savory>savoury
73
+ `;
74
+ var IZE_RE = /^(.*)iz(e|ed|es|er|ers|ing|ings|ation|ations|ational|able|ability)$/;
75
+ var NOT_IZE = new Set("size capsize outsize oversize undersize resize supersize downsize upsize desize sensize kingsize assize".split(" "));
76
+ var SIZE_VERB_RE = /(?:thesize|asize|osize|opsize)$/;
77
+ var LYZE_RE = /^(.*)lyz(e|ed|es|er|ers|ing|able)$/;
78
+ function britishVariants(words2) {
79
+ const list = new Set(words2);
80
+ const add = /* @__PURE__ */ new Set(), remove = /* @__PURE__ */ new Set(), map = /* @__PURE__ */ new Map();
81
+ const replace = (us, gb) => {
82
+ add.add(gb);
83
+ map.set(us, gb);
84
+ if (list.has(us)) remove.add(us);
85
+ };
86
+ for (const w of list) {
87
+ const lz = LYZE_RE.exec(w);
88
+ if (lz && lz[1].length >= 2) {
89
+ replace(w, `${lz[1]}lys${lz[2]}`);
90
+ continue;
91
+ }
92
+ const iz = IZE_RE.exec(w);
93
+ if (!iz || iz[1].length < 3) continue;
94
+ const verb = `${iz[1]}ize`.toLowerCase();
95
+ if (NOT_IZE.has(verb) || verb.endsWith("seize") || verb.endsWith("size") && !SIZE_VERB_RE.test(verb)) continue;
96
+ add.add(`${iz[1]}is${iz[2]}`);
97
+ }
98
+ for (const [stem, endings] of OUR) {
99
+ const only = stem.startsWith("+"), us = stem.replace("+", ""), gb = `${us.slice(0, -2)}our`;
100
+ for (const e of endings.split(" ")) only ? add.add(gb + e) : replace(us + e, gb + e);
101
+ }
102
+ for (const v of DOUBLE_L) {
103
+ const verb = v.replace("*", "");
104
+ const ends = v.startsWith("*") ? ["ed", "ing", "er", "ers"] : ["ed", "ing"];
105
+ for (const e of ends) replace(verb + e, `${verb}l${e}`);
106
+ }
107
+ for (const p of PAIRS.split(/\s+/)) {
108
+ if (!p) continue;
109
+ const only = p.startsWith("+"), [us, gb] = p.replace("+", "").split(">");
110
+ if (only) add.add(gb);
111
+ else replace(us, gb);
112
+ }
113
+ for (const w of add) remove.delete(w);
114
+ return { add: [...add], remove: [...remove], map };
115
+ }
116
+
117
+ // src/dictionaries/en-GB.ts
118
+ var EN_GB_DICTIONARY_INFO = {
119
+ language: "en-GB",
120
+ source: `${EN_DICTIONARY_INFO.source}, with British spellings derived by the OpenWorkbook rules (-ise next to -ize, -lyse, -our, -re, -ogue, -ence, doubled l and a table of common pairs)`,
121
+ license: `${EN_DICTIONARY_INFO.license} Rules and tables: MIT (OpenWorkbook).`
122
+ };
123
+ var words = null;
124
+ var common = null;
125
+ var american = null;
126
+ function britishWords() {
127
+ if (words) return words;
128
+ const us = englishWords();
129
+ const v = britishVariants(us);
130
+ const drop = new Set(v.remove);
131
+ const out = us.filter((w) => !drop.has(w));
132
+ const have = new Set(out);
133
+ for (const w of v.add) if (!have.has(w)) out.push(w);
134
+ common = englishCommonWords().map((w) => v.map.get(w) ?? w);
135
+ american = v.map;
136
+ return words = out;
137
+ }
138
+ function createBritishEnglishSpeller(options = {}) {
139
+ const list = britishWords();
140
+ const us = american;
141
+ const s = createWordListSpeller(list, { ...options, inflections: "en", common, exclude: [...us.keys(), ...options.exclude ?? []] });
142
+ const max = options.maxSuggestions ?? 8;
143
+ const first = (word, found) => {
144
+ const gb = us.get(word.replace(/\u2019/g, "'").toLowerCase());
145
+ if (!gb) return [...found];
146
+ const x = matchSpellingCase(word, gb);
147
+ return [x, ...found.filter((y) => y !== x)].slice(0, max);
148
+ };
149
+ return {
150
+ get ready() {
151
+ return s.ready;
152
+ },
153
+ get size() {
154
+ return s.size;
155
+ },
156
+ add: (...ws) => s.add(...ws),
157
+ has: (w) => s.has(w),
158
+ check: (w, language) => s.check(w, language),
159
+ suggestions: (w) => first(w, s.suggestions(w)),
160
+ suggest: (w, language) => {
161
+ const r = s.suggest(w, language);
162
+ return Array.isArray(r) ? first(w, r) : Promise.resolve(r).then((l) => first(w, l));
163
+ }
164
+ };
165
+ }
166
+ export {
167
+ EN_GB_DICTIONARY_INFO,
168
+ britishWords,
169
+ createBritishEnglishSpeller
170
+ };