{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\n\nimport _regeneratorRuntime from \"@babel/runtime/regenerator\";\n\nfunction _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nimport $hGDng$react, { useMemo as $hGDng$useMemo, useRef as $hGDng$useRef } from \"react\";\n\nfunction $parcel$export(e, n, v, s) {\n  Object.defineProperty(e, n, {\n    get: v,\n    set: s,\n    enumerable: true,\n    configurable: true\n  });\n}\n\nvar $d80587bf41d0fb18$exports = {};\n$parcel$export($d80587bf41d0fb18$exports, \"Item\", function () {\n  return $d80587bf41d0fb18$export$6d08773d2e66f8f2;\n});\n\nfunction $d80587bf41d0fb18$var$Item(props) {\n  return null;\n}\n\n$d80587bf41d0fb18$var$Item.getCollectionNode = _regeneratorRuntime.mark(function getCollectionNode(props, context) {\n  var childItems, title, children, rendered, textValue;\n  return _regeneratorRuntime.wrap(function getCollectionNode$(_context2) {\n    while (1) {\n      switch (_context2.prev = _context2.next) {\n        case 0:\n          childItems = props.childItems, title = props.title, children = props.children;\n          rendered = props.title || props.children;\n          textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';\n          if (!textValue && !(context != null && context.suppressTextValueWarning)) console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');\n          _context2.next = 6;\n          return {\n            type: 'item',\n            props: props,\n            rendered: rendered,\n            textValue: textValue,\n            'aria-label': props['aria-label'],\n            hasChildNodes: $d80587bf41d0fb18$var$hasChildItems(props),\n            childNodes: _regeneratorRuntime.mark(function childNodes() {\n              var _iterator, _step, child1, items;\n\n              return _regeneratorRuntime.wrap(function childNodes$(_context) {\n                while (1) {\n                  switch (_context.prev = _context.next) {\n                    case 0:\n                      if (!childItems) {\n                        _context.next = 10;\n                        break;\n                      }\n\n                      _iterator = _createForOfIteratorHelperLoose(childItems);\n\n                    case 2:\n                      if ((_step = _iterator()).done) {\n                        _context.next = 8;\n                        break;\n                      }\n\n                      child1 = _step.value;\n                      _context.next = 6;\n                      return {\n                        type: 'item',\n                        value: child1\n                      };\n\n                    case 6:\n                      _context.next = 2;\n                      break;\n\n                    case 8:\n                      _context.next = 14;\n                      break;\n\n                    case 10:\n                      if (!title) {\n                        _context.next = 14;\n                        break;\n                      }\n\n                      items = [];\n                      $hGDng$react.Children.forEach(children, function (child) {\n                        items.push({\n                          type: 'item',\n                          element: child\n                        });\n                      });\n                      return _context.delegateYield(items, \"t0\", 14);\n\n                    case 14:\n                    case \"end\":\n                      return _context.stop();\n                  }\n                }\n              }, childNodes);\n            })\n          };\n\n        case 6:\n        case \"end\":\n          return _context2.stop();\n      }\n    }\n  }, getCollectionNode);\n});\n\nfunction $d80587bf41d0fb18$var$hasChildItems(props) {\n  if (props.hasChildItems != null) return props.hasChildItems;\n  if (props.childItems) return true;\n  if (props.title && $hGDng$react.Children.count(props.children) > 0) return true;\n  return false;\n}\n\nvar $d80587bf41d0fb18$export$6d08773d2e66f8f2 = $d80587bf41d0fb18$var$Item;\nvar $591e4228be66f7fb$exports = {};\n$parcel$export($591e4228be66f7fb$exports, \"Section\", function () {\n  return $591e4228be66f7fb$export$6e2c8f0811a474ce;\n});\n\nfunction $591e4228be66f7fb$var$Section(props) {\n  return null;\n}\n\n$591e4228be66f7fb$var$Section.getCollectionNode = _regeneratorRuntime.mark(function getCollectionNode(props) {\n  var children, title, items1;\n  return _regeneratorRuntime.wrap(function getCollectionNode$(_context4) {\n    while (1) {\n      switch (_context4.prev = _context4.next) {\n        case 0:\n          children = props.children, title = props.title, items1 = props.items;\n          _context4.next = 3;\n          return {\n            type: 'section',\n            hasChildNodes: true,\n            rendered: title,\n            'aria-label': props['aria-label'],\n            childNodes: _regeneratorRuntime.mark(function childNodes() {\n              var _iterator2, _step2, item, items;\n\n              return _regeneratorRuntime.wrap(function childNodes$(_context3) {\n                while (1) {\n                  switch (_context3.prev = _context3.next) {\n                    case 0:\n                      if (!(typeof children === 'function')) {\n                        _context3.next = 12;\n                        break;\n                      }\n\n                      if (items1) {\n                        _context3.next = 3;\n                        break;\n                      }\n\n                      throw new Error('props.children was a function but props.items is missing');\n\n                    case 3:\n                      _iterator2 = _createForOfIteratorHelperLoose(items1);\n\n                    case 4:\n                      if ((_step2 = _iterator2()).done) {\n                        _context3.next = 10;\n                        break;\n                      }\n\n                      item = _step2.value;\n                      _context3.next = 8;\n                      return {\n                        type: 'item',\n                        value: item,\n                        renderer: children\n                      };\n\n                    case 8:\n                      _context3.next = 4;\n                      break;\n\n                    case 10:\n                      _context3.next = 15;\n                      break;\n\n                    case 12:\n                      items = [];\n                      $hGDng$react.Children.forEach(children, function (child) {\n                        items.push({\n                          type: 'item',\n                          element: child\n                        });\n                      });\n                      return _context3.delegateYield(items, \"t0\", 15);\n\n                    case 15:\n                    case \"end\":\n                      return _context3.stop();\n                  }\n                }\n              }, childNodes);\n            })\n          };\n\n        case 3:\n        case \"end\":\n          return _context4.stop();\n      }\n    }\n  }, getCollectionNode);\n});\nvar $591e4228be66f7fb$export$6e2c8f0811a474ce = $591e4228be66f7fb$var$Section;\nvar $b8582cc7aa33d0e8$exports = {};\nvar $b0e94ff142179e1f$exports = {};\n$parcel$export($b0e94ff142179e1f$exports, \"useCollection\", function () {\n  return $b0e94ff142179e1f$export$6cd28814d92fa9c9;\n});\n\nvar $0ef13e8a225e58db$export$bf788dd355e3a401 = function () {\n  function $0ef13e8a225e58db$export$bf788dd355e3a401() {\n    _classCallCheck(this, $0ef13e8a225e58db$export$bf788dd355e3a401);\n\n    this.cache = new WeakMap();\n  }\n\n  _createClass($0ef13e8a225e58db$export$bf788dd355e3a401, [{\n    key: \"build\",\n    value: function build(props, context) {\n      var _this = this;\n\n      this.context = context;\n      return $0ef13e8a225e58db$var$iterable(function () {\n        return _this.iterateCollection(props);\n      });\n    }\n  }, {\n    key: \"iterateCollection\",\n    value: _regeneratorRuntime.mark(function iterateCollection(props) {\n      var children, items, _iterator3, _step3, item, _items, index, _i, _items2, _item, nodes, _iterator4, _step4, node;\n\n      return _regeneratorRuntime.wrap(function iterateCollection$(_context5) {\n        while (1) {\n          switch (_context5.prev = _context5.next) {\n            case 0:\n              children = props.children, items = props.items;\n\n              if (!(typeof children === 'function')) {\n                _context5.next = 12;\n                break;\n              }\n\n              if (items) {\n                _context5.next = 4;\n                break;\n              }\n\n              throw new Error('props.children was a function but props.items is missing');\n\n            case 4:\n              _iterator3 = _createForOfIteratorHelperLoose(props.items);\n\n            case 5:\n              if ((_step3 = _iterator3()).done) {\n                _context5.next = 10;\n                break;\n              }\n\n              item = _step3.value;\n              return _context5.delegateYield(this.getFullNode({\n                value: item\n              }, {\n                renderer: children\n              }), \"t0\", 8);\n\n            case 8:\n              _context5.next = 5;\n              break;\n\n            case 10:\n              _context5.next = 30;\n              break;\n\n            case 12:\n              _items = [];\n              $hGDng$react.Children.forEach(children, function (child) {\n                _items.push(child);\n              });\n              index = 0;\n              _i = 0, _items2 = _items;\n\n            case 16:\n              if (!(_i < _items2.length)) {\n                _context5.next = 30;\n                break;\n              }\n\n              _item = _items2[_i];\n              nodes = this.getFullNode({\n                element: _item,\n                index: index\n              }, {});\n              _iterator4 = _createForOfIteratorHelperLoose(nodes);\n\n            case 20:\n              if ((_step4 = _iterator4()).done) {\n                _context5.next = 27;\n                break;\n              }\n\n              node = _step4.value;\n              index++;\n              _context5.next = 25;\n              return node;\n\n            case 25:\n              _context5.next = 20;\n              break;\n\n            case 27:\n              _i++;\n              _context5.next = 16;\n              break;\n\n            case 30:\n            case \"end\":\n              return _context5.stop();\n          }\n        }\n      }, iterateCollection, this);\n    })\n  }, {\n    key: \"getKey\",\n    value: function getKey(item, partialNode, state, parentKey) {\n      if (item.key != null) return item.key;\n      if (partialNode.type === 'cell' && partialNode.key != null) return \"\" + parentKey + partialNode.key;\n      var v = partialNode.value;\n\n      if (v != null) {\n        var _v$key;\n\n        var key = (_v$key = v.key) != null ? _v$key : v.id;\n        if (key == null) throw new Error('No key found for item');\n        return key;\n      }\n\n      return parentKey ? parentKey + \".\" + partialNode.index : \"$.\" + partialNode.index;\n    }\n  }, {\n    key: \"getChildState\",\n    value: function getChildState(state, partialNode) {\n      return {\n        renderer: partialNode.renderer || state.renderer\n      };\n    }\n  }, {\n    key: \"getFullNode\",\n    value: _regeneratorRuntime.mark(function getFullNode(partialNode, state, parentKey, parentNode) {\n      var element, cached, type, name, _childNodes, index, result, childNode, nodeKey, nodes, children, _iterator5, _step5, _node, builder, node;\n\n      return _regeneratorRuntime.wrap(function getFullNode$(_context7) {\n        while (1) {\n          switch (_context7.prev = _context7.next) {\n            case 0:\n              element = partialNode.element;\n\n              if (!(!element && partialNode.value && state && state.renderer)) {\n                _context7.next = 10;\n                break;\n              }\n\n              cached = this.cache.get(partialNode.value);\n\n              if (!(cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context)))) {\n                _context7.next = 9;\n                break;\n              }\n\n              cached.index = partialNode.index;\n              cached.parentKey = parentNode ? parentNode.key : null;\n              _context7.next = 8;\n              return cached;\n\n            case 8:\n              return _context7.abrupt(\"return\");\n\n            case 9:\n              element = state.renderer(partialNode.value);\n\n            case 10:\n              if (!$hGDng$react.isValidElement(element)) {\n                _context7.next = 41;\n                break;\n              }\n\n              type = element.type;\n\n              if (!(typeof type !== 'function' && typeof type.getCollectionNode !== 'function')) {\n                _context7.next = 15;\n                break;\n              }\n\n              name = typeof element.type === 'function' ? element.type.name : element.type;\n              throw new Error(\"Unknown element <\" + name + \"> in collection.\");\n\n            case 15:\n              _childNodes = type.getCollectionNode(element.props, this.context);\n              index = partialNode.index;\n              result = _childNodes.next();\n\n            case 18:\n              if (!(!result.done && result.value)) {\n                _context7.next = 40;\n                break;\n              }\n\n              childNode = result.value;\n              partialNode.index = index;\n              nodeKey = childNode.key;\n              if (!nodeKey) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);\n              nodes = this.getFullNode(_objectSpread(_objectSpread({}, childNode), {}, {\n                key: nodeKey,\n                index: index,\n                wrapper: $0ef13e8a225e58db$var$compose(partialNode.wrapper, childNode.wrapper)\n              }), this.getChildState(state, childNode), parentKey ? \"\" + parentKey + element.key : element.key, parentNode);\n              children = _toConsumableArray(nodes);\n              _iterator5 = _createForOfIteratorHelperLoose(children);\n\n            case 26:\n              if ((_step5 = _iterator5()).done) {\n                _context7.next = 37;\n                break;\n              }\n\n              _node = _step5.value;\n              _node.value = childNode.value || partialNode.value;\n              if (_node.value) this.cache.set(_node.value, _node);\n\n              if (!(partialNode.type && _node.type !== partialNode.type)) {\n                _context7.next = 32;\n                break;\n              }\n\n              throw new Error(\"Unsupported type <\" + $0ef13e8a225e58db$var$capitalize(_node.type) + \"> in <\" + $0ef13e8a225e58db$var$capitalize(parentNode.type) + \">. Only <\" + $0ef13e8a225e58db$var$capitalize(partialNode.type) + \"> is supported.\");\n\n            case 32:\n              index++;\n              _context7.next = 35;\n              return _node;\n\n            case 35:\n              _context7.next = 26;\n              break;\n\n            case 37:\n              result = _childNodes.next(children);\n              _context7.next = 18;\n              break;\n\n            case 40:\n              return _context7.abrupt(\"return\");\n\n            case 41:\n              if (!(partialNode.key == null)) {\n                _context7.next = 43;\n                break;\n              }\n\n              return _context7.abrupt(\"return\");\n\n            case 43:\n              builder = this;\n              node = {\n                type: partialNode.type,\n                props: partialNode.props,\n                key: partialNode.key,\n                parentKey: parentNode ? parentNode.key : null,\n                value: partialNode.value,\n                level: parentNode ? parentNode.level + 1 : 0,\n                index: partialNode.index,\n                rendered: partialNode.rendered,\n                textValue: partialNode.textValue,\n                'aria-label': partialNode['aria-label'],\n                wrapper: partialNode.wrapper,\n                shouldInvalidate: partialNode.shouldInvalidate,\n                hasChildNodes: partialNode.hasChildNodes,\n                childNodes: $0ef13e8a225e58db$var$iterable(_regeneratorRuntime.mark(function _callee() {\n                  var index, _iterator6, _step6, child, _nodes, _iterator7, _step7, node1;\n\n                  return _regeneratorRuntime.wrap(function _callee$(_context6) {\n                    while (1) {\n                      switch (_context6.prev = _context6.next) {\n                        case 0:\n                          if (partialNode.hasChildNodes) {\n                            _context6.next = 2;\n                            break;\n                          }\n\n                          return _context6.abrupt(\"return\");\n\n                        case 2:\n                          index = 0;\n                          _iterator6 = _createForOfIteratorHelperLoose(partialNode.childNodes());\n\n                        case 4:\n                          if ((_step6 = _iterator6()).done) {\n                            _context6.next = 19;\n                            break;\n                          }\n\n                          child = _step6.value;\n                          if (child.key != null) child.key = \"\" + node.key + child.key;\n                          child.index = index;\n                          _nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n                          _iterator7 = _createForOfIteratorHelperLoose(_nodes);\n\n                        case 10:\n                          if ((_step7 = _iterator7()).done) {\n                            _context6.next = 17;\n                            break;\n                          }\n\n                          node1 = _step7.value;\n                          index++;\n                          _context6.next = 15;\n                          return node1;\n\n                        case 15:\n                          _context6.next = 10;\n                          break;\n\n                        case 17:\n                          _context6.next = 4;\n                          break;\n\n                        case 19:\n                        case \"end\":\n                          return _context6.stop();\n                      }\n                    }\n                  }, _callee);\n                }))\n              };\n              _context7.next = 47;\n              return node;\n\n            case 47:\n            case \"end\":\n              return _context7.stop();\n          }\n        }\n      }, getFullNode, this);\n    })\n  }]);\n\n  return $0ef13e8a225e58db$export$bf788dd355e3a401;\n}();\n\nfunction $0ef13e8a225e58db$var$iterable(iterator) {\n  var cache = [];\n  var iterable = null;\n  return _defineProperty({}, Symbol.iterator, _regeneratorRuntime.mark(function _callee2() {\n    var _iterator8, _step8, item, _iterator9, _step9, item1;\n\n    return _regeneratorRuntime.wrap(function _callee2$(_context8) {\n      while (1) {\n        switch (_context8.prev = _context8.next) {\n          case 0:\n            _iterator8 = _createForOfIteratorHelperLoose(cache);\n\n          case 1:\n            if ((_step8 = _iterator8()).done) {\n              _context8.next = 7;\n              break;\n            }\n\n            item = _step8.value;\n            _context8.next = 5;\n            return item;\n\n          case 5:\n            _context8.next = 1;\n            break;\n\n          case 7:\n            if (!iterable) iterable = iterator();\n            _iterator9 = _createForOfIteratorHelperLoose(iterable);\n\n          case 9:\n            if ((_step9 = _iterator9()).done) {\n              _context8.next = 16;\n              break;\n            }\n\n            item1 = _step9.value;\n            cache.push(item1);\n            _context8.next = 14;\n            return item1;\n\n          case 14:\n            _context8.next = 9;\n            break;\n\n          case 16:\n          case \"end\":\n            return _context8.stop();\n        }\n      }\n    }, _callee2);\n  }));\n}\n\nfunction $0ef13e8a225e58db$var$compose(outer, inner) {\n  if (outer && inner) return function (element) {\n    return outer(inner(element));\n  };\n  if (outer) return outer;\n  if (inner) return inner;\n}\n\nfunction $0ef13e8a225e58db$var$capitalize(str) {\n  return str[0].toUpperCase() + str.slice(1);\n}\n\nfunction $b0e94ff142179e1f$export$6cd28814d92fa9c9(props, factory, context) {\n  var invalidators = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];\n  var builder = $hGDng$useMemo(function () {\n    return new $0ef13e8a225e58db$export$bf788dd355e3a401();\n  }, []);\n  var prev = $hGDng$useRef(null);\n  return $hGDng$useMemo(function () {\n    var nodes = builder.build(props, context);\n    prev.current = factory(nodes, prev.current);\n    return prev.current;\n  }, [builder, props.children, props.items, context].concat(_toConsumableArray(invalidators)));\n}\n\nvar $a5bc6066b2ba167e$exports = {};\n$parcel$export($a5bc6066b2ba167e$exports, \"getItemCount\", function () {\n  return $a5bc6066b2ba167e$export$77d5aafae4e095b2;\n});\nvar $a5bc6066b2ba167e$var$cache = new WeakMap();\n\nfunction $a5bc6066b2ba167e$export$77d5aafae4e095b2(collection) {\n  var count = $a5bc6066b2ba167e$var$cache.get(collection);\n  if (count != null) return count;\n  count = 0;\n\n  for (var _iterator10 = _createForOfIteratorHelperLoose(collection), _step10; !(_step10 = _iterator10()).done;) {\n    var item = _step10.value;\n    if (item.type === 'section') count += $a5bc6066b2ba167e$export$77d5aafae4e095b2(item.childNodes);else count++;\n  }\n\n  $a5bc6066b2ba167e$var$cache.set(collection, count);\n  return count;\n}\n\nexport { $d80587bf41d0fb18$export$6d08773d2e66f8f2 as Item, $591e4228be66f7fb$export$6e2c8f0811a474ce as Section, $b0e94ff142179e1f$export$6cd28814d92fa9c9 as useCollection, $a5bc6066b2ba167e$export$77d5aafae4e095b2 as getItemCount };","map":{"version":3,"sources":["packages/@react-stately/collections/src/Item.ts","packages/@react-stately/collections/src/Section.ts","packages/@react-stately/collections/src/useCollection.ts","packages/@react-stately/collections/src/CollectionBuilder.ts","packages/@react-stately/collections/src/getItemCount.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAgBS,0B,CAAQ,K,EAAmC;AAClD,SAAO,IAAP;AACD;;AAED,0BAAI,CAAC,iBAAL,4BAAyB,SAAU,iBAAV,CAA+B,KAA/B,EAAoD,OAApD;AAAA;AAAA;AAAA;AAAA;AAAA;AAClB,UAAA,UADkB,GACa,KADb,CAClB,UADkB,EACN,KADM,GACa,KADb,CACR,KADQ,EACC,QADD,GACa,KADb,CACD,QADC;AAGnB,UAAA,QAHmB,GAGR,KAAK,CAAC,KAAN,IAAe,KAAK,CAAC,QAHb;AAInB,UAAA,SAJmB,GAIP,KAAK,CAAC,SAAN,KAAoB,OAAO,QAAP,KAAoB,QAApB,GAA+B,QAA/B,GAA0C,EAA9D,KAAqE,KAAK,CAAC,YAAD,CAA1E,IAA4F,EAJrF;AAOvB,cAAE,CAAG,SAAH,IAAY,EAAK,OAAL,YAAK,OAAO,CAAE,wBAAd,CAAd,EACE,OAAO,CAAC,IAAR,CAAa,wHAAb;AARqB;iBAWjB;AACJ,YAAA,IAAI,EAAE,MADF;AAEJ,YAAA,KAAK,EAAE,KAFH;sBAGJ,QAHI;uBAIJ,SAJI;AAKJ,0BAAc,KAAK,CAAC,YAAD,CALf;AAMJ,YAAA,aAAa,EAAE,mCAAa,CAAC,KAAD,CANxB;AAOH,YAAA,UAPG;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,2BAQE,UARF;AAAA;AAAA;AAAA;;AAAA,kEASkB,UATlB;;AAAA;AAAA;AAAA;AAAA;AAAA;;AASS,sBAAA,MATT;AAAA;AAS4B,6BACpB;AACJ,wBAA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KAAR,CAAc,KAAd,EAAqB,OAArB,CAAZ;AACA,IAAA,IAAI,CAAC,OAAL,GAAe,OAAO,CAAC,KAAD,EAAQ,IAAI,CAAC,OAAb,CAAtB;AACA,WAAO,IAAI,CAAC,OAAZ;AAGD,GANa,GAMV,OANU,EAMD,KAAK,CAAC,QANL,EAMe,KAAK,CAAC,KANrB,EAM4B,OAN5B,4BAMwC,YANxC,GAAd;AAOD;;;;;;AEfD,IAAM,2BAAK,GAAG,IAAI,OAAJ,EAAd;;SAEgB,yC,CAAgB,U,EAAuC;AACrE,MAAI,KAAK,GAAG,2BAAK,CAAC,GAAN,CAAU,UAAV,CAAZ;AACA,MAAI,KAAK,IAAI,IAAb,EACE,OAAO,KAAP;AAGF,EAAA,KAAK,GAAG,CAAR;;AACA,yDAAiB,UAAjB;AAAA,QAAS,IAAT;AACE,QAAI,IAAI,CAAC,IAAL,KAAc,SAAlB,EACE,KAAK,IAAI,yCAAY,CAAC,IAAI,CAAC,UAAN,CAArB,CADF,KAGE,KAAK;AAJT;;AAQA,EAAA,2BAAK,CAAC,GAAN,CAAU,UAAV,EAAsB,KAAtB;AACA,SAAO,KAAP;AACD","sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ItemElement, ItemProps} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\n\nfunction Item<T>(props: ItemProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n  return null;\n}\n\nItem.getCollectionNode = function* getCollectionNode<T>(props: ItemProps<T>, context: any): Generator<PartialNode<T>> {\n  let {childItems, title, children} = props;\n\n  let rendered = props.title || props.children;\n  let textValue = props.textValue || (typeof rendered === 'string' ? rendered : '') || props['aria-label'] || '';\n\n  // suppressTextValueWarning is used in components like Tabs, which don't have type to select support.\n  if (!textValue && !context?.suppressTextValueWarning) {\n    console.warn('<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.');\n  }\n\n  yield {\n    type: 'item',\n    props: props,\n    rendered,\n    textValue,\n    'aria-label': props['aria-label'],\n    hasChildNodes: hasChildItems(props),\n    *childNodes() {\n      if (childItems) {\n        for (let child of childItems) {\n          yield {\n            type: 'item',\n            value: child\n          };\n        }\n      } else if (title) {\n        let items: PartialNode<T>[] = [];\n        React.Children.forEach(children, child => {\n          items.push({\n            type: 'item',\n            element: child as ItemElement<T>\n          });\n        });\n\n        yield* items;\n      }\n    }\n  };\n};\n\nfunction hasChildItems<T>(props: ItemProps<T>) {\n  if (props.hasChildItems != null) {\n    return props.hasChildItems;\n  }\n\n  if (props.childItems) {\n    return true;\n  }\n\n  if (props.title && React.Children.count(props.children) > 0) {\n    return true;\n  }\n\n  return false;\n}\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Item = Item as <T>(props: ItemProps<T>) => JSX.Element;\nexport {_Item as Item};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {PartialNode} from './types';\nimport React, {ReactElement} from 'react';\nimport {SectionProps} from '@react-types/shared';\n\nfunction Section<T>(props: SectionProps<T>): ReactElement { // eslint-disable-line @typescript-eslint/no-unused-vars\n  return null;\n}\n\nSection.getCollectionNode = function* getCollectionNode<T>(props: SectionProps<T>): Generator<PartialNode<T>> {\n  let {children, title, items} = props;\n  yield {\n    type: 'section',\n    hasChildNodes: true,\n    rendered: title,\n    'aria-label': props['aria-label'],\n    *childNodes() {\n      if (typeof children === 'function') {\n        if (!items) {\n          throw new Error('props.children was a function but props.items is missing');\n        }\n    \n        for (let item of items) {\n          yield {\n            type: 'item',\n            value: item,\n            renderer: children\n          };\n        }\n      } else {\n        let items: PartialNode<T>[] = [];\n        React.Children.forEach(children, child => {\n          items.push({\n            type: 'item',\n            element: child\n          });\n        });\n\n        yield* items;\n      }\n    }\n  };\n};\n\n// We don't want getCollectionNode to show up in the type definition\nlet _Section = Section as <T>(props: SectionProps<T>) => JSX.Element;\nexport {_Section as Section};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, CollectionBase, Node} from '@react-types/shared';\nimport {CollectionBuilder} from './CollectionBuilder';\nimport {useMemo, useRef} from 'react';\n\ntype CollectionFactory<T, C extends Collection<Node<T>>> = (node: Iterable<Node<T>>, prev: C | null) => C;\n\nexport function useCollection<T extends object, C extends Collection<Node<T>> = Collection<Node<T>>>(props: CollectionBase<T>, factory: CollectionFactory<T, C>, context?: unknown, invalidators: Array<any> = []): C {\n  let builder = useMemo(() => new CollectionBuilder<T>(), []);\n\n  let prev = useRef<C>(null);\n  return useMemo(() => {\n    let nodes = builder.build(props, context);\n    prev.current = factory(nodes, prev.current);\n    return prev.current;\n  // Don't invalidate when any prop changes, just the two we care about.\n  // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [builder, props.children, props.items, context, ...invalidators]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CollectionBase, CollectionElement, Node} from '@react-types/shared';\nimport {PartialNode} from './types';\nimport React, {Key, ReactElement} from 'react';\n\ninterface CollectionBuilderState {\n  renderer?: (value: any) => ReactElement\n}\n\nexport class CollectionBuilder<T extends object> {\n  private context?: unknown;\n  private cache: WeakMap<T, Node<T>> = new WeakMap();\n\n  build(props: CollectionBase<T>, context?: unknown) {\n    this.context = context;\n    return iterable(() => this.iterateCollection(props));\n  }\n\n  private *iterateCollection(props: CollectionBase<T>) {\n    let {children, items} = props;\n\n    if (typeof children === 'function') {\n      if (!items) {\n        throw new Error('props.children was a function but props.items is missing');\n      }\n\n      for (let item of props.items) {\n        yield* this.getFullNode({\n          value: item\n        }, {renderer: children});\n      }\n    } else {\n      let items: CollectionElement<T>[] = [];\n      React.Children.forEach(children, child => {\n        items.push(child);\n      });\n\n      let index = 0;\n      for (let item of items) {\n        let nodes = this.getFullNode({\n          element: item,\n          index: index\n        }, {});\n\n        for (let node of nodes) {\n          index++;\n          yield node;\n        }\n      }\n    }\n  }\n\n  private getKey(item: CollectionElement<T>, partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key): Key {\n    if (item.key != null) {\n      return item.key;\n    }\n\n    if (partialNode.type === 'cell' && partialNode.key != null) {\n      return `${parentKey}${partialNode.key}`;\n    }\n\n    let v = partialNode.value as any;\n    if (v != null) {\n      let key = v.key ?? v.id;\n      if (key == null) {\n        throw new Error('No key found for item');\n      }\n\n      return key;\n    }\n\n    return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;\n  }\n\n  private getChildState(state: CollectionBuilderState, partialNode: PartialNode<T>) {\n    return {\n      renderer: partialNode.renderer || state.renderer\n    };\n  }\n\n  private *getFullNode(partialNode: PartialNode<T>, state: CollectionBuilderState, parentKey?: Key, parentNode?: Node<T>): Generator<Node<T>> {\n    // If there's a value instead of an element on the node, and a parent renderer function is available,\n    // use it to render an element for the value.\n    let element = partialNode.element;\n    if (!element && partialNode.value && state && state.renderer) {\n      let cached = this.cache.get(partialNode.value);\n      if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {\n        cached.index = partialNode.index;\n        cached.parentKey = parentNode ? parentNode.key : null;\n        yield cached;\n        return;\n      }\n\n      element = state.renderer(partialNode.value);\n    }\n\n    // If there's an element with a getCollectionNode function on its type, then it's a supported component.\n    // Call this function to get a partial node, and recursively build a full node from there.\n    if (React.isValidElement(element)) {\n      let type = element.type as any;\n      if (typeof type !== 'function' && typeof type.getCollectionNode !== 'function') {\n        let name = typeof element.type === 'function' ? element.type.name : element.type;\n        throw new Error(`Unknown element <${name}> in collection.`);\n      }\n\n      let childNodes = type.getCollectionNode(element.props, this.context) as Generator<PartialNode<T>, void, Node<T>[]>;\n      let index = partialNode.index;\n      let result = childNodes.next();\n      while (!result.done && result.value) {\n        let childNode = result.value;\n\n        partialNode.index = index;\n\n        let nodeKey = childNode.key;\n        if (!nodeKey) {\n          nodeKey = childNode.element ? null : this.getKey(element as CollectionElement<T>, partialNode, state, parentKey);\n        }\n\n        let nodes = this.getFullNode({\n          ...childNode,\n          key: nodeKey,\n          index,\n          wrapper: compose(partialNode.wrapper, childNode.wrapper)\n        }, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);\n\n        let children = [...nodes];\n        for (let node of children) {\n          // Cache the node based on its value\n          node.value = childNode.value || partialNode.value;\n          if (node.value) {\n            this.cache.set(node.value, node);\n          }\n\n          // The partial node may have specified a type for the child in order to specify a constraint.\n          // Verify that the full node that was built recursively matches this type.\n          if (partialNode.type && node.type !== partialNode.type) {\n            throw new Error(`Unsupported type <${capitalize(node.type)}> in <${capitalize(parentNode.type)}>. Only <${capitalize(partialNode.type)}> is supported.`);\n          }\n\n          index++;\n          yield node;\n        }\n\n        result = childNodes.next(children);\n      }\n\n      return;\n    }\n\n    // Ignore invalid elements\n    if (partialNode.key == null) {\n      return;\n    }\n\n    // Create full node\n    let builder = this;\n    let node: Node<T> = {\n      type: partialNode.type,\n      props: partialNode.props,\n      key: partialNode.key,\n      parentKey: parentNode ? parentNode.key : null,\n      value: partialNode.value,\n      level: parentNode ? parentNode.level + 1 : 0,\n      index: partialNode.index,\n      rendered: partialNode.rendered,\n      textValue: partialNode.textValue,\n      'aria-label': partialNode['aria-label'],\n      wrapper: partialNode.wrapper,\n      shouldInvalidate: partialNode.shouldInvalidate,\n      hasChildNodes: partialNode.hasChildNodes,\n      childNodes: iterable(function *() {\n        if (!partialNode.hasChildNodes) {\n          return;\n        }\n\n        let index = 0;\n        for (let child of partialNode.childNodes()) {\n          // Ensure child keys are globally unique by prepending the parent node's key\n          if (child.key != null) {\n            child.key = `${node.key}${child.key}`;\n          }\n\n          child.index = index;\n          let nodes = builder.getFullNode(child, builder.getChildState(state, child), node.key, node);\n          for (let node of nodes) {\n            index++;\n            yield node;\n          }\n        }\n      })\n    };\n\n    yield node;\n  }\n}\n\n// Wraps an iterator function as an iterable object, and caches the results.\nfunction iterable<T>(iterator: () => IterableIterator<Node<T>>): Iterable<Node<T>> {\n  let cache = [];\n  let iterable = null;\n  return {\n    *[Symbol.iterator]() {\n      for (let item of cache) {\n        yield item;\n      }\n\n      if (!iterable) {\n        iterable = iterator();\n      }\n\n      for (let item of iterable) {\n        cache.push(item);\n        yield item;\n      }\n    }\n  };\n}\n\ntype Wrapper = (element: ReactElement) => ReactElement;\nfunction compose(outer: Wrapper | void, inner: Wrapper | void): Wrapper {\n  if (outer && inner) {\n    return (element) => outer(inner(element));\n  }\n\n  if (outer) {\n    return outer;\n  }\n\n  if (inner) {\n    return inner;\n  }\n}\n\nfunction capitalize(str: string) {\n  return str[0].toUpperCase() + str.slice(1);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Node} from '@react-types/shared';\n\nconst cache = new WeakMap<Iterable<unknown>, number>();\n\nexport function getItemCount<T>(collection: Iterable<Node<T>>): number {\n  let count = cache.get(collection);\n  if (count != null) {\n    return count;\n  }\n\n  count = 0;\n  for (let item of collection) {\n    if (item.type === 'section') {\n      count += getItemCount(item.childNodes);\n    } else {\n      count++;\n    }\n  }\n\n  cache.set(collection, count);\n  return count;\n}\n"]},"metadata":{},"sourceType":"module"}