import { u } from './Skeleton-DfjdyTna.mjs';
import { mergeProps, ref, watch, resolveComponent, unref, withCtx, createVNode, withModifiers, toDisplayString, withDirectives, vModelCheckbox, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderList, ssrRenderComponent, ssrInterpolate, ssrRenderTeleport, ssrIncludeBooleanAttr, ssrLooseContain, ssrRenderAttr } from 'vue/server-renderer';
import { f as cf, b as Zt, u as Qt, d as gs, c as tf, a as Ts } from './server.mjs';
import { N, j } from './AddressCard-BVu-XEX6.mjs';
import { a } from './NoData-IIg4-CUc.mjs';
import { n } from './Backdrop-CxzzDpnH.mjs';
import { g } from './SvgIcon-YE_5uJaI.mjs';
import { I } from './BaseSelectInput-BWW5kqB1.mjs';
import { q as q$1 } from './BaseTextInput-sD2PisNb.mjs';
import { k } from './BasePhoneInput-Djo1XFlE.mjs';
import { l } from './Success-CcKbULjX.mjs';
import * as R from 'yup';
import { p as pe } from './index-Dj5w-pp2.mjs';
import '../_/nitro.mjs';
import 'node:http';
import 'node:https';
import 'node:fs';
import 'node:url';
import 'node:path';
import 'unhead';
import '@unhead/shared';
import 'vue-router';
import 'vue-rate';
import 'date-fns';
import '@hennge/vue3-pagination';
import 'axios';
import 'vue-social-sharing';
import './client-only-CAHE6F0E.mjs';
import '@headlessui/vue';
import './Modal-C67xWHXr.mjs';

