{"version":3,"sources":["../src/components/RatingDisplay/useRatingDisplay.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useRatingDisplayBase_unstable } from '@fluentui/react-rating';\n\nimport { RatingItem } from '../Rating';\nimport type { RatingDisplayProps, RatingDisplayState } from './RatingDisplay.types';\n\n/**\n * Returns the state for a RatingDisplay component, given its props and ref.\n * The returned state can be modified with hooks before being passed to `renderRatingDisplay`.\n */\nexport const useRatingDisplay = (props: RatingDisplayProps, ref: React.Ref<HTMLDivElement>): RatingDisplayState => {\n  const state = useRatingDisplayBase_unstable(\n    {\n      icon: 'span',\n      ...props,\n    },\n    ref,\n  );\n\n  const { compact, max } = state;\n\n  const rootChildren = React.useMemo(() => {\n    return compact ? (\n      <RatingItem value={1} key={1} aria-hidden={true} />\n    ) : (\n      Array.from(Array(max), (_, i) => <RatingItem value={i + 1} key={i + 1} aria-hidden={true} />)\n    );\n  }, [compact, max]);\n\n  state.root.children ??= rootChildren;\n\n  return state;\n};\n"],"names":["useRatingDisplay","props","ref","state","useRatingDisplayBase_unstable","icon","compact","max","rootChildren","React","useMemo","RatingItem","value","key","aria-hidden","Array","from","_","i","root","children"],"mappings":"AAAA;;;;;+BAYaA;;;eAAAA;;;;iEAVU;6BACuB;wBAEnB;AAOpB,MAAMA,mBAAmB,CAACC,OAA2BC;IAC1D,MAAMC,QAAQC,IAAAA,0CAA6B,EACzC;QACEC,MAAM;QACN,GAAGJ,KAAK;IACV,GACAC;IAGF,MAAM,EAAEI,OAAO,EAAEC,GAAG,EAAE,GAAGJ;IAEzB,MAAMK,eAAeC,OAAMC,OAAO,CAAC;QACjC,OAAOJ,wBACL,qBAACK,kBAAU;YAACC,OAAO;YAAGC,KAAK;YAAGC,eAAa;aAE3CC,MAAMC,IAAI,CAACD,MAAMR,MAAM,CAACU,GAAGC,kBAAM,qBAACP,kBAAU;gBAACC,OAAOM,IAAI;gBAAGL,KAAKK,IAAI;gBAAGJ,eAAa;;IAExF,GAAG;QAACR;QAASC;KAAI;IAEjBJ,MAAMgB,IAAI,CAACC,QAAQ,KAAKZ;IAExB,OAAOL;AACT"}