@lhncbc/ucum-lhc 4.2.0 → 5.0.2

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 (36) hide show
  1. package/README.md +50 -12
  2. package/browser-dist/ucum-lhc.js +841 -1325
  3. package/data/ucumDefs.min.json +1 -1
  4. package/package.json +1 -1
  5. package/source/ucumLhcUtils.js +100 -66
  6. package/source/ucumXmlDocument.js +5 -2
  7. package/source/unit.js +2 -1
  8. package/source/unitString.js +159 -140
  9. package/source-cjs/config.js +1 -12
  10. package/source-cjs/config.js.map +1 -1
  11. package/source-cjs/dimension.js +20 -63
  12. package/source-cjs/dimension.js.map +1 -1
  13. package/source-cjs/jsonArrayPack.js +7 -25
  14. package/source-cjs/jsonArrayPack.js.map +1 -1
  15. package/source-cjs/prefix.js +12 -26
  16. package/source-cjs/prefix.js.map +1 -1
  17. package/source-cjs/prefixTables.js +10 -24
  18. package/source-cjs/prefixTables.js.map +1 -1
  19. package/source-cjs/ucumFunctions.js +35 -32
  20. package/source-cjs/ucumFunctions.js.map +1 -1
  21. package/source-cjs/ucumInternalUtils.js +5 -13
  22. package/source-cjs/ucumInternalUtils.js.map +1 -1
  23. package/source-cjs/ucumJsonDefs.js +1 -16
  24. package/source-cjs/ucumJsonDefs.js.map +1 -1
  25. package/source-cjs/ucumLhcUtils.js +117 -138
  26. package/source-cjs/ucumLhcUtils.js.map +1 -1
  27. package/source-cjs/ucumPkg.js +1 -6
  28. package/source-cjs/ucumPkg.js.map +1 -1
  29. package/source-cjs/ucumXmlDocument.js +162 -184
  30. package/source-cjs/ucumXmlDocument.js.map +1 -1
  31. package/source-cjs/unit.js +97 -181
  32. package/source-cjs/unit.js.map +1 -1
  33. package/source-cjs/unitString.js +537 -618
  34. package/source-cjs/unitString.js.map +1 -1
  35. package/source-cjs/unitTables.js +33 -139
  36. package/source-cjs/unitTables.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../source/ucumXmlDocument.js"],"names":["Prefix","require","PrefixTables","Unit","UnitString","UnitTables","packArray","jsonfile","xmldoc","fs","essenceFile_","xmlInput_","UcumXmlDocument","constructor","data","readFileSync","XmlDocument","moleCodes_","holdThis","prototype","Error","exports","self","getInstance","parseXml","parsePrefixes","childrenNamed","parseBaseUnits","parseUnitStrings","writeJsonFile","writeVersionText","prefixes","plen","length","p","curPfx","attrs","attr","Code","CODE","childNamed","val","pValNode","Math","pow","ptab","isDefined","newPref","add","unitNodes","blen","utab","b","curBUnit","dim","newUnit","addUnit","unitStrings","uStrParser","stopNow","alen","a","haveUnit","curUA","toUpperCase","sym","symVal","replace","trim","symI","toString","compressed","sub","sup","isMetric","isArbitrary","class","valNode","indexOf","isSpecial","funcNode","name","parseFloat","value","slashPos","ar","split","UNIT","substr","exp","parseInt","console","log","PI","retObj","parseString","ret","retString","retMsg","getProperty","newMag","err","message","uList","printUnits","writeFileSync","encoding","mode","flag","licenseText","pfxTabs","pfxArray","allPrefixesByCode","uTabs","uArray","allUnitsByDef","defsHash","dt","Date","spaces","rootNode","versionNum","version","revNum","revision","rootString","dateIdx","nextDolIdx","revDate","versionText"],"mappings":";;;;;;;AAAA;;;;;;;AAOA,IAAIA,MAAM,GAAGC,OAAO,CAAC,aAAD,CAAP,CAAuBD,MAApC;;AACA,IAAIE,YAAY,GAAGD,OAAO,CAAC,mBAAD,CAAP,CAA6BC,YAAhD;;AACA,IAAIC,IAAI,GAAGF,OAAO,CAAC,WAAD,CAAP,CAAqBE,IAAhC;;AACA,IAAIC,UAAU,GAAGH,OAAO,CAAC,iBAAD,CAAP,CAA2BG,UAA5C;;AACA,IAAIC,UAAU,GAAGJ,OAAO,CAAC,iBAAD,CAAP,CAA2BI,UAA5C;;AACA,IAAIC,SAAS,GAAGL,OAAO,CAAC,oBAAD,CAAP,CAA8BK,SAA9C;;AACA,IAAIC,QAAQ,GAAGN,OAAO,CAAC,UAAD,CAAtB;;AAEA,IAAIO,MAAM,GAAGP,OAAO,CAAC,QAA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ACvD,IAAP,EAAT;AACA,QAAIyD,UAAU,GAAGL,QAAQ,CAAClD,QAAT,CAAkB;AAACC,MAAAA,UAAU,EAAC;AAAZ,KAAlB,CAAjB;AACA,QAAIuD,OAAO,GAAGD,UAAU,CAAC/C,OAAX,CAAmB,QAAnB,CAAd;AACA+C,IAAAA,UAAU,GAAGA,UAAU,CAACrC,MAAX,CAAkBsC,OAAO,GAAG,CAA5B,CAAb;AACA,QAAIC,UAAU,GAAGF,UAAU,CAAC/C,OAAX,CAAmB,GAAnB,CAAjB;AACA,QAAIkD,OAAO,GAAGH,UAAU,CAACrC,MAAX,CAAkB,CAAlB,EAAqBuC,UAArB,EAAkC5D,OAAlC,CAA0C,GAA1C,EAA8C,EAA9C,CAAd;AACA6D,IAAAA,OAAO,GAAGA,OAAO,CAAC5D,IAAR,EAAV;AACA,QAAI6D,WAAW,GAAI,WAAUR,UAAW,cAAaE,MAAO,IAA1C,GACR,SAAQK,OAAQ,EAD1B;AAGAvH,IAAAA,EAAE,CAACgG,aAAH,CAAiB,gCAAjB,EACEwB,WADF,EACe;AAACvB,MAAAA,QAAQ,EAAE,MAAX;AAAmBC,MAAAA,IAAI,EAAE,KAAzB;AAAgCC,MAAAA,IAAI,EAAE;AAAtC,KADf;AAED,GAzd0B,CAydzB;;;AAzdyB,C,CA2d3B;;AAGF;;;;;;;;;;;;;;;AAWAhG,eAAe,CAACW,WAAhB,GAA8B,YAAU;AACtC,SAAO,IAAIX,eAAJ,EAAP;AACD,CAFD,C,CAIA;AACA;;;AACAA,eAAe,CAACW,WAAhB","sourcesContent":["/**\n * This class handles opening, reading and parsing the XML file of ucum\n * definitions (prefixes, base units, and unit atoms).\n *\n * @author Lee Mericle\n *\n */\nvar Prefix = require(\"./prefix.js\").Prefix;\nvar PrefixTables = require(\"./prefixTables.js\").PrefixTables;\nvar Unit = require(\"./unit.js\").Unit;\nvar UnitString = require(\"./unitString.js\").UnitString;\nvar UnitTables = require('./unitTables.js').UnitTables;\nvar packArray = require('./jsonArrayPack.js').packArray;\nvar jsonfile = require('jsonfile');\n\nvar xmldoc = require('xmldoc');\nvar fs = require('fs');\n\nvar essenceFile_ = '../data/ucum-essence.xml';\n\n/**\n * The full xml document\n * @type XmlDocument\n */\nvar xmlInput_ = null;\n\nexport class UcumXmlDocument {\n\n\n /**\n * Constructor. This reads the XML document (essenceFile_) into the\n * xmldoc object, which is an object used by the xmldoc class available\n * from GitHub - https://github.com/nfarina/xmldoc. The object provides\n * methods to read the file and access its contents.\n *\n */\n constructor() {\n // read the XML file and create an xmlDocument object from it.\n let data = fs.readFileSync(essenceFile_);\n xmlInput_ = new xmldoc.XmlDocument(data);\n\n // Array of unit codes in the ucum-essence.xml file that indicate a\n // mole based unit. The moleExp_ attribute for these units needs to be\n // set, but there doesn't seem to be an algorithmic way to find these.\n // Creation of unit objects after this file is processed will pick up\n // the moleExp_ value from the base mole unit, but the ones defined in\n // this file will not necessarily do that.\n this.moleCodes_ = ['mol', 'eq', 'osm', 'kat', 'U' ];\n\n // Make this a singleton. See UnitTables constructor for details.\n\n let holdThis = UcumXmlDocument.prototype;\n UcumXmlDocument = function () {\n throw (new Error('UcumXmlDocument is a Singleton. ' +\n 'Use UcumXmlDocument.getInstance() instead.'));\n };\n if (exports)\n exports.UcumXmlDocument = UcumXmlDocument;\n UcumXmlDocument.prototype = holdThis;\n\n let self = this ;\n UcumXmlDocument.getInstance = function(){return self} ;\n }\n\n\n /**\n * This method controls parsing of the XML into objects used by this\n * program. It uses separate methods to parse the prefixes, the\n * base units, and the units.\n *\n * @returns nothing\n */\n parseXml() {\n\n this.parsePrefixes(xmlInput_.childrenNamed(\"prefix\"));\n this.parseBaseUnits(xmlInput_.childrenNamed(\"base-unit\")) ;\n this.parseUnitStrings(xmlInput_.childrenNamed(\"unit\")) ;\n\n // Create or replace the json file of the prefix and unit definitions\n this.writeJsonFile();\n this.writeVersionText();\n\n }\n\n\n /**\n * Creates prefix objects from the xml prefix nodes passed in and gets\n * them added to the prefix tables.\n *\n * @params prefixes the array of prefix nodes from the xml file, in the\n * order in which the nodes are defined in that file.\n *\n * @returns nothing\n */\n parsePrefixes(prefixes) {\n\n\n let plen = prefixes.length ;\n\n for (let p = 0; p < plen; p++) {\n let curPfx = prefixes[p];\n let attrs = {} ;\n\n attrs[\"code_\"] = curPfx.attr.Code;\n attrs[\"ciCode_\"] = curPfx.attr.CODE;\n attrs[\"name_\"] = curPfx.childNamed('name').val;\n attrs[\"printSymbol_\"] = curPfx.childNamed('printSymbol').val;\n\n // Set the prefix value. If there is a <sup> element in the\n // value node, then this is a base 10 based prefix (10 to the x power).\n // Set the value to 10 taken to the indicated power.\n // Otherwise this is not 10 based and the value contains the\n // actual value for the prefix.\n let pValNode = curPfx.childNamed('value') ;\n attrs[\"value_\"] = null;\n attrs[\"exp_\"] = pValNode.childNamed('sup');\n if (attrs[\"exp_\"] != null) {\n attrs[\"exp_\"] = attrs[\"exp_\"].val;\n attrs[\"value_\"] = Math.pow(10, attrs[\"exp_\"]);\n }\n else {\n attrs[\"value_\"] = pValNode.val;\n attrs[\"exp_\"] = null;\n }\n\n // Make sure the prefix has not already been created. If it hasn't,\n // create the prefix object and then add it to the prefix tables.\n let ptab = PrefixTables.getInstance();\n if (ptab.isDefined(attrs[\"code_\"])) {\n throw(new Error('Prefix constructor called for prefix already ' +\n `defined; code = ${attrs[\"code_\"]}`));\n }\n else {\n let newPref = new Prefix(attrs);\n ptab.add(newPref);\n }\n }\n } // end parsePrefixes\n\n\n /**\n * Creates base unit objects from the xml nodes passed in and adds\n * them to the unit tables.\n *\n * @params unitNodes the array of base unit nodes from the xml file, in the\n * order in which the nodes are defined in that file. (Order is important\n * for all units).\n *\n * @returns nothing\n */\n parseBaseUnits(unitNodes) {\n let blen = unitNodes.length ;\n let utab = UnitTables.getInstance() ;\n for (let b = 0; b < blen; b++) {\n let curBUnit = unitNodes[b];\n let attrs = {} ;\n attrs['isBase_'] = true ;\n attrs['name_'] = curBUnit.childNamed('name').val ;\n attrs['csCode_'] = curBUnit.attr.Code ;\n attrs['ciCode_'] = curBUnit.attr.CODE ;\n attrs['property_'] = curBUnit.childNamed('property').val;\n attrs['variable_'] = curBUnit.attr.dim ;\n attrs['printSymbol_'] = curBUnit.childNamed('printSymbol').val;\n attrs['dim_'] = b ;\n attrs['source_'] = 'UCUM';\n let newUnit = new Unit(attrs);\n utab.addUnit(newUnit) ;\n }\n } // end parseBaseUnits\n\n\n /**\n * Creates non-base unit objects from the xml nodes passed in and adds\n * them to the unit tables.\n *\n * @params unitStrings the array of non-base unit nodes from the xml file, in the\n * order in which the nodes are defined in that file. (Order is important\n * for all units).\n *\n * @returns nothing\n */\n parseUnitStrings(unitStrings) {\n\n let utab = UnitTables.getInstance() ;\n let uStrParser = UnitString.getInstance();\n let stopNow = false ;\n let alen = unitStrings.length ;\n for (let a = 0; a < alen && !stopNow; a++) {\n let haveUnit = true;\n let curUA = unitStrings[a];\n let attrs = {};\n attrs['isBase_'] = false;\n attrs['source_'] = 'UCUM';\n attrs['name_'] = curUA.childNamed('name').val;\n attrs['csCode_'] = curUA.attr.Code;\n if (curUA.attr.CODE)\n attrs['ciCode_'] = curUA.attr.CODE;\n else\n attrs['ciCode_'] = curUA.attr.Code.toUpperCase();\n attrs['property_'] = curUA.childNamed('property').val;\n if (curUA.childNamed('printSymbol')) {\n let sym = curUA.childNamed('printSymbol') ;\n let symVal = sym.val;\n symVal = symVal.replace(/\\n/g, \"\");\n symVal = symVal.trim();\n let symI = sym.childNamed('i');\n if (symI)\n //symVal = '<i>' + symI.val + '</>';\n symVal = symI.toString({compressed:true});\n let sub = sym.childNamed('sub');\n let sup = sym.childNamed('sup');\n if (sub)\n symVal += sub.toString({compressed:true});\n if (sup)\n symVal += sup.toString({compressed:true});\n\n attrs['printSymbol_'] = symVal;\n }\n if (curUA.attr.isMetric === \"yes\")\n attrs['isMetric_'] = true ;\n else\n attrs['isMetric_'] = false ;\n if (curUA.attr.isArbitrary)\n attrs['isArbitrary_'] = true ;\n else\n attrs['isArbitrary_'] = false ;\n if (curUA.attr.class) {\n attrs['class_'] = curUA.attr.class;\n }\n let valNode = curUA.childNamed('value');\n if (this.moleCodes_.indexOf(curUA.attr.Code) !== -1)\n attrs['moleExp_'] = 1;\n else\n attrs['moleExp_'] = 0;\n\n\n // Process special units\n if (curUA.attr.isSpecial) {\n attrs['isSpecial_'] = curUA.attr.isSpecial === \"yes\";\n let funcNode = valNode.childNamed('function');\n attrs['cnv_'] = funcNode.attr.name;\n attrs['csUnitString_'] = funcNode.attr.Unit;\n if (attrs['csUnitString_'] === '1') {\n attrs['baseFactor_'] = 1 ;\n }\n else if (attrs['csCode_'] === '[pH]') {\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value) ;\n }\n else {\n let slashPos = attrs['csUnitString_'].indexOf('/');\n let ar = [];\n\n // unit string = K/9 or K/4 or m2/s4/Hz\n if (slashPos >= 0) {\n ar = attrs['csUnitString_'].split('/');\n }\n // unit string = K/9 or K/4\n if ((slashPos >= 0) && (ar.length === 2)) {\n attrs['csUnitString_'] = ar[0];\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value/ar[1]);\n }\n // unit string = 10*-5.Pa\n else if (attrs['csCode_'] === 'B[SPL]') {\n attrs['baseFactor_'] = Math.pow(10, -5) * 2 ;\n attrs['csUnitString_'] = \"Pa\" ;\n }\n // unit string = m1/s4/Hz, K, deg, V, mV, uV, nV, W, kW\n else {\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value);\n }\n } // end if the unit string is not 1\n } // end if the unit is special\n\n else {\n // what I'm calling the unit string is the string that defines the\n // unit based on other units, e.g., rad2 (radian squared) to define\n // a steradian unit. It's not necessarily a proper base unit, although\n // it ultimately builds on base units.\n attrs['csUnitString_'] = valNode.attr.Unit;\n attrs['ciUnitString_'] = valNode.attr.UNIT;\n\n // what I'm calling the factor here (string and number versions)\n // is the magnitude used in conjunction with the unit string to define\n // the new unit, e.g., 3 for a yard that is based in the definition\n // of feet.\n\n attrs['baseFactorStr_'] = valNode.attr.value;\n if (attrs['csCode_'] === '[pi]')\n attrs['baseFactor_'] = parseFloat(attrs['baseFactorStr_']);\n else if (valNode.childNamed('sup')) {\n attrs['baseFactor_'] = parseFloat(valNode.attr.value) ;\n }\n else {\n attrs['baseFactor_'] = parseFloat(valNode.val);\n }\n } // end if this is not a special unit\n\n // Arbitrary units are defined in the UCUM spec as \"not of any\n // specific dimension and are not commensurable with any other\n // unit\" (3.2.24). All arbitrary units in the units definition\n // XML file currently have a unit string of 1 and a base factor of 1\n // except the \"international unit\" with a code of [IU]. Its\n // unit string is the \"international unit\" with a code of [iU],\n // which is also an arbitrary unit - with a unit string of 1.\n // So I am assuming [IU] is just another code for the same unit.\n if (attrs['isArbitrary_'] === true) {\n attrs['magnitude_'] = 1;\n attrs['dim_'] = null;\n }\n\n // units with class = \"dimless\" don't have dimension arrays.\n // They're things like the number pi or the number 10 or percent.\n // Haven't figured out how to handle them yet.\n else if (attrs['class_'] === 'dimless' ||\n attrs['csCode_'] === 'mol') {\n attrs['dim_'] = null ;\n // figure the magnitude based on the unit string\n // if it's 1, the magnitude is the value specified for\n // the base factor, e.g., 3.141592653589793238462 ... for pi\n if (attrs['csUnitString_'] === '1') {\n attrs['magnitude_'] = attrs['baseFactor_'];\n }\n // else if the unit string starts with 10*, the magnitude is\n // 10 to the power specified following 10* e.g., unit = 10*-2\n // for the \"%\" unit. Except for the mole, which is that\n // multiplied by the base factor, which in this case (only,\n // I think) is not 1.\n else if (attrs['csUnitString_'].substr(0,3) == \"10*\") {\n let exp = parseInt(attrs['csUnitString_'].substr(3));\n attrs['magnitude_'] = Math.pow(10, exp) ;\n if (attrs['baseFactor_'] !== 1) {\n attrs['magnitude_'] *= attrs['baseFactor_'];\n }\n }\n // else I don't know what it is.\n else {\n attrs['defError_'] = true ;\n console.log('unexpected dimless unit definition, unit code ' +\n 'is ' + attrs['csCode_']) ;\n }\n } // end if this is a unit with class = dimless\n\n // Handle carat of gold alloys - which doesn't get a dimension\n //\n else if (attrs['csCode_'] === \"[car_Au]\") {\n attrs['magnitude_'] = 1/24 ;\n attrs['dim_'] = null ;\n }\n else {\n\n // Make sure there's a unit string to base the new unit on. There\n // should be, but I'm just checking here to make sure. And omit\n // ones with a unit string of 1. That won't do us any good.\n if (attrs['csUnitString_'] && attrs['csUnitString_'] !== '1' &&\n attrs['csUnitString_'] !== 1) {\n\n haveUnit = false;\n // Handle some special cases\n // 1. the Oersted unit, whose string is /[pi].A/m and whose\n // value is 250. Set the baseFactor to 250/[pi] and\n // the unit string to A/m\n if (attrs['csCode_'] === 'Oe') {\n attrs['baseFactor_'] = 250 / Math.PI;\n attrs['csUnitString_'] = \"A/m\"\n }\n // 2. Strings that start with '/'. Set the function to\n // the inverse function and trim the '/' off the front\n // of the string.\n else if (attrs['csUnitString_'][0] === '/') {\n attrs['cnv_'] = 'inv';\n attrs['csUnitString_'] = attrs['csUnitString_'].substr(1);\n }\n // 3. the Svedberg unit, whose string is 10*-13.s. Set the\n // base factor to 10*-13 and the unit string to s.\n else if (attrs['csCode_'] === '[S]') {\n attrs['baseFactor_'] = Math.pow(10, -13);\n attrs['csUnitString_'] = 's';\n }\n // 4. permeability of vaccuum - code [mu_0], unit given is\n // 4.[pi].10*-7.N/A2\n else if (attrs['csCode_'] === '[mu_0]') {\n attrs['baseFactor_'] = 4 * Math.PI * Math.pow(10, -7);\n attrs['csUnitString_'] = 'N/A2';\n }\n // The unit string parser will use the unit(s) named in the\n // string to create a new unit with the appropriate dimension\n // object and magnitude before it's multiplied by the one\n // specified in the input node.\n try {\n let retObj = uStrParser.parseString(attrs['csUnitString_'],\n 'validate', false);\n let ret = retObj[0];\n let retString = retObj[1];\n let retMsg = retObj[2];\n\n // Get the dimension object and magnitude (and adjust by\n // specified magnitude factor) from the unit created and\n // assign them to the attributes we'll use to create the\n // unit for this listing.\n if (ret) {\n attrs['dim_'] = ret.getProperty('dim_');\n let newMag = ret.getProperty('magnitude_');\n newMag *= attrs['baseFactor_'];\n attrs['magnitude_'] = newMag;\n haveUnit = true ;\n }\n // if there's no unit, report an error\n else {\n attrs['defError_'] = true;\n console.log(`unit definition error; code = ${attrs['csCode_']}; `+\n `msg = ${retMsg}`);\n attrs['dim_'] = null;\n attrs['magnitude_'] = null;\n }\n }\n catch(err) {\n console.log('error thrown from unit parsing code for unit name ' +\n attrs['name_'] + '\\n' + err.message);\n stopNow = true;\n }\n } // end if there is a unit string to parse\n } // end if this is not a dimless unit\n\n if (haveUnit) {\n // Now create the unit we want based on the attributes we've\n // accumulated from the xml input and from figuring the dimension\n // and magnitude. Add it to the unit tables\n let newUnit = new Unit(attrs);\n utab.addUnit(newUnit);\n\n // for now, create a list of the units created and save it to a file\n // for debugging. This is a temporary file.\n let uList = utab.printUnits();\n fs.writeFileSync('UnitsList.txt', uList,\n {encoding: 'utf8', mode: 0o666, flag: 'w'});\n } // end if have a parsed unit\n } // end for a => - to alen\n\n } // end parseUnitStrings\n\n\n /**\n * This writes out the ucumDefs data file, which contains all prefixes and\n * units (base units and others) read and parsed from the XML file.\n *\n * This creates or replace the file \"ucumDefs.json\" in the data directory.\n */\n writeJsonFile() {\n\n let licenseText = \"The following data (prefixes and units) was generated \" +\n \"by the UCUM LHC code from the UCUM data and selected \" +\n \"LOINC combinations of UCUM units. The license for \" +\n \"the UCUM LHC code (demo and library code as well as \" +\n \"the combined units) is located at \" +\n \"https://github.com/lhncbc/ucum-lhc/blob/LICENSE.md.\" ;\n let pfxTabs = PrefixTables.getInstance() ;\n let pfxArray = pfxTabs.allPrefixesByCode();\n let uTabs = UnitTables.getInstance();\n let uArray = uTabs.allUnitsByDef();\n\n let defsHash = { 'license' : licenseText,\n 'prefixes' : packArray(pfxArray),\n 'units' : packArray(uArray)};\n let dt = new Date();\n jsonfile.writeFileSync('../data/ucumDefs.json',\n defsHash,\n {spaces: 2, encoding: 'utf8', mode: 0o644, flag: 'w'});\n jsonfile.writeFileSync('../data/ucumDefs.min.json',\n defsHash,\n {encoding: 'utf8', mode: 0o644, flag: 'w'});\n } // end writeJsonFile\n\n /**\n * This writes out the ucumDefs data file, which contains all prefixes and\n * units (base units and others) read and parsed from the XML file.\n *\n * This creates the file in the data directory and appends the\n * current Date object value to \"ucumDefs\" so that this does not run\n * into problems with a previously existing file.\n */\n writeVersionText() {\n\n let rootNode = xmlInput_;\n let versionNum = rootNode.attr.version;\n let revNum = rootNode.attr.revision;\n revNum = revNum.replace('$Revision:', '');\n revNum = revNum.replace('$', '');\n revNum = revNum.trim();\n let rootString = rootNode.toString({compressed:true});\n let dateIdx = rootString.indexOf('$Date:');\n rootString = rootString.substr(dateIdx + 6);\n let nextDolIdx = rootString.indexOf('$');\n let revDate = rootString.substr(0, nextDolIdx ).replace('$','');\n revDate = revDate.trim();\n let versionText = `version ${versionNum}, revision ${revNum}, ` +\n `dated ${revDate}`;\n\n fs.writeFileSync('../data/ucumEssenceVersion.txt',\n versionText, {encoding: 'utf8', mode: 0o644, flag: 'w'});\n } // end writeVersionText\n\n} // end UcumXmlDocument\n\n\n/**\n * This function exists ONLY until the original UcumXmlDocument constructor\n * is called for the first time. It's defined here in case getInstance\n * is called before the constructor. This calls the constructor.\n *\n * The constructor redefines the getInstance function to return the\n * singleton UcumXmlDocument object. This is based on the UnitTables singleton\n * implementation; see more detail in the UnitTables constructor description.\n *\n * @return the singleton UcumXmlDocument object.\n */\nUcumXmlDocument.getInstance = function(){\n return new UcumXmlDocument();\n}\n\n// Perform the first request for the document object, to get the\n// getInstance method set.\nUcumXmlDocument.getInstance();"],"file":"ucumXmlDocument.js"}