const F = {};
const O = F.setup;
F.setup = (e2, l2) => {
  const t2 = useSSRContext();
  return (t2.modules || (t2.modules = /* @__PURE__ */ new Set())).add("components/Shared/AddressSkelton.vue"), O ? O(e2, l2) : undefined;
};
const q = cf(F, [["ssrRender", function(a2, t2, s2, d2) {
  const o2 = u;
  t2(`<div${ssrRenderAttrs(mergeProps({ class: "grid grid-cols-1 gap-8" }, d2))}><!--[-->`), ssrRenderList(2, (e2) => {
    t2('<div class="p-4 bg-white rounded-lg border h-[166px] space-y-4"><div class="flex justify-between items-center">'), t2(ssrRenderComponent(o2, { class: "h-[24px] w-[160px]" }, null, s2)), t2(ssrRenderComponent(o2, { class: "h-[20px] w-[120px]" }, null, s2)), t2('</div><div class="flex justify-between items-center">'), t2(ssrRenderComponent(o2, { class: "h-[24px] w-[200px]" }, null, s2)), t2('</div><div class="flex justify-between items-center">'), t2(ssrRenderComponent(o2, { class: "h-[24px] w-[150px]" }, null, s2)), t2(ssrRenderComponent(o2, { class: "h-[20px] w-[120px]" }, null, s2)), t2("</div></div>");
  }), t2("<!--]--></div>");
}]]), C = { __name: "my-addresses", __ssrInlineRender: true, setup(e2) {
  const { public: { baseGeneralURL: a2 } } = Zt(), S2 = Qt().$axios, { t: F2 } = gs(), O2 = tf(), C2 = ref(false), V2 = ref(false), G = ref(false), { data: D, status: M, refresh: J } = Ts("addresses", () => S2("address").then((e3) => e3.data.data).catch((e3) => e3.response.data));
  ref(0);
  const Q = ref({ country: null, city: null, state: null, saveForLater: false }), X = R.object().shape({ country: R.object().required(F2("ERRORS.country")), state: R.object().required(F2("ERRORS.state")), city: R.object().required(F2("ERRORS.city")), name: R.string().required(F2("ERRORS.name")), last_name: R.string().required(F2("ERRORS.last_name")), address: R.object().required(F2("ERRORS.address")), zip_code: R.string().required(F2("ERRORS.zip_code")), phone: R.object().shape({ phone_number: R.string().required(F2("ERRORS.phone")).test("phone-length", function(e3) {
    const { phone_limit: a3 } = this.parent;
    return !!e3 && (e3.length === a3 || this.createError({ message: F2("ERRORS.phone_limit", { phone_limit: a3 }) }));
  }), phone_code: R.string().required(F2("ERRORS.phone_code")) }) }), H = ref([]), K = ref([]);
  watch(() => Q.value.country, (e3) => {
    e3 ? (async (e4) => {
      S2(`get_country_states/${e4}`, { method: "GET", baseURL: a2 }).then((e5) => {
        H.value = e5.data.data;
      }).catch((e5) => {
      });
    })(e3.id) : (H.value = [], K.value = []);
  }, { deep: true, immediate: true }), watch(() => Q.value.state, (e3) => {
    e3 ? (async (e4) => {
      S2(`get_state_cities/${e4}`, { method: "GET", baseURL: a2 }).then((e5) => {
        K.value = e5.data.data;
      }).catch((e5) => {
      });
    })(e3.id) : K.value = [];
  }, { deep: true, immediate: true });
  const W = async (e3) => {
    V2.value = true;
    const a3 = new FormData();
    a3.append("country_id", e3.country.id), a3.append("state_id", e3.state.id), a3.append("city_id", e3.city.id), a3.append("first_name", e3.name), a3.append("last_name", e3.last_name), a3.append("phone", e3.phone.phone_number), a3.append("phone_code", e3.phone.phone_code), a3.append("street_address", e3.address.location), a3.append("lat", e3.address.lat), a3.append("lng", e3.address.lng), a3.append("zip_code", e3.zip_code), a3.append("is_default", +Q.value.saveForLater);
    try {
      await S2("address", { method: "POST", data: a3 }), G.value = true, C2.value = false, J();
    } catch (l2) {
      pe.error(l2.response.data.message);
    } finally {
      V2.value = false;
    }
  };
  return (e3, a3, t2, s2) => {
    var S3;
    const x2 = q, U2 = N, f2 = a, g2 = n, E2 = g, j2 = resolveComponent("VeeForm"), k2 = I, F3 = q$1, Y = k, Z = j, ee = l;
    a3(`<div${ssrRenderAttrs(mergeProps({ class: "bg-[#F6F7FC] py-6 lg:py-10 px-2 lg:px-14 h-fit" }, s2))}><h3 class="font-bold text-3xl lg:mb-12 mb-6">${ssrInterpolate(e3.$t("TITLES.my_addresses"))}</h3>`), "pending" === unref(M) ? (a3("<div>"), a3(ssrRenderComponent(x2, null, null, t2)), a3("</div>")) : "success" === unref(M) ? (a3('<div class="space-y-8">'), (null == (S3 = unref(D)) ? undefined : S3.length) ? (a3("<!--[-->"), ssrRenderList(unref(D), (e4) => {
      a3(ssrRenderComponent(U2, { key: e4.id, address: e4, onUpdated: (e5) => unref(J)() }, null, t2));
    }), a3("<!--]-->")) : a3(ssrRenderComponent(f2, { class: "!min-h-[320px]" }, null, t2)), a3("</div>")) : a3("<!---->"), a3(`<button class="base-btn w-full font-semibold mt-8 !h-16">${ssrInterpolate(e3.$t("TITLES.add_new_address"))}</button>`), ssrRenderTeleport(a3, (a4) => {
      unref(C2) ? a4(ssrRenderComponent(g2, { class: "!z-[999999999]", onClose: (e4) => C2.value = false }, { default: withCtx((a5, l2, t3, s3) => {
        if (!l2) return [createVNode("div", { onClick: withModifiers(() => {
        }, ["stop"]), class: "bg-white max-h-[95%] w-[800px] overflow-y-auto p-4 lg:p-12", "data-aos": "zoom-in", "data-aos-duration": "800" }, [createVNode("div", { class: "relative" }, [createVNode("h4", { class: "text-xl lg:text-3xl text-center mb-10 font-bold" }, toDisplayString(e3.$t("TITLES.add_new_address")), 1), createVNode("button", { class: "absolute size-12 top-1/2 border border-[#E1E1E1] flex items-center justify-center rounded-full -translate-y-1/2 end-0", onClick: (e4) => C2.value = false }, [createVNode(E2, { name: "close-2" })], 8, ["onClick"])]), createVNode(j2, { "validation-schema": unref(X), onSubmit: W, initialValues: unref(Q) }, { default: withCtx(() => [createVNode("div", { class: "grid grid-cols-2 gap-4 mb-6" }, [createVNode("div", null, [createVNode(k2, { name: "country", label: e3.$t("LABELS.country"), placeholder: e3.$t("INPUTS.country"), value: unref(Q).country, "onUpdate:value": (e4) => unref(Q).country = e4, items: unref(O2).countries }, null, 8, ["label", "placeholder", "value", "onUpdate:value", "items"])]), createVNode("div", null, [createVNode(k2, { name: "state", label: e3.$t("LABELS.state"), placeholder: e3.$t("INPUTS.state"), value: unref(Q).state, "onUpdate:value": (e4) => unref(Q).state = e4, items: unref(H) }, null, 8, ["label", "placeholder", "value", "onUpdate:value", "items"])])]), createVNode("div", { class: "mb-6" }, [createVNode(k2, { name: "city", label: e3.$t("LABELS.city"), placeholder: e3.$t("INPUTS.city"), value: unref(Q).city, "onUpdate:value": (e4) => unref(Q).city = e4, items: unref(K) }, null, 8, ["label", "placeholder", "value", "onUpdate:value", "items"])]), createVNode("div", { class: "grid grid-cols-2 gap-4 mb-6" }, [createVNode("div", null, [createVNode(F3, { name: "name", label: e3.$t("LABELS.name"), placeholder: e3.$t("INPUTS.name"), type: "text", value: unref(Q).name, "onUpdate:value": (e4) => unref(Q).name = e4 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])]), createVNode("div", null, [createVNode(F3, { name: "last_name", label: e3.$t("LABELS.last_name"), placeholder: e3.$t("INPUTS.last_name"), type: "text", value: unref(Q).last_name, "onUpdate:value": (e4) => unref(Q).last_name = e4 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])])]), createVNode("div", { class: "mb-6" }, [createVNode(Y, { name: "phone", label: e3.$t("LABELS.phone"), placeholder: e3.$t("INPUTS.phone"), value: unref(Q).phone, "onUpdate:value": (e4) => unref(Q).phone = e4 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])]), createVNode("div", { class: "mb-6" }, [createVNode(Z, { name: "address", label: e3.$t("LABELS.address"), placeholder: e3.$t("INPUTS.address"), value: unref(Q).address, "onUpdate:value": (e4) => unref(Q).address = e4 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])]), createVNode("div", { class: "mb-6" }, [createVNode(F3, { name: "zip_code", label: e3.$t("LABELS.zip_code"), placeholder: e3.$t("INPUTS.zip_code"), type: "text", value: unref(Q).zip_code, "onUpdate:value": (e4) => unref(Q).zip_code = e4 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])]), createVNode("div", { class: "mb-6 flex items-center" }, [withDirectives(createVNode("input", { type: "checkbox", id: "saveForLater", "onUpdate:modelValue": (e4) => unref(Q).saveForLater = e4, class: "me-3 !h-6 checked:after:!content-['\u2714'] !rounded-none !border-primary !w-6" }, null, 8, ["onUpdate:modelValue"]), [[vModelCheckbox, unref(Q).saveForLater]]), createVNode("label", { for: "saveForLater", class: "text-lg cursor-pointer" }, toDisplayString(e3.$t("LABELS.save_for_later")), 1)]), createVNode("button", { loading: unref(V2), disabled: unref(V2), type: "submit", class: "base-btn capitalize !h-14 w-full bg-black text-white" }, toDisplayString(e3.$t("LABELS.save_address")), 9, ["loading", "disabled"])]), _: 1 }, 8, ["validation-schema", "initialValues"])], 8, ["onClick"])];
        l2(`<div class="bg-white max-h-[95%] w-[800px] overflow-y-auto p-4 lg:p-12" data-aos="zoom-in" data-aos-duration="800"${s3}><div class="relative"${s3}><h4 class="text-xl lg:text-3xl text-center mb-10 font-bold"${s3}>${ssrInterpolate(e3.$t("TITLES.add_new_address"))}</h4><button class="absolute size-12 top-1/2 border border-[#E1E1E1] flex items-center justify-center rounded-full -translate-y-1/2 end-0"${s3}>`), l2(ssrRenderComponent(E2, { name: "close-2" }, null, t3, s3)), l2("</button></div>"), l2(ssrRenderComponent(j2, { "validation-schema": unref(X), onSubmit: W, initialValues: unref(Q) }, { default: withCtx((a6, l3, t4, s4) => {
          if (!l3) return [createVNode("div", { class: "grid grid-cols-2 gap-4 mb-6" }, [createVNode("div", null, [createVNode(k2, { name: "country", label: e3.$t("LABELS.country"), placeholder: e3.$t("INPUTS.country"), value: unref(Q).country, "onUpdate:value": (e4) => unref(Q).country = e4, items: unref(O2).countries }, null, 8, ["label", "placeholder", "value", "onUpdate:value", "items"])]), createVNode("div", null, [createVNode(k2, { name: "state", label: e3.$t("LABELS.state"), placeholder: e3.$t("INPUTS.state"), value: unref(Q).state, "onUpdate:value": (e4) => unref(Q).state = e4, items: unref(H) }, null, 8, ["label", "placeholder", "value", "onUpdate:value", "items"])])]), createVNode("div", { class: "mb-6" }, [createVNode(k2, { name: "city", label: e3.$t("LABELS.city"), placeholder: e3.$t("INPUTS.city"), value: unref(Q).city, "onUpdate:value": (e4) => unref(Q).city = e4, items: unref(K) }, null, 8, ["label", "placeholder", "value", "onUpdate:value", "items"])]), createVNode("div", { class: "grid grid-cols-2 gap-4 mb-6" }, [createVNode("div", null, [createVNode(F3, { name: "name", label: e3.$t("LABELS.name"), placeholder: e3.$t("INPUTS.name"), type: "text", value: unref(Q).name, "onUpdate:value": (e4) => unref(Q).name = e4 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])]), createVNode("div", null, [createVNode(F3, { name: "last_name", label: e3.$t("LABELS.last_name"), placeholder: e3.$t("INPUTS.last_name"), type: "text", value: unref(Q).last_name, "onUpdate:value": (e4) => unref(Q).last_name = e4 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])])]), createVNode("div", { class: "mb-6" }, [createVNode(Y, { name: "phone", label: e3.$t("LABELS.phone"), placeholder: e3.$t("INPUTS.phone"), value: unref(Q).phone, "onUpdate:value": (e4) => unref(Q).phone = e4 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])]), createVNode("div", { class: "mb-6" }, [createVNode(Z, { name: "address", label: e3.$t("LABELS.address"), placeholder: e3.$t("INPUTS.address"), value: unref(Q).address, "onUpdate:value": (e4) => unref(Q).address = e4 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])]), createVNode("div", { class: "mb-6" }, [createVNode(F3, { name: "zip_code", label: e3.$t("LABELS.zip_code"), placeholder: e3.$t("INPUTS.zip_code"), type: "text", value: unref(Q).zip_code, "onUpdate:value": (e4) => unref(Q).zip_code = e4 }, null, 8, ["label", "placeholder", "value", "onUpdate:value"])]), createVNode("div", { class: "mb-6 flex items-center" }, [withDirectives(createVNode("input", { type: "checkbox", id: "saveForLater", "onUpdate:modelValue": (e4) => unref(Q).saveForLater = e4, class: "me-3 !h-6 checked:after:!content-['\u2714'] !rounded-none !border-primary !w-6" }, null, 8, ["onUpdate:modelValue"]), [[vModelCheckbox, unref(Q).saveForLater]]), createVNode("label", { for: "saveForLater", class: "text-lg cursor-pointer" }, toDisplayString(e3.$t("LABELS.save_for_later")), 1)]), createVNode("button", { loading: unref(V2), disabled: unref(V2), type: "submit", class: "base-btn capitalize !h-14 w-full bg-black text-white" }, toDisplayString(e3.$t("LABELS.save_address")), 9, ["loading", "disabled"])];
          l3(`<div class="grid grid-cols-2 gap-4 mb-6"${s4}><div${s4}>`), l3(ssrRenderComponent(k2, { name: "country", label: e3.$t("LABELS.country"), placeholder: e3.$t("INPUTS.country"), value: unref(Q).country, "onUpdate:value": (e4) => unref(Q).country = e4, items: unref(O2).countries }, null, t4, s4)), l3(`</div><div${s4}>`), l3(ssrRenderComponent(k2, { name: "state", label: e3.$t("LABELS.state"), placeholder: e3.$t("INPUTS.state"), value: unref(Q).state, "onUpdate:value": (e4) => unref(Q).state = e4, items: unref(H) }, null, t4, s4)), l3(`</div></div><div class="mb-6"${s4}>`), l3(ssrRenderComponent(k2, { name: "city", label: e3.$t("LABELS.city"), placeholder: e3.$t("INPUTS.city"), value: unref(Q).city, "onUpdate:value": (e4) => unref(Q).city = e4, items: unref(K) }, null, t4, s4)), l3(`</div><div class="grid grid-cols-2 gap-4 mb-6"${s4}><div${s4}>`), l3(ssrRenderComponent(F3, { name: "name", label: e3.$t("LABELS.name"), placeholder: e3.$t("INPUTS.name"), type: "text", value: unref(Q).name, "onUpdate:value": (e4) => unref(Q).name = e4 }, null, t4, s4)), l3(`</div><div${s4}>`), l3(ssrRenderComponent(F3, { name: "last_name", label: e3.$t("LABELS.last_name"), placeholder: e3.$t("INPUTS.last_name"), type: "text", value: unref(Q).last_name, "onUpdate:value": (e4) => unref(Q).last_name = e4 }, null, t4, s4)), l3(`</div></div><div class="mb-6"${s4}>`), l3(ssrRenderComponent(Y, { name: "phone", label: e3.$t("LABELS.phone"), placeholder: e3.$t("INPUTS.phone"), value: unref(Q).phone, "onUpdate:value": (e4) => unref(Q).phone = e4 }, null, t4, s4)), l3(`</div><div class="mb-6"${s4}>`), l3(ssrRenderComponent(Z, { name: "address", label: e3.$t("LABELS.address"), placeholder: e3.$t("INPUTS.address"), value: unref(Q).address, "onUpdate:value": (e4) => unref(Q).address = e4 }, null, t4, s4)), l3(`</div><div class="mb-6"${s4}>`), l3(ssrRenderComponent(F3, { name: "zip_code", label: e3.$t("LABELS.zip_code"), placeholder: e3.$t("INPUTS.zip_code"), type: "text", value: unref(Q).zip_code, "onUpdate:value": (e4) => unref(Q).zip_code = e4 }, null, t4, s4)), l3(`</div><div class="mb-6 flex items-center"${s4}><input type="checkbox" id="saveForLater"${ssrIncludeBooleanAttr(Array.isArray(unref(Q).saveForLater) ? ssrLooseContain(unref(Q).saveForLater, null) : unref(Q).saveForLater) ? " checked" : ""} class="me-3 !h-6 checked:after:!content-[&#39;\u2714&#39;] !rounded-none !border-primary !w-6"${s4}><label for="saveForLater" class="text-lg cursor-pointer"${s4}>${ssrInterpolate(e3.$t("LABELS.save_for_later"))}</label></div><button${ssrRenderAttr("loading", unref(V2))}${ssrIncludeBooleanAttr(unref(V2)) ? " disabled" : ""} type="submit" class="base-btn capitalize !h-14 w-full bg-black text-white"${s4}>${ssrInterpolate(e3.$t("LABELS.save_address"))}</button>`);
        }), _: 1 }, t3, s3)), l2("</div>");
      }), _: 1 }, t2)) : a4("<!---->");
    }, "body", false, t2), unref(G) ? ssrRenderTeleport(a3, (a4) => {
      a4(ssrRenderComponent(ee, { onClose: (e4) => G.value = false, title: e3.$t("TITLES.address_added"), desc: e3.$t("TITLES.address_added_desc") }, null, t2));
    }, "body", false, t2) : a3("<!---->"), a3("</div>");
  };
} }, V = C.setup;
C.setup = (e2, l2) => {
  const t2 = useSSRContext();
  return (t2.modules || (t2.modules = /* @__PURE__ */ new Set())).add("pages/profile/my-addresses.vue"), V ? V(e2, l2) : undefined;
};

export { C as default };
//# sourceMappingURL=my-addresses-Dy3SHLsp.mjs.map
