import { defineComponent, ref, reactive, mergeProps, unref, withCtx, createVNode, createTextVNode, toDisplayString, useSSRContext } from 'vue'; import { ssrRenderComponent, ssrRenderAttrs, ssrInterpolate, ssrRenderSlot } from 'vue/server-renderer'; import { B as BasicIconOld } from './BasicIconOld-93vAWohq.mjs'; import { u as useRouter$1, a as useConfigStore, e as loading, f as generateOtp, d as api$1, v as verifyOtp, c as setToken, s as supabase, h as forgetPassword, r as removeToken } from './server.mjs'; import { _ as _export_sfc } from './_plugin-vue_export-helper-1tPrXgE0.mjs'; import { B as BasicInput } from './BasicInput-DrA-e4wX.mjs'; import { B as BasicButton } from './BasicButton-QGDeiwgb.mjs'; import OtpInput from 'vue3-otp-input'; import { i as inputRulesNoMessage } from './inputRules-Cr4Uiro2.mjs'; import { I as InstaInput } from './InstaInput-cG9pc4SD.mjs'; import '../_/nitro.mjs'; import 'node:http'; import 'node:https'; import 'node:events'; import 'node:buffer'; import 'node:fs'; import 'node:url'; import 'consola'; import 'ipx'; import 'node:path'; import 'node:crypto'; import 'pinia'; import '@supabase/supabase-js'; import '@babel/runtime/helpers/esm/extends'; import '@babel/runtime/helpers/esm/objectSpread2'; import '@ant-design/colors'; import '@ctrl/tinycolor'; import 'stylis'; import 'vue-types'; import 'lodash-es'; import 'axios'; import '@ant-design/icons-vue'; import '../routes/renderer.mjs'; import 'vue-bundle-renderer/runtime'; import 'unhead/server'; import 'devalue'; import 'unhead/utils'; import './usePrice-B-5-jXKQ.mjs'; import './index-B8JfwQ3c.mjs'; import './FormItemContext-eb0AodWH.mjs'; import './index-C8EZBqzI.mjs'; import 'lodash-es/isPlainObject.js'; import 'resize-observer-polyfill'; import './index-C9wXCwkF.mjs'; import 'dom-align'; import './index-CRte5P_X.mjs'; import 'throttle-debounce'; import './FormItem-2KfKSOCd.mjs'; import 'lodash-es/cloneDeep.js'; import 'async-validator'; import 'lodash-es/find.js'; import './collapseMotion-cQ2SGjCA.mjs'; const _sfc_main$2 = {}; function _sfc_ssrRender(_ctx, _push, _parent, _attrs) { _push(``); ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent); _push(``); } const _sfc_setup$2 = _sfc_main$2.setup; _sfc_main$2.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/InstaUserInput.vue"); return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0; }; const InstaUserInput = /* @__PURE__ */ Object.assign(_export_sfc(_sfc_main$2, [["ssrRender", _sfc_ssrRender]]), { __name: "InstaUserInput" }); const _sfc_main$1 = /* @__PURE__ */ defineComponent({ __name: "index", __ssrInlineRender: true, setup(__props) { const router = useRouter$1(); const config = useConfigStore(); ref(false); const step = ref("mobile"); const form = reactive({ mobile: void 0, otp: void 0, password: void 0 }); async function handleOnComplete(value) { form.otp = value; } async function updatePassword() { if (form.password.length < 6) { api$1.error(config.useString("minPassIs6")); return; } try { loading.value = true; const res = await forgetPassword(form.mobile, form.otp, form.password); removeToken(); console.log("res ===>", res); router.push({ name: "auth-login" }); } catch (e) { } finally { loading.value = false; } } async function verifyCode() { try { loading.value = true; const res = await verifyOtp(form.mobile, form.otp); console.log("res ===>", res); setToken(res.session.access_token); await supabase.auth.setSession(res.session); step.value = "password"; } catch (e) { console.log("e ===>", e); } finally { loading.value = false; } } async function findAccount() { try { loading.value = true; const res = await generateOtp(form.mobile, "forget"); if (!res?.user?.id) { api$1.error(config.useString("userNotHaveAccount")); router.push({ name: "auth-login" }); return; } step.value = "otp"; } catch (e) { } finally { loading.value = false; } } return (_ctx, _push, _parent, _attrs) => { _push(`
`); _push(ssrRenderComponent(BasicIconOld, { icon: "vuesax-linear:arrow-left-1", class: "mb-5 font-semibold cursor-pointer", size: "26", onClick: ($event) => unref(router).back() }, null, _parent)); _push(`
`); if (step.value === "mobile") { _push(`
${ssrInterpolate(unref(config).useString("findYourAccount"))}
${ssrInterpolate(unref(config).useString("enterYourPhone"))}
`); _push(ssrRenderComponent(InstaInput, { class: "mt5", rules: unref(inputRulesNoMessage)(), value: form.mobile, "onUpdate:value": ($event) => form.mobile = $event, label: "phone", name: "mobile" }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(ssrRenderComponent(BasicInput, { value: form.mobile, "onUpdate:value": ($event) => form.mobile = $event, "place-holder": unref(config).useString("phone") }, null, _parent2, _scopeId)); } else { return [ createVNode(BasicInput, { value: form.mobile, "onUpdate:value": ($event) => form.mobile = $event, "place-holder": unref(config).useString("phone") }, null, 8, ["value", "onUpdate:value", "place-holder"]) ]; } }), _: 1 }, _parent)); _push(ssrRenderComponent(BasicButton, { block: "", class: "mt-5", type: "primary", onClick: findAccount, size: "large", loading: unref(loading), curve: "" }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(`${ssrInterpolate(unref(config).useString("findAccount"))}`); } else { return [ createTextVNode(toDisplayString(unref(config).useString("findAccount")), 1) ]; } }), _: 1 }, _parent)); _push(`
`); } else if (step.value === "otp") { _push(`
${ssrInterpolate(unref(config).useString("registerOtp"))}
${ssrInterpolate(unref(config).useString("registerOtpDescription", form.mobile))}
`); _push(ssrRenderComponent(unref(OtpInput), { style: { "direction": "ltr" }, class: "mt-10 justify-center", ref: "otpInput", autocomplete: "one-time-code", "input-classes": "otp-input", separator: "", "num-inputs": 5, "should-auto-focus": true, "is-input-num": true, onOnComplete: handleOnComplete }, null, _parent)); _push(ssrRenderComponent(BasicButton, { block: "", class: "mt-5", type: "primary", onClick: verifyCode, size: "large", loading: unref(loading) }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(`${ssrInterpolate(unref(config).useString("verifyCode"))}`); } else { return [ createTextVNode(toDisplayString(unref(config).useString("verifyCode")), 1) ]; } }), _: 1 }, _parent)); _push(`
`); } else if (step.value === "password") { _push(`
${ssrInterpolate(unref(config).useString("createNewPassword"))}
${ssrInterpolate(unref(config).useString("registerPasswordDescription"))}
`); _push(ssrRenderComponent(InstaUserInput, { class: "mt5" }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(`
${ssrInterpolate(unref(config).useString("password"))}
`); _push2(ssrRenderComponent(BasicInput, { value: form.password, "onUpdate:value": ($event) => form.password = $event, "is-password": "", size: "large" }, null, _parent2, _scopeId)); } else { return [ createVNode("div", { class: "text-gray-6" }, toDisplayString(unref(config).useString("password")), 1), createVNode(BasicInput, { value: form.password, "onUpdate:value": ($event) => form.password = $event, "is-password": "", size: "large" }, null, 8, ["value", "onUpdate:value"]) ]; } }), _: 1 }, _parent)); _push(ssrRenderComponent(BasicButton, { block: "", class: "mt-5", type: "primary", onClick: updatePassword, size: "large", loading: unref(loading) }, { default: withCtx((_, _push2, _parent2, _scopeId) => { if (_push2) { _push2(`${ssrInterpolate(unref(config).useString("updatePassword"))}`); } else { return [ createTextVNode(toDisplayString(unref(config).useString("updatePassword")), 1) ]; } }), _: 1 }, _parent)); _push(`
`); } else { _push(``); } _push(`
`); }; } }); const _sfc_setup$1 = _sfc_main$1.setup; _sfc_main$1.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/forget/index.vue"); return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0; }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "index", __ssrInlineRender: true, setup(__props) { return (_ctx, _push, _parent, _attrs) => { _push(ssrRenderComponent(_sfc_main$1, _attrs, null, _parent)); }; } }); const _sfc_setup = _sfc_main.setup; _sfc_main.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/auth/forget/index.vue"); return _sfc_setup ? _sfc_setup(props, ctx) : void 0; }; export { _sfc_main as default };