PromoCursed/node_modules/.cache/babel-loader/e4b8c7641dbd1914f8206162698e7566f28b71a3623c35c97dc9d5ed658ce035.json
2024-08-20 23:25:37 +04:00

1 line
14 KiB
JSON

{"ast":null,"code":"// Part logic is from `qrcode.react`. (ISC License)\n// https://github.com/zpao/qrcode.react\n\n// ==========================================================\n\nimport { Ecc } from \"./libs/qrcodegen\";\n\n// =================== ERROR_LEVEL ==========================\nexport var ERROR_LEVEL_MAP = {\n L: Ecc.LOW,\n M: Ecc.MEDIUM,\n Q: Ecc.QUARTILE,\n H: Ecc.HIGH\n};\n\n// =================== DEFAULT_VALUE ==========================\nexport var DEFAULT_SIZE = 128;\nexport var DEFAULT_LEVEL = 'L';\nexport var DEFAULT_BACKGROUND_COLOR = '#FFFFFF';\nexport var DEFAULT_FRONT_COLOR = '#000000';\nexport var DEFAULT_NEED_MARGIN = false;\nexport var DEFAULT_MINVERSION = 1;\nexport var SPEC_MARGIN_SIZE = 4;\nexport var DEFAULT_MARGIN_SIZE = 0;\nexport var DEFAULT_IMG_SCALE = 0.1;\n\n// =================== UTILS ==========================\n/**\n * Generate a path string from modules\n * @param modules\n * @param margin \n * @returns \n */\nexport function generatePath(modules) {\n var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n var ops = [];\n modules.forEach(function (row, y) {\n var start = null;\n row.forEach(function (cell, x) {\n if (!cell && start !== null) {\n ops.push(\"M\".concat(start + margin, \" \").concat(y + margin, \"h\").concat(x - start, \"v1H\").concat(start + margin, \"z\"));\n start = null;\n return;\n }\n if (x === row.length - 1) {\n if (!cell) {\n return;\n }\n if (start === null) {\n ops.push(\"M\".concat(x + margin, \",\").concat(y + margin, \" h1v1H\").concat(x + margin, \"z\"));\n } else {\n ops.push(\"M\".concat(start + margin, \",\").concat(y + margin, \" h\").concat(x + 1 - start, \"v1H\").concat(start + margin, \"z\"));\n }\n return;\n }\n if (cell && start === null) {\n start = x;\n }\n });\n });\n return ops.join('');\n}\n/**\n * Excavate modules\n * @param modules \n * @param excavation \n * @returns \n */\nexport function excavateModules(modules, excavation) {\n return modules.slice().map(function (row, y) {\n if (y < excavation.y || y >= excavation.y + excavation.h) {\n return row;\n }\n return row.map(function (cell, x) {\n if (x < excavation.x || x >= excavation.x + excavation.w) {\n return cell;\n }\n return false;\n });\n });\n}\n\n/**\n * Get image settings\n * @param cells The modules of the QR code\n * @param size The size of the QR code\n * @param margin \n * @param imageSettings \n * @returns \n */\nexport function getImageSettings(cells, size, margin, imageSettings) {\n if (imageSettings == null) {\n return null;\n }\n var numCells = cells.length + margin * 2;\n var defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);\n var scale = numCells / size;\n var w = (imageSettings.width || defaultSize) * scale;\n var h = (imageSettings.height || defaultSize) * scale;\n var x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;\n var y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;\n var opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity;\n var excavation = null;\n if (imageSettings.excavate) {\n var floorX = Math.floor(x);\n var floorY = Math.floor(y);\n var ceilW = Math.ceil(w + x - floorX);\n var ceilH = Math.ceil(h + y - floorY);\n excavation = {\n x: floorX,\n y: floorY,\n w: ceilW,\n h: ceilH\n };\n }\n var crossOrigin = imageSettings.crossOrigin;\n return {\n x: x,\n y: y,\n h: h,\n w: w,\n excavation: excavation,\n opacity: opacity,\n crossOrigin: crossOrigin\n };\n}\n\n/**\n * Get margin size\n * @param needMargin Whether need margin\n * @param marginSize Custom margin size\n * @returns \n */\nexport function getMarginSize(needMargin, marginSize) {\n if (marginSize != null) {\n return Math.floor(marginSize);\n }\n return needMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;\n}\n/**\n * Check if Path2D is supported\n */\nexport var isSupportPath2d = function () {\n try {\n new Path2D().addPath(new Path2D());\n } catch (e) {\n return false;\n }\n return true;\n}();","map":{"version":3,"names":["Ecc","ERROR_LEVEL_MAP","L","LOW","M","MEDIUM","Q","QUARTILE","H","HIGH","DEFAULT_SIZE","DEFAULT_LEVEL","DEFAULT_BACKGROUND_COLOR","DEFAULT_FRONT_COLOR","DEFAULT_NEED_MARGIN","DEFAULT_MINVERSION","SPEC_MARGIN_SIZE","DEFAULT_MARGIN_SIZE","DEFAULT_IMG_SCALE","generatePath","modules","margin","arguments","length","undefined","ops","forEach","row","y","start","cell","x","push","concat","join","excavateModules","excavation","slice","map","h","w","getImageSettings","cells","size","imageSettings","numCells","defaultSize","Math","floor","scale","width","height","opacity","excavate","floorX","floorY","ceilW","ceil","ceilH","crossOrigin","getMarginSize","needMargin","marginSize","isSupportPath2d","Path2D","addPath","e"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/@rc-component/qrcode/es/utils.js"],"sourcesContent":["// Part logic is from `qrcode.react`. (ISC License)\n// https://github.com/zpao/qrcode.react\n\n// ==========================================================\n\nimport { Ecc } from \"./libs/qrcodegen\";\n\n// =================== ERROR_LEVEL ==========================\nexport var ERROR_LEVEL_MAP = {\n L: Ecc.LOW,\n M: Ecc.MEDIUM,\n Q: Ecc.QUARTILE,\n H: Ecc.HIGH\n};\n\n// =================== DEFAULT_VALUE ==========================\nexport var DEFAULT_SIZE = 128;\nexport var DEFAULT_LEVEL = 'L';\nexport var DEFAULT_BACKGROUND_COLOR = '#FFFFFF';\nexport var DEFAULT_FRONT_COLOR = '#000000';\nexport var DEFAULT_NEED_MARGIN = false;\nexport var DEFAULT_MINVERSION = 1;\nexport var SPEC_MARGIN_SIZE = 4;\nexport var DEFAULT_MARGIN_SIZE = 0;\nexport var DEFAULT_IMG_SCALE = 0.1;\n\n// =================== UTILS ==========================\n/**\n * Generate a path string from modules\n * @param modules\n * @param margin \n * @returns \n */\nexport function generatePath(modules) {\n var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n var ops = [];\n modules.forEach(function (row, y) {\n var start = null;\n row.forEach(function (cell, x) {\n if (!cell && start !== null) {\n ops.push(\"M\".concat(start + margin, \" \").concat(y + margin, \"h\").concat(x - start, \"v1H\").concat(start + margin, \"z\"));\n start = null;\n return;\n }\n if (x === row.length - 1) {\n if (!cell) {\n return;\n }\n if (start === null) {\n ops.push(\"M\".concat(x + margin, \",\").concat(y + margin, \" h1v1H\").concat(x + margin, \"z\"));\n } else {\n ops.push(\"M\".concat(start + margin, \",\").concat(y + margin, \" h\").concat(x + 1 - start, \"v1H\").concat(start + margin, \"z\"));\n }\n return;\n }\n if (cell && start === null) {\n start = x;\n }\n });\n });\n return ops.join('');\n}\n/**\n * Excavate modules\n * @param modules \n * @param excavation \n * @returns \n */\nexport function excavateModules(modules, excavation) {\n return modules.slice().map(function (row, y) {\n if (y < excavation.y || y >= excavation.y + excavation.h) {\n return row;\n }\n return row.map(function (cell, x) {\n if (x < excavation.x || x >= excavation.x + excavation.w) {\n return cell;\n }\n return false;\n });\n });\n}\n\n/**\n * Get image settings\n * @param cells The modules of the QR code\n * @param size The size of the QR code\n * @param margin \n * @param imageSettings \n * @returns \n */\nexport function getImageSettings(cells, size, margin, imageSettings) {\n if (imageSettings == null) {\n return null;\n }\n var numCells = cells.length + margin * 2;\n var defaultSize = Math.floor(size * DEFAULT_IMG_SCALE);\n var scale = numCells / size;\n var w = (imageSettings.width || defaultSize) * scale;\n var h = (imageSettings.height || defaultSize) * scale;\n var x = imageSettings.x == null ? cells.length / 2 - w / 2 : imageSettings.x * scale;\n var y = imageSettings.y == null ? cells.length / 2 - h / 2 : imageSettings.y * scale;\n var opacity = imageSettings.opacity == null ? 1 : imageSettings.opacity;\n var excavation = null;\n if (imageSettings.excavate) {\n var floorX = Math.floor(x);\n var floorY = Math.floor(y);\n var ceilW = Math.ceil(w + x - floorX);\n var ceilH = Math.ceil(h + y - floorY);\n excavation = {\n x: floorX,\n y: floorY,\n w: ceilW,\n h: ceilH\n };\n }\n var crossOrigin = imageSettings.crossOrigin;\n return {\n x: x,\n y: y,\n h: h,\n w: w,\n excavation: excavation,\n opacity: opacity,\n crossOrigin: crossOrigin\n };\n}\n\n/**\n * Get margin size\n * @param needMargin Whether need margin\n * @param marginSize Custom margin size\n * @returns \n */\nexport function getMarginSize(needMargin, marginSize) {\n if (marginSize != null) {\n return Math.floor(marginSize);\n }\n return needMargin ? SPEC_MARGIN_SIZE : DEFAULT_MARGIN_SIZE;\n}\n/**\n * Check if Path2D is supported\n */\nexport var isSupportPath2d = function () {\n try {\n new Path2D().addPath(new Path2D());\n } catch (e) {\n return false;\n }\n return true;\n}();"],"mappings":"AAAA;AACA;;AAEA;;AAEA,SAASA,GAAG,QAAQ,kBAAkB;;AAEtC;AACA,OAAO,IAAIC,eAAe,GAAG;EAC3BC,CAAC,EAAEF,GAAG,CAACG,GAAG;EACVC,CAAC,EAAEJ,GAAG,CAACK,MAAM;EACbC,CAAC,EAAEN,GAAG,CAACO,QAAQ;EACfC,CAAC,EAAER,GAAG,CAACS;AACT,CAAC;;AAED;AACA,OAAO,IAAIC,YAAY,GAAG,GAAG;AAC7B,OAAO,IAAIC,aAAa,GAAG,GAAG;AAC9B,OAAO,IAAIC,wBAAwB,GAAG,SAAS;AAC/C,OAAO,IAAIC,mBAAmB,GAAG,SAAS;AAC1C,OAAO,IAAIC,mBAAmB,GAAG,KAAK;AACtC,OAAO,IAAIC,kBAAkB,GAAG,CAAC;AACjC,OAAO,IAAIC,gBAAgB,GAAG,CAAC;AAC/B,OAAO,IAAIC,mBAAmB,GAAG,CAAC;AAClC,OAAO,IAAIC,iBAAiB,GAAG,GAAG;;AAElC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,OAAO,EAAE;EACpC,IAAIC,MAAM,GAAGC,SAAS,CAACC,MAAM,GAAG,CAAC,IAAID,SAAS,CAAC,CAAC,CAAC,KAAKE,SAAS,GAAGF,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC;EAClF,IAAIG,GAAG,GAAG,EAAE;EACZL,OAAO,CAACM,OAAO,CAAC,UAAUC,GAAG,EAAEC,CAAC,EAA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