{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport useLockEffect from \"./useLockEffect\";\n/**\n * When user first focus one input, any submit will trigger focus another one.\n * When second time focus one input, submit will not trigger focus again.\n * When click outside to close the panel, trigger event if it can trigger onChange.\n */\nexport default function useRangeActive(disabled) {\n var empty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var mergedOpen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n var _React$useState = React.useState(0),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n activeIndex = _React$useState2[0],\n setActiveIndex = _React$useState2[1];\n var _React$useState3 = React.useState(false),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n focused = _React$useState4[0],\n setFocused = _React$useState4[1];\n var activeListRef = React.useRef([]);\n var lastOperationRef = React.useRef(null);\n var triggerFocus = function triggerFocus(nextFocus) {\n setFocused(nextFocus);\n };\n\n // ============================= Record =============================\n var lastOperation = function lastOperation(type) {\n if (type) {\n lastOperationRef.current = type;\n }\n return lastOperationRef.current;\n };\n\n // ============================ Strategy ============================\n // Trigger when input enter or input blur or panel close\n var nextActiveIndex = function nextActiveIndex(nextValue) {\n var list = activeListRef.current;\n var filledActiveSet = new Set(list.filter(function (index) {\n return nextValue[index] || empty[index];\n }));\n var nextIndex = list[list.length - 1] === 0 ? 1 : 0;\n if (filledActiveSet.size >= 2 || disabled[nextIndex]) {\n return null;\n }\n return nextIndex;\n };\n\n // ============================= Effect =============================\n // Wait in case it's from the click outside to blur\n useLockEffect(focused || mergedOpen, function () {\n if (!focused) {\n activeListRef.current = [];\n }\n });\n React.useEffect(function () {\n if (focused) {\n activeListRef.current.push(activeIndex);\n }\n }, [focused, activeIndex]);\n return [focused, triggerFocus, lastOperation, activeIndex, setActiveIndex, nextActiveIndex, activeListRef.current];\n}","map":{"version":3,"names":["_slicedToArray","React","useLockEffect","useRangeActive","disabled","empty","arguments","length","undefined","mergedOpen","_React$useState","useState","_React$useState2","activeIndex","setActiveIndex","_React$useState3","_React$useState4","focused","setFocused","activeListRef","useRef","lastOperationRef","triggerFocus","nextFocus","lastOperation","type","current","nextActiveIndex","nextValue","list","filledActiveSet","Set","filter","index","nextIndex","size","useEffect","push"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/rc-picker/es/PickerInput/hooks/useRangeActive.js"],"sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport useLockEffect from \"./useLockEffect\";\n/**\n * When user first focus one input, any submit will trigger focus another one.\n * When second time focus one input, submit will not trigger focus again.\n * When click outside to close the panel, trigger event if it can trigger onChange.\n */\nexport default function useRangeActive(disabled) {\n var empty = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];\n var mergedOpen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n var _React$useState = React.useState(0),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n activeIndex = _React$useState2[0],\n setActiveIndex = _React$useState2[1];\n var _React$useState3 = React.useState(false),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n focused = _React$useState4[0],\n setFocused = _React$useState4[1];\n var activeListRef = React.useRef([]);\n var lastOperationRef = React.useRef(null);\n var triggerFocus = function triggerFocus(nextFocus) {\n setFocused(nextFocus);\n };\n\n // ============================= Record =============================\n var lastOperation = function lastOperation(type) {\n if (type) {\n lastOperationRef.current = type;\n }\n return lastOperationRef.current;\n };\n\n // ============================ Strategy ============================\n // Trigger when input enter or input blur or panel close\n var nextActiveIndex = function nextActiveIndex(nextValue) {\n var list = activeListRef.current;\n var filledActiveSet = new Set(list.filter(function (index) {\n return nextValue[index] || empty[index];\n }));\n var nextIndex = list[list.length - 1] === 0 ? 1 : 0;\n if (filledActiveSet.size >= 2 || disabled[nextIndex]) {\n return null;\n }\n return nextIndex;\n };\n\n // ============================= Effect =============================\n // Wait in case it's from the click outside to blur\n useLockEffect(focused || mergedOpen, function () {\n if (!focused) {\n activeListRef.current = [];\n }\n });\n React.useEffect(function () {\n if (focused) {\n activeListRef.current.push(activeIndex);\n }\n }, [focused, activeIndex]);\n return [focused, triggerFocus, lastOperation, activeIndex, setActiveIndex, nextActiveIndex, activeListRef.current];\n}"],"mappings":"AAAA,OAAOA,cAAc,MAAM,0CAA0C;AACrE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAOC,aAAa,MAAM,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CAACC,QAAQ,EAAE;EAC/C,IAAIC,KAAK,GAAGC,SAAS,CAACC,MAAM,GAAG,CAAC,IAAID,SAAS,CAAC,CAAC,CAAC,KAAKE,SAAS,GAAGF,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE;EAClF,IAAIG,UAAU,GAAGH,SAAS,CAACC,MAAM,GAAG,CAAC,IAAID,SAAS,CAAC,CAAC,CAAC,KAAKE,SAAS,GAAGF,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK;EAC1F,IAAII,eAAe,GAAGT,KAAK,CAACU,QAAQ,CAAC,CAAC,CAAC;IACrCC,gBAAgB,GAAGZ,cAAc,CAACU,eAAe,EAAE,CAAC,CAAC;IACrDG,WAAW,GAAGD,gBAAgB,CAAC,CAAC,CAAC;IACjCE,cAAc,GAAGF,gBAAgB,CAAC,CAAC,CAAC;EACtC,IAAIG,gBAAgB,GAAGd,KAAK,CAACU,QAAQ,CAAC,KAAK,CAAC;IAC1CK,gBAAgB,GAAGhB,cAAc,CAACe,gBAAgB,EAAE,CAAC,CAAC;IACtDE,OAAO,GAAGD,gBAAgB,CAAC,CAAC,CAAC;IAC7BE,UAAU,GAAGF,gBAAgB,CAAC,CAAC,CAAC;EAClC,IAAIG,aAAa,GAAGlB,KAAK,CAACmB,MAAM,CAAC,EAAE,CAAC;EACpC,IAAIC,gBAAgB,GAAGpB,KAAK,CAACmB,MAAM,CAAC,IAAI,CAAC;EACzC,IAAIE,YAAY,GAAG,SAASA,Y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