"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useControlPanels = void 0; var _public = require("@kbn/embeddable-plugin/public"); var _unifiedFieldList = require("@kbn/unified-field-list"); var _react = require("@xstate/react"); var _react2 = require("react"); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ const useControlPanels = (logExplorerProfileStateService, data) => { const { query, filters, fromDate, toDate } = (0, _unifiedFieldList.useQuerySubscriber)({ data }); const timeRange = { from: fromDate, to: toDate }; const controlPanels = (0, _react.useSelector)(logExplorerProfileStateService, state => { if (!('controlPanels' in state.context)) return; return state.context.controlPanels; }); const getInitialInput = (0, _react2.useCallback)(async initialInput => { const input = { ...initialInput, viewMode: _public.ViewMode.VIEW, panels: controlPanels !== null && controlPanels !== void 0 ? controlPanels : initialInput.panels, filters: filters !== null && filters !== void 0 ? filters : [], query: query, timeRange: { from: fromDate, to: toDate } }; return { initialInput: input }; }, [controlPanels, filters, fromDate, query, toDate]); const setControlGroupAPI = (0, _react2.useCallback)(controlGroupAPI => { logExplorerProfileStateService.send({ type: 'INITIALIZE_CONTROL_GROUP_API', controlGroupAPI }); }, [logExplorerProfileStateService]); return { getInitialInput, setControlGroupAPI, query, filters, timeRange }; }; exports.useControlPanels = useControlPanels;