1
+ {"version":3,"file":"ucumXmlDocument.js","names":["Prefix","require","PrefixTables","Unit","UnitString","UnitTables","packArray","jsonfile","xmldoc","fs","essenceFile_","xmlInput_","UcumXmlDocument","constructor","data","readFileSync","XmlDocument","moleCodes_","holdThis","prototype","exports","Error","self","getInstance","parseXml","parsePrefixes","childrenNamed","parseBaseUnits","parseUnitStrings","writeJsonFile","writeVersionText","prefixes","plen","length","p","curPfx","attrs","attr","Code","CODE","childNamed","val","pValNode","parseFloat","ptab","isDefined","newPref","add","unitNodes","blen","utab","b","curBUnit","dim","newUnit","addUnit","unitStrings","uStrParser","stopNow","alen","a","haveUnit","curUA","toUpperCase","sym","symVal","replace","trim","symI","toString","compressed","sub","sup","isMetric","isArbitrary","class","valNode","indexOf","isSpecial","funcNode","name","value","slashPos","ar","split","Math","pow","UNIT","substr","exp","parseInt","console","log","PI","retObj","parseString","ret","retString","retMsg","getProperty","newMag","err","message","uList","printUnits","writeFileSync","encoding","mode","flag","licenseText","pfxTabs","pfxArray","allPrefixesByCode","uTabs","uArray","allUnitsByDef","defsHash","dt","Date","spaces","rootNode","versionNum","version","revNum","revision","rootString","dateIdx","nextDolIdx","revDate","versionText"],"sources":["../source/ucumXmlDocument.js"],"sourcesContent":["/**\n * This class handles opening, reading and parsing the XML file of ucum\n * definitions (prefixes, base units, and unit atoms).\n *\n * @author Lee Mericle\n *\n */\nvar Prefix = require(\"./prefix.js\").Prefix;\nvar PrefixTables = require(\"./prefixTables.js\").PrefixTables;\nvar Unit = require(\"./unit.js\").Unit;\nvar UnitString = require(\"./unitString.js\").UnitString;\nvar UnitTables = require('./unitTables.js').UnitTables;\nvar packArray = require('./jsonArrayPack.js').packArray;\nvar jsonfile = require('jsonfile');\n\nvar xmldoc = require('xmldoc');\nvar fs = require('fs');\n\nvar essenceFile_ = '../data/ucum-essence.xml';\n\n/**\n * The full xml document\n * @type XmlDocument\n */\nvar xmlInput_ = null;\n\nexport class UcumXmlDocument {\n\n\n /**\n * Constructor. This reads the XML document (essenceFile_) into the\n * xmldoc object, which is an object used by the xmldoc class available\n * from GitHub - https://github.com/nfarina/xmldoc. The object provides\n * methods to read the file and access its contents.\n *\n */\n constructor() {\n // read the XML file and create an xmlDocument object from it.\n let data = fs.readFileSync(essenceFile_);\n xmlInput_ = new xmldoc.XmlDocument(data);\n\n // Array of unit codes in the ucum-essence.xml file that indicate a\n // mole based unit. The moleExp_ attribute for these units needs to be\n // set, but there doesn't seem to be an algorithmic way to find these.\n // Creation of unit objects after this file is processed will pick up\n // the moleExp_ value from the base mole unit, but the ones defined in\n // this file will not necessarily do that.\n this.moleCodes_ = ['mol', 'eq', 'osm', 'kat', 'U' ];\n\n // Make this a singleton. See UnitTables constructor for details.\n\n let holdThis = UcumXmlDocument.prototype;\n UcumXmlDocument = function () {\n throw (new Error('UcumXmlDocument is a Singleton. ' +\n 'Use UcumXmlDocument.getInstance() instead.'));\n };\n if (exports)\n exports.UcumXmlDocument = UcumXmlDocument;\n UcumXmlDocument.prototype = holdThis;\n\n let self = this ;\n UcumXmlDocument.getInstance = function(){return self} ;\n }\n\n\n /**\n * This method controls parsing of the XML into objects used by this\n * program. It uses separate methods to parse the prefixes, the\n * base units, and the units.\n *\n * @returns nothing\n */\n parseXml() {\n\n this.parsePrefixes(xmlInput_.childrenNamed(\"prefix\"));\n this.parseBaseUnits(xmlInput_.childrenNamed(\"base-unit\")) ;\n this.parseUnitStrings(xmlInput_.childrenNamed(\"unit\")) ;\n\n // Create or replace the json file of the prefix and unit definitions\n this.writeJsonFile();\n this.writeVersionText();\n\n }\n\n\n /**\n * Creates prefix objects from the xml prefix nodes passed in and gets\n * them added to the prefix tables.\n *\n * @params prefixes the array of prefix nodes from the xml file, in the\n * order in which the nodes are defined in that file.\n *\n * @returns nothing\n */\n parsePrefixes(prefixes) {\n\n\n let plen = prefixes.length ;\n\n for (let p = 0; p < plen; p++) {\n let curPfx = prefixes[p];\n let attrs = {} ;\n\n attrs[\"code_\"] = curPfx.attr.Code;\n attrs[\"ciCode_\"] = curPfx.attr.CODE;\n attrs[\"name_\"] = curPfx.childNamed('name').val;\n attrs[\"printSymbol_\"] = curPfx.childNamed('printSymbol').val;\n\n // Set the prefix value. If there is a <sup> element in the\n // value node, then this is a base 10 based prefix (10 to the x power).\n // Set the value to 10 taken to the indicated power.\n // Otherwise this is not 10 based and the value contains the\n // actual value for the prefix.\n let pValNode = curPfx.childNamed('value') ;\n attrs[\"value_\"] = null;\n attrs[\"exp_\"] = pValNode.childNamed('sup');\n if (attrs[\"exp_\"] != null) {\n attrs[\"exp_\"] = attrs[\"exp_\"].val;\n // Use parseFloat('1eSOMETHING') instead of Math.pow() to avoid\n // small number changes like 1.0000000000000001e-21. See LF-2830.\n // attrs[\"value_\"] = Math.pow(10, attrs[\"exp_\"]);\n attrs[\"value_\"] = parseFloat(`1e${attrs[\"exp_\"]}`);\n }\n else {\n attrs[\"value_\"] = pValNode.val;\n attrs[\"exp_\"] = null;\n }\n\n // Make sure the prefix has not already been created. If it hasn't,\n // create the prefix object and then add it to the prefix tables.\n let ptab = PrefixTables.getInstance();\n if (ptab.isDefined(attrs[\"code_\"])) {\n throw(new Error('Prefix constructor called for prefix already ' +\n `defined; code = ${attrs[\"code_\"]}`));\n }\n else {\n let newPref = new Prefix(attrs);\n ptab.add(newPref);\n }\n }\n } // end parsePrefixes\n\n\n /**\n * Creates base unit objects from the xml nodes passed in and adds\n * them to the unit tables.\n *\n * @params unitNodes the array of base unit nodes from the xml file, in the\n * order in which the nodes are defined in that file. (Order is important\n * for all units).\n *\n * @returns nothing\n */\n parseBaseUnits(unitNodes) {\n let blen = unitNodes.length ;\n let utab = UnitTables.getInstance() ;\n for (let b = 0; b < blen; b++) {\n let curBUnit = unitNodes[b];\n let attrs = {} ;\n attrs['isBase_'] = true ;\n attrs['name_'] = curBUnit.childNamed('name').val ;\n attrs['csCode_'] = curBUnit.attr.Code ;\n attrs['ciCode_'] = curBUnit.attr.CODE ;\n attrs['property_'] = curBUnit.childNamed('property').val;\n attrs['variable_'] = curBUnit.attr.dim ;\n attrs['printSymbol_'] = curBUnit.childNamed('printSymbol').val;\n attrs['dim_'] = b ;\n attrs['source_'] = 'UCUM';\n let newUnit = new Unit(attrs);\n utab.addUnit(newUnit) ;\n }\n } // end parseBaseUnits\n\n\n /**\n * Creates non-base unit objects from the xml nodes passed in and adds\n * them to the unit tables.\n *\n * @params unitStrings the array of non-base unit nodes from the xml file, in the\n * order in which the nodes are defined in that file. (Order is important\n * for all units).\n *\n * @returns nothing\n */\n parseUnitStrings(unitStrings) {\n\n let utab = UnitTables.getInstance() ;\n let uStrParser = UnitString.getInstance();\n let stopNow = false ;\n let alen = unitStrings.length ;\n for (let a = 0; a < alen && !stopNow; a++) {\n let haveUnit = true;\n let curUA = unitStrings[a];\n let attrs = {};\n attrs['isBase_'] = false;\n attrs['source_'] = 'UCUM';\n attrs['name_'] = curUA.childNamed('name').val;\n attrs['csCode_'] = curUA.attr.Code;\n if (curUA.attr.CODE)\n attrs['ciCode_'] = curUA.attr.CODE;\n else\n attrs['ciCode_'] = curUA.attr.Code.toUpperCase();\n attrs['property_'] = curUA.childNamed('property').val;\n if (curUA.childNamed('printSymbol')) {\n let sym = curUA.childNamed('printSymbol') ;\n let symVal = sym.val;\n symVal = symVal.replace(/\\n/g, \"\");\n symVal = symVal.trim();\n let symI = sym.childNamed('i');\n if (symI)\n //symVal = '<i>' + symI.val + '</>';\n symVal = symI.toString({compressed:true});\n let sub = sym.childNamed('sub');\n let sup = sym.childNamed('sup');\n if (sub)\n symVal += sub.toString({compressed:true});\n if (sup)\n symVal += sup.toString({compressed:true});\n\n attrs['printSymbol_'] = symVal;\n }\n if (curUA.attr.isMetric === \"yes\")\n attrs['isMetric_'] = true ;\n else\n attrs['isMetric_'] = false ;\n if (curUA.attr.isArbitrary)\n attrs['isArbitrary_'] = true ;\n else\n attrs['isArbitrary_'] = false ;\n if (curUA.attr.class) {\n attrs['class_'] = curUA.attr.class;\n }\n let valNode = curUA.childNamed('value');\n if (this.moleCodes_.indexOf(curUA.attr.Code) !== -1)\n attrs['moleExp_'] = 1;\n else\n attrs['moleExp_'] = 0;\n\n\n // Process special units\n if (curUA.attr.isSpecial) {\n attrs['isSpecial_'] = curUA.attr.isSpecial === \"yes\";\n let funcNode = valNode.childNamed('function');\n attrs['cnv_'] = funcNode.attr.name;\n attrs['csUnitString_'] = funcNode.attr.Unit;\n if (attrs['csUnitString_'] === '1') {\n attrs['baseFactor_'] = 1 ;\n }\n else if (attrs['csCode_'] === '[pH]') {\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value) ;\n }\n else {\n let slashPos = attrs['csUnitString_'].indexOf('/');\n let ar = [];\n\n // unit string = K/9 or K/4 or m2/s4/Hz\n if (slashPos >= 0) {\n ar = attrs['csUnitString_'].split('/');\n }\n // unit string = K/9 or K/4\n if ((slashPos >= 0) && (ar.length === 2)) {\n attrs['csUnitString_'] = ar[0];\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value/ar[1]);\n }\n // unit string = 10*-5.Pa\n else if (attrs['csCode_'] === 'B[SPL]') {\n attrs['baseFactor_'] = Math.pow(10, -5) * 2 ;\n attrs['csUnitString_'] = \"Pa\" ;\n }\n // unit string = m1/s4/Hz, K, deg, V, mV, uV, nV, W, kW\n else {\n attrs['baseFactor_'] = parseFloat(funcNode.attr.value);\n }\n } // end if the unit string is not 1\n } // end if the unit is special\n\n else {\n // what I'm calling the unit string is the string that defines the\n // unit based on other units, e.g., rad2 (radian squared) to define\n // a steradian unit. It's not necessarily a proper base unit, although\n // it ultimately builds on base units.\n attrs['csUnitString_'] = valNode.attr.Unit;\n attrs['ciUnitString_'] = valNode.attr.UNIT;\n\n // what I'm calling the factor here (string and number versions)\n // is the magnitude used in conjunction with the unit string to define\n // the new unit, e.g., 3 for a yard that is based in the definition\n // of feet.\n\n attrs['baseFactorStr_'] = valNode.attr.value;\n if (attrs['csCode_'] === '[pi]')\n attrs['baseFactor_'] = parseFloat(attrs['baseFactorStr_']);\n else if (valNode.childNamed('sup')) {\n attrs['baseFactor_'] = parseFloat(valNode.attr.value) ;\n }\n else {\n attrs['baseFactor_'] = parseFloat(valNode.val);\n }\n } // end if this is not a special unit\n\n // Arbitrary units are defined in the UCUM spec as \"not of any\n // specific dimension and are not commensurable with any other\n // unit\" (3.2.24). All arbitrary units in the units definition\n // XML file currently have a unit string of 1 and a base factor of 1\n // except the \"international unit\" with a code of [IU]. Its\n // unit string is the \"international unit\" with a code of [iU],\n // which is also an arbitrary unit - with a unit string of 1.\n // So I am assuming [IU] is just another code for the same unit.\n if (attrs['isArbitrary_'] === true) {\n attrs['magnitude_'] = 1;\n attrs['dim_'] = null;\n }\n\n // units with class = \"dimless\" don't have dimension arrays.\n // They're things like the number pi or the number 10 or percent.\n // Haven't figured out how to handle them yet.\n else if (attrs['class_'] === 'dimless' ||\n attrs['csCode_'] === 'mol') {\n attrs['dim_'] = null ;\n // figure the magnitude based on the unit string\n // if it's 1, the magnitude is the value specified for\n // the base factor, e.g., 3.141592653589793238462 ... for pi\n if (attrs['csUnitString_'] === '1') {\n attrs['magnitude_'] = attrs['baseFactor_'];\n }\n // else if the unit string starts with 10*, the magnitude is\n // 10 to the power specified following 10* e.g., unit = 10*-2\n // for the \"%\" unit. Except for the mole, which is that\n // multiplied by the base factor, which in this case (only,\n // I think) is not 1.\n else if (attrs['csUnitString_'].substr(0,3) == \"10*\") {\n let exp = parseInt(attrs['csUnitString_'].substr(3));\n attrs['magnitude_'] = Math.pow(10, exp) ;\n if (attrs['baseFactor_'] !== 1) {\n attrs['magnitude_'] *= attrs['baseFactor_'];\n }\n }\n // else I don't know what it is.\n else {\n attrs['defError_'] = true ;\n console.log('unexpected dimless unit definition, unit code ' +\n 'is ' + attrs['csCode_']) ;\n }\n } // end if this is a unit with class = dimless\n\n // Handle carat of gold alloys - which doesn't get a dimension\n //\n else if (attrs['csCode_'] === \"[car_Au]\") {\n attrs['magnitude_'] = 1/24 ;\n attrs['dim_'] = null ;\n }\n else {\n\n // Make sure there's a unit string to base the new unit on. There\n // should be, but I'm just checking here to make sure. And omit\n // ones with a unit string of 1. That won't do us any good.\n if (attrs['csUnitString_'] && attrs['csUnitString_'] !== '1' &&\n attrs['csUnitString_'] !== 1) {\n\n haveUnit = false;\n // Handle some special cases\n // 1. the Oersted unit, whose string is /[pi].A/m and whose\n // value is 250. Set the baseFactor to 250/[pi] and\n // the unit string to A/m\n if (attrs['csCode_'] === 'Oe') {\n attrs['baseFactor_'] = 250 / Math.PI;\n attrs['csUnitString_'] = \"A/m\"\n }\n // 2. Strings that start with '/'. Set the function to\n // the inverse function and trim the '/' off the front\n // of the string.\n else if (attrs['csUnitString_'][0] === '/') {\n attrs['cnv_'] = 'inv';\n attrs['csUnitString_'] = attrs['csUnitString_'].substr(1);\n }\n // 3. the Svedberg unit, whose string is 10*-13.s. Set the\n // base factor to 10*-13 and the unit string to s.\n else if (attrs['csCode_'] === '[S]') {\n attrs['baseFactor_'] = Math.pow(10, -13);\n attrs['csUnitString_'] = 's';\n }\n // 4. permeability of vaccuum - code [mu_0], unit given is\n // 4.[pi].10*-7.N/A2\n else if (attrs['csCode_'] === '[mu_0]') {\n attrs['baseFactor_'] = 4 * Math.PI * Math.pow(10, -7);\n attrs['csUnitString_'] = 'N/A2';\n }\n // The unit string parser will use the unit(s) named in the\n // string to create a new unit with the appropriate dimension\n // object and magnitude before it's multiplied by the one\n // specified in the input node.\n try {\n let retObj = uStrParser.parseString(attrs['csUnitString_'],\n 'validate', false);\n let ret = retObj[0];\n let retString = retObj[1];\n let retMsg = retObj[2];\n\n // Get the dimension object and magnitude (and adjust by\n // specified magnitude factor) from the unit created and\n // assign them to the attributes we'll use to create the\n // unit for this listing.\n if (ret) {\n attrs['dim_'] = ret.getProperty('dim_');\n let newMag = ret.getProperty('magnitude_');\n newMag *= attrs['baseFactor_'];\n attrs['magnitude_'] = newMag;\n haveUnit = true ;\n }\n // if there's no unit, report an error\n else {\n attrs['defError_'] = true;\n console.log(`unit definition error; code = ${attrs['csCode_']}; `+\n `msg = ${retMsg}`);\n attrs['dim_'] = null;\n attrs['magnitude_'] = null;\n }\n }\n catch(err) {\n console.log('error thrown from unit parsing code for unit name ' +\n attrs['name_'] + '\\n' + err.message);\n stopNow = true;\n }\n } // end if there is a unit string to parse\n } // end if this is not a dimless unit\n\n if (haveUnit) {\n // Now create the unit we want based on the attributes we've\n // accumulated from the xml input and from figuring the dimension\n // and magnitude. Add it to the unit tables\n let newUnit = new Unit(attrs);\n utab.addUnit(newUnit);\n\n // for now, create a list of the units created and save it to a file\n // for debugging. This is a temporary file.\n let uList = utab.printUnits();\n fs.writeFileSync('UnitsList.txt', uList,\n {encoding: 'utf8', mode: 0o666, flag: 'w'});\n } // end if have a parsed unit\n } // end for a => - to alen\n\n } // end parseUnitStrings\n\n\n /**\n * This writes out the ucumDefs data file, which contains all prefixes and\n * units (base units and others) read and parsed from the XML file.\n *\n * This creates or replace the file \"ucumDefs.json\" in the data directory.\n */\n writeJsonFile() {\n\n let licenseText = \"The following data (prefixes and units) was generated \" +\n \"by the UCUM LHC code from the UCUM data and selected \" +\n \"LOINC combinations of UCUM units. The license for \" +\n \"the UCUM LHC code (demo and library code as well as \" +\n \"the combined units) is located at \" +\n \"https://github.com/lhncbc/ucum-lhc/blob/LICENSE.md.\" ;\n let pfxTabs = PrefixTables.getInstance() ;\n let pfxArray = pfxTabs.allPrefixesByCode();\n let uTabs = UnitTables.getInstance();\n let uArray = uTabs.allUnitsByDef();\n\n let defsHash = { 'license' : licenseText,\n 'prefixes' : packArray(pfxArray),\n 'units' : packArray(uArray)};\n let dt = new Date();\n jsonfile.writeFileSync('../data/ucumDefs.json',\n defsHash,\n {spaces: 2, encoding: 'utf8', mode: 0o644, flag: 'w'});\n jsonfile.writeFileSync('../data/ucumDefs.min.json',\n defsHash,\n {encoding: 'utf8', mode: 0o644, flag: 'w'});\n } // end writeJsonFile\n\n /**\n * This writes out the ucumDefs data file, which contains all prefixes and\n * units (base units and others) read and parsed from the XML file.\n *\n * This creates the file in the data directory and appends the\n * current Date object value to \"ucumDefs\" so that this does not run\n * into problems with a previously existing file.\n */\n writeVersionText() {\n\n let rootNode = xmlInput_;\n let versionNum = rootNode.attr.version;\n let revNum = rootNode.attr.revision;\n revNum = revNum.replace('$Revision:', '');\n revNum = revNum.replace('$', '');\n revNum = revNum.trim();\n let rootString = rootNode.toString({compressed:true});\n let dateIdx = rootString.indexOf('$Date:');\n rootString = rootString.substr(dateIdx + 6);\n let nextDolIdx = rootString.indexOf('$');\n let revDate = rootString.substr(0, nextDolIdx ).replace('$','');\n revDate = revDate.trim();\n let versionText = `version ${versionNum}, revision ${revNum}, ` +\n `dated ${revDate}`;\n\n fs.writeFileSync('../data/ucumEssenceVersion.txt',\n versionText, {encoding: 'utf8', mode: 0o644, flag: 'w'});\n } // end writeVersionText\n\n} // end UcumXmlDocument\n\n\n/**\n * This function exists ONLY until the original UcumXmlDocument constructor\n * is called for the first time. It's defined here in case getInstance\n * is called before the constructor. This calls the constructor.\n *\n * The constructor redefines the getInstance function to return the\n * singleton UcumXmlDocument object. This is based on the UnitTables singleton\n * implementation; see more detail in the UnitTables constructor description.\n *\n * @return the singleton UcumXmlDocument object.\n */\nUcumXmlDocument.getInstance = function(){\n return new UcumXmlDocument();\n}\n\n// Perform the first request for the document object, to get the\n// getInstance method set.\nUcumXmlDocument.getInstance();\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAIA,MAAM,GAAGC,OAAO,CAAC,aAAa,CAAC,CAACD,MAAM;AAC1C,IAAIE,YAAY,GAAGD,OAAO,CAAC,mBAAmB,CAAC,CAACC,YAAY;AAC5D,IAAIC,IAAI,GAAGF,OAAO,CAAC,WAAW,CAAC,CAACE,IAAI;AACpC,IAAIC,UAAU,GAAGH,OAAO,CAAC,iBAAiB,CAAC,CAACG,UAAU;AACtD,IAAIC,UAAU,GAAGJ,OAAO,CAAC,iBAAiB,CAAC,CAACI,UAAU;AACtD,IAAIC,SAAS,GAAGL,OAAO,CAAC,oBAAoB,CAAC,CAACK,SAAS;AACvD,IAAIC,QAAQ,GAAGN,OAAO,CAAC,UAAU,CAAC;AAElC,IAAIO,MAAM,GAAGP,OAAO,CAAC,QAAQ,CAAC;AAC9B,IAAIQ,EAAE,GAAGR,OAAO,CAAC,IAAI,CAAC;AAEtB,IAAIS,YAAY,GAAG,0BAA0B;;AAE7C;AACA;AACA;AACA;AACA,IAAIC,SAAS,GAAG,IAAI;AAEb,MAAM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