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

1 line
10 KiB
JSON

{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nexport var STATUS_ADD = 'add';\nexport var STATUS_KEEP = 'keep';\nexport var STATUS_REMOVE = 'remove';\nexport var STATUS_REMOVED = 'removed';\nexport function wrapKeyToObject(key) {\n var keyObj;\n if (key && _typeof(key) === 'object' && 'key' in key) {\n keyObj = key;\n } else {\n keyObj = {\n key: key\n };\n }\n return _objectSpread(_objectSpread({}, keyObj), {}, {\n key: String(keyObj.key)\n });\n}\nexport function parseKeys() {\n var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n return keys.map(wrapKeyToObject);\n}\nexport function diffKeys() {\n var prevKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var currentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var list = [];\n var currentIndex = 0;\n var currentLen = currentKeys.length;\n var prevKeyObjects = parseKeys(prevKeys);\n var currentKeyObjects = parseKeys(currentKeys);\n\n // Check prev keys to insert or keep\n prevKeyObjects.forEach(function (keyObj) {\n var hit = false;\n for (var i = currentIndex; i < currentLen; i += 1) {\n var currentKeyObj = currentKeyObjects[i];\n if (currentKeyObj.key === keyObj.key) {\n // New added keys should add before current key\n if (currentIndex < i) {\n list = list.concat(currentKeyObjects.slice(currentIndex, i).map(function (obj) {\n return _objectSpread(_objectSpread({}, obj), {}, {\n status: STATUS_ADD\n });\n }));\n currentIndex = i;\n }\n list.push(_objectSpread(_objectSpread({}, currentKeyObj), {}, {\n status: STATUS_KEEP\n }));\n currentIndex += 1;\n hit = true;\n break;\n }\n }\n\n // If not hit, it means key is removed\n if (!hit) {\n list.push(_objectSpread(_objectSpread({}, keyObj), {}, {\n status: STATUS_REMOVE\n }));\n }\n });\n\n // Add rest to the list\n if (currentIndex < currentLen) {\n list = list.concat(currentKeyObjects.slice(currentIndex).map(function (obj) {\n return _objectSpread(_objectSpread({}, obj), {}, {\n status: STATUS_ADD\n });\n }));\n }\n\n /**\n * Merge same key when it remove and add again:\n * [1 - add, 2 - keep, 1 - remove] -> [1 - keep, 2 - keep]\n */\n var keys = {};\n list.forEach(function (_ref) {\n var key = _ref.key;\n keys[key] = (keys[key] || 0) + 1;\n });\n var duplicatedKeys = Object.keys(keys).filter(function (key) {\n return keys[key] > 1;\n });\n duplicatedKeys.forEach(function (matchKey) {\n // Remove `STATUS_REMOVE` node.\n list = list.filter(function (_ref2) {\n var key = _ref2.key,\n status = _ref2.status;\n return key !== matchKey || status !== STATUS_REMOVE;\n });\n\n // Update `STATUS_ADD` to `STATUS_KEEP`\n list.forEach(function (node) {\n if (node.key === matchKey) {\n // eslint-disable-next-line no-param-reassign\n node.status = STATUS_KEEP;\n }\n });\n });\n return list;\n}","map":{"version":3,"names":["_objectSpread","_typeof","STATUS_ADD","STATUS_KEEP","STATUS_REMOVE","STATUS_REMOVED","wrapKeyToObject","key","keyObj","String","parseKeys","keys","arguments","length","undefined","map","diffKeys","prevKeys","currentKeys","list","currentIndex","currentLen","prevKeyObjects","currentKeyObjects","forEach","hit","i","currentKeyObj","concat","slice","obj","status","push","_ref","duplicatedKeys","Object","filter","matchKey","_ref2","node"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/rc-motion/es/util/diff.js"],"sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nexport var STATUS_ADD = 'add';\nexport var STATUS_KEEP = 'keep';\nexport var STATUS_REMOVE = 'remove';\nexport var STATUS_REMOVED = 'removed';\nexport function wrapKeyToObject(key) {\n var keyObj;\n if (key && _typeof(key) === 'object' && 'key' in key) {\n keyObj = key;\n } else {\n keyObj = {\n key: key\n };\n }\n return _objectSpread(_objectSpread({}, keyObj), {}, {\n key: String(keyObj.key)\n });\n}\nexport function parseKeys() {\n var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n return keys.map(wrapKeyToObject);\n}\nexport function diffKeys() {\n var prevKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var currentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var list = [];\n var currentIndex = 0;\n var currentLen = currentKeys.length;\n var prevKeyObjects = parseKeys(prevKeys);\n var currentKeyObjects = parseKeys(currentKeys);\n\n // Check prev keys to insert or keep\n prevKeyObjects.forEach(function (keyObj) {\n var hit = false;\n for (var i = currentIndex; i < currentLen; i += 1) {\n var currentKeyObj = currentKeyObjects[i];\n if (currentKeyObj.key === keyObj.key) {\n // New added keys should add before current key\n if (currentIndex < i) {\n list = list.concat(currentKeyObjects.slice(currentIndex, i).map(function (obj) {\n return _objectSpread(_objectSpread({}, obj), {}, {\n status: STATUS_ADD\n });\n }));\n currentIndex = i;\n }\n list.push(_objectSpread(_objectSpread({}, currentKeyObj), {}, {\n status: STATUS_KEEP\n }));\n currentIndex += 1;\n hit = true;\n break;\n }\n }\n\n // If not hit, it means key is removed\n if (!hit) {\n list.push(_objectSpread(_objectSpread({}, keyObj), {}, {\n status: STATUS_REMOVE\n }));\n }\n });\n\n // Add rest to the list\n if (currentIndex < currentLen) {\n list = list.concat(currentKeyObjects.slice(currentIndex).map(function (obj) {\n return _objectSpread(_objectSpread({}, obj), {}, {\n status: STATUS_ADD\n });\n }));\n }\n\n /**\n * Merge same key when it remove and add again:\n * [1 - add, 2 - keep, 1 - remove] -> [1 - keep, 2 - keep]\n */\n var keys = {};\n list.forEach(function (_ref) {\n var key = _ref.key;\n keys[key] = (keys[key] || 0) + 1;\n });\n var duplicatedKeys = Object.keys(keys).filter(function (key) {\n return keys[key] > 1;\n });\n duplicatedKeys.forEach(function (matchKey) {\n // Remove `STATUS_REMOVE` node.\n list = list.filter(function (_ref2) {\n var key = _ref2.key,\n status = _ref2.status;\n return key !== matchKey || status !== STATUS_REMOVE;\n });\n\n // Update `STATUS_ADD` to `STATUS_KEEP`\n list.forEach(function (node) {\n if (node.key === matchKey) {\n // eslint-disable-next-line no-param-reassign\n node.status = STATUS_KEEP;\n }\n });\n });\n return list;\n}"],"mappings":"AAAA,OAAOA,aAAa,MAAM,0CAA0C;AACpE,OAAOC,OAAO,MAAM,mCAAmC;AACvD,OAAO,IAAIC,UAAU,GAAG,KAAK;AAC7B,OAAO,IAAIC,WAAW,GAAG,MAAM;AAC/B,OAAO,IAAIC,aAAa,GAAG,QAAQ;AACnC,OAAO,IAAIC,cAAc,GAAG,SAAS;AACrC,OAAO,SAASC,eAAeA,CAACC,GAAG,EAAE;EACnC,IAAIC,MAAM;EACV,IAAID,GAAG,IAAIN,OAAO,CAACM,GAAG,CAAC,KAAK,QAAQ,IAAI,KAAK,IAAIA,GAAG,EAAE;IACpDC,MAAM,GAAGD,GAAG;EACd,CAAC,MAAM;IACLC,MAAM,GAAG;MACPD,GAAG,EAAEA;IACP,CAAC;EACH;EACA,OAAOP,aAAa,CAACA,aAAa,CAAC,CAAC,CAAC,EAAEQ,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE;IAClDD,GAAG,EAAEE,MAAM,CAACD,MAAM,CAACD,GAAG;EACxB,CAAC,CAAC;AACJ;AACA,OAAO,SAASG,SAASA,CAAA,EAAG;EAC1B,IAAIC,IAAI,GAAGC,SAAS,CAACC,MAAM,GAAG,CAAC,IAAID,SAAS,CAAC,CAAC,CAAC,KAAKE,SAAS,GAAGF,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE;EACjF,OAAOD,IAAI,CAACI,GAAG,CAACT,eAAe,CAAC;AAClC;AACA,OAAO,SAASU,QAAQA,CAAA,EAAG;EACzB,IAAIC,QAAQ,GAAGL,SAAS,CAACC,MAAM,GAAG,CAAC,IAAID,SAAS,CAAC,CAAC,CAAC,KAAKE,SAAS,GAAGF,SAAS,CAAC,CAAC,CAAC,GA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