{"version":3,"file":"Component-B83Wd5AE.mjs","sources":["../node_modules/es-toolkit/dist/compat/math/min.mjs","../src/components/ConversationMessage/extensions/NodeViews/TreemapChart/utils.ts","../src/components/ConversationMessage/extensions/NodeViews/TreemapChart/hooks/useTreemapNodeView.ts","../src/components/ConversationMessage/extensions/NodeViews/TreemapChart/Component.tsx"],"sourcesContent":["function min(items = []) {\n    let minElement = items[0];\n    let min = undefined;\n    for (let i = 0; i < items.length; i++) {\n        const element = items[i];\n        if (min == null || element < min) {\n            min = element;\n            minElement = element;\n        }\n    }\n    return minElement;\n}\n\nexport { min };\n","import type { ReportTreemapApiData, ReportTreemapNodeData } from '@antscorp/antsomi-charts';\nimport type { SourceField } from '@antscorp/antsomi-charts/es/components/Report/types';\n\nexport const formatReportPerfData = (rows: ReportTreemapApiData, metric: SourceField) => {\n\tconst result: ReportTreemapNodeData[] = [];\n\n\tfor (const row of rows) {\n\t\tconst itemData: ReportTreemapNodeData = {\n\t\t\taggregations: [],\n\t\t\tnodes: [],\n\t\t};\n\n\t\tif (Array.isArray(row.item)) {\n\t\t\tfor (const item of row.item) {\n\t\t\t\tif (item.aggregationType === 'none') {\n\t\t\t\t\titemData[item.name] = item.value;\n\t\t\t\t} else {\n\t\t\t\t\titemData.aggregations = [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: item.name,\n\t\t\t\t\t\t\ttype: item.aggregationType,\n\t\t\t\t\t\t\tvalue: item.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (row.nodes) {\n\t\t\titemData.nodes = formatReportPerfData(row.nodes, metric);\n\t\t}\n\n\t\tresult.push(itemData);\n\t}\n\n\treturn result;\n};\n","import type { NodeViewProps } from '@tiptap/react';\nimport { useMemo, useState } from 'react';\nimport { useDeepCompareEffect } from 'use-deep-compare';\nimport { useChartNodeView } from '@/hooks/useChartNodeView';\nimport { TreemapAttrsSchema } from '@/schemas/tiptap';\nimport type { TreemapAttrs } from '@/types/tiptap';\nimport { Utils } from '@/utils';\nimport { formatReportPerfData } from '../utils';\n\ntype Params = {\n\tnodeViewProps: NodeViewProps;\n};\n\nexport const useTreemapNodeView = (params: Params) => {\n\tconst { nodeViewProps } = params;\n\tconst {\n\t\textension: { options = {} },\n\t\tnode,\n\t} = nodeViewProps;\n\n\tconst messageId = `${options.messageId}`;\n\tconst dataSourceId = parseInt(options.dataSourceId, 10) || 0;\n\n\tconst [attrs, setAttrs] = useState<TreemapAttrs>();\n\n\tconst { data, dataSourceSchema, isLoading, error } = useChartNodeView({\n\t\tid: messageId,\n\t\tattrs,\n\t\tdataSourceId,\n\t\tenabled: !!attrs,\n\t});\n\n\tuseDeepCompareEffect(() => {\n\t\tsetAttrs(TreemapAttrsSchema.parse(node.attrs));\n\t}, [node.attrs]);\n\n\tconst serializedData = useMemo(() => {\n\t\tif (!(data && attrs && dataSourceSchema)) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst settings = Utils.nodeView.report.attrsToCompSetting({\n\t\t\tdataSourceSchema,\n\t\t\tattrs,\n\t\t});\n\n\t\treturn {\n\t\t\tdata: formatReportPerfData(data.rows, settings.metric[0]),\n\t\t\tsettings,\n\t\t};\n\t}, [data, attrs, dataSourceSchema]);\n\n\treturn { data: serializedData?.data, settings: serializedData?.settings, isLoading, error };\n};\n","import { Report } from '@antscorp/antsomi-charts';\nimport { Spin } from '@antscorp/antsomi-ui';\nimport { min } from 'es-toolkit/compat';\nimport type { ChartNodeViewProps } from '@/types/tiptap';\nimport { useTreemapNodeView } from './hooks';\n\nconst { Treemap } = Report;\n\nexport const TreemapNodeView = (props: ChartNodeViewProps) => {\n\tconst { chartWrapperSize, renderDropdownAction } = props;\n\n\tconst { data, settings, isLoading } = useTreemapNodeView({\n\t\tnodeViewProps: props,\n\t});\n\n\tif (isLoading || !data || !settings) {\n\t\treturn <Spin indicatorSize={20} />;\n\t}\n\n\tconst width = min([chartWrapperSize?.width, 500]);\n\n\treturn (\n\t\t<>\n\t\t\t<Treemap\n\t\t\t\tlevelToShow={settings.levelToShow}\n\t\t\t\theight={chartWrapperSize?.height}\n\t\t\t\twidth={width}\n\t\t\t\trenderMetric={settings.renderMetric}\n\t\t\t\tdimension={settings.dimension}\n\t\t\t\tdata={data}\n\t\t\t\tmode=\"VIEW\"\n\t\t\t/>\n\n\t\t\t{renderDropdownAction(data)}\n\t\t</>\n\t);\n};\n"],"names":["min","items","minElement","i","element","formatReportPerfData","rows","metric","result","row","itemData","item","useTreemapNodeView","params","nodeViewProps","options","node","messageId","dataSourceId","attrs","setAttrs","useState","data","dataSourceSchema","isLoading","error","useChartNodeView","useDeepCompareEffect","TreemapAttrsSchema","serializedData","useMemo","settings","Utils","Treemap","Report","TreemapNodeView","props","chartWrapperSize","renderDropdownAction","Spin","width"],"mappings":";;;;;;AAAA,SAASA,EAAIC,IAAQ,IAAI;AACrB,MAAIC,IAAaD,EAAM,CAAC,GACpBD;AACJ,WAASG,IAAI,GAAGA,IAAIF,EAAM,QAAQE,KAAK;AACnC,UAAMC,IAAUH,EAAME,CAAC;AACvB,KAAIH,KAAO,QAAQI,IAAUJ,OACzBA,IAAMI,GACNF,IAAaE;AAAA,EAErB;AACA,SAAOF;AACX;ACRO,MAAMG,IAAuB,CAACC,GAA4BC,MAAwB;AACxF,QAAMC,IAAkC,CAAA;AAExC,aAAWC,KAAOH,GAAM;AACvB,UAAMI,IAAkC;AAAA,MACvC,cAAc,CAAA;AAAA,MACd,OAAO,CAAA;AAAA,IAAC;AAGT,QAAI,MAAM,QAAQD,EAAI,IAAI;AACzB,iBAAWE,KAAQF,EAAI;AACtB,QAAIE,EAAK,oBAAoB,SAC5BD,EAASC,EAAK,IAAI,IAAIA,EAAK,QAE3BD,EAAS,eAAe;AAAA,UACvB;AAAA,YACC,MAAMC,EAAK;AAAA,YACX,MAAMA,EAAK;AAAA,YACX,OAAOA,EAAK;AAAA,UAAA;AAAA,QACb;AAMJ,IAAIF,EAAI,UACPC,EAAS,QAA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