// Copyright 2022 The Parca Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import {CompressionType, setCompressionCodec} from '@uwdata/flechette';
import * as lz4 from 'lz4js';

import MatchersInput from './MatchersInput';
import MetricsGraph, {type ContextMenuItemOrSubmenu, type Series} from './MetricsGraph';
import ProfileExplorer from './ProfileExplorer';
import ProfileTypeSelector from './ProfileTypeSelector';
import {SelectWithRefresh} from './SelectWithRefresh';
import SimpleMatchers from './SimpleMatchers';
import CustomSelect from './SimpleMatchers/Select';
import {
  LabelsQueryProvider,
  useLabelsQueryProvider,
  type LabelsQueryProviderContextType,
} from './contexts/LabelsQueryProvider';
import {UnifiedLabelsProvider, useUnifiedLabels} from './contexts/UnifiedLabelsContext';
import {useLabelNames} from './hooks/useLabels';
import {useQueryState} from './hooks/useQueryState';

setCompressionCodec(CompressionType.LZ4_FRAME, {
  encode: (data: Uint8Array) => lz4.compress(data),
  decode: (data: Uint8Array) => lz4.decompress(data),
});

export {useMetricsGraphDimensions} from './MetricsGraph/useMetricsGraphDimensions';

export * from './ProfileFlameChart';
export * from './ProfileFlameGraph';
export * from './ProfileSource';
export {
  convertToProtoFilters,
  convertFromProtoFilters,
  useProfileFilters,
  type ProfileFilter,
} from './ProfileView/components/ProfileFilters/useProfileFilters';
export * from './ProfileView';
export * from './ProfileViewWithData';
export * from './utils';
export * from './ProfileTypeSelector';
export * from './SourceView';
export * from './ProfileMetricsGraph';
export * from './useSumBy';
export {QueryControls} from './QueryControls';

export {default as ProfileFilters} from './ProfileView/components/ProfileFilters';
export {useProfileFiltersUrlState} from './ProfileView/components/ProfileFilters/useProfileFiltersUrlState';

export {useProfileTypes} from './ProfileSelector';

export {
  stringParam,
  boolParam,
  intParam,
  commaArrayParam,
  invertCallStackParser,
  groupByParser,
  flamechartDimensionParser,
  tableColumnsParser,
  hiddenBinariesParser,
  jsonParser,
} from './hooks/urlParsers';

export {useDashboardItems} from './hooks/useDashboardItems';
export {useColorBy} from './hooks/useColorBy';

export {
  ProfileExplorer,
  ProfileTypeSelector,
  CustomSelect,
  SelectWithRefresh,
  useLabelNames,
  MetricsGraph,
  SimpleMatchers,
  MatchersInput,
  type ContextMenuItemOrSubmenu,
  type Series,
  LabelsQueryProvider,
  useLabelsQueryProvider,
  UnifiedLabelsProvider,
  useUnifiedLabels,
  useQueryState,
  type LabelsQueryProviderContextType,
};
