@glion/annotate-profile-datatypes 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Rethink Health
3
+ Copyright (c) 2023 Rethink Health, SUARL
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,mBAAmB;QAC3B,6DAA6D;QAC7D,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAChC,iDAAiD;QACjD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,qEAAqE;QACrE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,mDAAmD;QACnD,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B;IACD,UAAU,aAAa;QACrB,6CAA6C;QAC7C,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,qDAAqD;QACrD,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACxB,0DAA0D;QAC1D,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,qEAAqE;QACrE,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;QACtC,yDAAyD;QACzD,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAChC,yDAAyD;QACzD,KAAK,CAAC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C;QAChC,0CAA0C;QAC1C,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,oDAAoD;QACpD,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,iDAAiD;QACjD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC1B,sBAAsB;QACtB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC5B;CACF;AA4CD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CA4B9D,CAAC;AAEJ,eAAe,6BAA6B,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,29 @@
1
1
  import { SKIP, visit } from "@glion/util-visit";
2
2
  //#region src/index.ts
3
+ const findDatatype = (datatypes, id) => id === void 0 ? void 0 : datatypes.get(id);
4
+ /**
5
+ * Annotates each component or subcomponent `datatype` defines with its row,
6
+ * and the subcomponents of each component whose datatype is composite.
7
+ */
8
+ function annotateComponents(children, datatype, datatypes) {
9
+ for (const [sequence, profile] of datatype.componentsBySequence) {
10
+ const child = children[sequence - 1];
11
+ if (child === void 0) continue;
12
+ const childDatatype = findDatatype(datatypes, profile.datatypeId);
13
+ Object.assign(child.data ??= {}, {
14
+ id: `${datatype.id}.${sequence}`,
15
+ ...profile,
16
+ kind: childDatatype?.kind,
17
+ title: childDatatype?.title
18
+ });
19
+ switch (child.type) {
20
+ case "component":
21
+ if (childDatatype?.kind === "composite") annotateComponents(child.children, childDatatype, datatypes);
22
+ break;
23
+ case "subcomponent": break;
24
+ }
25
+ }
26
+ }
3
27
  /**
4
28
  * Unified plugin that annotates FieldRepetition, Component, and Subcomponent
5
29
  * nodes with datatype profile metadata using a stop-at-primitive cascade.
@@ -20,43 +44,18 @@ import { SKIP, visit } from "@glion/util-visit";
20
44
  const hl7v2AnnotateProfileDatatypes = () => (tree, file) => {
21
45
  const datatypes = file.data.profile?.datatypes;
22
46
  if (datatypes === void 0) return tree;
23
- const findDatatype = (id) => id === void 0 ? void 0 : datatypes.get(id);
24
47
  visit(tree, "field", (field) => {
25
- const datatype = findDatatype(field.data?.datatype);
48
+ const datatype = findDatatype(datatypes, field.data?.datatype);
26
49
  if (datatype === void 0) return SKIP;
27
- visit(field, "field-repetition", (repetition) => {
50
+ for (const repetition of field.children) {
28
51
  Object.assign(repetition.data ??= {}, {
29
52
  datatypeId: datatype.id,
30
53
  kind: datatype.kind,
31
54
  table: field.data?.table,
32
55
  title: datatype.title
33
56
  });
34
- });
35
- if (datatype.kind !== "composite") return SKIP;
36
- visit(field, "component", (component, _, componentInfo) => {
37
- const profile = datatype.componentsBySequence.get(componentInfo.sequence);
38
- if (profile === void 0) return SKIP;
39
- const componentDatatype = findDatatype(profile.datatypeId);
40
- Object.assign(component.data ??= {}, {
41
- id: `${datatype.id}.${componentInfo.sequence}`,
42
- ...profile,
43
- kind: componentDatatype?.kind,
44
- title: componentDatatype?.title
45
- });
46
- if (componentDatatype?.kind !== "composite") return SKIP;
47
- visit(component, "subcomponent", (subcomponent, __, subcomponentInfo) => {
48
- const subcomponentProfile = componentDatatype.componentsBySequence.get(subcomponentInfo.sequence);
49
- if (subcomponentProfile === void 0) return;
50
- const subcomponentDatatype = findDatatype(subcomponentProfile.datatypeId);
51
- Object.assign(subcomponent.data ??= {}, {
52
- id: `${componentDatatype.id}.${subcomponentInfo.sequence}`,
53
- ...subcomponentProfile,
54
- kind: subcomponentDatatype?.kind,
55
- title: subcomponentDatatype?.title
56
- });
57
- });
58
- return SKIP;
59
- });
57
+ if (datatype.kind === "composite") annotateComponents(repetition.children, datatype, datatypes);
58
+ }
60
59
  return SKIP;
61
60
  });
62
61
  return tree;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars -- triggers VFile DataMap augmentation\nimport type { ProfileContext } from \"@glion/annotate-profile-context\";\n// oxlint-disable-next-line no-unused-vars -- triggers FieldData augmentation\nimport type { hl7v2AnnotateProfileFields } from \"@glion/annotate-profile-fields\";\nimport type { Root } from \"@glion/ast\";\nimport { SKIP, visit } from \"@glion/util-visit\";\nimport type { Optionality } from \"@glion/utils\";\nimport type { Plugin } from \"unified\";\nimport type { VFile } from \"vfile\";\n\ndeclare module \"@glion/ast\" {\n interface FieldRepetitionData {\n /** Datatype ID for this field (e.g., \"ST\", \"CWE\", \"MSG\"). */\n datatypeId?: string | undefined;\n /** Datatype kind: \"primitive\" or \"composite\". */\n kind?: string | undefined;\n /** Datatype title (e.g., \"String Data\", \"Coded with Exceptions\"). */\n title?: string | undefined;\n /** The field's table (TBL#), such as \"HL70001\". */\n table?: string | undefined;\n }\n interface ComponentData {\n /** Position in the parent datatype (SEQ). */\n sequence?: number | undefined;\n /** Component identifier (e.g., \"CWE.1\", \"XPN.2\"). */\n id?: string | undefined;\n /** Component name from the parent datatype definition. */\n name?: string | undefined;\n /** OPT of this component in the parent datatype (e.g., \"R\", \"O\"). */\n optionality?: Optionality | undefined;\n /** Datatype ID for this component (e.g., \"ST\", \"ID\"). */\n datatypeId?: string | undefined;\n /** Table of this component's codes (e.g., \"HL70200\"). */\n table?: string | undefined;\n /** Maximum allowed length for this component. */\n maxLength?: number | undefined;\n /** Datatype kind: \"primitive\" or \"composite\". */\n kind?: string | undefined;\n /** Datatype title (e.g., \"String Data\"). */\n title?: string | undefined;\n }\n interface SubcomponentData {\n /** Position in the parent datatype (SEQ). */\n sequence?: number | undefined;\n /** Subcomponent identifier (e.g., \"FN.1\", \"HD.2\"). */\n id?: string | undefined;\n /** Subcomponent name from the parent component's datatype definition. */\n name?: string | undefined;\n /** OPT of this subcomponent in the component's datatype. */\n optionality?: Optionality | undefined;\n /** Datatype ID for this subcomponent. */\n datatypeId?: string | undefined;\n /** Table of this subcomponent's codes. */\n table?: string | undefined;\n /** Maximum allowed length for this subcomponent. */\n maxLength?: number | undefined;\n /** Datatype kind: \"primitive\" or \"composite\". */\n kind?: string | undefined;\n /** Datatype title. */\n title?: string | undefined;\n }\n}\n\n/**\n * Unified plugin that annotates FieldRepetition, Component, and Subcomponent\n * nodes with datatype profile metadata using a stop-at-primitive cascade.\n *\n * Annotation flows down the AST and stops at the node where the primitive\n * value lives:\n *\n * - Primitive field → stops at FieldRepetition\n * - Composite field with primitive components → stops at Component\n * - Composite field with composite components → stops at Subcomponent\n *\n * `kind: \"primitive\"` = the value is here.\n * `kind: \"composite\"` = look at children.\n * No annotation = the value lives on an ancestor.\n *\n * Requires the fields annotator to run first (preset guarantees ordering).\n */\nexport const hl7v2AnnotateProfileDatatypes: Plugin<[], Root, Root> =\n () => (tree: Root, file: VFile) => {\n const datatypes = file.data.profile?.datatypes;\n if (datatypes === undefined) {\n return tree;\n }\n\n const findDatatype = (id: string | undefined) =>\n id === undefined ? undefined : datatypes.get(id);\n\n visit(tree, \"field\", (field) => {\n const datatype = findDatatype(field.data?.datatype);\n if (datatype === undefined) {\n return SKIP;\n }\n\n visit(field, \"field-repetition\", (repetition) => {\n Object.assign((repetition.data ??= {}), {\n datatypeId: datatype.id,\n kind: datatype.kind,\n table: field.data?.table,\n title: datatype.title,\n });\n });\n if (datatype.kind !== \"composite\") {\n return SKIP;\n }\n\n visit(field, \"component\", (component, _, componentInfo) => {\n const profile = datatype.componentsBySequence.get(\n componentInfo.sequence\n );\n if (profile === undefined) {\n return SKIP;\n }\n\n const componentDatatype = findDatatype(profile.datatypeId);\n Object.assign((component.data ??= {}), {\n id: `${datatype.id}.${componentInfo.sequence}`,\n ...profile,\n kind: componentDatatype?.kind,\n title: componentDatatype?.title,\n });\n if (componentDatatype?.kind !== \"composite\") {\n return SKIP;\n }\n\n visit(\n component,\n \"subcomponent\",\n (subcomponent, __, subcomponentInfo) => {\n const subcomponentProfile =\n componentDatatype.componentsBySequence.get(\n subcomponentInfo.sequence\n );\n if (subcomponentProfile === undefined) {\n return;\n }\n\n const subcomponentDatatype = findDatatype(\n subcomponentProfile.datatypeId\n );\n Object.assign((subcomponent.data ??= {}), {\n id: `${componentDatatype.id}.${subcomponentInfo.sequence}`,\n ...subcomponentProfile,\n kind: subcomponentDatatype?.kind,\n title: subcomponentDatatype?.title,\n });\n }\n );\n return SKIP;\n });\n return SKIP;\n });\n\n return tree;\n };\n\nexport default hl7v2AnnotateProfileDatatypes;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgFA,MAAa,uCACJ,MAAY,SAAgB;CACjC,MAAM,YAAY,KAAK,KAAK,SAAS;AACrC,KAAI,cAAc,KAAA,EAChB,QAAO;CAGT,MAAM,gBAAgB,OACpB,OAAO,KAAA,IAAY,KAAA,IAAY,UAAU,IAAI,GAAG;AAElD,OAAM,MAAM,UAAU,UAAU;EAC9B,MAAM,WAAW,aAAa,MAAM,MAAM,SAAS;AACnD,MAAI,aAAa,KAAA,EACf,QAAO;AAGT,QAAM,OAAO,qBAAqB,eAAe;AAC/C,UAAO,OAAQ,WAAW,SAAS,EAAE,EAAG;IACtC,YAAY,SAAS;IACrB,MAAM,SAAS;IACf,OAAO,MAAM,MAAM;IACnB,OAAO,SAAS;IACjB,CAAC;IACF;AACF,MAAI,SAAS,SAAS,YACpB,QAAO;AAGT,QAAM,OAAO,cAAc,WAAW,GAAG,kBAAkB;GACzD,MAAM,UAAU,SAAS,qBAAqB,IAC5C,cAAc,SACf;AACD,OAAI,YAAY,KAAA,EACd,QAAO;GAGT,MAAM,oBAAoB,aAAa,QAAQ,WAAW;AAC1D,UAAO,OAAQ,UAAU,SAAS,EAAE,EAAG;IACrC,IAAI,GAAG,SAAS,GAAG,GAAG,cAAc;IACpC,GAAG;IACH,MAAM,mBAAmB;IACzB,OAAO,mBAAmB;IAC3B,CAAC;AACF,OAAI,mBAAmB,SAAS,YAC9B,QAAO;AAGT,SACE,WACA,iBACC,cAAc,IAAI,qBAAqB;IACtC,MAAM,sBACJ,kBAAkB,qBAAqB,IACrC,iBAAiB,SAClB;AACH,QAAI,wBAAwB,KAAA,EAC1B;IAGF,MAAM,uBAAuB,aAC3B,oBAAoB,WACrB;AACD,WAAO,OAAQ,aAAa,SAAS,EAAE,EAAG;KACxC,IAAI,GAAG,kBAAkB,GAAG,GAAG,iBAAiB;KAChD,GAAG;KACH,MAAM,sBAAsB;KAC5B,OAAO,sBAAsB;KAC9B,CAAC;KAEL;AACD,UAAO;IACP;AACF,SAAO;GACP;AAEF,QAAO"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { ProfileContext } from \"@glion/annotate-profile-context\";\n// oxlint-disable-next-line no-unused-vars -- triggers FieldData augmentation\nimport type { hl7v2AnnotateProfileFields } from \"@glion/annotate-profile-fields\";\nimport type { Component, Root, Subcomponent } from \"@glion/ast\";\nimport { SKIP, visit } from \"@glion/util-visit\";\nimport type { Optionality } from \"@glion/utils\";\nimport type { Plugin } from \"unified\";\nimport type { VFile } from \"vfile\";\n\ndeclare module \"@glion/ast\" {\n interface FieldRepetitionData {\n /** Datatype ID for this field (e.g., \"ST\", \"CWE\", \"MSG\"). */\n datatypeId?: string | undefined;\n /** Datatype kind: \"primitive\" or \"composite\". */\n kind?: string | undefined;\n /** Datatype title (e.g., \"String Data\", \"Coded with Exceptions\"). */\n title?: string | undefined;\n /** The field's table (TBL#), such as \"HL70001\". */\n table?: string | undefined;\n }\n interface ComponentData {\n /** Position in the parent datatype (SEQ). */\n sequence?: number | undefined;\n /** Component identifier (e.g., \"CWE.1\", \"XPN.2\"). */\n id?: string | undefined;\n /** Component name from the parent datatype definition. */\n name?: string | undefined;\n /** OPT of this component in the parent datatype (e.g., \"R\", \"O\"). */\n optionality?: Optionality | undefined;\n /** Datatype ID for this component (e.g., \"ST\", \"ID\"). */\n datatypeId?: string | undefined;\n /** Table of this component's codes (e.g., \"HL70200\"). */\n table?: string | undefined;\n /** Maximum allowed length for this component. */\n maxLength?: number | undefined;\n /** Datatype kind: \"primitive\" or \"composite\". */\n kind?: string | undefined;\n /** Datatype title (e.g., \"String Data\"). */\n title?: string | undefined;\n }\n interface SubcomponentData {\n /** Position in the parent datatype (SEQ). */\n sequence?: number | undefined;\n /** Subcomponent identifier (e.g., \"FN.1\", \"HD.2\"). */\n id?: string | undefined;\n /** Subcomponent name from the parent component's datatype definition. */\n name?: string | undefined;\n /** OPT of this subcomponent in the component's datatype. */\n optionality?: Optionality | undefined;\n /** Datatype ID for this subcomponent. */\n datatypeId?: string | undefined;\n /** Table of this subcomponent's codes. */\n table?: string | undefined;\n /** Maximum allowed length for this subcomponent. */\n maxLength?: number | undefined;\n /** Datatype kind: \"primitive\" or \"composite\". */\n kind?: string | undefined;\n /** Datatype title. */\n title?: string | undefined;\n }\n}\n\ntype Datatypes = ProfileContext[\"datatypes\"];\ntype DatatypeDefinition = NonNullable<ReturnType<Datatypes[\"get\"]>>;\n\nconst findDatatype = (datatypes: Datatypes, id: string | undefined) =>\n id === undefined ? undefined : datatypes.get(id);\n\n/**\n * Annotates each component or subcomponent `datatype` defines with its row,\n * and the subcomponents of each component whose datatype is composite.\n */\nfunction annotateComponents(\n children: readonly (Component | Subcomponent)[],\n datatype: DatatypeDefinition,\n datatypes: Datatypes\n): void {\n for (const [sequence, profile] of datatype.componentsBySequence) {\n const child = children[sequence - 1];\n if (child === undefined) {\n continue;\n }\n\n const childDatatype = findDatatype(datatypes, profile.datatypeId);\n Object.assign((child.data ??= {}), {\n id: `${datatype.id}.${sequence}`,\n ...profile,\n kind: childDatatype?.kind,\n title: childDatatype?.title,\n });\n switch (child.type) {\n case \"component\": {\n if (childDatatype?.kind === \"composite\") {\n annotateComponents(child.children, childDatatype, datatypes);\n }\n break;\n }\n case \"subcomponent\": {\n break;\n }\n }\n }\n}\n\n/**\n * Unified plugin that annotates FieldRepetition, Component, and Subcomponent\n * nodes with datatype profile metadata using a stop-at-primitive cascade.\n *\n * Annotation flows down the AST and stops at the node where the primitive\n * value lives:\n *\n * - Primitive field → stops at FieldRepetition\n * - Composite field with primitive components → stops at Component\n * - Composite field with composite components → stops at Subcomponent\n *\n * `kind: \"primitive\"` = the value is here.\n * `kind: \"composite\"` = look at children.\n * No annotation = the value lives on an ancestor.\n *\n * Requires the fields annotator to run first (preset guarantees ordering).\n */\nexport const hl7v2AnnotateProfileDatatypes: Plugin<[], Root, Root> =\n () => (tree: Root, file: VFile) => {\n const datatypes = file.data.profile?.datatypes;\n if (datatypes === undefined) {\n return tree;\n }\n\n visit(tree, \"field\", (field) => {\n const datatype = findDatatype(datatypes, field.data?.datatype);\n if (datatype === undefined) {\n return SKIP;\n }\n\n for (const repetition of field.children) {\n Object.assign((repetition.data ??= {}), {\n datatypeId: datatype.id,\n kind: datatype.kind,\n table: field.data?.table,\n title: datatype.title,\n });\n if (datatype.kind === \"composite\") {\n annotateComponents(repetition.children, datatype, datatypes);\n }\n }\n return SKIP;\n });\n\n return tree;\n };\n\nexport default hl7v2AnnotateProfileDatatypes;\n"],"mappings":";;AAiEA,MAAM,gBAAgB,WAAsB,OAC1C,OAAO,KAAA,IAAY,KAAA,IAAY,UAAU,IAAI,GAAG;;;;;AAMlD,SAAS,mBACP,UACA,UACA,WACM;AACN,MAAK,MAAM,CAAC,UAAU,YAAY,SAAS,sBAAsB;EAC/D,MAAM,QAAQ,SAAS,WAAW;AAClC,MAAI,UAAU,KAAA,EACZ;EAGF,MAAM,gBAAgB,aAAa,WAAW,QAAQ,WAAW;AACjE,SAAO,OAAQ,MAAM,SAAS,EAAE,EAAG;GACjC,IAAI,GAAG,SAAS,GAAG,GAAG;GACtB,GAAG;GACH,MAAM,eAAe;GACrB,OAAO,eAAe;GACvB,CAAC;AACF,UAAQ,MAAM,MAAd;GACE,KAAK;AACH,QAAI,eAAe,SAAS,YAC1B,oBAAmB,MAAM,UAAU,eAAe,UAAU;AAE9D;GAEF,KAAK,eACH;;;;;;;;;;;;;;;;;;;;;AAuBR,MAAa,uCACJ,MAAY,SAAgB;CACjC,MAAM,YAAY,KAAK,KAAK,SAAS;AACrC,KAAI,cAAc,KAAA,EAChB,QAAO;AAGT,OAAM,MAAM,UAAU,UAAU;EAC9B,MAAM,WAAW,aAAa,WAAW,MAAM,MAAM,SAAS;AAC9D,MAAI,aAAa,KAAA,EACf,QAAO;AAGT,OAAK,MAAM,cAAc,MAAM,UAAU;AACvC,UAAO,OAAQ,WAAW,SAAS,EAAE,EAAG;IACtC,YAAY,SAAS;IACrB,MAAM,SAAS;IACf,OAAO,MAAM,MAAM;IACnB,OAAO,SAAS;IACjB,CAAC;AACF,OAAI,SAAS,SAAS,YACpB,oBAAmB,WAAW,UAAU,UAAU,UAAU;;AAGhE,SAAO;GACP;AAEF,QAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glion/annotate-profile-datatypes",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Unified plugin to annotate HL7v2 field repetition, component, and subcomponent nodes with datatype profile metadata",
5
5
  "keywords": [
6
6
  "annotate",
@@ -40,10 +40,10 @@
40
40
  "dependencies": {
41
41
  "unified": "11.0.5",
42
42
  "vfile": "6.0.3",
43
- "@glion/annotate-profile-fields": "0.26.0",
44
- "@glion/ast": "0.26.0",
45
- "@glion/util-visit": "0.26.0",
46
- "@glion/utils": "0.26.0"
43
+ "@glion/ast": "0.27.0",
44
+ "@glion/annotate-profile-fields": "0.27.0",
45
+ "@glion/util-visit": "0.27.0",
46
+ "@glion/utils": "0.27.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/node": "25.6.0",
@@ -52,8 +52,8 @@
52
52
  "tsdown": "0.21.10",
53
53
  "typescript": "6.0.3",
54
54
  "vitest": "4.1.11",
55
- "@glion/builder": "0.26.0",
56
- "@glion/annotate-profile-context": "0.26.0",
55
+ "@glion/annotate-profile-context": "0.27.0",
56
+ "@glion/builder": "0.27.0",
57
57
  "@glion/check-readme": "0.18.0",
58
58
  "@glion/testing": "0.18.0",
59
59
  "@glion/tsconfig": "0.18.0"