{"version":3,"file":"Predictions.stories.jsx","sourceRoot":"","sources":["../../../src/work/Predictions/Predictions.stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,eAAe;IACb,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,WAAW;CACf,CAAC;AAEV,MAAM,CAAC,MAAM,eAAe,GAAY,GAAG,EAAE;IAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAEtC,MAAM,sBAAsB,GAAG,WAAW,CACxC,CAAC,KAAa,EAAE,EAAE,CAChB,YAAY,CAAC,KAAK,EAAE;QAClB,MAAM;QACN,OAAO,EAAE;YACP,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,SAAS;SAChB;KACF,CAAC,EACJ,EAAE,CACH,CAAC;IAEF,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAmB;QACzE;YACE,EAAE,EAAE,GAAG;YACP,KAAK,EAAE,YAAY;YACnB,KAAK,EAAE,sBAAsB,CAAC,EAAE,CAAC;YACjC,cAAc,EAAE,CAAC,iBAAiB,CAAC,AAAD,EAAG;SACtC;QACD;YACE,EAAE,EAAE,GAAG;YACP,KAAK,EAAE,yCAAyC;YAChD,KAAK,EAAE,sBAAsB,CAAC,EAAE,CAAC;SAClC;QACD;YACE,EAAE,EAAE,GAAG;YACP,KAAK,EAAE,sBAAsB;YAC7B,KAAK,EAAE,sBAAsB,CAAC,EAAE,CAAC;SAClC;KACF,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9B,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChC,mBAAmB,CAAC;oBAClB,GAAG,gBAAgB;oBACnB;wBACE,EAAE,EAAE,GAAG;wBACP,KAAK,EAAE,qBAAqB;wBAC5B,KAAK,EAAE,sBAAsB,CAAC,EAAE,CAAC;qBAClC;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAE/C,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,EAAG,CAAC;AAClF,CAAC,CAAC","sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport { Predictions } from '@pega/cosmos-react-work';\nimport { formatNumber, useConfiguration } from '@pega/cosmos-react-core';\nimport type { PredictionItem } from '@pega/cosmos-react-work/lib/components/Predictions/Predictions.types';\n\nimport { FraudRiskRenderer } from './Predictions.mocks';\n\nexport default {\n  title: 'Work/Predictions',\n  component: Predictions\n} as Meta;\n\nexport const PredictionsDemo: StoryFn = () => {\n  const { locale } = useConfiguration();\n\n  const getFormattedPercentage = useCallback(\n    (value: number) =>\n      formatNumber(value, {\n        locale,\n        options: {\n          style: 'unit',\n          unit: 'percent'\n        }\n      }),\n    []\n  );\n\n  const [predictionsItems, setPredictionsItems] = useState<PredictionItem[]>([\n    {\n      id: '1',\n      label: 'Fraud risk',\n      value: getFormattedPercentage(76),\n      additionalInfo: <FraudRiskRenderer />\n    },\n    {\n      id: '2',\n      label: 'Predict the likehood of case completion',\n      value: getFormattedPercentage(73)\n    },\n    {\n      id: '3',\n      label: 'Probability to churn',\n      value: getFormattedPercentage(82)\n    }\n  ]);\n\n  useEffect(() => {\n    const timeout = setTimeout(() => {\n      if (predictionsItems.length < 4) {\n        setPredictionsItems([\n          ...predictionsItems,\n          {\n            id: '4',\n            label: 'Risk of missing SLA',\n            value: getFormattedPercentage(19)\n          }\n        ]);\n      }\n    }, 3000);\n    return () => clearTimeout(timeout);\n  }, [predictionsItems, getFormattedPercentage]);\n\n  return <Predictions count={predictionsItems.length} items={predictionsItems} />;\n};\n"]}