import {select as d3Select} from "d3-selection";import {$FOCUS, $GAUGE} from "../../config/classes";
type FocusParam = string | string[];
export default { focus(targetIdsValue?: FocusParam): void { const $$ = this.internal; const {state} = $$; const targetIds = $$.mapToTargetIds(targetIdsValue); const candidates = $$.$el.svg.selectAll( $$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)) );
this.revert(); this.defocus();
candidates.classed($FOCUS.focused, true).classed($FOCUS.defocused, false);
if ($$.hasArcType() && !state.hasRadar) { $$.expandArc(targetIds);
$$.hasType("gauge") && $$.markOverlapped(targetIdsValue, $$, `.${$GAUGE.gaugeValue}`); }
$$.toggleFocusLegend(targetIds, true);
state.focusedTargetIds = targetIds; state.defocusedTargetIds = state.defocusedTargetIds.filter(id => targetIds.indexOf(id) < 0); },
defocus(targetIdsValue?: FocusParam): void { const $$ = this.internal; const {state} = $$; const targetIds = $$.mapToTargetIds(targetIdsValue); const candidates = $$.$el.svg.selectAll( $$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)) );
candidates.classed($FOCUS.focused, false).classed($FOCUS.defocused, true);
if ($$.hasArcType(null, ["polar"])) { $$.unexpandArc(targetIds);
$$.hasType("gauge") && $$.undoMarkOverlapped($$, `.${$GAUGE.gaugeValue}`); }
$$.toggleFocusLegend(targetIds, false);
state.focusedTargetIds = state.focusedTargetIds.filter(id => targetIds.indexOf(id) < 0); state.defocusedTargetIds = targetIds; },
revert(targetIdsValue?: FocusParam): void { const $$ = this.internal; const {config, state, $el} = $$; const targetIds = $$.mapToTargetIds(targetIdsValue); const candidates = $el.svg.selectAll($$.selectorTargets(targetIds));
candidates.classed($FOCUS.focused, false).classed($FOCUS.defocused, false);
$$.hasArcType(null, ["polar"]) && $$.unexpandArc(targetIds);
if (config.legend_show) { $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$))); $el.legend.selectAll($$.selectorLegends(targetIds)) .filter(function() { return d3Select(this).classed($FOCUS.legendItemFocused); }) .classed($FOCUS.legendItemFocused, false); }
state.focusedTargetIds = []; state.defocusedTargetIds = []; }};