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EAAQ,GAAK,CAC/B,CASA,SAAS,MAAM,EAAI,GAClB,IAAI,EAAQ,EAAG,QAAQ,KACvB,OAAI,EAAQ,EACJ,CAAC,EAAU,GAEZ,CAAC,EAAG,OAAO,EAAG,GAAQ,EAAG,OAAO,EAAQ,GAChD,CAEA,OAAO,QAAU,SAAU,EAAM,EAAU,EAAM,GAEhD,OAAI,GAAQ,GAAY,EAChB,iBAAiB,OAAO,CAC9B,QAAS,EACT,SAAU,EACV,KAAM,EACN,GAAI,IAEoB,iBAAR,EACV,iBAAiB,OAAO,QACZ,IAAT,EACH,iBAAiB,OAAO,QADzB,CAIR,EACA,OAAO,QAAQ,iBAAmB,iBAClC,OAAO,QAAQ,SAAW,SAC1B,OAAO,QAAQ,OAAS,OACxB,OAAO,QAAQ,MAAQ","file":"/npm/@compassdigital/id@3.8.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@compassdigital/id@3.8.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar Hashids = require('hashids/cjs');\nvar hashids = new Hashids(\"Compass Digital\");\n\nvar dictionary = {\n\t\"l\": \"location\",\n\t\"m\": \"menu\",\n\t\"i\": \"item\",\n\t\"c\": \"shoppingcart\",\n\t\"o\": \"order\"\n};\n\nvar dictionary_flip = {};\nObject.keys(dictionary).forEach(function (short) {\n\tdictionary_flip[dictionary[short]] = short;\n});\n\nvar CompassDigitalId = function () {\n\tfunction CompassDigitalId() {\n\t\t_classCallCheck(this, CompassDigitalId);\n\t}\n\n\t_createClass(CompassDigitalId, null, [{\n\t\tkey: \"word_shortform\",\n\t\tvalue: function word_shortform(longform) {\n\t\t\tif (!longform || typeof longform != \"string\") return;\n\n\t\t\treturn dictionary_flip[longform];\n\t\t}\n\t}, {\n\t\tkey: \"word_longform\",\n\t\tvalue: function word_longform(shortform) {\n\t\t\tif (!shortform || typeof shortform != \"string\") return;\n\n\t\t\treturn dictionary[shortform.toLowerCase()];\n\t\t}\n\t}, {\n\t\tkey: \"encode\",\n\t\tvalue: function encode(config) {\n\t\t\tif (!config || !(config.service && config.provider && config.type)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (config.id) {\n\t\t\t\tvar parsed = CompassDigitalId.decode(config.id);\n\n\t\t\t\t// ID is already a CDL ID with the same config\n\t\t\t\tif (parsed && parsed.service == config.service && parsed.type == config.type) {\n\t\t\t\t\treturn config.id;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar parts = [];\n\t\t\t[\"service\", \"provider\", \"type\"].forEach(function (key) {\n\t\t\t\tvar val = config[key].toString().toLowerCase();\n\n\t\t\t\tif (val.indexOf(\".\") >= 0) {\n\t\t\t\t\tthrow new Error(key + \" cannot contain a period\");\n\t\t\t\t}\n\n\t\t\t\tvar short_form = CompassDigitalId.word_shortform(val);\n\n\t\t\t\tparts.push(short_form ? short_form.toUpperCase() : val);\n\t\t\t});\n\t\t\tif (config.id) parts.push(config.id.toString());\n\n\t\t\tvar joined = parts.join(\".\");\n\n\t\t\tvar hex_joined = Buffer.from(joined).toString(\"hex\");\n\t\t\tvar hashid = hashids.encodeHex(hex_joined);\n\n\t\t\treturn hashid;\n\t\t}\n\t}, {\n\t\tkey: \"valid\",\n\t\tvalue: function valid(id) {\n\t\t\ttry {\n\t\t\t\tif (!id) return false;\n\t\t\t\tif (!id.length || id.length < 13) return false; // IDs never are smaller than 13 chars.\n\t\t\t\tif (Number.isFinite(Number(id))) return false;\n\t\t\t\tvar regexp = /^[0-9a-f]{8}[0-9a-f]{4}[0-5][0-9a-f]{3}[089ab][0-9a-f]{3}[0-9a-f]{12}$/i; //Checks if id is a non-hyphens uuid v1-v5\n\t\t\t\tif (id.length === 32 && id.match(regexp)) return false;\n\t\t\t\tvar hex = hashids.decodeHex(id);\n\t\t\t\tif (!hex || Array.isArray(hex)) return false;\n\t\t\t\treturn true;\n\t\t\t} catch (err) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}, {\n\t\tkey: \"decode\",\n\t\tvalue: function decode(id) {\n\t\t\ttry {\n\t\t\t\tvar hex = hashids.decodeHex(id);\n\t\t\t\tif (Array.isArray(hex)) return;\n\t\t\t\tvar joined = Buffer.from(hex, \"hex\").toString();\n\n\t\t\t\tvar parsed = joined.split(\".\");\n\n\t\t\t\tif (parsed.length >= 3) {\n\t\t\t\t\tvar id = parsed[3] ? joined.substring(parsed[0].length + parsed[1].length + parsed[2].length + 3) : \"\";\n\n\t\t\t\t\tvar json = {\n\t\t\t\t\t\tservice: parsed[0],\n\t\t\t\t\t\tprovider: parsed[1],\n\t\t\t\t\t\ttype: parsed[2],\n\t\t\t\t\t\tid: id\n\t\t\t\t\t};\n\n\t\t\t\t\t[\"service\", \"provider\", \"type\"].forEach(function (key) {\n\t\t\t\t\t\tvar val = json[key];\n\t\t\t\t\t\tif (val.length === 1 && val.toString().toUpperCase() == val) {\n\t\t\t\t\t\t\tval = CompassDigitalId.word_longform(val);\n\t\t\t\t\t\t\tif (val) json[key] = val;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\treturn json;\n\t\t\t\t} else {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}]);\n\n\treturn CompassDigitalId;\n}();\n\n/**\n * Check if the provided id contains one or more properties.\n *\n * Ex: check if it's a device id\n *\n * \tID.contains(id, { service: \"kds\", provider: \"cdl\", type: \"device\" })\n *\n * @param {EncodedID|DecodedID} id\n * @param {Partial<DecodedID>} constraints\n * @return {boolean}\n */\n\n\nfunction contains(id, constraints) {\n\tif (typeof id == \"string\") {\n\t\tid = CompassDigitalId.decode(id);\n\t}\n\tif (!id || !constraints) {\n\t\treturn false;\n\t}\n\tif (typeof constraints.prefix !== \"undefined\") {\n\t\tvar _split = split(String(id.id)),\n\t\t    _split2 = _slicedToArray(_split, 1),\n\t\t    prefix = _split2[0];\n\n\t\tif (prefix !== constraints.prefix) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn (typeof constraints.service === \"undefined\" || constraints.service === id.service) && (typeof constraints.provider === \"undefined\" || constraints.provider === id.provider) && (typeof constraints.type === \"undefined\" || constraints.type === id.type) && (typeof constraints.id === \"undefined\" || String(id.id) === String(constraints.id));\n}\n\n/**\n * If id is an encoded cdl id, decode it and return the contained id property.\n * Otherwise return the original value.\n *\n * @param {string|undefined} id\n * @param {Constraints|undefined} constraints\n * @return {string|undefined}\n */\nfunction unwrap(id, constraints) {\n\tvar decoded = CompassDigitalId.decode(id);\n\tif (constraints && !contains(decoded, constraints)) {\n\t\treturn id;\n\t}\n\treturn decoded ? decoded.id : id;\n}\n\n/**\n * Split the prefix from the inner id.\n * If there's no prefix, return the fallback prefix.\n * If no fallback is provided, the prefix will be undefined.\n *\n * Example: tacit/be6eeceeb2c811edafa10242ac120002\n */\nfunction split(id, fallback) {\n\tvar index = id.indexOf(\"/\");\n\tif (index < 0) {\n\t\treturn [fallback, id];\n\t}\n\treturn [id.substr(0, index), id.substr(index + 1)];\n}\n\nmodule.exports = function (data, provider, type, id) {\n\n\tif (data && provider && type) {\n\t\treturn CompassDigitalId.encode({\n\t\t\tservice: data,\n\t\t\tprovider: provider,\n\t\t\ttype: type,\n\t\t\tid: id\n\t\t});\n\t} else if (typeof data == \"string\") {\n\t\treturn CompassDigitalId.decode(data);\n\t} else if (data !== undefined) {\n\t\treturn CompassDigitalId.encode(data);\n\t}\n\treturn undefined;\n};\nmodule.exports.CompassDigitalId = CompassDigitalId;\nmodule.exports.contains = contains;\nmodule.exports.unwrap = unwrap;\nmodule.exports.split = split;"]}