import { p } from './Modal-CVXpm7Mt.mjs';
import { useSSRContext, ref, watch, mergeProps, withCtx, createVNode, toDisplayString, unref, isRef, createCommentVNode, openBlock, createBlock, resolveComponent, createTextVNode } from 'vue';
import { ssrRenderComponent, ssrInterpolate, ssrRenderClass, ssrIncludeBooleanAttr, ssrRenderAttr } from 'vue/server-renderer';
import _ from 'vue3-otp-input';
import { p as pe } from './index-Dj5w-pp2.mjs';
import { d as uf, e as Zt, c as gn, f as au, b as Qs, a as Qt, g as $a, _ as An } from './server.mjs';
import { B } from './BasePhoneInput-BHlnMg14.mjs';
import * as O from 'yup';

const A = { __name: "OTPForm", __ssrInlineRender: true, props: { title: { type: String, required: true }, disabled: { type: Boolean, required: false } }, emits: ["confirm", "resend", "editPhone", "close", "success"], setup(t2, { emit: m2 }) {
  const h2 = t2, { public: { tokenName: L2, profileName: w2 } } = Zt(), C2 = ref(gn("phoneCode").value), O2 = ref(gn("phone").value), A2 = au(), { t: R2 } = Qs(), N2 = ref(""), j2 = Qt().$axios, U2 = $a(), k = () => {
    N2.value.length < 4 ? pe.error(R2("ERRORS.verification_code_must_be_four_digits")) : M();
  }, B = ref(false), F = ref(59), q = () => {
    B.value = false;
  };
  q(), watch(() => h2.disabled, (e2) => {
    e2 || (F.value = 59, 0 == F.value && (F.value = 59, q()));
  }, { deep: true });
  const D = () => {
    B.value && (Q(), F.value = 59, q());
  }, Q = () => {
    j2("resendCode", { method: "POST", data: { phone_code: C2.value, phone: O2.value } }).then((e2) => {
      pe.success(e2.data.message);
    }).catch((e2) => {
      pe.error(e2.response.data.message);
    });
  }, H = gn("she_in_guest_token"), M = () => {
    j2("verify_Phone", { method: "POST", data: { phone_code: C2.value, phone: O2.value, code: N2.value, device_token: "Figo", type: "ios" } }).then((e2) => {
      H.value = null, gn(w2).value = e2.data.data, gn(L2).value = e2.data.data.token, pe.success(e2.data.message), gn("phoneCode").value = undefined, gn("phone").value = undefined, gn("oldPhoneCode").value = undefined, gn("oldPhone").value = undefined, setTimeout(() => {
        U2.push(A2("/profile"));
      }, 1500);
    }).catch((e2) => {
      pe.error(e2.response.data.message);
    });
  };
  return (a2, s2, m3, h3) => {
    s2(ssrRenderComponent(p, mergeProps({ onClose: (e2) => a2.$emit("close"), title: t2.title }, h3), { default: withCtx((e2, s3, o2, l2) => {
      if (!s3) return [createVNode("div", { class: "otp-wrapper" }, [createVNode("div", { class: "mb-6" }, [createVNode("div", { class: "mb-4" }, [createVNode("p", { class: "mb-3 text-primary" }, toDisplayString(a2.$t("TITLES.otpSent")), 1), createVNode("p", { class: "text-primary" }, "+" + toDisplayString(unref(C2)) + " " + toDisplayString(unref(O2)), 1)]), createVNode("button", { onClick: (e3) => a2.$emit("editPhone"), type: "button", class: "text-[#06528D] font-medium text-lg mb-8" }, toDisplayString(a2.$t("TITLES.edit_phone_number")), 9, ["onClick"]), createVNode(unref(_), { "input-classes": "otp-input", conditionalClass: ["one", "two", "three", "four"], separator: "", inputType: "letter-numeric", "num-inputs": 4, value: unref(N2), "onUpdate:value": (e3) => isRef(N2) ? N2.value = e3 : null, "should-auto-focus": false, "should-focus-order": true, placeholder: ["\u0640\u0640\u0640\u0640", "\u0640\u0640\u0640\u0640", "\u0640\u0640\u0640\u0640", "\u0640\u0640\u0640\u0640"], "is-disabled": t2.disabled }, null, 8, ["value", "onUpdate:value", "is-disabled"]), t2.disabled ? createCommentVNode("", true) : (openBlock(), createBlock("div", { key: 0, class: "flex items-center justify-between mt-8" }, [createVNode("div", { class: "flex items-center gap-2" }, [createVNode("span", null, toDisplayString(a2.$t("TITLES.didNotReceive")), 1), createVNode("button", { onClick: D, class: ["text-primary underline font-medium", !unref(B) && "opacity-50 cursor-not-allowed"], type: "button", disabled: !unref(B) }, toDisplayString(a2.$t("TITLES.resend")), 11, ["disabled"])]), createVNode("span", { class: "text-[#E92A35]" }, " 0:" + toDisplayString(unref(F)), 1)]))]), createVNode("div", null, [createVNode("button", { disabled: t2.disabled || unref(N2).length < 4, loading: t2.disabled, onClick: k, class: "base-btn w-full mx-auto mb-2" }, toDisplayString(a2.$t("BUTTONS.submit")), 9, ["disabled", "loading"])])])];
      s3(`<div class="otp-wrapper"${l2}><div class="mb-6"${l2}><div class="mb-4"${l2}><p class="mb-3 text-primary"${l2}>${ssrInterpolate(a2.$t("TITLES.otpSent"))}</p><p class="text-primary"${l2}>+${ssrInterpolate(unref(C2))} ${ssrInterpolate(unref(O2))}</p></div><button type="button" class="text-[#06528D] font-medium text-lg mb-8"${l2}>${ssrInterpolate(a2.$t("TITLES.edit_phone_number"))}</button>`), s3(ssrRenderComponent(unref(_), { "input-classes": "otp-input", conditionalClass: ["one", "two", "three", "four"], separator: "", inputType: "letter-numeric", "num-inputs": 4, value: unref(N2), "onUpdate:value": (e3) => isRef(N2) ? N2.value = e3 : null, "should-auto-focus": false, "should-focus-order": true, placeholder: ["\u0640\u0640\u0640\u0640", "\u0640\u0640\u0640\u0640", "\u0640\u0640\u0640\u0640", "\u0640\u0640\u0640\u0640"], "is-disabled": t2.disabled }, null, o2, l2)), t2.disabled ? s3("<!---->") : s3(`<div class="flex items-center justify-between mt-8"${l2}><div class="flex items-center gap-2"${l2}><span${l2}>${ssrInterpolate(a2.$t("TITLES.didNotReceive"))}</span><button class="${ssrRenderClass([!unref(B) && "opacity-50 cursor-not-allowed", "text-primary underline font-medium"])}" type="button"${ssrIncludeBooleanAttr(!unref(B)) ? " disabled" : ""}${l2}>${ssrInterpolate(a2.$t("TITLES.resend"))}</button></div><span class="text-[#E92A35]"${l2}> 0:${ssrInterpolate(unref(F))}</span></div>`), s3(`</div><div${l2}><button${ssrIncludeBooleanAttr(t2.disabled || unref(N2).length < 4) ? " disabled" : ""}${ssrRenderAttr("loading", t2.disabled)} class="base-btn w-full mx-auto mb-2"${l2}>${ssrInterpolate(a2.$t("BUTTONS.submit"))}</button></div></div>`);
    }), _: 1 }, m3));
  };
} }, R = A.setup;
A.setup = (e2, a2) => {
  const s2 = useSSRContext();
  return (s2.modules || (s2.modules = /* @__PURE__ */ new Set())).add("components/Auth/OTPForm.vue"), R ? R(e2, a2) : undefined;
};
const N = { __name: "EditPhoneForm", __ssrInlineRender: true, props: { title: { type: String, required: true } }, emits: ["close", "toggleOtp"], setup(t2, { emit: s2 }) {
  const i2 = Qt().$axios, { t: r2 } = Qs(), c2 = ref(O.object().shape({ phone: O.object().shape({ phone_number: O.string().required(r2("ERRORS.phone")).test("phone-length", function(e2) {
    const { phone_limit: t3 } = this.parent;
    return !!e2 && (e2.length === t3 || this.createError({ message: r2("ERRORS.phone_limit", { phone_limit: t3 }) }));
  }) }) })), p2 = ref(false), $2 = ref(gn("oldPhoneCode").value), _2 = ref(gn("oldPhone").value), y2 = async (e2) => {
    p2.value = true, i2("update-phone-signup", { method: "POST", data: { _method: "PATCH", old_phone_code: $2.value, old_phone: _2.value, phone_code: e2.phone.phone_code, phone: e2.phone.phone_number } }).then((t3) => {
      gn("phoneCode").value = e2.phone.phone_code, gn("phone").value = e2.phone.phone_number, pe.success(t3.data.message), I2("close"), I2("toggleOtp");
    }).catch((e3) => {
      pe.error(e3.response.data.message);
    }).finally(() => {
      p2.value = false;
    });
  }, I2 = s2;
  return (a2, s3, i3, r3) => {
    const $3 = p, _3 = resolveComponent("VeeForm"), g2 = B, S2 = An;
    s3(ssrRenderComponent($3, mergeProps({ onClose: (e2) => a2.$emit("close"), title: t2.title }, r3), { default: withCtx((e2, t3, s4, o2) => {
      if (!t3) return [createVNode("div", { class: "mb-8" }, [createVNode("p", { class: "text-primary" }, toDisplayString(a2.$t("TITLES.editPhoneInstruction")), 1)]), createVNode(_3, { "validation-schema": unref(c2), onSubmit: y2 }, { default: withCtx(() => [createVNode("div", { class: "mb-8" }, [createVNode(g2, { name: "phone", label: a2.$t("LABELS.phone"), placeholder: a2.$t("INPUTS.phone") }, null, 8, ["label", "placeholder"])]), createVNode("div", null, [createVNode("button", { disabled: unref(p2), loading: unref(p2), type: "submit", class: "base-btn w-full mb-2" }, toDisplayString(a2.$t("BUTTONS.send")), 9, ["disabled", "loading"])]), createVNode("div", { class: "flex items-center justify-center gap-2 mt-6" }, [createVNode("span", null, toDisplayString(a2.$t("TITLES.createAccountQuestion")), 1), createVNode(S2, { to: a2.localePath("/auth/create-account"), class: "text-[#E92A35]" }, { default: withCtx(() => [createTextVNode(toDisplayString(a2.$t("TITLES.register")), 1)]), _: 1 }, 8, ["to"])])]), _: 1 }, 8, ["validation-schema"])];
      t3(`<div class="mb-8" data-v-e26e8cee${o2}><p class="text-primary" data-v-e26e8cee${o2}>${ssrInterpolate(a2.$t("TITLES.editPhoneInstruction"))}</p></div>`), t3(ssrRenderComponent(_3, { "validation-schema": unref(c2), onSubmit: y2 }, { default: withCtx((e3, t4, s5, o3) => {
        if (!t4) return [createVNode("div", { class: "mb-8" }, [createVNode(g2, { name: "phone", label: a2.$t("LABELS.phone"), placeholder: a2.$t("INPUTS.phone") }, null, 8, ["label", "placeholder"])]), createVNode("div", null, [createVNode("button", { disabled: unref(p2), loading: unref(p2), type: "submit", class: "base-btn w-full mb-2" }, toDisplayString(a2.$t("BUTTONS.send")), 9, ["disabled", "loading"])]), createVNode("div", { class: "flex items-center justify-center gap-2 mt-6" }, [createVNode("span", null, toDisplayString(a2.$t("TITLES.createAccountQuestion")), 1), createVNode(S2, { to: a2.localePath("/auth/create-account"), class: "text-[#E92A35]" }, { default: withCtx(() => [createTextVNode(toDisplayString(a2.$t("TITLES.register")), 1)]), _: 1 }, 8, ["to"])])];
        t4(`<div class="mb-8" data-v-e26e8cee${o3}>`), t4(ssrRenderComponent(g2, { name: "phone", label: a2.$t("LABELS.phone"), placeholder: a2.$t("INPUTS.phone") }, null, s5, o3)), t4(`</div><div data-v-e26e8cee${o3}><button${ssrIncludeBooleanAttr(unref(p2)) ? " disabled" : ""}${ssrRenderAttr("loading", unref(p2))} type="submit" class="base-btn w-full mb-2" data-v-e26e8cee${o3}>${ssrInterpolate(a2.$t("BUTTONS.send"))}</button></div><div class="flex items-center justify-center gap-2 mt-6" data-v-e26e8cee${o3}><span data-v-e26e8cee${o3}>${ssrInterpolate(a2.$t("TITLES.createAccountQuestion"))}</span>`), t4(ssrRenderComponent(S2, { to: a2.localePath("/auth/create-account"), class: "text-[#E92A35]" }, { default: withCtx((e4, t5, s6, o4) => {
          if (!t5) return [createTextVNode(toDisplayString(a2.$t("TITLES.register")), 1)];
          t5(`${ssrInterpolate(a2.$t("TITLES.register"))}`);
        }), _: 1 }, s5, o3)), t4("</div>");
      }), _: 1 }, s4, o2));
    }), _: 1 }, i3));
  };
} }, j = N.setup;
N.setup = (e2, a2) => {
  const s2 = useSSRContext();
  return (s2.modules || (s2.modules = /* @__PURE__ */ new Set())).add("components/Auth/EditPhoneForm.vue"), j ? j(e2, a2) : undefined;
};
const U = uf(N, [["__scopeId", "data-v-e26e8cee"]]);

export { A, U };
//# sourceMappingURL=EditPhoneForm-CICvim1z.mjs.map
