
{"id":320803,"date":"2025-08-01T11:58:59","date_gmt":"2025-08-01T03:58:59","guid":{"rendered":"https:\/\/tzuchiculture.org\/member-registration\/"},"modified":"2025-09-26T17:52:37","modified_gmt":"2025-09-26T09:52:37","slug":"en-signup","status":"publish","type":"page","link":"https:\/\/culture.daaimobile.org\/en\/en-signup\/","title":{"rendered":"Member Registration"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; hover_enabled=&#8221;0&#8243; da_disable_devices=&#8221;off|off|off&#8221; global_colors_info=&#8221;{}&#8221; custom_margin=&#8221;0px|0px|0px|0px|false|false&#8221; custom_padding=&#8221;0px|0px|0px|0px|false|false&#8221; sticky_enabled=&#8221;0&#8243; da_is_popup=&#8221;off&#8221; da_exit_intent=&#8221;off&#8221; da_has_close=&#8221;on&#8221; da_alt_close=&#8221;off&#8221; da_dark_close=&#8221;off&#8221; da_not_modal=&#8221;on&#8221; da_is_singular=&#8221;off&#8221; da_with_loader=&#8221;off&#8221; da_has_shadow=&#8221;on&#8221;][et_pb_row _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; hover_enabled=&#8221;0&#8243; global_colors_info=&#8221;{}&#8221; custom_margin=&#8221;0px|auto|0px|auto|false|false&#8221; custom_padding=&#8221;0px|0px|0px|0px|false|false&#8221; sticky_enabled=&#8221;0&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_text _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n            <div class=\"form-wrapper-c\">\n                <div class=\"title-wrapper\">\n                  <div class=\"main-title-c\">\n                    Sign Up                  <\/div>\n                <\/div>\n                <div class=\"custom-register-form\">\n\t\t            <div style=\"display:flex;justify-content:flex-end;font-size:1.2em;\">\n                        <a href=\"https:\/\/culture.daaimobile.org\/en\/join-us\/\" class=\"login-link\" style=\"color:#000\">Back to Login<\/a>\t\t\t\t\t\t\t\t\t\n\t\t            <\/div>\n                    <form method=\"post\" action=\"\" id=\"supabase-register-form\">\n                        <input type=\"hidden\" id=\"supabase_register_nonce\" name=\"supabase_register_nonce\" value=\"3da377c0a5\" \/><input type=\"hidden\" name=\"_wp_http_referer\" value=\"\/en\/wp-json\/wp\/v2\/pages\/320803\" \/>                        <div id=\"step-1\">\n                            <div class=\"contact-type-wrapper\">\n\t    \t    \t\t\t    <label for=\"contact_type\" class=\"form-label\" style=\"display:block;\">Choose a registration method<\/label>\n                                <div style=\"margin-top:1em;\">\n                                    <label class=\"form-label\"><input type=\"radio\" name=\"contact_type\" value=\"phone\" onchange=\"switchMethod()\" checked \/>Phone<\/label>\n                                    <label class=\"form-label\"><input type=\"radio\" name=\"contact_type\" value=\"email\" onchange=\"switchMethod()\" \/>Email<\/label>\n                                <\/div>\n                            <\/div>\n                            <div style=\"margin-bottom: 1em;\">\n                                <div class=\"acf-custom-wrapper input-button-row\">\n                                    <input type=\"text\" name=\"custom_email_phone\" id=\"custom_email_phone\" placeholder=\"Enter your phone number\" \/>\n                                <\/div>\n \t    \t    \t\t\t\t<label id=\"verify-phone-label\" class=\"culture\" for=\"custom_email_phone\" >\n                                    <span class=\"line\">After entering,<\/span>\n                                    <span class=\"line\">please click the [Send Verification Code] button\u25bc<\/span>\n                                <\/label>\n                                <button type=\"button\" id=\"send-otp\" class=\"culture btn-center\" >Send Verification Code<\/button>\n                            <\/div>\n                            <div id=\"otp-section\" style=\"margin-bottom: 1em;\">\n\t    \t    \t\t\t\t<label for=\"otp_code\" class=\"form-label\">Enter the verification code you received<\/label>\n                                <div class=\"acf-custom-wrapper input-button-row\">\n                                    <input type=\"text\" id=\"otp_code\" name=\"otp_code\" placeholder=\"Enter your verification code\" maxlength=\"6\" \/>\n                                <\/div>\n                                <p id=\"otp-timer\" style=\"text-align:center; margin-top:0.5em; color: #888;\"><\/p>\n                            <\/div>\n                            <input type=\"hidden\" name=\"verified_phone\" id=\"verified_phone\" value=\"\">\n                            <div style=\"margin-bottom: 1em;\">\n\t    \t    \t\t\t\t<label for=\"custom_password\" class=\"form-label required\">Set a password<\/label>\n                                <div class=\"acf-password-wrapper\">\n                                    <div class=\"acf-custom-wrapper input-button-row\" id=\"acf-custom-password-wrapper\">\n                                        <input type=\"password\" name=\"custom_password\" id=\"custom_password\" placeholder=\"At least 8 characters with letters and numbers\" \/>\n                                    <\/div>\n                                <\/div>\n                            <\/div>\n                            <input type=\"hidden\" name=\"supabase_uid\" id=\"supabase_uid\" \/>\n                            <input type=\"hidden\" name=\"supabase_token\" id=\"supabase_token\" \/>\n                            <input type=\"hidden\" name=\"provider\" id=\"provider\" value=\"\" \/>\n                            <input type=\"hidden\" name=\"display_name\" id=\"display_name\" value=\"\" \/>\n                            <input type=\"hidden\" name=\"picture\" id=\"picture\"  value=\"\" \/>\n                            <button type=\"submit\" id=\"register-submit\" name=\"custom_register_submit\" class=\"culture register-btn btn-disabled\" disabled>Register<\/button>\n                        <\/div>\n                    <\/form>\n                <\/div>\n                <div id=\"social-signup\" style=\"margin-top:2em;\">\n                    <p>Or sign up with<\/p>\n                    <div style=\"text-align:center;padding-top:0.5em;padding-bottom:2em;\">\n                        <button type=\"button\" class=\"social-login-button\" onclick=\"loginLine()\">\n                          <img decoding=\"async\" src=\"https:\/\/culture.daaimobile.org\/wp-content\/plugins\/supabase-register-loginer\/assets\/LINE1.png\" alt=\"LINE Icon\" \/>\n                        <\/button>\n                        <button type=\"button\" class=\"social-login-button\" onclick=\"loginWithProvider('facebook')\">\n                          <img decoding=\"async\" src=\"https:\/\/culture.daaimobile.org\/wp-content\/plugins\/supabase-register-loginer\/assets\/FB1.png\" alt=\"Facebook Icon\" \/>\n                        <\/button>\n                        <button type=\"button\" class=\"social-login-button\" onclick=\"loginWithProvider('google')\">\n                          <img decoding=\"async\" src=\"https:\/\/culture.daaimobile.org\/wp-content\/plugins\/supabase-register-loginer\/assets\/GOOGLE1.png\" alt=\"Google Icon\" \/>\n                        <\/button>\n                    <\/div>\n                <\/div>\n            <\/div>\n            <link rel=\"stylesheet\" href=\"https:\/\/cdn.jsdelivr.net\/npm\/intl-tel-input@25.3.2\/build\/css\/intlTelInput.min.css\" \/>\n            <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/intl-tel-input@25.3.2\/build\/js\/intlTelInput.min.js\"><\/script>\n            <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/@supabase\/supabase-js@2\"><\/script>\n            <script>\n                function loginLine() {\n                    const params = new URLSearchParams({\n                        response_type: \"code\",\n                        client_id: \"2002599300\",\n                        redirect_uri: window.location.href.split('#')[0],\n                        scope: \"openid profile email\",\n                        state: Math.random().toString(36).substring(2)\n                    });\n                    window.location.href = \"https:\/\/access.line.me\/oauth2\/v2.1\/authorize?\" + params.toString();\n                }\n                const client = supabase.createClient(\"https:\/\/jxnqpnlyieukvpehurgl.supabase.co\", \"sb_publishable_vb5kvkB5cSa-M6oq5iUDtQ_dJuDKZs5\");\n                async function loginWithProvider(provider) {\n                    const redirectUrl = window.location.origin + window.location.pathname + \"?from_oauth=1\";\n                    const { data, error } = await client.auth.signInWithOAuth({\n                        provider: provider,\n                        options: {\n                            redirectTo: redirectUrl\n                        }\n                    });\n                    if (error) {\n                        alert('\u793e\u7fa4\u8a3b\u518a\u932f\u8aa4\uff1a' + error.message);\n                    } else {\n                        sessionStorage.setItem(\"register_submitted\", \"0\");\n                    }\n                }\n                const i18n = {\n                    selectedCountryAriaLabel: \"\u9078\u64c7\u570b\u5bb6\u3001\u5730\u5340\",\n                    noCountrySelected: \"\u7121\u570b\u5bb6\u3001\u5730\u5340\u5099\u9078\",\n                    countryListAriaLabel: \"\u570b\u5bb6\u3001\u5730\u5340\u6e05\u55ae\",\n                    searchPlaceholder: \"\u641c\u5c0b\",\n                    zeroSearchResults: \"\u7121\u641c\u5c0b\u7d50\u679c\",\n                    oneSearchResult: \"\u641c\u5c0b\u5230 1 \u500b\u7d50\u679c\",\n                    multipleSearchResults: \"\u641c\u5c0b\u5230 ${count} \u500b\u7d50\u679c\",\n                }\n                const phoneInput = document.getElementById(\"custom_email_phone\");\n                let iti = null;\n                function initPhoneIti() {\n                    iti = window.intlTelInput(phoneInput, {\n                        initialCountry: \"tw\",\n                        countryOrder: [\"tw\", \"us\", \"cn\", \"hk\", \"sg\", \"my\", \"id\", \"jp\"],\n                        i18n: i18n,\n\t\t\t\t\t    loadUtils: () => import(\"https:\/\/cdn.jsdelivr.net\/npm\/intl-tel-input@25.3.2\/build\/js\/utils.js\")\n                    });\n\t\t\t\t}\n                function switchMethod() {\n                    const method = document.querySelector('input[name=\"contact_type\"]:checked').value;\n                    if(method === 'email') {\n\t\t\t\t\t\titi.destroy();\n\t\t\t\t\t\titi = null;\n\t\t\t\t\t\tphoneInput.style.padding = \"10px\";\n                        document.getElementById('send-otp').style.display = 'none';\n                        document.getElementById('otp-section').style.display = 'none';\n                        document.getElementById('verify-phone-label').innerHTML = \"\";\n                        document.getElementById('custom_email_phone').placeholder=\"Please enter your email address\";\n                    } else {\n                        initPhoneIti();\n\t\t\t\t\t\tphoneInput.style.padding = \"\";\n\t\t\t\t\t\tphoneInput.style.paddingLeft = \"88px\";\n                        document.getElementById('send-otp').style.display = 'block';\n                        document.getElementById('otp-section').style.display = 'block';\n                        document.getElementById('verify-phone-label').innerHTML = \"<span class='line'>After entering,<\/span><span class='line'>please click the [Send Verification Code] button\u25bc<\/span>\";\n                        document.getElementById('custom_email_phone').placeholder=\"At least 8 characters with letters and numbers\";\n                    }\n                }\n                document.addEventListener('DOMContentLoaded', function () {\n                    const wrapper = document.querySelector('.acf-password-wrapper');\n                    if (wrapper) {\n                        const input = wrapper.querySelector('input[type=\"password\"], input[type=\"text\"]');\n                        if (input) {\n                            const button = document.createElement('button');\n                            button.type = 'button';\n                            button.className = 'dashicons dashicons-visibility acf-toggle-password';\n                            button.setAttribute('aria-label', '\u5207\u63db\u5bc6\u78bc\u53ef\u898b');\n                            button.addEventListener('click', function () {\n                                const isPassword = input.type === 'password';\n                                input.type = isPassword ? 'text' : 'password';\n                                button.classList.toggle('dashicons-visibility');\n                                button.classList.toggle('dashicons-hidden');\n                            });\n                            wrapper.style.position = 'relative';\n                            wrapper.appendChild(button);\n                        }\n                    }\n                    switchMethod();\n    \n                    const sendOTPBtn = document.getElementById(\"send-otp\");\n                    const verifyOTPBtn = document.getElementById(\"verify-otp\");\n                    const otpSection = document.getElementById(\"otp-section\");\n                    const verifiedPhoneInput = document.getElementById(\"verified_phone\");\n                    const submitBtn = document.getElementById(\"register-submit\");\n                    let countdown = null;\n\n                    function startResendCountdown(duration, button, timerText) {\n                        let seconds = duration;\n                        button.disabled = true;\n                        button.style.opacity = 0.6;\n                        timerText.textContent = seconds + ' ' + ` seconds remaining before you can resend`;\n                    \n                        countdown = setInterval(() => {\n                            seconds--;\n                            if (seconds <= 0) {\n                                clearInterval(countdown);\n                                timerText.textContent = '';\n                                button.disabled = false;\n                                button.style.opacity = 1;\n                                button.textContent = 'Resend verification code';\n                            } else {\n                                timerText.textContent = seconds + ' ' + ` seconds remaining before you can resend`;\n                            }\n                        }, 1000);\n                    }\n\n                    async function checkEmailVerified() {\n                        const userId = document.getElementById('supabase_uid')?.value;\n                        const nonce = document.querySelector('input[name=\"supabase_register_nonce\"]')?.value;\n                    \n                        const formData = new FormData();\n                        formData.append('action', 'supabase_check_email_verified'); \n                        formData.append('user_id', userId);\n                        formData.append('supabase_register_nonce', nonce);\n                        sendOTPBtn.disabled = true;\n                        sendOTPBtn.classList.add(\"loading\", \"btn-disabled\");\n                        const originalText = sendOTPBtn.innerHTML;\n                        sendOTPBtn.innerHTML = `\n                            <span class=\"spinner\"><\/span> Processing\u2026                        `;\n                    \n                        try {\n                            const resp = await fetch(\"https:\/\/culture.daaimobile.org\/wp-admin\/admin-ajax.php\", {\n                                method: 'POST',\n                                body: formData\n                            });\n                            const result = await resp.json();\n                            if (result.success) {\n                                if(result.data.email_confirmed) {\n                                    submitBtn.disabled = false;\n                                    document.getElementById('supabase-register-form').requestSubmit(submitBtn);\n                                } else {\n                                    alert(\"\u60a8\u5c1a\u672a\u9a57\u8b49\u96fb\u5b50\u4fe1\u7bb1\uff0c\u8acb\u81f3\u60a8\u7684\u96fb\u5b50\u4fe1\u7bb1\u9ede\u64ca\u300c\u9a57\u8b49\u90f5\u4ef6\u300d\u7684\u9023\u7d50\uff0c\u4ee5\u78ba\u8a8d\u96fb\u5b50\u4fe1\u7bb1\u5730\u5740\\nYour email address has not been verified. Please check your inbox and click the link in the verification email to confirm your email address.\");\n                                }\n                            } else {\n                                alert(\"\u53d6\u5f97\u8a3b\u518a\u8cc7\u6599\u5931\u6557\uff0c\u8acb\u518d\u8a66\u4e00\u6b21\u6216\u806f\u7d61\u5ba2\u670d\uff1a\\nFailed to retrieve registration data. Please try again or contact customer service\uff1a\\n\" + (result.data?.message ?? '\u672a\u77e5\u932f\u8aa4'));\n                            }\n                        } catch (err) {\n                            alert('\u547c\u53eb\u5f8c\u53f0\u932f\u8aa4\uff1a' + err);\n                        } finally {\n                            sendOTPBtn.disabled = false;\n                            sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                            sendOTPBtn.innerHTML = originalText;\n                        }\n                    }\n\n                    const AJAX_URL = \"https:\/\/culture.daaimobile.org\/wp-admin\/admin-ajax.php\";\n                    async function checkUserExists(value, type) {\n                      const sites = [\n                        \"https:\/\/tzuchiculture.org\",\n                        \"https:\/\/dharma.daai.tv\",\n                        \/\/\"https:\/\/crm.daaimobile.org\"\n                      ];\n                      let errMsg = \"\";\n                      for (let site of sites) {\n                        try {\n                          const apiUrl = site.replace(\/\\\/$\/, '') + '\/wp-json\/supabase-sso\/v1\/check_user_exists';\n                          const res = await fetch(apiUrl, {\n                            method: \"POST\",\n                            headers: {\n                              \"Content-Type\": \"application\/json\",\n                            },\n                            body: JSON.stringify({ value, type })\n                          });\n                          if (!res.ok) {\n                            errMsg += site + \" \u56de\u61c9\u5931\u6557:\" + res.status;\n                            continue;\n                          }\n                          const json = await res.json();\n                          if (json.success) {\n                            if (json.data?.exists) {\n                              return true;\n                            }\n                            continue;\n                          } else {\n                            errMsg += site + \" \u56de\u61c9\u5931\u6557:\" + (json.data?.message || \"\u672a\u77e5\u932f\u8aa4\");\n                          }\n                        } catch (err) {\n                          errMsg += site + \" \u547c\u53eb\u5931\u6557:\" + (err.message || err);\n                          continue;\n                        }\n                      }\n                      if(errMsg != \"\") {\n                        alert(\"\u6aa2\u67e5\u5e33\u865f\u5931\u6557 Account check failed\uff1a\" + errMsg);\n                        return null;\n                      } else {\n                        return false;\n                      }\n                    }\n\n                    sendOTPBtn.addEventListener(\"click\", async function () {\n                        const method = document.querySelector('input[name=\"contact_type\"]:checked').value;\n                        if(method === 'email') {\n                            checkEmailVerified();\n                        } else {\n                            const phone = iti.getNumber();\n                            if (!iti.isValidNumber()) {\n                                alert(\"\u8acb\u8f38\u5165\u6b63\u78ba\u7684\u624b\u6a5f\u865f\u78bc Enter your valid phone number\");\n                                return;\n                            }\n                            sendOTPBtn.disabled = true;\n                            sendOTPBtn.classList.add(\"loading\", \"btn-disabled\");\n                            const originalText = sendOTPBtn.innerHTML;\n                            sendOTPBtn.innerHTML = `\n                                <span class=\"spinner\"><\/span> Processing\u2026                            `;\n                            const exists = await checkUserExists(phone, 'phone');\n                            if (exists === null) {\n                                sendOTPBtn.disabled = false;\n                                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                                sendOTPBtn.innerHTML = originalText;\n                                return;\n                            }\n                            if (exists) {\n                                alert(\"\u624b\u6a5f\u96fb\u8a71\/Email\u5df2\u8a3b\u518a\u70ba\u6703\u54e1 User already registered\");\n                                sendOTPBtn.classList.remove(\"loading\");\n                                sendOTPBtn.innerHTML = originalText;\n                                return;\n                            }\n                            try {\n                                fetch(AJAX_URL, {\n                                    method: \"POST\",\n                                    headers: { 'Content-Type': 'application\/x-www-form-urlencoded' },\n                                    body: new URLSearchParams({\n                                        action: 'send_custom_otp_sms',\n                                        phone: phone\n                                    })\n                                }).then(r => r.json()).then(result => {\n                                    if (result.success) {\n                                        alert(\"\u9a57\u8b49\u78bc\u5df2\u767c\u9001\uff01 Verification code has been sent.\");\n                                        otpSection.style.display = \"block\";\n                                        const timerText = document.getElementById(\"otp-timer\");\n                                        startResendCountdown(60, sendOTPBtn, timerText);\n                                    } else {\n                                        alert(\"\u767c\u9001\u9a57\u8b49\u78bc\u5931\u6557\uff1a\" + result.data);\n                                    }\n                                });\n                            } catch (err) {\n                                alert('\u767c\u9001\u9a57\u8b49\u78bc\uff0c\u547c\u53eb\u5f8c\u53f0\u932f\u8aa4\uff1a' + err);\n                            } finally {\n                                sendOTPBtn.disabled = false;\n                                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                                sendOTPBtn.innerHTML = originalText;\n                            }\n                        }\n                    });\n\n                    function verifyOTP(otp) {\n                        const phone = iti.getNumber();\n                    \n                        if (!otp || !phone) {\n                            alert(\"\u8acb\u8f38\u5165\u624b\u6a5f\u8207\u9a57\u8b49\u78bc\\nEnter your phone number and Verification Code\");\n                            return;\n                        }\n                    \n                        const formData = new FormData();\n                        formData.append(\"action\", \"verify_otp\");\n                        formData.append(\"phone\", phone);\n                        formData.append(\"otp\", otp);\n                    \n                        fetch(\"https:\/\/culture.daaimobile.org\/wp-admin\/admin-ajax.php\", {\n                            method: \"POST\",\n                            body: formData\n                        })\n                        .then(res => res.json())\n                        .then(res => {\n                            if (res.success) {\n                                alert(\"\u624b\u6a5f\u9a57\u8b49\u6210\u529f\uff01 Successfully verified\");\n                                clearInterval(countdown);\n                                verifiedPhoneInput.value = phone;\n                                sendOTPBtn.disabled = true;\n                                sendOTPBtn.classList.add(\"btn-disabled\");\n                                \/\/otpSection.style.display = \"none\";\n                                checkFieldsComplete();\n                            } else {\n                                alert(\"\u9a57\u8b49\u5931\u6557\uff1a\" + (res.message || \"\u672a\u77e5\u932f\u8aa4\"));\n                            }\n                        })\n                        .catch(() => alert(\"\u767c\u9001\u5931\u6557\uff0c\u8acb\u91cd\u8a66\"));\n                    }\n\n                    const step1 = document.getElementById('step-1');\n\n                    function verifyStep1() {\n                        const method = document.querySelector('input[name=\"contact_type\"]:checked').value;\n                        let   email = \"\";\n\t\t\t\t\t    if(iti) {\n                            email = iti.getNumber();\n\t\t\t\t        } else {\n                            email = phoneInput?.value?.trim();\n\t\t\t\t        }\n                        const isValidEmail = email && \/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/.test(email);\n                        const otpInput = document.getElementById(\"otp_code\");\n                        const otp = otpInput?.value?.trim();\n                        const verifiedPhone = verifiedPhoneInput?.value?.trim();\n                        const passwordInput = document.getElementById(\"custom_password\");\n                        const password = passwordInput?.value?.trim();\n                        const isValidPassword = password && password.length >= 8 && \/[a-zA-Z]\/.test(password) && \/\\d\/.test(password);\n                        if (!verifiedPhone && !isValidEmail && otp.length == 6) {\n                            verifyOTP(otp);\n                            return false;\n                        }\n                        if(email && method == 'phone') {\n\t\t\t\t\t\t    if(!email.match(\/^\\+\\d{10,15}$\/)) {\n                                phoneInput?.classList.add(\"field-error\");\n\t\t\t\t\t\t    } else {\n                                phoneInput?.classList.remove(\"field-error\");\n\t\t\t\t\t\t    }\n\t\t\t\t\t\t    if (otp) {\n\t\t\t\t\t\t        if(verifiedPhone) {\n                                    otpInput?.classList.remove(\"field-error\");\n\t\t\t\t\t\t        } else {\n                                    otpInput?.classList.add(\"field-error\");\n\t\t\t\t\t\t        }\n\t\t\t\t\t\t    }\n                        } else if(email && method == 'email') {\n\t\t\t\t\t\t    if(!isValidEmail) {\n                                phoneInput?.classList.add(\"field-error\");\n\t\t\t\t\t\t    } else {\n                                phoneInput?.classList.remove(\"field-error\");\n\t\t\t\t\t\t    }\n                        } else {\n                            phoneInput?.classList.remove(\"field-error\");\n                        }\n                        if (isValidPassword) {\n                            passwordInput?.classList.remove(\"field-error\");\n                        } else if(password) {\n                            passwordInput?.classList.add(\"field-error\");\n                        }\n                        return (verifiedPhone || isValidEmail) && isValidPassword;\n                    }\n    \n                    function checkFieldsComplete() {\n                        if(verifyStep1()) {\n                            submitBtn.disabled = false;\n                            submitBtn.classList.remove('btn-disabled');\n                            submitBtn.classList.add('btn-enabled');\n                        } else {\n                            submitBtn.disabled = true;\n                            submitBtn.classList.add('btn-disabled');\n                            submitBtn.classList.remove('btn-enabled');\n                        }\n                    }\n                    step1.addEventListener('input', checkFieldsComplete);\n                    step1.addEventListener('change', checkFieldsComplete);\n\n                    submitBtn.addEventListener(\"click\", async function () {\n                        if (verifyStep1()) {\n                            const method = document.querySelector('input[name=\"contact_type\"]:checked').value;\n                            const nonce = document.querySelector('input[name=\"supabase_register_nonce\"]')?.value;\n                            let phone = '';\n                            let email = '';\n                            submitBtn.disabled = true;\n                            submitBtn.classList.add(\"loading\", \"btn-disabled\");\n                            const originalText = submitBtn.innerHTML;\n                            submitBtn.innerHTML = `\n                                <span class=\"spinner\"><\/span> Processing\u2026                            `;\n                            if(method == 'email' || iti == null) {\n                                email = phoneInput?.value.trim();\n                                const exists = await checkUserExists(email, 'email');\n                                if (exists === null) {\n                                    submitBtn.disabled = false;\n                                    submitBtn.classList.remove(\"loading\", \"btn-disabled\");\n                                    submitBtn.innerHTML = originalText;\n                                    return;\n                                }\n                                if (exists) {\n                                    alert(\"\u624b\u6a5f\u96fb\u8a71\/Email\u5df2\u8a3b\u518a\u70ba\u6703\u54e1 User already registered\");\n                                    submitBtn.classList.remove(\"loading\");\n                                    submitBtn.innerHTML = originalText;\n                                    return;\n                                }\n                            } else {\n                                phone = iti.getNumber();\n                            }\n                            const password = document.getElementById('custom_password').value.trim();\n                            const formData = new FormData();\n                            formData.append(\"action\", \"supabase_ajax_register\");\n                            formData.append(\"phone\", phone);\n                            formData.append(\"email\", email);\n                            formData.append(\"password\", password);\n                            formData.append(\"supabase_register_nonce\", nonce);\n\n                            try {\n                                const response = await fetch(AJAX_URL, {\n                                    method: \"POST\",\n                                    body: formData\n                                });\n                                const result = await response.json();\n                                const data = result.data;\n                                if (result.success) {\n                                    document.getElementById('supabase_uid').value = data?.user_id || '';\n                                    document.getElementById('supabase_token').value = data?.token || '';\n                                    if(method == 'email') {\n                                        document.getElementById('verify-phone-label').innerHTML = \"<span class='line'>Please check your email inbox and click the link in<\/span><span class='line'>the verification email to confirm your email address.<\/span>\";\n                                        sendOTPBtn.innerText = 'I have clicked the link in the verification email.';\n\t\t\t\t\t\t\t\t\t    sendOTPBtn.style.width = '80%';\n                                        sendOTPBtn.style.display = 'block';\n                                    } else {\n                                        submitBtn.disabled = false;\n                                        document.getElementById('supabase-register-form').requestSubmit(submitBtn);\n                                    }\n                                } else {\n                                    let msg = (result.data?.message || \"\u8a3b\u518a\u5931\u6557\");\n                                    if(msg.includes(\"User already registered\")) {\n                                        msg = \"\u624b\u6a5f\u96fb\u8a71\/Email\u5df2\u8a3b\u518a\u70ba\u6703\u54e1 User already registered\";\n                                    }\n                                    alert(\"\u8a3b\u518a\u932f\u8aa4\uff1a\" + msg);\n                                }\n                            } catch (error) {\n                              alert(\"\u8acb\u6c42\u932f\u8aa4\uff1a\" + error);\n                            } finally {\n                                \/\/submitBtn.disabled = false; \/\/disabled for email check\n                                submitBtn.classList.remove(\"loading\");\n                                submitBtn.innerHTML = originalText;\n                            }\n                        }\n                    });\n\n                    const urlParams = new URLSearchParams(window.location.search);\n                    const fromOAuth = urlParams.get(\"from_oauth\");\n                    const code = urlParams.get(\"code\");\n                    if(code) {\n                        const emailP = \"\"; \n                        const phoneP = \"\"; \n                        const passwordP = \"\"; \n                        if(emailP) {\n\t    \t\t\t\t\titi.destroy();\n    \t\t\t\t\t\titi = null;\n                            phoneInput.value = emailP;\n                        } else {\n                            phoneInput.value = phoneP;\n                            verifiedPhoneInput.value = phoneP;\n                        }\n                        document.getElementById('custom_password').value = passwordP;\n                        document.getElementById('provider').value = \"line\";\n                        if (verifyStep1()) {\n                            setTimeout(() => {\n                                submitBtn.disabled = false;\n                                submitBtn.click();\n                            }, 500);\n                        }\n                    } else if (fromOAuth && sessionStorage.getItem(\"register_submitted\") == \"0\") {\n                        client.auth.onAuthStateChange((event, session) => {\n                            if (event === \"SIGNED_IN\" && session?.user && session?.access_token) {\n                                document.getElementById('supabase_uid').value = session.user.id;\n                                document.getElementById('supabase_token').value = session.access_token;\n                                document.getElementById('provider').value = session.user.app_metadata.provider;\n                                document.getElementById('custom_email_phone').value = session.user.email || \"\";\n                                document.getElementById('custom_password').value = \"\";\n    \n                                sessionStorage.setItem(\"register_submitted\", \"1\");\n                                setTimeout(() => {\n                                    submitBtn.disabled = false;\n                                    submitBtn.click();\n                                }, 500);\n                            }\n                        });\n                    } else {\n                        sessionStorage.removeItem(\"register_submitted\");\n                    }\n                });\n            <\/script>\n    \n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"            <div class=\"form-wrapper-c\">\n                <div class=\"title-wrapper\">\n                  <div class=\"main-title-c\">\n                    Sign Up                  <\/div>\n                <\/div>\n                <div class=\"custom-register-form\">\n\t\t            <div style=\"display:flex;justify-content:flex-end;font-size:1.2em;\">\n                        <a href=\"https:\/\/culture.daaimobile.org\/en\/join-us\/\" class=\"login-link\" style=\"color:#000\">Back to Login<\/a>\t\t\t\t\t\t\t\t\t\n\t\t            <\/div>\n                    <form method=\"post\" action=\"\" id=\"supabase-register-form\">\n                        <input type=\"hidden\" id=\"supabase_register_nonce\" name=\"supabase_register_nonce\" value=\"3da377c0a5\" \/><input type=\"hidden\" name=\"_wp_http_referer\" value=\"\/en\/wp-json\/wp\/v2\/pages\/320803\" \/>                        <div id=\"step-1\">\n                            <div class=\"contact-type-wrapper\">\n\t    \t    \t\t\t    <label for=\"contact_type\" class=\"form-label\" style=\"display:block;\">Choose a registration method<\/label>\n                                <div style=\"margin-top:1em;\">\n                                    <label class=\"form-label\"><input type=\"radio\" name=\"contact_type\" value=\"phone\" onchange=\"switchMethod()\" checked \/>Phone<\/label>\n                                    <label class=\"form-label\"><input type=\"radio\" name=\"contact_type\" value=\"email\" onchange=\"switchMethod()\" \/>Email<\/label>\n                                <\/div>\n                            <\/div>\n                            <div style=\"margin-bottom: 1em;\">\n                                <div class=\"acf-custom-wrapper input-button-row\">\n                                    <input type=\"text\" name=\"custom_email_phone\" id=\"custom_email_phone\" placeholder=\"Enter your phone number\" \/>\n                                <\/div>\n \t    \t    \t\t\t\t<label id=\"verify-phone-label\" class=\"culture\" for=\"custom_email_phone\" >\n                                    <span class=\"line\">After entering,<\/span>\n                                    <span class=\"line\">please click the [Send Verification Code] button\u25bc<\/span>\n                                <\/label>\n                                <button type=\"button\" id=\"send-otp\" class=\"culture btn-center\" >Send Verification Code<\/button>\n                            <\/div>\n                            <div id=\"otp-section\" style=\"margin-bottom: 1em;\">\n\t    \t    \t\t\t\t<label for=\"otp_code\" class=\"form-label\">Enter the verification code you received<\/label>\n                                <div class=\"acf-custom-wrapper input-button-row\">\n                                    <input type=\"text\" id=\"otp_code\" name=\"otp_code\" placeholder=\"Enter your verification code\" maxlength=\"6\" \/>\n                                <\/div>\n                                <p id=\"otp-timer\" style=\"text-align:center; margin-top:0.5em; color: #888;\"><\/p>\n                            <\/div>\n                            <input type=\"hidden\" name=\"verified_phone\" id=\"verified_phone\" value=\"\">\n                            <div style=\"margin-bottom: 1em;\">\n\t    \t    \t\t\t\t<label for=\"custom_password\" class=\"form-label required\">Set a password<\/label>\n                                <div class=\"acf-password-wrapper\">\n                                    <div class=\"acf-custom-wrapper input-button-row\" id=\"acf-custom-password-wrapper\">\n                                        <input type=\"password\" name=\"custom_password\" id=\"custom_password\" placeholder=\"At least 8 characters with letters and numbers\" \/>\n                                    <\/div>\n                                <\/div>\n                            <\/div>\n                            <input type=\"hidden\" name=\"supabase_uid\" id=\"supabase_uid\" \/>\n                            <input type=\"hidden\" name=\"supabase_token\" id=\"supabase_token\" \/>\n                            <input type=\"hidden\" name=\"provider\" id=\"provider\" value=\"\" \/>\n                            <input type=\"hidden\" name=\"display_name\" id=\"display_name\" value=\"\" \/>\n                            <input type=\"hidden\" name=\"picture\" id=\"picture\"  value=\"\" \/>\n                            <button type=\"submit\" id=\"register-submit\" name=\"custom_register_submit\" class=\"culture register-btn btn-disabled\" disabled>Register<\/button>\n                        <\/div>\n                    <\/form>\n                <\/div>\n                <div id=\"social-signup\" style=\"margin-top:2em;\">\n                    <p>Or sign up with<\/p>\n                    <div style=\"text-align:center;padding-top:0.5em;padding-bottom:2em;\">\n                        <button type=\"button\" class=\"social-login-button\" onclick=\"loginLine()\">\n                          <img decoding=\"async\" src=\"https:\/\/culture.daaimobile.org\/wp-content\/plugins\/supabase-register-loginer\/assets\/LINE1.png\" alt=\"LINE Icon\" \/>\n                        <\/button>\n                        <button type=\"button\" class=\"social-login-button\" onclick=\"loginWithProvider('facebook')\">\n                          <img decoding=\"async\" src=\"https:\/\/culture.daaimobile.org\/wp-content\/plugins\/supabase-register-loginer\/assets\/FB1.png\" alt=\"Facebook Icon\" \/>\n                        <\/button>\n                        <button type=\"button\" class=\"social-login-button\" onclick=\"loginWithProvider('google')\">\n                          <img decoding=\"async\" src=\"https:\/\/culture.daaimobile.org\/wp-content\/plugins\/supabase-register-loginer\/assets\/GOOGLE1.png\" alt=\"Google Icon\" \/>\n                        <\/button>\n                    <\/div>\n                <\/div>\n            <\/div>\n            <link rel=\"stylesheet\" href=\"https:\/\/cdn.jsdelivr.net\/npm\/intl-tel-input@25.3.2\/build\/css\/intlTelInput.min.css\" \/>\n            <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/intl-tel-input@25.3.2\/build\/js\/intlTelInput.min.js\"><\/script>\n            <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/@supabase\/supabase-js@2\"><\/script>\n            <script>\n                function loginLine() {\n                    const params = new URLSearchParams({\n                        response_type: \"code\",\n                        client_id: \"2002599300\",\n                        redirect_uri: window.location.href.split('#')[0],\n                        scope: \"openid profile email\",\n                        state: Math.random().toString(36).substring(2)\n                    });\n                    window.location.href = \"https:\/\/access.line.me\/oauth2\/v2.1\/authorize?\" + params.toString();\n                }\n                const client = supabase.createClient(\"https:\/\/jxnqpnlyieukvpehurgl.supabase.co\", \"sb_publishable_vb5kvkB5cSa-M6oq5iUDtQ_dJuDKZs5\");\n                async function loginWithProvider(provider) {\n                    const redirectUrl = window.location.origin + window.location.pathname + \"?from_oauth=1\";\n                    const { data, error } = await client.auth.signInWithOAuth({\n                        provider: provider,\n                        options: {\n                            redirectTo: redirectUrl\n                        }\n                    });\n                    if (error) {\n                        alert('\u793e\u7fa4\u8a3b\u518a\u932f\u8aa4\uff1a' + error.message);\n                    } else {\n                        sessionStorage.setItem(\"register_submitted\", \"0\");\n                    }\n                }\n                const i18n = {\n                    selectedCountryAriaLabel: \"\u9078\u64c7\u570b\u5bb6\u3001\u5730\u5340\",\n                    noCountrySelected: \"\u7121\u570b\u5bb6\u3001\u5730\u5340\u5099\u9078\",\n                    countryListAriaLabel: \"\u570b\u5bb6\u3001\u5730\u5340\u6e05\u55ae\",\n                    searchPlaceholder: \"\u641c\u5c0b\",\n                    zeroSearchResults: \"\u7121\u641c\u5c0b\u7d50\u679c\",\n                    oneSearchResult: \"\u641c\u5c0b\u5230 1 \u500b\u7d50\u679c\",\n                    multipleSearchResults: \"\u641c\u5c0b\u5230 ${count} \u500b\u7d50\u679c\",\n                }\n                const phoneInput = document.getElementById(\"custom_email_phone\");\n                let iti = null;\n                function initPhoneIti() {\n                    iti = window.intlTelInput(phoneInput, {\n                        initialCountry: \"tw\",\n                        countryOrder: [\"tw\", \"us\", \"cn\", \"hk\", \"sg\", \"my\", \"id\", \"jp\"],\n                        i18n: i18n,\n\t\t\t\t\t    loadUtils: () => import(\"https:\/\/cdn.jsdelivr.net\/npm\/intl-tel-input@25.3.2\/build\/js\/utils.js\")\n                    });\n\t\t\t\t}\n                function switchMethod() {\n                    const method = document.querySelector('input[name=\"contact_type\"]:checked').value;\n                    if(method === 'email') {\n\t\t\t\t\t\titi.destroy();\n\t\t\t\t\t\titi = null;\n\t\t\t\t\t\tphoneInput.style.padding = \"10px\";\n                        document.getElementById('send-otp').style.display = 'none';\n                        document.getElementById('otp-section').style.display = 'none';\n                        document.getElementById('verify-phone-label').innerHTML = \"\";\n                        document.getElementById('custom_email_phone').placeholder=\"Please enter your email address\";\n                    } else {\n                        initPhoneIti();\n\t\t\t\t\t\tphoneInput.style.padding = \"\";\n\t\t\t\t\t\tphoneInput.style.paddingLeft = \"88px\";\n                        document.getElementById('send-otp').style.display = 'block';\n                        document.getElementById('otp-section').style.display = 'block';\n                        document.getElementById('verify-phone-label').innerHTML = \"<span class='line'>After entering,<\/span><span class='line'>please click the [Send Verification Code] button\u25bc<\/span>\";\n                        document.getElementById('custom_email_phone').placeholder=\"At least 8 characters with letters and numbers\";\n                    }\n                }\n                document.addEventListener('DOMContentLoaded', function () {\n                    const wrapper = document.querySelector('.acf-password-wrapper');\n                    if (wrapper) {\n                        const input = wrapper.querySelector('input[type=\"password\"], input[type=\"text\"]');\n                        if (input) {\n                            const button = document.createElement('button');\n                            button.type = 'button';\n                            button.className = 'dashicons dashicons-visibility acf-toggle-password';\n                            button.setAttribute('aria-label', '\u5207\u63db\u5bc6\u78bc\u53ef\u898b');\n                            button.addEventListener('click', function () {\n                                const isPassword = input.type === 'password';\n                                input.type = isPassword ? 'text' : 'password';\n                                button.classList.toggle('dashicons-visibility');\n                                button.classList.toggle('dashicons-hidden');\n                            });\n                            wrapper.style.position = 'relative';\n                            wrapper.appendChild(button);\n                        }\n                    }\n                    switchMethod();\n    \n                    const sendOTPBtn = document.getElementById(\"send-otp\");\n                    const verifyOTPBtn = document.getElementById(\"verify-otp\");\n                    const otpSection = document.getElementById(\"otp-section\");\n                    const verifiedPhoneInput = document.getElementById(\"verified_phone\");\n                    const submitBtn = document.getElementById(\"register-submit\");\n                    let countdown = null;\n\n                    function startResendCountdown(duration, button, timerText) {\n                        let seconds = duration;\n                        button.disabled = true;\n                        button.style.opacity = 0.6;\n                        timerText.textContent = seconds + ' ' + ` seconds remaining before you can resend`;\n                    \n                        countdown = setInterval(() => {\n                            seconds--;\n                            if (seconds <= 0) {\n                                clearInterval(countdown);\n                                timerText.textContent = '';\n                                button.disabled = false;\n                                button.style.opacity = 1;\n                                button.textContent = 'Resend verification code';\n                            } else {\n                                timerText.textContent = seconds + ' ' + ` seconds remaining before you can resend`;\n                            }\n                        }, 1000);\n                    }\n\n                    async function checkEmailVerified() {\n                        const userId = document.getElementById('supabase_uid')?.value;\n                        const nonce = document.querySelector('input[name=\"supabase_register_nonce\"]')?.value;\n                    \n                        const formData = new FormData();\n                        formData.append('action', 'supabase_check_email_verified'); \n                        formData.append('user_id', userId);\n                        formData.append('supabase_register_nonce', nonce);\n                        sendOTPBtn.disabled = true;\n                        sendOTPBtn.classList.add(\"loading\", \"btn-disabled\");\n                        const originalText = sendOTPBtn.innerHTML;\n                        sendOTPBtn.innerHTML = `\n                            <span class=\"spinner\"><\/span> Processing\u2026                        `;\n                    \n                        try {\n                            const resp = await fetch(\"https:\/\/culture.daaimobile.org\/wp-admin\/admin-ajax.php\", {\n                                method: 'POST',\n                                body: formData\n                            });\n                            const result = await resp.json();\n                            if (result.success) {\n                                if(result.data.email_confirmed) {\n                                    submitBtn.disabled = false;\n                                    document.getElementById('supabase-register-form').requestSubmit(submitBtn);\n                                } else {\n                                    alert(\"\u60a8\u5c1a\u672a\u9a57\u8b49\u96fb\u5b50\u4fe1\u7bb1\uff0c\u8acb\u81f3\u60a8\u7684\u96fb\u5b50\u4fe1\u7bb1\u9ede\u64ca\u300c\u9a57\u8b49\u90f5\u4ef6\u300d\u7684\u9023\u7d50\uff0c\u4ee5\u78ba\u8a8d\u96fb\u5b50\u4fe1\u7bb1\u5730\u5740\\nYour email address has not been verified. Please check your inbox and click the link in the verification email to confirm your email address.\");\n                                }\n                            } else {\n                                alert(\"\u53d6\u5f97\u8a3b\u518a\u8cc7\u6599\u5931\u6557\uff0c\u8acb\u518d\u8a66\u4e00\u6b21\u6216\u806f\u7d61\u5ba2\u670d\uff1a\\nFailed to retrieve registration data. Please try again or contact customer service\uff1a\\n\" + (result.data?.message ?? '\u672a\u77e5\u932f\u8aa4'));\n                            }\n                        } catch (err) {\n                            alert('\u547c\u53eb\u5f8c\u53f0\u932f\u8aa4\uff1a' + err);\n                        } finally {\n                            sendOTPBtn.disabled = false;\n                            sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                            sendOTPBtn.innerHTML = originalText;\n                        }\n                    }\n\n                    const AJAX_URL = \"https:\/\/culture.daaimobile.org\/wp-admin\/admin-ajax.php\";\n                    async function checkUserExists(value, type) {\n                      const sites = [\n                        \"https:\/\/tzuchiculture.org\",\n                        \"https:\/\/dharma.daai.tv\",\n                        \/\/\"https:\/\/crm.daaimobile.org\"\n                      ];\n                      let errMsg = \"\";\n                      for (let site of sites) {\n                        try {\n                          const apiUrl = site.replace(\/\\\/$\/, '') + '\/wp-json\/supabase-sso\/v1\/check_user_exists';\n                          const res = await fetch(apiUrl, {\n                            method: \"POST\",\n                            headers: {\n                              \"Content-Type\": \"application\/json\",\n                            },\n                            body: JSON.stringify({ value, type })\n                          });\n                          if (!res.ok) {\n                            errMsg += site + \" \u56de\u61c9\u5931\u6557:\" + res.status;\n                            continue;\n                          }\n                          const json = await res.json();\n                          if (json.success) {\n                            if (json.data?.exists) {\n                              return true;\n                            }\n                            continue;\n                          } else {\n                            errMsg += site + \" \u56de\u61c9\u5931\u6557:\" + (json.data?.message || \"\u672a\u77e5\u932f\u8aa4\");\n                          }\n                        } catch (err) {\n                          errMsg += site + \" \u547c\u53eb\u5931\u6557:\" + (err.message || err);\n                          continue;\n                        }\n                      }\n                      if(errMsg != \"\") {\n                        alert(\"\u6aa2\u67e5\u5e33\u865f\u5931\u6557 Account check failed\uff1a\" + errMsg);\n                        return null;\n                      } else {\n                        return false;\n                      }\n                    }\n\n                    sendOTPBtn.addEventListener(\"click\", async function () {\n                        const method = document.querySelector('input[name=\"contact_type\"]:checked').value;\n                        if(method === 'email') {\n                            checkEmailVerified();\n                        } else {\n                            const phone = iti.getNumber();\n                            if (!iti.isValidNumber()) {\n                                alert(\"\u8acb\u8f38\u5165\u6b63\u78ba\u7684\u624b\u6a5f\u865f\u78bc Enter your valid phone number\");\n                                return;\n                            }\n                            sendOTPBtn.disabled = true;\n                            sendOTPBtn.classList.add(\"loading\", \"btn-disabled\");\n                            const originalText = sendOTPBtn.innerHTML;\n                            sendOTPBtn.innerHTML = `\n                                <span class=\"spinner\"><\/span> Processing\u2026                            `;\n                            const exists = await checkUserExists(phone, 'phone');\n                            if (exists === null) {\n                                sendOTPBtn.disabled = false;\n                                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                                sendOTPBtn.innerHTML = originalText;\n                                return;\n                            }\n                            if (exists) {\n                                alert(\"\u624b\u6a5f\u96fb\u8a71\/Email\u5df2\u8a3b\u518a\u70ba\u6703\u54e1 User already registered\");\n                                sendOTPBtn.classList.remove(\"loading\");\n                                sendOTPBtn.innerHTML = originalText;\n                                return;\n                            }\n                            try {\n                                fetch(AJAX_URL, {\n                                    method: \"POST\",\n                                    headers: { 'Content-Type': 'application\/x-www-form-urlencoded' },\n                                    body: new URLSearchParams({\n                                        action: 'send_custom_otp_sms',\n                                        phone: phone\n                                    })\n                                }).then(r => r.json()).then(result => {\n                                    if (result.success) {\n                                        alert(\"\u9a57\u8b49\u78bc\u5df2\u767c\u9001\uff01 Verification code has been sent.\");\n                                        otpSection.style.display = \"block\";\n                                        const timerText = document.getElementById(\"otp-timer\");\n                                        startResendCountdown(60, sendOTPBtn, timerText);\n                                    } else {\n                                        alert(\"\u767c\u9001\u9a57\u8b49\u78bc\u5931\u6557\uff1a\" + result.data);\n                                    }\n                                });\n                            } catch (err) {\n                                alert('\u767c\u9001\u9a57\u8b49\u78bc\uff0c\u547c\u53eb\u5f8c\u53f0\u932f\u8aa4\uff1a' + err);\n                            } finally {\n                                sendOTPBtn.disabled = false;\n                                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                                sendOTPBtn.innerHTML = originalText;\n                            }\n                        }\n                    });\n\n                    function verifyOTP(otp) {\n                        const phone = iti.getNumber();\n                    \n                        if (!otp || !phone) {\n                            alert(\"\u8acb\u8f38\u5165\u624b\u6a5f\u8207\u9a57\u8b49\u78bc\\nEnter your phone number and Verification Code\");\n                            return;\n                        }\n                    \n                        const formData = new FormData();\n                        formData.append(\"action\", \"verify_otp\");\n                        formData.append(\"phone\", phone);\n                        formData.append(\"otp\", otp);\n                    \n                        fetch(\"https:\/\/culture.daaimobile.org\/wp-admin\/admin-ajax.php\", {\n                            method: \"POST\",\n                            body: formData\n                        })\n                        .then(res => res.json())\n                        .then(res => {\n                            if (res.success) {\n                                alert(\"\u624b\u6a5f\u9a57\u8b49\u6210\u529f\uff01 Successfully verified\");\n                                clearInterval(countdown);\n                                verifiedPhoneInput.value = phone;\n                                sendOTPBtn.disabled = true;\n                                sendOTPBtn.classList.add(\"btn-disabled\");\n                                \/\/otpSection.style.display = \"none\";\n                                checkFieldsComplete();\n                            } else {\n                                alert(\"\u9a57\u8b49\u5931\u6557\uff1a\" + (res.message || \"\u672a\u77e5\u932f\u8aa4\"));\n                            }\n                        })\n                        .catch(() => alert(\"\u767c\u9001\u5931\u6557\uff0c\u8acb\u91cd\u8a66\"));\n                    }\n\n                    const step1 = document.getElementById('step-1');\n\n                    function verifyStep1() {\n                        const method = document.querySelector('input[name=\"contact_type\"]:checked').value;\n                        let   email = \"\";\n\t\t\t\t\t    if(iti) {\n                            email = iti.getNumber();\n\t\t\t\t        } else {\n                            email = phoneInput?.value?.trim();\n\t\t\t\t        }\n                        const isValidEmail = email && \/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/.test(email);\n                        const otpInput = document.getElementById(\"otp_code\");\n                        const otp = otpInput?.value?.trim();\n                        const verifiedPhone = verifiedPhoneInput?.value?.trim();\n                        const passwordInput = document.getElementById(\"custom_password\");\n                        const password = passwordInput?.value?.trim();\n                        const isValidPassword = password && password.length >= 8 && \/[a-zA-Z]\/.test(password) && \/\\d\/.test(password);\n                        if (!verifiedPhone && !isValidEmail && otp.length == 6) {\n                            verifyOTP(otp);\n                            return false;\n                        }\n                        if(email && method == 'phone') {\n\t\t\t\t\t\t    if(!email.match(\/^\\+\\d{10,15}$\/)) {\n                                phoneInput?.classList.add(\"field-error\");\n\t\t\t\t\t\t    } else {\n                                phoneInput?.classList.remove(\"field-error\");\n\t\t\t\t\t\t    }\n\t\t\t\t\t\t    if (otp) {\n\t\t\t\t\t\t        if(verifiedPhone) {\n                                    otpInput?.classList.remove(\"field-error\");\n\t\t\t\t\t\t        } else {\n                                    otpInput?.classList.add(\"field-error\");\n\t\t\t\t\t\t        }\n\t\t\t\t\t\t    }\n                        } else if(email && method == 'email') {\n\t\t\t\t\t\t    if(!isValidEmail) {\n                                phoneInput?.classList.add(\"field-error\");\n\t\t\t\t\t\t    } else {\n                                phoneInput?.classList.remove(\"field-error\");\n\t\t\t\t\t\t    }\n                        } else {\n                            phoneInput?.classList.remove(\"field-error\");\n                        }\n                        if (isValidPassword) {\n                            passwordInput?.classList.remove(\"field-error\");\n                        } else if(password) {\n                            passwordInput?.classList.add(\"field-error\");\n                        }\n                        return (verifiedPhone || isValidEmail) && isValidPassword;\n                    }\n    \n                    function checkFieldsComplete() {\n                        if(verifyStep1()) {\n                            submitBtn.disabled = false;\n                            submitBtn.classList.remove('btn-disabled');\n                            submitBtn.classList.add('btn-enabled');\n                        } else {\n                            submitBtn.disabled = true;\n                            submitBtn.classList.add('btn-disabled');\n                            submitBtn.classList.remove('btn-enabled');\n                        }\n                    }\n                    step1.addEventListener('input', checkFieldsComplete);\n                    step1.addEventListener('change', checkFieldsComplete);\n\n                    submitBtn.addEventListener(\"click\", async function () {\n                        if (verifyStep1()) {\n                            const method = document.querySelector('input[name=\"contact_type\"]:checked').value;\n                            const nonce = document.querySelector('input[name=\"supabase_register_nonce\"]')?.value;\n                            let phone = '';\n                            let email = '';\n                            submitBtn.disabled = true;\n                            submitBtn.classList.add(\"loading\", \"btn-disabled\");\n                            const originalText = submitBtn.innerHTML;\n                            submitBtn.innerHTML = `\n                                <span class=\"spinner\"><\/span> Processing\u2026                            `;\n                            if(method == 'email' || iti == null) {\n                                email = phoneInput?.value.trim();\n                                const exists = await checkUserExists(email, 'email');\n                                if (exists === null) {\n                                    submitBtn.disabled = false;\n                                    submitBtn.classList.remove(\"loading\", \"btn-disabled\");\n                                    submitBtn.innerHTML = originalText;\n                                    return;\n                                }\n                                if (exists) {\n                                    alert(\"\u624b\u6a5f\u96fb\u8a71\/Email\u5df2\u8a3b\u518a\u70ba\u6703\u54e1 User already registered\");\n                                    submitBtn.classList.remove(\"loading\");\n                                    submitBtn.innerHTML = originalText;\n                                    return;\n                                }\n                            } else {\n                                phone = iti.getNumber();\n                            }\n                            const password = document.getElementById('custom_password').value.trim();\n                            const formData = new FormData();\n                            formData.append(\"action\", \"supabase_ajax_register\");\n                            formData.append(\"phone\", phone);\n                            formData.append(\"email\", email);\n                            formData.append(\"password\", password);\n                            formData.append(\"supabase_register_nonce\", nonce);\n\n                            try {\n                                const response = await fetch(AJAX_URL, {\n                                    method: \"POST\",\n                                    body: formData\n                                });\n                                const result = await response.json();\n                                const data = result.data;\n                                if (result.success) {\n                                    document.getElementById('supabase_uid').value = data?.user_id || '';\n                                    document.getElementById('supabase_token').value = data?.token || '';\n                                    if(method == 'email') {\n                                        document.getElementById('verify-phone-label').innerHTML = \"<span class='line'>Please check your email inbox and click the link in<\/span><span class='line'>the verification email to confirm your email address.<\/span>\";\n                                        sendOTPBtn.innerText = 'I have clicked the link in the verification email.';\n\t\t\t\t\t\t\t\t\t    sendOTPBtn.style.width = '80%';\n                                        sendOTPBtn.style.display = 'block';\n                                    } else {\n                                        submitBtn.disabled = false;\n                                        document.getElementById('supabase-register-form').requestSubmit(submitBtn);\n                                    }\n                                } else {\n                                    let msg = (result.data?.message || \"\u8a3b\u518a\u5931\u6557\");\n                                    if(msg.includes(\"User already registered\")) {\n                                        msg = \"\u624b\u6a5f\u96fb\u8a71\/Email\u5df2\u8a3b\u518a\u70ba\u6703\u54e1 User already registered\";\n                                    }\n                                    alert(\"\u8a3b\u518a\u932f\u8aa4\uff1a\" + msg);\n                                }\n                            } catch (error) {\n                              alert(\"\u8acb\u6c42\u932f\u8aa4\uff1a\" + error);\n                            } finally {\n                                \/\/submitBtn.disabled = false; \/\/disabled for email check\n                                submitBtn.classList.remove(\"loading\");\n                                submitBtn.innerHTML = originalText;\n                            }\n                        }\n                    });\n\n                    const urlParams = new URLSearchParams(window.location.search);\n                    const fromOAuth = urlParams.get(\"from_oauth\");\n                    const code = urlParams.get(\"code\");\n                    if(code) {\n                        const emailP = \"\"; \n                        const phoneP = \"\"; \n                        const passwordP = \"\"; \n                        if(emailP) {\n\t    \t\t\t\t\titi.destroy();\n    \t\t\t\t\t\titi = null;\n                            phoneInput.value = emailP;\n                        } else {\n                            phoneInput.value = phoneP;\n                            verifiedPhoneInput.value = phoneP;\n                        }\n                        document.getElementById('custom_password').value = passwordP;\n                        document.getElementById('provider').value = \"line\";\n                        if (verifyStep1()) {\n                            setTimeout(() => {\n                                submitBtn.disabled = false;\n                                submitBtn.click();\n                            }, 500);\n                        }\n                    } else if (fromOAuth && sessionStorage.getItem(\"register_submitted\") == \"0\") {\n                        client.auth.onAuthStateChange((event, session) => {\n                            if (event === \"SIGNED_IN\" && session?.user && session?.access_token) {\n                                document.getElementById('supabase_uid').value = session.user.id;\n                                document.getElementById('supabase_token').value = session.access_token;\n                                document.getElementById('provider').value = session.user.app_metadata.provider;\n                                document.getElementById('custom_email_phone').value = session.user.email || \"\";\n                                document.getElementById('custom_password').value = \"\";\n    \n                                sessionStorage.setItem(\"register_submitted\", \"1\");\n                                setTimeout(() => {\n                                    submitBtn.disabled = false;\n                                    submitBtn.click();\n                                }, 500);\n                            }\n                        });\n                    } else {\n                        sessionStorage.removeItem(\"register_submitted\");\n                    }\n                });\n            <\/script>\n    \n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","pgc_sgb_lightbox_settings":"","footnotes":"","_links_to":"","_links_to_target":""},"dipi_cpt_category":[],"class_list":["post-320803","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/pages\/320803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/comments?post=320803"}],"version-history":[{"count":1,"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/pages\/320803\/revisions"}],"predecessor-version":[{"id":320804,"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/pages\/320803\/revisions\/320804"}],"wp:attachment":[{"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/media?parent=320803"}],"wp:term":[{"taxonomy":"dipi_cpt_category","embeddable":true,"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/dipi_cpt_category?post=320803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}