UNPKG

jobsys-explore

Version:

Enhanced component based on vant

1 lines 322 kB
{"version":3,"file":"hooks-D4gUJQDD.cjs","names":["option","options","value","labels","values","isBytes","abytes","aexists","clean","hexes","bytesToHex","utf8ToBytes","bytesToUtf8","toBytes","concatBytes","Hash","randomBytes","_0n","_1n","abool","isBytes_","hexToNumber","bytesToHex_","hexToBytes_","numberToVarBytesBE","equalBytes","copyBytes","asciiToBytes","bitGet","bitSet","concatBytes_","isHash","notImplemented","abytes","u.abytes","anumber","u.anumber","bytesToHex","u.bytesToHex","u.bytesToUtf8","u.concatBytes","hexToBytes","u.hexToBytes","isBytes","u.isBytes","randomBytes","u.randomBytes","utf8ToBytes","u.utf8ToBytes","u.abool","numberToHexUnpadded","u.numberToHexUnpadded","u.hexToNumber","bytesToNumberBE","u.bytesToNumberBE","bytesToNumberLE","u.bytesToNumberLE","numberToBytesBE","u.numberToBytesBE","numberToBytesLE","u.numberToBytesLE","u.numberToVarBytesBE","ensureBytes","u.ensureBytes","u.equalBytes","copyBytes","u.copyBytes","u.asciiToBytes","inRange","u.inRange","aInRange","u.aInRange","bitLen","u.bitLen","u.bitGet","u.bitSet","bitMask","u.bitMask","createHmacDrbg","u.createHmacDrbg","u.notImplemented","memoized","u.memoized","validateObject","u.validateObject","u.isHash","HMAC","Hash","toBytes","hmac","_0n","_1n","_2n","_3n","_4n","field","_0n","_1n","window","field","wbits","concatBytes","abytes","endo","bytesToHex","randomBytesWeb","getSharedSecret","randomBytes","hmac","nobleHmac","r","s","isBytes","toBytes","toBytes","utils.hexToNumber","createView","setBigUint64","utils2.numberToBytesBE","utils2.bytesToHex","utils2.hexToNumber","utils3.concatBytes","utils4.hexToNumber","utils4.numberToHexUnpadded","utils4.concatBytes","utils5.concatBytes","utils5.hexToNumber","utils5.numberToHexUnpadded","utils5.bytesToHex","createView2","sm2","sm3","sm4"],"sources":["../hooks/network.js","../hooks/utils.js","../hooks/form.js","../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/crypto.js","../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js","../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/utils.js","../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/utils.js","../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/hmac.js","../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/modular.js","../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/curve.js","../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/weierstrass.js","../node_modules/.pnpm/@noble+ciphers@1.3.0/node_modules/@noble/ciphers/esm/utils.js","../node_modules/.pnpm/@noble+ciphers@1.3.0/node_modules/@noble/ciphers/esm/_polyval.js","../node_modules/.pnpm/sm-crypto-v2@1.15.1/node_modules/sm-crypto-v2/dist/index.mjs","../hooks/cipher.js","../hooks/datetime.js","../hooks/regex.js"],"sourcesContent":["import axios from \"axios\"\nimport { allowMultipleToast, closeToast, showLoadingToast } from \"vant\"\nimport { isObject, isString } from \"lodash-es\"\n\n/**\n * 请求返回状态码\n * @type {{STATE_CODE_NOT_FOUND: string, STATE_CODE_SUCCESS: string, STATE_CODE_FAIL: string, STATE_CODE_INFO_NOT_COMPLETE: string, STATE_CODE_NOT_ALLOWED: string}}\n */\nexport const STATUS = {\n\tSTATE_CODE_SUCCESS: \"SUCCESS\", // 成功\n\tSTATE_CODE_FAIL: \"FAIL\", // 失败\n\tSTATE_CODE_NOT_FOUND: \"NOT_FOUND\", // 找不到资源\n\tSTATE_CODE_INFO_NOT_COMPLETE: \"INCOMPLETE\", // 信息不完整\n\tSTATE_CODE_NOT_ALLOWED: \"NOT_ALLOWED\", //没有权限\n}\n\n/**\n * STATUS 适配器,内部使用\n * @param status\n * @private\n */\nexport function _configStatus(status) {\n\tObject.keys(status).forEach((key) => {\n\t\tSTATUS[key] = status[key]\n\t})\n}\n\n/**\n * 通用 AJAX 请求\n * @param {Object} [fetcher] - 用于存储请求状态的对象\n * @returns {{post(*=, *=, *=): Promise<unknown>, get(*=, *=): Promise<unknown>}}\n */\nexport function useFetch(fetcher) {\n\t// 记录当前 Fetcher 是否处于 Loading 状态\n\tlet globalLoading = null\n\n\tif (!fetcher) {\n\t\tfetcher = {}\n\t}\n\tfetcher.loading = true\n\n\treturn {\n\t\t/**\n\t\t * get请求\n\t\t * @param url\n\t\t * @param {Object} [config] - axios config\n\t\t * @returns {Promise<unknown>}\n\t\t */\n\t\tget(url, config) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\taxios\n\t\t\t\t\t.get(url, config)\n\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\tresolve(res)\n\t\t\t\t\t})\n\t\t\t\t\t.catch((err) => {\n\t\t\t\t\t\treject(err)\n\t\t\t\t\t})\n\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\tif (globalLoading) {\n\t\t\t\t\t\t\tallowMultipleToast(false)\n\t\t\t\t\t\t\tglobalLoading.close()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfetcher.loading = false\n\t\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\t/**\n\t\t * post请求\n\t\t * @param {string} url\n\t\t * @param {Object} data\n\t\t * @param {Object} [config] - axios config\n\t\t * @returns {Promise<unknown>}\n\t\t */\n\t\tpost(url, data, config) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\taxios\n\t\t\t\t\t.post(url, data, config)\n\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\tresolve(res)\n\t\t\t\t\t})\n\t\t\t\t\t.catch((err) => {\n\t\t\t\t\t\treject(err)\n\t\t\t\t\t})\n\t\t\t\t\t.finally(() => {\n\t\t\t\t\t\tif (globalLoading) {\n\t\t\t\t\t\t\tallowMultipleToast(false)\n\t\t\t\t\t\t\tglobalLoading.close()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfetcher.loading = false\n\t\t\t\t\t})\n\t\t\t})\n\t\t},\n\n\t\t/**\n\t\t * 参数为\n\t\t * @param {String|Object} [message] Toast 的 Message 或者是 Toast 的配置\n\t\t * @return {*}\n\t\t */\n\t\tloading(message) {\n\t\t\tcloseToast(true)\n\t\t\tallowMultipleToast()\n\t\t\tif (isString(message)) {\n\t\t\t\tglobalLoading = showLoadingToast({\n\t\t\t\t\tmessage: message || \"加载中...\",\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tforbidClick: true,\n\t\t\t\t})\n\t\t\t} else if (isObject(message)) {\n\t\t\t\tglobalLoading = showLoadingToast({ duration: 0, ...message })\n\t\t\t} else {\n\t\t\t\tglobalLoading = showLoadingToast({\n\t\t\t\t\tmessage: \"加载中...\",\n\t\t\t\t\tduration: 0,\n\t\t\t\t\tforbidClick: true,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn this\n\t\t},\n\t}\n}\n","import { find, flatMapDeep, isNull, isUndefined, reduce } from \"lodash-es\"\n\n/**\n * 从 options 中根据 value 获取 text\n * @param value\n * @param options\n * * @param {Object} [adapter={value: \"value\",label: \"label\",children: \"children\"}] - 选项适配器\n * @param adapter\n * @return {*|string|string}\n */\nexport function useTextFromOptionsValue(value, options, adapter) {\n\tif (!options) {\n\t\treturn \"\"\n\t}\n\tadapter = adapter || {\n\t\tvalue: \"value\",\n\t\tlabel: \"text\",\n\t}\n\tconst option = options.find((option) => option[adapter.value] === value)\n\treturn option ? option[adapter.label] : \"\"\n}\n\n/**\n * 从嵌套的 options 中根据 value 获取 text, 如 [1, 3] => [\"东\", \"南\"]\n *\n * @param {Array} options - 嵌套的选项\n * @param {Array} values - 需要查找的值\n * @param {Object} [adapter={value: \"value\",label: \"label\",children: \"children\"}] - 选项适配器\n * @return Array\n */\nexport function useFindTextsInValues(options, values, adapter) {\n\tadapter = adapter || {\n\t\tvalue: \"value\",\n\t\tlabel: \"text\",\n\t\tchildren: \"children\",\n\t}\n\n\tconst labels = []\n\n\tfunction recursiveSearch(node) {\n\t\tif (values.includes(node[adapter.value])) {\n\t\t\tlabels.push(node[adapter.label])\n\t\t}\n\n\t\tif (node[adapter.children]?.length) {\n\t\t\tnode[adapter.children].forEach((child) => {\n\t\t\t\trecursiveSearch(child)\n\t\t\t})\n\t\t}\n\t}\n\n\toptions.forEach((item) => {\n\t\trecursiveSearch(item)\n\t})\n\n\treturn labels\n}\n\n/**\n * 从嵌套的 options 中根据 value 获取 label, 如地区路径: [440000, 440100, 440113] => ['广东省', '广州市', '番禺区']\n * @param {Array} options\n * @param {Array} path\n * @param {Object} [adapter]\n * @return Array\n */\nexport function useFindLabelsFromPath(options, path, adapter) {\n\tadapter = adapter || {\n\t\tvalue: \"value\",\n\t\tlabel: \"text\",\n\t\tchildren: \"children\",\n\t}\n\n\tlet labels = []\n\treduce(\n\t\tpath,\n\t\t(acc, value) => {\n\t\t\tconst item = find(acc, { [adapter.value]: value })\n\t\t\tif (item) {\n\t\t\t\tlabels.push(item[adapter.label])\n\t\t\t\treturn item[adapter.children]\n\t\t\t}\n\t\t},\n\t\toptions,\n\t)\n\treturn labels\n}\n\n/**\n * 从 options 为 [{text: \"\", value: \"\", children: []] 样式的多层数组中,根据所给的 value 递归找出该 option\n * @param {Array} options\n * @param {Number|String} value\n * @param {Object} [adapter]\n * @return {Object|null}\n */\nexport function useFindOptionByValue(options, value, adapter) {\n\tadapter = adapter || {\n\t\tvalue: \"value\",\n\t\tlabel: \"text\",\n\t\tchildren: \"children\",\n\t}\n\n\t// 遍历 options 数组\n\tfor (let option of options) {\n\t\t// 如果当前 option 的 value 匹配目标值,则返回当前 option\n\t\tif (option[adapter.value] === value) {\n\t\t\treturn option\n\t\t}\n\t\t// 如果当前 option 有子选项\n\t\tif (option[adapter.children] && option[adapter.children].length) {\n\t\t\t// 递归搜索子选项数组\n\t\t\tconst foundOption = useFindOptionByValue(option[adapter.children], value, adapter)\n\t\t\t// 如果找到了匹配的子选项,则返回\n\t\t\tif (foundOption) {\n\t\t\t\treturn foundOption\n\t\t\t}\n\t\t}\n\t}\n\t// 如果未找到匹配的选项,则返回 null\n\treturn null\n}\n\n/**\n * [移动端适配]\n * 从嵌套的 options 中根据 value 获取 text\n * @param {Array} options\n * @param {Array} path\n * @param {Object} [adapter]\n * @return Array\n */\nexport function useFindTextsFromPath(options, path, adapter) {\n\tadapter = adapter || {\n\t\tvalue: \"value\",\n\t\tlabel: \"text\",\n\t\tchildren: \"children\",\n\t}\n\treturn useFindLabelsFromPath(options, path, adapter)\n}\n\n/**\n * let obj = {\n * \"name\": \"西学楼1号\",\n * \"parent\": {\n * \"name\": \"学生宿舍\",\n * \"parent\": {\n * \"name\": \"宿舍区域\",\n * }\n * }\n * }\n * useFindPropertyRecursive(obj, 'name', 'parent') // [\"西学楼1号\", \"学生宿舍\", \"宿舍区域\"]\n *\n * 从嵌套的对象中递归获取某个属性\n * @param {Object} item 获取对象\n * @param {String} propertyKey 想获取的属性名称\n * @param {String} nestedKey 嵌套的属性\n * @return Array\n */\nexport function useFindPropertyRecursive(item, propertyKey, nestedKey) {\n\treturn flatMapDeep(item, (value, key) => {\n\t\tif (key === propertyKey) {\n\t\t\treturn value\n\t\t}\n\t\tif (key === nestedKey) {\n\t\t\treturn useFindPropertyRecursive(value, propertyKey, nestedKey)\n\t\t}\n\t\treturn []\n\t})\n}\n\n/**\n * 从嵌套的 options 中根据 value 获取 text 路径, 如地区路径: 440113 => [\"广东省\", \"广州市\", \" 番禺区\"]\n * @param options\n * @param value\n * @param adapter\n * @return {*}\n */\nexport function useFindParentLabels(options, value, adapter) {\n\tadapter = adapter || {\n\t\tvalue: \"value\",\n\t\tlabel: \"text\",\n\t\tchildren: \"children\",\n\t}\n\n\tconst labels = []\n\n\tfunction findParentLabels(options, value, labels) {\n\t\tfor (const option of options) {\n\t\t\tif (option[adapter.value] === value) {\n\t\t\t\tlabels.unshift(option[adapter.label])\n\t\t\t\tbreak\n\t\t\t} else if (option[adapter.children]) {\n\t\t\t\tconst childResult = findParentLabels(option[adapter.children], value, labels)\n\t\t\t\tif (childResult.length > 0) {\n\t\t\t\t\tlabels.unshift(option[adapter.label])\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn labels\n\t}\n\n\treturn findParentLabels(options, value, labels)\n}\n\n/**\n * 从嵌套的 options 中根据 value 获取整个 values 路径, 如地区路径: 440113 => [440000, 440100, 440113]\n * @param options\n * @param value\n * @param adapter\n * @return Array\n */\nexport function useFindParentValues(options, value, adapter) {\n\tadapter = adapter || {\n\t\tvalue: \"value\",\n\t\tlabel: \"text\",\n\t\tchildren: \"children\",\n\t}\n\n\tconst values = []\n\n\tfunction findParentValues(options, value, values) {\n\t\tfor (const option of options) {\n\t\t\tif (option[adapter.value] === value) {\n\t\t\t\tvalues.unshift(option[adapter.value])\n\t\t\t\tbreak\n\t\t\t} else if (option[adapter.children]) {\n\t\t\t\tconst childResult = findParentValues(option[adapter.children], value, values)\n\t\t\t\tif (childResult.length > 0) {\n\t\t\t\t\tvalues.unshift(option[adapter.value])\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn values\n\t}\n\n\treturn findParentValues(options, value, values)\n}\n\nconst localCacheSession = {}\nconst localSession = {\n\tsetItem(key, value) {\n\t\tlocalCacheSession[key] = value\n\t},\n\tgetItem(key) {\n\t\treturn localCacheSession[key]\n\t},\n\tremoveItem(key) {\n\t\tdelete localCacheSession[key]\n\t},\n}\n\nwindow._printCache = () => {\n\tconsole.log(JSON.parse(JSON.stringify(localCacheSession, null, 2)))\n}\n\n/**\n * 用于储存缓存的值\n * @param {*} key 缓存的 key\n * @param {*} [sessionType] 缓存的类型,默认为内存缓存\n * @returns get(默认值) 获取缓存的值,set(键, 值) 设置缓存的值\n */\nexport function useCache(key, sessionType) {\n\tconst cacheSession = sessionType || localSession\n\tconst shouldTransform = !!sessionType // 如果是 localStorage 之类的,则需要转换一下\n\treturn {\n\t\tget(defaultValue) {\n\t\t\tconst value = cacheSession.getItem(key)\n\t\t\tif (isNull(value) || isUndefined(value)) {\n\t\t\t\treturn defaultValue\n\t\t\t}\n\t\t\treturn shouldTransform ? JSON.parse(value) : value\n\t\t},\n\t\tset(value) {\n\t\t\tcacheSession.setItem(key, shouldTransform ? JSON.stringify(value) : value)\n\t\t},\n\t\tremove() {\n\t\t\tcacheSession.removeItem(key)\n\t\t},\n\t}\n}\n","import { cloneDeep, isArray, isBoolean, isDate, isFunction, isObject, isString, isUndefined } from \"lodash-es\"\nimport { STATUS } from \"./network\"\nimport { showFailToast, showSuccessToast } from \"vant\"\nimport dayjs from \"dayjs\"\n\n/**\n * 创建一个隐藏的表单\n *\n * @param {Object} options\n * @param {string} options.url\n * @param {Object} options.data\n * @param {string} [options.method]\n * @param {string} options.csrfToken\n * @returns {HTMLFormElement}\n */\nexport function useHiddenForm(options) {\n\tconst { url, data, csrfToken } = options\n\tlet { method } = options\n\n\tmethod = method || \"post\"\n\n\tconst form = document.createElement(\"form\")\n\tform.action = url\n\tform.method = method\n\tform.target = \"_blank\"\n\tform.style.display = \"none\"\n\n\tObject.keys(data).forEach((key) => {\n\t\tconst input = document.createElement(\"input\")\n\t\tinput.type = \"hidden\"\n\t\tinput.name = key\n\t\tinput.value = data[key]\n\t\tform.appendChild(input)\n\t})\n\n\tif (!csrfToken) {\n\t\tconst input = document.createElement(\"input\")\n\t\tinput.type = \"hidden\"\n\t\tinput.name = \"_token\"\n\t\tinput.value = document.querySelector('meta[name=\"csrf-token\"]').getAttribute(\"content\")\n\t\tform.appendChild(input)\n\t}\n\n\tdocument.body.appendChild(form)\n\n\treturn form\n}\n\n/**\n * 处理请求结果\n *\n * @param {object} res 请求结果\n * @param {string|number} res.status 请求结果状态\n * @param {*} res.result 请求结果信息\n * @param {Object.<string, string|function>} ops 状态的处理对象\n */\nexport function useProcessStatus(res, ops) {\n\tconst { status } = res\n\tconst msg = res.result\n\tconst predefined = {}\n\tpredefined.default = \"请求失败, 请检查数据并重试\"\n\tpredefined[STATUS.STATE_CODE_FAIL] = \"系统错误,请稍候再试\"\n\tpredefined[STATUS.STATE_CODE_NOT_FOUND] = \"请求的内容不存在\"\n\tpredefined[STATUS.STATE_CODE_INFO_NOT_COMPLETE] = \"信息不完整\"\n\tpredefined[STATUS.STATE_CODE_NOT_ALLOWED] = \"没有权限\"\n\n\t// 有几个常用的自定义名称\n\tconst special = {\n\t\t[STATUS.STATE_CODE_SUCCESS]: \"success\",\n\t}\n\n\tconst op = ops[status] || ops[special[status]] || predefined[status] || predefined.default\n\n\tif (isString(op)) {\n\t\tif (status === STATUS.STATE_CODE_SUCCESS) {\n\t\t\tshowSuccessToast(op)\n\t\t} else {\n\t\t\tshowFailToast(msg || op)\n\t\t}\n\t} else if (isFunction(op)) {\n\t\top()\n\t}\n}\n\n/**\n * 处理正确请求结果\n *\n * @param {object} res 请求结果\n * @param {string} res.status 请求结果状态\n * @param {*} res.result 请求结果信息\n * @param {string|function} success 状态的处理对象\n */\nexport function useProcessStatusSuccess(res, success) {\n\tuseProcessStatus(res, { success })\n}\n\n/**\n * 处理表单提交失败\n * @param {*} e\n */\nexport function useFormFail(e) {\n\tif (e && e.errorFields) {\n\t\te.errorFields.forEach((item) => {\n\t\t\tshowFailToast(item.errors.join(\" \"))\n\t\t})\n\t} else if (!(e && e.response)) {\n\t\tshowFailToast(\"请检查填写项\")\n\t} else {\n\t\tshowFailToast(\"网络异常\")\n\t}\n}\n\n/**\n * 处理表单数据\n * @param {Object} form\n * @param {Object} [format] 需要处理的类型\n * @param {boolean|string|Function} [format.date] `true`: 转成时间戳,`string`: 为 Format 格式, 如 `\"YYYY-MM-DD\"`, `function`: 自定义处理函数, 参数为 dayjs 对象\n * @param {boolean} [format.boolean] 布尔值处理, 如果开启则 `true` 转成 1, `false` 转成 0\n * @param {string|Function} [format.attachment] `string`: 附件字段名, `function`: 自定义处理函数, 参数为附件对象\n * @return {Object}\n */\nexport function useFormFormat(form, format) {\n\t//必须先 Copy form, 否则会改变 vm model 里的引用值而导致出错\n\tconst newForm = cloneDeep(form)\n\tformat = format || {}\n\tconst formatter = (obj) => {\n\t\tfor (let key in obj) {\n\t\t\t//日期处理\n\n\t\t\tlet date\n\t\t\tif (dayjs.isDayjs(obj[key])) {\n\t\t\t\tdate = obj[key]\n\t\t\t} else if (isDate(obj[key])) {\n\t\t\t\tdate = dayjs(obj[key])\n\t\t\t}\n\n\t\t\tif (date && format.date) {\n\t\t\t\tif (isString(format.date)) {\n\t\t\t\t\tobj[key] = date.format(format.date)\n\t\t\t\t} else if (isFunction(format.date)) {\n\t\t\t\t\tobj[key] = format.date(date)\n\t\t\t\t} else {\n\t\t\t\t\tobj[key] = date.unix()\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t//布尔值处理\n\t\t\tif (isBoolean(obj[key]) && format.boolean) {\n\t\t\t\tif (format.boolean === true) {\n\t\t\t\t\tobj[key] = obj[key] ? 1 : 0\n\t\t\t\t} else if (Array.isArray(format.boolean)) {\n\t\t\t\t\tobj[key] = obj[key] ? format.boolean?.[0] || 1 : format.boolean?.[1] || 0\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t//附件处理\n\t\t\tif (format.attachment) {\n\t\t\t\tconst checker = format.attachment\n\t\t\t\tif (isObject(obj[key]) && obj[key]._type === \"file\" && isString(checker) && !isUndefined(obj[key][checker])) {\n\t\t\t\t\tobj[key] = obj[key][checker]\n\t\t\t\t\tcontinue\n\t\t\t\t} else if (isObject(obj[key]) && isFunction(checker) && obj[key]._type === \"file\") {\n\t\t\t\t\tobj[key] = checker(obj[key])\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t//数组处理\n\t\t\tif (isArray(obj[key])) {\n\t\t\t\tobj[key] = formatter(obj[key])\n\t\t\t}\n\t\t}\n\n\t\treturn obj\n\t}\n\n\treturn formatter(newForm)\n}\n\nexport default {\n\tuseHiddenForm,\n\tuseProcessStatus,\n\tuseProcessStatusSuccess,\n\tuseFormFail,\n\tuseFormFormat,\n}\n","export const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;\n//# sourceMappingURL=crypto.js.map","/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\n/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */\nexport function isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n/** Asserts something is positive integer. */\nexport function anumber(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error('positive integer expected, got ' + n);\n}\n/** Asserts something is Uint8Array. */\nexport function abytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n/** Asserts something is hash */\nexport function ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.createHasher');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\n/** Asserts a hash instance has not been destroyed / finished */\nexport function aexists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\n/** Asserts output is properly-sized byte array */\nexport function aoutput(out, instance) {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n/** Cast u8 / u16 / u32 to u8. */\nexport function u8(arr) {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** Cast u8 / u16 / u32 to u32. */\nexport function u32(arr) {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n/** Zeroize a byte array. Warning: JS provides no guarantees. */\nexport function clean(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/** Create DataView of an array for easy byte-level manipulation. */\nexport function createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** The rotate right (circular right shift) operation for uint32 */\nexport function rotr(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/** The rotate left (circular left shift) operation for uint32 */\nexport function rotl(word, shift) {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexport const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n/** The byte swap operation for uint32 */\nexport function byteSwap(word) {\n return (((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff));\n}\n/** Conditionally byte swap if on a big-endian platform */\nexport const swap8IfBE = isLE\n ? (n) => n\n : (n) => byteSwap(n);\n/** @deprecated */\nexport const byteSwapIfBE = swap8IfBE;\n/** In place byte swap for Uint32Array */\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\nexport const swap32IfBE = isLE\n ? (u) => u\n : byteSwap32;\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin = /* @__PURE__ */ (() => \n// @ts-ignore\ntypeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * Convert byte array to hex string. Uses built-in function, when available.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin)\n return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };\nfunction asciiToBase16(ch) {\n if (ch >= asciis._0 && ch <= asciis._9)\n return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F)\n return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f)\n return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n // @ts-ignore\n if (hasHexBuiltin)\n return Uint8Array.fromHex(hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */\nexport const nextTick = async () => { };\n/** Returns control to thread each 'tick' ms to avoid blocking. */\nexport async function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick();\n ts += diff;\n }\n}\n/**\n * Converts string to bytes using UTF8 encoding.\n * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Converts bytes to string using UTF8 encoding.\n * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'\n */\nexport function bytesToUtf8(bytes) {\n return new TextDecoder().decode(bytes);\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n/**\n * Helper for KDFs: consumes uint8array or string.\n * When string is passed, does utf8 decoding, using TextDecoder.\n */\nexport function kdfInputToBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n/** Copies several Uint8Arrays into one. */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\nexport function checkOpts(defaults, opts) {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\n/** For runtime check if class implements interface */\nexport class Hash {\n}\n/** Wraps hash function, creating an interface on top of it */\nexport function createHasher(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\nexport function createOptHasher(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport function createXOFer(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport const wrapConstructor = createHasher;\nexport const wrapConstructorWithOpts = createOptHasher;\nexport const wrapXOFConstructorWithOpts = createXOFer;\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nexport function randomBytes(bytesLength = 32) {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return Uint8Array.from(crypto.randomBytes(bytesLength));\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n//# sourceMappingURL=utils.js.map","/**\n * Hex, bytes and number utilities.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport { abytes as abytes_, bytesToHex as bytesToHex_, concatBytes as concatBytes_, hexToBytes as hexToBytes_, isBytes as isBytes_, } from '@noble/hashes/utils.js';\nexport { abytes, anumber, bytesToHex, bytesToUtf8, concatBytes, hexToBytes, isBytes, randomBytes, utf8ToBytes, } from '@noble/hashes/utils.js';\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nexport function abool(title, value) {\n if (typeof value !== 'boolean')\n throw new Error(title + ' boolean expected, got ' + value);\n}\n// tmp name until v2\nexport function _abool2(value, title = '') {\n if (typeof value !== 'boolean') {\n const prefix = title && `\"${title}\"`;\n throw new Error(prefix + 'expected boolean, got type=' + typeof value);\n }\n return value;\n}\n// tmp name until v2\n/** Asserts something is Uint8Array. */\nexport function _abytes2(value, length, title = '') {\n const bytes = isBytes_(value);\n const len = value?.length;\n const needsLen = length !== undefined;\n if (!bytes || (needsLen && len !== length)) {\n const prefix = title && `\"${title}\" `;\n const ofLen = needsLen ? ` of length ${length}` : '';\n const got = bytes ? `length=${len}` : `type=${typeof value}`;\n throw new Error(prefix + 'expected Uint8Array' + ofLen + ', got ' + got);\n }\n return value;\n}\n// Used in weierstrass, der\nexport function numberToHexUnpadded(num) {\n const hex = num.toString(16);\n return hex.length & 1 ? '0' + hex : hex;\n}\nexport function hexToNumber(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n return hex === '' ? _0n : BigInt('0x' + hex); // Big Endian\n}\n// BE: Big Endian, LE: Little Endian\nexport function bytesToNumberBE(bytes) {\n return hexToNumber(bytesToHex_(bytes));\n}\nexport function bytesToNumberLE(bytes) {\n abytes_(bytes);\n return hexToNumber(bytesToHex_(Uint8Array.from(bytes).reverse()));\n}\nexport function numberToBytesBE(n, len) {\n return hexToBytes_(n.toString(16).padStart(len * 2, '0'));\n}\nexport function numberToBytesLE(n, len) {\n return numberToBytesBE(n, len).reverse();\n}\n// Unpadded, rarely used\nexport function numberToVarBytesBE(n) {\n return hexToBytes_(numberToHexUnpadded(n));\n}\n/**\n * Takes hex string or Uint8Array, converts to Uint8Array.\n * Validates output length.\n * Will throw error for other types.\n * @param title descriptive title for an error e.g. 'secret key'\n * @param hex hex string or Uint8Array\n * @param expectedLength optional, will compare to result array's length\n * @returns\n */\nexport function ensureBytes(title, hex, expectedLength) {\n let res;\n if (typeof hex === 'string') {\n try {\n res = hexToBytes_(hex);\n }\n catch (e) {\n throw new Error(title + ' must be hex string or Uint8Array, cause: ' + e);\n }\n }\n else if (isBytes_(hex)) {\n // Uint8Array.from() instead of hash.slice() because node.js Buffer\n // is instance of Uint8Array, and its slice() creates **mutable** copy\n res = Uint8Array.from(hex);\n }\n else {\n throw new Error(title + ' must be hex string or Uint8Array');\n }\n const len = res.length;\n if (typeof expectedLength === 'number' && len !== expectedLength)\n throw new Error(title + ' of length ' + expectedLength + ' expected, got ' + len);\n return res;\n}\n// Compares 2 u8a-s in kinda constant time\nexport function equalBytes(a, b) {\n if (a.length !== b.length)\n return false;\n let diff = 0;\n for (let i = 0; i < a.length; i++)\n diff |= a[i] ^ b[i];\n return diff === 0;\n}\n/**\n * Copies Uint8Array. We can't use u8a.slice(), because u8a can be Buffer,\n * and Buffer#slice creates mutable copy. Never use Buffers!\n */\nexport function copyBytes(bytes) {\n return Uint8Array.from(bytes);\n}\n/**\n * Decodes 7-bit ASCII string to Uint8Array, throws on non-ascii symbols\n * Should be safe to use for things expected to be ASCII.\n * Returns exact same result as utf8ToBytes for ASCII or throws.\n */\nexport function asciiToBytes(ascii) {\n return Uint8Array.from(ascii, (c, i) => {\n const charCode = c.charCodeAt(0);\n if (c.length !== 1 || charCode > 127) {\n throw new Error(`string contains non-ASCII character \"${ascii[i]}\" with code ${charCode} at position ${i}`);\n }\n return charCode;\n });\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\n// export const utf8ToBytes: typeof utf8ToBytes_ = utf8ToBytes_;\n/**\n * Converts bytes to string using UTF8 encoding.\n * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'\n */\n// export const bytesToUtf8: typeof bytesToUtf8_ = bytesToUtf8_;\n// Is positive bigint\nconst isPosBig = (n) => typeof n === 'bigint' && _0n <= n;\nexport function inRange(n, min, max) {\n return isPosBig(n) && isPosBig(min) && isPosBig(max) && min <= n && n < max;\n}\n/**\n * Asserts min <= n < max. NOTE: It's < max and not <= max.\n * @example\n * aInRange('x', x, 1n, 256n); // would assume x is in (1n..255n)\n */\nexport function aInRange(title, n, min, max) {\n // Why min <= n < max and not a (min < n < max) OR b (min <= n <= max)?\n // consider P=256n, min=0n, max=P\n // - a for min=0 would require -1: `inRange('x', x, -1n, P)`\n // - b would commonly require subtraction: `inRange('x', x, 0n, P - 1n)`\n // - our way is the cleanest: `inRange('x', x, 0n, P)\n if (!inRange(n, min, max))\n throw new Error('expected valid ' + title + ': ' + min + ' <= n < ' + max + ', got ' + n);\n}\n// Bit operations\n/**\n * Calculates amount of bits in a bigint.\n * Same as `n.toString(2).length`\n * TODO: merge with nLength in modular\n */\nexport function bitLen(n) {\n let len;\n for (len = 0; n > _0n; n >>= _1n, len += 1)\n ;\n return len;\n}\n/**\n * Gets single bit at position.\n * NOTE: first bit position is 0 (same as arrays)\n * Same as `!!+Array.from(n.toString(2)).reverse()[pos]`\n */\nexport function bitGet(n, pos) {\n return (n >> BigInt(pos)) & _1n;\n}\n/**\n * Sets single bit at position.\n */\nexport function bitSet(n, pos, value) {\n return n | ((value ? _1n : _0n) << BigInt(pos));\n}\n/**\n * Calculate mask for N bits. Not using ** operator with bigints because of old engines.\n * Same as BigInt(`0b${Array(i).fill('1').join('')}`)\n */\nexport const bitMask = (n) => (_1n << BigInt(n)) - _1n;\n/**\n * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs.\n * @returns function that will call DRBG until 2nd arg returns something meaningful\n * @example\n * const drbg = createHmacDRBG<Key>(32, 32, hmac);\n * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined\n */\nexport function createHmacDrbg(hashLen, qByteLen, hmacFn) {\n if (typeof hashLen !== 'number' || hashLen < 2)\n throw new Error('hashLen must be a number');\n if (typeof qByteLen !== 'number' || qByteLen < 2)\n throw new Error('qByteLen must be a number');\n if (typeof hmacFn !== 'function')\n throw new Error('hmacFn must be a function');\n // Step B, Step C: set hashLen to 8*ceil(hlen/8)\n const u8n = (len) => new Uint8Array(len); // creates Uint8Array\n const u8of = (byte) => Uint8Array.of(byte); // another shortcut\n let v = u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs.\n let k = u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same\n let i = 0; // Iterations counter, will throw when over 1000\n const reset = () => {\n v.fill(1);\n k.fill(0);\n i = 0;\n };\n const h = (...b) => hmacFn(k, v, ...b); // hmac(k)(v, ...values)\n const reseed = (seed = u8n(0)) => {\n // HMAC-DRBG reseed() function. Steps D-G\n k = h(u8of(0x00), seed); // k = hmac(k || v || 0x00 || seed)\n v = h(); // v = hmac(k || v)\n if (seed.length === 0)\n return;\n k = h(u8of(0x01), seed); // k = hmac(k || v || 0x01 || seed)\n v = h(); // v = hmac(k || v)\n };\n const gen = () => {\n // HMAC-DRBG generate() function\n if (i++ >= 1000)\n throw new Error('drbg: tried 1000 values');\n let len = 0;\n const out = [];\n while (len < qByteLen) {\n v = h();\n const sl = v.slice();\n out.push(sl);\n len += v.length;\n }\n return concatBytes_(...out);\n };\n const genUntil = (seed, pred) => {\n reset();\n reseed(seed); // Steps D-G\n let res = undefined; // Step H: grind until k is in [1..n-1]\n while (!(res = pred(gen())))\n reseed();\n reset();\n return res;\n };\n return genUntil;\n}\n// Validating curves and fields\nconst validatorFns = {\n bigint: (val) => typeof val === 'bigint',\n function: (val) => typeof val === 'function',\n boolean: (val) => typeof val === 'boolean',\n string: (val) => typeof val === 'string',\n stringOrUint8Array: (val) => typeof val === 'string' || isBytes_(val),\n isSafeInteger: (val) => Number.isSafeInteger(val),\n array: (val) => Array.isArray(val),\n field: (val, object) => object.Fp.isValid(val),\n hash: (val) => typeof val === 'function' && Number.isSafeInteger(val.outputLen),\n};\n// type Record<K extends string | number | symbol, T> = { [P in K]: T; }\nexport function validateObject(object, validators, optValidators = {}) {\n const checkField = (fieldName, type, isOptional) => {\n const checkVal = validatorFns[type];\n if (typeof checkVal !== 'function')\n throw new Error('invalid validator function');\n const val = object[fieldName];\n if (isOptional && val === undefined)\n return;\n if (!checkVal(val, object)) {\n throw new Error('param ' + String(fieldName) + ' is invalid. Expected ' + type + ', got ' + val);\n }\n };\n for (const [fieldName, type] of Object.entries(validators))\n checkField(fieldName, type, false);\n for (const [fieldName, type] of Object.entries(optValidators))\n checkField(fieldName, type, true);\n return object;\n}\n// validate type tests\n// const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 };\n// const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok!\n// // Should fail type-check\n// const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' });\n// const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' });\n// const z3 = validateObject(o, { test: 'boolean', z: 'bug' });\n// const z4 = validateObject(o, { a: 'boolean', z: 'bug' });\nexport function isHash(val) {\n return typeof val === 'function' && Number.isSafeInteger(val.outputLen);\n}\nexport function _validateObject(object, fields, optFields = {}) {\n if (!object || typeof object !== 'object')\n throw new Error('expected valid options object');\n function checkField(fieldName, expectedType, isOpt) {\n const val = object[fieldName];\n if (isOpt && val === undefined)\n return;\n const current = typeof val;\n if (current !== expectedType || val === null)\n throw new Error(`param \"${fieldName}\" is invalid: expected ${expectedType}, got ${current}`);\n }\n Object.entries(fields).forEach(([k, v]) => checkField(k, v, false));\n Object.entries(optFields).forEach(([k, v]) => checkField(k, v, true));\n}\n/**\n * throws not implemented error\n */\nexport const notImplemented = () => {\n throw new Error('not implemented');\n};\n/**\n * Memoizes (caches) computation result.\n * Uses WeakMap: the value is going auto-cleaned by GC after last reference is removed.\n */\nexport function memoized(fn) {\n const map = new WeakMap();\n return (arg, ...args) => {\n const val = map.get(arg);\n if (val !== undefined)\n return val;\n const computed = fn(arg, ...args);\n map.set(arg, computed);\n return computed;\n };\n}\n//# sourceMappingURL=utils.js.map","/**\n * Deprecated module: moved from curves/abstract/utils.js to curves/utils.js\n * @module\n */\nimport * as u from \"../utils.js\";\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const abytes = u.abytes;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const anumber = u.anumber;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const bytesToHex = u.bytesToHex;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const bytesToUtf8 = u.bytesToUtf8;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const concatBytes = u.concatBytes;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const hexToBytes = u.hexToBytes;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const isBytes = u.isBytes;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const randomBytes = u.randomBytes;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const utf8ToBytes = u.utf8ToBytes;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const abool = u.abool;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const numberToHexUnpadded = u.numberToHexUnpadded;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const hexToNumber = u.hexToNumber;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const bytesToNumberBE = u.bytesToNumberBE;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const bytesToNumberLE = u.bytesToNumberLE;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const numberToBytesBE = u.numberToBytesBE;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const numberToBytesLE = u.numberToBytesLE;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const numberToVarBytesBE = u.numberToVarBytesBE;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const ensureBytes = u.ensureBytes;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const equalBytes = u.equalBytes;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const copyBytes = u.copyBytes;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const asciiToBytes = u.asciiToBytes;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const inRange = u.inRange;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const aInRange = u.aInRange;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const bitLen = u.bitLen;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const bitGet = u.bitGet;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const bitSet = u.bitSet;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const bitMask = u.bitMask;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const createHmacDrbg = u.createHmacDrbg;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const notImplemented = u.notImplemented;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const memoized = u.memoized;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const validateObject = u.validateObject;\n/** @deprecated moved to `@noble/curves/utils.js` */\nexport const isHash = u.isHash;\n//# sourceMappingURL=utils.js.map","/**\n * HMAC: RFC2104 message authentication code.\n * @module\n */\nimport { abytes, aexists, ahash, clean, Hash, toBytes } from \"./utils.js\";\nexport class HMAC extends Hash {\n constructor(hash, _key) {\n super();\n this.finished = false;\n this.destroyed = false;\n ahash(hash);\n const key = toBytes(_key);\n this.iHash = hash.create();\n if (typeof this.iHash.update !== 'function')\n throw new Error('Expected instance of class which extends utils.Hash');\n this.blockLen = this.iHash.blockLen;\n this.outputLen = this.iHash.outputLen;\n const blockLen = this.blockLen;\n const pad = new Uint8Array(blockLen);\n // blockLen can be bigger than outputLen\n pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36;\n this.iHash.update(pad);\n // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone\n this.oHash = hash.create();\n // Undo internal XOR && apply outer XOR\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36 ^ 0x5c;\n this.oHash.update(pad);\n clean(pad);\n }\n update(buf) {\n aexists(this);\n this.iHash.update(buf);\n return this;\n }\n digestInto(out) {\n aexists(this);\n abytes(out, this.outputLen);\n this.finished = true;\n this.iHash.digestInto(out);\n this.oHash.update(out);\n this.oHash.digestInto(out);\n this.destroy();\n }\n digest() {\n const out = new Uint8Array(this.oHash.outputLen);\n this.digestInto(out);\n return out;\n }\n _cloneInto(to) {\n // Create new instance without calling constructor since key already in state and we don't know it.\n to || (to = Object.create(Object.getPrototypeOf(this), {}));\n const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;\n to = to;\n to.finished = finished;\n to.destroyed = destroyed;\n to.blockLen = blockLen;\n to.outputLen = outputLen;\n to.oHash = oHash._cloneInto(to.oHash);\n to.iHash = iHash._cloneInto(to.iHash);\n return to;\n }\n clone() {\n return this._cloneInto();\n }\n destroy() {\n this.destroyed = true;\n this.oHash.destroy();\n this.iHash.destroy();\n }\n}\n/**\n * HMAC: RFC2104 message authentication code.\n * @param hash - function that would be used e.g. sha256\n * @param key - message key\n * @param message - message data\n * @example\n * import { hmac } from '@noble/hashes/hmac';\n * import { sha256 } from '@noble/hashes/sha2';\n * const mac1 = hmac(sha256, 'key', 'message');\n */\nexport const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();\nhmac.create = (hash, key) => new HMAC(hash, key);\n//# sourceMappingURL=hmac.js.map","/**\n * Utils for modular division and fields.\n * Field over 11 is a finite (Galois) field is integer number operations `mod 11`.\n * There is no division: it is replaced by modular multiplicative inverse.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport { _validateObject, anumber, bitMask, bytesToNumberBE, bytesToNumberLE, ensureBytes, numberToBytesBE, numberToBytesLE, } from \"../utils.js\";\n// prettier-ignore\nconst _0n = BigInt(0), _1n = BigInt(1), _2n = /* @__PURE__ */ BigInt(2), _3n = /* @__PURE__ */ BigInt(3);\n// prettier-ignore\nconst _4n = /* @__PURE__ */ BigInt(4), _5n = /* @__PURE__ */ BigInt(5), _7n = /* @__PURE__ */ BigInt(7);\n// prettier-ignore\nconst _8n = /* @__PURE__ */ BigInt(8), _9n = /* @__PURE__ */ BigInt(9), _16n = /* @__PURE__ */ BigInt(16);\n// Calculates a modulo b\nexport function mod(a, b) {\n const result = a % b;\n return result >= _0n ? result : b + result;\n}\n/**\n * Efficiently raise num to power and do modular division.\n * Unsafe in some contexts: uses ladder, so can expose bigint bits.\n * @example\n * pow(2n, 6n, 11n) // 64n % 11n == 9n\n */\nexport function pow(num, power, modulo) {\n return FpPow(Field(modulo), num, power);\n}\n/** Does `x^(2^power)` mod p. `pow2(30, 4)` == `30^(2^4)` */\nexport function pow2(x, power, modulo) {\n let res = x;\n while (power-- > _0n) {\n res *= res;\n res %= modulo;\n }\n return res;\n}\n/**\n * Inverses number over modulo.\n * Implemented using [Euclidean GCD](https://brilliant.org/wiki/extended-euclidean-algorithm/).\n */\nexport function invert(number, modulo) {\n if (number === _0n)\n throw new Error('invert: expected non-zero number');\n if (modulo <= _0n)\n throw new Error('invert: expected positive modulus, got ' + modulo);\n // Fermat's little theorem \"CT-like\" version inv(n) = n^(m-2) mod m is 30x slower.\n let a = mod(number, modulo);\n let b = modulo;\n // prettier-ignore\n let x = _0n, y = _1n, u = _1n, v = _0n;\n while (a !== _0n) {\n // JIT applies optimization if those two lines follow each other\n const q = b / a;\n const r = b % a;\n