function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import React, { PureComponent } from "react";
import { StyleSheet } from "react-native";
import { connect } from "react-redux";
import { FormCardSectionOptionLauncher } from "./FormCardSectionOptionLauncher";
import { getMainBrandingColourFromState, TEXT_DARK } from "../colours";
import { Services } from "../config";
class AudienceSelectorLauncher extends PureComponent {
  constructor(...args) {
    super(...args);
    _defineProperty(this, "onPressAudience", () => {
      const {
        user,
        audienceType,
        audienceTypeSelection
      } = this.props;
      Services.navigation.navigate("audienceSelectorPage", {
        site: user.site,
        audienceType: audienceType || "Custom",
        audienceTypeSelection: audienceTypeSelection || [],
        onChange: (audienceType, audienceTypeSelection) => {
          if (this.props.onChange) this.props.onChange(audienceType, audienceTypeSelection);
        }
      });
    });
  }
  render() {
    const {
      style,
      textStyle,
      audienceTypeSelection
    } = this.props;
    const selected = audienceTypeSelection && audienceTypeSelection.length > 0 ? `Current selection: ${audienceTypeSelection.map(i => i.Title).join(", ")}` : "";
    return /*#__PURE__*/React.createElement(FormCardSectionOptionLauncher, {
      sectionStyle: [styles.audienceSection, style],
      textStyle: [styles.audienceText, textStyle],
      onPress: this.onPressAudience,
      title: "Audience",
      description: selected,
      value: selected ? "Custom" : "All Users"
    });
  }
}
const styles = StyleSheet.create({
  audienceSection: {
    paddingHorizontal: 0
  },
  audienceText: {
    fontFamily: "sf-semibold",
    fontSize: 16,
    color: TEXT_DARK
  }
});
const mapStateToProps = state => {
  return {
    user: state.user,
    colourBrandingMain: getMainBrandingColourFromState(state)
  };
};
const audienceSelectorLauncher = connect(mapStateToProps, {})(AudienceSelectorLauncher);
export { audienceSelectorLauncher as AudienceSelectorLauncher };
//# sourceMappingURL=AudienceSelectorLauncher.js.map