{"version":3,"file":"components/TextDrawer/duplicate.mjs","sources":["../../../src/components/TextDrawer/duplicate.tsx"],"sourcesContent":["import { Col, Row, Space, Tooltip, Typography } from 'antd';\nimport React from 'react';\nimport { Rule, SDK } from '@rsdoctor/types';\nimport { ExceptionOutlined } from '@ant-design/icons';\nimport { Alerts } from '@rsdoctor/utils/common';\nimport { Size } from '../../constants';\nimport { TextDrawer, TextDrawerProps } from './index';\nimport {\n  PackageRelationAlert,\n  PackageRelationReasons,\n  PackageRelationReasonsWithServer,\n} from '../Alert/package-relation';\nimport { PackageRelationAlertProps } from '../Alert/types';\nimport { ServerAPIProvider } from '../Manifest';\n\ninterface DuplicatePackageDrawerContentProps extends Omit<TextDrawerProps, 'text'> {\n  duplicatePackages: Rule.PackageRelationDiffRuleStoreData[];\n  cwd: string;\n  textStyle?: React.CSSProperties;\n  children: PackageRelationAlertProps['getPackageRelationContentComponent'];\n}\n\ninterface DuplicatePackageDrawerProps extends Omit<DuplicatePackageDrawerContentProps, 'children'> {\n  moduleGraph: Pick<SDK.ModuleGraphData, 'dependencies' | 'modules'>;\n  moduleCodeMap: SDK.ModuleCodeData;\n}\n\nconst DuplicatePackageDrawerContent: React.FC<DuplicatePackageDrawerContentProps> = ({\n  duplicatePackages = [],\n  cwd,\n  children,\n  ...props\n}) => {\n  return (\n    <TextDrawer\n      {...props}\n      buttonStyle={{ fontSize: 'inherit', ...props.buttonStyle }}\n      buttonProps={{ type: 'text', ...props.buttonProps }}\n      text={\n        <Tooltip title=\"Click to show the details of duplicate packages\">\n          <Space style={{ fontSize: 'inherit' }}>\n            <Typography.Text strong style={{ fontSize: 'inherit', color: 'inherit', ...props.textStyle }}>\n              {duplicatePackages.length}\n            </Typography.Text>\n            <ExceptionOutlined />\n          </Space>\n        </Tooltip>\n      }\n      drawerProps={{ title: 'Duplicate Packages Viewer', ...props.drawerProps }}\n    >\n      <Row gutter={[Size.BasePadding, Size.BasePadding]}>\n        {duplicatePackages.map((err, i) => {\n          return (\n            <Col span={24} key={i}>\n              <PackageRelationAlert data={err} cwd={cwd} getPackageRelationContentComponent={children} />\n            </Col>\n          );\n        })}\n      </Row>\n    </TextDrawer>\n  );\n};\n\nexport const DuplicatePackageDrawer: React.FC<DuplicatePackageDrawerProps> = ({ moduleGraph, ...props }) => {\n  return (\n    <DuplicatePackageDrawerContent {...props}>\n      {(res) => {\n        return (\n          <ServerAPIProvider\n            api={SDK.ServerAPI.API.GetModuleCodeByModuleIds}\n            body={{ moduleIds: moduleGraph.modules.map((mod) => mod.id) }}\n          >\n            {(moduleCodes) => (\n              <PackageRelationReasons\n                data={Alerts.getPackageRelationAlertDetails(\n                  moduleGraph.modules,\n                  moduleGraph.dependencies,\n                  props.cwd,\n                  res.package.dependencies,\n                  moduleCodes,\n                )}\n                cwd={props.cwd}\n              />\n            )}\n          </ServerAPIProvider>\n        );\n      }}\n    </DuplicatePackageDrawerContent>\n  );\n};\n\nexport const DuplicatePackageDrawerWithServer: React.FC<Omit<DuplicatePackageDrawerContentProps, 'children'>> = (\n  props,\n) => {\n  return (\n    <DuplicatePackageDrawerContent {...props}>\n      {(res) => {\n        return (\n          <PackageRelationReasonsWithServer body={{ id: res.data.id, target: res.package.target }} cwd={props.cwd} />\n        );\n      }}\n    </DuplicatePackageDrawerContent>\n  );\n};\n"],"names":["DuplicatePackageDrawerContent","duplicatePackages","cwd","children","props","TextDrawer","Tooltip","Space","Typography","ExceptionOutlined","Row","Size","err","i","Col","PackageRelationAlert","DuplicatePackageDrawer","moduleGraph","res","ServerAPIProvider","SDK","mod","moduleCodes","PackageRelationReasons","Alerts","DuplicatePackageDrawerWithServer","PackageRelationReasonsWithServer"],"mappings":";;;;;;;;;;AA2BA,MAAMA,gCAA8E,CAAC,EACnFC,oBAAoB,EAAE,EACtBC,GAAG,EACHC,QAAQ,EACR,GAAGC,OACJ,GACQ,WAAP,GACE,IAACC,YAAUA;QACR,GAAGD,KAAK;QACT,aAAa;YAAE,UAAU;YAAW,GAAGA,MAAM,WAAW;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