import { _export_sfc } from './_plugin-vue_export-helper-e9a2c33e.js';
import { openBlock, createElementBlock, createBaseVNode, renderSlot, Fragment, createBlock, createVNode, QBtn, resolveComponent, withCtx, createTextVNode } from './__federation_expose_Modules-a9c6a6fc.js';
import { QInput } from './QInput-a81d9a9f.js';
import { passwordRules } from './validationUtil-531209ab.js';

const _sfc_main$4 = {};
const _hoisted_1$1 = {
  class: "row",
  style: {
    "column-gap": "40px"
  }
};
const _hoisted_2$1 = {
  class: "col"
};
const _hoisted_3$1 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_4 = {
  class: "row"
};
const _hoisted_5 = {
  class: "row",
  style: {
    "column-gap": "40px"
  }
};
const _hoisted_6 = {
  class: "col"
};
const _hoisted_7 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_8 = {
  class: "row"
};
const _hoisted_9 = {
  class: "row",
  style: {
    "column-gap": "40px"
  }
};
const _hoisted_10 = {
  class: "col"
};
const _hoisted_11 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_12 = {
  class: "row"
};
const _hoisted_13 = {
  class: "row",
  style: {
    "margin-bottom": "12px"
  }
};
const _hoisted_14 = {
  class: "col text-right"
};
function _sfc_render$4(_ctx, _cache) {
  return openBlock(), createElementBlock(Fragment, null, [createBaseVNode("div", _hoisted_1$1, [createBaseVNode("div", _hoisted_2$1, [createBaseVNode("div", _hoisted_3$1, [renderSlot(_ctx.$slots, "1")]), createBaseVNode("div", _hoisted_4, [renderSlot(_ctx.$slots, "2")])])]), createBaseVNode("div", _hoisted_5, [createBaseVNode("div", _hoisted_6, [createBaseVNode("div", _hoisted_7, [renderSlot(_ctx.$slots, "3")]), createBaseVNode("div", _hoisted_8, [renderSlot(_ctx.$slots, "4")])])]), createBaseVNode("div", _hoisted_9, [createBaseVNode("div", _hoisted_10, [createBaseVNode("div", _hoisted_11, [renderSlot(_ctx.$slots, "5")]), createBaseVNode("div", _hoisted_12, [renderSlot(_ctx.$slots, "6")]), createBaseVNode("div", _hoisted_13, [createBaseVNode("div", _hoisted_14, [renderSlot(_ctx.$slots, "7")])])])])], 64);
}
const SettingsLayout = /*#__PURE__*/_export_sfc(_sfc_main$4, [['render', _sfc_render$4]]);

const _sfc_main$3 = {
  props: ['value'],
  data() {
    return {};
  }
};
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createBlock(QInput, {
    style: {
      "width": "400px"
    },
    dense: "",
    "bottom-slots": "",
    outlined: "",
    "model-value": $props.value,
    onInput: _cache[0] || (_cache[0] = $event => _ctx.$emit('update:modelValue', $event.target.value))
  }, null, 8, ["model-value"]);
}
const InputField = /*#__PURE__*/_export_sfc(_sfc_main$3, [['render', _sfc_render$3]]);

const SettingsSaveButton_vue_vue_type_style_index_0_scoped_71d42342_lang = '';

const _sfc_main$2 = {
  props: ["currentPassword", "newPassword", "confirmNewPassword"],
  data() {
    return {
      headers: {
        "Content-type": "application/json"
      }
    };
  },
  methods: {
    onClickedUpdated() {
      const data = {
        "currentPassword": this.currentPassword,
        "newPassword": this.newPassword
      };
      window.$http.post('/rest/v1/user/update-password', data, {
        headers: this.headers
      }).then(res => {
        this.$q.notify({
          color: "positive",
          message: "Password changed successfully.",
          icon: "check"
        });
        if (res.data.status == 1) ; else if (res.data.status == 2) ; else {
          this.$q.notify({
            color: "negative",
            message: "Something went wrong. Please contact customer support for assistance.",
            icon: "close"
          });
        }
      }).catch(error => {
        if (error.response.status === 401) {
          this.$q.notify({
            color: "negative",
            message: "Incorrect current password. Please try again.",
            icon: "close"
          });
          return;
        }
        this.$q.notify({
          color: "negative",
          message: "Something went wrong. Please contact customer support for assistance.",
          icon: "close"
        });
      });
    }
  }
};
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createElementBlock("div", null, [createVNode(QBtn, {
    flat: "",
    "no-caps": "",
    label: "Change password",
    class: "save-btn",
    onClick: _cache[0] || (_cache[0] = $event => $options.onClickedUpdated())
  })]);
}
const SaveButton = /*#__PURE__*/_export_sfc(_sfc_main$2, [['render', _sfc_render$2], ['__scopeId', "data-v-71d42342"]]);

const _sfc_main$1 = {};
function _sfc_render$1(_ctx, _cache) {
  const _component_router_link = resolveComponent("router-link");
  return openBlock(), createBlock(_component_router_link, {
    to: "/login/forgot-id",
    class: "text-grey-9"
  }, {
    default: withCtx(() => [createTextVNode(" Change password ")]),
    _: 1
  });
}
const ChangePasswordLink = /*#__PURE__*/_export_sfc(_sfc_main$1, [['render', _sfc_render$1]]);

const _sfc_main = {
  components: {
    SaveButton,
    ChangePasswordLink,
    InputField,
    SettingsLayout
  },
  data() {
    return {
      currentPassword: null,
      newPassword: null,
      confirmNewPassword: null
    };
  },
  computed: {
    rule() {
      return passwordRules;
    }
  }
};
const _hoisted_1 = /*#__PURE__*/createBaseVNode("span", null, "Current password *", -1);
const _hoisted_2 = /*#__PURE__*/createBaseVNode("span", null, "New password *", -1);
const _hoisted_3 = /*#__PURE__*/createBaseVNode("span", null, "Confirm new password *", -1);
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_input_field = resolveComponent("input-field");
  const _component_save_button = resolveComponent("save-button");
  const _component_settings_layout = resolveComponent("settings-layout");
  return openBlock(), createBlock(_component_settings_layout, null, {
    "1": withCtx(() => [_hoisted_1]),
    "2": withCtx(() => [createVNode(_component_input_field, {
      type: "password",
      modelValue: $data.currentPassword,
      "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => $data.currentPassword = $event)
    }, null, 8, ["modelValue"])]),
    "3": withCtx(() => [_hoisted_2]),
    "4": withCtx(() => [createVNode(_component_input_field, {
      rules: $options.rule,
      type: "password",
      modelValue: $data.newPassword,
      "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => $data.newPassword = $event)
    }, null, 8, ["rules", "modelValue"])]),
    "5": withCtx(() => [_hoisted_3]),
    "6": withCtx(() => [createVNode(_component_input_field, {
      rules: [v => !!v || '* Password confirm is required', v => v === $data.newPassword || '* Password confirm must be same as password'],
      type: "password",
      modelValue: $data.confirmNewPassword,
      "onUpdate:modelValue": _cache[2] || (_cache[2] = $event => $data.confirmNewPassword = $event)
    }, null, 8, ["rules", "modelValue"])]),
    "7": withCtx(() => [createVNode(_component_save_button, {
      currentPassword: $data.currentPassword,
      newPassword: $data.newPassword,
      confirmNewPassword: $data.confirmNewPassword
    }, null, 8, ["currentPassword", "newPassword", "confirmNewPassword"])]),
    _: 1
  });
}
const index = /*#__PURE__*/_export_sfc(_sfc_main, [['render', _sfc_render]]);

export { index as default };
