{"ast":null,"code":"import $6vYhU$react from \"react\";\nimport { createContextScope as $6vYhU$createContextScope } from \"@radix-ui/react-context\";\nimport { useComposedRefs as $6vYhU$useComposedRefs } from \"@radix-ui/react-compose-refs\";\nimport { Slot as $6vYhU$Slot } from \"@radix-ui/react-slot\";\n\n// We have resorted to returning slots directly rather than exposing primitives that can then\n// be slotted like `<CollectionItem as={Slot}>…</CollectionItem>`.\n// This is because we encountered issues with generic types that cannot be statically analysed\n// due to creating them dynamically via createCollection.\nfunction $e02a7d9cb1dc128c$export$c74125a8e3af6bb2(name) {\n  /* -----------------------------------------------------------------------------------------------\n  * CollectionProvider\n  * ---------------------------------------------------------------------------------------------*/\n  const PROVIDER_NAME = name + 'CollectionProvider';\n  const [createCollectionContext, createCollectionScope] = $6vYhU$createContextScope(PROVIDER_NAME);\n  const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {\n    collectionRef: {\n      current: null\n    },\n    itemMap: new Map()\n  });\n  const CollectionProvider = props => {\n    const {\n      scope: scope,\n      children: children\n    } = props;\n    const ref = $6vYhU$react.useRef(null);\n    const itemMap = $6vYhU$react.useRef(new Map()).current;\n    return /*#__PURE__*/$6vYhU$react.createElement(CollectionProviderImpl, {\n      scope: scope,\n      itemMap: itemMap,\n      collectionRef: ref\n    }, children);\n  };\n  /*#__PURE__*/\n  Object.assign(CollectionProvider, {\n    displayName: PROVIDER_NAME\n  });\n  /* -----------------------------------------------------------------------------------------------\n  * CollectionSlot\n  * ---------------------------------------------------------------------------------------------*/\n  const COLLECTION_SLOT_NAME = name + 'CollectionSlot';\n  const CollectionSlot = /*#__PURE__*/$6vYhU$react.forwardRef((props, forwardedRef) => {\n    const {\n      scope: scope,\n      children: children\n    } = props;\n    const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);\n    const composedRefs = $6vYhU$useComposedRefs(forwardedRef, context.collectionRef);\n    return /*#__PURE__*/$6vYhU$react.createElement($6vYhU$Slot, {\n      ref: composedRefs\n    }, children);\n  });\n  /*#__PURE__*/\n  Object.assign(CollectionSlot, {\n    displayName: COLLECTION_SLOT_NAME\n  });\n  /* -----------------------------------------------------------------------------------------------\n  * CollectionItem\n  * ---------------------------------------------------------------------------------------------*/\n  const ITEM_SLOT_NAME = name + 'CollectionItemSlot';\n  const ITEM_DATA_ATTR = 'data-radix-collection-item';\n  const CollectionItemSlot = /*#__PURE__*/$6vYhU$react.forwardRef((props, forwardedRef) => {\n    const {\n      scope: scope,\n      children: children,\n      ...itemData\n    } = props;\n    const ref = $6vYhU$react.useRef(null);\n    const composedRefs = $6vYhU$useComposedRefs(forwardedRef, ref);\n    const context = useCollectionContext(ITEM_SLOT_NAME, scope);\n    $6vYhU$react.useEffect(() => {\n      context.itemMap.set(ref, {\n        ref: ref,\n        ...itemData\n      });\n      return () => void context.itemMap.delete(ref);\n    });\n    return /*#__PURE__*/$6vYhU$react.createElement($6vYhU$Slot, {\n      [ITEM_DATA_ATTR]: '',\n      ref: composedRefs\n    }, children);\n  });\n  /*#__PURE__*/\n  Object.assign(CollectionItemSlot, {\n    displayName: ITEM_SLOT_NAME\n  });\n  /* -----------------------------------------------------------------------------------------------\n  * useCollection\n  * ---------------------------------------------------------------------------------------------*/\n  function useCollection(scope) {\n    const context = useCollectionContext(name + 'CollectionConsumer', scope);\n    const getItems = $6vYhU$react.useCallback(() => {\n      const collectionNode = context.collectionRef.current;\n      if (!collectionNode) return [];\n      const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));\n      const items = Array.from(context.itemMap.values());\n      const orderedItems = items.sort((a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current));\n      return orderedItems;\n    }, [context.collectionRef, context.itemMap]);\n    return getItems;\n  }\n  return [{\n    Provider: CollectionProvider,\n    Slot: CollectionSlot,\n    ItemSlot: CollectionItemSlot\n  }, useCollection, createCollectionScope];\n}\nexport { $e02a7d9cb1dc128c$export$c74125a8e3af6bb2 as createCollection };","map":{"version":3,"names":["$e02a7d9cb1dc128c$export$c74125a8e3af6bb2","createCollection","name","PROVIDER_NAME","createCollectionContext","createCollectionScope","$6vYhU$createContextScope","CollectionProviderImpl","useCollectionContext","collectionRef","current","itemMap","Map","CollectionProvider","props","scope","children","ref","$6vYhU$react","useRef","createElement","Object","assign","displayName","COLLECTION_SLOT_NAME","CollectionSlot","forwardRef","forwardedRef","context","composedRefs","$6vYhU$useComposedRefs","$6vYhU$Slot","ITEM_SLOT_NAME","ITEM_DATA_ATTR","CollectionItemSlot","itemData","useEffect","set","delete","useCollection","getItems","useCallback","collectionNode","orderedNodes","Array","from","querySelectorAll","items","values","orderedItems","sort","a","b","indexOf","Provider","Slot","ItemSlot"],"sources":["C:\\Users\\user\\Desktop\\000newport\\node_modules\\@radix-ui\\react-collection\\dist\\packages\\react\\collection\\src\\index.ts","C:\\Users\\user\\Desktop\\000newport\\node_modules\\@radix-ui\\react-collection\\dist\\packages\\react\\collection\\src\\Collection.tsx"],"sourcesContent":["export { createCollection } from './Collection';\nexport type { CollectionProps } from './Collection';\n","import React from 'react';\nimport { createContextScope } from '@radix-ui/react-context';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { Slot } from '@radix-ui/react-slot';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\ntype SlotProps = Radix.ComponentPropsWithoutRef<typeof Slot>;\ntype CollectionElement = HTMLElement;\ninterface CollectionProps extends SlotProps {\n  scope: any;\n}\n\n// We have resorted to returning slots directly rather than exposing primitives that can then\n// be slotted like `<CollectionItem as={Slot}>…</CollectionItem>`.\n// This is because we encountered issues with generic types that cannot be statically analysed\n// due to creating them dynamically via createCollection.\n\nfunction createCollection<ItemElement extends HTMLElement, ItemData = {}>(name: string) {\n  /* -----------------------------------------------------------------------------------------------\n   * CollectionProvider\n   * ---------------------------------------------------------------------------------------------*/\n\n  const PROVIDER_NAME = name + 'CollectionProvider';\n  const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);\n\n  type ContextValue = {\n    collectionRef: React.RefObject<CollectionElement>;\n    itemMap: Map<React.RefObject<ItemElement>, { ref: React.RefObject<ItemElement> } & ItemData>;\n  };\n\n  const [CollectionProviderImpl, useCollectionContext] = createCollectionContext<ContextValue>(\n    PROVIDER_NAME,\n    { collectionRef: { current: null }, itemMap: new Map() }\n  );\n\n  const CollectionProvider: React.FC<{ children?: React.ReactNode; scope: any }> = (props) => {\n    const { scope, children } = props;\n    const ref = React.useRef<CollectionElement>(null);\n    const itemMap = React.useRef<ContextValue['itemMap']>(new Map()).current;\n    return (\n      <CollectionProviderImpl scope={scope} itemMap={itemMap} collectionRef={ref}>\n        {children}\n      </CollectionProviderImpl>\n    );\n  };\n\n  CollectionProvider.displayName = PROVIDER_NAME;\n\n  /* -----------------------------------------------------------------------------------------------\n   * CollectionSlot\n   * ---------------------------------------------------------------------------------------------*/\n\n  const COLLECTION_SLOT_NAME = name + 'CollectionSlot';\n\n  const CollectionSlot = React.forwardRef<CollectionElement, CollectionProps>(\n    (props, forwardedRef) => {\n      const { scope, children } = props;\n      const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);\n      const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);\n      return <Slot ref={composedRefs}>{children}</Slot>;\n    }\n  );\n\n  CollectionSlot.displayName = COLLECTION_SLOT_NAME;\n\n  /* -----------------------------------------------------------------------------------------------\n   * CollectionItem\n   * ---------------------------------------------------------------------------------------------*/\n\n  const ITEM_SLOT_NAME = name + 'CollectionItemSlot';\n  const ITEM_DATA_ATTR = 'data-radix-collection-item';\n\n  type CollectionItemSlotProps = ItemData & {\n    children: React.ReactNode;\n    scope: any;\n  };\n\n  const CollectionItemSlot = React.forwardRef<ItemElement, CollectionItemSlotProps>(\n    (props, forwardedRef) => {\n      const { scope, children, ...itemData } = props;\n      const ref = React.useRef<ItemElement>(null);\n      const composedRefs = useComposedRefs(forwardedRef, ref);\n      const context = useCollectionContext(ITEM_SLOT_NAME, scope);\n\n      React.useEffect(() => {\n        context.itemMap.set(ref, { ref, ...(itemData as unknown as ItemData) });\n        return () => void context.itemMap.delete(ref);\n      });\n\n      return (\n        <Slot {...{ [ITEM_DATA_ATTR]: '' }} ref={composedRefs}>\n          {children}\n        </Slot>\n      );\n    }\n  );\n\n  CollectionItemSlot.displayName = ITEM_SLOT_NAME;\n\n  /* -----------------------------------------------------------------------------------------------\n   * useCollection\n   * ---------------------------------------------------------------------------------------------*/\n\n  function useCollection(scope: any) {\n    const context = useCollectionContext(name + 'CollectionConsumer', scope);\n\n    const getItems = React.useCallback(() => {\n      const collectionNode = context.collectionRef.current;\n      if (!collectionNode) return [];\n      const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));\n      const items = Array.from(context.itemMap.values());\n      const orderedItems = items.sort(\n        (a, b) => orderedNodes.indexOf(a.ref.current!) - orderedNodes.indexOf(b.ref.current!)\n      );\n      return orderedItems;\n    }, [context.collectionRef, context.itemMap]);\n\n    return getItems;\n  }\n\n  return [\n    { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },\n    useCollection,\n    createCollectionScope,\n  ] as const;\n}\n\nexport { createCollection };\nexport type { CollectionProps };\n"],"mappings":";;;;;ACaA;AACA;AACA;AACA;AAEA,SAASA,yCAATC,CAA0EC,IAA1E,EAAwF;EACtF;;;EAIA,MAAMC,aAAa,GAAGD,IAAI,GAAG,oBAA7B;EACA,MAAM,CAACE,uBAAD,EAA0BC,qBAA1B,IAAmDC,yBAAkB,CAACH,aAAD,CAA3E;EAOA,MAAM,CAACI,sBAAD,EAAyBC,oBAAzB,IAAiDJ,uBAAuB,CAC5ED,aAD4E,EAE5E;IAAEM,aAAa,EAAE;MAAEC,OAAO,EAAE;KAA5B;IAAoCC,OAAO,EAAE,IAAIC,GAAJ;GAF+B,CAA9E;EAKA,MAAMC,kBAAwE,GAAIC,KAAD,IAAW;IAC1F,MAAM;MArCVC,KAAA,EAqCYA,KAAF;MArCVC,QAAA,EAqCmBA;IAA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