"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var accounts;
        (function (accounts) {
            "use strict";
            function InitAccessibleAccountsPage($container) {
                new AccountsManagerAccessible($container);
            }
            accounts.InitAccessibleAccountsPage = InitAccessibleAccountsPage;
            function InitDisputesPage($container) {
                new ChargeGroupsManagerAccessible($container);
            }
            accounts.InitDisputesPage = InitDisputesPage;
            function initAccessableStatementDateRange(container, data) {
                ((d) => {
                    const fromDate = container.querySelector(`[name="StatementDateStart"]`);
                    const toDate = container.querySelector(`[name="StatementDateEnd"]`);
                    let chargeGroupID = data.chargegroupid;
                    if (starrez.library.utils.IsNotNullUndefined(chargeGroupID)) {
                        chargeGroupID = Number(chargeGroupID);
                    }
                    d.querySelector(".ui-btn-showreport").addEventListener("click", e => {
                        if (fromDate.checkValidity() && toDate.checkValidity()) {
                            var call = new starrez.service.accounts.GetStatementReport({
                                pageID: portal.page.CurrentPage.PageID,
                                dateStart: fromDate.pxValue(),
                                dateEnd: toDate.pxValue(),
                                chargeGroupID: chargeGroupID,
                                isEventEnquiry: data.iseventenquiry || false
                            });
                            starrez.library.service.OpenInNewTab(call.GetURLWithParameters());
                        }
                    });
                })(document);
            }
            accounts.initAccessableStatementDateRange = initAccessableStatementDateRange;
            function InitStatementDateRange($container) {
                var chargeGroupID = $container.data("chargegroupid");
                if (starrez.library.utils.IsNotNullUndefined(chargeGroupID)) {
                    chargeGroupID = Number(chargeGroupID);
                }
                portal.PageElements.$actions.find(".ui-btn-showreport").SRClick(e => {
                    var isEventEnquiry = $container.data("iseventenquiry");
                    if (starrez.library.utils.IsNullOrUndefined(isEventEnquiry)) {
                        isEventEnquiry = false;
                    }
                    var call = new starrez.service.accounts.GetStatementReport({
                        pageID: portal.page.CurrentPage.PageID,
                        dateStart: $container.GetControl("StatementDateStart").SRVal(),
                        dateEnd: $container.GetControl("StatementDateEnd").SRVal(),
                        chargeGroupID: chargeGroupID,
                        isEventEnquiry: isEventEnquiry
                    });
                    starrez.library.service.OpenInNewTab(call.GetURLWithParameters());
                });
            }
            accounts.InitStatementDateRange = InitStatementDateRange;
            function InitAccountsSettings($container) {
                var $invoiceType = $container.GetControl("InvoiceReportType");
                var $invoiceLayout = $container.GetControl("InvoiceReportLayout");
                $invoiceType.change(e => {
                    ReportTypeChanged(false, $invoiceType.SRVal(), $invoiceLayout);
                });
            }
            accounts.InitAccountsSettings = InitAccountsSettings;
            function InitAccountStatementSettings($container) {
                const $statementType = $container.GetControl("StatementReportType");
                const $statementLayout = $container.GetControl("StatementReportLayout");
                $statementType.off('change').on('change', e => {
                    ReportTypeChanged(true, $statementType.SRVal(), $statementLayout);
                });
            }
            accounts.InitAccountStatementSettings = InitAccountStatementSettings;
            function ReportTypeChanged(isStatement, reportType, $ctrl) {
                var call = new starrez.service.accounts.GetReportLayouts({
                    isStatement: isStatement,
                    reportType: reportType
                });
                call.Request((data) => {
                    starrez.library.controls.dropdown.FillDropDown(data, $ctrl, "Value", "Text", $ctrl.SRVal(), true);
                });
            }
            class ChargeGroupsManager {
                constructor($container, isAccessible) {
                    this.$container = $container;
                    this.model = starrez.model.EntryTransactionsBaseModel($container);
                    var $tableContainer = $container.find(".ui-account-summary-container");
                    if (isAccessible) {
                        const tables = starrez.tablesetup.CreateTableManager($tableContainer.find("table"), $('body'));
                        this.chargeGroupsTable = tables[0];
                        const selectButtons = $tableContainer.find(".ui-btn-charge-group-select");
                        selectButtons.SRClick((e) => {
                            this.LoadDetailsTableOnButtonClick($(e.currentTarget));
                        });
                    }
                    else {
                        const tables = starrez.tablesetup.CreateTableManager($tableContainer.find("table"), $tableContainer, {
                            AttachRowClickEvent: true,
                            OnRowClick: ($tr, data, e, manager) => { this.LoadDetailsTable($tr); }
                        });
                        this.chargeGroupsTable = tables[0];
                        this.AttachFocusEvents($tableContainer);
                    }
                    this.$detailsContainer = $container.find(".ui-account-details-container");
                }
                LoadDetailsTable($tr) {
                    // The row is (de-)selected when it's clicked before this function is called.
                    // So isSelected here means it was clicked for the first time.
                    // If the raw was selected, the calling function will deselect it, so isSelected here will be false.
                    if ($tr.isSelected()) {
                        var call;
                        var rawTermSessionID = $tr.data("termsession");
                        if (starrez.library.utils.IsNotNullUndefined(rawTermSessionID)) {
                            call = new starrez.service.accounts.GetAccountDetailsForTermSession({
                                pageID: portal.page.CurrentPage.PageID,
                                chargeGroupID: Number($tr.data("chargegroup")),
                                termSessionID: Number(rawTermSessionID)
                            }).Request({ ActionVerb: starrez.library.service.RequestType.Post, UseStandardError: false });
                        }
                        else {
                            call = new starrez.service.accounts.GetAccountDetails({
                                pageID: portal.page.CurrentPage.PageID,
                                chargeGroupID: Number($tr.data("chargegroup"))
                            }).Request({ ActionVerb: starrez.library.service.RequestType.Post, UseStandardError: false });
                        }
                        call.done((html) => {
                            this.$detailsContainer.html(html);
                            this.$container.data("TransactionsManager", new TransactionsManager(this.$detailsContainer, this.model));
                        }).fail(() => {
                            portal.page.CurrentPage.SetErrorMessage(this.model.LoadTransactionsErrorMessage);
                        });
                    }
                }
                LoadDetailsTableOnButtonClick($button) {
                    let call;
                    const rawTermSessionID = $button.data("termsession_id");
                    const hasTermSession = starrez.library.utils.IsNotNullUndefined(rawTermSessionID);
                    const chargeGroupID = Number($button.data("chargegroup_id"));
                    const termSessionID = hasTermSession ? Number(rawTermSessionID) : null;
                    if (hasTermSession) {
                        call = new starrez.service.accounts.GetAccountDetailsForTermSession({
                            pageID: portal.page.CurrentPage.PageID,
                            chargeGroupID: chargeGroupID,
                            termSessionID: termSessionID
                        }).Request({ ActionVerb: starrez.library.service.RequestType.Post, UseStandardError: false });
                    }
                    else {
                        call = new starrez.service.accounts.GetAccountDetails({
                            pageID: portal.page.CurrentPage.PageID,
                            chargeGroupID: chargeGroupID
                        }).Request({ ActionVerb: starrez.library.service.RequestType.Post, UseStandardError: false });
                    }
                    call.done((html) => {
                        this.$detailsContainer.html(html);
                        this.$container.data("TransactionsManager", new TransactionsManager(this.$detailsContainer, this.model));
                    }).fail(() => {
                        portal.page.CurrentPage.SetErrorMessage(this.model.LoadTransactionsErrorMessage);
                    });
                    this.chargeGroupsTable.Rows().each((index, row) => {
                        const $row = $(row);
                        const rowchargeGroupID = $row.data("chargegroup");
                        const rowTermSessionID = $row.data("termsession");
                        if (rowchargeGroupID == chargeGroupID && rowTermSessionID == (hasTermSession ? termSessionID : undefined)) {
                            $row.SelectRow(true);
                        }
                    });
                }
                AttachFocusEvents($tableContainer) {
                    $tableContainer.on("focusin", (e) => {
                        if ($(e.target).hasClass("ui-account-summary-container")) {
                            this.chargeGroupsTable.DisplayFocus(true);
                        }
                        else {
                            this.chargeGroupsTable.DisplayFocus(false);
                        }
                    });
                    $tableContainer.on("focusout", (e) => {
                        this.chargeGroupsTable.DisplayFocus(false);
                    });
                }
            }
            class ChargeGroupsManagerAccessible {
                constructor($container) {
                    this.$container = $container;
                    this.GetDetailsCall = ($button) => {
                        const rawTermSessionID = $button.data("termsession_id");
                        const hasTermSession = starrez.library.utils.IsNotNullUndefined(rawTermSessionID);
                        const chargeGroupID = Number($button.data("chargegroup_id"));
                        const termSessionID = hasTermSession ? Number(rawTermSessionID) : null;
                        if (hasTermSession) {
                            return new starrez.service.accounts.GetAccountDetailsForTermSessionResponsive({
                                pageID: portal.page.CurrentPage.PageID,
                                chargeGroupID: chargeGroupID,
                                termSessionID: termSessionID,
                                isMobile: portal.general.transactions.responsive.IsMobile()
                            });
                        }
                        return new starrez.service.accounts.GetAccountDetailsResponsive({
                            pageID: portal.page.CurrentPage.PageID,
                            chargeGroupID: chargeGroupID,
                            isMobile: portal.general.transactions.responsive.IsMobile()
                        });
                    };
                    this.model = starrez.model.EntryTransactionsBaseModel($container);
                    var $accountContainer = $container.find(".ui-account-summary-container");
                    this.$tableContainer = $accountContainer.find('.ui-responsive-active-table-container');
                    this.$detailsContainer = $container.find(".ui-account-details-container");
                    this.$tableContainer.on(starrez.activetable.responsive.eventTableLoaded, () => {
                        const tables = starrez.tablesetup.responsive.CreateTableManager(this.$tableContainer, $('body'));
                        this.chargeGroupsTable = tables[0];
                        this.chargeGroupsTable.$table.SRClickDelegate("charge-group-select", ".ui-btn-charge-group-select", (e) => {
                            this.LoadDetailsTableOnButtonClick($(e.currentTarget));
                        });
                    });
                }
                LoadDetailsTableOnButtonClick($button) {
                    portal.general.transactions.responsive.SetGetCall(() => this.GetDetailsCall($button));
                    portal.general.transactions.responsive.Init();
                    const rawTermSessionID = $button.data("termsession_id");
                    const hasTermSession = starrez.library.utils.IsNotNullUndefined(rawTermSessionID);
                    const chargeGroupID = Number($button.data("chargegroup_id"));
                    const termSessionID = hasTermSession ? Number(rawTermSessionID) : null;
                    this.chargeGroupsTable.Rows().each((index, row) => {
                        const $row = $(row);
                        const rowchargeGroupID = $row.data("chargegroup");
                        const rowTermSessionID = $row.data("termsession");
                        if (rowchargeGroupID == chargeGroupID && rowTermSessionID == (hasTermSession ? termSessionID : undefined)) {
                            $row.SelectRow(true);
                        }
                    });
                }
            }
            class AccountsManagerAccessible extends ChargeGroupsManagerAccessible {
                constructor($container) {
                    super($container);
                    this.$container = $container;
                    this.$responsiveTableContainer = $container.find('.ui-responsive-active-table-container');
                    this.$responsiveTableContainer.on(starrez.activetable.responsive.eventTableLoaded, () => {
                        this.accountsModel = starrez.model.AccountSummaryModel($container);
                        this.$manualBreakup = $container.GetControl("ManualBreakup");
                        this.$totalToPay = $container.GetControl("TotalToPay");
                        this.$breakupAmounts = $container.GetControl("AmountToPay");
                        this.BindTable();
                    });
                }
                BindTable() {
                    if (!this.accountsModel.ForceFullPayment) {
                        if (!this.accountsModel.SplitChargeGroupByTermSession) {
                            this.AttachManualBreakupClick();
                        }
                    }
                    else {
                        this.$totalToPay.ReadOnly();
                        this.$breakupAmounts.Disable();
                        this.$breakupAmounts.SRHide();
                        this.UpdateTotalAmountToOustandingBalance();
                    }
                    this.AttachPayButton();
                    this.AttachStatementButton();
                    this.AttachBreakupAmountsChange();
                    this.DisableRowSelectionOnInputClick();
                    if (!this.accountsModel.ForceFullPayment) {
                        this.ToggleAmountInputs();
                    }
                }
                AttachStatementButton() {
                    this.$container.SRClickDelegate("viewstatement", ".ui-btn-view-statement", () => {
                        var $chargeGroup = this.chargeGroupsTable.SelectedRows().first();
                        var statementPageID = this.$container.data("statementpageid");
                        if (starrez.library.utils.IsNotNullUndefined(statementPageID) && /^\d+$/.test(statementPageID)) {
                            new starrez.service.accounts.GetStatementDateInputByPageID({
                                pageID: portal.page.CurrentPage.PageID,
                                chargeGroupID: $chargeGroup.isFound() ? $chargeGroup.data("chargegroup") : null,
                                statementPageID: statementPageID
                            }).Request().done((url) => {
                                window.location.href = url;
                            });
                        }
                        else {
                            var call = new starrez.service.accounts.GetStatementDateInput({
                                pageID: portal.page.CurrentPage.PageID,
                                chargeGroupID: $chargeGroup.isFound() ? $chargeGroup.data("chargegroup") : null
                            });
                            call.Request().done((url) => {
                                window.location.href = url;
                            });
                        }
                    });
                }
                DisableRowSelectionOnInputClick() {
                    this.$breakupAmounts.SRClick(e => {
                        e.stopPropagation();
                    });
                }
                PaySelectedAccounts() {
                    var amounts = [];
                    var areAmountsValid = true;
                    this.chargeGroupsTable.Rows().each((index, row) => {
                        var $row = $(row);
                        var $ctrl = $row.GetControl("AmountToPay");
                        var validationResult = starrez.library.validation.ValidateField($ctrl);
                        if (!validationResult.IsValid) {
                            areAmountsValid = false;
                            return;
                        }
                        var amt = Number($ctrl.SRVal());
                        if (amt > 0) {
                            var chargeGroupID = $row.data("chargegroup");
                            var termSessionID = $row.data("termsession");
                            amounts.push({ ChargeGroupID: chargeGroupID, TermSessionID: termSessionID, Amount: amt });
                        }
                    });
                    if (!areAmountsValid) {
                        portal.page.CurrentPage.SetErrorMessage(this.accountsModel.EnterAmountsToPayMessage);
                    }
                    else {
                        new starrez.service.accounts.AddPaymentsToCart({
                            pageID: portal.page.CurrentPage.PageID,
                            payments: amounts
                        }).Post().done(() => {
                            portal.page.CurrentPage.SubmitPage();
                        });
                    }
                }
                PayAllAccounts() {
                    var validationResult = starrez.library.validation.ValidateField(this.$totalToPay);
                    var amount = Number(this.$totalToPay.SRVal());
                    if (!validationResult.IsValid) {
                        portal.page.CurrentPage.SetErrorMessage(this.accountsModel.EnterAmountsToPayMessage);
                    }
                    else {
                        new starrez.service.accounts.PayAll({
                            pageID: portal.page.CurrentPage.PageID,
                            amount: amount
                        }).Post().done(response => {
                            portal.page.CurrentPage.SubmitPage();
                        });
                    }
                }
                AttachPayButton() {
                    this.$container.SRClickDelegate("payselected", ".ui-btn-pay-selected", () => {
                        if (this.UseManualBreakup()) {
                            this.PaySelectedAccounts();
                        }
                        else {
                            this.PayAllAccounts();
                        }
                    });
                }
                UseManualBreakup() {
                    if (this.accountsModel.SplitChargeGroupByTermSession && (!this.accountsModel.ForceFullPayment)) {
                        return true;
                    }
                    else {
                        return this.$manualBreakup.SRVal();
                    }
                }
                AttachManualBreakupClick() {
                    this.$manualBreakup.change(e => {
                        this.ToggleAmountInputs();
                    });
                }
                ToggleAmountInputs() {
                    if (this.UseManualBreakup()) {
                        this.$totalToPay.Disable();
                        this.$breakupAmounts.Enable();
                        this.UpdateTotalAmountByPaymentBreakup();
                    }
                    else {
                        this.$totalToPay.Enable();
                        this.$breakupAmounts.Disable();
                        this.UpdateTotalAmountToOustandingBalance();
                    }
                }
                AttachBreakupAmountsChange() {
                    this.$breakupAmounts.focusout((e) => {
                        this.CleanCurrencyTextbox($(e.target));
                        this.UpdateTotalAmountByPaymentBreakup();
                    });
                }
                CleanCurrencyTextbox($control) {
                    var amountString = $control.SRVal();
                    if (starrez.library.stringhelper.IsUndefinedOrEmpty(amountString)) {
                        $control.SRVal(this.FormatCurrency(0));
                        return;
                    }
                    var amount = Number($control.SRVal());
                    $control.SRVal(this.FormatCurrency(amount));
                }
                ;
                UpdateTotalAmountByPaymentBreakup() {
                    this.$totalToPay.SRVal(this.FormatCurrency(this.GetBreakupAmountsTotal()));
                }
                ;
                UpdateTotalAmountToOustandingBalance() {
                    this.$totalToPay.SRVal(this.FormatCurrency(this.accountsModel.TotalToPay));
                }
                GetBreakupAmountsTotal() {
                    var lineAmount;
                    var total = 0;
                    this.$breakupAmounts.each((index, element) => {
                        lineAmount = Number($(element).SRVal());
                        if (!isNaN(lineAmount)) {
                            total += lineAmount;
                        }
                    });
                    return total;
                }
                ;
                FormatCurrency(amount) {
                    return amount.toFixed(this.accountsModel.MoneyInputDecimalPlaces);
                }
            }
            class TransactionsManager {
                constructor($container, model) {
                    this.$container = $container;
                    this.model = model;
                    var tables = starrez.tablesetup.CreateTableManager($container.find("table"), $container, {
                        AttachRowClickEvent: true
                    });
                    // If there are no transactions, there will be no table
                    if (tables.length > 0) {
                        this.transactionsTable = tables[0];
                        this.AttachInvoiceButton();
                        this.AttachDisputeButton();
                        this.transactionsTable.Rows().each((i, e) => {
                            var $row = $(e);
                            if (!starrez.library.convert.ToBoolean($row.data("isdisputable"))) {
                                $row.GetControl("Select").Disable();
                                $row.prop("title", model.CannotDisputeTransactionMessage);
                            }
                        });
                    }
                }
                AttachInvoiceButton() {
                    this.$container.find(".ui-btn-view-invoice").SRClick(e => {
                        var isEventEnquiry = this.$container.data("iseventenquiry");
                        if (starrez.library.utils.IsNullOrUndefined(isEventEnquiry)) {
                            isEventEnquiry = false;
                        }
                        var call = new starrez.service.accounts.GetInvoiceReport({
                            pageID: portal.page.CurrentPage.PageID,
                            invoiceID: $(e.currentTarget).closest("tr").data("invoice"),
                            isEventEnquiry: isEventEnquiry
                        });
                        starrez.library.service.OpenInNewTab(call.GetURLWithParameters());
                    });
                }
                AttachDisputeButton() {
                    this.$container.find(".ui-btn-dispute").SRClick(e => {
                        var selectedTransactions = this.GetSelectedIDs();
                        if (selectedTransactions.length < 1) {
                            portal.page.CurrentPage.SetErrorMessage(this.model.TransactionsNotSelectedErrorMessage);
                        }
                        else {
                            new starrez.service.accounts.GetDisputeUrl({
                                pageID: portal.page.CurrentPage.PageID,
                                transactionIDs: selectedTransactions
                            }).Request().done(url => {
                                window.location.href = url;
                            });
                        }
                    });
                }
                GetSelectedIDs() {
                    return this.transactionsTable
                        .SelectedRows()
                        .map((i, e) => Number($(e).data("transaction")))
                        .toArray();
                }
            }
        })(accounts = general.accounts || (general.accounts = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.accounts.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var transactions;
        (function (transactions) {
            "use strict";
            function InitTransactionTable($container) {
                new TransactionsManager($container);
            }
            transactions.InitTransactionTable = InitTransactionTable;
            class TransactionsManager {
                constructor($container) {
                    this.$container = $container;
                    this.ScrollToTable = () => {
                        $('html, body').animate({ scrollTop: this.$responsiveTableContainer.offset().top - 100 }, 200);
                        this.$responsiveTableContainer.focus();
                    };
                    this.BindTable = () => {
                        const tables = starrez.tablesetup.responsive.CreateTableManager(this.$responsiveTableContainer, $('body'), {
                            AttachRowClickEvent: true,
                        }, true);
                        // If there are no transactions, there will be no table
                        if (tables.length > 0) {
                            this.ScrollToTable();
                            this.transactionsTable = tables[0];
                            this.transactionsTable.Rows().each((i, e) => {
                                var $row = $(e);
                                if (!starrez.library.convert.ToBoolean($row.data("isdisputable"))) {
                                    $row.GetControl("Select").Disable();
                                    $row.prop("title", this.model.CannotDisputeTransactionMessage);
                                }
                            });
                        }
                    };
                    this.$transactionContainer = $container;
                    this.$accountSummaryContainer = $container.closest('.ui-account-details-container');
                    this.model = starrez.model.AccountDetailsModel($container);
                    // Bind responsive table events
                    this.$responsiveTableContainer = $container.closest('.ui-responsive-active-table-container');
                    this.$responsiveTableContainer
                        .unbind(starrez.activetable.responsive.eventTableLoaded)
                        .on(starrez.activetable.responsive.eventTableLoaded, () => {
                        this.BindTable();
                    });
                    this.BindTable();
                    this.AttachInvoiceButton();
                    this.AttachDisputeButton();
                }
                AttachInvoiceButton() {
                    this.$transactionContainer.SRClickDelegate("view-invoice", ".ui-btn-view-invoice", (e) => {
                        var isEventEnquiry = this.$accountSummaryContainer.data("iseventenquiry");
                        if (starrez.library.utils.IsNullOrUndefined(isEventEnquiry)) {
                            isEventEnquiry = false;
                        }
                        var call = new starrez.service.accounts.GetInvoiceReport({
                            pageID: portal.page.CurrentPage.PageID,
                            invoiceID: $(e.currentTarget).closest(this.transactionsTable.GetRowSelector()).data("invoice"),
                            isEventEnquiry: isEventEnquiry
                        });
                        starrez.library.service.OpenInNewTab(call.GetURLWithParameters());
                    });
                }
                AttachDisputeButton() {
                    this.$transactionContainer.SRClickDelegate("dispute-transactions", ".ui-btn-dispute", (e) => {
                        var selectedTransactions = this.transactionsTable.SelectedRows()
                            .map((i, e) => Number($(e).data("transaction")))
                            .toArray();
                        if (selectedTransactions.length < 1) {
                            portal.page.CurrentPage.SetErrorMessage(this.model.TransactionsNotSelectedErrorMessage);
                        }
                        else {
                            new starrez.service.accounts.GetDisputeUrl({
                                pageID: portal.page.CurrentPage.PageID,
                                transactionIDs: selectedTransactions
                            }).Request().done(url => {
                                window.location.href = url;
                            });
                        }
                    });
                }
            }
        })(transactions = general.transactions || (general.transactions = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.transactions.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var transactions;
        (function (transactions) {
            var responsive;
            (function (responsive) {
                "use strict";
                let _responsiveActiveTable;
                function InitResponsiveTable($container) {
                    if ($container.find(starrez.activetable.responsive.responsiveTableContainerClass).length) {
                        _responsiveActiveTable = new starrez.activetable.responsive.CustomResponsiveActiveTable($container);
                    }
                }
                responsive.InitResponsiveTable = InitResponsiveTable;
                function Init() {
                    _responsiveActiveTable.Init();
                }
                responsive.Init = Init;
                function SetGetCall(callFunc) {
                    _responsiveActiveTable.SetGetCall(callFunc);
                }
                responsive.SetGetCall = SetGetCall;
                function IsMobile() {
                    return _responsiveActiveTable.IsMobile();
                }
                responsive.IsMobile = IsMobile;
            })(responsive = transactions.responsive || (transactions.responsive = {}));
        })(transactions = general.transactions || (general.transactions = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.transactions.responsive.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function AccountDetailsModel($sys) {
            return {
                CannotDisputeTransactionMessage: $sys.data('cannotdisputetransactionmessage'),
                DetailsHeader: $sys.data('detailsheader'),
                DisputeButtonText: $sys.data('disputebuttontext'),
                IsDisputePageEnabled: starrez.library.convert.ToBoolean($sys.data('isdisputepageenabled')),
                IsMobile: starrez.library.convert.ToBoolean($sys.data('ismobile')),
                TransactionsNotSelectedErrorMessage: $sys.data('transactionsnotselectederrormessage'),
            };
        }
        model.AccountDetailsModel = AccountDetailsModel;
        function AccountSummaryModel($sys) {
            return {
                EnterAmountsToPayMessage: $sys.data('enteramountstopaymessage'),
                ForceFullPayment: starrez.library.convert.ToBoolean($sys.data('forcefullpayment')),
                MoneyInputDecimalPlaces: Number($sys.data('moneyinputdecimalplaces')),
                SplitChargeGroupByTermSession: starrez.library.convert.ToBoolean($sys.data('splitchargegroupbytermsession')),
                TotalToPay: Number($sys.data('totaltopay')),
            };
        }
        model.AccountSummaryModel = AccountSummaryModel;
        function EntryTransactionsBaseModel($sys) {
            return {
                CannotDisputeTransactionMessage: $sys.data('cannotdisputetransactionmessage'),
                ChargeGroupID: $sys.data('chargegroupid'),
                LoadTransactionsErrorMessage: $sys.data('loadtransactionserrormessage'),
                Transaction_TermSessionID: $sys.data('transaction_termsessionid'),
                TransactionsNotSelectedErrorMessage: $sys.data('transactionsnotselectederrormessage'),
            };
        }
        model.EntryTransactionsBaseModel = EntryTransactionsBaseModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var accounts;
        (function (accounts) {
            "use strict";
            class AddPaymentsToCart extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "AddPaymentsToCart";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        payments: this.o.payments,
                    };
                    return obj;
                }
            }
            accounts.AddPaymentsToCart = AddPaymentsToCart;
            class GetAccountDetails extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetAccountDetails";
                }
                CallData() {
                    var obj = {
                        chargeGroupID: this.o.chargeGroupID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            accounts.GetAccountDetails = GetAccountDetails;
            class GetAccountDetailsForTermSession extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetAccountDetailsForTermSession";
                }
                CallData() {
                    var obj = {
                        chargeGroupID: this.o.chargeGroupID,
                        pageID: this.o.pageID,
                        termSessionID: this.o.termSessionID,
                    };
                    return obj;
                }
            }
            accounts.GetAccountDetailsForTermSession = GetAccountDetailsForTermSession;
            class GetAccountDetailsForTermSessionResponsive extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetAccountDetailsForTermSessionResponsive";
                }
                CallData() {
                    var obj = {
                        chargeGroupID: this.o.chargeGroupID,
                        isMobile: this.o.isMobile,
                        pageID: this.o.pageID,
                        termSessionID: this.o.termSessionID,
                    };
                    return obj;
                }
            }
            accounts.GetAccountDetailsForTermSessionResponsive = GetAccountDetailsForTermSessionResponsive;
            class GetAccountDetailsResponsive extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetAccountDetailsResponsive";
                }
                CallData() {
                    var obj = {
                        chargeGroupID: this.o.chargeGroupID,
                        isMobile: this.o.isMobile,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            accounts.GetAccountDetailsResponsive = GetAccountDetailsResponsive;
            class GetDisputeUrl extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetDisputeUrl";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        transactionIDs: this.o.transactionIDs,
                    };
                    return obj;
                }
            }
            accounts.GetDisputeUrl = GetDisputeUrl;
            class GetDisputeUrlByPageID extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetDisputeUrlByPageID";
                }
                CallData() {
                    var obj = {
                        disputePageID: this.o.disputePageID,
                        pageID: this.o.pageID,
                        transactionIDs: this.o.transactionIDs,
                    };
                    return obj;
                }
            }
            accounts.GetDisputeUrlByPageID = GetDisputeUrlByPageID;
            class GetInvoiceReport extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetInvoiceReport";
                }
                CallData() {
                    var obj = {
                        invoiceID: this.o.invoiceID,
                        isEventEnquiry: this.o.isEventEnquiry,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            accounts.GetInvoiceReport = GetInvoiceReport;
            class GetReportLayouts extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetReportLayouts";
                }
                CallData() {
                    var obj = {
                        isStatement: this.o.isStatement,
                        reportType: this.o.reportType,
                    };
                    return obj;
                }
            }
            accounts.GetReportLayouts = GetReportLayouts;
            class GetStatementDateInput extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetStatementDateInput";
                }
                CallData() {
                    var obj = {
                        chargeGroupID: this.o.chargeGroupID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            accounts.GetStatementDateInput = GetStatementDateInput;
            class GetStatementDateInputByPageID extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetStatementDateInputByPageID";
                }
                CallData() {
                    var obj = {
                        chargeGroupID: this.o.chargeGroupID,
                        pageID: this.o.pageID,
                        statementPageID: this.o.statementPageID,
                    };
                    return obj;
                }
            }
            accounts.GetStatementDateInputByPageID = GetStatementDateInputByPageID;
            class GetStatementReport extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "GetStatementReport";
                }
                CallData() {
                    var obj = {
                        chargeGroupID: this.o.chargeGroupID,
                        dateEnd: this.o.dateEnd,
                        dateStart: this.o.dateStart,
                        isEventEnquiry: this.o.isEventEnquiry,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            accounts.GetStatementReport = GetStatementReport;
            class PayAll extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Accounts";
                    this.Controller = "accounts";
                    this.Action = "PayAll";
                }
                CallData() {
                    var obj = {
                        amount: this.o.amount,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            accounts.PayAll = PayAll;
        })(accounts = service.accounts || (service.accounts = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var additionaloccupant;
        (function (additionaloccupant) {
            var management;
            (function (management) {
                "use strict";
                function InitialiseFieldListEditor($container) {
                    portal.fieldlist.control.InitFieldListManager($container, existingFields => new starrez.service.additionaloccupant.CreateNewField({
                        existingFields: existingFields
                    }));
                }
                management.InitialiseFieldListEditor = InitialiseFieldListEditor;
                function InitialiseAdditionalOccupantList($container) {
                    new AdditionalOccupantListManager($container);
                }
                management.InitialiseAdditionalOccupantList = InitialiseAdditionalOccupantList;
                class AdditionalOccupantListManager {
                    constructor($container) {
                        this.$container = $container;
                        this.model = starrez.model.AdditionalOccupantManagementModel($container);
                        this.$container.find(".ui-delete-occupant").SRClick((e) => this.DeleteOccupant(e));
                        this.$container.find(".ui-view-occupant").SRClick((e) => this.ViewOccupant(e));
                    }
                    DeleteOccupant(e) {
                        var $button = $(e.currentTarget);
                        var $actionPanel = $button.closest(".ui-action-panel");
                        var message = $button.data("deleteconfirmationtext").toString();
                        portal.ConfirmAction(message, this.model.DeleteOccupantConfirmationHeaderText).done(() => {
                            var hash = $button.data("hash").toString();
                            var bookingOccupantID = this.GetBookingOccupantID($actionPanel);
                            new starrez.service.additionaloccupant.DeleteOccupant({
                                hash: hash,
                                pageID: portal.page.CurrentPage.PageID,
                                bookingOccupantID: bookingOccupantID
                            }).Post().done(() => {
                                location.reload();
                            });
                        });
                    }
                    ViewOccupant(e) {
                        var $button = $(e.currentTarget);
                        var $actionPanel = $button.closest(".ui-action-panel");
                        var hash = $button.data("hash").toString();
                        var bookingOccupantID = this.GetBookingOccupantID($actionPanel);
                        new starrez.service.additionaloccupant.RedirectToDetailsPage({
                            hash: hash,
                            pageID: portal.page.CurrentPage.PageID,
                            bookingOccupantID: bookingOccupantID,
                            readOnly: !this.model.AllowEdit
                        }).Post().done((url) => {
                            location.href = url;
                        });
                    }
                    GetBookingOccupantID($actionPanel) {
                        return Number($actionPanel.data("bookingoccupantid"));
                    }
                }
            })(management = additionaloccupant.management || (additionaloccupant.management = {}));
        })(additionaloccupant = general.additionaloccupant || (general.additionaloccupant = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.additionaloccupant.management.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var additionaloccupant;
        (function (additionaloccupant) {
            var search;
            (function (search) {
                "use strict";
                function InitialiseAdditionalOccupantSearch($container) {
                    new AdditionalOccupantSearch($container);
                }
                search.InitialiseAdditionalOccupantSearch = InitialiseAdditionalOccupantSearch;
                class AdditionalOccupantSearch {
                    constructor($container) {
                        this.$container = $container;
                        this.$searchPreviousContainer = this.$container.find(".ui-search-previous-container");
                        this.$searchAllContainer = this.$container.find(".ui-search-all-container");
                        this.$searchAllResult = this.$container.find(".ui-search-all-result");
                        this.$searchAllConfigurableFieldList = this.$container.find(".ui-search-all-configurable-field-list");
                        this.$SearchAll = $container.GetControl("SearchAll_Selected");
                        this.$radioButtons = this.$container.GetControl("ui-radio-search-type");
                        this.$searchbutton = this.$container.find(".ui-btn-search-all");
                        this.AttachRadioButtonClickEvent();
                        this.AttachSearchButtonClickEvent();
                        this.bookingIDs = $container.data("entrybookingids");
                        this.noSearchCriteriaErrorMessage = $container.data("nosearchcriteriaerrormessage");
                        this.$container.find(".ui-field .ui-input").keydown(e => {
                            if (e.keyCode === starrez.keyboard.EnterCode) {
                                this.RunSearch();
                                // The browsers have a behaviour where they will automatically submit the form if there is only one
                                // input field on it. This is not what we want to do, so call SafeStopPropagation to block this from happening.
                                // http://stackoverflow.com/questions/1370021/why-does-forms-with-single-input-field-submit-upon-pressing-enter-key-in-input
                                starrez.library.utils.SafeStopPropagation(e);
                                return false;
                            }
                        });
                    }
                    AttachRadioButtonClickEvent() {
                        this.$radioButtons.each((_, element) => {
                            starrez.keyboard.AttachSelectEvent($(element), (e) => { $(element).trigger("click"); });
                        });
                        this.$radioButtons.SRClick((e) => {
                            const $rdo = $(e.currentTarget);
                            const radioValue = $rdo.SRVal();
                            if (radioValue === "search-all") {
                                this.$SearchAll.SRVal(true);
                                this.$searchPreviousContainer.hide();
                                this.$searchAllContainer.show();
                            }
                            else {
                                this.$SearchAll.SRVal(false);
                                this.$searchPreviousContainer.show();
                                this.$searchAllContainer.hide();
                            }
                        });
                    }
                    AttachSearchButtonClickEvent() {
                        this.$searchbutton.SRClick(() => this.RunSearch());
                    }
                    RunSearch() {
                        var filters = this.GetSearchFilters();
                        if (filters.filter((filter) => starrez.library.stringhelper.IsUndefinedOrEmpty(filter.Value)).length == 0) {
                            new starrez.service.additionaloccupant.SearchForEntry({
                                pageID: portal.page.CurrentPage.PageID,
                                bookingIDs: this.bookingIDs,
                                enteredValues: filters
                            }).Post().done((newHTML) => {
                                this.$searchAllResult.html(newHTML);
                                this.$searchAllResult.GetControl("SearchAll_EntryID").each((_, element) => {
                                    starrez.keyboard.AttachSelectEvent($(element), (e) => { $(element).trigger("click"); });
                                });
                            });
                            ;
                        }
                        else {
                            portal.page.CurrentPage.SetErrorMessage(this.noSearchCriteriaErrorMessage);
                        }
                    }
                    GetSearchFilters() {
                        return this.$container.find(".ui-field").GetAllControls().map((index, ctrl) => this.GetPopulatedFilter($(ctrl))).toArray();
                    }
                    GetControlKey($ctrl) {
                        return $ctrl.closest("li").data("field-id").toString();
                    }
                    GetPopulatedFilter($ctrl) {
                        return {
                            Key: this.GetControlKey($ctrl),
                            Value: $ctrl.SRVal()
                        };
                    }
                }
            })(search = additionaloccupant.search || (additionaloccupant.search = {}));
        })(additionaloccupant = general.additionaloccupant || (general.additionaloccupant = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.additionaloccupant.search.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function AdditionalOccupantManagementModel($sys) {
            return {
                AllowEdit: starrez.library.convert.ToBoolean($sys.data('allowedit')),
                AutomaticAdditionalOccupantOption: $sys.data('automaticadditionaloccupantoption'),
                DeleteOccupantConfirmationHeaderText: $sys.data('deleteoccupantconfirmationheadertext'),
            };
        }
        model.AdditionalOccupantManagementModel = AdditionalOccupantManagementModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var additionaloccupant;
        (function (additionaloccupant) {
            "use strict";
            class CreateNewField extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "AdditionalOccupant";
                    this.Controller = "additionaloccupant";
                    this.Action = "CreateNewField";
                }
                CallData() {
                    var obj = {
                        existingFields: this.o.existingFields,
                    };
                    return obj;
                }
            }
            additionaloccupant.CreateNewField = CreateNewField;
            class DeleteOccupant extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "AdditionalOccupant";
                    this.Controller = "additionaloccupant";
                    this.Action = "DeleteOccupant";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        bookingOccupantID: this.o.bookingOccupantID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            additionaloccupant.DeleteOccupant = DeleteOccupant;
            class RedirectToDetailsPage extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "AdditionalOccupant";
                    this.Controller = "additionaloccupant";
                    this.Action = "RedirectToDetailsPage";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        bookingOccupantID: this.o.bookingOccupantID,
                        pageID: this.o.pageID,
                        readOnly: this.o.readOnly,
                    };
                    return obj;
                }
            }
            additionaloccupant.RedirectToDetailsPage = RedirectToDetailsPage;
            class RedirectToSearchOccupantPage extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "AdditionalOccupant";
                    this.Controller = "additionaloccupant";
                    this.Action = "RedirectToSearchOccupantPage";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        bookingOccupantID: this.o.bookingOccupantID,
                        pageID: this.o.pageID,
                        readOnly: this.o.readOnly,
                    };
                    return obj;
                }
            }
            additionaloccupant.RedirectToSearchOccupantPage = RedirectToSearchOccupantPage;
            class SearchForEntry extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "AdditionalOccupant";
                    this.Controller = "additionaloccupant";
                    this.Action = "SearchForEntry";
                }
                CallData() {
                    var obj = {
                        bookingIDs: this.o.bookingIDs,
                        enteredValues: this.o.enteredValues,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            additionaloccupant.SearchForEntry = SearchForEntry;
        })(additionaloccupant = service.additionaloccupant || (service.additionaloccupant = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var general;
    (function (general) {
        var adobesign;
        (function (adobesign) {
            "use strict";
            const initialAdobeSignDocumentCreationWaitDelay = 700;
            const maxAdobeSignDocumentCreationWaitAttempts = 5;
            const adobeSignCreationMultiplier = 1.5;
            const waitTimeForAgreementNotExposed = 500;
            class AdobeSignAgreementViewResult {
            }
            function InitAdobeSignWidget($container) {
                new AdobeSignModel($container);
            }
            adobesign.InitAdobeSignWidget = InitAdobeSignWidget;
            class AdobeSignModel {
                constructor($container) {
                    this.$container = $container;
                    this.widgetID = Number($container.data("portalpagewidgetid"));
                    this.model = starrez.model.AdobeSignWidgetModel($container);
                    this.AttachEvents();
                }
                AttachEvents() {
                    this.AttachLoadAgreement();
                }
                AttachLoadAgreement() {
                    const $adobeSignContainer = this.$container.find(".ui-adobe-sign-frame-container");
                    const $agreementLoader = this.$container.find(".ui-agreement-loader");
                    if ($agreementLoader.isFound()) {
                        const getAgreementViewUrlHash = $agreementLoader.data("getagreementviewhash");
                        const isAgreementReadyForSignatureUrlHash = $agreementLoader.data("isagreementreadyforsignatureurlhash");
                        const agreement = $agreementLoader.data("agreement");
                        const entryPortalDataID = $agreementLoader.data("entryportaldataid");
                        this.WaitForAgreementToBeReady(agreement, isAgreementReadyForSignatureUrlHash).then((isAgreementReady) => {
                            if (isAgreementReady) {
                                const callServer = (retry = true) => {
                                    return new Promise((resolve, reject) => {
                                        const call = new starrez.ServerRequest("General/AdobeSign", "AdobeSign", "GetAgreementView", {
                                            portalPageWidgetID: this.widgetID,
                                            entryPortalDataID: entryPortalDataID,
                                            hash: getAgreementViewUrlHash
                                        });
                                        call.Get().done((result) => {
                                            if (result.IsAgreementReadyAndExposed) {
                                                resolve(result);
                                            }
                                            else if (retry) {
                                                this.Sleep(waitTimeForAgreementNotExposed).then(e => {
                                                    callServer(false).then(resolve).catch(reject);
                                                });
                                            }
                                            else {
                                                reject();
                                            }
                                        });
                                    });
                                };
                                callServer().then((result) => {
                                    $adobeSignContainer.html(result.AgreementView);
                                }).catch(err => {
                                    $adobeSignContainer.html(this.model.DocumentCreationFailedMessage);
                                });
                            }
                            else {
                                $adobeSignContainer.html(this.model.DocumentCreationFailedMessage);
                            }
                        });
                    }
                }
                WaitForAgreementToBeReady(agreement, hash) {
                    // After the agreement is created, it takes AdobeSign a few moments to actually create the document in it's internal
                    // system so that it can be used. This function will poll the AdobeSign API to get the status of the document
                    // so that we can tell once it has been created and we can safely get the signing url.
                    let attemptsMade = 0;
                    let sleepTimer = initialAdobeSignDocumentCreationWaitDelay;
                    return this.WaitForAgreementToBeReadyLoop(sleepTimer, attemptsMade, agreement, hash);
                }
                WaitForAgreementToBeReadyLoop(sleepTimer, attemptsMade, agreement, hash) {
                    return this.Sleep(sleepTimer).then(() => {
                        return this.IsAgreementReady(agreement, hash).then((isAgreementReadyForSignature) => {
                            if (isAgreementReadyForSignature) {
                                return true;
                            }
                            else if (attemptsMade >= maxAdobeSignDocumentCreationWaitAttempts) {
                                return false;
                            }
                            else {
                                sleepTimer = sleepTimer * adobeSignCreationMultiplier;
                                attemptsMade = attemptsMade + 1;
                                return this.WaitForAgreementToBeReadyLoop(sleepTimer, attemptsMade, agreement, hash);
                            }
                        });
                    });
                }
                IsAgreementReady(agreement, hash) {
                    const call = new starrez.service.adobesign.IsAgreementReadyForSignature({
                        agreement: agreement,
                        portalPageWidgetID: this.widgetID,
                        hash: hash
                    });
                    return new Promise((resolve) => {
                        call.Post().done((isAgreementReadyForSignature) => {
                            return resolve(isAgreementReadyForSignature);
                        });
                    });
                }
                Sleep(time) {
                    return new Promise((resolve) => {
                        setTimeout(resolve, time);
                    });
                }
            }
        })(adobesign = general.adobesign || (general.adobesign = {}));
    })(general = starrez.general || (starrez.general = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.general.adobesign.js.map
"use strict";
var starrez;
(function (starrez) {
    var general;
    (function (general) {
        var adobesigneditor;
        (function (adobesigneditor) {
            "use strict";
            let SignatoryStatus;
            (function (SignatoryStatus) {
                SignatoryStatus[SignatoryStatus["SignatoryNotFound"] = 0] = "SignatoryNotFound";
                SignatoryStatus[SignatoryStatus["SignatoryFoundAndActive"] = 1] = "SignatoryFoundAndActive";
                SignatoryStatus[SignatoryStatus["SignatoryFoundAndInactive"] = 2] = "SignatoryFoundAndInactive";
                SignatoryStatus[SignatoryStatus["NotAuthenticated"] = 3] = "NotAuthenticated";
            })(SignatoryStatus || (SignatoryStatus = {}));
            let GroupNameStatus;
            (function (GroupNameStatus) {
                GroupNameStatus[GroupNameStatus["GroupNameFound"] = 0] = "GroupNameFound";
                GroupNameStatus[GroupNameStatus["GroupNameNotFound"] = 1] = "GroupNameNotFound";
                GroupNameStatus[GroupNameStatus["GroupNameNotSpecified"] = 2] = "GroupNameNotSpecified";
                GroupNameStatus[GroupNameStatus["NotAuthenticated"] = 3] = "NotAuthenticated";
            })(GroupNameStatus || (GroupNameStatus = {}));
            class SignatoryValidationResult {
            }
            class GroupValidationResult {
            }
            function InitAdobeSignSettingsEditor($container) {
                portal.editor.widget.OnWidgetSettingsSave = () => {
                    const def = $.Deferred();
                    const $signatoryControl = $container.GetControl("AdobeAcrobatSignSignatoryID");
                    const $addAdobeSignSignatoryOption = $container.GetControl("AddAdobeAcrobatSignSignatory");
                    const $addAdobeSignGroupOption = $container.GetControl("GroupName");
                    if ($addAdobeSignSignatoryOption.SRVal()) {
                        const portalPageWidgetID = GetPortalPageWidgetID($container[0]);
                        const validatecall = new starrez.ServerRequest("General/AdobeSign", "AdobeSign", "ValidateSignatory", {
                            signatoryEmail: $signatoryControl.SRVal(),
                            portalPageWidgetID: portalPageWidgetID,
                            hash: $signatoryControl.data("validatesignatoryhash")
                        });
                        validatecall.Get().done((result) => {
                            if (result.SignatoryStatus === SignatoryStatus.SignatoryFoundAndInactive) {
                                portal.ConfirmAction("Warning: You have selected a deactivated signatory. This means your organization will not be able to complete the signing of any agreements for this widget.", "Deactivated Signatory", "Cancel", "Continue Anyway").fail(() => {
                                    ValidateAndSaveGroup($addAdobeSignGroupOption, $container).done(() => {
                                        def.resolve();
                                    });
                                }).done(() => {
                                    def.reject();
                                });
                            }
                            else if (result.SignatoryStatus === SignatoryStatus.SignatoryNotFound) {
                                portal.ShowMessage("Error: The signatory email you have entered does not exist in your Adobe Acrobat Sign account. Please enter a valid Adobe Acrobat Sign signatory email.", "Invalid Signatory").done(() => {
                                    def.reject();
                                });
                            }
                            else if (result.SignatoryStatus === SignatoryStatus.NotAuthenticated) {
                                portal.ShowMessage("Error: Unable to validate the signatory email. Please first authenticate with Adobe Acrobat Sign in the StarRez Web Marketplace tile prior to adding a signatory.", "Authentication Error").done(() => {
                                    def.reject();
                                });
                            }
                            else {
                                // Other statuses SignatoryFoundAndActive and SignatoryNotRequired do not require any action
                                const savecall = new starrez.ServerRequest("General/AdobeSign", "AdobeSign", "SaveSignatory", {
                                    signatoryID: result.SignatoryID,
                                    portalPageWidgetID: portalPageWidgetID,
                                    hash: $signatoryControl.data("savesignatoryhash"),
                                });
                                savecall.Post().done(() => {
                                    ValidateAndSaveGroup($addAdobeSignGroupOption, $container).done(() => {
                                        def.resolve();
                                    });
                                });
                            }
                        });
                    }
                    else {
                        // The option to require a signatory is not enabled, so no need to validate this
                        ValidateAndSaveGroup($addAdobeSignGroupOption, $container).done(() => {
                            def.resolve();
                        });
                    }
                    return def.promise();
                };
            }
            adobesigneditor.InitAdobeSignSettingsEditor = InitAdobeSignSettingsEditor;
            function InitTemplateSelection(container, options) {
                // As the template list comes from a call to Adobe Sign, we need to populate the template list manually
                const call = new starrez.service.adobesign.GetTemplateList({
                    portalPageWidgetID: GetPortalPageWidgetID(container),
                    hash: options.getListFunctionHash
                });
                call.Get().done((result) => {
                    if (result.IsAuthenticated) {
                        const AdobeSignTemplateDropDown = $(container).GetControl("AdobeAcrobatSignTemplateID");
                        starrez.library.controls.dropdown.FillDropDown(result.TemplateList, AdobeSignTemplateDropDown, "TemplateID", "TemplateName", result.SelectedItem, false);
                    }
                    else {
                        SetNotAuthenticatedMessage(container);
                    }
                });
            }
            adobesigneditor.InitTemplateSelection = InitTemplateSelection;
            function InitSignatorySelection(container, options) {
                const signatoryControl = $(container).GetControl("AdobeAcrobatSignSignatoryID");
                signatoryControl.attr("data-validatesignatoryhash", options.validateSignatoryHash);
                signatoryControl.attr("data-savesignatoryhash", options.saveSignatoryHash);
            }
            adobesigneditor.InitSignatorySelection = InitSignatorySelection;
            function InitGroupNameSelection(container, options) {
                const groupControl = $(container).GetControl("GroupName");
                groupControl.attr("data-validategroupnamehash", options.validateGroupNameHash);
                groupControl.attr("data-savegroupnamehash", options.saveGroupNameHash);
            }
            adobesigneditor.InitGroupNameSelection = InitGroupNameSelection;
            function ValidateAndSaveGroup($addAdobeSignGroupOption, $container) {
                const def = $.Deferred();
                const portalPageWidgetID = GetPortalPageWidgetID($container[0]);
                if ($addAdobeSignGroupOption.SRVal()) {
                    const validatecall = new starrez.ServerRequest("General/AdobeSign", "AdobeSign", "ValidateGroupName", {
                        groupName: $addAdobeSignGroupOption.SRVal(),
                        portalPageWidgetID: portalPageWidgetID,
                        hash: $addAdobeSignGroupOption.data("validategroupnamehash")
                    });
                    validatecall.Get().done((result) => {
                        if (result.GroupNameStatus === GroupNameStatus.GroupNameNotFound) {
                            portal.ShowMessage("Error: You have selected a group that does not exist in your Adobe Acrobat Sign account.", "Invalid Group").done(() => {
                                def.reject(false);
                            });
                        }
                        else if (result.GroupNameStatus === GroupNameStatus.NotAuthenticated) {
                            portal.ShowMessage("Error: Unable to validate the group name. Please first authenticate with Adobe Acrobat Sign in the StarRez Web Marketplace tile prior to adding a group.", "Authentication Error").done(() => {
                                def.reject(false);
                            });
                        }
                        else {
                            SaveGroupName(result, portalPageWidgetID, $addAdobeSignGroupOption).done(() => {
                                def.resolve(true);
                            });
                        }
                    });
                }
                else {
                    const result = new GroupValidationResult();
                    result.GroupNameStatus = GroupNameStatus.GroupNameNotSpecified;
                    SaveGroupName(result, portalPageWidgetID, $addAdobeSignGroupOption).done(() => {
                        def.resolve(true);
                    });
                }
                return def.promise();
            }
            function SaveGroupName(groupValidationResult, portalPageWidgetID, $addAdobeSignGroupOption) {
                const savecall = new starrez.ServerRequest("General/AdobeSign", "AdobeSign", "SaveGroupName", {
                    groupID: groupValidationResult.GroupID,
                    groupName: groupValidationResult.GroupName,
                    portalPageWidgetID: portalPageWidgetID,
                    hash: $addAdobeSignGroupOption.data("savegroupnamehash")
                });
                return savecall.Post();
            }
            function GetPortalPageWidgetID(container) {
                const widgetSettings = container.closest(".ui-widget-settings");
                return (parseInt(widgetSettings.dataset["portalpagewidgetid"]));
            }
            function SetNotAuthenticatedMessage(container) {
                // If we are not authenticated with Adobe Sign it is not possible to get the template or signatory list. Show a message to indicate this to the user.
                container.innerHTML = "<span class=\"not-authenticated-setting-message\">Please first authenticate with the Adobe Acrobat Sign Marketplace tile in StarRez Web.</span>";
            }
        })(adobesigneditor = general.adobesigneditor || (general.adobesigneditor = {}));
    })(general = starrez.general || (starrez.general = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.general.adobesigneditor.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function AdobeSignWidgetModel($sys) {
            return {
                DocumentCreationFailedMessage: $sys.data('documentcreationfailedmessage'),
                MergeFieldValues: $sys.data('mergefieldvalues'),
            };
        }
        model.AdobeSignWidgetModel = AdobeSignWidgetModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var adobesign;
        (function (adobesign) {
            "use strict";
            class GetAgreementView extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "AdobeSign";
                    this.Controller = "adobesign";
                    this.Action = "GetAgreementView";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        entryPortalDataID: this.o.entryPortalDataID,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            adobesign.GetAgreementView = GetAgreementView;
            class GetSignatoryList extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "AdobeSign";
                    this.Controller = "adobesign";
                    this.Action = "GetSignatoryList";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            adobesign.GetSignatoryList = GetSignatoryList;
            class GetTemplateList extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "AdobeSign";
                    this.Controller = "adobesign";
                    this.Action = "GetTemplateList";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            adobesign.GetTemplateList = GetTemplateList;
            class IsAgreementReadyForSignature extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "AdobeSign";
                    this.Controller = "adobesign";
                    this.Action = "IsAgreementReadyForSignature";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        agreement: this.o.agreement,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            adobesign.IsAgreementReadyForSignature = IsAgreementReadyForSignature;
            class IsSignatoryActive extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "AdobeSign";
                    this.Controller = "adobesign";
                    this.Action = "IsSignatoryActive";
                }
                CallData() {
                    var obj = {
                        signatoryID: this.o.signatoryID,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            adobesign.IsSignatoryActive = IsSignatoryActive;
        })(adobesign = service.adobesign || (service.adobesign = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var application;
        (function (application) {
            var termselector;
            (function (termselector) {
                "use strict";
                function Initialise($container) {
                    new TermSelector($container);
                }
                termselector.Initialise = Initialise;
                class TermSelector {
                    constructor($container) {
                        this.$term = $container.GetControl('TermID');
                        this.$classification = $container.GetControl('ClassificationID');
                        this.$applyButton = $container.find('.ui-select-action');
                        this.AttachClickEvents($container);
                    }
                    AttachClickEvents($container) {
                        this.$applyButton.SRClick((e) => {
                            var $self = $(e.currentTarget);
                            var termID = $self.closest('.ui-action-panel').data('termid');
                            var classificationID = $self.closest('.ui-action-panel').data('classificationid');
                            this.ApplyForTerm(termID, classificationID);
                            starrez.library.utils.SafeStopPropagation(e);
                        });
                    }
                    ApplyForTerm(termID, classificationID) {
                        if (starrez.library.utils.IsNotNullUndefined(termID)) {
                            this.$term.SRVal(termID);
                        }
                        if (starrez.library.utils.IsNotNullUndefined(classificationID) && starrez.library.utils.IsNotNullUndefined(termID)) {
                            this.$classification.SRVal(classificationID);
                        }
                        portal.page.CurrentPage.SubmitPage();
                    }
                }
            })(termselector = application.termselector || (application.termselector = {}));
        })(application = general.application || (general.application = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.application.termselector.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var applicationpreferences;
    (function (applicationpreferences) {
        "use strict";
        function InitApplicationPreferencesPage($container) {
            new ApplicationPreferencesWidget($container);
        }
        applicationpreferences.InitApplicationPreferencesPage = InitApplicationPreferencesPage;
        class ApplicationPreferencesWidget {
            constructor($container) {
                this.$container = $container;
                this.applicationPreferencesModel = starrez.model.ApplicationPreferencesModel($container);
                this.loadPreferencesErrorMessage = this.applicationPreferencesModel.LoadPreferencesErrorMessage;
                this.addButtonErrorMessage = this.applicationPreferencesModel.AddButtonErrorMessage;
                this.saveButtonErrorMessage = this.applicationPreferencesModel.SaveButtonErrorMessage;
                this.preferenceNotSelectedErrorMessage = this.applicationPreferencesModel.PreferenceNotSelectedErrorMessage;
                this.maximumNumberOfPreferences = this.applicationPreferencesModel.MaximumNumberOfPreferences;
                this.$addButton = this.$container.find('.ui-add-application-preference');
                this.$saveButton = $('body').find('.ui-submit-page-content');
                this.$preferenceMessage = this.$container.find('.ui-preference-message');
                this.maximumNumberOfPreferencesOverallErrorMessage = this.applicationPreferencesModel.MaximumNumberOfPreferencesOverallErrorMessage;
                this.pageID = portal.page.CurrentPage.PageID;
                this.isValid = true;
                this.$responsiveTableContainer = $container.find('.ui-responsive-active-table-container');
                this.$responsiveTableContainer.on(starrez.activetable.responsive.eventTableLoaded, () => {
                    this.BindTable();
                });
            }
            BindTable() {
                // Bind events in here
                this.preferencesTable = starrez.tablesetup.CreateTableManager(this.$responsiveTableContainer.find("table"), $('body'))[0];
                this.AttachDeleteEvents();
                this.AttachAddEvents();
                this.AttachRowEvents();
                this.EnableAddAndSave();
                portal.page.CurrentPage.FetchAdditionalData = () => this.GetData();
                portal.page.CurrentPage.AddCustomValidation(this);
            }
            IsMobile() {
                return this.$responsiveTableContainer.data('isMobile') === true;
            }
            GetRowSelector() {
                return this.IsMobile() ? "tbody" : "tbody tr";
            }
            GetRows() {
                return this.preferencesTable.$table.find(this.GetRowSelector());
            }
            AttachDeleteEvents() {
                this.preferencesTable.$table.SRClickDelegate('delete', '.ui-btn-delete', (e) => {
                    var $deleteButton = $(e.currentTarget);
                    $deleteButton.closest(this.GetRowSelector()).remove();
                    this.EnableAddAndSave();
                    this.UpdatePreferenceMessage();
                    this.UpdateRowOrder();
                });
            }
            AttachRowEvents() {
                this.preferencesTable.$table.SRClickDelegate('ok', '.ui-btn-ok', (e) => {
                    var $okButton = $(e.currentTarget);
                    var $preferenceDropDown = $okButton.closest(this.GetRowSelector()).GetControl('PreferenceDropdown');
                    var preferenceValue = $preferenceDropDown.SRVal();
                    if (preferenceValue === "-1") {
                        alert(this.preferenceNotSelectedErrorMessage);
                        return false;
                    }
                    var hash = this.preferencesTable.$table.attr('displaypreferencehash').toString();
                    new starrez.service.applicationpreferences.ActiveTableDisplayPreferenceRow({
                        index: this.GetRows().length,
                        pageID: this.pageID,
                        preferenceID: Number(preferenceValue),
                        hash: hash,
                        isMobile: this.IsMobile()
                    }).Post().done((results) => {
                        if (starrez.library.utils.IsNotNullUndefined(results)) {
                            if (this.IsMobile()) {
                                this.preferencesTable.$table.append(results);
                            }
                            else {
                                if (!this.preferencesTable.$table.find('tbody').isFound()) {
                                    this.preferencesTable.$table.append('<tbody></tbody>');
                                }
                                this.preferencesTable.$table.find('tbody').append(results);
                            }
                            $okButton.closest(this.GetRowSelector()).remove();
                        }
                        else {
                            portal.page.CurrentPage.SetErrorMessage(this.loadPreferencesErrorMessage);
                        }
                        this.UpdateRowOrder();
                        this.EnableAddAndSave();
                    });
                });
                this.preferencesTable.$table.SRClickDelegate('cancel', '.ui-btn-cancel', (e) => {
                    var $cancelButton = $(e.currentTarget);
                    $cancelButton.closest(this.GetRows()).remove();
                    this.UpdatePreferenceMessage();
                    this.EnableAddAndSave();
                });
            }
            EnableAddAndSave() {
                this.$addButton.prop("title", "");
                this.$saveButton.prop("title", "");
                if (this.maximumNumberOfPreferences > this.GetRows().length) {
                    this.$addButton.Enable();
                }
                this.$saveButton.Enable();
                this.isValid = true;
            }
            AddPreferenceRowTable(results) {
                if (!results.IsPreferenceLimitReached) {
                    if (this.IsMobile()) {
                        this.preferencesTable.$table.append(results.PreferenceRow);
                    }
                    else {
                        if (!this.preferencesTable.$table.find('tbody').isFound()) {
                            this.preferencesTable.$table.append('<tbody></tbody>');
                        }
                        this.preferencesTable.$table.find('tbody').append(results.PreferenceRow);
                    }
                    this.UpdateRowOrder();
                }
                if (this.maximumNumberOfPreferences <= this.GetRows().length) {
                    this.$preferenceMessage.find('div').text(this.maximumNumberOfPreferencesOverallErrorMessage);
                }
                else {
                    this.$preferenceMessage.html(results.DisplayNotificationMessage);
                }
            }
            AddPreferenceRow() {
                var preferenceIDs = this.GetPreferenceIDs();
                var hash = this.preferencesTable.$table.attr('editpreferencehash').toString();
                new starrez.service.applicationpreferences.ActiveTableEditPreferenceOnlyRow({
                    index: this.GetRows().length,
                    preferenceIDs: preferenceIDs,
                    pageID: this.pageID,
                    hash: hash,
                    isMobile: this.IsMobile()
                }).Post().done((results) => {
                    if (starrez.library.utils.IsNotNullUndefined(results)) {
                        this.AddPreferenceRowTable(results);
                    }
                    else {
                        portal.page.CurrentPage.SetErrorMessage(this.loadPreferencesErrorMessage);
                    }
                });
                this.$addButton.prop("title", this.addButtonErrorMessage);
                this.$saveButton.prop("title", this.saveButtonErrorMessage);
                this.$addButton.Disable();
                this.$saveButton.Disable();
                this.isValid = false;
            }
            AttachAddEvents() {
                this.$addButton.SRClick(() => {
                    this.AddPreferenceRow();
                });
                if (this.maximumNumberOfPreferences <= this.GetRows().length) {
                    this.$addButton.Disable();
                }
            }
            Validate() {
                var deferred = $.Deferred();
                if (this.isValid) {
                    deferred.resolve();
                }
                else {
                    deferred.reject();
                }
                return deferred.promise();
            }
            GetPreferenceIDs() {
                var preferenceIDs = [];
                this.GetRows().each((index, element) => {
                    preferenceIDs.push(Number($(element).data('id')));
                });
                return preferenceIDs;
            }
            UpdateRowOrder() {
                var $rowOrders = this.preferencesTable.$table.find('.ui-order-column');
                var preferenceNumber = 1;
                $rowOrders.each((index, element) => {
                    $(element).text(preferenceNumber);
                    preferenceNumber++;
                });
            }
            UpdatePreferenceMessage() {
                new starrez.service.applicationpreferences.DeleteRowMessage({
                    numberOfPreferences: this.GetPreferenceIDs().length,
                    pageID: this.pageID
                }).Post().done((results) => {
                    this.$preferenceMessage.html(results);
                });
            }
            GetData() {
                var data = this.GetPreferenceIDs();
                return {
                    SelectedPreferences: data
                };
            }
        }
        class ApplicationPreferencesModel {
            constructor($container) {
                this.$container = $container;
                this.preferencesTable = starrez.tablesetup.CreateTableManager(this.$container.find(".ui-application-preferences-table table"), $('body'))[0];
                this.applicationPreferencesModel = starrez.model.ApplicationPreferencesModel($container);
                this.loadPreferencesErrorMessage = this.applicationPreferencesModel.LoadPreferencesErrorMessage;
                this.addButtonErrorMessage = this.applicationPreferencesModel.AddButtonErrorMessage;
                this.saveButtonErrorMessage = this.applicationPreferencesModel.SaveButtonErrorMessage;
                this.preferenceNotSelectedErrorMessage = this.applicationPreferencesModel.PreferenceNotSelectedErrorMessage;
                this.maximumNumberOfPreferences = this.applicationPreferencesModel.MaximumNumberOfPreferences;
                this.$tbody = this.preferencesTable.$table.find('tbody');
                this.$addButton = this.$container.find('.ui-add-application-preference');
                this.$saveButton = $('body').find('.ui-submit-page-content');
                this.$preferenceMessage = this.$container.find('.ui-preference-message');
                this.maximumNumberOfPreferencesOverallErrorMessage = this.applicationPreferencesModel.MaximumNumberOfPreferencesOverallErrorMessage;
                this.pageID = portal.page.CurrentPage.PageID;
                this.AttachDeleteEvents();
                this.AttachAddEvents();
                this.AttachRowEvents();
                this.isValid = true;
                portal.page.CurrentPage.FetchAdditionalData = () => this.GetData();
                portal.page.CurrentPage.AddCustomValidation(this);
            }
            AttachAddEvents() {
                this.$addButton.SRClick(() => {
                    this.AddPreferenceRow();
                });
                if (this.maximumNumberOfPreferences <= this.preferencesTable.Rows().length) {
                    this.$addButton.Disable();
                }
            }
            AttachDeleteEvents() {
                this.preferencesTable.$table.SRClickDelegate('delete', '.ui-btn-delete', (e) => {
                    var $deleteButton = $(e.currentTarget);
                    $deleteButton.closest('tr').remove();
                    this.EnableAddandSave();
                    this.UpdatePreferenceMessage();
                    this.UpdateRowOrder();
                });
            }
            AttachRowEvents() {
                this.preferencesTable.$table.SRClickDelegate('ok', '.ui-btn-ok', (e) => {
                    var $okButton = $(e.currentTarget);
                    var $preferenceDropDown = $okButton.closest('tr').GetControl('PreferenceDropdown');
                    var preferenceValue = $preferenceDropDown.SRVal();
                    if (preferenceValue === "0") {
                        alert(this.preferenceNotSelectedErrorMessage);
                        return false;
                    }
                    var hash = this.preferencesTable.$table.attr('displaypreferencehash').toString();
                    new starrez.service.applicationpreferences.DisplayPreferenceRow({
                        index: this.preferencesTable.Rows().length,
                        pageID: this.pageID,
                        preferenceID: Number(preferenceValue),
                        hash: hash
                    }).Post().done((results) => {
                        if (starrez.library.utils.IsNotNullUndefined(results)) {
                            this.preferencesTable.$table.find('tbody').append(results);
                            $okButton.closest('tr').remove();
                        }
                        else {
                            portal.page.CurrentPage.SetErrorMessage(this.loadPreferencesErrorMessage);
                        }
                    });
                    this.EnableAddandSave();
                });
                this.preferencesTable.$table.SRClickDelegate('cancel', '.ui-btn-cancel', (e) => {
                    var $cancelButton = $(e.currentTarget);
                    $cancelButton.closest('tr').remove();
                    this.UpdatePreferenceMessage();
                    this.EnableAddandSave();
                });
            }
            EnableAddandSave() {
                this.$addButton.prop("title", "");
                this.$saveButton.prop("title", "");
                if (this.maximumNumberOfPreferences > this.preferencesTable.Rows().length) {
                    this.$addButton.Enable();
                }
                this.$saveButton.Enable();
                this.isValid = true;
            }
            AddPreferenceRow() {
                var preferenceIDs = this.GetPreferenceIDs();
                var hash = this.preferencesTable.$table.attr('editpreferencehash').toString();
                new starrez.service.applicationpreferences.EditPreferenceOnlyRow({
                    index: this.preferencesTable.Rows().length,
                    preferenceIDs: preferenceIDs,
                    pageID: this.pageID,
                    hash: hash
                }).Post().done((results) => {
                    if (starrez.library.utils.IsNotNullUndefined(results)) {
                        this.AddPreferenceRowTable(results);
                    }
                    else {
                        portal.page.CurrentPage.SetErrorMessage(this.loadPreferencesErrorMessage);
                    }
                });
                this.$addButton.prop("title", this.addButtonErrorMessage);
                this.$saveButton.prop("title", this.saveButtonErrorMessage);
                this.$addButton.Disable();
                this.$saveButton.Disable();
                this.isValid = false;
            }
            AddPreferenceRowTable(results) {
                if (!results.IsPreferenceLimitReached) {
                    if (this.$tbody.isFound()) {
                        this.$tbody.append(results.PreferenceRow);
                    }
                    else {
                        this.preferencesTable.$table.append('<tbody></tbody>');
                        this.$tbody = this.preferencesTable.$table.find('tbody');
                        this.$tbody.append(results.PreferenceRow);
                    }
                    this.UpdateRowOrder();
                }
                if (this.maximumNumberOfPreferences <= this.preferencesTable.Rows().length) {
                    this.$preferenceMessage.find('div').text(this.maximumNumberOfPreferencesOverallErrorMessage);
                }
                else {
                    this.$preferenceMessage.html(results.DisplayNotificationMessage);
                }
            }
            GetPreferenceIDs() {
                var $tableRows = this.$tbody.find('tr');
                var preferenceIDs = [];
                $tableRows.each((index, element) => {
                    preferenceIDs.push(Number($(element).data('id')));
                });
                return preferenceIDs;
            }
            UpdateRowOrder() {
                var $rowOrders = this.$tbody.find('.ui-order-column');
                var preferenceNumber = 1;
                $rowOrders.each((index, element) => {
                    $(element).text(preferenceNumber);
                    preferenceNumber++;
                });
            }
            UpdatePreferenceMessage() {
                new starrez.service.applicationpreferences.DeleteRowMessage({
                    numberOfPreferences: this.GetPreferenceIDs().length,
                    pageID: this.pageID
                }).Post().done((results) => {
                    this.$preferenceMessage.html(results);
                });
            }
            Validate() {
                var deferred = $.Deferred();
                if (this.isValid) {
                    deferred.resolve();
                }
                else {
                    deferred.reject();
                }
                return deferred.promise();
            }
            GetData() {
                var data = this.GetPreferenceIDs();
                return {
                    SelectedPreferences: data
                };
            }
        }
    })(applicationpreferences = portal.applicationpreferences || (portal.applicationpreferences = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.applicationpreferences.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function ApplicationPreferencesModel($sys) {
            return {
                AddButtonErrorMessage: $sys.data('addbuttonerrormessage'),
                LoadPreferencesErrorMessage: $sys.data('loadpreferenceserrormessage'),
                MaximumNumberOfPreferences: Number($sys.data('maximumnumberofpreferences')),
                MaximumNumberOfPreferencesOverallErrorMessage: $sys.data('maximumnumberofpreferencesoverallerrormessage'),
                PreferenceItems: $sys.data('preferenceitems'),
                PreferenceNotSelectedErrorMessage: $sys.data('preferencenotselectederrormessage'),
                SaveButtonErrorMessage: $sys.data('savebuttonerrormessage'),
            };
        }
        model.ApplicationPreferencesModel = ApplicationPreferencesModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var applicationpreferences;
        (function (applicationpreferences) {
            "use strict";
            class ActiveTableDisplayPreferenceRow extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "ApplicationPreferences";
                    this.Controller = "applicationpreferences";
                    this.Action = "ActiveTableDisplayPreferenceRow";
                }
                CallData() {
                    var obj = {
                        index: this.o.index,
                        isMobile: this.o.isMobile,
                        preferenceID: this.o.preferenceID,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            applicationpreferences.ActiveTableDisplayPreferenceRow = ActiveTableDisplayPreferenceRow;
            class ActiveTableEditPreferenceOnlyRow extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "ApplicationPreferences";
                    this.Controller = "applicationpreferences";
                    this.Action = "ActiveTableEditPreferenceOnlyRow";
                }
                CallData() {
                    var obj = {
                        index: this.o.index,
                        isMobile: this.o.isMobile,
                        preferenceIDs: this.o.preferenceIDs,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            applicationpreferences.ActiveTableEditPreferenceOnlyRow = ActiveTableEditPreferenceOnlyRow;
            class DeleteRowMessage extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "ApplicationPreferences";
                    this.Controller = "applicationpreferences";
                    this.Action = "DeleteRowMessage";
                }
                CallData() {
                    var obj = {
                        numberOfPreferences: this.o.numberOfPreferences,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            applicationpreferences.DeleteRowMessage = DeleteRowMessage;
            class DisplayPreferenceRow extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "ApplicationPreferences";
                    this.Controller = "applicationpreferences";
                    this.Action = "DisplayPreferenceRow";
                }
                CallData() {
                    var obj = {
                        index: this.o.index,
                        preferenceID: this.o.preferenceID,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            applicationpreferences.DisplayPreferenceRow = DisplayPreferenceRow;
            class EditPreferenceOnlyRow extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "ApplicationPreferences";
                    this.Controller = "applicationpreferences";
                    this.Action = "EditPreferenceOnlyRow";
                }
                CallData() {
                    var obj = {
                        index: this.o.index,
                        preferenceIDs: this.o.preferenceIDs,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            applicationpreferences.EditPreferenceOnlyRow = EditPreferenceOnlyRow;
        })(applicationpreferences = service.applicationpreferences || (service.applicationpreferences = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var appointmentreschedule;
    (function (appointmentreschedule) {
        "use strict";
        function Initialise($container) {
            new AppointmentReschedule($container);
        }
        appointmentreschedule.Initialise = Initialise;
        class AppointmentReschedule {
            constructor($container) {
                this.$container = $container;
                this.$Container = $container;
                this.InitBackbutton();
            }
            InitBackbutton() {
                const backButton = this.$Container.find(".ui-back-button");
                backButton.SRClick((e) => {
                    window.location.href = $(e.currentTarget).data("href");
                });
            }
        }
    })(appointmentreschedule = portal.appointmentreschedule || (portal.appointmentreschedule = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.appointmentreschedule.js.map
"use strict";
var portal;
(function (portal) {
    var appointmentreschedulepicker;
    (function (appointmentreschedulepicker) {
        "use strict";
        function Initialise($container) {
            new AppointmentReschedule($container);
        }
        appointmentreschedulepicker.Initialise = Initialise;
        class AppointmentReschedule {
            constructor($container) {
                this.$container = $container;
                this.separator = "<svg width=\"14\" height=\"22\" viewBox=\"0 0 14 22\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">" +
                    "<path d=\"M13.6663 11.0001C13.656 11.2906 13.5267 11.5786 13.2777 11.8006L2.60197 21.3193C2.08393 21.7825 1.24222 21.7825 0.722668 21.3193C0.203121 20.8574 0.203121 20.1069 0.722668 19.6437L10.417 11.0001L0.722668 2.35645C0.203121 1.89317 0.203121 1.14273 0.722668 0.680833C1.24222 0.217554 2.08388 0.217554 2.60197 0.680833L13.2777 10.1995C13.5267 10.4215 13.6561 10.7095 13.6663 11.0001Z\" fill=\"#6D748D\"/>" +
                    "</svg>";
                this.$Container = $container;
                const processPicker = this.$Container.find(".ui-processPicker");
                this.processID = processPicker.data("processid");
                this.portalPageID = processPicker.data("portalpageid");
                this.initialDate = new Date(processPicker.data("initialdate"));
                this.today = new Date(processPicker.data("today"));
                this.getDaysHash = processPicker.data("getdayshash");
                this.languageSetting = processPicker.data("languagesetting");
                this.todayButtonText = processPicker.data("todaybuttontext");
                this.monthAriaLabel = processPicker.data("montharialabel");
                this.appointmentAviailableDateSelectionAriaLabel = processPicker.data("appointmentaviailabledateselectionarialabel");
                this.noAppointmentAviailableDateSelectionAriaLabel = processPicker.data("noappointmentaviailabledateselectionarialabel");
                this.noAppointmentsForThisMonthNextButtonAriaLabel = processPicker.data("noappointmentsforthismonthnextbuttonarialabel");
                this.noAppointmentsForThisMonthPreviousButtonAriaLabel = processPicker.data("noappointmentsforthismonthpreviousbuttonarialabel");
                this.calendarAccessibility = processPicker.data("calendaraccessibility");
                this.model = starrez.model.RescheduleAppointmentModel($(document.getElementById("page-container")));
                this.InitstarrezCalendar();
                $container.SRClickDelegate("timeslots", ".ui-appointmentPicker-timeslot", e => {
                    const $me = $(e.currentTarget);
                    const newStartDate = new Date($me.data("startdate"));
                    const newEndDate = new Date($me.data("enddate"));
                    const hash = $me.data("urlhash");
                    const date = $me.data("date");
                    const time = $me.data("time");
                    const duration = $me.data("duration");
                    const existingApptHTML = this.GetAppointmentHTML(this.model.ConfirmCurrentText, this.model.ExistingAppointmentDate, this.model.ExistingAppointmentTime, this.model.ExistingAppointmentDuration);
                    const newApptHTML = this.GetAppointmentHTML(this.model.ConfirmNewText, date, time, duration);
                    portal.ConfirmAction(this.GetConfirmationMessage(existingApptHTML, newApptHTML), this.model.ConfirmMessageTitle, this.model.ConfirmYesbuttonText, this.model.ConfirmNobuttonText).done(() => {
                        const call = new starrez.service.appointmenttimeslot.RescheduleAppointment({
                            appointmentProcessID: this.model.TimeslotProcessID,
                            startDate: newStartDate,
                            endDate: newEndDate,
                            portalPageID: this.portalPageID,
                            existingTimeSlotID: this.model.ExistingTimeslotID,
                            hash: hash
                        });
                        call.Post().done((newTimeSlotID) => {
                            portal.appointmenttimeslot.PushState(newTimeSlotID, this.model.ParentPageUrl);
                            window.location.href = this.model.ParentPageUrl;
                        }).fail(() => {
                            $(e.target).focus();
                        });
                    });
                });
                $container.SRClickDelegate("timeslotgroup", ".ui-appointmentPicker-timeslotgroup", e => {
                    const $me = $(e.currentTarget);
                    const date = $me.data("date");
                    const group = $me.data("group");
                    const hash = $me.data("hash");
                    new starrez.service.appointmentpicker.GetTimeSlotListForReschedule({
                        hash: hash,
                        date: new Date(date),
                        groupEnum: group,
                        portalPageID: this.portalPageID,
                        processID: this.processID,
                        existingAppointmentID: this.model.ExistingTimeslotID
                    }).Request({
                        ActionVerb: starrez.library.service.RequestType.Post,
                        RejectOnFail: true
                    }).done((html) => {
                        $me.attr("aria-pressed", "true");
                        $me.parent().siblings().find(".ui-appointmentPicker-timeslotgroup").attr("aria-pressed", "false");
                        this.$container.find(".ui-appointmentPicker-timeslotList").html(html);
                    });
                });
            }
            GetConfirmationMessage(existingApptHTML, newApptHTML) {
                return $.toHTML(`<div class="px_appointmenttimeslot_confirmation">
					<p>${this.model.ConfirmMessage}</p>
					<div class="px_appointmenttimeslot_confirmation_sections">
						${existingApptHTML}
						<div class="px_appointmenttimeslot_confirmation_sections_separator">${this.separator}</div>
						${newApptHTML}
					</div>
				</div>`).prop("outerHTML");
            }
            GetAppointmentHTML(title, dateHTML, timeHTML, durationHTML) {
                const dayRegex = /\b((mon|tue(s)?|wed(nes)?|thu(rs)?|fri|sat(ur)?|sun)(day)?)\b/i;
                let dayOfWeek;
                let dateNoDay;
                let dateString;
                if (dateHTML.match(dayRegex)) {
                    dayOfWeek = dateHTML.match(dayRegex)[0];
                    dateNoDay = dateHTML.replace(dateHTML.match(dayRegex)[0], "");
                    dateString = dateNoDay.replace(/[\,]+/g, "");
                }
                else {
                    dayOfWeek = "";
                    dateString = dateHTML;
                }
                return $.toHTML(`
				<div class="px_appointmenttimeslot_confirmation_sections_appointment">
					<span class="px_appointmenttimeslot_confirmation_sections_appointment_info px_reschedule_confirmation_title">${title}</span>
					<time class="px_appointmenttimeslot_confirmation_sections_appointment_info">${dayOfWeek}</time>
					<time class="px_appointmenttimeslot_confirmation_sections_appointment_info">${dateString}</time>
					<time class="px_appointmenttimeslot_confirmation_sections_appointment_info">${timeHTML}</time>
					<span>${durationHTML}</span>
				</div>
			`).prop("outerHTML");
            }
            InitstarrezCalendar() {
                var calanderDiv = this.$Container.find(".ui-starrez-calendar");
                const call = new starrez.service.appointmentpicker.GetAvialableDays({
                    processID: this.processID,
                    portalPageID: this.model.ParentPageID,
                    hash: this.getDaysHash
                });
                call.Request().done(result => {
                    const availableDates = result.map(date => ({ date: new Date(date), message: "" }));
                    this.ShowLegend();
                    // Create the datepicker
                    // @ts-ignore
                    window.starrezCalendar(this.initialDate.getMonth() + 1, this.initialDate.getFullYear(), {
                        elem: calanderDiv[0],
                        previousSelection: new Date(this.model.ExistingAppointmentDateJS),
                        currentSelection: this.initialDate,
                        today: this.today,
                        onClick: (d) => {
                            this.UpdateTimeSlots(d);
                        },
                        available: availableDates,
                        monthAriaLabel: this.monthAriaLabel,
                        appointmentAviailableDateSelectionAriaLabel: this.appointmentAviailableDateSelectionAriaLabel,
                        noAppointmentAviailableDateSelectionAriaLabel: this.noAppointmentAviailableDateSelectionAriaLabel,
                        noAppointmentsForThisMonthNextButtonAriaLabel: this.noAppointmentsForThisMonthNextButtonAriaLabel,
                        noAppointmentsForThisMonthPreviousButtonAriaLabel: this.noAppointmentsForThisMonthPreviousButtonAriaLabel,
                        languageSetting: this.languageSetting,
                        todayButtonText: this.todayButtonText,
                        // Remove when removing FF PXAccessibilityEnableAppointmentsCalendarAccessibilityFeatures STAR-35612
                        calendarAccessibility: this.calendarAccessibility,
                    });
                });
            }
            ShowLegend() {
                var calanderDiv = this.$Container.find(".ui-calendar-legend");
                calanderDiv.addClass("px_calendar-legend-show");
            }
            UpdateTimeSlots(date) {
                const call = new starrez.service.appointmentpicker.GetDaysTimeSlots({
                    portalPageID: this.portalPageID,
                    processID: this.processID,
                    date: date,
                    existingtimeslotID: this.model.ExistingTimeslotID
                });
                call.Request().done(html => {
                    this.$container.find(".ui-appointmentpicker-timeslots").html(html);
                    if (this.calendarAccessibility === "True") {
                        this.$container.find('[aria-pressed="true"]').focus();
                    }
                    else {
                        // Remove when removing FF PXAccessibilityEnableAppointmentsCalendarAccessibilityFeatures STAR-35612
                        this.$container.find('[aria-pressed="true"]').click();
                    }
                });
            }
        }
    })(appointmentreschedulepicker = portal.appointmentreschedulepicker || (portal.appointmentreschedulepicker = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.appointmentreschedulepicker.js.map
"use strict";
var portal;
(function (portal) {
    var appointments;
    (function (appointments) {
        "use strict";
        const hours = "hours";
        function Initialise($container) {
            new Appointments($container);
        }
        appointments.Initialise = Initialise;
        class Appointments {
            constructor($container) {
                this.$container = $container;
                this.model = starrez.model.AppointmentsModel($container);
                this.$calendar = $container.find(".ui-fullcalendar");
                this.$suggestions = $container.find(".ui-suggestions");
                this.$appointmentsList = $container.find(".ui-booked-appointments-list");
                this.$processDescription = $container.find(".ui-process-description");
                this.$currentProcessContainer = $container.find(".ui-current-process-container");
                this.$noAppointmentsNotification = $container.find(".ui-no-appointments-notification");
                this.$jumpToDate = this.$container.GetControl("appointments-jumptodate");
                this.$calendarViewDropdown = this.$container.GetControl("DefaultView");
                this.$processList = $container.GetControl("appointment-process-id");
                if (this.$processList.isFound()) {
                    this.selectedProcessID = this.$processList.SRVal();
                }
                else {
                    this.selectedProcessID = $container.GetControl("appointment-process-id").SRVal();
                }
                this.InitialiseButtonEvents();
                this.InitialiseTableEvents();
                this.InitialiseProcessChangeEvent(this.$processList);
                this.InitialiseFullCalendar(this.$calendar);
            }
            InitialiseFullCalendar($calendar) {
                var initial = moment(this.model.InitialDate);
                var baseUrl = portal.StartupOptions.BaseUrl;
                if (baseUrl === "/") {
                    //The browser can handle it perfectly well if the baseUrl is empty. Adding slash here will actually cause problems.
                    //The change is done here instead of in StartupOptions.cs to avoid any unknown implications
                    baseUrl = "";
                }
                $calendar.fullCalendar({
                    header: {
                        left: "",
                        center: "",
                        right: ""
                    },
                    buttonText: {
                        today: this.model.TodayButtonText,
                        month: this.model.MonthButtonText,
                        week: this.model.WeekButtonText,
                        day: this.model.DayButtonText
                    },
                    timeFormat: "h(:mm)a", // All other views - 7pm
                    events: {
                        url: baseUrl +
                            new starrez.service.appointments.GetTimeslots({
                                start: new Date(), // will be overritten by fullcalendar
                                end: new Date(), // will be overritten by fullcalendar
                                portalPageID: portal.page.CurrentPage.PageID,
                                appointmentProcessID: this.selectedProcessID
                            }).GetURL(),
                        type: "POST",
                        data: () => {
                            return {
                                portalPageID: portal.page.CurrentPage.PageID,
                                appointmentProcessID: this.selectedProcessID
                            };
                        }
                    },
                    firstDay: this.model.FirstDayOfWeek,
                    defaultDate: initial,
                    minTime: moment.duration(this.model.MinHour, hours),
                    maxTime: moment.duration(this.model.MaxHour, hours),
                    defaultView: this.model.DefaultView,
                    timezone: false,
                    theme: false,
                    allDayDefault: false,
                    allDaySlot: false,
                    views: {
                        agenda: {
                            timeFormat: "h:mma" // Agenda view - 5:00 pm - 6:30 pm
                        },
                        month: {
                            columnFormat: 'ddd'
                        },
                        week: {
                            columnFormat: 'ddd Do'
                        },
                        day: {
                            columnFormat: 'ddd Do'
                        }
                    },
                    viewRender: (view) => {
                        // when we update the calendar, keep the date picker synced up
                        if (starrez.library.utils.IsNotNullUndefined(this.$jumpToDate) && this.$jumpToDate.isFound()) {
                            this.updatingCalendar = true;
                            var momentDate = this.$calendar.fullCalendar("getDate").toDate();
                            var dateWithoutTimezone = new Date(momentDate.getUTCFullYear(), momentDate.getUTCMonth(), momentDate.getUTCDate());
                            this.$jumpToDate.SRVal(dateWithoutTimezone);
                        }
                    },
                    eventClick: (slot, e) => {
                        starrez.library.utils.SafeStopPropagation(e);
                        const slotStart = slot.start;
                        const slotEnd = slot.end;
                        var start = moment(new Date(slotStart.year(), slotStart.month(), slotStart.date(), slotStart.hours(), slotStart.minutes()));
                        var end = moment(new Date(slotEnd.year(), slotEnd.month(), slotEnd.date(), slotEnd.hours(), slotEnd.minutes()));
                        if (starrez.library.convert.ToBoolean(slot["booked"]) || start <= moment()) {
                            return;
                        }
                        portal.ConfirmAction(slot["description"] + this.model.BookConfirmationMessage, "Book Appointment")
                            .done(() => {
                            var call = new starrez.service.appointments.BookTimeslot({
                                startDate: start.toDate(),
                                endDate: end.toDate(),
                                portalPageID: portal.page.CurrentPage.PageID,
                                appointmentProcessID: this.selectedProcessID,
                                hash: slot["bookurlhash"]
                            });
                            call.Request({
                                ActionVerb: starrez.library.service.RequestType.Post,
                                RejectOnFail: true
                            }).done((data) => {
                                portal.page.CurrentPage.SetSuccessMessage(data);
                                this.RefetchBookedAppointments();
                                if (this.model.ShowSuggestions) {
                                    this.ShowSuggestions();
                                }
                            }).always(() => {
                                $calendar.fullCalendar("refetchEvents");
                            });
                        }).fail(() => {
                            $(e.target).focus();
                        });
                    }
                });
                var $calendarViewDropdownList = this.$calendarViewDropdown.find("select");
                $calendarViewDropdownList.attr("aria-label", this.model.CalendarViewDropdownAriaLabel);
            }
            InitialiseButtonEvents() {
                // when the date picker is updated
                this.$jumpToDate.on("change", (e) => {
                    if (this.updatingCalendar) {
                        this.updatingCalendar = false;
                    }
                    else {
                        var date = $(e.currentTarget).SRVal();
                        var gotoDate = moment(date);
                        this.$calendar.fullCalendar("gotoDate", gotoDate);
                    }
                });
                // when the calendar view dropdown is changed
                this.$calendarViewDropdown.on("change", () => {
                    this.$calendar.fullCalendar("changeView", this.$calendarViewDropdown.SRVal());
                });
                // when one of the calendar nav buttons is clicked
                this.$container.find(".ui-calendar-action").SRClick((e) => {
                    var $button = $(e.currentTarget);
                    var action = $button.data("action").toString();
                    this.$calendar.fullCalendar(action);
                });
            }
            InitialiseTableEvents() {
                this.$appointmentsList.on("click", ".ui-cancel-appointment", (e) => {
                    var timeslotID = Number($(e.target).closest("tr").data("timeslot"));
                    portal.ConfirmAction(this.model.CancelConfirmationMessage, "Cancel Appointment").done(() => {
                        var call = new starrez.service.appointments.CancelTimeslot({
                            timeSlotID: timeslotID,
                            portalPageID: portal.page.CurrentPage.PageID,
                            hash: $(e.currentTarget).data('hash'),
                        });
                        call.Post().done((data) => {
                            portal.page.CurrentPage.SetSuccessMessage(data);
                            this.RefetchBookedAppointments();
                            this.$calendar.fullCalendar("refetchEvents");
                        });
                    });
                });
            }
            InitialiseProcessChangeEvent($processList) {
                $processList.change((e) => {
                    this.selectedProcessID = $processList.SRVal();
                    this.RefetchProcessDescription();
                    new starrez.service.appointments.GetProcessInitialDate({
                        appointmentProcessID: this.selectedProcessID
                    }).Post().done((date) => {
                        if (!starrez.library.stringhelper.IsUndefinedOrEmpty(date)) {
                            this.$currentProcessContainer.show();
                            this.$noAppointmentsNotification.hide();
                            var gotoDate = moment(date);
                            this.$calendar.fullCalendar("gotoDate", gotoDate);
                            this.$calendar.fullCalendar("refetchEvents");
                        }
                        else {
                            this.$currentProcessContainer.hide();
                            this.$noAppointmentsNotification.show();
                        }
                    });
                });
            }
            RefetchProcessDescription() {
                new starrez.service.appointments.GetProcessDescription({
                    portalPageID: portal.page.CurrentPage.PageID,
                    appointmentProcessID: this.selectedProcessID
                }).Post().done((data) => {
                    this.$processDescription.html(data);
                });
            }
            RefetchBookedAppointments() {
                new starrez.service.appointments.GetBookedAppointments({
                    portalPageID: portal.page.CurrentPage.PageID,
                    appointmentProcessIDs: starrez.library.convert.ToNumberArray(this.model.AppointmentProcessIDs)
                }).Post().done((data) => {
                    this.$appointmentsList.html(data);
                });
            }
            ShowSuggestions() {
                new starrez.service.appointments.GetSuggestions({
                    pageID: portal.page.CurrentPage.PageID,
                    roomLocationIDs: this.model.RoomLocationIDs
                }).Post().done((html) => {
                    this.$suggestions.html(html);
                });
            }
        }
    })(appointments = portal.appointments || (portal.appointments = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.appointments.js.map
"use strict";
var portal;
(function (portal) {
    var appointmenttimeslot;
    (function (appointmenttimeslot) {
        "use strict";
        function Initialise($container) {
            new AppointmentTimeslot($container);
        }
        appointmenttimeslot.Initialise = Initialise;
        function PushState(timeSlotID, url) {
            var state = {
                timeSlotID: timeSlotID
            };
            window.history.pushState(state, "", url);
        }
        appointmenttimeslot.PushState = PushState;
        class AppointmentTimeslot {
            constructor($container) {
                this.$container = $container;
                this.$Container = $container;
                this.InitConfirmation();
            }
            InitConfirmation() {
                var state = window.history.state;
                if (window.history.length > 0 && state) {
                    // load reschedule success message
                    new starrez.service.appointmenttimeslot.GetRescheduleSuccessMessage({
                        portalPageID: portal.page.CurrentPage.PageID,
                        timeSlotID: Number(state.timeSlotID)
                    }).Post().done((html) => {
                        portal.page.CurrentPage.SetSuccessMessageHTML(html);
                        $(document).find(".ui-page-success").SRFocus();
                        // use document here as page message is outside of the container
                        $(document).SRClickDelegate("addtocalendar-reschedule-successmessage", ".ui-successmessage-calendar-btn", e => {
                            window.open($(e.currentTarget).data("url"), '_blank');
                        });
                    });
                }
            }
        }
    })(appointmenttimeslot = portal.appointmenttimeslot || (portal.appointmenttimeslot = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.appointmenttimeslot.js.map
"use strict";
var portal;
(function (portal) {
    var appointmenttimeslotgroup;
    (function (appointmenttimeslotgroup) {
        "use strict";
        function Initialise($container) {
            new AppointmentTimeslotGroup($container);
        }
        appointmenttimeslotgroup.Initialise = Initialise;
        class AppointmentTimeslotGroup {
            constructor($container) {
                this.$container = $container;
                $container.find(".ui-appointmentPicker-timeslotgroup").keydown(function (e) {
                    const $me = $(e.currentTarget);
                    const key = e.key;
                    switch (key) {
                        case "ArrowLeft":
                            e.preventDefault();
                            if ($me.parent().index() > 0) {
                                $me.parent().prev().find(".ui-appointmentPicker-timeslotgroup").focus();
                            }
                            break;
                        case "ArrowRight":
                            e.preventDefault();
                            if ($me.parent().next().length > 0) {
                                $me.parent().next().find(".ui-appointmentPicker-timeslotgroup").focus();
                            }
                            break;
                        case "ArrowDown":
                            e.preventDefault();
                            $container.closest(".ui-appointmentpicker-timeslots").find(".ui-appointmentPicker-timeslot[tabindex=0]").focus();
                            break;
                        case "ArrowUp":
                            e.preventDefault();
                            break;
                        default:
                            break;
                    }
                });
                $container.find(".ui-appointmentPicker-timeslotgroup").focus(function (e) {
                    const $me = $(e.currentTarget);
                    $container.find(".ui-appointmentPicker-timeslotgroup").attr("tabindex", -1);
                    $me.attr("tabindex", 0);
                });
            }
        }
    })(appointmenttimeslotgroup = portal.appointmenttimeslotgroup || (portal.appointmenttimeslotgroup = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.appointmenttimeslotgroup.js.map
"use strict";
var portal;
(function (portal) {
    var appointmenttimeslotlist;
    (function (appointmenttimeslotlist) {
        "use strict";
        function Initialise($container) {
            new AppointmentTimeslotList($container);
        }
        appointmenttimeslotlist.Initialise = Initialise;
        class AppointmentTimeslotList {
            constructor($container) {
                this.$container = $container;
                $container.find(".ui-appointmentPicker-timeslot").keydown(function (e) {
                    const $me = $(e.currentTarget);
                    const key = e.key;
                    const isSingleColumn = window.innerWidth < 900;
                    const index = $me.parent().index();
                    const $prevTimeslot = $me.parent().prev().find(".ui-appointmentPicker-timeslot");
                    const $nextTimeslot = $me.parent().next().find(".ui-appointmentPicker-timeslot");
                    const total = $me.parent().parent().children().length;
                    switch (key) {
                        case "ArrowLeft":
                            e.preventDefault();
                            if (!isSingleColumn && index % 2 != 0 && $prevTimeslot.length > 0) {
                                $prevTimeslot.focus();
                            }
                            break;
                        case "ArrowRight":
                            e.preventDefault();
                            if (!isSingleColumn && index % 2 == 0 && $nextTimeslot.length > 0) {
                                $nextTimeslot.focus();
                            }
                            break;
                        case "ArrowDown":
                            e.preventDefault();
                            if (isSingleColumn && $nextTimeslot.length > 0) {
                                $nextTimeslot.focus();
                            }
                            else if (total > 2 && index < total - 2) {
                                $me.parent().next().next().find(".ui-appointmentPicker-timeslot").focus();
                            }
                            break;
                        case "ArrowUp":
                            e.preventDefault();
                            if (index == 1 && !isSingleColumn || index == 0) {
                                // back to timeslots group
                                const timeslotgroup = $container.closest(".ui-appointmentpicker-timeslots").find(".ui-appointmentPicker-timeslotgroup[tabindex=0]");
                                if (timeslotgroup.length > 0) {
                                    timeslotgroup.focus();
                                }
                                else {
                                    $container.closest(".ui-appointmentpicker-timeslots").scrollTop(0);
                                }
                            }
                            if (isSingleColumn && $prevTimeslot.length > 0) {
                                $prevTimeslot.focus();
                            }
                            else if (total > 2 && index > 1) {
                                $me.parent().prev().prev().find(".ui-appointmentPicker-timeslot").focus();
                            }
                            break;
                        default:
                            break;
                    }
                });
                $container.find(".ui-appointmentPicker-timeslot").focus(function (e) {
                    const $me = $(e.currentTarget);
                    $container.find(".ui-appointmentPicker-timeslot").attr("tabindex", -1);
                    $me.attr("tabindex", 0);
                });
            }
        }
    })(appointmenttimeslotlist = portal.appointmenttimeslotlist || (portal.appointmenttimeslotlist = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.appointmenttimeslotlist.js.map
"use strict";
var portal;
(function (portal) {
    var bookedappointmenttable;
    (function (bookedappointmenttable) {
        "use strict";
        function Initialise($container) {
            new BookedAppointmentTable($container);
        }
        bookedappointmenttable.Initialise = Initialise;
        class BookedAppointmentTable {
            constructor($container) {
                this.$container = $container;
                this.$Container = $container;
                const processPicker = this.$Container.find(".ui-processPicker");
                this.processID = processPicker.data("processid");
                this.portalPageID = processPicker.data("portalpageid");
                this.initialDate = new Date(processPicker.data("initialdate"));
                this.getDaysHash = processPicker.data("getdayshash");
                this.model = starrez.model.AppointmentTimeslotModel($(document.getElementById("page-container")));
                this.$responsiveTableContainer = $container.find('.ui-responsive-active-table-container');
                this.InitButtonActions();
            }
            IsMobile() {
                return this.$responsiveTableContainer.data('isMobile') === true;
            }
            GetRowSelector() {
                return this.IsMobile() ? "tbody" : "tbody tr";
            }
            InitButtonActions() {
                this.$Container.SRClickDelegate("addtocalendar-appointment", ".ui-addtocalendar-appointment", e => {
                    e.preventDefault();
                    window.open($(e.currentTarget).data("url"), '_blank');
                });
                this.$Container.SRClickDelegate("reschedule-appointment", ".ui-reschedule-appointment", e => {
                    e.preventDefault();
                    window.location.href = $(e.currentTarget).data("href");
                });
                this.$Container.SRClickDelegate("cancel-appointment", ".ui-cancel-appointment", e => {
                    e.preventDefault();
                    var timeSlotID = Number($(e.currentTarget).closest(this.GetRowSelector()).data("timeslot"));
                    var processID = $(e.currentTarget).closest(this.GetRowSelector()).data("process");
                    var timeSlotDate = $(e.currentTarget).closest(this.GetRowSelector()).data("timeslotdate");
                    var hash = $(e.currentTarget).data("hash");
                    var processHTML = $(e.currentTarget).closest(this.GetRowSelector()).find(".ui-bookedappointmenttable-processdescription").html();
                    var dateTimeHTML = $(e.currentTarget).closest(this.GetRowSelector()).find(".ui-bookedappointmenttable-dateandtime").html();
                    portal.ConfirmAction(this.ConfirmationMessage(processHTML, dateTimeHTML), this.model.CancelConfirmationTitle, this.model.ConfirmBookCancellationButtonText, this.model.UndoBookCancellationButtonText).done(() => {
                        new starrez.service.appointmenttimeslot.CancelTimeslot({
                            timeSlotID: timeSlotID,
                            portalPageID: portal.page.CurrentPage.PageID,
                            appointmentProcessIDs: starrez.library.convert.ToNumberArray(this.model.AppointmentProcessIDs),
                            hash: hash
                        }).Post().done((data) => {
                            portal.page.CurrentPage.SetSuccessMessage(data);
                            new starrez.service.appointmenttimeslot.GetCancelSuccessMessage({
                                portalPageID: portal.page.CurrentPage.PageID,
                                timeSlotID: Number(data)
                            }).Post().done((html) => {
                                // Show success message
                                portal.page.CurrentPage.SetSuccessMessageHTML(html);
                                $(document).find(".ui-page-success").SRFocus();
                            });
                            // reload timeslots if same process and same date is selected in the calendar
                            $(document).find(".px_processPicker_show").each((_index, elm) => {
                                var date = $(elm).find(".starrezCalendar_button.current").data("date");
                                if (processID == $(elm).data("processid") && date == new Date(timeSlotDate).toDateString()) {
                                    new starrez.service.appointmentpicker.GetDaysTimeSlots({
                                        portalPageID: portal.page.CurrentPage.PageID,
                                        processID: Number(processID),
                                        date: new Date(date)
                                    }).Request().done(html => {
                                        $(elm).find(".ui-appointmentpicker-timeslots").html(html);
                                    });
                                }
                            });
                            // Update the booked appointments
                            new starrez.service.appointmenttimeslot.GetBookedAppointmentTable({
                                portalPageID: portal.page.CurrentPage.PageID,
                                appointmentProcessIDs: starrez.library.convert.ToNumberArray(this.model.AppointmentProcessIDs)
                            }).Post().done((html) => {
                                $(document).find(".ui-bookedappointment-table").html(html);
                            });
                        });
                    });
                });
            }
            ConfirmationMessage(processHTML, dateHTML) {
                return $.toHTML(`<div class="px_appointmenttimeslot_confirmation">
					<p>${this.model.CancelConfirmationMessage}</p>
					<span class="px_appointmenttimeslot_confirmation_info">${processHTML}</span>
					<time class="px_appointmenttimeslot_confirmation_info">${dateHTML}</time>
				</div>`).prop("outerHTML");
            }
        }
    })(bookedappointmenttable = portal.bookedappointmenttable || (portal.bookedappointmenttable = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.bookedappointmenttable.js.map
"use strict";
var portal;
(function (portal) {
    var booknewappointmentpicker;
    (function (booknewappointmentpicker) {
        "use strict";
        function Initialise($container) {
            new BookNewAppointmentPicker($container);
        }
        booknewappointmentpicker.Initialise = Initialise;
        class BookNewAppointmentPicker {
            constructor($container) {
                this.$container = $container;
                this.$Container = $container;
                const processPicker = this.$Container.find(".ui-processPicker");
                this.processID = processPicker.data("processid");
                this.portalPageID = processPicker.data("portalpageid");
                this.initialDate = new Date(processPicker.data("initialdate"));
                this.today = new Date(processPicker.data("today"));
                this.getDaysHash = processPicker.data("getdayshash");
                this.todayButtonText = processPicker.data("todaybuttontext");
                this.monthAriaLabel = processPicker.data("montharialabel");
                this.appointmentAviailableDateSelectionAriaLabel = processPicker.data("appointmentaviailabledateselectionarialabel");
                this.noAppointmentAviailableDateSelectionAriaLabel = processPicker.data("noappointmentaviailabledateselectionarialabel");
                this.noAppointmentsForThisMonthNextButtonAriaLabel = processPicker.data("noappointmentsforthismonthnextbuttonarialabel");
                this.noAppointmentsForThisMonthPreviousButtonAriaLabel = processPicker.data("noappointmentsforthismonthpreviousbuttonarialabel");
                this.calendarAccessibility = processPicker.data("calendaraccessibility");
                this.languageSetting = processPicker.data("languagesetting");
                this.model = starrez.model.AppointmentTimeslotModel($(document.getElementById("page-container")));
                this.InitstarrezCalendar();
                $container.find(".ui-appointmentpicker-button").SRClick(e => {
                    const processPickerButton = e.currentTarget;
                    const processPicker = processPickerButton.parentElement;
                    processPicker.classList.toggle("px_processPicker_show");
                    const isVisible = processPicker.HasClass("px_processPicker_show");
                    processPickerButton.setAttribute('aria-expanded', isVisible.toString());
                    const appointmentPickerContent = processPicker.querySelector(".ui-appointmentpicker-dropdown");
                    appointmentPickerContent.setAttribute("aria-hidden", (!isVisible).toString());
                    window.setTimeout(() => {
                        processPicker.scrollIntoView({
                            behavior: "smooth"
                        });
                    }, 200);
                });
                $container.SRClickDelegate("timeslotgroup", ".ui-appointmentPicker-timeslotgroup", e => {
                    const $me = $(e.currentTarget);
                    const date = $me.data("date");
                    const group = $me.data("group");
                    const hash = $me.data("hash");
                    new starrez.service.appointmentpicker.GetTimeSlotList({
                        hash: hash,
                        date: new Date(date),
                        groupEnum: group,
                        portalPageID: this.portalPageID,
                        processID: this.processID
                    }).Request({
                        ActionVerb: starrez.library.service.RequestType.Post,
                        RejectOnFail: true
                    }).done((html) => {
                        $me.attr("aria-pressed", "true");
                        $me.parent().siblings().find(".ui-appointmentPicker-timeslotgroup").attr("aria-pressed", "false");
                        this.$container.find(".ui-appointmentPicker-timeslotList").html(html);
                    });
                });
                $container.SRClickDelegate("timeslots", ".ui-appointmentPicker-timeslot", e => {
                    const $me = $(e.currentTarget);
                    const startDate = $me.data("startdate");
                    const endDate = $me.data("enddate");
                    const hash = $me.data("urlhash");
                    const process = $me.data("process");
                    const date = $me.data("date");
                    const time = $me.data("time");
                    const duration = $me.data("duration");
                    portal.ConfirmAction(this.ConfirmationMessage(process, date, time, duration), this.model.BookConfirmationTitle, this.model.ConfirmBookConfirmationButtonText, this.model.UndoBookConfirmationButtonText)
                        .done(() => {
                        new starrez.service.appointmenttimeslot.BookTimeslot({
                            startDate: new Date(startDate),
                            endDate: new Date(endDate),
                            portalPageID: portal.page.CurrentPage.PageID,
                            appointmentProcessID: this.processID,
                            hash: hash
                        }).Request({
                            ActionVerb: starrez.library.service.RequestType.Post,
                            RejectOnFail: true
                        }).always(() => {
                            // update timeslots
                            this.UpdateTimeSlots(new Date(startDate));
                        }).done((timeSlotID) => {
                            // close all the panels
                            this.CloseAllPanels();
                            // update booked appointments
                            new starrez.service.appointmenttimeslot.GetBookedAppointmentTable({
                                portalPageID: portal.page.CurrentPage.PageID,
                                appointmentProcessIDs: starrez.library.convert.ToNumberArray(this.model.AppointmentProcessIDs)
                            }).Post().done((html) => {
                                $(document).find(".ui-bookedappointment-table").html(html);
                            });
                            new starrez.service.appointmenttimeslot.GetBookingSuccessMessage({
                                portalPageID: portal.page.CurrentPage.PageID,
                                timeSlotID: Number(timeSlotID)
                            }).Post().done((html) => {
                                portal.page.CurrentPage.SetSuccessMessageHTML(html);
                                // use document here as page message is outside of the container
                                $(document).find(".ui-page-success").SRFocus();
                                $(document).SRClickDelegate("addtocalendar-book-successmessage", ".ui-successmessage-calendar-btn", e => {
                                    window.open($(e.currentTarget).data("url"), '_blank');
                                });
                            });
                        });
                    }).fail(() => {
                        $(e.target).focus();
                    });
                });
            }
            CloseAllPanels() {
                this.$container.find(".ui-processPicker").each((index, e) => {
                    const $element = $(e);
                    $element.removeClass("px_processPicker_show");
                    $element.find(".ui-appointmentpicker-dropdown").attr("aria-hidden", "true");
                });
            }
            InitstarrezCalendar() {
                var calanderDiv = this.$Container.find(".ui-starrez-calendar");
                const call = new starrez.service.appointmentpicker.GetAvialableDays({
                    portalPageID: this.portalPageID,
                    processID: this.processID,
                    hash: this.getDaysHash
                });
                call.Request().done(result => {
                    const availableDates = result.map(date => ({ date: new Date(date), message: "" }));
                    // Create the datepicker
                    // @ts-ignore
                    window.starrezCalendar(this.initialDate.getMonth() + 1, this.initialDate.getFullYear(), {
                        elem: calanderDiv[0],
                        //previousSelection: this.initialDate, <- this is used when there is a previous booking
                        currentSelection: this.initialDate,
                        today: this.today,
                        onClick: (d) => {
                            this.UpdateTimeSlots(d);
                        },
                        available: availableDates,
                        monthAriaLabel: this.monthAriaLabel,
                        appointmentAviailableDateSelectionAriaLabel: this.appointmentAviailableDateSelectionAriaLabel,
                        noAppointmentAviailableDateSelectionAriaLabel: this.noAppointmentAviailableDateSelectionAriaLabel,
                        noAppointmentsForThisMonthNextButtonAriaLabel: this.noAppointmentsForThisMonthNextButtonAriaLabel,
                        noAppointmentsForThisMonthPreviousButtonAriaLabel: this.noAppointmentsForThisMonthPreviousButtonAriaLabel,
                        languageSetting: this.languageSetting,
                        todayButtonText: this.todayButtonText,
                        //Remove when removing FF PXAccessibilityEnableAppointmentsCalendarAccessibilityFeatures STAR-35612
                        calendarAccessibility: this.calendarAccessibility
                    });
                });
            }
            UpdateTimeSlots(date) {
                const call = new starrez.service.appointmentpicker.GetDaysTimeSlots({
                    portalPageID: this.portalPageID,
                    processID: this.processID,
                    date: date,
                    existingtimeslotID: null
                });
                call.Request().done(html => {
                    this.$container.find(".ui-appointmentpicker-timeslots").html(html);
                });
            }
            ConfirmationMessage(processHTML, dateHTML, timeHTML, durationHTML) {
                return $.toHTML(`<div class="px_appointmenttimeslot_confirmation">
					<p>${this.model.BookConfirmationMessage}</p>
					<span class="px_appointmenttimeslot_confirmation_info">${processHTML}</span>
					<time class="px_appointmenttimeslot_confirmation_info">${dateHTML}<br>${timeHTML}</time>
					<span>${durationHTML}</span>
				</div>`).prop("outerHTML");
            }
        }
    })(booknewappointmentpicker = portal.booknewappointmentpicker || (portal.booknewappointmentpicker = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.booknewappointmentpicker.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function AppointmentsModel($sys) {
            return {
                AppointmentProcessIDs: $sys.data('appointmentprocessids'),
                AvailableViews: ($sys.data('availableviews') === '') ? [] : ($sys.data('availableviews')).toString().split(','),
                BookConfirmationMessage: $sys.data('bookconfirmationmessage'),
                CalendarViewDropdownAriaLabel: $sys.data('calendarviewdropdownarialabel'),
                CancelConfirmationMessage: $sys.data('cancelconfirmationmessage'),
                DayButtonText: $sys.data('daybuttontext'),
                DayViewDateFormat: $sys.data('dayviewdateformat'),
                DefaultView: $sys.data('defaultview'),
                FirstDayOfWeek: Number($sys.data('firstdayofweek')),
                InitialDate: moment($sys.data('initialdate')).toDate(),
                MaxHour: Number($sys.data('maxhour')),
                MinHour: Number($sys.data('minhour')),
                MonthButtonText: $sys.data('monthbuttontext'),
                NextDayButtonAriaLabel: $sys.data('nextdaybuttonarialabel'),
                PreviousDayButtonAriaLabel: $sys.data('previousdaybuttonarialabel'),
                RoomLocationIDs: ($sys.data('roomlocationids') === '') ? [] : ($sys.data('roomlocationids')).toString().split(',').map(function (e) { return Number(e); }),
                ShowSuggestions: starrez.library.convert.ToBoolean($sys.data('showsuggestions')),
                TodayButtonText: $sys.data('todaybuttontext'),
                WeekButtonText: $sys.data('weekbuttontext'),
                WeekViewDateFormat: $sys.data('weekviewdateformat'),
            };
        }
        model.AppointmentsModel = AppointmentsModel;
        function AppointmentTimeslotModel($sys) {
            return {
                AppointmentProcessIDs: $sys.data('appointmentprocessids'),
                BookConfirmationMessage: $sys.data('bookconfirmationmessage'),
                BookConfirmationTitle: $sys.data('bookconfirmationtitle'),
                CancelConfirmationMessage: $sys.data('cancelconfirmationmessage'),
                CancelConfirmationTitle: $sys.data('cancelconfirmationtitle'),
                ConfirmBookCancellationButtonText: $sys.data('confirmbookcancellationbuttontext'),
                ConfirmBookConfirmationButtonText: $sys.data('confirmbookconfirmationbuttontext'),
                RoomLocationIDs: ($sys.data('roomlocationids') === '') ? [] : ($sys.data('roomlocationids')).toString().split(',').map(function (e) { return Number(e); }),
                UndoBookCancellationButtonText: $sys.data('undobookcancellationbuttontext'),
                UndoBookConfirmationButtonText: $sys.data('undobookconfirmationbuttontext'),
            };
        }
        model.AppointmentTimeslotModel = AppointmentTimeslotModel;
        function RescheduleAppointmentModel($sys) {
            return {
                ConfirmCurrentText: $sys.data('confirmcurrenttext'),
                ConfirmMessage: $sys.data('confirmmessage'),
                ConfirmMessageTitle: $sys.data('confirmmessagetitle'),
                ConfirmNewText: $sys.data('confirmnewtext'),
                ConfirmNobuttonText: $sys.data('confirmnobuttontext'),
                ConfirmYesbuttonText: $sys.data('confirmyesbuttontext'),
                ExistingAppointmentDate: $sys.data('existingappointmentdate'),
                ExistingAppointmentDateJS: $sys.data('existingappointmentdatejs'),
                ExistingAppointmentDuration: $sys.data('existingappointmentduration'),
                ExistingAppointmentTime: $sys.data('existingappointmenttime'),
                ExistingTimeslotID: $sys.data('existingtimeslotid'),
                ParentPageID: Number($sys.data('parentpageid')),
                ParentPageUrl: $sys.data('parentpageurl'),
                TimeslotProcessID: Number($sys.data('timeslotprocessid')),
            };
        }
        model.RescheduleAppointmentModel = RescheduleAppointmentModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var appointmentpicker;
        (function (appointmentpicker) {
            "use strict";
            class GetAvialableDays extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmentpicker";
                    this.Action = "GetAvialableDays";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        portalPageID: this.o.portalPageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            appointmentpicker.GetAvialableDays = GetAvialableDays;
            class GetDaysTimeSlots extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmentpicker";
                    this.Action = "GetDaysTimeSlots";
                }
                CallData() {
                    var obj = {
                        date: this.o.date,
                        existingtimeslotID: this.o.existingtimeslotID,
                        portalPageID: this.o.portalPageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            appointmentpicker.GetDaysTimeSlots = GetDaysTimeSlots;
            class GetTimeSlotList extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmentpicker";
                    this.Action = "GetTimeSlotList";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        date: this.o.date,
                        groupEnum: this.o.groupEnum,
                        portalPageID: this.o.portalPageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            appointmentpicker.GetTimeSlotList = GetTimeSlotList;
            class GetTimeSlotListForReschedule extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmentpicker";
                    this.Action = "GetTimeSlotListForReschedule";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        date: this.o.date,
                        existingAppointmentID: this.o.existingAppointmentID,
                        groupEnum: this.o.groupEnum,
                        portalPageID: this.o.portalPageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            appointmentpicker.GetTimeSlotListForReschedule = GetTimeSlotListForReschedule;
        })(appointmentpicker = service.appointmentpicker || (service.appointmentpicker = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var appointments;
        (function (appointments) {
            "use strict";
            class BookTimeslot extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointments";
                    this.Action = "BookTimeslot";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        appointmentProcessID: this.o.appointmentProcessID,
                        endDate: this.o.endDate,
                        portalPageID: this.o.portalPageID,
                        startDate: this.o.startDate,
                    };
                    return obj;
                }
            }
            appointments.BookTimeslot = BookTimeslot;
            class CancelTimeslot extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointments";
                    this.Action = "CancelTimeslot";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        portalPageID: this.o.portalPageID,
                        timeSlotID: this.o.timeSlotID,
                    };
                    return obj;
                }
            }
            appointments.CancelTimeslot = CancelTimeslot;
            class GetBookedAppointments extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointments";
                    this.Action = "GetBookedAppointments";
                }
                CallData() {
                    var obj = {
                        appointmentProcessIDs: this.o.appointmentProcessIDs,
                        portalPageID: this.o.portalPageID,
                    };
                    return obj;
                }
            }
            appointments.GetBookedAppointments = GetBookedAppointments;
            class GetProcessDescription extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointments";
                    this.Action = "GetProcessDescription";
                }
                CallData() {
                    var obj = {
                        appointmentProcessID: this.o.appointmentProcessID,
                        portalPageID: this.o.portalPageID,
                    };
                    return obj;
                }
            }
            appointments.GetProcessDescription = GetProcessDescription;
            class GetProcessInitialDate extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointments";
                    this.Action = "GetProcessInitialDate";
                }
                CallData() {
                    var obj = {
                        appointmentProcessID: this.o.appointmentProcessID,
                    };
                    return obj;
                }
            }
            appointments.GetProcessInitialDate = GetProcessInitialDate;
            class GetSuggestions extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointments";
                    this.Action = "GetSuggestions";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        roomLocationIDs: this.o.roomLocationIDs,
                    };
                    return obj;
                }
            }
            appointments.GetSuggestions = GetSuggestions;
            class GetTimeslots extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointments";
                    this.Action = "GetTimeslots";
                }
                CallData() {
                    var obj = {
                        appointmentProcessID: this.o.appointmentProcessID,
                        end: this.o.end,
                        portalPageID: this.o.portalPageID,
                        start: this.o.start,
                    };
                    return obj;
                }
            }
            appointments.GetTimeslots = GetTimeslots;
        })(appointments = service.appointments || (service.appointments = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var appointmenttimeslot;
        (function (appointmenttimeslot) {
            "use strict";
            class BookTimeslot extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmenttimeslot";
                    this.Action = "BookTimeslot";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        appointmentProcessID: this.o.appointmentProcessID,
                        endDate: this.o.endDate,
                        portalPageID: this.o.portalPageID,
                        startDate: this.o.startDate,
                    };
                    return obj;
                }
            }
            appointmenttimeslot.BookTimeslot = BookTimeslot;
            class CancelTimeslot extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmenttimeslot";
                    this.Action = "CancelTimeslot";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        appointmentProcessIDs: this.o.appointmentProcessIDs,
                        portalPageID: this.o.portalPageID,
                        timeSlotID: this.o.timeSlotID,
                    };
                    return obj;
                }
            }
            appointmenttimeslot.CancelTimeslot = CancelTimeslot;
            class GetAppointmentsICalendarFile extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmenttimeslot";
                    this.Action = "GetAppointmentsICalendarFile";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        timeSlotID: this.o.timeSlotID,
                    };
                    return obj;
                }
            }
            appointmenttimeslot.GetAppointmentsICalendarFile = GetAppointmentsICalendarFile;
            class GetBookedAppointmentTable extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmenttimeslot";
                    this.Action = "GetBookedAppointmentTable";
                }
                CallData() {
                    var obj = {
                        appointmentProcessIDs: this.o.appointmentProcessIDs,
                        portalPageID: this.o.portalPageID,
                    };
                    return obj;
                }
            }
            appointmenttimeslot.GetBookedAppointmentTable = GetBookedAppointmentTable;
            class GetBookingSuccessMessage extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmenttimeslot";
                    this.Action = "GetBookingSuccessMessage";
                }
                CallData() {
                    var obj = {
                        portalPageID: this.o.portalPageID,
                        timeSlotID: this.o.timeSlotID,
                    };
                    return obj;
                }
            }
            appointmenttimeslot.GetBookingSuccessMessage = GetBookingSuccessMessage;
            class GetCancelSuccessMessage extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmenttimeslot";
                    this.Action = "GetCancelSuccessMessage";
                }
                CallData() {
                    var obj = {
                        portalPageID: this.o.portalPageID,
                        timeSlotID: this.o.timeSlotID,
                    };
                    return obj;
                }
            }
            appointmenttimeslot.GetCancelSuccessMessage = GetCancelSuccessMessage;
            class GetRescheduleSuccessMessage extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmenttimeslot";
                    this.Action = "GetRescheduleSuccessMessage";
                }
                CallData() {
                    var obj = {
                        portalPageID: this.o.portalPageID,
                        timeSlotID: this.o.timeSlotID,
                    };
                    return obj;
                }
            }
            appointmenttimeslot.GetRescheduleSuccessMessage = GetRescheduleSuccessMessage;
            class RescheduleAppointment extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Appointments";
                    this.Controller = "appointmenttimeslot";
                    this.Action = "RescheduleAppointment";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        appointmentProcessID: this.o.appointmentProcessID,
                        endDate: this.o.endDate,
                        existingTimeSlotID: this.o.existingTimeSlotID,
                        portalPageID: this.o.portalPageID,
                        startDate: this.o.startDate,
                    };
                    return obj;
                }
            }
            appointmenttimeslot.RescheduleAppointment = RescheduleAppointment;
        })(appointmenttimeslot = service.appointmenttimeslot || (service.appointmenttimeslot = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var booking;
    (function (booking) {
        "use strict";
        function init(container) {
            ((c, ctrls) => {
                const groupCode = ctrls.getByName("GroupCode");
                const result = c.querySelector(".ui-group-selector-result");
                const button = c.querySelector(".ui-enter-group-code");
                button.addEventListener("click", () => {
                    if (groupCode.checkValidity()) {
                        new starrez.service.booking.GetGroups({
                            portalPageID: portal.page.CurrentPage.PageID,
                            groupCode: groupCode.pxValue()
                        }).Get().done((data) => {
                            result.innerHTML = data;
                        });
                    }
                });
                groupCode.addEventListener("keydown", e => {
                    if (e.keyCode === starrez.keyboard.EnterCode) {
                        e.preventDefault();
                        e.stopPropagation();
                        button.click();
                    }
                });
                button.click();
            })(container, portal.pxcontrols.controlFunctions);
        }
        booking.init = init;
        function Initialise($container) {
            new Booking($container);
        }
        booking.Initialise = Initialise;
        class Booking {
            constructor($container) {
                this.$container = $container;
                this.$resultContainer = $container.find(".ui-group-selector-result");
                this.$groupCodeButton = $container.find(".ui-enter-group-code");
                this.$groupCodeText = this.$container.GetControl("GroupCode");
                this.AttachEvent();
                //Reload the result for the first time
                this.$groupCodeButton.click();
            }
            AttachEvent() {
                this.$groupCodeButton.SRClick((e) => {
                    new starrez.service.booking.GetGroups({
                        portalPageID: portal.page.CurrentPage.PageID,
                        groupCode: this.$groupCodeText.SRVal()
                    }).Get().done((data) => {
                        this.$resultContainer.html(data);
                    });
                });
                this.$groupCodeText.keydown(e => {
                    if (e.keyCode === starrez.keyboard.EnterCode) {
                        // The browsers have a behaviour where they will automatically submit the form if there is only one
                        // input field on it. This is not what we want to do, so call SafeStopPropagation to block this from happening.
                        // http://stackoverflow.com/questions/1370021/why-does-forms-with-single-input-field-submit-upon-pressing-enter-key-in-input
                        starrez.library.utils.SafeStopPropagation(e);
                        this.$groupCodeButton.click();
                    }
                });
            }
        }
    })(booking = portal.booking || (portal.booking = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.booking.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var booking;
        (function (booking) {
            "use strict";
            class GetGroups extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Booking";
                    this.Controller = "booking";
                    this.Action = "GetGroups";
                }
                CallData() {
                    var obj = {
                        groupCode: this.o.groupCode,
                        portalPageID: this.o.portalPageID,
                    };
                    return obj;
                }
            }
            booking.GetGroups = GetGroups;
        })(booking = service.booking || (service.booking = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var bookingroommateprofiles;
        (function (bookingroommateprofiles) {
            "use strict";
            function Initialise($container) {
                bookingroommateprofiles.Model = new BookingRoommateProfiles($container);
            }
            bookingroommateprofiles.Initialise = Initialise;
            class BookingRoommateProfiles {
                constructor($container) {
                    this.$container = $container;
                    var $headerContainer = this.$container.find(".ui-booking-roommate-profile-type-container");
                    $headerContainer.SRClick((e) => {
                        var $header = $(e.currentTarget);
                        var $matchContainer = $header.closest(".ui-booking-roommate-profile-container");
                        var expanded = false;
                        if ($matchContainer.hasClass("collapsed")) {
                            expanded = true;
                        }
                        var $toggleIcon = $header.find(".ui-profile-toggle");
                        var $profileItemsContainer = $matchContainer.find(".ui-booking-roommate-profile-items-container");
                        if (expanded) {
                            $toggleIcon.removeClass("fa-caret-right").addClass("fa-caret-down");
                            $profileItemsContainer.css("maxHeight", $profileItemsContainer[0].scrollHeight + "px");
                            $header.attr("aria-expanded", "true");
                        }
                        else {
                            $toggleIcon.removeClass("fa-caret-down").addClass("fa-caret-right");
                            $profileItemsContainer.css("maxHeight", "");
                            $header.attr("aria-expanded", "false");
                        }
                        $matchContainer.toggleClass("collapsed");
                    });
                    $headerContainer.on("keyup", (e) => {
                        if (e.keyCode === starrez.keyboard.EnterCode || e.keyCode === starrez.keyboard.SpaceCode) {
                            $(e.currentTarget).trigger("click");
                        }
                    });
                }
            }
        })(bookingroommateprofiles = general.bookingroommateprofiles || (general.bookingroommateprofiles = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.bookingroommateprofiles.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var bottomlineregistration;
    (function (bottomlineregistration) {
        "use strict";
        function InitialiseRegistrationPage($container) {
            new RegistrationPage($container);
        }
        bottomlineregistration.InitialiseRegistrationPage = InitialiseRegistrationPage;
        class RegistrationPage {
            constructor($container) {
                this.$container = $container;
                this.$registerButton = $container.find(".ui-registerrecurringpayments");
                this.$cancelButton = $container.find(".ui-cancelrecurringpayments");
                this.AttachButtonEvents();
            }
            AttachButtonEvents() {
                this.$registerButton.SRClick(() => {
                    this.Register();
                });
                this.$cancelButton.SRClick(() => {
                    portal.ConfirmAction("Are you sure you want to cancel your Direct Debit Mandate?", "Direct Debit Mandate").done(() => {
                        this.Cancel();
                    });
                });
            }
            Register() {
                new starrez.service.bottomlineregistration.Register({
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                })
                    .Post()
                    .done((data, textStatus, jqXHR) => {
                    window.location.href = data;
                })
                    .fail((jqXHR, textStatus, errorThrown) => {
                    portal.page.CurrentPage.SetErrorMessage("Could not register for Bottomline Direct Debit");
                });
            }
            Cancel() {
                new starrez.service.bottomlineregistration.Cancel({
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                })
                    .Post()
                    .done((data, textStatus, jqXHR) => {
                    window.location.href = data;
                })
                    .fail((jqXHR, textStatus, errorThrown) => {
                    portal.page.CurrentPage.SetErrorMessage("Could not cancel Bottomline Direct Debit registration");
                });
            }
        }
    })(bottomlineregistration = starrez.bottomlineregistration || (starrez.bottomlineregistration = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.bottomlineregistration.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function BottomlineRegistrationModel($sys) {
            return {};
        }
        model.BottomlineRegistrationModel = BottomlineRegistrationModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var bottomlineregistration;
        (function (bottomlineregistration) {
            "use strict";
            class Cancel extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "BottomlineRegistration";
                    this.Controller = "bottomlineregistration";
                    this.Action = "Cancel";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            bottomlineregistration.Cancel = Cancel;
            class Register extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "BottomlineRegistration";
                    this.Controller = "bottomlineregistration";
                    this.Action = "Register";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            bottomlineregistration.Register = Register;
        })(bottomlineregistration = service.bottomlineregistration || (service.bottomlineregistration = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var bpointregistration;
    (function (bpointregistration) {
        "use strict";
        function InitialiseRegistrationPage($container) {
            new RegistrationPage($container);
        }
        bpointregistration.InitialiseRegistrationPage = InitialiseRegistrationPage;
        class RegistrationPage {
            constructor($container) {
                this.$container = $container;
                this.$createButton = $container.find(".ui-create");
                this.$updateButton = $container.find(".ui-update");
                this.$deleteButton = $container.find(".ui-delete");
                this.AttachButtonEvents();
            }
            AttachButtonEvents() {
                this.$createButton.SRClick(() => {
                    this.CreateUpdateToken();
                });
                this.$updateButton.SRClick(() => {
                    this.CreateUpdateToken();
                });
                this.$deleteButton.SRClick(() => {
                    this.DeleteToken();
                });
            }
            CreateUpdateToken() {
                var call = new starrez.service.bpointregistration.Create({
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                });
                var url = starrez.library.service.CreateUrl(call.GetURLWithParameters());
                if (window.parent) {
                    parent.location.href = url;
                }
                else {
                    location.href = url;
                }
            }
            DeleteToken() {
                var call = new starrez.service.bpointregistration.Delete({
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                });
                var url = starrez.library.service.CreateUrl(call.GetURLWithParameters());
                if (window.parent) {
                    parent.location.href = url;
                }
                else {
                    location.href = url;
                }
            }
        }
    })(bpointregistration = starrez.bpointregistration || (starrez.bpointregistration = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.bpointregistration.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var bpointregistration;
        (function (bpointregistration) {
            "use strict";
            class Create extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "BPOINTRegistration";
                    this.Controller = "bpointregistration";
                    this.Action = "Create";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            bpointregistration.Create = Create;
            class Delete extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "BPOINTRegistration";
                    this.Controller = "bpointregistration";
                    this.Action = "Delete";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            bpointregistration.Delete = Delete;
        })(bpointregistration = service.bpointregistration || (service.bpointregistration = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var bpointv3registration;
    (function (bpointv3registration) {
        "use strict";
        function InitialiseRegistrationPage($container) {
            new RegistrationPage($container);
        }
        bpointv3registration.InitialiseRegistrationPage = InitialiseRegistrationPage;
        class RegistrationPage {
            constructor($container) {
                this.$container = $container;
                this.$createButton = $container.find(".ui-create");
                this.$updateButton = $container.find(".ui-update");
                this.$deleteButton = $container.find(".ui-delete");
                this.AttachButtonEvents();
            }
            AttachButtonEvents() {
                this.$createButton.SRClick(() => {
                    this.CreateUpdateToken();
                });
                this.$updateButton.SRClick(() => {
                    this.CreateUpdateToken();
                });
                this.$deleteButton.SRClick(() => {
                    this.DeleteToken();
                });
            }
            CreateUpdateToken() {
                var call = new starrez.service.bpointv3registration.Create({
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                });
                var url = starrez.library.service.CreateUrl(call.GetURLWithParameters());
                if (window.parent) {
                    parent.location.href = url;
                }
                else {
                    location.href = url;
                }
            }
            DeleteToken() {
                var call = new starrez.service.bpointv3registration.Delete({
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                });
                var url = starrez.library.service.CreateUrl(call.GetURLWithParameters());
                if (window.parent) {
                    parent.location.href = url;
                }
                else {
                    location.href = url;
                }
            }
        }
    })(bpointv3registration = starrez.bpointv3registration || (starrez.bpointv3registration = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.bpointregistration.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var bpointv3registration;
        (function (bpointv3registration) {
            "use strict";
            class Create extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "BPOINTv3Registration";
                    this.Controller = "bpointv3registration";
                    this.Action = "Create";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            bpointv3registration.Create = Create;
            class Delete extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "BPOINTv3Registration";
                    this.Controller = "bpointv3registration";
                    this.Action = "Delete";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            bpointv3registration.Delete = Delete;
        })(bpointv3registration = service.bpointv3registration || (service.bpointv3registration = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var concerns;
        (function (concerns) {
            "use strict";
            function InitConcerns($container) {
                new ConcernsManager($container);
            }
            concerns.InitConcerns = InitConcerns;
            class ConcernsManager {
                constructor($container) {
                    this.$container = $container;
                    this.$container.find(".ui-add-participant").SRClick(e => this.AddParticipant(e));
                    this.$container.find(".ui-remove-participant").SRClick(e => this.RemoveParticipant(e));
                    if (window.location.hash.indexOf("ParticipantModified") != -1) {
                        $.ScrollToWithAnimation(".ui-participants");
                    }
                    var $concernType = $container.GetControl("ConcernTypeID");
                    var $concernSubType = $container.GetControl("ConcernSubTypeID");
                    if ($concernSubType.length) {
                        $concernSubType.Disable();
                        $concernType.change(() => {
                            var concernTypeID = Number($concernType.SRVal());
                            if (concernTypeID > 0) {
                                var getSubTypes = new starrez.service.concerns.GetConcernSubTypes({
                                    concernTypeID: concernTypeID
                                });
                                getSubTypes.Request((json) => {
                                    if (portal.Feature.PortalXFormControls) {
                                        portal.pxcontrols.pxFillDropDown(json, document.getElementsByName("ConcernSubTypeID")[0]);
                                    }
                                    else {
                                        starrez.library.controls.dropdown.FillDropDown(json, $concernSubType, "Value", "Text", "", false);
                                    }
                                    $concernSubType.Enable();
                                });
                            }
                            else {
                                starrez.library.controls.dropdown.SetValue($concernSubType, "0");
                                $concernSubType.Disable();
                            }
                        });
                    }
                }
                AddParticipant(e) {
                    portal.page.CurrentPage.FetchAdditionalData = () => {
                        return { AddParticipantAfterCreation: true };
                    };
                    portal.page.CurrentPage.SubmitPage();
                }
                RemoveParticipant(e) {
                    var $button = $(e.currentTarget);
                    portal.ConfirmAction($button.data("confirmmessage").toString(), "Remove Participant").done(() => {
                        new starrez.service.concerns.RemoveParticipant({
                            participantID: Number($button.data("participantid")),
                            hash: $button.data("hash").toString()
                        }).Post().done(() => {
                            $button.closest(".ui-action-panel").remove();
                        });
                    });
                }
            }
        })(concerns = general.concerns || (general.concerns = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.concerns.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var concerns;
        (function (concerns) {
            "use strict";
            class GetConcernSubTypes extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Concerns";
                    this.Controller = "concerns";
                    this.Action = "GetConcernSubTypes";
                }
                CallData() {
                    var obj = {
                        concernTypeID: this.o.concernTypeID,
                    };
                    return obj;
                }
            }
            concerns.GetConcernSubTypes = GetConcernSubTypes;
            class RemoveParticipant extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Concerns";
                    this.Controller = "concerns";
                    this.Action = "RemoveParticipant";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        participantID: this.o.participantID,
                    };
                    return obj;
                }
            }
            concerns.RemoveParticipant = RemoveParticipant;
        })(concerns = service.concerns || (service.concerns = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
/* Wrappers for what will eventually be generated by TSMVC  */
var starrez;
(function (starrez) {
    var general;
    (function (general) {
        var datainput;
        (function (datainput) {
            var formwidget;
            (function (formwidget) {
                var servicewrapper;
                (function (servicewrapper) {
                    "use strict";
                })(servicewrapper = formwidget.servicewrapper || (formwidget.servicewrapper = {}));
            })(formwidget = datainput.formwidget || (datainput.formwidget = {}));
        })(datainput = general.datainput || (general.datainput = {}));
    })(general = starrez.general || (starrez.general = {}));
})(starrez || (starrez = {}));
var portal;
(function (portal) {
    var general;
    (function (general) {
        var datainput;
        (function (datainput) {
            "use strict";
            let ControlType;
            (function (ControlType) {
                ControlType[ControlType["Checkbox"] = 0] = "Checkbox";
                ControlType[ControlType["DatePicker"] = 1] = "DatePicker";
                ControlType[ControlType["DateTimePicker"] = 2] = "DateTimePicker";
                ControlType[ControlType["DecimalTextbox"] = 3] = "DecimalTextbox";
                ControlType[ControlType["Dropdown"] = 4] = "Dropdown";
                ControlType[ControlType["IntegerTextbox"] = 5] = "IntegerTextbox";
                ControlType[ControlType["TimePicker"] = 6] = "TimePicker";
                ControlType[ControlType["TextArea"] = 7] = "TextArea";
                ControlType[ControlType["RadioButtons"] = 8] = "RadioButtons";
            })(ControlType = datainput.ControlType || (datainput.ControlType = {}));
            let LookupType;
            (function (LookupType) {
                LookupType[LookupType["Lookup"] = 0] = "Lookup";
                LookupType[LookupType["DatabaseTable"] = 1] = "DatabaseTable";
                LookupType[LookupType["GenericTable"] = 2] = "GenericTable";
            })(LookupType = datainput.LookupType || (datainput.LookupType = {}));
            var editorDataName = "Editor";
            function InitializeFieldListInlineEditor($container) {
                var widget = starrez.model.WidgetModelBaseModel($container);
                $container.data(editorDataName, new FieldListEditor($container.data("tablename").toString(), widget.PortalPageWidgetID, $container, false));
                InitializeFormWidget($container);
            }
            datainput.InitializeFieldListInlineEditor = InitializeFieldListInlineEditor;
            function InitializeRepeatingFieldListInlineEditor($container) {
                var widget = starrez.model.WidgetModelBaseModel($container);
                $container.data(editorDataName, new FieldListEditor($container.data("tablename").toString(), widget.PortalPageWidgetID, $container, true));
                InitializeFormWidget($container);
            }
            datainput.InitializeRepeatingFieldListInlineEditor = InitializeRepeatingFieldListInlineEditor;
            function InitializeNewFieldEditor($container) {
                var portalPageWidgetID = Number($container.data("portalpagewidgetid"));
                $container.data(editorDataName, new NewFieldEditor($container, portalPageWidgetID));
            }
            datainput.InitializeNewFieldEditor = InitializeNewFieldEditor;
            function InitializeEditFieldEditor($container) {
                var portalPageWidgetID = Number($container.data("portalpagewidgetid"));
                var fieldType = $container.data("fieldtype");
                $container.data(editorDataName, new EditFieldEditor($container, portalPageWidgetID));
                var $intellisenseContainer = $container.find(".ui-editor-setting-row").not(".ui-disable-intellisense");
                starrez.library.controls.autocomplete.Hookup($intellisenseContainer, t => new starrez.service.formwidget.FieldAutoComplete({ fieldType: fieldType, text: t, portalPageWidgetID: portalPageWidgetID }));
                starrez.library.controls.autocomplete.HookupSimpleMDE($intellisenseContainer, t => new starrez.service.formwidget.FieldAutoComplete({ fieldType: fieldType, text: t, portalPageWidgetID: portalPageWidgetID }));
                starrez.library.controls.starqlbuilder.HookupAllAutoCompleteHandlers($intellisenseContainer, t => new starrez.service.formwidget.FieldAutoComplete({ fieldType: fieldType, text: t, portalPageWidgetID: portalPageWidgetID }));
            }
            datainput.InitializeEditFieldEditor = InitializeEditFieldEditor;
            function InitializeFormWidget($container) {
                var portalPageWidgetID = Number($container.data("portalpagewidgetid"));
                let formWidget = new FormWidget(portalPageWidgetID, $container);
                $container.data("FormWidget", formWidget);
                window.addEventListener("load", () => {
                    portal.page.RemoveDuplicateFields($container);
                    formWidget.CleanupAfterDuplicateRemoval();
                });
            }
            datainput.InitializeFormWidget = InitializeFormWidget;
            function InitializeNewLookupEditor($container) {
                $container.data(editorDataName, new LookupEditor($container));
            }
            datainput.InitializeNewLookupEditor = InitializeNewLookupEditor;
            class FormWidget {
                constructor(portalPageWidgetID, $container) {
                    this.portalPageWidgetID = portalPageWidgetID;
                    this.$container = $container;
                    portal.page.RegisterWidgetSaveData(portalPageWidgetID, () => this.GetSaveData());
                    // Setup the Add record button
                    var $addButton = this.$container.find(".ui-add-record");
                    $addButton.SRClick((e) => {
                        this.AddNewRecord();
                    });
                }
                GetSaveData() {
                    var saveData = new starrez.library.collections.KeyValue();
                    if (portal.Feature.PortalXFormControls) {
                        const allControls = portal.pxcontrols.getAllControlsInContainer(this.$container.get(0));
                        allControls.forEach(e => {
                            const wrapper = e.element.closest(".ui-field-record");
                            const fieldID = wrapper.dataset["fieldid"];
                            const recordID = wrapper.dataset["key"];
                            const masterRecordID = wrapper.dataset["masterid"];
                            const value = e.serverValue;
                            // Prevent any field name from being submitted - it must be one of the pre-configured ones
                            // {guid}: value
                            saveData.Add(fieldID + "_" + recordID + "_" + masterRecordID, value);
                        });
                    }
                    else {
                        var $allControls = this.$container.GetAllControls();
                        // WTF!
                        $allControls.each((index, element) => {
                            var $control = $(element);
                            var fieldID = $control.closest("li").data("id").toString();
                            var recordID = $control.closest(".ui-field-record").data("id").toString();
                            var masterRecordID = $control.closest(".ui-field-record").data("masterid").toString();
                            var value = starrez.library.convert.ToValueForServer($control.SRVal());
                            // Prevent any field name from being submitted - it must be one of the pre-configured ones
                            // {guid}: value
                            saveData.Add(fieldID + "_" + recordID + "_" + masterRecordID, value);
                        });
                    }
                    var data = saveData.ToArray();
                    if (data.length === 0) {
                        return null;
                    }
                    return data;
                }
                CleanupAfterDuplicateRemoval() {
                    let fieldList = this.$container.find(".ui-field-list").get(0);
                    let $fieldList = $(fieldList);
                    let hrs = $fieldList.find("hr.repeating-field-list-divider");
                    let foundOrphans = false;
                    hrs.each((index, hr) => {
                        let $hr = $(hr);
                        if ($hr.prev().length == 0) {
                            // If we're here, this is a divider HR with no previous item to divide, so
                            // get rid of it
                            $hr.remove();
                            foundOrphans = true;
                        }
                    });
                    if (foundOrphans && $fieldList.children().length == 0) {
                        // If we're here, this is a duplicate field and so we shouldn't show
                        // the 'add new record' button
                        let $addButton = this.$container.find(".ui-add-record");
                        $addButton.remove();
                    }
                }
                AddNewRecord() {
                    var deferred = $.Deferred();
                    // Find the lowest master ID that exists.  Set the new master ID to -1, if no negative IDs yet exist, or decrement by 1 if they do
                    const children = this.$container.closest(".ui-field-list-container").find(".ui-field-list [data-masterid]");
                    const ids = children.map((_, li) => Number($(li).data("masterid"))).toArray();
                    var minID = Math.min.apply(this, ids);
                    var addNewRecordCall = new starrez.service.repeatingformwidget.AddNewRecord({
                        portalPageWidgetID: this.portalPageWidgetID,
                        index: ids.length
                    });
                    if (minID >= 0) {
                        minID = -1;
                    }
                    else {
                        minID--;
                    }
                    addNewRecordCall.Get().done(html => {
                        var newRecord = $(html);
                        newRecord.find(".ui-field-record").each(function () {
                            $(this).attr("data-masterid", minID);
                        });
                        this.$container.closest(".ui-field-list-container").find(".ui-field-list").append(newRecord);
                        portal.page.RemoveDuplicateFields(this.$container);
                        if (this.$container.find(newRecord).length > 0) {
                            let hr = document.createElement("hr");
                            hr.AddClass("repeating-field-list-divider");
                            newRecord.append(hr);
                        }
                        deferred.resolve();
                    });
                    return deferred.promise();
                }
            }
            class FieldListEditor {
                constructor(tableName, portalPageWidgetID, $container, repeatFlag) {
                    this.tableName = tableName;
                    this.portalPageWidgetID = portalPageWidgetID;
                    this.$container = $container;
                    this.repeatFlag = repeatFlag;
                    this.sortOptions = {
                        handle: ".ui-drag-handle",
                        axis: "y",
                        cursor: "move",
                        items: "> li:not(.ui-add-field)"
                    };
                    this.InitOrdering();
                    this.AttachEvents();
                }
                RefreshFieldList() {
                    var deferred = $.Deferred();
                    var refreshFieldListCall = new starrez.service.formwidget.GetRefreshedFieldList({
                        portalPageWidgetID: this.portalPageWidgetID,
                        url: window.location.href,
                        repeatFlag: this.repeatFlag
                    });
                    refreshFieldListCall.Get().done(html => {
                        // Refreshing the list will register the save data - so remove the existing registration so we don"t end up with multiple
                        portal.page.RemoveWidgetSaveData(this.portalPageWidgetID);
                        var $fieldContainer = this.$container.closest(".ui-field-list-container");
                        $fieldContainer.html(html);
                        portal.validation.ValidateForm($fieldContainer);
                        deferred.resolve();
                    });
                    return deferred.promise();
                }
                AttachEvents() {
                    // Setup the add field button/template
                    var $addFieldButton = this.$container.find(".ui-add-field");
                    $addFieldButton.SRClick(() => {
                        var call = new starrez.service.formwidget.CreateNewField({
                            tableName: this.tableName,
                            portalPageWidgetID: this.portalPageWidgetID
                        });
                        portal.OpenSRWActionInDialog(call, popup => {
                            this.InitFieldEditor(popup);
                        });
                    });
                    // Setup the Edit buttons next to each field
                    var $editButtons = this.$container.find(".ui-edit-field");
                    $editButtons.click(e => {
                        var $fieldItem = $(e.currentTarget).closest("li");
                        this.EditField($fieldItem);
                        starrez.library.utils.SafeStopPropagation(e);
                    });
                    // Setup the Remove buttons next to each field
                    var $removeButtons = this.$container.find(".ui-remove-field");
                    $removeButtons.click(e => {
                        var $button = $(e.currentTarget);
                        var $fieldItem = $button.closest("li");
                        var fieldLabel = $button.data("label");
                        portal.ConfirmAction("Do you want to delete '" + fieldLabel + "'?", "Delete").done(() => {
                            this.RemoveField($fieldItem);
                        });
                        starrez.library.utils.SafeStopPropagation(e);
                    });
                }
                EditField($fieldItem) {
                    var id = String($fieldItem.closest("li").data("id"));
                    var editCall = new starrez.service.formwidget.EditField({
                        fieldID: id,
                        portalPageWidgetID: this.portalPageWidgetID
                    });
                    portal.OpenSRWActionInDialog(editCall, popup => {
                        this.InitFieldEditor(popup);
                    });
                }
                RemoveField($fieldItem) {
                    var id = String($fieldItem.closest("li").data("id"));
                    var removeCall = new starrez.service.formwidget.RemoveField({
                        fieldID: id,
                        portalPageWidgetID: this.portalPageWidgetID,
                        errorHandler: starrez.error.CreateErrorObject()
                    });
                    removeCall.Post().done(() => {
                        this.RefreshFieldList();
                    });
                }
                InitOrdering() {
                    var $fieldList = this.$container.find(".ui-field-list");
                    $fieldList.sortable(this.sortOptions);
                    $fieldList.on("sortupdate", e => {
                        var idOrderMapping = new starrez.library.collections.KeyValue();
                        $fieldList.find("li:not(.ui-add-field, .ui-ignore-sort)").each((index, element) => {
                            var id = String($(element).data("id"));
                            idOrderMapping.Add(id, index);
                        });
                        var updateCall = new starrez.service.formwidget.ReorderFields({
                            idOrderMapping: idOrderMapping.ToArray(),
                            portalPageWidgetID: this.portalPageWidgetID,
                            errorHandler: starrez.error.CreateErrorObject()
                        });
                        updateCall.Post().done(() => {
                            this.RefreshFieldList();
                        });
                    });
                }
                InitFieldEditor(popup) {
                    var $editorContainer = popup.$article.find(".ui-field-container");
                    var fieldEditor = $editorContainer.data(editorDataName);
                    fieldEditor.fieldListEditor = this;
                }
            }
            class FieldEditorBase {
                constructor($container, portalPageWidgetID) {
                    this.$container = $container;
                    this.portalPageWidgetID = portalPageWidgetID;
                    this.InitControls();
                }
                InitControls() {
                    var $saveButton = starrez.popup.GetPopupContainerAreas(this.$container).$footer.find(".ui-btn-save");
                    $saveButton.click(() => {
                        this.Validate().done(() => {
                            this.Save().done(() => {
                                this.PostSaveOperation();
                            });
                        }).fail((message) => {
                            starrez.ui.ShowAlertMessage(message);
                        });
                    });
                }
                Validate() {
                    var validationDeferred = $.Deferred();
                    var message = this.SynchronousValidation();
                    if (starrez.library.utils.IsNotNullUndefined(message)) {
                        validationDeferred.reject(message);
                    }
                    else {
                        validationDeferred.resolve(null);
                    }
                    return validationDeferred.promise();
                }
                /**
                  *Simple validation that is Synchronous. Complicated valudation will require overriding Validate()
                  * returns message when invalid null/undefined when valid
                  */
                SynchronousValidation() {
                    return null;
                }
                Get(controlName) {
                    const $control = this.$container.GetControl(controlName);
                    if ($control) {
                        return $control.SRVal();
                    }
                    else {
                        return null;
                    }
                }
            }
            class NewFieldEditor extends FieldEditorBase {
                constructor($container, portalPageWidgetID) {
                    super($container, portalPageWidgetID);
                    this.$fieldNameControl = this.$container.GetControl(NewFieldEditor.FieldPropertyName);
                }
                Save() {
                    var selectedFields = this.$selectedNodes.map((i, e) => {
                        var fieldData = {
                            FieldName: $(e).data("field-uniqueid").toString(),
                            DisplayName: $(e).data("field-displayname").toString(),
                            TableName: $(e).closest(".ui-treeview-list").find(".ui-tree-view-row-item:first").data("caption").toString(),
                            LookupID: Number(this.$container.GetControl("LookupID").SRVal())
                        };
                        return fieldData;
                    }).toArray();
                    var call = new starrez.service.formwidget.AddFields({
                        fields: selectedFields,
                        portalPageWidgetID: this.portalPageWidgetID,
                        errorHandler: starrez.error.CreateErrorObject()
                    });
                    return call.Post();
                }
                PostSaveOperation() {
                    //1. Form widgets detect duplicate fields by assigning same HTML ID to same fields loaded on CURRENT request.
                    //   This means that if there are multiple form widgets on one page, admin won't know if they added duplicate fields/not
                    //   until they reload the page and force reload all fields in all form widgets on the page in a single request.
                    //   Long story short, just reload the page here, don't use RefreshFieldList method. Otherwise, duplicate fields checking won't work.
                    //2. IE has issues where SRClickDelegate attached to iFrame contents won't work if only the iframe is refreshed,
                    //   hence why we need to refresh the whole window
                    if (starrez.library.browser.GetBrowser() === starrez.library.browser.BrowserType.InternetExplorer) {
                        window.top.location.reload();
                    }
                    else {
                        location.reload();
                    }
                }
                SynchronousValidation() {
                    this.$selectedNodes = starrez.library.controls.treeview.SelectedItem(this.$fieldNameControl);
                    if (!this.$selectedNodes.isFound()) {
                        return "You must select at least one field to continue.";
                    }
                    return null;
                }
            }
            NewFieldEditor.FieldPropertyName = "FieldName";
            class EditFieldEditor extends FieldEditorBase {
                InitControls() {
                    super.InitControls();
                    this.editableRelatedFields = [EditFieldEditor.MaxLengthPropertyName, EditFieldEditor.PatternPropertyName, EditFieldEditor.ErrorTextPropertyName,
                        EditFieldEditor.DefaultValuePropertyName, EditFieldEditor.IsRequiredPropertyName, EditFieldEditor.RequiredErrorMessage, EditFieldEditor.PatternErrorMessage,
                        EditFieldEditor.MaxLengthErrorMessage, EditFieldEditor.UsePatternValidation];
                    this.$isReadOnlyControl = this.$container.GetControl(EditFieldEditor.IsReadOnlyPropertyName);
                    this.$isReadOnlyControl.change(() => this.ToggleEditableRelatedFields(false));
                    this.ToggleEditableRelatedFields(true);
                    this.$isControlTypeOverrideControl = this.$container.GetControl(EditFieldEditor.IsControlTypeOverride);
                    this.$isControlTypeOverrideControl.change(() => {
                        this.ToggleControlOverride(false, true);
                    });
                    this.ToggleControlOverride(true, false);
                    this.$controlTypeOverrideControl = this.$container.GetControl(EditFieldEditor.ControlTypeOverride);
                    this.$controlTypeOverrideControl.change(() => {
                        this.ToggleDropdownControls(false, true);
                    });
                    this.$lookupTypeControl = this.$container.GetControl(EditFieldEditor.LookupType);
                    this.$lookupTypeControl.change(() => {
                        this.ToggleLookupControls(false, true);
                    });
                    this.$container.GetControl(EditFieldEditor.LookupID).change(() => {
                        this.UpdateDefaultValueControl();
                    });
                    this.$isRequiredControl = this.$container.GetControl(EditFieldEditor.IsRequiredPropertyName);
                    this.$isRequiredControl.change(() => this.ToggleControl(false, starrez.library.convert.ToBoolean(this.$isRequiredControl.SRVal()), EditFieldEditor.RequiredErrorMessage));
                    this.ToggleControl(true, starrez.library.convert.ToBoolean(this.$isRequiredControl.SRVal()), EditFieldEditor.RequiredErrorMessage);
                    this.$usePatternValidationControl = this.$container.GetControl(EditFieldEditor.UsePatternValidation);
                    this.$usePatternValidationControl.change(() => {
                        this.TogglePatternValidationControls(false);
                    });
                    this.TogglePatternValidationControls(true);
                    this.$lookupTableNameControl = this.$container.GetControl(EditFieldEditor.LookupTableName);
                    this.$lookupTableValueColumnNameControl = this.$container.GetControl(EditFieldEditor.LookupTableValueColumnName);
                    this.$lookupTableTextColumnNameControl = this.$container.GetControl(EditFieldEditor.LookupTableTextColumnName);
                    this.$defaultValueControl = this.$container.find(".ui-default-value-control");
                    this.$lookupTableNameControl.change(e => {
                        this.GetLookupTableColumns();
                        this.UpdateDefaultValueControl();
                    });
                    this.$lookupTableTextColumnNameControl.change(() => {
                        this.UpdateDefaultValueControl();
                    });
                    this.$lookupTableValueColumnNameControl.change(() => {
                        this.UpdateDefaultValueControl();
                    });
                    var $addLookupButton = this.$container.find(".ui-btn-add-lookup");
                    $addLookupButton.click(e => {
                        this.AddLookup();
                    });
                }
                AddLookup() {
                    var addLookupCall = new starrez.service.formwidget.AddLookup();
                    portal.OpenSRWActionInDialog(addLookupCall, popup => {
                        this.InitLookupEditor(popup);
                    });
                }
                RefreshLookups(value, innerHtml) {
                    var option = document.createElement("option");
                    option.value = value.toString();
                    ;
                    option.innerText = innerHtml;
                    var $select = this.$container.GetControl(EditFieldEditor.LookupID).children("div").children("select");
                    $select.append(option);
                }
                GetLookupTables() {
                    var call = new starrez.service.formwidget.GetLookupTables({
                        lookupType: this.$container.GetControl(EditFieldEditor.LookupType).SRVal()
                    });
                    call.Get().done(json => {
                        starrez.library.controls.dropdown.FillDropDown(json, this.$lookupTableNameControl, "Value", "Text", "", false);
                        this.GetLookupTableColumns();
                    });
                }
                GetLookupTableColumns() {
                    var call = new starrez.service.formwidget.GetTableColumns({
                        lookupType: this.$container.GetControl(EditFieldEditor.LookupType).SRVal(),
                        tableName: this.$container.GetControl(EditFieldEditor.LookupTableName).SRVal()
                    });
                    call.Get().done(json => {
                        starrez.library.controls.dropdown.FillDropDown(json, this.$lookupTableValueColumnNameControl, "Value", "Text", "", false);
                        starrez.library.controls.dropdown.FillDropDown(json, this.$lookupTableTextColumnNameControl, "Value", "Text", "", false);
                        this.UpdateDefaultValueControl();
                    });
                }
                GetEditableField() {
                    if (portal.Feature.PortalXFormControls) {
                        return {
                            Label: this.Get(EditFieldEditor.LabelPropertyName),
                            IsRequired: starrez.library.convert.ToBoolean(this.Get(EditFieldEditor.IsRequiredPropertyName)),
                            MaxLength: this.Get(EditFieldEditor.MaxLengthPropertyName),
                            PatternString: this.Get(EditFieldEditor.PatternPropertyName),
                            DefaultValue: this.Get(EditFieldEditor.DefaultValuePropertyName),
                            ID: this.Get(EditFieldEditor.IDPropertyName),
                            IsReadOnly: starrez.library.convert.ToBoolean(this.Get(EditFieldEditor.IsReadOnlyPropertyName)),
                            UsePatternValidation: starrez.library.convert.ToBoolean(this.Get(EditFieldEditor.UsePatternValidation)),
                            PatternErrorMessage: this.Get(EditFieldEditor.PatternErrorMessage),
                            MaxLengthErrorMessage: this.Get(EditFieldEditor.MaxLengthErrorMessage),
                            MinValueErrorMessage: this.Get(EditFieldEditor.MinValueErrorMessage),
                            MaxValueErrorMessage: this.Get(EditFieldEditor.MaxValueErrorMessage),
                            RequiredErrorMessage: this.Get(EditFieldEditor.RequiredErrorMessage),
                            LookupType: this.Get(EditFieldEditor.LookupType),
                            LookupID: this.Get(EditFieldEditor.LookupID),
                            LookupCriteria: this.Get(EditFieldEditor.LookupCriteria),
                            LookupSortColumn: this.Get(EditFieldEditor.LookupSortColumn),
                            LookupSortOrder: this.Get(EditFieldEditor.LookupSortOrder),
                            ControlTypeOverride: this.Get(EditFieldEditor.ControlTypeOverride),
                            IsControlTypeOverride: starrez.library.convert.ToBoolean(this.Get(EditFieldEditor.IsControlTypeOverride)),
                            LookupTableName: this.Get(EditFieldEditor.LookupTableName),
                            LookupTableValueColumnName: this.Get(EditFieldEditor.LookupTableValueColumnName),
                            LookupTableTextColumnName: this.Get(EditFieldEditor.LookupTableTextColumnName),
                            IsUniqueID: this.Get(EditFieldEditor.IsUniqueIDPropertyName),
                            ValidationCriteria: this.Get(EditFieldEditor.ValidationCriteria),
                            ValidationCriteriaErrorMessage: this.Get(EditFieldEditor.ValidationCriteriaErrorMessage),
                            Placeholder: this.Get(EditFieldEditor.PlaceHolder), // remove the optional here when removing the FF
                            AutoComplete: this.Get(EditFieldEditor.AutoComplete),
                        };
                    }
                    else {
                        return {
                            Label: this.Get(EditFieldEditor.LabelPropertyName),
                            IsRequired: starrez.library.convert.ToBoolean(this.Get(EditFieldEditor.IsRequiredPropertyName)),
                            MaxLength: this.Get(EditFieldEditor.MaxLengthPropertyName),
                            PatternString: this.Get(EditFieldEditor.PatternPropertyName),
                            DefaultValue: this.Get(EditFieldEditor.DefaultValuePropertyName),
                            ID: this.Get(EditFieldEditor.IDPropertyName),
                            IsReadOnly: starrez.library.convert.ToBoolean(this.Get(EditFieldEditor.IsReadOnlyPropertyName)),
                            UsePatternValidation: starrez.library.convert.ToBoolean(this.Get(EditFieldEditor.UsePatternValidation)),
                            PatternErrorMessage: this.Get(EditFieldEditor.PatternErrorMessage),
                            MaxLengthErrorMessage: this.Get(EditFieldEditor.MaxLengthErrorMessage),
                            MinValueErrorMessage: this.Get(EditFieldEditor.MinValueErrorMessage),
                            MaxValueErrorMessage: this.Get(EditFieldEditor.MaxValueErrorMessage),
                            RequiredErrorMessage: this.Get(EditFieldEditor.RequiredErrorMessage),
                            LookupType: this.Get(EditFieldEditor.LookupType),
                            LookupID: this.Get(EditFieldEditor.LookupID),
                            LookupCriteria: this.Get(EditFieldEditor.LookupCriteria),
                            LookupSortColumn: this.Get(EditFieldEditor.LookupSortColumn),
                            LookupSortOrder: this.Get(EditFieldEditor.LookupSortOrder),
                            ControlTypeOverride: this.Get(EditFieldEditor.ControlTypeOverride),
                            IsControlTypeOverride: starrez.library.convert.ToBoolean(this.Get(EditFieldEditor.IsControlTypeOverride)),
                            LookupTableName: this.Get(EditFieldEditor.LookupTableName),
                            LookupTableValueColumnName: this.Get(EditFieldEditor.LookupTableValueColumnName),
                            LookupTableTextColumnName: this.Get(EditFieldEditor.LookupTableTextColumnName),
                            IsUniqueID: this.Get(EditFieldEditor.IsUniqueIDPropertyName),
                            ValidationCriteria: this.Get(EditFieldEditor.ValidationCriteria),
                            ValidationCriteriaErrorMessage: this.Get(EditFieldEditor.ValidationCriteriaErrorMessage),
                            Placeholder: "",
                            AutoComplete: ""
                        };
                    }
                }
                Save() {
                    var fieldData = this.GetEditableField();
                    var call = new starrez.service.formwidget.SaveField({
                        field: fieldData,
                        portalPageWidgetID: this.portalPageWidgetID,
                        errorHandler: starrez.error.CreateErrorObject()
                    });
                    return call.Post();
                }
                PostSaveOperation() {
                    this.fieldListEditor.RefreshFieldList().always(() => {
                        starrez.popup.Close(this.$container);
                    });
                }
                ToggleEditableRelatedFields(beQuick) {
                    var isReadOnly = starrez.library.convert.ToBoolean(this.$isReadOnlyControl.SRVal());
                    var effect = beQuick ? undefined : "slideup";
                    this.editableRelatedFields.forEach(controlName => {
                        var $controlRow = this.$container.GetControl(controlName).closest("li");
                        if (isReadOnly) {
                            $controlRow.hide(effect);
                        }
                        else if (!$controlRow.hasClass("ui-hide")) {
                            $controlRow.show(effect, () => {
                                starrez.popup.AutoHeightPopup(this.$container);
                            });
                        }
                    });
                }
                ToggleControlOverride(beQuick, populateTables) {
                    var isOverride = starrez.library.convert.ToBoolean(this.$isControlTypeOverrideControl.SRVal());
                    if (isOverride) {
                        this.ToggleControl(beQuick, true, EditFieldEditor.ControlTypeOverride);
                        this.ToggleDropdownControls(beQuick, populateTables);
                    }
                    else {
                        this.ToggleControl(beQuick, false, EditFieldEditor.ControlTypeOverride);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupType);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupID);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupCriteria);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupSortColumn);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupSortOrder);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupTableName);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupTableTextColumnName);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupTableValueColumnName);
                    }
                    this.UpdateDefaultValueControl();
                }
                ToggleDropdownControls(beQuick, populateTables) {
                    var overrideType = this.$container.GetControl(EditFieldEditor.ControlTypeOverride).SRVal();
                    if (overrideType == ControlType.Dropdown || overrideType == ControlType.RadioButtons) {
                        this.ToggleControl(beQuick, true, EditFieldEditor.LookupType);
                        this.ToggleLookupControls(beQuick, populateTables);
                    }
                    else {
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupType);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupID);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupCriteria);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupSortColumn);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupSortOrder);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupTableName);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupTableTextColumnName);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupTableValueColumnName);
                    }
                    this.UpdateDefaultValueControl();
                }
                UpdateDefaultValueControl() {
                    //make sure we send request only when the control type is overridden and edit field's state has changed
                    if (starrez.library.convert.ToBoolean(this.Get(EditFieldEditor.IsControlTypeOverride))) {
                        var editField = this.GetEditableField();
                        var editFieldCurrentState = JSON.stringify(editField);
                        var isEditFieldStateChanged = starrez.library.stringhelper.IsUndefinedOrEmpty(this.editFieldState) || !starrez.library.stringhelper.Equals(this.editFieldState, editFieldCurrentState, false);
                        if (isEditFieldStateChanged) {
                            this.editFieldState = editFieldCurrentState;
                            new starrez.service.formwidget.UpdateDefaultValueControl({
                                portalPageWidgetID: this.portalPageWidgetID,
                                unsavedEditField: editField
                            }).Post().done(html => {
                                this.$defaultValueControl.html(html);
                            });
                        }
                    }
                }
                ToggleLookupControls(beQuick, populateTables) {
                    var lookupType = this.$container.GetControl(EditFieldEditor.LookupType).SRVal();
                    if (lookupType == LookupType.Lookup) {
                        this.ToggleControl(beQuick, true, EditFieldEditor.LookupID);
                        this.ToggleControl(beQuick, true, EditFieldEditor.LookupCriteria);
                        this.ToggleControl(beQuick, true, EditFieldEditor.LookupSortColumn);
                        this.ToggleControl(beQuick, true, EditFieldEditor.LookupSortOrder);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupTableName);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupTableTextColumnName);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupTableValueColumnName);
                        this.UpdateDefaultValueControl();
                    }
                    else {
                        if (populateTables) {
                            //We can't have simultaneous AJAX calls at the same time,
                            //otherwise the loading animation on the dropdown will get confused on when to stop.
                            //Hence, in this case, UpdateDefaultValueControl is called when all the requests have finished
                            this.GetLookupTables();
                        }
                        else {
                            this.UpdateDefaultValueControl();
                        }
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupID);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupCriteria);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupSortColumn);
                        this.ToggleControl(beQuick, false, EditFieldEditor.LookupSortOrder);
                        this.ToggleControl(beQuick, true, EditFieldEditor.LookupTableName);
                        this.ToggleControl(beQuick, true, EditFieldEditor.LookupTableTextColumnName);
                        this.ToggleControl(beQuick, true, EditFieldEditor.LookupTableValueColumnName);
                    }
                }
                TogglePatternValidationControls(beQuick) {
                    var usePattern = this.$container.GetControl(EditFieldEditor.UsePatternValidation).SRVal();
                    if (usePattern) {
                        this.ToggleControl(beQuick, true, EditFieldEditor.PatternPropertyName);
                        this.ToggleControl(beQuick, true, EditFieldEditor.PatternErrorMessage);
                    }
                    else {
                        this.ToggleControl(beQuick, false, EditFieldEditor.PatternPropertyName);
                        this.ToggleControl(beQuick, false, EditFieldEditor.PatternErrorMessage);
                    }
                }
                ToggleControl(beQuick, show, controlName) {
                    var effect = beQuick ? undefined : "slideup";
                    const $control = this.$container.GetControl(controlName);
                    if ($control) {
                        var $controlRow = $control.closest("li");
                        if (show) {
                            $controlRow.show(effect);
                            $controlRow.removeClass("ui-hide");
                        }
                        else {
                            $controlRow.hide(effect);
                            $controlRow.addClass("ui-hide");
                        }
                    }
                }
                InitLookupEditor(popup) {
                    var $editorContainer = popup.$article.find(".ui-lookup-container");
                    var lookupEditor = $editorContainer.data(editorDataName);
                    lookupEditor.editFieldEditor = this;
                }
            }
            EditFieldEditor.MaxLengthPropertyName = "MaxLength";
            EditFieldEditor.LabelPropertyName = "Label";
            EditFieldEditor.IsRequiredPropertyName = "IsRequired";
            EditFieldEditor.PatternPropertyName = "PatternString";
            EditFieldEditor.ErrorTextPropertyName = "ErrorText";
            EditFieldEditor.DefaultValuePropertyName = "DefaultValue";
            EditFieldEditor.IDPropertyName = "ID";
            EditFieldEditor.IsReadOnlyPropertyName = "IsReadOnly";
            EditFieldEditor.UsePatternValidation = "UsePatternValidation";
            EditFieldEditor.PatternErrorMessage = "PatternErrorMessage";
            EditFieldEditor.MaxLengthErrorMessage = "MaxLengthErrorMessage";
            EditFieldEditor.MinValueErrorMessage = "MinValueErrorMessage";
            EditFieldEditor.MaxValueErrorMessage = "MaxValueErrorMessage";
            EditFieldEditor.RequiredErrorMessage = "RequiredErrorMessage";
            EditFieldEditor.LookupType = "LookupType";
            EditFieldEditor.LookupID = "LookupID";
            EditFieldEditor.LookupCriteria = "LookupCriteria";
            EditFieldEditor.LookupSortColumn = "LookupSortColumn";
            EditFieldEditor.LookupSortOrder = "LookupSortOrder";
            EditFieldEditor.ControlTypeOverride = "ControlTypeOverride";
            EditFieldEditor.IsControlTypeOverride = "IsControlTypeOverride";
            EditFieldEditor.LookupTableName = "LookupTableName";
            EditFieldEditor.LookupTableValueColumnName = "LookupTableValueColumnName";
            EditFieldEditor.LookupTableTextColumnName = "LookupTableTextColumnName";
            EditFieldEditor.IsUniqueIDPropertyName = "IsUniqueID";
            EditFieldEditor.ValidationCriteria = "ValidationCriteria";
            EditFieldEditor.ValidationCriteriaErrorMessage = "ValidationCriteriaErrorMessage";
            EditFieldEditor.PlaceHolder = "Placeholder";
            EditFieldEditor.AutoComplete = "AutoComplete";
            class LookupEditor {
                constructor($container) {
                    this.$container = $container;
                    this.InitControls();
                }
                InitControls() {
                    this.$srEditor = this.$container.find(".ui-sr-editor");
                    var $saveButton = starrez.popup.GetPopupContainerAreas(this.$container).$footer.find(".ui-btn-save");
                    $saveButton.click(() => {
                        this.Save().done((result) => {
                            this.editFieldEditor.RefreshLookups(result, this.$container.GetControl(LookupEditor.LookupDescription).SRVal());
                            starrez.popup.Close(this.$container);
                        }).fail(() => {
                        });
                    });
                    var $addValueButton = this.$container.find(".ui-btn-add-value");
                    $addValueButton.click(e => {
                        var clone = this.$srEditor.clone(false, false);
                        clone.removeClass("hidden");
                        var $valuesContainer = this.$container.find(".ui-field-properties");
                        $valuesContainer.append(clone);
                    });
                }
                Save() {
                    var deferred = $.Deferred();
                    var description = this.$container.GetControl(LookupEditor.LookupDescription).SRVal();
                    if (starrez.library.stringhelper.IsUndefinedOrEmpty(description)) {
                        starrez.ui.ShowAlertMessage("You must enter a Lookup Description");
                        deferred.reject(-1);
                        return deferred.promise();
                    }
                    var values = new Array();
                    var $allControls = this.$container.GetAllControls();
                    var text = undefined;
                    for (var i = 1; i < $allControls.length - 2; i++) {
                        var $textControl = $($allControls[i]);
                        var $valueControl = $($allControls[++i]);
                        if ($textControl.hasClass("text") && !$textControl.hasClass("hidden") && $valueControl.hasClass("text") && !$valueControl.hasClass("hidden")) {
                            var text = $textControl.SRVal();
                            var value = $valueControl.SRVal();
                            if (!starrez.library.stringhelper.IsUndefinedOrEmpty(text)) {
                                if (values.indexOf(text) === -1) {
                                    values.push(text);
                                    values.push(value);
                                }
                                else {
                                    starrez.ui.ShowAlertMessage("Every item in the list must have a unique display text.");
                                    deferred.reject(-1);
                                    return deferred.promise();
                                }
                            }
                            else {
                                starrez.ui.ShowAlertMessage("Every item must have a Display Text");
                                deferred.reject(-1);
                                return deferred.promise();
                            }
                        }
                    }
                    if (values.length == 0) {
                        starrez.ui.ShowAlertMessage("You must enter at least one value");
                        deferred.reject(-1);
                        return deferred.promise();
                    }
                    var call = new starrez.service.formwidget.SaveLookup({
                        description: description,
                        lookupTextValues: values,
                        errorHandler: starrez.error.CreateErrorObject()
                    });
                    call.Post().done((result) => {
                        deferred.resolve(result);
                    });
                    return deferred.promise();
                }
            }
            LookupEditor.LookupDescription = "LookupDescription";
        })(datainput = general.datainput || (general.datainput = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.datainput.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function FieldModel($sys) {
            return {
                TableName: $sys.data('tablename'),
            };
        }
        model.FieldModel = FieldModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var formwidget;
        (function (formwidget) {
            "use strict";
            class AddFields extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "AddFields";
                }
                CallData() {
                    var obj = {
                        errorHandler: this.o.errorHandler,
                        fields: this.o.fields,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            formwidget.AddFields = AddFields;
            class AddLookup extends starrez.library.service.AddInActionCallBase {
                constructor() {
                    super();
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "AddLookup";
                }
            }
            formwidget.AddLookup = AddLookup;
            class CreateNewField extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "CreateNewField";
                }
                CallData() {
                    var obj = {
                        portalPageWidgetID: this.o.portalPageWidgetID,
                        tableName: this.o.tableName,
                    };
                    return obj;
                }
            }
            formwidget.CreateNewField = CreateNewField;
            class EditField extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "EditField";
                }
                CallData() {
                    var obj = {
                        fieldID: this.o.fieldID,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            formwidget.EditField = EditField;
            class FieldAutoComplete extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "FieldAutoComplete";
                }
                CallData() {
                    var obj = {
                        fieldType: this.o.fieldType,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                        text: this.o.text,
                    };
                    return obj;
                }
            }
            formwidget.FieldAutoComplete = FieldAutoComplete;
            class GetLookupTables extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "GetLookupTables";
                }
                CallData() {
                    var obj = {
                        lookupType: this.o.lookupType,
                    };
                    return obj;
                }
            }
            formwidget.GetLookupTables = GetLookupTables;
            class GetRefreshedFieldList extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "GetRefreshedFieldList";
                }
                CallData() {
                    var obj = {
                        portalPageWidgetID: this.o.portalPageWidgetID,
                        repeatFlag: this.o.repeatFlag,
                        url: this.o.url,
                    };
                    return obj;
                }
            }
            formwidget.GetRefreshedFieldList = GetRefreshedFieldList;
            class GetTableColumns extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "GetTableColumns";
                }
                CallData() {
                    var obj = {
                        lookupType: this.o.lookupType,
                        tableName: this.o.tableName,
                    };
                    return obj;
                }
            }
            formwidget.GetTableColumns = GetTableColumns;
            class RemoveField extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "RemoveField";
                }
                CallData() {
                    var obj = {
                        errorHandler: this.o.errorHandler,
                        fieldID: this.o.fieldID,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            formwidget.RemoveField = RemoveField;
            class ReorderFields extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "ReorderFields";
                }
                CallData() {
                    var obj = {
                        errorHandler: this.o.errorHandler,
                        idOrderMapping: this.o.idOrderMapping,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            formwidget.ReorderFields = ReorderFields;
            class SaveField extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "SaveField";
                }
                CallData() {
                    var obj = {
                        errorHandler: this.o.errorHandler,
                        field: this.o.field,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            formwidget.SaveField = SaveField;
            class SaveLookup extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "SaveLookup";
                }
                CallData() {
                    var obj = {
                        description: this.o.description,
                        errorHandler: this.o.errorHandler,
                        lookupTextValues: this.o.lookupTextValues,
                    };
                    return obj;
                }
            }
            formwidget.SaveLookup = SaveLookup;
            class UpdateDefaultValueControl extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "formwidget";
                    this.Action = "UpdateDefaultValueControl";
                }
                CallData() {
                    var obj = {
                        portalPageWidgetID: this.o.portalPageWidgetID,
                        unsavedEditField: this.o.unsavedEditField,
                    };
                    return obj;
                }
            }
            formwidget.UpdateDefaultValueControl = UpdateDefaultValueControl;
        })(formwidget = service.formwidget || (service.formwidget = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var repeatingformwidget;
        (function (repeatingformwidget) {
            "use strict";
            class AddNewRecord extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DataInput";
                    this.Controller = "repeatingformwidget";
                    this.Action = "AddNewRecord";
                }
                CallData() {
                    var obj = {
                        index: this.o.index,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            repeatingformwidget.AddNewRecord = AddNewRecord;
        })(repeatingformwidget = service.repeatingformwidget || (service.repeatingformwidget = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var general;
    (function (general) {
        var daterangepicker;
        (function (daterangepicker) {
            "use strict";
            function InitSettingsEditor($container) {
                var $selectedTable = $container.GetControl("SelectedTable");
                var $dateStartField = $container.GetControl("DateStartField");
                var $dateEndField = $container.GetControl("DateEndField");
                $selectedTable.change(() => {
                    var selectedValue = $selectedTable.SRVal();
                    var call = new starrez.service.daterangepicker.GetTableDateColumns({ tableOption: selectedValue });
                    call.Post().done(data => {
                        starrez.library.controls.dropdown.Clear($dateStartField);
                        starrez.library.controls.dropdown.FillDropDown(data, $dateStartField, "Value", "Key", "-1", false);
                        starrez.library.controls.dropdown.Clear($dateEndField);
                        starrez.library.controls.dropdown.FillDropDown(data, $dateEndField, "Value", "Key", "-1", false);
                    });
                });
            }
            daterangepicker.InitSettingsEditor = InitSettingsEditor;
        })(daterangepicker = general.daterangepicker || (general.daterangepicker = {}));
    })(general = starrez.general || (starrez.general = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.general.daterangepickerwidget.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var daterangepicker;
        (function (daterangepicker) {
            "use strict";
            class GetTableDateColumns extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DateRangePicker";
                    this.Controller = "daterangepicker";
                    this.Action = "GetTableDateColumns";
                }
                CallData() {
                    var obj = {
                        tableOption: this.o.tableOption,
                    };
                    return obj;
                }
            }
            daterangepicker.GetTableDateColumns = GetTableDateColumns;
        })(daterangepicker = service.daterangepicker || (service.daterangepicker = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var docraptor;
        (function (docraptor) {
            "use strict";
            function Initialise($container) {
                new DocRaptor($container);
            }
            docraptor.Initialise = Initialise;
            class DocRaptor {
                constructor($container) {
                    this.$container = $container;
                    this.model = starrez.model.DocRaptorModel($container);
                    this.widgetID = Number(this.$container.data("portalpagewidgetid"));
                    if (this.model.SendEmail) {
                        portal.page.RegisterWidgetSaveData(this.widgetID, () => this.GetData());
                    }
                    $container.find(".ui-docraptor").SRClick(() => {
                        this.SendRequest();
                    });
                }
                SendRequest() {
                    new starrez.service.docraptor.GeneratePdf({
                        portalPageWidgetID: this.widgetID,
                        content: this.BuildHtmlToPdf()
                    }).Post().done((url) => {
                        if (starrez.library.utils.IsNotNullUndefined(url)) {
                            location.href = url;
                        }
                    });
                }
                /**
                 * Takes all the css,js and page content and wraps it up to be rendered
                 */
                BuildHtmlToPdf() {
                    let pdfContent = portal.PageElements.$pageContainer.closest(".portalx").clone();
                    if (portal.Feature.PortalxLandmarkRegionChanges) {
                        pdfContent.children(":not(#main-content)").remove();
                    }
                    else {
                        pdfContent.children(":not(.mm-page)").remove();
                    }
                    let $html = $("<html></html>");
                    let $head = $("<head></head>");
                    let $body = $("<body></body>").append(pdfContent);
                    $.each(document.styleSheets, (index, stylesheet) => {
                        if (starrez.library.utils.IsNotNullUndefined(stylesheet.href)) {
                            const $link = $("<link href='" + stylesheet.href + "' rel='Stylesheet' type='" + stylesheet.type + "' />");
                            $head.append($link);
                        }
                    });
                    $html.append($head).append($body);
                    this.RemoveElementsFromPDF(pdfContent, $html);
                    return $html.get(0).outerHTML;
                }
                /**
                 * On Save and Continue send the html for the pdf along with the page data
                 */
                GetData() {
                    return [{
                            Key: "HtmlContent",
                            Value: this.BuildHtmlToPdf()
                        }];
                }
                /**
                 * Removes content not relevant to PDF
                 * 1. Page Save buttons
                 * 2. DocRaptor save PDF button
                 * 3. Widgets that are only visible on page
                 * 4. Script tags as we are not running javascript
                 * 5. Favicon as it's one less thing to download before pdf-ing
                 */
                RemoveElementsFromPDF(pdfContent, html) {
                    pdfContent.find(".page-actions").remove();
                    pdfContent.find(".ui-docraptor").remove();
                    pdfContent.find(".visible-only-on-page").remove();
                    html.find("script").remove();
                    html.find("link[rel='shortcut icon']").remove();
                }
            }
        })(docraptor = general.docraptor || (general.docraptor = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.docraptorwidget.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function DocRaptorModel($sys) {
            return {
                SendEmail: starrez.library.convert.ToBoolean($sys.data('sendemail')),
                ShowButton: starrez.library.convert.ToBoolean($sys.data('showbutton')),
            };
        }
        model.DocRaptorModel = DocRaptorModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var docraptor;
        (function (docraptor) {
            "use strict";
            class GeneratePdf extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DocRaptor";
                    this.Controller = "docraptor";
                    this.Action = "GeneratePdf";
                }
                CallData() {
                    var obj = {
                        content: this.o.content,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            docraptor.GeneratePdf = GeneratePdf;
        })(docraptor = service.docraptor || (service.docraptor = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var general;
    (function (general) {
        var docusign;
        (function (docusign) {
            "use strict";
            const WIDGET_ID_SELECTOR_PREFIX = '#DocuSignSignature_';
            const DOCUSIGN_NOTIFICATION_SELECTOR = '.ui-docusign-document';
            const COMPLETED_NOTIFICATION_SELECTOR = '.ui-completed';
            const INCOMPLETE_NOTIFICATION_SELECTOR = '.ui-incomplete';
            const DECLINE_NOTIFICATION_SELECTOR = '.ui-declined';
            const ERROR_NOTIFICATION_SELECTOR = '.ui-error';
            const RECHECK_WAIT_TIME = 180000; /*3 minutes*/
            function UpdateStatus(portalPageWidgetID, event) {
                var $widgetContainer = GetWidgetContainer(portalPageWidgetID);
                var $document = $widgetContainer.find(DOCUSIGN_NOTIFICATION_SELECTOR);
                var $notification = null;
                portal.page.CurrentPage.RemoveErrorMessagsByWidgetReference(portalPageWidgetID);
                if (event == DocuSignRecipientEvent.Decline || event == DocuSignRecipientEvent.Cancel) {
                    $notification = $widgetContainer.find(DECLINE_NOTIFICATION_SELECTOR);
                }
                else if (event == DocuSignRecipientEvent.Exception || event == DocuSignRecipientEvent.TimeToLiveExpired) {
                    $notification = $widgetContainer.find(ERROR_NOTIFICATION_SELECTOR);
                }
                else if (event == DocuSignRecipientEvent.SessionTimeout) {
                    ShowSessionExpiredMessage(portalPageWidgetID);
                }
                else if (event == DocuSignRecipientEvent.SigningComplete || event == DocuSignRecipientEvent.ViewingComplete) {
                    $notification = $widgetContainer.find(COMPLETED_NOTIFICATION_SELECTOR);
                }
                if (!starrez.library.utils.IsNullOrUndefined($notification)) {
                    $.ScrollToWithAnimation($widgetContainer);
                    $document.slideUp(() => {
                        $notification.fadeIn();
                        $notification.removeAttr('hidden');
                    });
                }
            }
            docusign.UpdateStatus = UpdateStatus;
            function NotifyWidget(portalPageWidgetID, termId, action, returnUrlKey) {
                var $widgetContainer = GetWidgetContainer(portalPageWidgetID);
                var $document = $widgetContainer.find(DOCUSIGN_NOTIFICATION_SELECTOR);
                var $notification;
                var signed = false;
                var reCheck = false;
                if (action === NotificationAction.Completed && !starrez.library.stringhelper.IsUndefinedOrEmpty(returnUrlKey)) {
                    var $key = $widgetContainer.GetControl('ReturnUrlKey');
                    $key.SRVal(returnUrlKey);
                    $notification = $widgetContainer.find(COMPLETED_NOTIFICATION_SELECTOR);
                    signed = true;
                }
                else if (action === NotificationAction.Actioned) {
                    $notification = $widgetContainer.find(INCOMPLETE_NOTIFICATION_SELECTOR);
                    signed = true;
                    reCheck = true;
                }
                else if (action === NotificationAction.Declined) {
                    $notification = $widgetContainer.find(DECLINE_NOTIFICATION_SELECTOR);
                }
                else if (action === NotificationAction.SessionTimeout) {
                    ShowSessionExpiredMessage(portalPageWidgetID);
                }
                else {
                    $notification = $widgetContainer.find(ERROR_NOTIFICATION_SELECTOR);
                }
                $.ScrollToWithAnimation($widgetContainer);
                $document.slideUp(() => {
                    $notification.fadeIn();
                    if (signed) {
                        var model = starrez.model.DocuSignWidgetModel($widgetContainer.closest('.ui-docusign'));
                        if (model.SavePageOnDocumentSigned) {
                            portal.page.CurrentPage.SubmitPage();
                            return;
                        }
                        portal.page.CurrentPage.RemoveErrorMessagsByWidgetReference(portalPageWidgetID);
                    }
                });
                if (reCheck) {
                    SetReCheck(portalPageWidgetID, termId);
                }
            }
            docusign.NotifyWidget = NotifyWidget;
            function ShowSessionExpiredMessage(portalPageWidgetID) {
                const $widgetContainer = GetWidgetContainer(portalPageWidgetID);
                const model = starrez.model.DocuSignWidgetModel($widgetContainer.closest('.ui-docusign'));
                portal.ShowMessage(model.SessionExpiredMessage, model.SessionExpiredMessageTitle).done(() => {
                    // windows.location.reload() causes it to not refresh correctly in FireFox after the timeout, so I need to set it like this instead as a work around
                    window.location.href = window.location.href;
                });
            }
            function GetWidgetContainer(portalPageWidgetID) {
                return $(WIDGET_ID_SELECTOR_PREFIX + portalPageWidgetID);
            }
            function ReCheckStatus(portalPageWidgetID, termId) {
                new starrez.service.notification.CheckDocumentStatus({
                    portalPageWidgetID: portalPageWidgetID,
                    termId: termId
                }).Request({
                    ShowLoading: false
                }).done((data) => {
                    var selector = null;
                    if (data === NotificationAction.Completed) {
                        selector = COMPLETED_NOTIFICATION_SELECTOR;
                    }
                    else if (data === NotificationAction.Declined) {
                        selector = DECLINE_NOTIFICATION_SELECTOR;
                    }
                    else if (data === NotificationAction.SessionTimeout) {
                        console.log('Session Timeout');
                        selector = ERROR_NOTIFICATION_SELECTOR;
                    }
                    else if (data === NotificationAction.Error) {
                        selector = ERROR_NOTIFICATION_SELECTOR;
                    }
                    if (selector !== null) {
                        portal.page.CurrentPage.RemoveErrorMessagsByWidgetReference(portalPageWidgetID);
                        var $widgetContainer = GetWidgetContainer(portalPageWidgetID);
                        $widgetContainer.find(INCOMPLETE_NOTIFICATION_SELECTOR).hide();
                        $widgetContainer.find(selector).fadeIn();
                    }
                    else {
                        SetReCheck(portalPageWidgetID, termId);
                    }
                });
            }
            function SetReCheck(portalPageWidgetID, termId) {
                setTimeout(() => ReCheckStatus(portalPageWidgetID, termId), RECHECK_WAIT_TIME);
            }
            let DocuSignRecipientEvent;
            (function (DocuSignRecipientEvent) {
                DocuSignRecipientEvent[DocuSignRecipientEvent["Cancel"] = 0] = "Cancel";
                DocuSignRecipientEvent[DocuSignRecipientEvent["Decline"] = 1] = "Decline";
                DocuSignRecipientEvent[DocuSignRecipientEvent["Exception"] = 2] = "Exception";
                DocuSignRecipientEvent[DocuSignRecipientEvent["SessionTimeout"] = 3] = "SessionTimeout";
                DocuSignRecipientEvent[DocuSignRecipientEvent["SigningComplete"] = 4] = "SigningComplete";
                DocuSignRecipientEvent[DocuSignRecipientEvent["TimeToLiveExpired"] = 5] = "TimeToLiveExpired";
                DocuSignRecipientEvent[DocuSignRecipientEvent["ViewingComplete"] = 6] = "ViewingComplete";
            })(DocuSignRecipientEvent || (DocuSignRecipientEvent = {}));
            let NotificationAction;
            (function (NotificationAction) {
                NotificationAction[NotificationAction["InvalidKey"] = 0] = "InvalidKey";
                NotificationAction[NotificationAction["Actioned"] = 1] = "Actioned";
                NotificationAction[NotificationAction["Declined"] = 2] = "Declined";
                NotificationAction[NotificationAction["Error"] = 3] = "Error";
                NotificationAction[NotificationAction["Completed"] = 4] = "Completed";
                NotificationAction[NotificationAction["SessionTimeout"] = 5] = "SessionTimeout";
            })(NotificationAction || (NotificationAction = {}));
        })(docusign = general.docusign || (general.docusign = {}));
    })(general = starrez.general || (starrez.general = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.general.docusign.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function DocuSignWidgetModel($sys) {
            return {
                DocusignCustomFieldValues: $sys.data('docusigncustomfieldvalues'),
                SavePageOnDocumentSigned: starrez.library.convert.ToBoolean($sys.data('savepageondocumentsigned')),
                SessionExpiredMessage: starrez.library.convert.ToString($sys.data('sessionexpiredmessage')),
                SessionExpiredMessageTitle: starrez.library.convert.ToString($sys.data('sessionexpiredmessagetitle')),
            };
        }
        model.DocuSignWidgetModel = DocuSignWidgetModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var notification;
        (function (notification) {
            "use strict";
            class CheckDocumentStatus extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "DocuSign";
                    this.Controller = "notification";
                    this.Action = "CheckDocumentStatus";
                }
                CallData() {
                    var obj = {
                        portalPageWidgetID: this.o.portalPageWidgetID,
                        termId: this.o.termId,
                    };
                    return obj;
                }
            }
            notification.CheckDocumentStatus = CheckDocumentStatus;
        })(notification = service.notification || (service.notification = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var dutyroundsdetail;
        (function (dutyroundsdetail) {
            function InitDutyRoundsDetailPage($container) {
                new DutyRoundsDetailModel($container);
            }
            dutyroundsdetail.InitDutyRoundsDetailPage = InitDutyRoundsDetailPage;
            class DutyRoundsDetailModel {
                constructor($container) {
                    this.$container = $container;
                    this.SetupBackToMyDutyRoundsButton();
                }
                SetupBackToMyDutyRoundsButton() {
                    this.$container.on("click", ".ui-back-to-mydutyrounds", (e) => {
                        const $currentTarget = $(e.currentTarget);
                        const $container = this.$container.find(".ui-log-details-container");
                        const call = new starrez.library.service.ActionCallBase();
                        call.Area = "General/DutyRounds";
                        call.Controller = "DutyRounds";
                        call.Action = "GetMyDutyRoundsPageUrl";
                        call.QueryData = () => {
                            return {
                                portalpageID: portal.page.CurrentPage.PageID,
                                currentPageNumber: Number($container.data("current-page-number")),
                                hash: $currentTarget.data('hash')
                            };
                        };
                        call.Get().done((url) => {
                            window.location.href = url;
                        });
                    });
                }
            }
        })(dutyroundsdetail = general.dutyroundsdetail || (general.dutyroundsdetail = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));

"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var dutyrounds;
        (function (dutyrounds) {
            function InitDutyRoundsPage($container) {
                new DutyRoundsModel($container);
            }
            dutyrounds.InitDutyRoundsPage = InitDutyRoundsPage;
            class DutyRoundsModel {
                constructor($container) {
                    this.$container = $container;
                    this.SetupSelectFormAction();
                }
                SetupSelectFormAction() {
                    this.$container.on("click", ".ui-select-action", (e) => {
                        const $currentTarget = $(e.currentTarget);
                        const $actionPanel = $currentTarget.closest(".ui-action-panel");
                        const hash = $actionPanel.data("hash");
                        const dutyRoundsTypeID = $actionPanel.data("dutyroundstypeid");
                        const existingDutyRoundsID = $actionPanel.data("existingdutyroundsid");
                        const call = new starrez.library.service.ActionCallBase();
                        call.Area = "General/DutyRounds";
                        call.Controller = "DutyRounds";
                        call.Action = "GetSelectForm";
                        call.QueryData = () => {
                            return {
                                dutyRoundsTypeID: dutyRoundsTypeID,
                                existingDutyRoundsID: existingDutyRoundsID,
                                portalpageID: portal.page.CurrentPage.PageID,
                                hash: hash
                            };
                        };
                        call.Get().done((url) => {
                            window.location.href = url;
                        });
                    });
                }
            }
        })(dutyrounds = general.dutyrounds || (general.dutyrounds = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));

"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var dutyroundsforms;
        (function (dutyroundsforms) {
            function InitDutyLogLogsPage($container) {
                new DutyRoundsFormsModel($container);
            }
            dutyroundsforms.InitDutyLogLogsPage = InitDutyLogLogsPage;
            class FollowUpOption {
            }
            class RoundOption {
            }
            class ChecklistOption {
            }
            class ChecklistAdditionalDetails {
            }
            class DutyRoundsFormsModel {
                constructor($container) {
                    this.hasChanges = false;
                    this.$container = $container;
                    this.$dutyRoundsFormsContainer = this.$container.find('.ui-dutyrounds-forms');
                    this.SetupSaveAndSubmitAction();
                    this.SetupAndCloseAction();
                    this.SetupCancelAction();
                    this.TrackControlChanges();
                }
                SetupSaveAndSubmitAction() {
                    this.$container.on("click", ".ui-save-and-submit", (e) => {
                        portal.ConfirmAction(this.$dutyRoundsFormsContainer.data('confirmsubmissiontext'), this.$dutyRoundsFormsContainer.data('confirmsubmissiontitle'), this.$dutyRoundsFormsContainer.data('confirmsumbissionsubmitbuttontext'), this.$dutyRoundsFormsContainer.data('dontsubmitpagebuttontext')).done(() => {
                            this.SubmitDutyRound(false);
                        });
                    });
                }
                SetupAndCloseAction() {
                    this.$container.on("click", ".ui-save-and-close", (e) => {
                        this.SubmitDutyRound(true);
                    });
                }
                SetupCancelAction() {
                    this.$container.on("click", ".ui-cancel", (e) => {
                        if (this.hasChanges) {
                            portal.ConfirmAction(this.$dutyRoundsFormsContainer.data('unsavedchangestext'), this.$dutyRoundsFormsContainer.data('unsavedchangestitle'), this.$dutyRoundsFormsContainer.data('dontcancelbuttontext'), this.$dutyRoundsFormsContainer.data('confirmdiscardchangesbuttontext')).fail(() => {
                                this.CancelDutyRoundSubmission();
                            });
                        }
                        else {
                            this.CancelDutyRoundSubmission();
                        }
                    });
                }
                CancelDutyRoundSubmission() {
                    const call = new starrez.library.service.ActionCallBase();
                    call.Area = "General/DutyRounds";
                    call.Controller = "DutyRounds";
                    call.Action = "GetParentPageUrl";
                    call.QueryData = () => {
                        return {
                            portalpageID: portal.page.CurrentPage.PageID,
                            hash: this.$dutyRoundsFormsContainer.data('getparentpageurlhash')
                        };
                    };
                    call.Get().done((url) => {
                        window.location.href = url;
                    });
                }
                TrackControlChanges() {
                    this.$container.find('input, select, textarea').on('change', () => {
                        this.hasChanges = true;
                    });
                }
                SubmitDutyRound(isDraft) {
                    const call = new starrez.library.service.ActionCallBase();
                    call.Area = "General/DutyRounds";
                    call.Controller = "DutyRounds";
                    call.Action = "SubmitDutyRounds";
                    // These need to be sent as post data for them to be passed to the SubmitDutyRounds method correctly
                    call.CallData = () => {
                        return {
                            dateCreated: this.$container.GetControl("LogDate").SRVal(),
                            roomLocationID: this.$container.GetControl("RoomLocationID").SRVal(),
                            followUpTypes: this.GetFollowUpOptions(),
                            isDraft: isDraft,
                            roundDescriptions: this.GetRounds(),
                            checklistOptions: this.GetChecklistOption(),
                            dutyRoundsAdditionalDetails: this.GetDutyRoundsAdditionalDetails(),
                            checklistAdditionalDetails: this.GetChecklistAdditionalDetails()
                        };
                    };
                    // For the hash to work these need to be sent as query data
                    call.QueryData = () => {
                        return {
                            portalPageID: portal.page.CurrentPage.PageID,
                            dutyRoundsTypeID: Number(this.$dutyRoundsFormsContainer.data('dutyroundstypeid')),
                            existingDutyRoundsID: Number(this.$dutyRoundsFormsContainer.data('existingdutyroundslogid')),
                            showDutyRoundsAdditionalDetails: this.$dutyRoundsFormsContainer.data('showdutyroundsadditionaldetails'),
                            hash: this.$dutyRoundsFormsContainer.data('saveandsubmiturlhash')
                        };
                    };
                    call.Post().done((url) => {
                        window.location.href = url;
                    });
                }
                GetRounds() {
                    const roundDescriptions = [];
                    const numberOfRounds = this.$dutyRoundsFormsContainer.data('numberofrounds');
                    for (let n = 0; n < numberOfRounds; n++) {
                        let roundControlName = 'Round_' + (n + 1);
                        let roundTextArea = this.$container.GetControl(roundControlName);
                        let round = new RoundOption();
                        round.roundDescription = roundTextArea.SRVal();
                        round.roundNumber = n + 1;
                        roundDescriptions.push(round);
                    }
                    return roundDescriptions;
                }
                GetFollowUpOptions() {
                    let followupOptions = [];
                    const $followUpContainer = this.$container.find('.ui-followup-options-container');
                    $followUpContainer.find('input[type=\'checkbox\']').each((index, element) => {
                        let $followUpCheckbox = element;
                        let followUpTypeID = Number($followUpCheckbox.name.replace('FollowUpType_', ''));
                        followupOptions.push({
                            followUpTypeID: followUpTypeID,
                            enabled: $followUpCheckbox.checked
                        });
                    });
                    return followupOptions;
                }
                GetChecklistOption() {
                    let checkBoxes = [];
                    const $checklistOptionsContainer = this.$container.find('.ui-checklistoptions-container');
                    $checklistOptionsContainer.find('input[type=\'checkbox\']').each((index, element) => {
                        let $followUpCheckbox = element;
                        let dutyRoundsChecklistOptionID = Number($followUpCheckbox.name.replace('DutyRoundsCompletedChecklistOptionID_', ''));
                        let dutyRoundsCompletedChecklistID = $(element.closest('.ui-checkbox-option')).data('dutyroundscompleted-checklist-id');
                        checkBoxes.push({
                            dutyRoundsCompletedChecklistOptionID: dutyRoundsChecklistOptionID,
                            dutyRoundsCompletedChecklistID: dutyRoundsCompletedChecklistID,
                            enabled: $followUpCheckbox.checked
                        });
                    });
                    return checkBoxes;
                }
                GetDutyRoundsAdditionalDetails() {
                    const showDutyRoundsAdditionalDetails = Boolean(this.$dutyRoundsFormsContainer.data('showdutyroundsadditionaldetails'));
                    if (!showDutyRoundsAdditionalDetails) {
                        // Additional details are not enabled so just return empty
                        return "";
                    }
                    ;
                    const $additionDetailsTextArea = this.$container.GetControl("DutyRoundsAdditionalDetails");
                    return $additionDetailsTextArea.SRVal();
                }
                GetChecklistAdditionalDetails() {
                    let checklistAdditionalDetails = [];
                    this.$container.find('.ui-checklist-additionaldetailscontainer').each((index, element) => {
                        const $checklistAdditionalDetails = $(element).find('textarea');
                        let dutyRoundscompletedChecklistID = Number($checklistAdditionalDetails[0].name.replace('ChecklistAdditionalDetails_', ''));
                        checklistAdditionalDetails.push({
                            dutyRoundsCompletedChecklistID: dutyRoundscompletedChecklistID,
                            additionalDetails: $checklistAdditionalDetails.SRVal()
                        });
                    });
                    return checklistAdditionalDetails;
                }
            }
        })(dutyroundsforms = general.dutyroundsforms || (general.dutyroundsforms = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));

"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var mydutyrounds;
        (function (mydutyrounds) {
            function InitMyDutyRoundsPage($container) {
                new MyDutyRoundsModel($container);
            }
            mydutyrounds.InitMyDutyRoundsPage = InitMyDutyRoundsPage;
            class MyDutyRoundsModel {
                constructor($container) {
                    this.$container = $container;
                    this.currentPageNumber = Number(this.$container.find(".ui-mydutyrounds-list").data("page-number"));
                    this.SetupReviewLogButtons();
                    this.SetupBackToDutyRoundsButton();
                    this.SetupPaging();
                }
                SetupReviewLogButtons() {
                    this.$container.on("click", ".ui-log-details", (e) => {
                        const $currentTarget = $(e.currentTarget);
                        const call = new starrez.library.service.ActionCallBase();
                        call.Area = "General/DutyRounds";
                        call.Controller = "DutyRounds";
                        call.Action = "GetDutyRoundDetailsPageUrl";
                        call.QueryData = () => {
                            return {
                                portalPageID: portal.page.CurrentPage.PageID,
                                dutyRoundsID: Number($currentTarget.data("dutyroundsid")),
                                currentPageNumber: this.currentPageNumber,
                                hash: $currentTarget.data("hash")
                            };
                        };
                        call.Get().done((url) => {
                            window.location.href = url;
                        });
                    });
                }
                SetupBackToDutyRoundsButton() {
                    this.$container.on("click", ".ui-back-to-duty-rounds", (e) => {
                        const call = new starrez.library.service.ActionCallBase();
                        call.Area = "General/DutyRounds";
                        call.Controller = "DutyRounds";
                        call.Action = "GetParentPageUrl";
                        call.QueryData = () => {
                            return {
                                portalpageID: portal.page.CurrentPage.PageID,
                                hash: $(e.currentTarget).data('hash')
                            };
                        };
                        call.Get().done((url) => {
                            window.location.href = url;
                        });
                    });
                }
                SetupPaging() {
                    const $pagingContainer = this.$container.find('.ui-paging-container');
                    portal.paging.AttachPagingClickEvent(this, $pagingContainer, this.LoadMyDutyRoundsList);
                }
                LoadMyDutyRoundsList(pageNumber) {
                    const $myDutyRoundsList = this.$container.find(".ui-mydutyrounds-list");
                    const urlHash = $myDutyRoundsList.data("getmydutyrounds-hash");
                    this.currentPageNumber = pageNumber;
                    const call = new starrez.library.service.ActionCallBase();
                    call.Area = "General/DutyRounds";
                    call.Controller = "DutyRounds";
                    call.Action = "GetMyDutyRoundsPage";
                    call.QueryData = () => {
                        return {
                            portalpageID: portal.page.CurrentPage.PageID,
                            pageNumber: pageNumber,
                            hash: urlHash
                        };
                    };
                    call.Get().done((result) => {
                        const logsContainer = this.$container.find('.ui-my-logs-container');
                        logsContainer.html(result);
                        // Need to set these up again since they get reloaded
                        this.SetupReviewLogButtons();
                        this.SetupPaging();
                    });
                }
            }
        })(mydutyrounds = general.mydutyrounds || (general.mydutyrounds = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));

"use strict";
var starrez;
(function (starrez) {
    var eazycollect;
    (function (eazycollect) {
        "use strict";
        function InitialiseRegistrationPage($container) {
            new RegistrationPage($container);
        }
        eazycollect.InitialiseRegistrationPage = InitialiseRegistrationPage;
        class RegistrationPage {
            constructor($container) {
                this.$container = $container;
                this.$createUpdateButton = $container.find(".ui-createupdate");
                this.$accountHolderName = $container.GetControl("AccountHolderName");
                this.$accountNumber = $container.GetControl("AccountNumber");
                this.$bankSortCode = $container.GetControl("BankSortCode");
                this.$ddConfirmation = $container.GetControl("DDConfirmation");
                this.AttachButtonEvents();
            }
            AttachButtonEvents() {
                this.$createUpdateButton.SRClick(() => {
                    this.CreateUpdateToken();
                });
            }
            CreateUpdateToken() {
                if (!this.DetailsAreValid())
                    return;
                new starrez.service.eazycollectregistration.RegisterCustomer({
                    pageID: portal.page.CurrentPage.PageID,
                    accountHolderName: this.$accountHolderName.SRVal(),
                    accountNumber: this.$accountNumber.SRVal(),
                    bankSortCode: this.$bankSortCode.SRVal()
                })
                    .Post()
                    .done((data, textStatus, jqXHR) => {
                    if (data.Fail) {
                        portal.page.CurrentPage.ClearMessages();
                        portal.page.CurrentPage.SetErrorMessage(data.Message);
                        return;
                    }
                    window.location.href = data.Value;
                })
                    .fail((jqXHR, textStatus, errorThrown) => {
                    portal.page.CurrentPage.SetErrorMessage("Could not register for EazyCollect");
                });
            }
            DetailsAreValid() {
                portal.page.CurrentPage.ClearMessages();
                var succes = true;
                var errorMessages = [];
                var accountHolderNamePattern = /^[0-9A-Za-z ]{1,18}$/;
                var enteredAccountHolderName = this.$accountHolderName.SRVal();
                if (!accountHolderNamePattern.test(enteredAccountHolderName)) {
                    errorMessages.push("Account Holder Name must consist of alphanumeric characters and spaces and can not exceed 18 characters.");
                    succes = false;
                }
                var accountNumberPattern = /^\d{8}$/;
                var enteredAccountNumber = this.$accountNumber.SRVal();
                if (!accountNumberPattern.test(enteredAccountNumber)) {
                    errorMessages.push("Account Number must be 8 digits.");
                    succes = false;
                }
                var bankSortCodePattern = /^\d{6}$/;
                var enteredBankSortCode = this.$bankSortCode.SRVal();
                if (!bankSortCodePattern.test(enteredBankSortCode)) {
                    errorMessages.push("Bank Sort Code must be 6 digits.");
                    succes = false;
                }
                var enteredDdConfirmation = this.$ddConfirmation.SRVal();
                if (!enteredDdConfirmation) {
                    errorMessages.push("You must confirm the agrement.");
                    succes = false;
                }
                if (!succes) {
                    portal.page.CurrentPage.SetErrorMessages(errorMessages);
                }
                return succes;
            }
        }
    })(eazycollect = starrez.eazycollect || (starrez.eazycollect = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.eazycollect.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN

    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function EazyCollectRegistrationModel($sys) {
            return {
                AccountHolderName: $sys.data('accountholdername'),
                AccountNumber: $sys.data('accountnumber'),
                BankSortCode: $sys.data('banksortcode'),
            };
        }
        model.EazyCollectRegistrationModel = EazyCollectRegistrationModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var eazycollectregistration;
        (function (eazycollectregistration) {
            "use strict";
            class RegisterCustomer extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "EazyCollectRegistration";
                    this.Controller = "eazycollectregistration";
                    this.Action = "RegisterCustomer";
                }
                CallData() {
                    var obj = {
                        accountHolderName: this.o.accountHolderName,
                        accountNumber: this.o.accountNumber,
                        bankSortCode: this.o.bankSortCode,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            eazycollectregistration.RegisterCustomer = RegisterCustomer;
        })(eazycollectregistration = service.eazycollectregistration || (service.eazycollectregistration = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var entryinvitation;
        (function (entryinvitation) {
            var confirmation;
            (function (confirmation) {
                "use strict";
                function InitialiseInvitationConfirmation($container) {
                    new InvitationConfirmation($container);
                }
                confirmation.InitialiseInvitationConfirmation = InitialiseInvitationConfirmation;
                class InvitationConfirmation {
                    constructor($container) {
                        this.$container = $container;
                        this.model = starrez.model.EntryInvitationConfirmationModel(this.$container);
                        this.SetupDeclineAction();
                    }
                    SetupDeclineAction() {
                        var $declineButton = portal.PageElements.$actions.find(".ui-decline-invitation");
                        $declineButton.SRClick(() => {
                            new starrez.service.entryinvitation.DeclineInvitation({
                                hash: $declineButton.data("hash"),
                                pageID: portal.page.CurrentPage.PageID,
                                entryInvitationID: this.model.EntryInvitationID
                            }).Post().done((url) => {
                                location.href = url;
                            });
                        });
                    }
                }
            })(confirmation = entryinvitation.confirmation || (entryinvitation.confirmation = {}));
        })(entryinvitation = general.entryinvitation || (general.entryinvitation = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.entryinvitation.confirmation.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function EntryInvitationConfirmationModel($sys) {
            return {
                EntryInvitationID: Number($sys.data('entryinvitationid')),
            };
        }
        model.EntryInvitationConfirmationModel = EntryInvitationConfirmationModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var entryinvitation;
        (function (entryinvitation) {
            "use strict";
            class DeclineInvitation extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "EntryInvitation";
                    this.Controller = "entryinvitation";
                    this.Action = "DeclineInvitation";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        entryInvitationID: this.o.entryInvitationID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            entryinvitation.DeclineInvitation = DeclineInvitation;
        })(entryinvitation = service.entryinvitation || (service.entryinvitation = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var entryphotouploadwidget;
    (function (entryphotouploadwidget) {
        "use strict";
        const update = "update";
        const del = "delete";
        function InitEntryPhotoUploadWidget($container) {
            new EntryPhotoUpload($container);
        }
        entryphotouploadwidget.InitEntryPhotoUploadWidget = InitEntryPhotoUploadWidget;
        class EntryPhotoUpload {
            constructor($container) {
                this.$container = $container;
                this.widgetID = Number($container.data('portalpagewidgetid'));
                this.$uploadContainer = portal.fileuploader.control.GetUploadContainer($container);
                this.model = starrez.model.EntryPhotoUploadModel($container);
                this.$uploadContainer.data("upload-instance").CustomValidation = (files) => this.ValidateFile(files);
                portal.page.RegisterWidgetSaveData(this.widgetID, () => this.GetSaveData());
            }
            GetSaveData() {
                var saveData = new starrez.library.collections.KeyValue();
                var saveStatus = portal.fileuploader.control.GetSaveStatus(this.$uploadContainer);
                if (saveStatus.Update) {
                    saveData.Add(update, saveStatus.Update);
                }
                if (saveStatus.Delete) {
                    saveData.Add(del, saveStatus.Delete);
                }
                const data = saveData.ToArray();
                if (data.length === 0) {
                    return null;
                }
                return data;
            }
            ValidateFile(files) {
                var deferred = $.Deferred();
                var isValid = true;
                // Should only ever be 1 file in the list as we don't use multi upload in this case
                if (files.length > 0) {
                    // Validate file extensions
                    const validExtensions = this.model.ValidFileExtensions.split(",").map(fe => fe.toLowerCase().trim());
                    if ($.inArray(files[0].name.split(".").pop().toLowerCase(), validExtensions) < 0) {
                        this.SetWarning(this.model.ValidFileExtensionsErrorMessage + validExtensions.join(", "));
                        isValid = false;
                    }
                    // Validate file size
                    if (files[0].size > this.model.MaxAttachmentBytes) {
                        this.SetWarning(this.model.MaxAttachmentBytesErrorMessage);
                        isValid = false;
                    }
                }
                deferred.resolve(isValid);
                return deferred.promise();
            }
            SetWarning(message) {
                var $notification = portal.fileuploader.control.GetNotification(this.$uploadContainer);
                portal.fileuploader.control.ClearNotification($notification);
                portal.fileuploader.control.SetNotification($notification, "uploader-alert-warning", message);
            }
        }
    })(entryphotouploadwidget = portal.entryphotouploadwidget || (portal.entryphotouploadwidget = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.entryphotouploadwidget.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function EntryPhotoUploadModel($sys) {
            return {
                MaxAttachmentBytes: Number($sys.data('maxattachmentbytes')),
                MaxAttachmentBytesErrorMessage: $sys.data('maxattachmentbyteserrormessage'),
                ValidFileExtensions: $sys.data('validfileextensions'),
                ValidFileExtensionsErrorMessage: $sys.data('validfileextensionserrormessage'),
            };
        }
        model.EntryPhotoUploadModel = EntryPhotoUploadModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var facebookfeed;
    (function (facebookfeed) {
        "use strict";
        function Initialise($container) {
            var facebookSDKInjector;
            if (facebookSDKInjector === undefined) {
                facebookSDKInjector = injectFacebookSDK;
                facebookSDKInjector(document, 'script', 'facebook-jssdk');
            }
        }
        facebookfeed.Initialise = Initialise;
        function injectFacebookSDK(document, tagName, id) {
            var js, fjs = document.getElementsByTagName(tagName)[0];
            if (document.getElementById(id))
                return;
            js = document.createElement(tagName);
            js.id = id;
            js.src = 'https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v3.0';
            fjs.parentNode.insertBefore(js, fjs);
        }
    })(facebookfeed = starrez.facebookfeed || (starrez.facebookfeed = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.facebookFeed.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var filedownloadwidget;
        (function (filedownloadwidget) {
            "use strict";
            function InitialiseFileDownloadSettings($container) {
                var model = starrez.model.WidgetModelBaseModel($container);
                portal.editor.widget.OnWidgetSettingsClose = () => {
                    new starrez.service.filedownload.Cancel({
                        portalPageWidgetID: model.PortalPageWidgetID
                    }).Post();
                };
                portal.editor.widget.OnWidgetSettingsSave = () => {
                    var def = $.Deferred();
                    // Pass in the DisplayOption as the Save function needs to know this to ensure that an invalid option is
                    // not able to be used with non PDF files	
                    new starrez.service.filedownload.Save({
                        portalPageWidgetID: model.PortalPageWidgetID, displayOption: $container.GetControl("DisplayOption").SRVal()
                    }).Post().done(() => {
                        def.resolve();
                    });
                    return def.promise();
                };
            }
            filedownloadwidget.InitialiseFileDownloadSettings = InitialiseFileDownloadSettings;
            function InitialiseFileDownload($container) {
                // This will setup the PDF Popup display
                $container.find(".ui-colorbox-iframe").colorbox({ iframe: true, innerWidth: '80%', innerHeight: '80%' });
            }
            filedownloadwidget.InitialiseFileDownload = InitialiseFileDownload;
        })(filedownloadwidget = general.filedownloadwidget || (general.filedownloadwidget = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.filedownloadwidget.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var filedownload;
        (function (filedownload) {
            "use strict";
            class Cancel extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "FileDownload";
                    this.Controller = "filedownload";
                    this.Action = "Cancel";
                }
                CallData() {
                    var obj = {
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            filedownload.Cancel = Cancel;
            class Save extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "FileDownload";
                    this.Controller = "filedownload";
                    this.Action = "Save";
                }
                CallData() {
                    var obj = {
                        displayOption: this.o.displayOption,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            filedownload.Save = Save;
        })(filedownload = service.filedownload || (service.filedownload = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var fileuploadwidget;
    (function (fileuploadwidget) {
        "use strict";
        function InitFileUploadWidget($container) {
            new FileUploadWidget($container);
        }
        fileuploadwidget.InitFileUploadWidget = InitFileUploadWidget;
        // This class is setup to be dynamically bound, as the table will load asynchronously
        class FileUploadWidget {
            constructor($container) {
                this.$container = $container;
                this.$uploadContainer = portal.fileuploader.control.GetUploadContainer($container);
                this.fileUploadModel = starrez.model.FileUploadModel($container);
                this.$maximumNumberOfFilesError = this.$container.find(".ui-maximum-attachments-error");
                this.$notification = portal.fileuploader.control.GetNotification(this.$uploadContainer);
                // Bind responsive table events
                this.$responsiveTableContainer = $container.find('.ui-responsive-active-table-container');
                this.$responsiveTableContainer.on(starrez.activetable.responsive.eventTableLoaded, () => {
                    this.BindTable();
                });
                var fileUpload = this.$uploadContainer.data("upload-instance");
                if (starrez.library.utils.IsNotNullUndefined(fileUpload)) {
                    fileUpload.AutomaticallySubmitFiles = true;
                    fileUpload.CustomValidation = (files) => this.FileUploadValidate(files);
                    fileUpload.LoadingText = this.fileUploadModel.UploadLoadingMessage;
                    this.$uploadContainer.on("upload-success", (e, info) => {
                        this.$responsiveTableContainer.trigger(starrez.activetable.responsive.eventTableRefresh);
                    });
                }
            }
            IsMobile() {
                return this.$responsiveTableContainer.data('isMobile') === true;
            }
            GetRowSelector() {
                return this.IsMobile() ? "tbody" : "tbody tr";
            }
            GetRows() {
                return this.uploadedFilesTable.$table.find(this.GetRowSelector());
            }
            BindTable() {
                this.$uploadedFilesTableDiv = this.$container.find(".ui-uploaded-files-table");
                this.uploadedFilesTable = starrez.tablesetup.CreateTableManager(this.$container.find(".ui-uploaded-files-table table"), $("body"))[0];
                this.AttachDeleteFileEvents();
                this.DisplayUploadDetails();
            }
            DisplayUploadDetails() {
                var $tableRows = this.GetRows();
                if ($tableRows.length === this.fileUploadModel.MaximumNumberOfFiles) {
                    this.$container.find(".ui-file-upload-label").hide();
                    this.$uploadContainer.hide();
                    this.$maximumNumberOfFilesError.show();
                }
                else {
                    this.$container.find(".ui-file-upload-label").show();
                    this.$uploadContainer.show();
                    this.$maximumNumberOfFilesError.hide();
                }
                if ($tableRows.length > 0) {
                    this.$uploadedFilesTableDiv.show();
                    this.uploadedFilesTable = starrez.tablesetup.CreateTableManager(this.$container.find(".ui-uploaded-files-table table"), $("body"))[0];
                }
                else {
                    this.$uploadedFilesTableDiv.hide();
                }
            }
            AttachDeleteFileEvents() {
                this.uploadedFilesTable.$table.SRClickDelegate("delete", ".ui-btn-delete", (e) => {
                    portal.fileuploader.control.ClearNotification(this.$notification);
                    portal.ConfirmAction(this.fileUploadModel.DeleteFileConfirmText, "Delete File").done(() => {
                        const rowSelector = this.GetRowSelector();
                        var $row = $(e.currentTarget).closest(rowSelector);
                        var id = Number($row.data("id"));
                        var hash = $row.data("deletehash").toString();
                        new starrez.service.fileupload.DeleteFile({
                            recordAttachmentID: id,
                            hash: hash
                        }).Post().done((success) => {
                            if (success) {
                                this.SetNotification(this.fileUploadModel.DeleteFileSuccessMessage, false);
                                this.uploadedFilesTable.RemoveRows($row);
                            }
                            else {
                                this.SetNotification(this.fileUploadModel.DeleteFileErrorMessage, true);
                            }
                            this.DisplayUploadDetails();
                        });
                        portal.fileuploader.control.ClearNotification(this.$notification);
                    });
                });
            }
            FileUploadValidate(files) {
                portal.fileuploader.control.ClearNotification(this.$notification);
                var deferred = $.Deferred();
                var fileData = [];
                var isValid = true;
                var isNotificationDone;
                var numberOfFiles = this.GetRows().length + files.length;
                if (numberOfFiles > this.fileUploadModel.MaximumNumberOfFiles) {
                    this.SetNotification(this.fileUploadModel.MaximumNumberOfFilesErrorMessage);
                    isNotificationDone = true;
                    isValid = false;
                }
                else {
                    for (var x = 0; x < files.length; x++) {
                        if (files[x].size > this.fileUploadModel.MaxAttachmentBytes) {
                            this.SetNotification(this.fileUploadModel.MaxAttachmentBytesErrorMessage);
                            isNotificationDone = true;
                            isValid = false;
                            break;
                        }
                        var ext = files[x].name.split(".").pop();
                        var isNamevalid = false;
                        $.each(this.fileUploadModel.ValidFileExtensions.split(","), (function (key, value) {
                            if (starrez.library.stringhelper.Equals(value.trim(), ext, true)) {
                                isNamevalid = true;
                                return false;
                            }
                        }));
                        if (!isNamevalid && !isNotificationDone) {
                            this.SetNotification(this.fileUploadModel.AttachmentTypeErrorMessage + this.fileUploadModel.ValidFileExtensions.split(",").join(", "));
                            isValid = false;
                            break;
                        }
                        else {
                            fileData.push({
                                Key: files[x].name,
                                Value: files[x].size
                            });
                        }
                    }
                }
                if (isValid) {
                    deferred.resolve(true);
                }
                else {
                    deferred.reject(false);
                }
                return deferred.promise();
            }
            SetNotification(message, isWarning = true) {
                var warningClass = "uploader-alert-warning";
                var infoClass = "uploader-alert-info";
                //Make sure $notification doesn't have any warning or info class
                this.$notification.removeClass(warningClass + " " + infoClass);
                var alertClass;
                if (isWarning) {
                    alertClass = warningClass;
                }
                else {
                    alertClass = infoClass;
                }
                portal.fileuploader.control.SetNotification(this.$notification, alertClass, message);
            }
        }
    })(fileuploadwidget = portal.fileuploadwidget || (portal.fileuploadwidget = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.fileuploadwidget.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function FileUploadModel($sys) {
            return {
                AttachmentTypeErrorMessage: $sys.data('attachmenttypeerrormessage'),
                DeleteFileConfirmText: $sys.data('deletefileconfirmtext'),
                DeleteFileErrorMessage: $sys.data('deletefileerrormessage'),
                DeleteFileSuccessMessage: $sys.data('deletefilesuccessmessage'),
                MaxAttachmentBytes: Number($sys.data('maxattachmentbytes')),
                MaxAttachmentBytesErrorMessage: $sys.data('maxattachmentbyteserrormessage'),
                MaximumNumberOfFiles: Number($sys.data('maximumnumberoffiles')),
                MaximumNumberOfFilesErrorMessage: $sys.data('maximumnumberoffileserrormessage'),
                MinimumNumberOfFiles: Number($sys.data('minimumnumberoffiles')),
                MinimumNumberOfFilesErrorMessage: $sys.data('minimumnumberoffileserrormessage'),
                UploadLoadingMessage: $sys.data('uploadloadingmessage'),
                ValidFileExtensions: $sys.data('validfileextensions'),
            };
        }
        model.FileUploadModel = FileUploadModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var fileupload;
        (function (fileupload) {
            "use strict";
            class DeleteFile extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "FileUpload";
                    this.Controller = "fileupload";
                    this.Action = "DeleteFile";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        recordAttachmentID: this.o.recordAttachmentID,
                    };
                    return obj;
                }
            }
            fileupload.DeleteFile = DeleteFile;
            class GetUploadedFileRow extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "FileUpload";
                    this.Controller = "fileupload";
                    this.Action = "GetUploadedFileRow";
                }
                CallData() {
                    var obj = {
                        existingQuery: this.o.existingQuery,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        widgetID: this.o.widgetID,
                    };
                    return obj;
                }
            }
            fileupload.GetUploadedFileRow = GetUploadedFileRow;
            class UploadFiles extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "FileUpload";
                    this.Controller = "fileupload";
                    this.Action = "UploadFiles";
                }
                CallData() {
                    var obj = {
                        existingQuery: this.o.existingQuery,
                        pageID: this.o.pageID,
                        widgetID: this.o.widgetID,
                    };
                    return obj;
                }
            }
            fileupload.UploadFiles = UploadFiles;
        })(fileupload = service.fileupload || (service.fileupload = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var fabackgroundcheck;
    (function (fabackgroundcheck) {
        "use strict";
        function InitialiseFABackgroundCheckPage($container) {
            new FABackGroundCheckModel($container);
        }
        fabackgroundcheck.InitialiseFABackgroundCheckPage = InitialiseFABackgroundCheckPage;
        class FABackGroundCheckModel {
            constructor($container) {
                this.$container = $container;
                this.$incomeMonthly = $container.GetControl("IncomeMonthly");
                this.$currentRent = $container.GetControl("CurrentRent");
                this.$incomeOther = $container.GetControl("IncomeOther");
                this.$incomeOtherType = $container.GetControl("IncomeOtherType");
                this.$incomeOtherPeriod = $container.GetControl("IncomeOtherPeriod");
                this.$incomeOtherTypeLabel = $("#IncomeOtherTypeLabelID");
                this.$incomeOtherPeriodLabel = $("#IncomeOtherPeriodLabelID");
                this.IncomeOtherTypeLabelRequiredMessage = this.$incomeOtherTypeLabel.attr("aria-label");
                this.IncomeOtherPeriodLabelRequiredMessage = this.$incomeOtherPeriodLabel.attr("aria-label");
                this.$guarantorIncome = $container.GetControl("GuarantorIncome");
                portal.page.CurrentPage.AddCustomValidation(this);
                this.AttachEvents();
                this.BlankAmountsIfZero();
            }
            Validate() {
                var deferred = $.Deferred();
                // This is necessary as Binder is failing without a proper logfging error when trying to reconstruct the model if
                // empty string are passed in for a numerical value. Income Other is not a required field.
                if (starrez.library.stringhelper.IsUndefinedOrEmpty(this.$incomeOther.SRVal())) {
                    this.$incomeOther.SRVal("0.00");
                }
                deferred.resolve();
                return deferred.promise();
            }
            BlankAmountsIfZero() {
                // As Decimal types are presented by default with a 0.00 but we want the user to povide with a value if
                // they cannot be sourced in the model or if they are 0
                this.BlankNumericValueIfZero(this.$incomeMonthly);
                this.BlankNumericValueIfZero(this.$currentRent);
                this.BlankNumericValueIfZero(this.$incomeOther);
                this.BlankNumericValueIfZero(this.$guarantorIncome);
            }
            BlankNumericValueIfZero(e) {
                if (!starrez.library.stringhelper.IsUndefinedOrEmpty(e.SRVal())) {
                    var amount = parseFloat(e.SRVal());
                    if (isNaN(amount) || amount === 0) {
                        e.SRVal("");
                    }
                }
            }
            AttachEvents() {
                this.$incomeOther.on("change", (e) => {
                    var amount = parseFloat(this.$incomeOther.SRVal());
                    // Income Other Type and Income Other Period are required only if Income Other Amount is > 0
                    // Need to gracefully add or remove validation depending on value of Other Income, client side.
                    if (isNaN(amount) || amount === 0) {
                        this.$incomeOtherType.removeClass("ui-hasvalidation");
                        this.$incomeOtherPeriod.removeClass("ui-hasvalidation");
                        this.$incomeOtherTypeLabel.attr("aria-label", this.$incomeOtherTypeLabel.SRVal());
                        this.$incomeOtherPeriodLabel.attr("aria-label", this.$incomeOtherPeriodLabel.SRVal());
                        this.DisplayValidationResult(this.$incomeOtherType, { IsValid: true, Message: null, Type: starrez.library.validation.ValidationType.Required });
                        this.DisplayValidationResult(this.$incomeOtherPeriod, { IsValid: true, Message: null, Type: starrez.library.validation.ValidationType.Required });
                    }
                    else {
                        this.$incomeOtherType.addClass("ui-hasvalidation");
                        this.$incomeOtherPeriod.addClass("ui-hasvalidation");
                        this.$incomeOtherTypeLabel.attr("aria-label", this.IncomeOtherTypeLabelRequiredMessage);
                        this.$incomeOtherPeriodLabel.attr("aria-label", this.IncomeOtherPeriodLabelRequiredMessage);
                        this.DisplayValidationResult(this.$incomeOtherType, { IsValid: !starrez.library.stringhelper.IsUndefinedOrEmpty(this.$incomeOtherType.SRVal()), Message: null, Type: starrez.library.validation.ValidationType.Required });
                        this.DisplayValidationResult(this.$incomeOtherPeriod, { IsValid: !starrez.library.stringhelper.IsUndefinedOrEmpty(this.$incomeOtherPeriod.SRVal()), Message: null, Type: starrez.library.validation.ValidationType.Required });
                    }
                });
            }
            // This was grabbed from other source as it is not publicly exposed.
            DisplayValidationResult($el, validationResult) {
                var $tagSpan;
                var $validationArea = $el;
                var hasValidationTagAdded = $validationArea.siblings().hasClass('ui-validation-flag');
                if (!hasValidationTagAdded) {
                    $tagSpan = $validationArea.after('<span></span>').next().hide();
                    $tagSpan.addClass('input-validation-error ui-validation-flag');
                    $tagSpan.addClass('ignorable-field');
                }
                else {
                    $tagSpan = $validationArea.siblings('.ui-validation-flag');
                }
                if (!validationResult.IsValid) {
                    $tagSpan.prop('title', validationResult.Message);
                    $tagSpan.unbind('click').click(() => {
                        portal.ShowMessage(validationResult.Message, "Error");
                    });
                    $tagSpan.css({ marginLeft: 5 });
                    $tagSpan.css({ width: 0 }).show().animate({ width: 16 });
                }
                else if ($tagSpan.is(":visible")) {
                    $tagSpan.animate({ width: 0 }, null, () => {
                        $tagSpan.hide();
                    });
                }
                return validationResult;
            }
        }
    })(fabackgroundcheck = starrez.fabackgroundcheck || (starrez.fabackgroundcheck = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.fabackgroundcheck.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function FirstAdvantageBackgroundCheckModel($sys) {
            return {
                AddressCity: $sys.data('addresscity'),
                AddressEmail: $sys.data('addressemail'),
                AddressState: $sys.data('addressstate'),
                AddressStreet: $sys.data('addressstreet'),
                AddressStreet2: $sys.data('addressstreet2'),
                AddressZip: $sys.data('addresszip'),
                CurrentRent: Number($sys.data('currentrent')),
                DateOfBirth: $sys.data('dateofbirth'),
                DriversLicenseNumber: $sys.data('driverslicensenumber'),
                DriversLicenseState: $sys.data('driverslicensestate'),
                EntryID: Number($sys.data('entryid')),
                FirstName: $sys.data('firstname'),
                GuarantorAddressCity: $sys.data('guarantoraddresscity'),
                GuarantorAddressEmail: $sys.data('guarantoraddressemail'),
                GuarantorAddressPhone: $sys.data('guarantoraddressphone'),
                GuarantorAddressState: $sys.data('guarantoraddressstate'),
                GuarantorAddressStreet: $sys.data('guarantoraddressstreet'),
                GuarantorAddressStreet2: $sys.data('guarantoraddressstreet2'),
                GuarantorAddressZip: $sys.data('guarantoraddresszip'),
                GuarantorDateOfBirth: $sys.data('guarantordateofbirth'),
                GuarantorFirstName: $sys.data('guarantorfirstname'),
                GuarantorIncome: Number($sys.data('guarantorincome')),
                GuarantorLastName: $sys.data('guarantorlastname'),
                GuarantorMiddleInitial: $sys.data('guarantormiddleinitial'),
                IncomeMonthly: Number($sys.data('incomemonthly')),
                IncomeOther: Number($sys.data('incomeother')),
                IncomeOtherPeriod: $sys.data('incomeotherperiod'),
                IncomeOtherType: $sys.data('incomeothertype'),
                LastName: $sys.data('lastname'),
                MiddleInitial: $sys.data('middleinitial'),
                MonthlyRent: Number($sys.data('monthlyrent')),
                PushNotificationURL: $sys.data('pushnotificationurl'),
                SSN_ITIN: $sys.data('ssn_itin'),
            };
        }
        model.FirstAdvantageBackgroundCheckModel = FirstAdvantageBackgroundCheckModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var flywirerecurringpayments;
    (function (flywirerecurringpayments) {
        "use strict";
        function InitialiseRegistrationPage($container) {
            new RegistrationPage($container);
        }
        flywirerecurringpayments.InitialiseRegistrationPage = InitialiseRegistrationPage;
        class RegistrationPage {
            constructor($container) {
                this.$container = $container;
                this.AttachButtonEvents();
                window.addEventListener("message", (event) => {
                    if (!event.origin.includes(".flywire.com")) {
                        return;
                    }
                    if (event.data.source !== 'checkout_session') {
                        return;
                    }
                    this.SubmitRegistrationResult(event.data);
                });
                this.InitialPage();
            }
            AttachButtonEvents() {
                this.$cardRegistrationButton = this.$container.find(".card-registration");
                this.$achRegistrationButton = this.$container.find(".ach-registration");
                this.$sepaRegistrationButton = this.$container.find(".sepa-registration");
                this.$bacsRegistrationButton = this.$container.find(".bacs-registration");
                this.$eftCanadaRegistrationButton = this.$container.find(".eft-canada-registration");
                this.$backToRegistrationButton = this.$container.find(".back-to-registration");
                this.$cardRegistrationButton.SRClick(() => {
                    this.Register('Card');
                });
                this.$achRegistrationButton.SRClick(() => {
                    this.Register('ACHDirectDebit');
                });
                this.$sepaRegistrationButton.SRClick(() => {
                    this.Register('SEPADirectDebit');
                });
                this.$bacsRegistrationButton.SRClick(() => {
                    this.Register('BACSDirectDebit');
                });
                this.$eftCanadaRegistrationButton.SRClick(() => {
                    this.Register('EFTCanadaDirectDebit');
                });
                this.$backToRegistrationButton.SRClick(() => {
                    this.InitialPage();
                });
            }
            UpdatePage(html) {
                this.$container.html(html);
                this.AttachButtonEvents();
            }
            InitialPage() {
                let call = new starrez.service.flywireregistration.InitialPage({
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                });
                call.Get().done((response) => {
                    this.UpdatePage(response);
                });
            }
            SubmitRegistrationResult(result) {
                let call = new starrez.service.flywireregistration.Result({
                    result,
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                });
                call.Post().done((response) => {
                    this.UpdatePage(response);
                });
            }
            Register(paymentMethod) {
                var call = new starrez.service.flywireregistration.RegistrationPage({
                    paymentMethod,
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                });
                call.Get().done((response) => {
                    this.UpdatePage(response);
                });
            }
        }
    })(flywirerecurringpayments = starrez.flywirerecurringpayments || (starrez.flywirerecurringpayments = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.general.flywirerecurringpayments.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var flywireregistration;
        (function (flywireregistration) {
            "use strict";
            class InitialPage extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "FlywireRecurringPayments";
                    this.Controller = "flywireregistration";
                    this.Action = "InitialPage";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            flywireregistration.InitialPage = InitialPage;
            class RegistrationPage extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "FlywireRecurringPayments";
                    this.Controller = "flywireregistration";
                    this.Action = "RegistrationPage";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        paymentMethod: this.o.paymentMethod,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            flywireregistration.RegistrationPage = RegistrationPage;
            class Result extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "FlywireRecurringPayments";
                    this.Controller = "flywireregistration";
                    this.Action = "Result";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                        result: this.o.result,
                    };
                    return obj;
                }
            }
            flywireregistration.Result = Result;
        })(flywireregistration = service.flywireregistration || (service.flywireregistration = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var image;
        (function (image) {
            "use strict";
            function InitSettingsEditor($container) {
                new ImageSettingsEditor($container);
            }
            image.InitSettingsEditor = InitSettingsEditor;
            class ImageSettingsEditor {
                constructor($container) {
                    this.model = starrez.model.ImageEditorModel($container);
                    this.$uploadContainer = portal.fileuploader.control.GetUploadContainer($container);
                    this.portalPageWidgetID = Number($container.data("portalpagewidgetid"));
                    this.fileUpload = portal.fileuploader.control.GetUploadInstance($container);
                    this.fileUpload.CustomValidation = (files) => this.ValidateFiles(files);
                    portal.editor.widget.OnWidgetSettingsSave = () => {
                        let def = $.Deferred();
                        let call = new starrez.service.image.Save({
                            portalPageWidgetID: this.portalPageWidgetID,
                            scaledHeight: Number($container.GetControl("ScaledHeight").SRVal())
                        });
                        call.Post().done(() => {
                            def.resolve();
                        });
                        return def.promise();
                    };
                }
                ValidateFiles(files) {
                    let deferred = $.Deferred();
                    let isValid = true;
                    // Should only ever be 1 file in the list as we don't use multi upload in this case
                    if (files.length > 0) {
                        // Validate file extensions
                        let validExtensions = ["jpg", "jpeg", "jpe", "gif", "png", "bmp", "svg"];
                        let extension = files[0].name.split(".").pop().toLowerCase();
                        if (validExtensions.indexOf(extension) == -1) {
                            portal.fileuploader.control.SetNotification(portal.fileuploader.control.GetNotification(this.$uploadContainer), "uploader-alert-warning", "Invalid file type. File must be one of " + validExtensions.join(", ") + ". Filename was " + files[0].name + ".");
                            isValid = false;
                        }
                        // Validate file size
                        if (files[0].size > this.model.MaxAttachmentLengthBytes) {
                            portal.fileuploader.control.SetNotification(portal.fileuploader.control.GetNotification(this.$uploadContainer), "uploader-alert-warning", "Uploaded file is too large. Maximum allowed size is " + this.model.MaxAttachmentLengthBytes + " bytes. File size is " + files[0].size + " bytes.");
                            isValid = false;
                        }
                    }
                    deferred.resolve(isValid);
                    return deferred.promise();
                }
            }
            function InitializeImageWidget($container) {
                let model = starrez.model.ImageModel($container);
                if (model.Is360Image && !portal.editor.IsInLiveEditMode) {
                    let mousemove = true;
                    let navbar = [
                        'autorotate',
                        'zoom',
                        'download',
                        'caption',
                        'gyroscope',
                        'fullscreen'
                    ];
                    if (!starrez.library.stringhelper.IsUndefinedOrEmpty(model.HyperLink)) {
                        mousemove = false;
                        navbar = false;
                    }
                    let photoSphereViewer = new PhotoSphereViewer({
                        panorama: model.ImageUrl,
                        container: $container.find('.ui-photo-sphere-viewer').get(0),
                        caption: model.AltText,
                        mousemove: mousemove,
                        mousewheel: false,
                        navbar: navbar
                    });
                }
            }
            image.InitializeImageWidget = InitializeImageWidget;
        })(image = general.image || (general.image = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.image.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function ImageModel($sys) {
            return {
                AltText: $sys.data('alttext'),
                HyperLink: $sys.data('hyperlink'),
                HyperLinkTarget: $sys.data('hyperlinktarget'),
                ImageUrl: $sys.data('imageurl'),
                Is360Image: starrez.library.convert.ToBoolean($sys.data('is360image')),
            };
        }
        model.ImageModel = ImageModel;
        function ImageEditorModel($sys) {
            return {
                MaxAttachmentLengthBytes: Number($sys.data('maxattachmentlengthbytes')),
            };
        }
        model.ImageEditorModel = ImageEditorModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var image;
        (function (image) {
            "use strict";
            class Save extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Image";
                    this.Controller = "image";
                    this.Action = "Save";
                }
                CallData() {
                    var obj = {
                        portalPageWidgetID: this.o.portalPageWidgetID,
                        scaledHeight: this.o.scaledHeight,
                    };
                    return obj;
                }
            }
            image.Save = Save;
        })(image = service.image || (service.image = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var inventory;
        (function (inventory) {
            "use strict";
            function InitialiseInventoryList($container) {
                new InventoryInspectionListAccessible($container);
            }
            inventory.InitialiseInventoryList = InitialiseInventoryList;
            function InitialiseDetailPage($container) {
                new InventoryInspectionDetails($container);
            }
            inventory.InitialiseDetailPage = InitialiseDetailPage;
            class InventoryInspectionList {
                constructor($container) {
                    this.$container = $container;
                    this.AttachEvents();
                }
                AttachEvents() {
                    this.$container.find(".ui-inventory-review").SRClick((e) => {
                        var $button = $(e.currentTarget);
                        var inspectionID = Number($button.closest("tr").data("roomspaceinventoryinspection"));
                        new starrez.service.inventory.GetInventoryDetailsUrl({
                            pageID: portal.page.CurrentPage.PageID,
                            inspectionID: inspectionID
                        }).Post().done((url) => {
                            location.href = url;
                        });
                    });
                }
            }
            class InventoryInspectionListAccessible {
                constructor($container) {
                    this.$container = $container;
                    this.$responsiveTableContainer = $container.find('.ui-responsive-active-table-container');
                    this.$responsiveTableContainer.on(starrez.activetable.responsive.eventTableLoaded, () => {
                        this.BindTable();
                        this.AttachEvents();
                    });
                }
                BindTable() {
                    this.inventoryInspectionDetailsTable = starrez.tablesetup.responsive.CreateTableManager(this.$responsiveTableContainer, $('body'), null, true)[0];
                }
                AttachEvents() {
                    this.inventoryInspectionDetailsTable.$table.SRClickDelegate("roomspaceinventoryinspection", ".ui-inventory-review", (e) => {
                        var $row = $(e.currentTarget).closest(this.inventoryInspectionDetailsTable.GetRowSelector());
                        var inspectionID = Number($row.data("roomspaceinventoryinspection"));
                        new starrez.service.inventory.GetInventoryDetailsUrl({
                            pageID: portal.page.CurrentPage.PageID,
                            inspectionID: inspectionID
                        }).Post().done((url) => {
                            location.href = url;
                        });
                    });
                }
            }
            class InventoryInspectionDetails {
                constructor($container) {
                    this.$container = $container;
                    this.pageModel = starrez.model.InventoryInspectionDetailsModel($container);
                    this.AttachEvents();
                }
                AttachEvents() {
                    this.$container.find(".ui-btn-more").SRClick((e) => {
                        starrez.library.utils.SafeStopPropagation(e);
                        var $button = $(e.currentTarget);
                        var $inventoryItem = $button.closest(".ui-inventory-item");
                        this.ToggleInformation($button, $inventoryItem);
                    });
                    this.$container.find(".ui-accept").SRClick((e) => {
                        this.ToggleAccepted(true, $(e.currentTarget));
                    });
                    this.$container.find(".ui-reject").SRClick((e) => {
                        this.ToggleAccepted(false, $(e.currentTarget));
                    });
                    portal.PageElements.$actions.find(".ui-btn-save-review").SRClick(() => {
                        var reviewItems = [];
                        var allAccepted = true;
                        this.$container.find(".ui-inventory-item").each((index, element) => {
                            var $item = $(element);
                            var accepted = starrez.library.convert.ToBoolean($item.data("accepted"));
                            allAccepted = allAccepted && accepted;
                            reviewItems.push({
                                Accepted: accepted,
                                ReviewComments: $item.GetControl("ReviewComments").SRVal(),
                                RoomSpaceInventoryInspectionItemID: $item.data("roomspaceinventoryinspectionitemid")
                            });
                        });
                        if (this.pageModel.ShowNotAcceptedConfirmation && !allAccepted) {
                            portal.ConfirmAction(this.pageModel.NotAcceptedConfirmationMessage, this.pageModel.NotAcceptedConfirmationTitle).done(() => {
                                this.SaveReview(this.$container, reviewItems);
                            });
                        }
                        else {
                            this.SaveReview(this.$container, reviewItems);
                        }
                    });
                }
                ToggleAccepted(accepted, $button) {
                    var $inventoryItem = $button.closest(".ui-inventory-item");
                    var $acceptButton = $inventoryItem.find(".ui-accept");
                    var $rejectButton = $inventoryItem.find(".ui-reject");
                    $inventoryItem.data("accepted", accepted);
                    if (accepted) {
                        $rejectButton.AriaShow();
                        $rejectButton.show();
                        $rejectButton.focus();
                        $acceptButton.AriaHide();
                        $acceptButton.hide();
                    }
                    else {
                        $acceptButton.AriaShow();
                        $acceptButton.show();
                        $acceptButton.focus();
                        $rejectButton.AriaHide();
                        $rejectButton.hide();
                    }
                }
                ToggleInformation($button, $inventoryItem) {
                    var $details = $inventoryItem.find(".ui-toggle-show");
                    if ($details.is(":visible")) {
                        $button.text(this.pageModel.MoreLinkText);
                        $button.removeClass("shown");
                    }
                    else {
                        $button.text(this.pageModel.LessLinkText);
                        $button.addClass("shown");
                    }
                    $details.slideToggle();
                }
                SaveReview($container, reviewItems) {
                    if (reviewItems.length > 0) {
                        new starrez.service.inventory.SaveReview({
                            inspectionID: this.pageModel.RoomSpaceInventoryInspectionID,
                            pageID: portal.page.CurrentPage.PageID,
                            items: reviewItems
                        }).Post().done(success => {
                            if (success) {
                                portal.page.CurrentPage.SubmitPage();
                            }
                            else {
                                portal.page.CurrentPage.SetErrorMessage(this.pageModel.SaveReviewErrorMessage);
                            }
                        }).fail(() => {
                            portal.page.CurrentPage.SetErrorMessage(this.pageModel.SaveReviewErrorMessage);
                        });
                    }
                }
            }
        })(inventory = general.inventory || (general.inventory = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.inventory.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function InventoryInspectionDetailsModel($sys) {
            return {
                AcceptAllOnSave: starrez.library.convert.ToBoolean($sys.data('acceptallonsave')),
                AcceptButtonText: $sys.data('acceptbuttontext'),
                AcceptedButtonText: $sys.data('acceptedbuttontext'),
                LessLinkText: $sys.data('lesslinktext'),
                MoreLinkText: $sys.data('morelinktext'),
                NotAcceptedConfirmationMessage: $sys.data('notacceptedconfirmationmessage'),
                NotAcceptedConfirmationTitle: $sys.data('notacceptedconfirmationtitle'),
                ReadOnly: starrez.library.convert.ToBoolean($sys.data('readonly')),
                RoomSpaceInventoryInspectionID: Number($sys.data('roomspaceinventoryinspectionid')),
                SaveReviewErrorMessage: $sys.data('savereviewerrormessage'),
                ShowAcceptButton: starrez.library.convert.ToBoolean($sys.data('showacceptbutton')),
                ShowNotAcceptedConfirmation: starrez.library.convert.ToBoolean($sys.data('shownotacceptedconfirmation')),
            };
        }
        model.InventoryInspectionDetailsModel = InventoryInspectionDetailsModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var inventory;
        (function (inventory) {
            "use strict";
            class GetInventoryDetailsUrl extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "Inventory";
                    this.Controller = "inventory";
                    this.Action = "GetInventoryDetailsUrl";
                }
                CallData() {
                    var obj = {
                        inspectionID: this.o.inspectionID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            inventory.GetInventoryDetailsUrl = GetInventoryDetailsUrl;
            class SaveReview extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "Inventory";
                    this.Controller = "inventory";
                    this.Action = "SaveReview";
                }
                CallData() {
                    var obj = {
                        inspectionID: this.o.inspectionID,
                        items: this.o.items,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            inventory.SaveReview = SaveReview;
        })(inventory = service.inventory || (service.inventory = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var livechat;
    (function (livechat) {
        "use strict";
        function Initialise($container) {
            var model = starrez.model.LiveChatModel($container);
        }
        livechat.Initialise = Initialise;
    })(livechat = starrez.livechat || (starrez.livechat = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.livechat.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function LiveChatModel($sys) {
            return {};
        }
        model.LiveChatModel = LiveChatModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var MailMerge;
        (function (MailMerge) {
            "use strict";
            function InitMailMergeWidget($container) {
                new MailMergeModel($container);
            }
            MailMerge.InitMailMergeWidget = InitMailMergeWidget;
            class MailMergeModel {
                constructor($container) {
                    this.model = starrez.model.MailMergeModel($container);
                    this.$container = $container;
                    this.SetupHasDownloadedFlagEvent();
                    this.DisplayInlineTemplate();
                }
                SetupHasDownloadedFlagEvent() {
                    var downloadTemplate = this.$container.find(".ui-download-mailmerge");
                    // The PDF download is a link, so that will get downloaded without the need for any extra code here.
                    // We still need to set the HasDownloadedFile hidden form field
                    // to mark the PDF file as having been downloaded.
                    downloadTemplate.SRClick(() => {
                        var hasDownloadedFile = this.$container.GetControl("HasDownloadedFile");
                        hasDownloadedFile.SRVal(true);
                    });
                }
                DisplayInlineTemplate() {
                    var $mailMergeView = this.$container.find(".ui-mailmergeview");
                    var call = new starrez.service.mailmerge.GetInlineDocument({
                        portalPageWidgetID: this.$container.data('portalpagewidgetid'),
                        hash: $mailMergeView.data("hash")
                    });
                    call.Request({
                        ActionVerb: starrez.library.service.RequestType.Post,
                        ShowLoading: false
                    }).done((result) => {
                        $mailMergeView.html(result);
                    });
                }
            }
        })(MailMerge = general.MailMerge || (general.MailMerge = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.mailmergewidget.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function MailMergeModel($sys) {
            return {
                MailMergeTemplate: Number($sys.data('mailmergetemplate')),
            };
        }
        model.MailMergeModel = MailMergeModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var mailmerge;
        (function (mailmerge) {
            "use strict";
            class DownloadMailMergeDocument extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "MailMerge";
                    this.Controller = "mailmerge";
                    this.Action = "DownloadMailMergeDocument";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            mailmerge.DownloadMailMergeDocument = DownloadMailMergeDocument;
            class GetInlineDocument extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "MailMerge";
                    this.Controller = "mailmerge";
                    this.Action = "GetInlineDocument";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            mailmerge.GetInlineDocument = GetInlineDocument;
        })(mailmerge = service.mailmerge || (service.mailmerge = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var mealplanselection;
        (function (mealplanselection) {
            "use strict";
            function InitMealPlanSelectionWidget($container) {
                var portalPageWidgetID = Number($container.data('portalpagewidgetid'));
                $container.data('MealPlanSelectionWidget', new MealPlanSelectionWidget(portalPageWidgetID, $container));
            }
            mealplanselection.InitMealPlanSelectionWidget = InitMealPlanSelectionWidget;
            // Copied from FormWidget. This should be made reusable.
            class MealPlanSelectionWidget {
                constructor(portalPageWidgetID, $container) {
                    this.portalPageWidgetID = portalPageWidgetID;
                    this.$container = $container;
                    portal.page.RegisterWidgetSaveData(portalPageWidgetID, () => this.GetSaveData());
                }
                GetSaveData() {
                    var saveData = new starrez.library.collections.KeyValue();
                    var $allControls = this.$container.GetAllControls();
                    $allControls.each((index, element) => {
                        var $control = $(element);
                        if ($control.HasChanged()) {
                            var fieldID = $control.closest('li').data('id').toString();
                            var value = $control.SRVal();
                            saveData.Add(fieldID, value);
                        }
                    });
                    var data = saveData.ToArray();
                    if (data.length === 0) {
                        return null;
                    }
                    return data;
                }
            }
        })(mealplanselection = general.mealplanselection || (general.mealplanselection = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.mealplanselection.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var messaging;
        (function (messaging) {
            "use strict";
            const UnreadUiClass = "ui-unread";
            const UnreadClasses = UnreadUiClass + " unread";
            const SelectedClass = "selected";
            const MessagingNavBarIconName = "MessagingNavigationBarIcon";
            let MessageType;
            (function (MessageType) {
                MessageType[MessageType["New"] = 0] = "New";
                MessageType[MessageType["Reply"] = 1] = "Reply";
                MessageType[MessageType["Forward"] = 2] = "Forward";
            })(MessageType || (MessageType = {}));
            ;
            /**
                * Adds disabled fields to save page function
                * @param $container
                */
            function InitComposeMessage($container) {
                portal.page.CurrentPage.FetchAdditionalData = () => {
                    return {
                        Subject: $container.GetControl("Subject").SRVal(),
                        Recipient: $container.GetControl("Recipient").SRVal()
                    };
                };
            }
            messaging.InitComposeMessage = InitComposeMessage;
            /**
                * On message click, redirects to the messaging module with the info of the selected
                * message. This allows the messaging page to show the message thread on load.
                * @param $container the messaging widget container
                */
            function InitialiseWidget($container) {
                $container.SRClickDelegate("convo-click", ".ui-widget-conversation", e => {
                    var $message = $(e.currentTarget);
                    var model = starrez.model.MessagingWidgetModel($container);
                    location.href = model.MessagingProcessUrl
                        + "#subject=" + encodeURIComponent($message.find(".ui-subject").text())
                        + "&correspondentID=" + encodeURIComponent($message.data("correspondentid"));
                });
            }
            messaging.InitialiseWidget = InitialiseWidget;
            function InitialisePage($container) {
                messaging.Model = new MessagingPage($container);
            }
            messaging.InitialisePage = InitialisePage;
            function EmailFrameOnLoad(frame) {
                // Resize
                var contentHeight = frame.contentWindow.document.body.scrollHeight;
                if (contentHeight > 500) {
                    contentHeight = 500;
                }
                else {
                    contentHeight += 30;
                }
                frame.height = contentHeight + "px";
                // Append default font
                frame.contentDocument.body.style.fontFamily = window.getComputedStyle(document.body).getPropertyValue("font-family");
            }
            messaging.EmailFrameOnLoad = EmailFrameOnLoad;
            class Conversation {
            }
            class MessagingPage {
                constructor($container) {
                    this.$container = $container;
                    this.$conversationsContainer = this.$container.find(".ui-conversations-container");
                    this.LoadConversations(1);
                    this.$messagesContainer = this.$container.find(".ui-messages-container");
                    var $selectedConvo = this.FindSelectedConvoOnPage(this.GetSelectedConvoFromHash());
                    if (starrez.library.utils.IsNotNullUndefined($selectedConvo)) {
                        $selectedConvo.click();
                    }
                    if (!portal.mobile.IsInMobileResolution()) {
                        var $firstConvo = this.$container.find(".ui-page-conversation").first();
                        if ($firstConvo.isFound()) {
                            $firstConvo.click();
                        }
                    }
                }
                LoadConversations(currentPageNumber) {
                    this.currentPageNumber = currentPageNumber;
                    new starrez.service.messaging.GetPagedConversations({
                        pageID: portal.page.CurrentPage.PageID,
                        currentPageNumber: this.currentPageNumber
                    }).Post().done((result) => {
                        this.$conversationsContainer.html(result);
                        portal.actionpanel.control.AutoAdjustActionPanelHeights(this.$container);
                        this.AttachConversationClick();
                        portal.paging.AttachPagingClickEvent(this, this.$conversationsContainer, this.LoadConversations);
                    });
                }
                /**
                    * If a hash is supplied in the Url then the it is extracted and a Conversation is created
                    * and returned. This will be set when linking from the messaging widget, or from an email
                    * that is sent to the student.
                    */
                GetSelectedConvoFromHash() {
                    var convo = new Conversation;
                    // removes the '#' from the start of the string. Then splits on the '&', then again on the '='
                    location.hash.substring(1).split("&").forEach(pair => {
                        var values = pair.split("=");
                        convo[values[0]] = decodeURIComponent(values[1]);
                    });
                    return convo;
                }
                /**
                    * Finds the conversation element on the dom based on the supplied conversation's
                    * correspondenceID and subject
                    * @param conversation the Conversation to find
                    */
                FindSelectedConvoOnPage(conversation) {
                    var $allConvos = this.$container.find(".ui-page-conversation");
                    if (starrez.library.utils.IsNotNullUndefined(conversation.correspondentID) && starrez.library.utils.IsNotNullUndefined(conversation.subject)) {
                        // loop through all conversations to find the matching element
                        for (var i = 0; i < $allConvos.length; i++) {
                            var $convo = $($allConvos[i]);
                            var correspondentMatch = Number($convo.data("correspondentid")) === Number(conversation.correspondentID);
                            var subjectMatch = starrez.library.stringhelper.Equals($convo.find(".ui-subject").text(), conversation.subject, false);
                            if (correspondentMatch && subjectMatch) {
                                return $convo;
                            }
                        }
                    }
                    return null;
                }
                AttachConversationClick() {
                    var $convos = this.$container.find(".ui-page-conversation");
                    $convos.SRClick(e => {
                        var $convo = $(e.currentTarget);
                        var $innerContainer = this.$container.find(".ui-messaging-inner-container");
                        this.Highlight($convo);
                        var call = new starrez.service.messaging.GetConversationMessages({
                            pageID: portal.page.CurrentPage.PageID,
                            subject: $convo.find(".ui-subject").text(),
                            otherEntryID: Number($convo.data("correspondentid"))
                        }).Request({ ActionVerb: starrez.library.service.RequestType.Post, UseStandardError: false });
                        call.done(html => {
                            $convo.removeClass(UnreadClasses);
                            $innerContainer.addClass(SelectedClass);
                            $convo.find(".ui-new-message-count").SRHide();
                            this.$messagesContainer.html(html);
                            this.MarkMessagesRead();
                            this.AttachMessageHeaderClick();
                            this.AttachMessageReplyClick();
                            this.AttachMessageForwardClick();
                            this.AttachMessageBackClick();
                            this.$messagesContainer.find(".ui-message-subject").focus();
                            // scroll to top
                            portal.page.CurrentPage.ScrollToTop();
                        }).fail(() => {
                            portal.page.CurrentPage.SetErrorMessage(starrez.model.MessagingPageModel(this.$container).MessageLoadingErrorMessage);
                        });
                    });
                    starrez.keyboard.AttachSelectEvent($convos, (e) => { $(e.target).click(); });
                }
                /**
                    * When in mobile mode, hooks up the back link to take you to the list of conversations
                    */
                AttachMessageBackClick() {
                    var $backButton = this.$messagesContainer.find(".ui-message-back-link");
                    $backButton.SRClick(e => {
                        this.$container.find(".ui-messaging-inner-container").removeClass(SelectedClass);
                    });
                    starrez.keyboard.AttachSelectEvent($backButton, (e) => { $(e.target).click(); });
                }
                /**
                    * Finds all unread messages, retrieves the correspondenceIDs and marks them as "read"
                    */
                MarkMessagesRead() {
                    var $unreadMessages = this.$messagesContainer.find(".ui-message." + UnreadUiClass);
                    // get array of correspondence IDs
                    var unreadCorrespondenceIDs = $unreadMessages.map((index, msg) => {
                        return Number($(msg).data("correspondenceid"));
                    }).toArray();
                    if (unreadCorrespondenceIDs.length > 0) {
                        var call = new starrez.service.messaging.MarkMessagesRead({
                            correspondenceIDs: unreadCorrespondenceIDs
                        }).Request({ ActionVerb: starrez.library.service.RequestType.Post, UseStandardError: false });
                        call.done(totalUnreadRemaining => {
                            // update the navbar with the new unread badge count
                            portal.navigation.NavigationBar.UpdateNavIconBadgeCount(MessagingNavBarIconName, totalUnreadRemaining);
                        }).fail(() => {
                            portal.page.CurrentPage.SetErrorMessage(starrez.model.MessagingPageModel(this.$container).MarkingAsReadErrorMessage);
                        });
                    }
                }
                AttachMessageHeaderClick() {
                    var $collapseButton = this.$messagesContainer.find(".ui-collapse");
                    $collapseButton.SRClick(e => {
                        $(e.currentTarget).closest(".ui-message").toggleClass("collapsed");
                    });
                }
                AttachMessageReplyClick() {
                    var $replyButton = this.$messagesContainer.find(".ui-reply");
                    $replyButton.SRClick(e => {
                        this.RespondToMessage(e, MessageType.Reply);
                    });
                }
                AttachMessageForwardClick() {
                    var $forwardButton = this.$messagesContainer.find(".ui-forward");
                    $forwardButton.SRClick(e => {
                        this.RespondToMessage(e, MessageType.Forward);
                    });
                }
                RespondToMessage(e, type) {
                    var $msg = $(e.currentTarget).closest(".ui-message");
                    var correspondenceID = Number($msg.data("correspondenceid"));
                    var hash = $msg.data("hash").toString();
                    new starrez.service.messaging.GetSendMessageUrl({
                        correspondenceID: correspondenceID,
                        pageID: portal.page.CurrentPage.PageID,
                        hash: hash,
                        messageType: type
                    }).Post().done((url) => {
                        location.href = url;
                    });
                    starrez.library.utils.SafeStopPropagation(e);
                }
                Highlight($convo) {
                    this.$container.find(".ui-highlight").SRUnHighlight();
                    $convo.SRHighlight();
                }
            }
        })(messaging = general.messaging || (general.messaging = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.messaging.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function ComposeMessageModel($sys) {
            return {
                Body: $sys.data('body'),
                MessageType: $sys.data('messagetype'),
                Recipient: $sys.data('recipient'),
                Recipient_EntryID: $sys.data('recipient_entryid'),
                Subject: $sys.data('subject'),
            };
        }
        model.ComposeMessageModel = ComposeMessageModel;
        function MessagingPageModel($sys) {
            return {
                MarkingAsReadErrorMessage: $sys.data('markingasreaderrormessage'),
                MessageLoadingErrorMessage: $sys.data('messageloadingerrormessage'),
            };
        }
        model.MessagingPageModel = MessagingPageModel;
        function MessagingWidgetModel($sys) {
            return {
                MessagingProcessUrl: $sys.data('messagingprocessurl'),
            };
        }
        model.MessagingWidgetModel = MessagingWidgetModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var messaging;
        (function (messaging) {
            "use strict";
            class GetConversationMessages extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Messaging";
                    this.Controller = "messaging";
                    this.Action = "GetConversationMessages";
                }
                CallData() {
                    var obj = {
                        otherEntryID: this.o.otherEntryID,
                        pageID: this.o.pageID,
                        subject: this.o.subject,
                    };
                    return obj;
                }
            }
            messaging.GetConversationMessages = GetConversationMessages;
            class GetPagedConversations extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Messaging";
                    this.Controller = "messaging";
                    this.Action = "GetPagedConversations";
                }
                CallData() {
                    var obj = {
                        currentPageNumber: this.o.currentPageNumber,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            messaging.GetPagedConversations = GetPagedConversations;
            class GetSendMessageUrl extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Messaging";
                    this.Controller = "messaging";
                    this.Action = "GetSendMessageUrl";
                }
                CallData() {
                    var obj = {
                        messageType: this.o.messageType,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        correspondenceID: this.o.correspondenceID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            messaging.GetSendMessageUrl = GetSendMessageUrl;
            class MarkMessagesRead extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Messaging";
                    this.Controller = "messaging";
                    this.Action = "MarkMessagesRead";
                }
                CallData() {
                    var obj = {
                        correspondenceIDs: this.o.correspondenceIDs,
                    };
                    return obj;
                }
            }
            messaging.MarkMessagesRead = MarkMessagesRead;
        })(messaging = service.messaging || (service.messaging = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var mydetails;
        (function (mydetails) {
            "use strict";
            function InitialiseMyDetails($container) {
                new MyDetails($container);
            }
            mydetails.InitialiseMyDetails = InitialiseMyDetails;
            class MyDetails {
                constructor($container) {
                    this.$container = $container;
                    this.AttachEvents();
                    this.model = starrez.model.MyDetailsModel($container);
                }
                AttachEvents() {
                    this.$container.find(".ui-btn-change-password").SRClick((e) => {
                        var call = new starrez.service.mydetails.ChangePassword({ pageID: portal.page.CurrentPage.PageID });
                        ;
                        call.Post().done((result) => {
                            if (starrez.library.convert.ToBoolean(result)) {
                                portal.page.CurrentPage.SetSuccessMessage(this.model.PasswordChangeRequestConfirmationMessage);
                            }
                            else {
                                portal.page.CurrentPage.SetErrorMessage(this.model.PasswordChangeRequestErrorMessage);
                            }
                        });
                    });
                }
            }
            mydetails.MyDetails = MyDetails;
        })(mydetails = general.mydetails || (general.mydetails = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.mydetails.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function MyDetailsModel($sys) {
            return {
                PasswordChangeRequestConfirmationMessage: $sys.data('passwordchangerequestconfirmationmessage'),
                PasswordChangeRequestErrorMessage: $sys.data('passwordchangerequesterrormessage'),
            };
        }
        model.MyDetailsModel = MyDetailsModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var mydetails;
        (function (mydetails) {
            "use strict";
            class ChangePassword extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "MyDetails";
                    this.Controller = "mydetails";
                    this.Action = "ChangePassword";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            mydetails.ChangePassword = ChangePassword;
        })(mydetails = service.mydetails || (service.mydetails = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var ngigradguard;
    (function (ngigradguard) {
        "use strict";
        function Initialise($container) {
            var model = starrez.model.NGIGradGuardModel($container);
        }
        ngigradguard.Initialise = Initialise;
    })(ngigradguard = starrez.ngigradguard || (starrez.ngigradguard = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.ngigradguard.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function NGIGradGuardModel($sys) {
            return {
                CancelledMessage: $sys.data('cancelledmessage'),
                CancelledRedirectText: $sys.data('cancelledredirecttext'),
                DefaultMessage: $sys.data('defaultmessage'),
                DefaultRedirectText: $sys.data('defaultredirecttext'),
                RedirectParameters: $sys.data('redirectparameters'),
                RedirectURL: $sys.data('redirecturl'),
                ResultCustomField: $sys.data('resultcustomfield'),
                SuccessMessage: $sys.data('successmessage'),
                UseEntryCustomField: starrez.library.convert.ToBoolean($sys.data('useentrycustomfield')),
            };
        }
        model.NGIGradGuardModel = NGIGradGuardModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var paymentschedule;
        (function (paymentschedule) {
            var responsive;
            (function (responsive) {
                "use strict";
                let _responsiveActiveTable;
                function InitResponsiveTable($container) {
                    if ($container.find(starrez.activetable.responsive.responsiveTableContainerClass).length) {
                        _responsiveActiveTable = new starrez.activetable.responsive.CustomResponsiveActiveTable($container);
                    }
                }
                responsive.InitResponsiveTable = InitResponsiveTable;
                function Init() {
                    _responsiveActiveTable.Init();
                }
                responsive.Init = Init;
                function SetGetCall(callFunc) {
                    _responsiveActiveTable.SetGetCall(callFunc);
                }
                responsive.SetGetCall = SetGetCall;
                function IsMobile() {
                    return _responsiveActiveTable.IsMobile();
                }
                responsive.IsMobile = IsMobile;
            })(responsive = paymentschedule.responsive || (paymentschedule.responsive = {}));
        })(paymentschedule = general.paymentschedule || (general.paymentschedule = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.paymentschedule.responsive.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var paymentschedule;
        (function (paymentschedule) {
            "use strict";
            function InitPaymentScheduleWidget($container) {
                new PaymentSchedule($container);
            }
            paymentschedule.InitPaymentScheduleWidget = InitPaymentScheduleWidget;
            class PaymentSchedule {
                constructor($container) {
                    this.GetTransactionCall = () => {
                        var $roomRate = this.$container.GetControl("RoomRateID");
                        var roomRate = $roomRate.SRVal();
                        if (starrez.library.utils.IsNotNullUndefined(roomRate)) {
                            return new starrez.service.paymentschedule.GetTransactionRecords({
                                portalPageWidgetID: this.widgetID,
                                rateID: !starrez.library.stringhelper.IsUndefinedOrEmpty(roomRate) ? roomRate : -1,
                                bookingIDs: this.model.BookingIDs,
                                isMobile: portal.general.paymentschedule.responsive.IsMobile(),
                                hash: this.$transactionContainer.data("hash"),
                            });
                        }
                        return null;
                    };
                    this.$container = $container;
                    this.$transactionContainer = $container.find(".ui-payment-schedule-transactions");
                    this.widgetID = Number($container.data("portalpagewidgetid"));
                    this.model = starrez.model.PaymentScheduleModel($container);
                    // Bind responsive table events
                    this.$responsiveTableContainer = $container.find('.ui-responsive-active-table-container');
                    this.$responsiveTableContainer.on(starrez.activetable.responsive.eventTableLoaded, () => {
                        this.BindTable();
                    });
                    this.AttachEvents();
                    portal.general.paymentschedule.responsive.SetGetCall(this.GetTransactionCall);
                    portal.general.paymentschedule.responsive.Init();
                }
                BindTable() {
                    this.paymentScheduleTransactionsTable = starrez.tablesetup.CreateTableManager(this.$container.find(".ui-payment-schedule-transactions table"), $('body'))[0];
                    if (this.paymentScheduleTransactionsTable) {
                        starrez.tablesetup.InitActiveTableEditor(this.paymentScheduleTransactionsTable.$table, () => {
                            this.paymentScheduleTransactionsTable = starrez.tablesetup.CreateTableManager(this.$container.find("ui-payment-schedule-transactions table"), $('body'))[0];
                        });
                    }
                }
                AttachEvents() {
                    var $roomRate = this.$container.GetControl("RoomRateID");
                    $roomRate.change(() => {
                        portal.general.paymentschedule.responsive.SetGetCall(this.GetTransactionCall);
                        portal.general.paymentschedule.responsive.Init();
                    });
                }
            }
        })(paymentschedule = general.paymentschedule || (general.paymentschedule = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.paymentschedulewidget.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var paymentschedule;
        (function (paymentschedule) {
            "use strict";
            function InitSettings($container) {
                new PaymentScheduleModelSettings($container);
            }
            paymentschedule.InitSettings = InitSettings;
            class PaymentScheduleModelSettings {
                constructor($container) {
                    this.$container = $container;
                    this.AttachEvents();
                }
                AttachEvents() {
                    this.$calculationMethod = this.$container.GetControl("CalculationMethod");
                    this.$customMethodConfig = this.$container.GetControl("CustomMethodConfig");
                    this.$proRateName = this.$container.GetControl("ProRateName");
                    this.SetupCalculationMethodchange();
                    this.SetupProRateReservationFilenameChange();
                    // Trigger a change so the dropdowns further down get populated with values	if not already set
                    if (starrez.library.stringhelper.IsUndefinedOrEmpty(this.$calculationMethod.SRVal())) {
                        this.$proRateName.change();
                    }
                    if (starrez.library.stringhelper.IsUndefinedOrEmpty(this.$customMethodConfig.SRVal())) {
                        this.$calculationMethod.change();
                    }
                }
                SetupProRateReservationFilenameChange() {
                    this.$proRateName.change((e) => {
                        var call = new starrez.service.paymentschedule.GetCalculationMethodConfig({
                            proRateReservationDll: this.$proRateName.SRVal()
                        });
                        call.Get().done(json => {
                            starrez.library.controls.dropdown.FillDropDown(json, this.$calculationMethod, "Value", "Text", "", false);
                            this.$calculationMethod.change(); // Need to do this to ensure the next dropdown gets populated
                        });
                    });
                }
                SetupCalculationMethodchange() {
                    this.$calculationMethod.change((e) => {
                        var call = new starrez.service.paymentschedule.GetCustomMethodConfig({
                            proRateName: this.$proRateName.SRVal(),
                            calculationMethod: this.$calculationMethod.SRVal()
                        });
                        call.Get().done(json => {
                            starrez.library.controls.dropdown.FillDropDown(json, this.$customMethodConfig, "Value", "Text", "", false);
                            this.$customMethodConfig.change();
                        });
                    });
                }
            }
        })(paymentschedule = general.paymentschedule || (general.paymentschedule = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.paymentschedulewidgeteditor.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function PaymentScheduleModel($sys) {
            return {
                BookingIDs: ($sys.data('bookingids') === '') ? [] : ($sys.data('bookingids')).toString().split(',').map(function (e) { return Number(e); }),
                HasPleaseSelectRoomRate: starrez.library.convert.ToBoolean($sys.data('haspleaseselectroomrate')),
            };
        }
        model.PaymentScheduleModel = PaymentScheduleModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var paymentschedule;
        (function (paymentschedule) {
            "use strict";
            class GetCalculationMethodConfig extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "PaymentSchedule";
                    this.Controller = "paymentschedule";
                    this.Action = "GetCalculationMethodConfig";
                }
                CallData() {
                    var obj = {
                        proRateReservationDll: this.o.proRateReservationDll,
                    };
                    return obj;
                }
            }
            paymentschedule.GetCalculationMethodConfig = GetCalculationMethodConfig;
            class GetCustomMethodConfig extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "PaymentSchedule";
                    this.Controller = "paymentschedule";
                    this.Action = "GetCustomMethodConfig";
                }
                CallData() {
                    var obj = {
                        calculationMethod: this.o.calculationMethod,
                        proRateName: this.o.proRateName,
                    };
                    return obj;
                }
            }
            paymentschedule.GetCustomMethodConfig = GetCustomMethodConfig;
            class GetTransactionRecords extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "PaymentSchedule";
                    this.Controller = "paymentschedule";
                    this.Action = "GetTransactionRecords";
                }
                CallData() {
                    var obj = {
                        isMobile: this.o.isMobile,
                        rateID: this.o.rateID,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        bookingIDs: this.o.bookingIDs,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            paymentschedule.GetTransactionRecords = GetTransactionRecords;
            class UpdateTransactionRecords extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "PaymentSchedule";
                    this.Controller = "paymentschedule";
                    this.Action = "UpdateTransactionRecords";
                }
                CallData() {
                    var obj = {
                        rateID: this.o.rateID,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        bookingIDs: this.o.bookingIDs,
                        portalPageWidgetID: this.o.portalPageWidgetID,
                    };
                    return obj;
                }
            }
            paymentschedule.UpdateTransactionRecords = UpdateTransactionRecords;
        })(paymentschedule = service.paymentschedule || (service.paymentschedule = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var paymentsvirtualterminal;
    (function (paymentsvirtualterminal) {
        "use strict";
        function InitialiseEntrySearch($container) {
            new EntrySearch($container);
        }
        paymentsvirtualterminal.InitialiseEntrySearch = InitialiseEntrySearch;
        class EntrySearch {
            constructor($container) {
                this.$container = $container;
                this.$searchButton = $container.find(".ui-search-button");
                this.$searchEntryID = $container.GetControl("Search_EntryID");
                this.$id1 = $container.GetControl("ID1");
                this.$nameLast = $container.GetControl("NameLast");
                this.$nameFirst = $container.GetControl("NameFirst");
                this.$dob = $container.GetControl("Dob");
                this.$selectedEntryID = $container.GetControl("Selected_EntryID");
                this.$entryTable = $container.find(".ui-found-entries-table");
                this.$entrySearchModel = starrez.model.EntrySearchModel($container);
                this.AttachButtonEvents();
                this.InitialiseTableEvents();
            }
            AttachButtonEvents() {
                this.$searchButton.SRClick(() => {
                    this.GetEntries();
                });
            }
            InitialiseTableEvents() {
                this.$entryTable.on("click", ".ui-select-entry", (e) => {
                    var entryID = Number($(e.target).closest("tr").data("entry"));
                    this.$selectedEntryID.SRVal(entryID);
                    portal.page.CurrentPage.SubmitPage();
                });
            }
            GetEntries() {
                new starrez.service.entrysearch.GetEntriesSearch({
                    searchEntryID: this.$searchEntryID.SRVal(),
                    id1: this.$id1.SRVal(),
                    nameLast: this.$nameLast.SRVal(),
                    nameFirst: this.$nameFirst.SRVal(),
                    dob: this.$dob.SRVal(),
                    pageID: portal.page.CurrentPage.PageID
                }).Post().done((searchResults) => {
                    this.$entryTable.SRShow();
                    this.$entryTable.html(searchResults);
                });
            }
            ;
        }
    })(paymentsvirtualterminal = starrez.paymentsvirtualterminal || (starrez.paymentsvirtualterminal = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.paymentsvirtualterminal.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function EntrySearchModel($sys) {
            return {
                Selected_EntryID: Number($sys.data('selected_entryid')),
            };
        }
        model.EntrySearchModel = EntrySearchModel;
        function ProxyAccountSummaryModel($sys) {
            return {};
        }
        model.ProxyAccountSummaryModel = ProxyAccountSummaryModel;
        function ProxyShoppingCartCheckoutModel($sys) {
            return {};
        }
        model.ProxyShoppingCartCheckoutModel = ProxyShoppingCartCheckoutModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var entrysearch;
        (function (entrysearch) {
            "use strict";
            class GetEntriesSearch extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "PaymentsVirtualTerminal";
                    this.Controller = "entrysearch";
                    this.Action = "GetEntriesSearch";
                }
                CallData() {
                    var obj = {
                        dob: this.o.dob,
                        id1: this.o.id1,
                        nameFirst: this.o.nameFirst,
                        nameLast: this.o.nameLast,
                        pageID: this.o.pageID,
                        searchEntryID: this.o.searchEntryID,
                    };
                    return obj;
                }
            }
            entrysearch.GetEntriesSearch = GetEntriesSearch;
        })(entrysearch = service.entrysearch || (service.entrysearch = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var printpage;
    (function (printpage) {
        "use strict";
        function InitialisePrintPageWidget($container) {
            var $printButton = $container.find(".ui-print-page");
            $printButton.SRClick(() => {
                window.print();
            });
        }
        printpage.InitialisePrintPageWidget = InitialisePrintPageWidget;
    })(printpage = starrez.printpage || (starrez.printpage = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.general.printpagewidget.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var profiles;
        (function (profiles) {
            "use strict";
            function Initialise($container) {
                var widget = starrez.model.WidgetModelBaseModel($container);
                InitializeProfileWidget($container);
            }
            profiles.Initialise = Initialise;
            function InitializeProfileWidget($container) {
                var portalPageWidgetID = Number($container.data('portalpagewidgetid'));
                $container.data('FormWidget', new ProfileWidget(portalPageWidgetID, $container));
            }
            profiles.InitializeProfileWidget = InitializeProfileWidget;
            class ProfileWidget {
                constructor(portalPageWidgetID, $container) {
                    this.portalPageWidgetID = portalPageWidgetID;
                    this.$container = $container;
                    portal.page.RegisterWidgetSaveData(portalPageWidgetID, () => this.GetSaveData());
                }
                GetSaveData() {
                    var saveData = new starrez.library.collections.KeyValue();
                    var $allControls = this.$container.GetAllControls();
                    $allControls.each((index, element) => {
                        var $control = $(element);
                        var profileID = $control.closest('.ui-profile-data').data('id');
                        var profileValue = $control.SRVal();
                        saveData.Add(profileID, profileValue);
                    });
                    var data = saveData.ToArray();
                    if (data.length === 0) {
                        return null;
                    }
                    return data;
                }
            }
        })(profiles = general.profiles || (general.profiles = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.profiles.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var programming;
        (function (programming) {
            "use strict";
            function InitProgramDetails($container) {
                new ProgramDetailsManager($container);
            }
            programming.InitProgramDetails = InitProgramDetails;
            class ProgramDetailsManager {
                constructor($container) {
                    this.$container = $container;
                    this.programID = starrez.model.ProgramDetailsModel($container).ProgramID;
                    this.$totalAmount = this.$container.find(".ui-quantity-total");
                    this.$qtyControl = this.$container.GetControl("SelectedQuantity");
                    this.getTotalAmountHash = this.$qtyControl.closest("li").data("hash").toString();
                    this.$qtyControl.on("change", (e) => {
                        var qty = Number(this.$qtyControl.SRVal());
                        var call = new starrez.service.programming.GetTotalAmount({
                            pageID: portal.page.CurrentPage.PageID,
                            programID: this.programID,
                            quantity: qty,
                            hash: this.getTotalAmountHash
                        });
                        call.Post().done((amount) => {
                            this.$totalAmount.text(amount);
                        });
                    });
                }
            }
            programming.ProgramDetailsManager = ProgramDetailsManager;
        })(programming = general.programming || (general.programming = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.programming.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function ProgramDetailsModel($sys) {
            return {
                ProgramID: Number($sys.data('programid')),
            };
        }
        model.ProgramDetailsModel = ProgramDetailsModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var programming;
        (function (programming) {
            "use strict";
            class GetTotalAmount extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Programming";
                    this.Controller = "programming";
                    this.Action = "GetTotalAmount";
                }
                CallData() {
                    var obj = {
                        quantity: this.o.quantity,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        programID: this.o.programID,
                    };
                    return obj;
                }
            }
            programming.GetTotalAmount = GetTotalAmount;
        })(programming = service.programming || (service.programming = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var promocodes;
        (function (promocodes) {
            "use strict";
            function InitialisePromoCodesWidget($container) {
                var portalPageWidgetID = Number($container.data("portalpagewidgetid"));
                var $promoCode = $container.GetControl("PromoCode");
                var $apply = $container.find(".ui-apply-promocode");
                $container.keydown(e => {
                    if (e.keyCode === starrez.keyboard.EnterCode) {
                        // The browsers have a behaviour where they will automatically submit the form if there is only one
                        // input field on it. This is not what we want to do, so call SafeStopPropagation to block this from happening.
                        // http://stackoverflow.com/questions/1370021/why-does-forms-with-single-input-field-submit-upon-pressing-enter-key-in-input
                        starrez.library.utils.SafeStopPropagation(e);
                        $apply.click();
                    }
                });
                $apply.SRClick(() => {
                    new starrez.service.promocodes.ApplyPromoCode({
                        portalPageWidgetID: portalPageWidgetID,
                        processID: portal.page.CurrentPage.ProcessID,
                        promoCode: $promoCode.SRVal()
                    }).Post().done((result) => {
                        if (result.Message.trim().length > 0) {
                            if (result.IsSuccess) {
                                var model = starrez.model.PromoCodesModel($container);
                                if (model.ReloadPageOnSuccess) {
                                    location.reload();
                                }
                                else {
                                    portal.page.CurrentPage.SetSuccessMessage(result.Message);
                                }
                            }
                            else if (portal.Feature.PortalXFormControls) {
                                portal.page.CurrentPage.ClearMessages();
                                portal.page.CurrentPage.AddErrorMessages([
                                    {
                                        field: $promoCode.SRName(),
                                        rulename: result.Message,
                                        type: 'StudentFacingDataError',
                                        extrainfo: ""
                                    }
                                ]);
                            }
                            else {
                                portal.page.CurrentPage.SetErrorMessage(result.Message);
                            }
                        }
                    });
                    $promoCode.on('keydown', (event) => {
                        if (event.key === 'Enter') {
                            event.preventDefault();
                        }
                    });
                });
            }
            promocodes.InitialisePromoCodesWidget = InitialisePromoCodesWidget;
        })(promocodes = general.promocodes || (general.promocodes = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.promocodes.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function PromoCodesModel($sys) {
            return {
                ReloadPageOnSuccess: starrez.library.convert.ToBoolean($sys.data('reloadpageonsuccess')),
            };
        }
        model.PromoCodesModel = PromoCodesModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var promocodes;
        (function (promocodes) {
            "use strict";
            class ApplyPromoCode extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "PromoCodes";
                    this.Controller = "promocodes";
                    this.Action = "ApplyPromoCode";
                }
                CallData() {
                    var obj = {
                        portalPageWidgetID: this.o.portalPageWidgetID,
                        processID: this.o.processID,
                        promoCode: this.o.promoCode,
                    };
                    return obj;
                }
            }
            promocodes.ApplyPromoCode = ApplyPromoCode;
        })(promocodes = service.promocodes || (service.promocodes = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var proxy;
    (function (proxy) {
        "use strict";
        function InitProxyAgreementPage($container) {
            "use strict";
            new ProxyAgreement($container);
        }
        proxy.InitProxyAgreementPage = InitProxyAgreementPage;
        function InitProxyPage($container) {
            "use strict";
            new ProxyPageModel($container);
        }
        proxy.InitProxyPage = InitProxyPage;
        let ProxyMessageType;
        (function (ProxyMessageType) {
            ProxyMessageType[ProxyMessageType["ProxyComplete"] = 0] = "ProxyComplete";
            ProxyMessageType[ProxyMessageType["ProxyNew"] = 1] = "ProxyNew";
            ProxyMessageType[ProxyMessageType["ProxySuccess"] = 2] = "ProxySuccess";
        })(ProxyMessageType || (ProxyMessageType = {}));
        // This class is setup to be dynamically bound, as the table will load asynchronously
        class ProxyAgreement {
            constructor($container) {
                this.$container = $container;
                this.pageID = portal.page.CurrentPage.PageID;
                this.proxyAgreementModel = starrez.model.ProxyAgreementModel($container);
                this.$addProxyButton = $container.find('.ui-add-proxy');
                this.maximumProxies = this.proxyAgreementModel.MaximumProxies;
                this.deleteProxyConfirmText = this.proxyAgreementModel.DeleteProxyConfirmText;
                this.refreshProxyConfirmText = this.proxyAgreementModel.RefreshProxyConfirmText;
                this.maximumProxiesErrorNotification = $container.find('.ui-maximum-proxies-error');
                this.deleteProxyErrorMessage = this.proxyAgreementModel.DeleteProxyErrorMessage;
                this.deleteCompleteProxyErrorMessage = this.proxyAgreementModel.DeleteCompleteProxyErrorMessage;
                this.refreshProxyErrorMessage = this.proxyAgreementModel.RefreshProxyErrorMessage;
                this.refreshCompleteProxyErrorMessage = this.proxyAgreementModel.RefreshCompleteProxyErrorMessage;
                this.deleteProxySuccessMessage = this.proxyAgreementModel.DeleteProxySuccessMessage;
                this.refreshProxySuccessMessage = this.proxyAgreementModel.RefreshProxySuccessMessage;
                // Bind responsive table events
                this.$responsiveTableContainer = $container.find('.ui-responsive-active-table-container');
                this.$responsiveTableContainer.on(starrez.activetable.responsive.eventTableLoaded, () => {
                    this.BindTable();
                });
            }
            IsMobile() {
                return this.$responsiveTableContainer.data('isMobile') === true;
            }
            GetRowSelector() {
                return this.IsMobile() ? "tbody" : "tbody tr";
            }
            GetRows() {
                return this.proxyTable.$table.find(this.GetRowSelector());
            }
            BindTable() {
                this.$proxyTableDiv = this.$container.find(".ui-proxy-table");
                this.proxyTable = starrez.tablesetup.CreateTableManager(this.$container.find(".ui-proxy-table table"), $('body'))[0];
                this.AttachClickEvents();
                this.AttachRowEvents();
                this.ProxyLimitReachedCheck();
            }
            AttachClickEvents() {
                this.$addProxyButton.SRClick(() => {
                    this.RedirectToProxyPage();
                });
            }
            AttachRowEvents() {
                starrez.tablesetup.InitActiveTableEditor(this.proxyTable.$table, () => {
                    this.proxyTable = starrez.tablesetup.CreateTableManager(this.$container.find(".ui-proxy-table table"), $('body'))[0];
                    this.AttachRowEvents();
                });
                this.proxyTable.$table.SRClickDelegate('delete', '.ui-btn-delete', (e) => {
                    portal.ConfirmAction(this.deleteProxyConfirmText, "Delete Proxy").done(() => {
                        var $row = $(e.currentTarget).closest(this.GetRowSelector());
                        var id = Number($row.data('id'));
                        var hash = $row.data('deletehash').toString();
                        new starrez.service.proxy.DeleteProxy({
                            entryApplicationProxyID: id,
                            hash: hash
                        }).Post().done((isDeleted) => {
                            var deleteType = ProxyMessageType[isDeleted];
                            var studentFacingErrors = [];
                            if (deleteType == ProxyMessageType.ProxyComplete) {
                                studentFacingErrors.push(this.deleteCompleteProxyErrorMessage);
                            }
                            if (deleteType == ProxyMessageType.ProxyNew) {
                                studentFacingErrors.push(this.deleteProxyErrorMessage);
                            }
                            if (studentFacingErrors.length > 0) {
                                portal.page.CurrentPage.SetErrorMessages(studentFacingErrors);
                            }
                            if (deleteType == ProxyMessageType.ProxySuccess) {
                                portal.page.CurrentPage.SetSuccessMessage(this.deleteProxySuccessMessage);
                                this.proxyTable.RemoveRows($row);
                                this.ProxyLimitReachedCheck();
                            }
                        });
                    });
                });
                this.proxyTable.$table.SRClickDelegate('refresh', '.ui-btn-refresh', (e) => {
                    portal.ConfirmAction(this.refreshProxyConfirmText, "Refresh Proxy").done(() => {
                        var $row = $(e.currentTarget).closest(this.GetRowSelector());
                        var id = Number($row.data('id'));
                        var hash = $row.data('refreshhash').toString();
                        new starrez.service.proxy.RefreshProxy({
                            pageID: portal.page.CurrentPage.PageID,
                            entryApplicationProxyID: id,
                            hash: hash
                        }).Post().done((isRefreshed) => {
                            var refreshType = ProxyMessageType[isRefreshed];
                            var studentFacingErrors = [];
                            if (refreshType == ProxyMessageType.ProxyComplete) {
                                studentFacingErrors.push(this.refreshCompleteProxyErrorMessage);
                            }
                            if (refreshType == ProxyMessageType.ProxyNew) {
                                studentFacingErrors.push(this.refreshProxyErrorMessage);
                            }
                            if (studentFacingErrors.length > 0) {
                                portal.page.CurrentPage.SetErrorMessages(studentFacingErrors);
                            }
                            if (refreshType == ProxyMessageType.ProxySuccess) {
                                new starrez.service.proxy.GetProxyTable({
                                    activeTableKey: this.proxyTable.$table.data("pageable-object"),
                                    pageID: portal.page.CurrentPage.PageID,
                                }).Post().done((results) => {
                                    this.$responsiveTableContainer.trigger(starrez.activetable.responsive.eventTableRefresh);
                                });
                                portal.page.CurrentPage.SetSuccessMessage(this.refreshProxySuccessMessage);
                            }
                        });
                    });
                });
            }
            ProxyLimitReachedCheck() {
                if (this.maximumProxies > 0 && this.GetRows().length >= this.maximumProxies) {
                    this.$addProxyButton.Disable();
                    this.maximumProxiesErrorNotification.SRShow();
                }
                else {
                    this.$addProxyButton.Enable();
                    this.maximumProxiesErrorNotification.SRHide();
                }
            }
            RedirectToProxyPage() {
                new starrez.service.proxy.AddNewProxy({
                    pageID: this.pageID,
                    index: this.GetRows().length,
                }).Post().done((results) => {
                    if (results != null) {
                        location.href = results;
                    }
                });
            }
        }
        class ProxyPageModel {
            constructor($container) {
                this.$container = $container;
                this.proxyPageModel = starrez.model.ProxyFormModel($container);
                this.inProxyMode = this.proxyPageModel.InProxyMode;
                this.recordID = this.proxyPageModel.EntryApplicationProxyID;
                this.detailsErrorMessage = this.proxyPageModel.MatchCustomErrorMessage;
                this.$matchingWidgetFields = $container.find('.ui-matching-widget').GetAllControls();
                portal.page.CurrentPage.FetchAdditionalWidgetData = () => this.GetData();
                portal.page.CurrentPage.AddCustomValidation(this);
            }
            Validate() {
                var deferred = $.Deferred();
                var values = [];
                if (this.inProxyMode) {
                    this.$matchingWidgetFields.each((i, e) => {
                        values.push({
                            Key: $(e).closest('.ui-field-record').data('fieldname'),
                            Value: $(e).SRVal()
                        });
                    });
                    new starrez.service.proxy.MatchProxy({
                        values: values,
                        entryApplicationProxyID: this.recordID
                    }).Post().done((isValid) => {
                        if (starrez.library.convert.ToBoolean(isValid)) {
                            deferred.resolve();
                        }
                        else {
                            portal.page.CurrentPage.SetErrorMessage(this.detailsErrorMessage);
                            deferred.reject();
                        }
                    });
                }
                else {
                    deferred.resolve();
                }
                return deferred.promise();
            }
            GetData() {
                return {
                    Key: "RecordID",
                    Value: this.recordID.toString()
                };
            }
        }
    })(proxy = portal.proxy || (portal.proxy = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.proxy.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function ProxyAgreementModel($sys) {
            return {
                DeleteCompleteProxyErrorMessage: $sys.data('deletecompleteproxyerrormessage'),
                DeleteProxyConfirmText: $sys.data('deleteproxyconfirmtext'),
                DeleteProxyErrorMessage: $sys.data('deleteproxyerrormessage'),
                DeleteProxySuccessMessage: $sys.data('deleteproxysuccessmessage'),
                MaximumProxies: Number($sys.data('maximumproxies')),
                MaximumProxiesErrorMessage: $sys.data('maximumproxieserrormessage'),
                RefreshCompleteProxyErrorMessage: $sys.data('refreshcompleteproxyerrormessage'),
                RefreshProxyConfirmText: $sys.data('refreshproxyconfirmtext'),
                RefreshProxyErrorMessage: $sys.data('refreshproxyerrormessage'),
                RefreshProxySuccessMessage: $sys.data('refreshproxysuccessmessage'),
            };
        }
        model.ProxyAgreementModel = ProxyAgreementModel;
        function ProxyFormModel($sys) {
            return {
                EntryApplicationProxyID: Number($sys.data('entryapplicationproxyid')),
                InProxyMode: starrez.library.convert.ToBoolean($sys.data('inproxymode')),
                MatchCustomErrorMessage: $sys.data('matchcustomerrormessage'),
            };
        }
        model.ProxyFormModel = ProxyFormModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var proxy;
        (function (proxy) {
            "use strict";
            class AddNewProxy extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Proxy";
                    this.Controller = "proxy";
                    this.Action = "AddNewProxy";
                }
                CallData() {
                    var obj = {
                        index: this.o.index,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            proxy.AddNewProxy = AddNewProxy;
            class DeleteProxy extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Proxy";
                    this.Controller = "proxy";
                    this.Action = "DeleteProxy";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        entryApplicationProxyID: this.o.entryApplicationProxyID,
                    };
                    return obj;
                }
            }
            proxy.DeleteProxy = DeleteProxy;
            class GetProxyTable extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Proxy";
                    this.Controller = "proxy";
                    this.Action = "GetProxyTable";
                }
                CallData() {
                    var obj = {
                        activeTableKey: this.o.activeTableKey,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            proxy.GetProxyTable = GetProxyTable;
            class MatchProxy extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Proxy";
                    this.Controller = "proxy";
                    this.Action = "MatchProxy";
                }
                CallData() {
                    var obj = {
                        entryApplicationProxyID: this.o.entryApplicationProxyID,
                        values: this.o.values,
                    };
                    return obj;
                }
            }
            proxy.MatchProxy = MatchProxy;
            class RefreshProxy extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Proxy";
                    this.Controller = "proxy";
                    this.Action = "RefreshProxy";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        entryApplicationProxyID: this.o.entryApplicationProxyID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            proxy.RefreshProxy = RefreshProxy;
        })(proxy = service.proxy || (service.proxy = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
/*! rxp-js - v1.3.1 - 2018-08-30
 * The official Realex Payments JS Library
 * https://github.com/realexpayments/rxp-js
 * Licensed MIT
 */

var RealexHpp = function () { "use strict"; var g, d, i, n, A, l = "https://pay.realexpayments.com/pay", I = I || Math.random().toString(16).substr(2, 8), e = /Windows Phone|IEMobile/.test(navigator.userAgent), t = /Android|iPad|iPhone|iPod/.test(navigator.userAgent), o = (0 < window.innerWidth ? window.innerWidth : screen.width) <= 360 || (0 < window.innerHeight ? window.innerHeight : screen.Height) <= 360, E = e, C = !e && (t || o), h = { createFormHiddenInput: function (e, t) { var A = document.createElement("input"); return A.setAttribute("type", "hidden"), A.setAttribute("name", e), A.setAttribute("value", t), A }, checkDevicesOrientation: function () { return 90 === window.orientation || -90 === window.orientation }, createOverlay: function () { var e = document.createElement("div"); return e.setAttribute("id", "rxp-overlay-" + I), e.style.position = "fixed", e.style.width = "100%", e.style.height = "100%", e.style.top = "0", e.style.left = "0", e.style.transition = "all 0.3s ease-in-out", e.style.zIndex = "100", E && (e.style.position = "absolute !important", e.style.WebkitOverflowScrolling = "touch", e.style.overflowX = "hidden", e.style.overflowY = "scroll"), document.body.appendChild(e), setTimeout(function () { e.style.background = "rgba(0, 0, 0, 0.7)" }, 1), e }, closeModal: function (e, t, A, i) { e && e.parentNode && e.parentNode.removeChild(e), t && t.parentNode && t.parentNode.removeChild(t), A && A.parentNode && A.parentNode.removeChild(A), i && (i.className = "", setTimeout(function () { i.parentNode && i.parentNode.removeChild(i) }, 300)) }, createCloseButton: function (e) { if (null === document.getElementById("rxp-frame-close-" + I)) { var t = document.createElement("img"); return t.setAttribute("id", "rxp-frame-close-" + I), t.setAttribute("src", "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAYAAAA7bUf6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QUJFRjU1MEIzMUQ3MTFFNThGQjNERjg2NEZCRjFDOTUiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QUJFRjU1MEMzMUQ3MTFFNThGQjNERjg2NEZCRjFDOTUiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBQkVGNTUwOTMxRDcxMUU1OEZCM0RGODY0RkJGMUM5NSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBQkVGNTUwQTMxRDcxMUU1OEZCM0RGODY0RkJGMUM5NSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PlHco5QAAAHpSURBVHjafFRdTsJAEF42JaTKn4glGIg++qgX4AAchHAJkiZcwnAQD8AF4NFHCaC2VgWkIQQsfl/jNJUik8Duzs/XmW9mN7Xb7VRc5vP5zWKxaK5Wq8Zmu72FqobfJG0YQ9M0+/l8/qFQKDzGY1JxENd1288vLy1s786KRZXJZCLber1Wn7MZt4PLarVnWdZ9AmQ8Hncc17UvymVdBMB/MgPQm+cFFcuy6/V6lzqDf57ntWGwYdBIVx0TfkBD6I9M35iRJgfIoAVjBLDZbA4CiJ5+9AdQi/EahibqDTkQx6fRSIHcPwA8Uy9A9Gcc47Xv+w2wzhRDYzqdVihLIbsIiCvP1NNOoX/29FQx3vgOgtt4FyRdCgPRarX4+goB9vkyAMh443cOEsIAAcjncuoI4TXWMAmCIGFhCQLAdZ8jym/cRJ+Y5nC5XCYAhINKpZLgSISZgoqh5iiLQrojAFICVwGS7tCfe5DbZzkP56XS4NVxwvTI/vXVVYIDnqmnnX70ZxzjNS8THHooK5hMpxHQIREA+tEfA9djfHR3MHkdx3Hspe9r3B+VzWaj2RESyR2mlCUE4MoGQDdxiwHURq2t94+PO9bMIYyTyDNLwMoM7g8+BfKeYGniyw2MdfSehF3Qmk1IvCc/AgwAaS86Etp38bUAAAAASUVORK5CYII="), t.setAttribute("style", "transition: all 0.5s ease-in-out; opacity: 0; float: left; position: absolute; left: 50%; margin-left: 173px; z-index: 99999999; top: 30px;"), setTimeout(function () { t.style.opacity = "1" }, 500), E && (t.style.position = "absolute", t.style.float = "right", t.style.top = "20px", t.style.left = "initial", t.style.marginLeft = "0px", t.style.right = "20px"), t } }, createForm: function (e, t, A) { var i = document.createElement("form"); i.setAttribute("method", "POST"), i.setAttribute("action", l); var n = !1; for (var o in t) "HPP_VERSION" === o && (n = !0), i.appendChild(h.createFormHiddenInput(o, t[o])); if (!1 === n && i.appendChild(h.createFormHiddenInput("HPP_VERSION", "2")), A) i.appendChild(h.createFormHiddenInput("MERCHANT_RESPONSE_URL", d)); else { var r = h.getUrlParser(window.location.href), a = r.protocol + "//" + r.host; i.appendChild(h.createFormHiddenInput("HPP_POST_RESPONSE", a)), i.appendChild(h.createFormHiddenInput("HPP_POST_DIMENSIONS", a)) } return i }, createSpinner: function () { var e = document.createElement("img"); return e.setAttribute("src", "data:image/gif;base64,R0lGODlhHAAcAPYAAP////OQHv338fzw4frfwPjIkPzx4/nVq/jKlfe7dv337/vo0fvn0Pzy5/WrVv38+vjDhva2bfzq1fe/f/vkyve8d/WoT/nRpP327ve9e/zs2vrWrPWqVPWtWfvmzve5cvazZvrdvPjKlPfAgPnOnPvp0/zx5fawYfe+ff317PnTp/nMmfvgwvfBgv39/PrXsPSeO/vjx/jJkvzz6PnNm/vkyfnUqfjLl/revvnQoPSfPfSgP/348/nPnvratfrYsvWlSvSbNPrZs/vhw/zv4P306vrXrvzq1/359f369vjHjvSjRvOXLfORIfOQHvjDh/rduvSaM/jEifvlzPzu3v37+Pvixfzr2Pzt3Pa1afa3b/nQovnSpfaxYvjFi/rbt/rcufWsWPjGjfSjRPShQfjChPOUJva0aPa2a/awX/e6dPWnTfWkSPScNve4cPWpUfSdOvOSI/OVKPayZPe9efauW/WpUvOYL/SiQ/OZMfScOPOTJfavXfWmSwAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAHAAcAAAH/4AAgoOEhYaHiIUKKYmNh0ofjoklL4RLUQ+DVZmSAAswOYIKTE1UglUCVZ0AGBYwPwBHTU44AFU8PKuCEzpARB5OTjYAPEi5jQYNgzE7QS1ET1JTD7iqgi6chAcOFRsmABUQBoQuSAIALjwpMwqHCBYcJyrHhulF9xiJFx0WMo0Y99o18oBCWSIXKZI0eoBhkaQHEA0JIIAAQoYPKiSlwIKFyIAUnAYUSBAhAogVkmZc0aChIz0ACiQQCLFAEhIMKXhkO8RiRqMqBnYe0iAigwoXiah4KMEI0QIII1rQyHeoypUFWH0aWjABAgkPLigIKUIIiQQNrDQs8EC2EAMKBlIV9EBgRAHWFEes1DiWpIjWRDVurCCCBAqUGUhqxEC7yoUNBENg4sChbICVaasw3PCBNAkLHAI1DBEoyQSObDGGZMPyV5egElNcNxJAVbZtQoEAACH5BAkKAAAALAAAAAAcABwAAAf/gACCg4SFhoeIhUVFiY2HYlKOiUdDgw9hDg+DPjWSgh4WX4JYY2MagipOBJ4AGF0OnTVkZDEAX05mDawAXg5dGCxBQQRFTE5djkQYgwxhFghYSjIDZU6qgy6ahS8RSj6MEyImhAoFHYJJPAJIhz1ZERVfCi6HVelISDyJNloRCI08ArJrdEQKEUcKtCF6oEDBDEkPIhoSwEKFDCktDkhyuAgDD3oADOR40qIFCi4bZywqkqIKISRYKAwpIalKwCQgD7kYMi6RC0aOsGxB8KLRDA1YBCQqsaLpBqU6DSDVsMzQFRkkXhwBcIUBVHREDmIYgOWKAkMMSpwFwINAiCkCTI5cEaCBwYKBVTAAnYQjBAYFVqx4XLBgwK6dIa4AUFCjxjIDDCTkdIQBzAJBPBrrA0DFw2ZJM2gKcjGFgsIBa3cNOrJVdaKArmMbCgQAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iFRSmJjYckK46JEjWECWqEQgSSghJnIYIzaSdFghdRQ5wAPBlalRIdHUcALzBrGKoAPVoJPBQWa1MNbDsJjgOMggtaaDkaCDREKG06OIMDHoYhEzRgpTQiWIQmCJhUEGxOT4dGEy1SYMmGLgVmTk5uiWBlLTQuiSTutXBERcSVRi5OWEtUBUMKE6r+FeJR48cFEjdeSEoigIfHJBIb/MixYgWCDZKQeFz5gFAVE0cWHHRUJUmSKhIRHSnVCENORCZYhJjys5CAGUWQJCISAsdQHolSLCoC1ZABMASmGACApYQCQg+kAkCCocgMpYWIGEBLMQYDBVRMiPAwoUFDEkEPPDrCUiOGAAUePCioogFLg1wuPMSgAkDAggUCAMzQwFiVgCEzkzy+C6DBFbSSiogbJEECoQZfcxEiUlk1IpWuYxsKBAAh+QQJCgAAACwAAAAAHAAcAAAH/4AAgoOEhYaHiIUzDYmNhxckjolXVoQQIy6DX5WSAFQZIYIKFQlFgjZrU50ASUojMZ4fblcAUBxdCqsALy1PKRpoZ0czJ2FKjgYpmQBEZSNbAys5DUpvDh6CVVdDy4M1IiohMwBcKwOEGFwQABIjYW3HhiwIKzQEM0mISmQ7cCOJU2is4PIgUQ44OxA4wrDhSKMqKEo0QpJCQZFuiIqwmGKiUJIrMQjgCFFDUggnTuKQKWNAEA8GLHCMLOkIB0oncuZgIfTAYooUkky8CLEASaIqwxzlczSjRgwGE3nwWHqISAynEowiEsADSddDBoZQOAKUigYehQQAreJVgFZCM1JSVBGEZMGCK1UapEiCoUiRpS6qzG00wO5UDVd4PPCba5ULCQw68tBwFoAAvxgbCfBARNADLFgGK8C3CsO5QUSoEFLwVpcgEy1dJ0LSWrZtQYEAACH5BAkKAAAALAAAAAAcABwAAAf/gACCg4SFhoeIhRgziY2HQgeOiUQ1hDcyLoNgFJKCJiIEggpSEIwALyALnQBVFzdTAANlZVcAQxEVCqsABCs0ClgTKCUCFVo9jg0pVYIpNDc/VBcqRFtZWrUASAtDhlhgLCUpAFAq2Z4XJAAaK2drW4dHITg4CwrMhg8IHQ52CIlUCISw8iARlzd1IjVCwsBEowciBjRKogDDOEdEQsSgUnAQEg0MasSwwkCSiig7loRBcURQEg0eatQgKekASjwcMpQohCRFkYuNDHwhcCVJoipYMDhSosHRjAULWib64STOjUQGGEDVgO8QHSdgMxxq4KEEFQEAZhjo6JEHAAZqUu44EWNIgQB8LzWYqKJAQRIegDsqiPElGRauSWbMQOKCBxK3q1xQ0VCEVZEiSAD85ZGpE5IrDgE8uIwPyd1VAkw1q+yx6y5RSl8nesBWtu1BgQAAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iFGEWJjYcEX46JDUeEG1sPgwQlkoIYUAuCPD00M4JfGVedAC5DIRoAMzQrWAA1I14CqwBHODg8JggiVwpPLQeORSlVor4UJj8/RDYTZUSCAiUxLoUGQxRHGABXMSaEA1wqABoXdCAvh0QxNTUlPNyGSDluWhHqiCYoxPCQCRGXLGrAOEoiwVQiJBdSNEKiAIM4R1SGTCFSUFASKhIWLGCgypGKNWHqoJECC0CSAUdEMmjZaMOaDmncILhGKIkABbocmfAgoUGjByaQOGrBwFEKLBrMJbIBh4yMSRqgmsB3CAKZHXAyHCpyBUtSABa5sjoAAoAECG9QgngxJAAJvgdF8lbhwQOAEidOYghSMCVEx0MK8j7Ye4+IHCdzdgHIq+sBX2YHnJhxKCnJjIsuBPAo+BfKqiQKCPEllCOS5EFIlL5OpHa27UAAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iFPBiJjYdXDI6JAlSENUMugx4akoJIVpwAVQQ4AoI1Mgadgh5WRAAKOCENAEc3PTyrABo1NQICIVAzPD00Qo4YCg+evR4YFBRFQjcrA4JJWAuGMx4lVAoAV1O0g1QbPgADP0oZYIcmDAsLGjyZhikqZS0Tx4gz8hLsGXJxYQQEAo6SaDCVCMMFE40e8ECSRJKBI0eKCASQxAQRLBo0WHPE5YwbNS1oVOLoEeQViI6MmEwwgsYrQhIpSiqi4UqKjYUeYAAaVMkRRzyKFGGU6IedDjYSKSiSgirRQTLChLGD4JCAGUsrTixU5QCdWivOrNliiKI9iRNNZ3wBY0KKHh1DPJVggRRJrhhOnBgxwIYMGl0AeIw9EjgEACMw2JCT5EKxIAxynFwRhCBKjFUSCQHJs0xQjy+ICbXoUuhqJyIlUss2FAgAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iFVQKJjYdEDI6JPESECzVVg0RUkoJVHliCLlMxCoJUYAadglcMAwBJFDFFAA0hBEirACYLCwpJMVYNDyw4U44CPA+CSb0SPAsMKUdQIaqwDVguhQpXWAOmJhIYhBhTx0UhWyIEhykaWBoGSYgKUCQrCCGJCvHXhy583FhRw1GVBvQSpRAyo1GVJFUyORpw5IqBXINcYCjCsUgKST9QlCkjhss1jR1nfHT0BQUEKQUOmCjk4gFESSkGmEixDJELZY14iDjiKAkPJDwa+UDjZkMipEgZIUqyIYGWLDR6EkqSjEcmJTeSDuLxY8QuLi2ybDFUReuAPU5W+KTgkkOCCgsc9gF4wEvrISlOnLAgAiePCgFnHKDQBQCIkycADADR4QPAFAd8Gqwy4ESLIAF2dlAQ5KMPlFULpBACgUezIChfGBOiAUJ2oiJXbOsmFAgAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iFDzyJjYcNEo6JSAaEGgtJgyZEkoIPGgODEgwKggZDJp2CAxoNAA8lDEUAKTE1jKopWBoKDwsMMw9TNQuOSUkuglVYWERJWFe6VjGuAFUKJsmESDNFKUgAGAaZgwKxAAILLFDFhjzeRUVViEgSBDghDJPxKY0LISGuOHKBYd4kD6USPVj4QJIJKkQakBvEo2JFAZJCiFhBI4eQVIKQWKwoCQcCGj0ufJlRyEXDTkVmzOiViIgblokU0IjU6EUeJy0a/ZjQQshLQ1ucKE2Dy5ACMFJaTLhgkNAXJ3m6DAFwwwtOQQpeeAnnA8EEG4Y8MMBlgA2cEylSVORY8OVMhBCDihw5emiFDh1gFITp8+LBCC1jVQE40+YJAAUgOOA94sZNqE4mYKiZVyWCA30ArJzB20mClKMtOnylAEVxIR8VXDfiQUW2bUOBAAAh+QQJCgAAACwAAAAAHAAcAAAH/4AAgoOEhYaHiIUuAomNhwpUjokPKYQGGkmDKSaSgi4zlYJUGowAMx4NnYIYRZVVWFiVCgsLPKoAAkVFSA8aGhgAJQtHjg9VLp6tM0kNJjwGDAupAC48RciEVQI8PJkCKdiCrxIASRpTVuSGSTxIPAJViElYNTUxJYna7o1HMTEakqo8aMTDg4JGM6aAYSApRYoiAsIBwABhzB4nTiZIkgAFB44hDGYIUgCBjRyMGh1x9GglZCEMC4ZckYRBQRFbiTDQAZgohQ0ijkKs0TOiEZQbKwhIJLRBxw4dXaYZwmClx4obP5YCINCGTZYQAIx4CTVyg4xqLLggEGLIA4VpCldAcNDS4AIJBkNQtGAhiBKRgYmMOHDAQoGWM2AAyCiz4haAEW+8TKygBSyWMmUMqOJRpwWyBy0iUBDkIQPfTiZIxBNEA41mQRIIOCYUo8zsRDx43t4tKBAAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iGSYmMh0gzjYkuPIQYRQ+DPA2RgwKUgilFSIICV5ucAEhIn6ECqVgarqhJPDyLRUUKAFRYVI1HMZAALgJIAg8KGDwKGlinAEkKLoU1Tnt1BABVAtOEKb4PBhIMR4c+cU5OaymILiYlCwtHmIcxQU4fjAYMDFjdiApQSGBU5QgGRjOmEFgQCUMKZf8AKLgBAgiZNvkaURkSo8aUI+wAYJDSYcyONloibexIoYQwQS6oEPgxpOGMXPQOPdjCMFESCgcZHdFiYUROQ0dChCgRkRCFOg4cRMCCiIcGAjhCUDgq6AiHDhWyxShAhJACKFweJJHAAgoFQ1dfrAwQlKRMhAwpfnCZMkXEihqCHmAwUIXRkAgRoLiQgsIHABsrVDRl1OPMDQAPZIzAAcAEjRVzOT2gI+XTjREMBF0RUZMThhyyAGyYYGCQhtaoCJVQMjk3ISQafAtHFAgAIfkECQoAAAAsAAAAABwAHAAAB/+AAIKDhIWGh4iGD4mMh1UCjYkNXlWDSQKVgo+Rgkl3HZkCSEmdMwqcgnNOWoI8SDwAD0VFSKgAP05ONgACPLApKUUujAsesABIek46CkmuAjNFp4IPPIuEQ3p2dDgAJBEmhdAuLikDGljDhTY6OjtZM4guAlRYWFSZhmB9cF3Xhxg0aBjw75ABNVYaGcDACEkDA+EaVUmSJJ8gF2AmgDgRBkWkGQwWlJBA5ViSG3PqOHiTIFIDDwtESkhBqAqRKTgoROJRJAUmRlA8MHoggSEjA16yQKiFiEqMGFgSXaETQcsEKoiSYIlRI0YJdYRMuIkgxYcLCSs0gEVyxcq8K1NhhpQwxCDEgEE3WrQggsPHFCpQcGCNlYKIRUNXyrTA4aIHAigArOAYUrDRhgk0yF1YQQBAChwhGqB6IEbJNCMIpggaAOYKKgwXjAJggSAiAANHbBW6kgMsAN+6q7jWTfxQIAA7AAAAAAAAAAAA"), e.setAttribute("id", "rxp-loader-" + I), e.style.left = "50%", e.style.position = "fixed", e.style.background = "#FFFFFF", e.style.borderRadius = "50%", e.style.width = "30px", e.style.zIndex = "200", e.style.marginLeft = "-15px", e.style.top = "120px", e }, createIFrame: function (e, t) { var A = h.createSpinner(); document.body.appendChild(A); var i, n = document.createElement("iframe"); if (n.setAttribute("name", "rxp-frame-" + I), n.setAttribute("id", "rxp-frame-" + I), n.setAttribute("height", "562px"), n.setAttribute("frameBorder", "0"), n.setAttribute("width", "360px"), n.setAttribute("seamless", "seamless"), n.style.zIndex = "10001", n.style.position = "absolute", n.style.transition = "transform 0.5s ease-in-out", n.style.transform = "scale(0.7)", n.style.opacity = "0", e.appendChild(n), E) { n.style.top = "0px", n.style.bottom = "0px", n.style.left = "0px", n.style.marginLeft = "0px;", n.style.width = "100%", n.style.height = "100%", n.style.minHeight = "100%", n.style.WebkitTransform = "translate3d(0,0,0)", n.style.transform = "translate3d(0, 0, 0)"; var o = document.createElement("meta"); o.name = "viewport", o.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0", document.getElementsByTagName("head")[0].appendChild(o) } else n.style.top = "40px", n.style.left = "50%", n.style.marginLeft = "-180px"; n.onload = function () { n.style.opacity = "1", n.style.transform = "scale(1)", n.style.backgroundColor = "#ffffff", A.parentNode && A.parentNode.removeChild(A), i = h.createCloseButton(), e.appendChild(i), i.addEventListener("click", function () { h.closeModal(i, n, A, e) }, !0) }; var r = h.createForm(document, t); return n.contentWindow.document.body ? n.contentWindow.document.body.appendChild(r) : n.contentWindow.document.appendChild(r), r.submit(), { spinner: A, iFrame: n, closeButton: i } }, openWindow: function (e) { var t = window.open(); if (!t) return null; var A = t.document, i = A.createElement("meta"), n = A.createAttribute("name"); n.value = "viewport", i.setAttributeNode(n); var o = A.createAttribute("content"); o.value = "width=device-width", i.setAttributeNode(o), A.head.appendChild(i); var r = h.createForm(A, e); return A.body.appendChild(r), r.submit(), t }, getUrlParser: function (e) { var t = document.createElement("a"); return t.href = e, t }, getHostnameFromUrl: function (e) { return h.getUrlParser(e).hostname }, isMessageFromHpp: function (e, t) { return h.getHostnameFromUrl(e) === h.getHostnameFromUrl(t) }, receiveMessage: function (d, s, c) { return function (e) { if (h.isMessageFromHpp(e.origin, l)) if (e.data && JSON.parse(e.data).iframe) { if (!C) { var t, A = JSON.parse(e.data).iframe.width, i = JSON.parse(e.data).iframe.height, n = !1; if (t = c ? d.getIframe() : document.getElementById("rxp-frame-" + I), "390px" === A && "440px" === i && (t.setAttribute("width", A), t.setAttribute("height", i), n = !0), t.style.backgroundColor = "#ffffff", E) { if (t.style.marginLeft = "0px", t.style.WebkitOverflowScrolling = "touch", t.style.overflowX = "scroll", t.style.overflowY = "scroll", !c) { var o = document.getElementById("rxp-overlay-" + I); o.style.overflowX = "scroll", o.style.overflowY = "scroll" } } else !c && n && (t.style.marginLeft = parseInt(A.replace("px", ""), 10) / 2 * -1 + "px"); !c && n && setTimeout(function () { document.getElementById("rxp-frame-close-" + I).style.marginLeft = parseInt(A.replace("px", ""), 10) / 2 - 7 + "px" }, 200) } } else { C && g ? g.close() : d.close(); var r = e.data, a = document.createElement("form"); a.setAttribute("method", "POST"), a.setAttribute("action", s), a.appendChild(h.createFormHiddenInput("hppResponse", r)), document.body.appendChild(a), a.submit() } } } }, r = { getInstance: function (e) { var t, A; return i || (h.checkDevicesOrientation(), E && window.addEventListener && window.addEventListener("orientationchange", function () { h.checkDevicesOrientation() }, !1), i = { lightbox: function () { if (C) g = h.openWindow(A); else { t = h.createOverlay(); var e = h.createIFrame(t, A); e.spinner, e.iFrame, e.closeButton } }, close: function () { h.closeModal() }, setToken: function (e) { A = e } }), i.setToken(e), i }, init: function (e, t, A) { var i = r.getInstance(A); document.getElementById(e).addEventListener ? document.getElementById(e).addEventListener("click", i.lightbox, !0) : document.getElementById(e).attachEvent("onclick", i.lightbox), window.addEventListener ? window.addEventListener("message", h.receiveMessage(i, t), !1) : window.attachEvent("message", h.receiveMessage(i, t)) } }, a = { getInstance: function (e) { var t, A; return n || (n = { embedded: function () { var e = h.createForm(document, A); t && (t.contentWindow.document.body ? t.contentWindow.document.body.appendChild(e) : t.contentWindow.document.appendChild(e), e.submit(), t.style.display = "inherit") }, close: function () { t.style.display = "none" }, setToken: function (e) { A = e }, setIframe: function (e) { t = document.getElementById(e) }, getIframe: function () { return t } }), n.setToken(e), n }, init: function (e, t, A, i) { var n = a.getInstance(i); n.setIframe(t), document.getElementById(e).addEventListener ? document.getElementById(e).addEventListener("click", n.embedded, !0) : document.getElementById(e).attachEvent("onclick", n.embedded), window.addEventListener ? window.addEventListener("message", h.receiveMessage(n, A, !0), !1) : window.attachEvent("message", h.receiveMessage(n, A, !0)) } }, s = { getInstance: function (e) { var t; return A || (h.checkDevicesOrientation(), E && window.addEventListener && window.addEventListener("orientationchange", function () { h.checkDevicesOrientation() }, !1), A = { redirect: function () { var e = h.createForm(document, t, !0); document.body.append(e), e.submit() }, setToken: function (e) { t = e } }), A.setToken(e), A }, init: function (e, t, A) { var i = s.getInstance(A); d = t, document.getElementById(e).addEventListener ? document.getElementById(e).addEventListener("click", i.redirect, !0) : document.getElementById(e).attachEvent("onclick", i.redirect), window.addEventListener ? window.addEventListener("message", h.receiveMessage(i, t), !1) : window.attachEvent("message", h.receiveMessage(i, t)) } }; return { init: r.init, lightbox: { init: r.init }, embedded: { init: a.init }, redirect: { init: s.init }, setHppUrl: function (e) { l = e }, _internal: h } }(), RealexRemote = function () { "use strict"; var r = function (e) { if (!/^\d{4}$/.test(e)) return !1; var t = parseInt(e.substring(0, 2), 10); parseInt(e.substring(2, 4), 10); return !(t < 1 || 12 < t) }; return { validateCardNumber: function (e) { if (!/^\d{12,19}$/.test(e)) return !1; for (var t = 0, A = 0, i = 0, n = !1, o = e.length - 1; 0 <= o; o--)A = parseInt(e.substring(o, o + 1), 10), n ? 9 < (i = 2 * A) && (i -= 9) : i = A, t += i, n = !n; return 0 == t % 10 }, validateCardHolderName: function (e) { return !!e && !!e.trim() && !!/^[\u0020-\u007E\u00A0-\u00FF]{1,100}$/.test(e) }, validateCvn: function (e) { return !!/^\d{3}$/.test(e) }, validateAmexCvn: function (e) { return !!/^\d{4}$/.test(e) }, validateExpiryDateFormat: r, validateExpiryDateNotInPast: function (e) { if (!r(e)) return !1; var t = parseInt(e.substring(0, 2), 10), A = parseInt(e.substring(2, 4), 10), i = new Date, n = i.getMonth() + 1, o = i.getFullYear(); return !(A < o % 100 || A === o % 100 && t < n) } } }();
"use strict";
var starrez;
(function (starrez) {
    var recaptcha;
    (function (recaptcha) {
        "use strict";
        function Initialise($container) {
            portal.page.CurrentPage.AddPostSubmissionFailOperation(ResetReCaptcha, 0);
        }
        recaptcha.Initialise = Initialise;
        function SetReCaptchaToken(token) {
            $('.ui-recaptcha').GetControl('ReCaptchaToken').SRVal(token);
        }
        recaptcha.SetReCaptchaToken = SetReCaptchaToken;
        function ResetReCaptcha(id) {
            $('.ui-recaptcha').GetControl('ReCaptchaToken').SRVal('');
            window["grecaptcha"].reset(id);
        }
        recaptcha.ResetReCaptcha = ResetReCaptcha;
    })(recaptcha = starrez.recaptcha || (starrez.recaptcha = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.reCaptcha.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var forgotpassword;
        (function (forgotpassword) {
            "use strict";
            function InitializeForgotPassword($container) {
                new ForgotPassword($container);
            }
            forgotpassword.InitializeForgotPassword = InitializeForgotPassword;
            class ForgotPassword {
                constructor($container) {
                    this.$container = $container;
                    this.$forgottenPasswordButton = this.$container.find(".ui-btn-forgotten-password");
                    this.$userName = this.$container.GetControl("Username");
                    this.model = starrez.model.ForgotPasswordModel(this.$container);
                    this.$container.on("keydown", (e) => {
                        if (e.keyCode === starrez.keyboard.EnterCode) {
                            starrez.library.utils.SafeStopPropagation(e);
                            this.$forgottenPasswordButton.trigger("click");
                        }
                    });
                    this.$userName.SRFocus();
                    this.$forgottenPasswordButton.SRClick(() => {
                        if (starrez.library.stringhelper.IsUndefinedOrEmpty(this.$userName.SRVal())) {
                            portal.page.CurrentPage.ClearMessages();
                            window.setTimeout(() => {
                                portal.page.CurrentPage.SetErrorMessage(this.model.UsernameRequiredErrorMessage);
                            }, 100);
                            return;
                        }
                        var call = new starrez.service.register.ForgottenPassword({
                            username: this.$userName.SRVal(),
                            portalPageID: portal.page.CurrentPage.PageID
                        });
                        call.Post().done((result) => {
                            if (result.Success) {
                                portal.page.CurrentPage.SetSuccessMessage(result.PasswordChangeRequestConfirmationMessage);
                                this.$forgottenPasswordButton.SRHide();
                                this.$container.off("keydown");
                                this.$container.on("keydown", (e) => {
                                    // Block page submit on enter.  Do nothing.
                                    if (e.keyCode === starrez.keyboard.EnterCode) {
                                        starrez.library.utils.SafeStopPropagation(e);
                                    }
                                });
                            }
                            else {
                                portal.page.CurrentPage.SetErrorMessage(result.PasswordChangeRequestErrorMessage);
                            }
                        });
                    });
                }
            }
        })(forgotpassword = general.forgotpassword || (general.forgotpassword = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.forgotpassword.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var portal;
(function (portal) {
    var general;
    (function (general) {
        var register;
        (function (register) {
            "use strict";
            var editorDataName = "Editor";
            function InitializeLoginWidget($container) {
                var widget = starrez.model.WidgetModelBaseModel($container);
                $container.data(editorDataName, new LoginWidget($container, widget.PortalPageWidgetID));
            }
            register.InitializeLoginWidget = InitializeLoginWidget;
            function InitializeAccesibleLoginWidget($container) {
                var widget = starrez.model.WidgetModelBaseModel($container);
                $container.data(editorDataName, new AccessibleLoginWidget($container, widget.PortalPageWidgetID));
            }
            register.InitializeAccesibleLoginWidget = InitializeAccesibleLoginWidget;
            function InitPage(container, options) {
                (() => {
                    const userName = container.querySelector("[name='Username']");
                    const password = container.querySelector("[name='Password']");
                    const rememberLogin = container.querySelector("[name='RememberLogin']");
                    const button = container.querySelector(".ui-btn-login");
                    // these can be not found, for example the ADFS redirect
                    if (userName && userName.pxValue() === "") {
                        userName && userName.pxFocus();
                    }
                    else {
                        password && password.pxFocus();
                    }
                    if (portal.Feature.PortalXFormControls) {
                        container.addEventListener("keypress", (e) => {
                            if (e.keyCode === starrez.keyboard.EnterCode) {
                                button.click();
                            }
                        });
                    }
                    else {
                        container.addEventListener("keyup", (e) => {
                            if (e.keyCode === starrez.keyboard.EnterCode) {
                                button.click();
                            }
                        });
                    }
                    button && button.addEventListener("click", () => {
                        const inputs = portal.pxcontrols.getAllControlsInContainer(container) || [];
                        if (portal.validation.ValidatePXControls(inputs, true)) {
                            const call = new starrez.service.register.Login({
                                pageID: portal.page.CurrentPage.PageID,
                                username: userName.pxValue(),
                                password: password.pxValue(),
                                rememberLogin: rememberLogin ? rememberLogin.pxValue() : false,
                                invalidCredentialsMessage: options.invalidCredentialsMessage,
                                returnUrl: options.url
                            });
                            call.Post().done(result => {
                                if (!result.ErrorMessage) {
                                    window.location.href = result.ReturnUrl;
                                }
                                else {
                                    portal.page.CurrentPage.SetErrorMessage(result.ErrorMessage);
                                    password.pxValue("");
                                    password.pxFocus();
                                }
                            });
                        }
                    });
                })();
            }
            register.InitPage = InitPage;
            class AccessibleLoginWidget {
                constructor($container, portalPageWidgetID) {
                    this.$container = $container;
                    this.portalPageWidgetID = portalPageWidgetID;
                    this.registerController = "General/Register/Register";
                    this.OTCEndpoint = "OneTimeCode";
                    this.newOTCEndpoint = "RegenerateOneTimeCode";
                    this.$userName = this.$container.GetControl("Username");
                    this.$password = this.$container.GetControl("Password");
                    this.$rememberLogin = this.$container.GetControl("RememberLogin");
                    this.model = starrez.model.LoginWidgetModel(this.$container);
                    this.AttachEvents();
                    if (this.$userName.SRVal() === "") {
                        this.$userName.SRFocus();
                    }
                    else {
                        this.$password.SRFocus();
                    }
                }
                AttachEvents() {
                    var $loginButton = this.$container.find(".ui-btn-login");
                    var returnUrl = $loginButton.data("url");
                    $loginButton.SRClick(() => {
                        var studentFacingErrors = [];
                        if (starrez.library.stringhelper.IsUndefinedOrEmpty(this.$userName.SRVal())) {
                            studentFacingErrors.push(this.model.UsernameRequiredErrorMessage);
                        }
                        if (starrez.library.stringhelper.IsUndefinedOrEmpty(this.$password.SRVal())) {
                            studentFacingErrors.push(this.model.PasswordRequiredErrorMessage);
                        }
                        if (studentFacingErrors.length > 0) {
                            portal.page.CurrentPage.ClearMessages();
                            window.setTimeout(() => {
                                portal.page.CurrentPage.SetErrorMessages(studentFacingErrors);
                            }, 100);
                            return;
                        }
                        var call = new starrez.service.register.Login({
                            pageID: portal.page.CurrentPage.PageID,
                            username: this.$userName.SRVal(),
                            password: this.$password.SRVal(),
                            rememberLogin: this.$rememberLogin.isFound() ? this.$rememberLogin.SRVal() : false,
                            invalidCredentialsMessage: this.model.InvalidCredentialsMessage,
                            returnUrl: returnUrl
                        });
                        call.Post().done(result => {
                            if (starrez.library.stringhelper.IsUndefinedOrEmpty(result.ErrorMessage)) {
                                if (result.ChallengeId > 0) {
                                    this.challengeId = result.ChallengeId;
                                    this.challengeProviderKey = result.ChallengeProviderKey;
                                    this.InitOtcDialog();
                                    return;
                                }
                                window.location.href = result.ReturnUrl;
                            }
                            else {
                                this.$password.SRVal('');
                                portal.page.CurrentPage.SetErrorMessage(result.ErrorMessage);
                                this.SetPasswordControlFocus();
                            }
                        });
                    });
                    this.$container.on("keyup", (e) => {
                        if (e.keyCode === starrez.keyboard.EnterCode) {
                            $loginButton.trigger("click");
                        }
                    });
                }
                SetPasswordControlFocus() {
                    window.setTimeout(() => { this.$password.SRFocus(); }, 100);
                }
                removeOtcDialog() {
                    const existingDialog = portal.PageElements.$pageContainer[0].querySelector(".ui-login-otc-dialog");
                    existingDialog === null || existingDialog === void 0 ? void 0 : existingDialog.close();
                    existingDialog === null || existingDialog === void 0 ? void 0 : existingDialog.remove();
                }
                InitOtcDialog() {
                    return __awaiter(this, void 0, void 0, function* () {
                        this.removeOtcDialog();
                        //TODO(STAR-37312): change to MFAemail address
                        let emailAddress = this.$userName.SRVal();
                        const partialResponse = yield starrez.getRequest(this.registerController, this.OTCEndpoint, { codeChallengeId: this.challengeId, email: emailAddress });
                        portal.PageElements.$pageContainer.append(partialResponse.asElement());
                        const dialog = portal.PageElements.$pageContainer[0].querySelector(".ui-login-otc-dialog");
                        this.InitOtcInputs(dialog);
                        dialog.showModal();
                    });
                }
                InitOtcInputs(dialog) {
                    const inputs = Array.from(dialog.querySelectorAll(".ui-login-otc-character-input"));
                    for (let i = 1; i < inputs.length; i++) {
                        inputs[i].addEventListener("keydown", (e) => {
                            if (e.key === "Backspace" && !e.target["value"]) {
                                inputs[i - 1].focus();
                            }
                        });
                    }
                    dialog.querySelector(".ui-login-otc-verify-button").addEventListener("keydown", (e) => {
                        if (e.key === "Backspace") {
                            inputs[inputs.length - 1].focus();
                        }
                    });
                    dialog.addEventListener("input", (event) => {
                        const inputElement = event.target.closest(".ui-login-otc-character-input");
                        if (inputElement && inputElement.value.trim().length > 0) {
                            const nextInputIndex = Number(inputElement.dataset.nextIndex);
                            if (nextInputIndex > 0) {
                                const nextInput = dialog.querySelector(`.ui-login-otc-character-input[data-otc-character-index="${nextInputIndex}"]`);
                                if (nextInput) {
                                    nextInput.focus();
                                    nextInput.select();
                                }
                            }
                            else if (nextInputIndex == 0) {
                                // The last input was made. Focus the submit button.
                                dialog.querySelector(".ui-login-otc-verify-button").focus();
                            }
                        }
                    });
                    dialog.addEventListener("paste", (event) => {
                        event.preventDefault();
                        const inputElement = event.target.closest(".ui-login-otc-character-input");
                        if (!inputElement || Number(inputElement.dataset.nextIndex) != 1) {
                            return;
                        }
                        const pastedText = (event.clipboardData).getData('text').trim();
                        if (!pastedText || !pastedText.length || pastedText.length != inputs.length)
                            return;
                        // Fill each input with the corresponding character from the pasted text
                        for (let i = 0; i < inputs.length; i++) {
                            inputs[i].value = pastedText[i];
                        }
                        dialog.querySelector(".ui-login-otc-verify-button").focus();
                    });
                    dialog.querySelector(".ui-otc-resend").addEventListener("click", () => __awaiter(this, void 0, void 0, function* () {
                        portal.page.CurrentPage.ClearMessages();
                        this.removeOtcDialog();
                        const response = yield starrez.postRequest(this.registerController, this.newOTCEndpoint, {
                            username: this.$userName.SRVal(),
                            challengeId: this.challengeId,
                            challengeProviderKey: this.challengeProviderKey
                        });
                        const result = response.asJSON();
                        if (result.IsSuccess) {
                            this.challengeId = result.ChallengeId;
                            this.InitOtcDialog();
                        }
                        else {
                            portal.page.CurrentPage.SetErrorMessage(result.ErrorMessage);
                        }
                    }));
                }
            }
            class LoginWidget {
                constructor($container, portalPageWidgetID) {
                    this.$container = $container;
                    this.portalPageWidgetID = portalPageWidgetID;
                    this.$userName = this.$container.GetControl("Username");
                    this.$password = this.$container.GetControl("Password");
                    this.$rememberLogin = this.$container.GetControl("RememberLogin");
                    this.model = starrez.model.LoginWidgetModel(this.$container);
                    this.AttachEvents();
                    if (this.$userName.SRVal() === "") {
                        this.$userName.SRFocus();
                    }
                    else {
                        this.$password.SRFocus();
                    }
                }
                AttachEvents() {
                    var $loginButton = this.$container.find(".ui-btn-login");
                    var returnUrl = $loginButton.data("url");
                    $loginButton.SRClick(() => {
                        var studentFacingErrors = [];
                        if (starrez.library.stringhelper.IsUndefinedOrEmpty(this.$userName.SRVal())) {
                            studentFacingErrors.push(this.model.UsernameRequiredErrorMessage);
                        }
                        if (starrez.library.stringhelper.IsUndefinedOrEmpty(this.$password.SRVal())) {
                            studentFacingErrors.push(this.model.PasswordRequiredErrorMessage);
                        }
                        if (studentFacingErrors.length > 0) {
                            portal.page.CurrentPage.SetErrorMessages(studentFacingErrors);
                            return;
                        }
                        var call = new starrez.service.register.Login({
                            pageID: portal.page.CurrentPage.PageID,
                            username: this.$userName.SRVal(),
                            password: this.$password.SRVal(),
                            rememberLogin: this.$rememberLogin.isFound() ? this.$rememberLogin.SRVal() : false,
                            invalidCredentialsMessage: this.model.InvalidCredentialsMessage,
                            returnUrl: returnUrl
                        });
                        call.Post().done(result => {
                            if (starrez.library.stringhelper.IsUndefinedOrEmpty(result.ErrorMessage)) {
                                window.location.href = result.ReturnUrl;
                            }
                            else {
                                this.$password.SRVal('');
                                portal.page.CurrentPage.SetErrorMessage(result.ErrorMessage);
                                this.SetPasswordControlFocus();
                            }
                        });
                    });
                    this.$container.on("keyup", (e) => {
                        if (e.keyCode === starrez.keyboard.EnterCode) {
                            $loginButton.trigger("click");
                        }
                    });
                }
                SetPasswordControlFocus() {
                    window.setTimeout(() => { this.$password.SRFocus(); }, 100);
                }
            }
        })(register = general.register || (general.register = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.register.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var updatecredentials;
        (function (updatecredentials) {
            "use strict";
            function InitialiseFieldListEditor($container) {
                portal.fieldlist.control.InitFieldListManager($container, existingFields => new starrez.service.register.CreateNewField({
                    existingFields: existingFields
                }));
            }
            updatecredentials.InitialiseFieldListEditor = InitialiseFieldListEditor;
            function InitialiseMatchManager($container) {
                new MatchManager($container);
            }
            updatecredentials.InitialiseMatchManager = InitialiseMatchManager;
            class MatchManager {
                constructor($container) {
                    this.$container = $container;
                    var $button = this.$container.find(".ui-submit-credentials");
                    $button.SRClick(() => this.SubmitUpgrade());
                    this.hash = $button.data("hash").toString();
                    this.SetupSubmitOnEnter();
                }
                SetupSubmitOnEnter() {
                    this.$container.keydown(e => {
                        if (e.keyCode === starrez.keyboard.EnterCode) {
                            this.SubmitUpgrade();
                            // The browsers have a behaviour where they will automatically submit the form if there is only one
                            // input field on it. This is not what we want to do, so call SafeStopPropagation to block this from happening.
                            // http://stackoverflow.com/questions/1370021/why-does-forms-with-single-input-field-submit-upon-pressing-enter-key-in-input
                            starrez.library.utils.SafeStopPropagation(e);
                        }
                    });
                }
                SubmitUpgrade() {
                    var $allFields = this.$container.find(".ui-field");
                    var dictionary = new starrez.library.collections.KeyValue();
                    // build up the dictionary of values to send to the server
                    this.$container.GetAllControls().each((index, ctrl) => {
                        var $ctrl = $(ctrl);
                        var key = $ctrl.closest("li").data("field-id").toString();
                        var value = $ctrl.SRVal();
                        dictionary.Add(key, value);
                    });
                    var call = new starrez.service.register.MatchCredentials({
                        hash: this.hash,
                        pageID: portal.page.CurrentPage.PageID,
                        values: dictionary.ToArray()
                    }).Post().done((message) => {
                        // email sent
                        portal.page.CurrentPage.SetSuccessMessage(message);
                    });
                }
            }
        })(updatecredentials = general.updatecredentials || (general.updatecredentials = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.updatecredentials.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function ForgotPasswordModel($sys) {
            return {
                PasswordChangeRequestConfirmationMessage: $sys.data('passwordchangerequestconfirmationmessage'),
                PasswordChangeRequestErrorMessage: $sys.data('passwordchangerequesterrormessage'),
                UsernameRequiredErrorMessage: $sys.data('usernamerequirederrormessage'),
            };
        }
        model.ForgotPasswordModel = ForgotPasswordModel;
        function LoginModel($sys) {
            return {};
        }
        model.LoginModel = LoginModel;
        function LoginWidgetModel($sys) {
            return {
                InvalidCredentialsMessage: $sys.data('invalidcredentialsmessage'),
                Password: $sys.data('password'),
                PasswordRequiredErrorMessage: $sys.data('passwordrequirederrormessage'),
                RememberLogin: starrez.library.convert.ToBoolean($sys.data('rememberlogin')),
                Username: $sys.data('username'),
                UsernameRequiredErrorMessage: $sys.data('usernamerequirederrormessage'),
            };
        }
        model.LoginWidgetModel = LoginWidgetModel;
        function UpdateCredentialsModel($sys) {
            return {};
        }
        model.UpdateCredentialsModel = UpdateCredentialsModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var register;
        (function (register) {
            "use strict";
            class CreateNewField extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Register";
                    this.Controller = "register";
                    this.Action = "CreateNewField";
                }
                CallData() {
                    var obj = {
                        existingFields: this.o.existingFields,
                    };
                    return obj;
                }
            }
            register.CreateNewField = CreateNewField;
            class ForgottenPassword extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Register";
                    this.Controller = "register";
                    this.Action = "ForgottenPassword";
                }
                CallData() {
                    var obj = {
                        portalPageID: this.o.portalPageID,
                        username: this.o.username,
                    };
                    return obj;
                }
            }
            register.ForgottenPassword = ForgottenPassword;
            class Login extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Register";
                    this.Controller = "register";
                    this.Action = "Login";
                }
                CallData() {
                    var obj = {
                        invalidCredentialsMessage: this.o.invalidCredentialsMessage,
                        pageID: this.o.pageID,
                        password: this.o.password,
                        rememberLogin: this.o.rememberLogin,
                        returnUrl: this.o.returnUrl,
                        username: this.o.username,
                    };
                    return obj;
                }
            }
            register.Login = Login;
            class MatchCredentials extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Register";
                    this.Controller = "register";
                    this.Action = "MatchCredentials";
                }
                CallData() {
                    var obj = {
                        values: this.o.values,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            register.MatchCredentials = MatchCredentials;
        })(register = service.register || (service.register = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var bookedresources;
        (function (bookedresources) {
            "use strict";
            function InitBookedResourcesPage($container) {
                new ManageResourcesModel($container);
            }
            bookedresources.InitBookedResourcesPage = InitBookedResourcesPage;
        })(bookedresources = general.bookedresources || (general.bookedresources = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
class ManageResourcesModel {
    constructor($container) {
        this.$container = $container;
        this.pageID = portal.page.CurrentPage.PageID;
        this.model = starrez.model.BookedResourcesModel($container);
        portal.actionpanel.control.AutoAdjustActionPanelHeights($container);
        this.AttachEvents();
    }
    AttachEvents() {
        this.$container.on("click", ".ui-cancel-resource", (e) => {
            var $currentTarget = $(e.currentTarget);
            var $button = $currentTarget.closest(".ui-cancel-resource");
            var $actionPanel = $currentTarget.closest(".ui-action-panel");
            portal.ConfirmAction(this.model.CancelResourceConfirmation, "Manage Resources").done(() => {
                var call = new starrez.service.resources.CancelResourceRequest({
                    pageID: this.pageID,
                    resourceBookingID: Number($actionPanel.data("resourcebookingid")),
                    hash: $button.data("hash")
                });
                call.Post().done((result) => {
                    // Remove the cancelled resource from the list
                    var $actionPanel = $currentTarget.closest(".ui-action-panel");
                    $actionPanel.remove();
                });
            });
        });
    }
}
//# sourceMappingURL=portal.general.manageresources.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var requestresource;
        (function (requestresource) {
            "use strict";
            function InitResourceSelectionPage($container) {
                new ResourceSelectionModel($container);
            }
            requestresource.InitResourceSelectionPage = InitResourceSelectionPage;
            class ResourceSelectionModel {
                constructor($container) {
                    this.$container = $container;
                    this.LoadResults();
                    this.AttachEvents();
                    this.model = starrez.model.RequestResourceModel($container);
                }
                LoadResults() {
                    this.pageID = portal.page.CurrentPage.PageID;
                    this.$resultsContainer = this.$container.find(".ui-results");
                    this.$noResultsContainer = this.$container.find(".ui-no-results");
                    this.$filtersContainer = this.$container.find(".ui-filters");
                    if (portal.Feature.PortalXFormControls) {
                        this.filters = {
                            LocationIDs: portal.pxcontrols.helpers.controls.multiSelect.value("RoomLocationID"),
                            LocationAreaIDs: portal.pxcontrols.helpers.controls.multiSelect.value("RoomLocationAreaID"),
                            ResourceTypeIDs: portal.pxcontrols.helpers.controls.multiSelect.value("ResourceTypeID"),
                            SearchString: this.$filtersContainer.GetControl("ResourceName").SRVal()
                        };
                    }
                    else {
                        this.filters = {
                            LocationIDs: this.$filtersContainer.GetControl("RoomLocationID").SRVal(),
                            LocationAreaIDs: this.$filtersContainer.GetControl("RoomLocationAreaID").SRVal(),
                            ResourceTypeIDs: this.$filtersContainer.GetControl("ResourceTypeID").SRVal(),
                            SearchString: this.$filtersContainer.GetControl("ResourceName").SRVal()
                        };
                    }
                    new starrez.service.resources.GetFilterResults({
                        pageID: this.pageID,
                        filters: this.filters,
                        dateStart: this.$container.GetControl("DateStart").SRVal(),
                        dateEnd: this.$container.GetControl("DateEnd").SRVal()
                    }).Post().done((result) => {
                        this.$resultsContainer.html(result.ResultsHtml);
                        portal.actionpanel.control.AutoAdjustActionPanelHeights(this.$container);
                    });
                }
                SetupAssignResourceAction() {
                    this.$container.on("click", ".ui-add-item-to-cart", (e) => {
                        var $currentTarget = $(e.currentTarget);
                        var $button = $currentTarget.closest(".ui-add-item-to-cart");
                        var $itemResult = $currentTarget.closest(".ui-card-result");
                        portal.ConfirmAction(this.model.ConfirmAssignResourceMessage, "Request Resource").done(() => {
                            var call = new starrez.service.resources.RequestResource({
                                resourceID: Number($itemResult.data("resourceid")),
                                pageID: this.pageID,
                                dateStart: this.$container.GetControl("DateStart").SRVal(),
                                dateEnd: this.$container.GetControl("DateEnd").SRVal(),
                                hash: $button.data("hash")
                            });
                            call.Post().done((result) => {
                                // Navigate to the page which shows the booked resource
                                location.href = this.model.BookedResourcesPageUrl;
                            });
                        });
                    });
                }
                AttachEvents() {
                    var $searchField = this.$filtersContainer.GetControl("ResourceName");
                    if (portal.Feature.PortalXFormControls) {
                        this.$filtersContainer.find("input[type=checkbox]").change((e) => {
                            this.LoadResults();
                        });
                    }
                    else {
                        this.$filtersContainer.GetAllControls().find("select").change((e) => {
                            this.LoadResults();
                        });
                    }
                    this.$container.GetControl("DateStart").change((e) => {
                        this.LoadResults();
                    });
                    this.$container.GetControl("DateEnd").change((e) => {
                        this.LoadResults();
                    });
                    new starrez.library.ui.KeyboardSearchListener($searchField, (searchTerm) => {
                        this.LoadResults();
                    });
                    this.SetupAssignResourceAction();
                    portal.mobile.SetupExpandAndCollapse(this.$container);
                }
            }
            ;
        })(requestresource = general.requestresource || (general.requestresource = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.requestresource.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function BookedResourcesModel($sys) {
            return {
                CancelResourceConfirmation: $sys.data('cancelresourceconfirmation'),
            };
        }
        model.BookedResourcesModel = BookedResourcesModel;
        function RequestResourceModel($sys) {
            return {
                BookedResourcesPageUrl: $sys.data('bookedresourcespageurl'),
                ConfirmAssignResourceMessage: $sys.data('confirmassignresourcemessage'),
                ResourceTypeID: ($sys.data('resourcetypeid') === '') ? [] : ($sys.data('resourcetypeid')).toString().split(',').map(function (e) { return Number(e); }),
                RoomLocationAreaID: ($sys.data('roomlocationareaid') === '') ? [] : ($sys.data('roomlocationareaid')).toString().split(',').map(function (e) { return Number(e); }),
                RoomLocationID: ($sys.data('roomlocationid') === '') ? [] : ($sys.data('roomlocationid')).toString().split(',').map(function (e) { return Number(e); }),
            };
        }
        model.RequestResourceModel = RequestResourceModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var resources;
        (function (resources) {
            "use strict";
            class CancelResourceRequest extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Resources";
                    this.Controller = "resources";
                    this.Action = "CancelResourceRequest";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        resourceBookingID: this.o.resourceBookingID,
                    };
                    return obj;
                }
            }
            resources.CancelResourceRequest = CancelResourceRequest;
            class GetFilterResults extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Resources";
                    this.Controller = "resources";
                    this.Action = "GetFilterResults";
                }
                CallData() {
                    var obj = {
                        dateEnd: this.o.dateEnd,
                        dateStart: this.o.dateStart,
                        filters: this.o.filters,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            resources.GetFilterResults = GetFilterResults;
            class RequestResource extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Resources";
                    this.Controller = "resources";
                    this.Action = "RequestResource";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        dateEnd: this.o.dateEnd,
                        dateStart: this.o.dateStart,
                        pageID: this.o.pageID,
                        resourceID: this.o.resourceID,
                    };
                    return obj;
                }
            }
            resources.RequestResource = RequestResource;
        })(resources = service.resources || (service.resources = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var roommaintenance;
        (function (roommaintenance) {
            "use strict";
            function InitialiseJobTable($container) {
                if (portal.Feature.PXAccessibilityEnableSemanticRoomMaintenanceTables) {
                    new MaintenanceJobList($container);
                }
                else {
                    new JobList($container);
                }
            }
            roommaintenance.InitialiseJobTable = InitialiseJobTable;
            function InitialiseJobDetail($container) {
                if (portal.Feature.PXAccessibilityEnableSemanticRoomMaintenanceTables) {
                    new MaintenanceJobDetail($container);
                }
                else {
                    new JobDetail($container);
                }
            }
            roommaintenance.InitialiseJobDetail = InitialiseJobDetail;
            class MaintenanceJobList {
                constructor($container) {
                    this.GetMaintenanceJobs = () => {
                        return new starrez.service.roommaintenance.GetRoomMaintenanceJobs({
                            pageID: this.pageID,
                            jobType: this.Get(MaintenanceJobList.JobTypePropertyName),
                            isMobile: portal.general.roommaintenance.responsive.IsMobile(),
                        });
                    };
                    this.$container = $container;
                    this.pageID = Number($container.data('portalpageid'));
                    // Bind responsive table events
                    this.$responsiveTableContainer = $container.find('.ui-responsive-active-table-container');
                    this.$responsiveTableContainer.on(starrez.activetable.responsive.eventTableLoaded, () => {
                        this.BindTable();
                        this.AttachEvents();
                    });
                    portal.general.roommaintenance.responsive.SetGetCall(this.GetMaintenanceJobs);
                    portal.general.roommaintenance.responsive.Init();
                }
                BindTable() {
                    this.maintenanceJobsTable = starrez.tablesetup.responsive.CreateTableManager(this.$responsiveTableContainer, $('body'))[0];
                    if (this.maintenanceJobsTable) {
                        starrez.tablesetup.InitActiveTableEditor(this.maintenanceJobsTable.$table, () => {
                            this.maintenanceJobsTable = starrez.tablesetup.responsive.CreateTableManager(this.$responsiveTableContainer, $('body'))[0];
                        });
                    }
                }
                AttachEvents() {
                    // drop down change
                    let $jobTypeControl = this.$container.GetControl(MaintenanceJobList.JobTypePropertyName);
                    $jobTypeControl.change(e => {
                        portal.general.roommaintenance.responsive.SetGetCall(this.GetMaintenanceJobs);
                        portal.general.roommaintenance.responsive.Init();
                    });
                    // add job
                    let model = starrez.model.MaintenanceModel(this.$container);
                    let $addJobButton = this.$container.find('.ui-btn-add-job');
                    $addJobButton.SRClick(() => {
                        this.roomSpaceMaintenanceHash = model.NewJobUrlHash;
                        this.NavigateToDetailPage(-1);
                    });
                    // edit job
                    this.maintenanceJobsTable.$table.SRClickDelegate("roommaintenance", ".ui-viewedit-job", (e) => {
                        var $row = $(e.currentTarget).closest(portal.general.roommaintenance.responsive.GetRowSelector());
                        this.roomSpaceMaintenanceHash = $row.data("hash").toString();
                        this.NavigateToDetailPage($row.data('roomspacemaintenance'));
                    });
                }
                NavigateToDetailPage(roomSpaceMaintenanceID) {
                    new starrez.service.roommaintenance.GetJobDetailUrl({
                        pageID: this.pageID,
                        roomSpaceMaintenanceID: roomSpaceMaintenanceID,
                        hash: this.roomSpaceMaintenanceHash
                    }).Post().done((url) => {
                        location.href = url;
                    });
                }
                Get(controlName) {
                    return this.$container.GetControl(controlName).SRVal();
                }
            }
            MaintenanceJobList.JobTypePropertyName = 'JobType';
            class JobList {
                constructor($container) {
                    this.$container = $container;
                    this.$jobTypeControl = this.$container.GetControl(JobList.JobTypePropertyName);
                    this.$tableDiv = $('.ui-jobs-table-div');
                    this.pageID = Number($container.data('portalpageid'));
                    var model = starrez.model.MaintenanceModel($container);
                    this.$jobTypeControl.change(e => {
                        this.GetJobs();
                    });
                    this.GetJobs();
                    var $addJobButton = this.$container.find('.ui-btn-add-job');
                    $addJobButton.SRClick(() => {
                        this.roomSpaceMaintenanceHash = model.NewJobUrlHash;
                        this.NavigateToDetailPage(-1);
                    });
                    this.$container.SRClickDelegate("roommaintenance", ".ui-viewedit-job", (e) => {
                        var $row = $(e.currentTarget).closest('tr');
                        this.roomSpaceMaintenanceHash = $row.data("hash").toString();
                        this.NavigateToDetailPage($row.data('roomspacemaintenance'));
                    });
                }
                GetJobs() {
                    var call = new starrez.service.roommaintenance.GetMaintenaceJobs({
                        pageID: this.pageID,
                        jobType: this.Get(JobList.JobTypePropertyName)
                    });
                    call.Get().done(result => {
                        this.$tableDiv.html(result);
                    });
                }
                NavigateToDetailPage(roomSpaceMaintenanceID) {
                    new starrez.service.roommaintenance.GetJobDetailUrl({
                        pageID: this.pageID,
                        roomSpaceMaintenanceID: roomSpaceMaintenanceID,
                        hash: this.roomSpaceMaintenanceHash
                    }).Post().done((url) => {
                        location.href = url;
                    });
                }
                Get(controlName) {
                    return this.$container.GetControl(controlName).SRVal();
                }
            }
            JobList.JobTypePropertyName = 'JobType';
            class MaintenanceJobDetail {
                constructor($container) {
                    this.GetMaintenanceRooms = () => {
                        return new starrez.service.roommaintenance.GetMaintenanceRooms({
                            pageID: this.pageID,
                            roomSpaceID: -1,
                            roomSpaceMaintenanceID: this.roomSpaceMaintenanceID,
                            roomType: this.Get(JobDetail.RoomTypePropertyName),
                            isMobile: portal.general.roommaintenance.responsive.IsMobile(),
                        });
                    };
                    this.$container = $container;
                    this.$tableDiv = $('.ui-rooms-table-div');
                    this.$roomSpaceMaintenanceCategoryIDControl = this.$container.GetControl(JobDetail.RoomSpaceMaintenanceCategoryIDPropertyName);
                    this.$roomSpaceMaintenanceItemIDControl = this.$container.GetControl(JobDetail.RoomSpaceMaintenanceItemIDPropertyName);
                    this.$model = starrez.model.MaintenanceJobDetailModel($container);
                    this.roomSpaceMaintenanceID = this.$model.RoomSpaceMaintenanceID;
                    this.roomSpaceID = this.$model.RoomSpaceID;
                    this.isNew = this.$model.IsNew;
                    this.pageID = Number($container.data('portalpageid'));
                    // Bind responsive table events
                    this.$responsiveTableContainer = $container.find('.ui-responsive-active-table-container');
                    this.$responsiveTableContainer.on(starrez.activetable.responsive.eventTableLoaded, () => {
                        this.BindTable();
                        this.AttachEvents();
                        this.AttachFocusEvents();
                    });
                    portal.general.roommaintenance.responsive.SetGetCall(this.GetMaintenanceRooms);
                    portal.general.roommaintenance.responsive.Init();
                }
                Get(controlName) {
                    return this.$container.GetControl(controlName).SRVal();
                }
                BindTable() {
                    this.maintenanceJobDetailTable = starrez.tablesetup.responsive.CreateTableManager(this.$responsiveTableContainer, $('body'))[0];
                    if (this.maintenanceJobDetailTable) {
                        starrez.tablesetup.InitActiveTableEditor(this.maintenanceJobDetailTable.$table, () => {
                            this.maintenanceJobDetailTable = starrez.tablesetup.responsive.CreateTableManager(this.$responsiveTableContainer, $('body'))[0];
                        });
                    }
                }
                AttachEvents() {
                    // room type dropdown change
                    let $roomTypeControl = this.$container.GetControl(JobDetail.RoomTypePropertyName);
                    $roomTypeControl.change(e => {
                        this.roomSpaceID = -1;
                        portal.general.roommaintenance.responsive.SetGetCall(this.GetMaintenanceRooms);
                        portal.general.roommaintenance.responsive.Init();
                    });
                    // row selector button click 
                    this.maintenanceJobDetailTable.$table.SRClickDelegate("roomspace", ".ui-btn-maintenance-job-room-select", (e) => {
                        this.roomSpaceID = Number($(e.currentTarget).data("roomspace_id"));
                        this.maintenanceJobDetailTable.Rows().each((index, row) => {
                            const $row = $(row);
                            const rowRoomSpaceID = $row.data("roomspace");
                            if (rowRoomSpaceID == this.roomSpaceID) {
                                $row.SelectRow(true);
                                return;
                            }
                        });
                    });
                    // room category drop down change
                    this.$roomSpaceMaintenanceCategoryIDControl.change(e => {
                        var call = new starrez.service.roommaintenance.GetMaintenanceItems({
                            pageID: this.pageID,
                            categoryID: this.Get(JobDetail.RoomSpaceMaintenanceCategoryIDPropertyName),
                            roomSpaceMaintenanceID: this.$model.RoomSpaceMaintenanceID
                        });
                        call.Get().done(json => {
                            if (portal.Feature.PortalXFormControls) {
                                portal.pxcontrols.pxFillDropDown(json, this.$roomSpaceMaintenanceItemIDControl[0]);
                            }
                            else {
                                starrez.library.controls.dropdown.FillDropDown(json, this.$roomSpaceMaintenanceItemIDControl, "Value", "Text", "", false);
                            }
                        });
                    });
                    var $saveButton = portal.PageElements.$actions.find('.ui-btn-save');
                    $saveButton.SRClick(() => {
                        var jobDetail = this.GetJobDetail();
                        if (portal.validation.ValidateForm(this.$container, true)) {
                            var call = new starrez.service.roommaintenance.SaveJob({
                                jobDetail: jobDetail
                            });
                            return call.Post().done(json => {
                                portal.page.CurrentPage.SubmitPage();
                            });
                        }
                    });
                    var $closeButton = portal.PageElements.$actions.find('.ui-btn-close-job');
                    $closeButton.SRClick(() => {
                        var jobDetail = this.GetJobDetail();
                        var call = new starrez.service.roommaintenance.CloseJob({
                            jobDetail: jobDetail
                        });
                        return call.Post().done(json => {
                            portal.page.CurrentPage.SubmitPage();
                        });
                    });
                }
                GetJobDetail() {
                    var jobDetail = {
                        RoomSpaceID: this.roomSpaceID,
                        RoomSpaceMaintenanceID: this.roomSpaceMaintenanceID,
                        Cause: this.Get(JobDetail.CausePropertyName),
                        Comments: this.Get(JobDetail.CommentsPropertyName),
                        Description: this.Get(JobDetail.DescriptionPropertyName),
                        OccupantPresent: this.Get(JobDetail.OccupantPresentPropertyName),
                        JobStatus: this.Get(JobDetail.StatusPropertyName),
                        RoomSpaceMaintenanceCategoryID: this.Get(JobDetail.RoomSpaceMaintenanceCategoryIDPropertyName),
                        RoomSpaceMaintenanceItemID: this.Get(JobDetail.RoomSpaceMaintenanceItemIDPropertyName),
                        RepairDescription: this.Get(JobDetail.RepairDescriptionPropertyName),
                        IsNew: this.isNew,
                        PortalPageID: this.pageID,
                    };
                    return jobDetail;
                }
                AttachFocusEvents() {
                    this.$tableDiv.on("focusin", (e) => {
                        this.maintenanceJobDetailTable.DisplayFocus(true);
                    });
                    this.$tableDiv.on("focusout", (e) => {
                        this.maintenanceJobDetailTable.DisplayFocus(false);
                    });
                }
            }
            MaintenanceJobDetail.CausePropertyName = 'Cause';
            MaintenanceJobDetail.CommentsPropertyName = 'Comments';
            MaintenanceJobDetail.DateReportedPropertyName = 'DateReported';
            MaintenanceJobDetail.DescriptionPropertyName = 'Description';
            MaintenanceJobDetail.OccupantPresentPropertyName = 'OccupantPresent';
            MaintenanceJobDetail.StatusPropertyName = 'JobStatus';
            MaintenanceJobDetail.RoomTypePropertyName = 'RoomType';
            MaintenanceJobDetail.RoomSpaceMaintenanceCategoryIDPropertyName = 'RoomSpaceMaintenanceCategoryID';
            MaintenanceJobDetail.RoomSpaceMaintenanceItemIDPropertyName = 'RoomSpaceMaintenanceItemID';
            MaintenanceJobDetail.RepairDescriptionPropertyName = 'RepairDescription';
            class JobDetail {
                constructor($container) {
                    this.$container = $container;
                    this.$detailContainer = $container;
                    this.$roomTypeControl = this.$container.GetControl(JobDetail.RoomTypePropertyName);
                    this.$tableDiv = $('.ui-rooms-table-div');
                    this.$roomSpaceMaintenanceCategoryIDControl = this.$container.GetControl(JobDetail.RoomSpaceMaintenanceCategoryIDPropertyName);
                    this.$roomSpaceMaintenanceItemIDControl = this.$container.GetControl(JobDetail.RoomSpaceMaintenanceItemIDPropertyName);
                    var model = starrez.model.MaintenanceJobDetailModel($container);
                    this.roomSpaceMaintenanceID = model.RoomSpaceMaintenanceID;
                    this.roomSpaceID = model.RoomSpaceID;
                    this.isNew = model.IsNew;
                    this.pageID = Number($container.data('portalpageid'));
                    this.$roomTypeControl.change(e => {
                        this.GetRooms();
                        this.roomSpaceID = -1;
                    });
                    this.GetRooms();
                    this.$roomSpaceMaintenanceCategoryIDControl.change(e => {
                        var call = new starrez.service.roommaintenance.GetMaintenanceItems({
                            pageID: this.pageID,
                            categoryID: this.Get(JobDetail.RoomSpaceMaintenanceCategoryIDPropertyName),
                            roomSpaceMaintenanceID: model.RoomSpaceMaintenanceID
                        });
                        if (portal.Feature.PortalXFormControls) {
                            call.Get().done(json => {
                                portal.pxcontrols.pxFillDropDown(json, document.getElementsByName("RoomSpaceMaintenanceItemID")[0]);
                            });
                        }
                        else {
                            call.Get().done(json => {
                                starrez.library.controls.dropdown.FillDropDown(json, this.$roomSpaceMaintenanceItemIDControl, "Value", "Text", "", false);
                            });
                        }
                    });
                    var $saveButton = portal.PageElements.$actions.find('.ui-btn-save');
                    $saveButton.SRClick(() => {
                        var jobDetail = this.GetJobDetail();
                        if (portal.validation.ValidateForm($container, true)) {
                            var call = new starrez.service.roommaintenance.SaveJob({
                                jobDetail: jobDetail
                            });
                            return call.Post().done(json => {
                                portal.page.CurrentPage.SubmitPage();
                            });
                        }
                    });
                    var $closeButton = portal.PageElements.$actions.find('.ui-btn-close-job');
                    $closeButton.SRClick(() => {
                        var jobDetail = this.GetJobDetail();
                        var call = new starrez.service.roommaintenance.CloseJob({
                            jobDetail: jobDetail
                        });
                        return call.Post().done(json => {
                            portal.page.CurrentPage.SubmitPage();
                        });
                    });
                }
                GetJobDetail() {
                    var jobDetail = {
                        RoomSpaceID: this.roomSpaceID,
                        RoomSpaceMaintenanceID: this.roomSpaceMaintenanceID,
                        Cause: this.Get(JobDetail.CausePropertyName),
                        Comments: this.Get(JobDetail.CommentsPropertyName),
                        Description: this.Get(JobDetail.DescriptionPropertyName),
                        OccupantPresent: this.Get(JobDetail.OccupantPresentPropertyName),
                        JobStatus: this.Get(JobDetail.StatusPropertyName),
                        RoomSpaceMaintenanceCategoryID: this.Get(JobDetail.RoomSpaceMaintenanceCategoryIDPropertyName),
                        RoomSpaceMaintenanceItemID: this.Get(JobDetail.RoomSpaceMaintenanceItemIDPropertyName),
                        RepairDescription: this.Get(JobDetail.RepairDescriptionPropertyName),
                        IsNew: this.isNew,
                        PortalPageID: this.pageID,
                    };
                    return jobDetail;
                }
                GetRooms() {
                    var call = new starrez.service.roommaintenance.GetRooms({
                        pageID: this.pageID,
                        roomSpaceID: this.roomSpaceID,
                        roomSpaceMaintenanceID: this.roomSpaceMaintenanceID,
                        roomType: this.Get(JobDetail.RoomTypePropertyName)
                    });
                    call.Get().done(result => {
                        this.$tableDiv.html(result);
                        var tableManagers = starrez.tablesetup.CreateTableManager(this.$container.find('.ui-active-table'), this.$container.find('.ui-rooms-table-div'), {
                            AttachRowClickEvent: this.isNew,
                            OnRowClick: ($tr, $data, e, sender) => {
                                if ($tr.isSelected()) {
                                    this.roomSpaceID = $tr.data('roomspace');
                                }
                                else {
                                    this.roomSpaceID = -1;
                                }
                            }
                        });
                        this.tableManager = tableManagers[0];
                        this.AttachFocusEvents();
                    });
                }
                Get(controlName) {
                    return this.$container.GetControl(controlName).SRVal();
                }
                AttachFocusEvents() {
                    this.$container.find('.ui-rooms-table-div').on("focusin", (e) => {
                        this.tableManager.DisplayFocus(true);
                    });
                    this.$container.find('.ui-rooms-table-div').on("focusout", (e) => {
                        this.tableManager.DisplayFocus(false);
                    });
                }
            }
            JobDetail.CausePropertyName = 'Cause';
            JobDetail.CommentsPropertyName = 'Comments';
            JobDetail.DateReportedPropertyName = 'DateReported';
            JobDetail.DescriptionPropertyName = 'Description';
            JobDetail.OccupantPresentPropertyName = 'OccupantPresent';
            JobDetail.StatusPropertyName = 'JobStatus';
            JobDetail.RoomTypePropertyName = 'RoomType';
            JobDetail.RoomSpaceMaintenanceCategoryIDPropertyName = 'RoomSpaceMaintenanceCategoryID';
            JobDetail.RoomSpaceMaintenanceItemIDPropertyName = 'RoomSpaceMaintenanceItemID';
            JobDetail.RepairDescriptionPropertyName = 'RepairDescription';
        })(roommaintenance = general.roommaintenance || (general.roommaintenance = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.roommaintenance.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var roommaintenance;
        (function (roommaintenance) {
            var responsive;
            (function (responsive) {
                "use strict";
                let _responsiveActiveTable;
                function InitResponsiveTable($container) {
                    if ($container.find(starrez.activetable.responsive.responsiveTableContainerClass).length) {
                        _responsiveActiveTable = new starrez.activetable.responsive.CustomResponsiveActiveTable($container);
                    }
                }
                responsive.InitResponsiveTable = InitResponsiveTable;
                function Init() {
                    _responsiveActiveTable.Init();
                }
                responsive.Init = Init;
                function SetGetCall(callFunc) {
                    _responsiveActiveTable.SetGetCall(callFunc);
                }
                responsive.SetGetCall = SetGetCall;
                function IsMobile() {
                    return _responsiveActiveTable.IsMobile();
                }
                responsive.IsMobile = IsMobile;
                function GetRowSelector() {
                    return this.IsMobile() ? "tbody" : "tbody tr";
                }
                responsive.GetRowSelector = GetRowSelector;
            })(responsive = roommaintenance.responsive || (roommaintenance.responsive = {}));
        })(roommaintenance = general.roommaintenance || (general.roommaintenance = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.roommaintenance.responsive.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function MaintenanceModel($sys) {
            return {
                NewJobUrlHash: $sys.data('newjoburlhash'),
            };
        }
        model.MaintenanceModel = MaintenanceModel;
        function MaintenanceJobDetailModel($sys) {
            return {
                IsNew: starrez.library.convert.ToBoolean($sys.data('isnew')),
                RoomSpaceID: Number($sys.data('roomspaceid')),
                RoomSpaceMaintenanceID: Number($sys.data('roomspacemaintenanceid')),
            };
        }
        model.MaintenanceJobDetailModel = MaintenanceJobDetailModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var roommaintenance;
        (function (roommaintenance) {
            "use strict";
            class CloseJob extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomMaintenance";
                    this.Controller = "roommaintenance";
                    this.Action = "CloseJob";
                }
                CallData() {
                    var obj = {
                        jobDetail: this.o.jobDetail,
                    };
                    return obj;
                }
            }
            roommaintenance.CloseJob = CloseJob;
            class GetJobDetailUrl extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomMaintenance";
                    this.Controller = "roommaintenance";
                    this.Action = "GetJobDetailUrl";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        roomSpaceMaintenanceID: this.o.roomSpaceMaintenanceID,
                    };
                    return obj;
                }
            }
            roommaintenance.GetJobDetailUrl = GetJobDetailUrl;
            class GetMaintenaceJobs extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomMaintenance";
                    this.Controller = "roommaintenance";
                    this.Action = "GetMaintenaceJobs";
                }
                CallData() {
                    var obj = {
                        jobType: this.o.jobType,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommaintenance.GetMaintenaceJobs = GetMaintenaceJobs;
            class GetMaintenanceItems extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomMaintenance";
                    this.Controller = "roommaintenance";
                    this.Action = "GetMaintenanceItems";
                }
                CallData() {
                    var obj = {
                        categoryID: this.o.categoryID,
                        pageID: this.o.pageID,
                        roomSpaceMaintenanceID: this.o.roomSpaceMaintenanceID,
                    };
                    return obj;
                }
            }
            roommaintenance.GetMaintenanceItems = GetMaintenanceItems;
            class GetMaintenanceRooms extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomMaintenance";
                    this.Controller = "roommaintenance";
                    this.Action = "GetMaintenanceRooms";
                }
                CallData() {
                    var obj = {
                        isMobile: this.o.isMobile,
                        pageID: this.o.pageID,
                        roomSpaceID: this.o.roomSpaceID,
                        roomSpaceMaintenanceID: this.o.roomSpaceMaintenanceID,
                        roomType: this.o.roomType,
                    };
                    return obj;
                }
            }
            roommaintenance.GetMaintenanceRooms = GetMaintenanceRooms;
            class GetRoomMaintenanceJobs extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomMaintenance";
                    this.Controller = "roommaintenance";
                    this.Action = "GetRoomMaintenanceJobs";
                }
                CallData() {
                    var obj = {
                        isMobile: this.o.isMobile,
                        jobType: this.o.jobType,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommaintenance.GetRoomMaintenanceJobs = GetRoomMaintenanceJobs;
            class GetRooms extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomMaintenance";
                    this.Controller = "roommaintenance";
                    this.Action = "GetRooms";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        roomSpaceID: this.o.roomSpaceID,
                        roomSpaceMaintenanceID: this.o.roomSpaceMaintenanceID,
                        roomType: this.o.roomType,
                    };
                    return obj;
                }
            }
            roommaintenance.GetRooms = GetRooms;
            class SaveJob extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomMaintenance";
                    this.Controller = "roommaintenance";
                    this.Action = "SaveJob";
                }
                CallData() {
                    var obj = {
                        jobDetail: this.o.jobDetail,
                    };
                    return obj;
                }
            }
            roommaintenance.SaveJob = SaveJob;
        })(roommaintenance = service.roommaintenance || (service.roommaintenance = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var roommates;
        (function (roommates) {
            var groupsearch;
            (function (groupsearch) {
                "use strict";
                function Initialise($container) {
                    groupsearch.Model = new RoommateGroupSearch($container);
                }
                groupsearch.Initialise = Initialise;
                class RoommateGroupSearch {
                    constructor($container) {
                        this.$container = $container;
                        this.isSearching = false;
                        this.isDirty = false;
                        this.model = starrez.model.RoommateGroupSearchModel($container);
                        this.$filtersContainer = this.$container.find(".ui-filters");
                        this.$resultsContainer = this.$container.find(".ui-results");
                        this.$includeUnlimitedSizeGroup = this.$container.GetControl("IncludeUnlimitedSizeGroup");
                        this.$minGroupSize = this.$filtersContainer.GetControl("MinGroupSize");
                        this.$maxGroupSize = this.$filtersContainer.GetControl("MaxGroupSize");
                        this.$groupName = this.$filtersContainer.GetControl("GroupName");
                        this.$entryNameWeb = this.$filtersContainer.GetControl("EntryNameWeb");
                        this.$profileItemFilters = this.$filtersContainer.GetControl("ProfileItemID").toArray();
                        this.Initialise();
                    }
                    Initialise() {
                        this.AttachEvents();
                        if (this.model.CurrentPageNumber == 0) {
                            this.model.CurrentPageNumber = 1;
                        }
                        this.LoadResults(this.model.CurrentPageNumber);
                    }
                    JoinGroupConfirmationDone(e) {
                        var $joinGroup = $(e.currentTarget);
                        var $result = $joinGroup.closest(".ui-card-result");
                        var roommateGroupID = Number($result.data("roommategroupid"));
                        new starrez.service.roommategroupsearch.JoinGroup({
                            hash: $joinGroup.data("hash"),
                            pageID: portal.page.CurrentPage.PageID,
                            roommateGroupID: roommateGroupID
                        }).Post().done(() => {
                            location.href = this.model.ParentPageUrl;
                        });
                    }
                    AttachEvents() {
                        this.$filtersContainer.find(".ui-select-list").change((e) => {
                            this.LoadResults(1);
                        });
                        //Only do the search on max group textbox' change, because when the leave the min's textbox,
                        //most probably they haven't set the max yet and don't want to do the search yet
                        this.$minGroupSize.change(() => {
                            this.LoadResults(1);
                        });
                        this.$maxGroupSize.change(() => {
                            this.LoadResults(1);
                        });
                        this.$filtersContainer.keydown(e => {
                            if (e.keyCode === starrez.keyboard.EnterCode) {
                                // The browsers have a behaviour where they will automatically submit the form if there is only one
                                // input field on it. This is not what we want to do, so call SafeStopPropagation to block this from happening.
                                // http://stackoverflow.com/questions/1370021/why-does-forms-with-single-input-field-submit-upon-pressing-enter-key-in-input
                                starrez.library.utils.SafeStopPropagation(e);
                                this.LoadResults(1);
                            }
                        });
                        this.$includeUnlimitedSizeGroup.change(() => {
                            this.LoadResults(1);
                        });
                        this.$groupName.change(() => {
                            this.LoadResults(1);
                        });
                        this.$entryNameWeb.change(() => {
                            this.LoadResults(1);
                        });
                        portal.mobile.SetupExpandAndCollapse(this.$filtersContainer);
                        this.$resultsContainer.on("click", ".ui-join-group", (e) => {
                            var $joinGroup = $(e.currentTarget);
                            if ($joinGroup.isEnabled()) {
                                if (this.model.ShowGroupSwitchConfirmation) {
                                    portal.ConfirmAction(this.model.GroupSwitchConfirmationMessage, this.model.GroupSwitchConfirmationTitle).done(() => {
                                        this.JoinGroupConfirmationDone(e);
                                    });
                                }
                                else {
                                    this.JoinGroupConfirmationDone(e);
                                }
                            }
                        });
                        this.$resultsContainer.on("click", ".ui-merge-group", (e) => {
                            var $joinGroup = $(e.currentTarget);
                            var $result = $joinGroup.closest(".ui-card-result");
                            var roommateGroupID = Number($result.data("roommategroupid"));
                            new starrez.service.roommategroupsearch.MergeGroup({
                                hash: $joinGroup.data("hash"),
                                pageID: portal.page.CurrentPage.PageID,
                                roommateGroupID: roommateGroupID
                            }).Post().done(() => {
                                location.href = this.model.ParentPageUrl;
                            });
                        });
                    }
                    GetRoomSearchFilters() {
                        this.model.MinGroupSize = this.$minGroupSize.SRVal();
                        this.model.MaxGroupSize = this.$maxGroupSize.SRVal();
                        this.model.IncludeUnlimitedSizeGroup = this.$includeUnlimitedSizeGroup.SRVal();
                        this.model.GroupName = this.$groupName.SRVal();
                        this.model.EntryNameWeb = this.$entryNameWeb.SRVal();
                        var profileItems = [];
                        this.$profileItemFilters.forEach((filter, index) => {
                            var $filter = $(filter);
                            var value = $filter.SRVal();
                            if (starrez.library.utils.IsNotNullUndefined(value)) {
                                profileItems.push(value);
                            }
                        });
                        return {
                            MinGroupSize: this.model.MinGroupSize,
                            MaxGroupSize: this.model.MaxGroupSize,
                            ProfileItemID: profileItems,
                            IncludeUnlimitedSizeGroup: this.model.IncludeUnlimitedSizeGroup,
                            GroupName: this.model.GroupName,
                            EntryNameWeb: this.model.EntryNameWeb
                        };
                    }
                    LoadResults(currentPageNumber) {
                        this.currentPageNumber = currentPageNumber;
                        if (this.isSearching) {
                            // Prevent multiple searches from happening at once
                            this.isDirty = true;
                            return;
                        }
                        this.isSearching = true;
                        this.isDirty = false;
                        new starrez.service.roommategroupsearch.GetFilterResults({
                            pageID: portal.page.CurrentPage.PageID,
                            filters: this.GetRoomSearchFilters(),
                            currentPageNumber: this.currentPageNumber
                        }).Request({
                            ActionVerb: starrez.library.service.RequestType.Post,
                            ShowLoading: false,
                            LoadingFunc: (loading) => {
                                if (loading) {
                                    this.$resultsContainer.addClass("loading");
                                }
                                else {
                                    this.$resultsContainer.removeClass("loading");
                                }
                            }
                        }).done((result) => {
                            this.isSearching = false;
                            if (this.isDirty) {
                                this.LoadResults(this.currentPageNumber);
                                return;
                            }
                            this.$resultsContainer.html(result);
                            portal.paging.AttachPagingClickEvent(this, this.$resultsContainer, this.LoadResults);
                        });
                    }
                }
            })(groupsearch = roommates.groupsearch || (roommates.groupsearch = {}));
        })(roommates = general.roommates || (general.roommates = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.roommates.groupsearch.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var roommates;
        (function (roommates) {
            var join;
            (function (join) {
                "use strict";
                function InitRoomJoinPage($container) {
                    new RoommateGroupJoinModel($container);
                }
                join.InitRoomJoinPage = InitRoomJoinPage;
                class RoommateGroupJoinModel {
                    constructor($container) {
                        this.$container = $container;
                        this.model = starrez.model.RoommateGroupJoinModel($container);
                        portal.page.CurrentPage.AddCustomValidation(this);
                    }
                    Validate() {
                        var deferred = $.Deferred();
                        if (!this.model.ShowGroupSwitchConfirmation) {
                            return deferred.resolve();
                        }
                        return portal.ConfirmAction(this.model.GroupSwitchConfirmationMessage, this.model.GroupSwitchConfirmationTitle);
                    }
                }
            })(join = roommates.join || (roommates.join = {}));
        })(roommates = general.roommates || (general.roommates = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.roommates.join.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var roommates;
        (function (roommates) {
            var main;
            (function (main) {
                "use strict";
                function InitialiseRoommateGroupManager($container) {
                    new RoommateGroupManager($container);
                }
                main.InitialiseRoommateGroupManager = InitialiseRoommateGroupManager;
                function InitialiseRoommateGroupList($container) {
                    new RoommateGroupListManager($container);
                }
                main.InitialiseRoommateGroupList = InitialiseRoommateGroupList;
                class RoommateListManager {
                    constructor($container) {
                        this.$container = $container;
                        this.$container.find(".ui-btn-send-message").SRClick(e => this.GoToPage(e));
                        this.$container.find(".ui-btn-view-profile").SRClick(e => this.GoToPage(e));
                    }
                    GoToPage(e) {
                        this.NavigatingToRelatedPage();
                        location.href = $(e.currentTarget).data("url");
                    }
                    NavigatingToRelatedPage() {
                    }
                }
                main.RoommateListManager = RoommateListManager;
                class RoommateGroupManager {
                    constructor($container) {
                        this.$container = $container;
                        this.model = starrez.model.RoommateGroupManageModel($container);
                        this.$container.find(".ui-leave-group").SRClick((e) => this.LeaveGroup(e));
                        this.$container.find(".ui-verify-group").SRClick((e) => this.VerifyGroup(e));
                        this.$container.find(".ui-delete-group").SRClick((e) => this.DeleteGroup(e));
                        this.$container.find(".ui-delete-invitation").SRClick((e) => this.CancelInvitation(e));
                        this.$container.find(".ui-accept-request").SRClick((e) => this.AcceptRequest(e));
                        this.$container.find(".ui-decline-request").SRClick((e) => this.DeclineRequest(e));
                        this.$container.find(".ui-cancel-request").SRClick((e) => this.CancelRequest(e));
                        this.$container.find(".ui-accept-merge-request").SRClick((e) => this.AcceptMergeRequest(e));
                        this.$container.find(".ui-decline-merge-request").SRClick((e) => this.DeclineMergeRequest(e));
                        this.$container.find(".ui-cancel-merge-request").SRClick((e) => this.CancelMergeRequest(e));
                    }
                    LeaveGroup(e) {
                        portal.ConfirmAction(this.model.LeaveGroupConfirmationMessage, "Leave Group").done(() => {
                            var $button = $(e.currentTarget);
                            var hash = $button.data("hash").toString();
                            var entryApplicationID = Number($button.data("applicationid"));
                            return new starrez.service.roommates.DeleteRoommate({
                                hash: hash,
                                pageID: portal.page.CurrentPage.PageID,
                                entryApplicationID: entryApplicationID
                            }).Post().done(() => {
                                location.reload();
                            });
                        });
                    }
                    VerifyGroup(e) {
                        new starrez.service.roommates.VerifyGroup({
                            pageID: portal.page.CurrentPage.PageID,
                            groupID: this.model.RoommateGroupID,
                            hash: $(e.currentTarget).data("hash").toString()
                        }).Post().done(() => {
                            location.reload();
                        });
                    }
                    CancelInvitation(e) {
                        var $currentTarget = $(e.currentTarget);
                        var $invitationactionPanel = $currentTarget.closest(".ui-action-panel");
                        portal.ConfirmAction(this.model.CancelInvitationConfirmationMessage, this.model.CancelInvitationConfirmationMessageTitle).done(() => {
                            new starrez.service.roommates.CancelInvitation({
                                entryInvitationID: Number($invitationactionPanel.data("entryinvitationid")),
                                pageID: portal.page.CurrentPage.PageID,
                                hash: $currentTarget.data("hash")
                            }).Post().done(() => {
                                location.reload();
                            });
                        });
                    }
                    DeleteGroup(e) {
                        portal.ConfirmAction(this.model.DeleteGroupConfirmationMessage, "Delete Group").done(() => {
                            var $button = $(e.currentTarget);
                            new starrez.service.roommates.DeleteGroup({
                                pageID: portal.page.CurrentPage.PageID,
                                groupID: this.model.RoommateGroupID,
                                hash: $button.data("hash").toString()
                            }).Post().done(() => {
                                location.reload();
                            });
                        });
                    }
                    AcceptRequestConfirmationDone(e) {
                        var $currentTarget = $(e.currentTarget);
                        var $requestActionPanel = $currentTarget.closest(".ui-action-panel");
                        new starrez.service.roommates.AcceptRequest({
                            roommateGroupRequestID: Number($requestActionPanel.data("roommategrouprequestid")),
                            isMember: starrez.library.convert.ToBoolean($requestActionPanel.data("ismember")),
                            pageID: portal.page.CurrentPage.PageID,
                            hash: $currentTarget.data("hash")
                        }).Post().done(() => {
                            location.reload();
                        });
                    }
                    AcceptRequest(e) {
                        var $currentTarget = $(e.currentTarget);
                        var $requestActionPanel = $currentTarget.closest(".ui-action-panel");
                        if (this.model.ShowGroupSwitchConfirmation && !starrez.library.convert.ToBoolean($requestActionPanel.data("ismember"))) {
                            portal.ConfirmAction(this.model.GroupSwitchConfirmationMessageTS, this.model.GroupSwitchConfirmationTitleTS).done(() => {
                                this.AcceptRequestConfirmationDone(e);
                            });
                        }
                        else {
                            this.AcceptRequestConfirmationDone(e);
                        }
                    }
                    DeclineRequest(e) {
                        var $currentTarget = $(e.currentTarget);
                        var $requestActionPanel = $currentTarget.closest(".ui-action-panel");
                        new starrez.service.roommates.DeclineRequest({
                            roommateGroupRequestID: Number($requestActionPanel.data("roommategrouprequestid")),
                            isMember: starrez.library.convert.ToBoolean($requestActionPanel.data("ismember")),
                            pageID: portal.page.CurrentPage.PageID,
                            hash: $currentTarget.data("hash")
                        }).Post().done(() => {
                            location.reload();
                        });
                    }
                    CancelRequest(e) {
                        var $currentTarget = $(e.currentTarget);
                        var $requestActionPanel = $currentTarget.closest(".ui-action-panel");
                        new starrez.service.roommates.CancelRequest({
                            roommateGroupRequestID: Number($requestActionPanel.data("roommategrouprequestid")),
                            isMember: starrez.library.convert.ToBoolean($requestActionPanel.data("ismember")),
                            pageID: portal.page.CurrentPage.PageID,
                            hash: $currentTarget.data("hash")
                        }).Post().done(() => {
                            location.reload();
                        });
                    }
                    AcceptMergeRequest(e) {
                        var $currentTarget = $(e.currentTarget);
                        var $requestActionPanel = $currentTarget.closest(".ui-action-panel");
                        new starrez.service.roommates.AcceptMergeRequest({
                            requesterRoommateGroupID: Number($requestActionPanel.data("requesterroommategroupid")),
                            roommateGroupRequestID: Number($requestActionPanel.data("roommategrouprequestid")),
                            pageID: portal.page.CurrentPage.PageID,
                            hash: $currentTarget.data("hash")
                        }).Post().done(() => {
                            location.reload();
                        });
                    }
                    DeclineMergeRequest(e) {
                        var $currentTarget = $(e.currentTarget);
                        var $requestActionPanel = $currentTarget.closest(".ui-action-panel");
                        new starrez.service.roommates.DeclineMergeRequest({
                            requesterRoommateGroupID: Number($requestActionPanel.data("requesterroommategroupid")),
                            roommateGroupRequestID: Number($requestActionPanel.data("roommategrouprequestid")),
                            pageID: portal.page.CurrentPage.PageID,
                            hash: $currentTarget.data("hash")
                        }).Post().done(() => {
                            location.reload();
                        });
                    }
                    CancelMergeRequest(e) {
                        var $currentTarget = $(e.currentTarget);
                        var $requestActionPanel = $currentTarget.closest(".ui-action-panel");
                        new starrez.service.roommates.CancelMergeRequest({
                            requesterRoommateGroupID: Number($requestActionPanel.data("requesterroommategroupid")),
                            roommateGroupRequestID: Number($requestActionPanel.data("roommategrouprequestid")),
                            pageID: portal.page.CurrentPage.PageID,
                            hash: $currentTarget.data("hash")
                        }).Post().done(() => {
                            location.reload();
                        });
                    }
                }
                class RoommateGroupListManager extends RoommateListManager {
                    constructor($container) {
                        super($container);
                        this.$container = $container;
                        this.model = starrez.model.RoommateGroupManageModel($container);
                        this.$container.find(".ui-delete-roommate").SRClick((e) => this.DeleteRoommate(e));
                        this.$container.find(".ui-make-leader").SRClick((e) => this.MakeLeader(e));
                        this.$container.find(".ui-move-up").SRClick((e) => this.ChangeRoommateOrder(e, true));
                        this.$container.find(".ui-move-down").SRClick((e) => this.ChangeRoommateOrder(e, false));
                    }
                    DeleteRoommate(e) {
                        var $button = $(e.currentTarget);
                        var $actionPanel = $button.closest(".ui-action-panel");
                        var message = this.SubstituteRoommateName(this.model.RemoveRoommateConfirmationMessage, $actionPanel);
                        portal.ConfirmAction(message, "Remove Roommate").done(() => {
                            var hash = $button.data("hash").toString();
                            var entryApplicationID = this.GetEntryApplicationID($actionPanel);
                            new starrez.service.roommates.DeleteRoommate({
                                hash: hash,
                                pageID: portal.page.CurrentPage.PageID,
                                entryApplicationID: entryApplicationID
                            }).Post().done(() => {
                                location.reload();
                            });
                        });
                    }
                    MakeLeader(e) {
                        var $button = $(e.currentTarget);
                        var $actionPanel = $button.closest(".ui-action-panel");
                        var message = this.SubstituteRoommateName(this.model.MakeGroupLeaderConfirmationMessage, $actionPanel);
                        portal.ConfirmAction(message, "Make Leader").done(() => {
                            var hash = $button.data("hash").toString();
                            var roommateApplicationID = this.GetEntryApplicationID($actionPanel);
                            new starrez.service.roommates.MakeLeader({
                                pageID: portal.page.CurrentPage.PageID,
                                newLeaderApplicationID: roommateApplicationID,
                                groupID: this.model.RoommateGroupID,
                                hash: hash
                            }).Post().done(() => {
                                location.reload();
                            });
                        });
                    }
                    ChangeRoommateOrder(e, moveUp) {
                        var $actionPanel = $(e.currentTarget).closest(".ui-action-panel");
                        var hashName = moveUp ? "moveuphash" : "movedownhash";
                        new starrez.service.roommates.ChangeRoommateOrder({
                            roommateApplicationID: this.GetEntryApplicationID($actionPanel),
                            groupID: this.model.RoommateGroupID,
                            moveUp: moveUp,
                            hash: $actionPanel.data(hashName).toString()
                        }).Post().done(() => {
                            if (moveUp) {
                                $actionPanel.insertBefore($actionPanel.prev());
                            }
                            else {
                                $actionPanel.insertAfter($actionPanel.next());
                            }
                        });
                    }
                    GetEntryApplicationID($actionPanel) {
                        return Number($actionPanel.data("entryapplicationid"));
                    }
                    SubstituteRoommateName(message, $actionPanel) {
                        return message.replace("{RoommateName}", $actionPanel.find(".ui-title").text());
                    }
                }
            })(main = roommates.main || (roommates.main = {}));
        })(roommates = general.roommates || (general.roommates = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.roommates.main.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var roommates;
        (function (roommates) {
            var search;
            (function (search) {
                "use strict";
                const StorageKeyPrefix = "Roommates.";
                const SearchManagerName = "SearchManager";
                function InitialiseFieldListEditor($container) {
                    portal.fieldlist.control.InitFieldListManager($container, existingFields => new starrez.service.roommatesearch.CreateNewField({
                        existingFields: existingFields
                    }));
                }
                search.InitialiseFieldListEditor = InitialiseFieldListEditor;
                function InitialiseDetailsSearchManager($container) {
                    $container.data(SearchManagerName, new DetailsSearchManager($container));
                }
                search.InitialiseDetailsSearchManager = InitialiseDetailsSearchManager;
                function InitialiseProfilesSearchManager($container) {
                    $container.data(SearchManagerName, new ProfilesSearchManager($container));
                }
                search.InitialiseProfilesSearchManager = InitialiseProfilesSearchManager;
                function InitialiseResultsManager($container) {
                    new SearchResultsManaager($container);
                }
                search.InitialiseResultsManager = InitialiseResultsManager;
                class SearchResultsManaager extends portal.general.roommates.main.RoommateListManager {
                    constructor($container) {
                        super($container);
                        this.$container = $container;
                        this.model = starrez.model.PotentialRoommatesModel(this.$container);
                        this.$container.find(".ui-btn-invite").SRClick((e) => this.Invite(e));
                        this.$container.find(".ui-btn-join").SRClick((e) => this.JoinGroup(e));
                        this.$container.find(".ui-btn-merge").SRClick((e) => this.MergeGroup(e));
                    }
                    Invite(e) {
                        var $button = $(e.currentTarget);
                        var hash = $button.data("hash").toString();
                        var $actionPanel = $button.closest(".ui-action-panel");
                        var entryApplicationID = Number($actionPanel.data("entryapplicationid"));
                        new starrez.service.roommatesearch.InviteToGroup({
                            pageID: portal.page.CurrentPage.PageID,
                            groupID: this.model.RoommateGroupID,
                            entryApplicationID: entryApplicationID,
                            hash: hash
                        }).Post().done((url) => {
                            location.href = url;
                        });
                    }
                    JoinGroupConfirmationDone(e) {
                        var $button = $(e.currentTarget);
                        var hash = $button.data("hash").toString();
                        var $actionPanel = $button.closest(".ui-action-panel");
                        var entryApplicationID = Number($actionPanel.data("entryapplicationid"));
                        var roommateGroupID = Number($actionPanel.data("roommategroupid"));
                        new starrez.service.roommatesearch.JoinGroup({
                            pageID: portal.page.CurrentPage.PageID,
                            groupID: roommateGroupID,
                            entryApplicationID: entryApplicationID,
                            hash: hash
                        }).Post().done((url) => {
                            location.href = url;
                        });
                    }
                    JoinGroup(e) {
                        var $button = $(e.currentTarget);
                        var $actionPanel = $button.closest(".ui-action-panel");
                        if (this.model.ShowGroupSwitchConfirmation) {
                            portal.ConfirmAction(this.model.GroupSwitchConfirmationMessage, this.model.GroupSwitchConfirmationTitle).done(() => {
                                this.JoinGroupConfirmationDone(e);
                            });
                        }
                        else {
                            this.JoinGroupConfirmationDone(e);
                        }
                    }
                    MergeGroup(e) {
                        var $button = $(e.currentTarget);
                        var hash = $button.data("hash").toString();
                        var $actionPanel = $button.closest(".ui-action-panel");
                        var entryApplicationID = Number($actionPanel.data("entryapplicationid"));
                        new starrez.service.roommatesearch.MergeGroup({
                            pageID: portal.page.CurrentPage.PageID,
                            groupID: this.model.RoommateGroupID,
                            entryApplicationID: entryApplicationID,
                            hash: hash
                        }).Post().done((url) => {
                            location.href = url;
                        });
                    }
                    NavigatingToRelatedPage() {
                        var searchManager = this.$container.closest(".ui-roommate-search").data(SearchManagerName);
                        if (starrez.library.utils.IsNotNullUndefined(searchManager)) {
                            searchManager.SaveFilters();
                        }
                    }
                }
                class SearchManager {
                    constructor($container) {
                        this.$container = $container;
                        this.$searchResults = this.$container.find(".ui-search-results");
                        this.$hideUnactionableResults = this.$container.GetControl("HideUnactionableResults");
                        this.$container.find(".ui-btn-search").SRClick(() => this.Search());
                        this.model = starrez.model.RoommateSearchBaseModel(this.$container);
                        if (this.FillFilters()) {
                            this.Search();
                        }
                        this.$container.find(".ui-field").keydown(e => {
                            if (e.keyCode === starrez.keyboard.EnterCode) {
                                this.Search();
                                // The browsers have a behaviour where they will automatically submit the form if there is only one
                                // input field on it. This is not what we want to do, so call SafeStopPropagation to block this from happening.
                                // http://stackoverflow.com/questions/1370021/why-does-forms-with-single-input-field-submit-upon-pressing-enter-key-in-input
                                starrez.library.utils.SafeStopPropagation(e);
                            }
                        });
                    }
                    Search() {
                        var filters = this.GetSearchFilters();
                        if (filters.length > 0) {
                            portal.page.CurrentPage.ClearMessages();
                            this.GetSearchRequest(filters).Post().done(results => {
                                this.$searchResults.html(results);
                                $.ScrollToWithAnimation(this.$searchResults);
                            });
                        }
                        else {
                            portal.page.CurrentPage.SetErrorMessage(this.model.NoSearchCriteriaErrorMessage);
                        }
                    }
                    GetSearchFilters() {
                        return this.$container.find(".ui-field").GetAllControls().map((index, ctrl) => this.GetPopulatedFilter($(ctrl))).toArray();
                    }
                    SaveFilters() {
                        var obj = new starrez.library.collections.KeyValue();
                        obj.AddRange(this.GetSearchFilters());
                        localStorage.setItem(this.GetStorageKey(), JSON.stringify(obj.ToObjectProperty()));
                    }
                    FillFilters() {
                        var filters = JSON.parse(localStorage.getItem(this.GetStorageKey()));
                        var hadFilters = false;
                        if (starrez.library.utils.IsNotNullUndefined(filters)) {
                            this.$container.find(".ui-field").GetAllControls().each((index, ctrl) => {
                                var $ctrl = $(ctrl);
                                var value = filters[this.GetControlKey($ctrl)];
                                if (starrez.library.utils.IsNotNullUndefined(value)) {
                                    $ctrl.SRVal(value);
                                    hadFilters = true;
                                }
                            });
                            this.ClearSavedFilter();
                        }
                        return hadFilters;
                    }
                    ClearSavedFilter() {
                        localStorage.removeItem(this.GetStorageKey());
                    }
                    GetStorageKey() {
                        return StorageKeyPrefix + this.GetStorageKeySuffix();
                    }
                }
                class DetailsSearchManager extends SearchManager {
                    GetStorageKeySuffix() {
                        return "Details";
                    }
                    GetControlKey($ctrl) {
                        return $ctrl.closest("li").data("field-id").toString();
                    }
                    GetPopulatedFilter($ctrl) {
                        var value = $ctrl.SRVal();
                        if (!starrez.library.stringhelper.IsUndefinedOrEmpty(value)) {
                            return {
                                Key: this.GetControlKey($ctrl),
                                Value: value
                            };
                        }
                        return null;
                    }
                    GetSearchRequest(filters) {
                        return new starrez.service.roommatesearch.SearchByDetails({
                            pageID: portal.page.CurrentPage.PageID,
                            searchTerms: filters,
                            hideUnactionableResults: this.$hideUnactionableResults.isFound() ? this.$hideUnactionableResults.SRVal() : true,
                            hash: this.model.SearchHash
                        });
                    }
                }
                class ProfilesSearchManager extends SearchManager {
                    GetStorageKeySuffix() {
                        return "Profiles";
                    }
                    GetControlKey($ctrl) {
                        var profileItemID = Number($ctrl.closest("li").data("item-id"));
                        var selectedOption = Number($ctrl.SRVal());
                        var isMandatory = isNaN(profileItemID);
                        return (isMandatory ? selectedOption : profileItemID).toString();
                    }
                    GetPopulatedFilter($ctrl) {
                        var profileItemID = Number($ctrl.closest("li").data("item-id"));
                        var selectedOption = Number($ctrl.SRVal());
                        var isMandatory = isNaN(profileItemID);
                        if (!isNaN(selectedOption) && selectedOption != -1) {
                            return {
                                Key: (isMandatory ? selectedOption : profileItemID).toString(),
                                Value: isMandatory ? NaN : selectedOption
                            };
                        }
                    }
                    GetSearchRequest(filters) {
                        return new starrez.service.roommatesearch.SearchByProfiles({
                            pageID: portal.page.CurrentPage.PageID,
                            searchProfiles: filters,
                            hideUnactionableResults: this.$hideUnactionableResults.isFound() ? this.$hideUnactionableResults.SRVal() : true,
                            hash: this.model.SearchHash
                        });
                    }
                }
            })(search = roommates.search || (roommates.search = {}));
        })(roommates = general.roommates || (general.roommates = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.roommates.search.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function PotentialRoommatesModel($sys) {
            return {
                EntryApplicationID: Number($sys.data('entryapplicationid')),
                GroupSwitchConfirmationMessage: $sys.data('groupswitchconfirmationmessage'),
                GroupSwitchConfirmationTitle: $sys.data('groupswitchconfirmationtitle'),
                RoommateGroupID: Number($sys.data('roommategroupid')),
                ShowGroupSwitchConfirmation: starrez.library.convert.ToBoolean($sys.data('showgroupswitchconfirmation')),
            };
        }
        model.PotentialRoommatesModel = PotentialRoommatesModel;
        function RoommateGroupJoinModel($sys) {
            return {
                GroupSwitchConfirmationMessage: $sys.data('groupswitchconfirmationmessage'),
                GroupSwitchConfirmationTitle: $sys.data('groupswitchconfirmationtitle'),
                ShowGroupSwitchConfirmation: starrez.library.convert.ToBoolean($sys.data('showgroupswitchconfirmation')),
            };
        }
        model.RoommateGroupJoinModel = RoommateGroupJoinModel;
        function RoommateGroupManageModel($sys) {
            return {
                CancelInvitationConfirmationMessage: $sys.data('cancelinvitationconfirmationmessage'),
                CancelInvitationConfirmationMessageTitle: $sys.data('cancelinvitationconfirmationmessagetitle'),
                DeleteGroupConfirmationMessage: $sys.data('deletegroupconfirmationmessage'),
                GroupSwitchConfirmationMessageTS: $sys.data('groupswitchconfirmationmessagets'),
                GroupSwitchConfirmationTitleTS: $sys.data('groupswitchconfirmationtitlets'),
                LeaveGroupConfirmationMessage: $sys.data('leavegroupconfirmationmessage'),
                MakeGroupLeaderConfirmationMessage: $sys.data('makegroupleaderconfirmationmessage'),
                RemoveRoommateConfirmationMessage: $sys.data('removeroommateconfirmationmessage'),
                RoommateGroupID: Number($sys.data('roommategroupid')),
                ShowGroupSwitchConfirmation: starrez.library.convert.ToBoolean($sys.data('showgroupswitchconfirmation')),
            };
        }
        model.RoommateGroupManageModel = RoommateGroupManageModel;
        function RoommateGroupSearchModel($sys) {
            return {
                CurrentPageNumber: Number($sys.data('currentpagenumber')),
                EntryNameWeb: $sys.data('entrynameweb'),
                GroupName: $sys.data('groupname'),
                GroupSwitchConfirmationMessage: $sys.data('groupswitchconfirmationmessage'),
                GroupSwitchConfirmationTitle: $sys.data('groupswitchconfirmationtitle'),
                IncludeUnlimitedSizeGroup: starrez.library.convert.ToBoolean($sys.data('includeunlimitedsizegroup')),
                MaxGroupSize: Number($sys.data('maxgroupsize')),
                MinGroupSize: Number($sys.data('mingroupsize')),
                ParentPageUrl: $sys.data('parentpageurl'),
                ProfileItemID: ($sys.data('profileitemid') === '') ? [] : ($sys.data('profileitemid')).toString().split(',').map(function (e) { return Number(e); }),
                ShowGroupSwitchConfirmation: starrez.library.convert.ToBoolean($sys.data('showgroupswitchconfirmation')),
            };
        }
        model.RoommateGroupSearchModel = RoommateGroupSearchModel;
        function RoommateSearchBaseModel($sys) {
            return {
                NoSearchCriteriaErrorMessage: $sys.data('nosearchcriteriaerrormessage'),
                SearchHash: $sys.data('searchhash'),
            };
        }
        model.RoommateSearchBaseModel = RoommateSearchBaseModel;
        function RoommateSearchByDetailsModel($sys) {
            return {};
        }
        model.RoommateSearchByDetailsModel = RoommateSearchByDetailsModel;
        function RoommateSearchByProfilesModel($sys) {
            return {};
        }
        model.RoommateSearchByProfilesModel = RoommateSearchByProfilesModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var roommategroupsearch;
        (function (roommategroupsearch) {
            "use strict";
            class GetFilterResults extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommategroupsearch";
                    this.Action = "GetFilterResults";
                }
                CallData() {
                    var obj = {
                        currentPageNumber: this.o.currentPageNumber,
                        filters: this.o.filters,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommategroupsearch.GetFilterResults = GetFilterResults;
            class JoinGroup extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommategroupsearch";
                    this.Action = "JoinGroup";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        roommateGroupID: this.o.roommateGroupID,
                    };
                    return obj;
                }
            }
            roommategroupsearch.JoinGroup = JoinGroup;
            class MergeGroup extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommategroupsearch";
                    this.Action = "MergeGroup";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        roommateGroupID: this.o.roommateGroupID,
                    };
                    return obj;
                }
            }
            roommategroupsearch.MergeGroup = MergeGroup;
        })(roommategroupsearch = service.roommategroupsearch || (service.roommategroupsearch = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var roommates;
        (function (roommates) {
            "use strict";
            class AcceptMergeRequest extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "AcceptMergeRequest";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        requesterRoommateGroupID: this.o.requesterRoommateGroupID,
                        roommateGroupRequestID: this.o.roommateGroupRequestID,
                    };
                    return obj;
                }
            }
            roommates.AcceptMergeRequest = AcceptMergeRequest;
            class AcceptRequest extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "AcceptRequest";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        isMember: this.o.isMember,
                        pageID: this.o.pageID,
                        roommateGroupRequestID: this.o.roommateGroupRequestID,
                    };
                    return obj;
                }
            }
            roommates.AcceptRequest = AcceptRequest;
            class CancelInvitation extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "CancelInvitation";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        entryInvitationID: this.o.entryInvitationID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommates.CancelInvitation = CancelInvitation;
            class CancelMergeRequest extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "CancelMergeRequest";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        requesterRoommateGroupID: this.o.requesterRoommateGroupID,
                        roommateGroupRequestID: this.o.roommateGroupRequestID,
                    };
                    return obj;
                }
            }
            roommates.CancelMergeRequest = CancelMergeRequest;
            class CancelRequest extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "CancelRequest";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        isMember: this.o.isMember,
                        pageID: this.o.pageID,
                        roommateGroupRequestID: this.o.roommateGroupRequestID,
                    };
                    return obj;
                }
            }
            roommates.CancelRequest = CancelRequest;
            class ChangeRoommateOrder extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "ChangeRoommateOrder";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        groupID: this.o.groupID,
                        moveUp: this.o.moveUp,
                        roommateApplicationID: this.o.roommateApplicationID,
                    };
                    return obj;
                }
            }
            roommates.ChangeRoommateOrder = ChangeRoommateOrder;
            class DeclineMergeRequest extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "DeclineMergeRequest";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        requesterRoommateGroupID: this.o.requesterRoommateGroupID,
                        roommateGroupRequestID: this.o.roommateGroupRequestID,
                    };
                    return obj;
                }
            }
            roommates.DeclineMergeRequest = DeclineMergeRequest;
            class DeclineRequest extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "DeclineRequest";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        isMember: this.o.isMember,
                        pageID: this.o.pageID,
                        roommateGroupRequestID: this.o.roommateGroupRequestID,
                    };
                    return obj;
                }
            }
            roommates.DeclineRequest = DeclineRequest;
            class DeleteGroup extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "DeleteGroup";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommates.DeleteGroup = DeleteGroup;
            class DeleteRoommate extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "DeleteRoommate";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        entryApplicationID: this.o.entryApplicationID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommates.DeleteRoommate = DeleteRoommate;
            class MakeLeader extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "MakeLeader";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        groupID: this.o.groupID,
                        newLeaderApplicationID: this.o.newLeaderApplicationID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommates.MakeLeader = MakeLeader;
            class VerifyGroup extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommates";
                    this.Action = "VerifyGroup";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommates.VerifyGroup = VerifyGroup;
        })(roommates = service.roommates || (service.roommates = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var roommatesearch;
        (function (roommatesearch) {
            "use strict";
            class CreateNewField extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommatesearch";
                    this.Action = "CreateNewField";
                }
                CallData() {
                    var obj = {
                        existingFields: this.o.existingFields,
                    };
                    return obj;
                }
            }
            roommatesearch.CreateNewField = CreateNewField;
            class InviteToGroup extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommatesearch";
                    this.Action = "InviteToGroup";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        entryApplicationID: this.o.entryApplicationID,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommatesearch.InviteToGroup = InviteToGroup;
            class JoinGroup extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommatesearch";
                    this.Action = "JoinGroup";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        entryApplicationID: this.o.entryApplicationID,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommatesearch.JoinGroup = JoinGroup;
            class MergeGroup extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommatesearch";
                    this.Action = "MergeGroup";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        entryApplicationID: this.o.entryApplicationID,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommatesearch.MergeGroup = MergeGroup;
            class SearchByDetails extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommatesearch";
                    this.Action = "SearchByDetails";
                }
                CallData() {
                    var obj = {
                        hideUnactionableResults: this.o.hideUnactionableResults,
                        searchTerms: this.o.searchTerms,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommatesearch.SearchByDetails = SearchByDetails;
            class SearchByProfiles extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Roommates";
                    this.Controller = "roommatesearch";
                    this.Action = "SearchByProfiles";
                }
                CallData() {
                    var obj = {
                        hideUnactionableResults: this.o.hideUnactionableResults,
                        searchProfiles: this.o.searchProfiles,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roommatesearch.SearchByProfiles = SearchByProfiles;
        })(roommatesearch = service.roommatesearch || (service.roommatesearch = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var roompreferences;
    (function (roompreferences) {
        "use strict";
        function InitRoomPreferencesPage($container) {
            new RoomPreferencesWidget($container);
        }
        roompreferences.InitRoomPreferencesPage = InitRoomPreferencesPage;
        class RoomPreferencesWidget {
            constructor($container) {
                this.$container = $container;
                this.roomPreferencesModel = starrez.model.RoomPreferencesBaseModel($container);
                this.$addButton = this.$container.find('.ui-add-room-preference');
                this.$saveButton = $('body').find('.ui-submit-page-content');
                this.$preferenceMessage = this.$container.find('.ui-preference-message');
                this.availableLocations = this.roomPreferencesModel.AvailableLocations;
                this.availablePreferences = this.roomPreferencesModel.AvailablePreferences;
                this.$responsiveTableContainer = $container.find('.ui-responsive-active-table-container');
                this.$responsiveTableContainer.on(starrez.activetable.responsive.eventTableLoaded, () => {
                    this.BindTable();
                });
            }
            IsMobile() {
                return this.$responsiveTableContainer.data('isMobile') === true;
            }
            GetRowSelector() {
                return this.IsMobile() ? "tbody" : "tbody tr";
            }
            GetRows() {
                return this.preferencesTable.$table.find(this.GetRowSelector());
            }
            BindTable() {
                // Bind events in here
                this.preferencesTable = starrez.tablesetup.CreateTableManager(this.$responsiveTableContainer.find("table"), $('body'))[0];
                this.$newRowTemplate = this.GetRows().first();
                this.AttachAddEvents();
                this.AttachDeleteEvents();
                this.AttachDropDownEvents();
                this.RefilterLocationDropDowns();
                this.RefilterPreferenceDropDowns();
                this.UpdateAddAndSave();
                this.ShowRemainingPreferencesMessage();
                portal.page.CurrentPage.FetchAdditionalData = () => this.GetData();
                portal.page.CurrentPage.AddCustomValidation(this);
            }
            Validate() {
                var deferred = $.Deferred();
                if (this.isValid) {
                    deferred.resolve();
                }
                else {
                    deferred.reject();
                }
                return deferred.promise();
            }
            GetData() {
                var data = this.GetPreferenceIDs();
                return {
                    SelectedPreferences: data
                };
            }
            AttachAddEvents() {
                this.$addButton.SRClick(() => {
                    this.AddNewPreferenceRow();
                });
            }
            AttachDeleteEvents() {
                this.preferencesTable.$table.SRClickDelegate('delete', '.ui-btn-delete', (e) => {
                    $(e.currentTarget).closest(this.GetRowSelector()).remove();
                    this.RefilterLocationDropDowns();
                    this.RefilterPreferenceDropDowns();
                    this.UpdateRowOrder();
                    this.UpdateAddAndSave();
                    this.ShowRemainingPreferencesMessage();
                });
            }
            AddNewPreferenceRow() {
                if (this.MaximumPreferencesReached()) {
                    this.ShowMessage(this.roomPreferencesModel.MaximumNumberOfPreferencesReachedErrorMessage);
                    return;
                }
                this.preferencesTable.$table.append(this.$newRowTemplate.clone());
                this.RefilterLocationDropDowns();
                this.RefilterPreferenceDropDowns();
                this.UpdateRowOrder();
                this.UpdateAddAndSave();
                this.ShowRemainingPreferencesMessage();
            }
            MinimumPreferencesReached() {
                if (this.roomPreferencesModel.MinimumNumberOfPreferences < 1)
                    return true;
                return this.GetRows().length >= this.roomPreferencesModel.MinimumNumberOfPreferences;
            }
            MaximumPreferencesReached() {
                if (this.roomPreferencesModel.MaximumNumberOfPreferences < 1)
                    return false;
                return this.GetRows().length >= this.roomPreferencesModel.MaximumNumberOfPreferences;
            }
            ShowMessage(message) {
                this.$preferenceMessage.find('div').text(message);
                this.$preferenceMessage.show();
            }
            ClearMessage() {
                this.$preferenceMessage.hide();
            }
            GetPreferenceIDs() {
                var preferenceIDs = [];
                this.GetRows().each((index, element) => {
                    var $preferenceDropDown = $(element).find('.ui-preference-dropdown').GetControl('PreferenceDropdown');
                    var preferenceValue = $preferenceDropDown.SRVal();
                    preferenceIDs.push(preferenceValue);
                });
                return preferenceIDs;
            }
            ShowRemainingPreferencesMessage() {
                var selectionCount = this.GetPreferenceIDs().length;
                var message = this.roomPreferencesModel.RemainingPreferencesMessage;
                message = message.replace("{number}", starrez.library.convert.ToString(this.roomPreferencesModel.MaximumNumberOfPreferences - selectionCount));
                this.ShowMessage(message);
            }
            GetLocationValues() {
                var locationValues = [];
                this.GetRows().each((index, element) => {
                    var $locationDropDown = $(element).find('.ui-location-dropdown').GetControl('LocationDropdown');
                    var locationValue = $locationDropDown.SRVal();
                    locationValues.push(locationValue);
                });
                return locationValues;
            }
            RefilterLocationDropDowns() {
                if (this.roomPreferencesModel.SelectPreferencesWithoutLocations)
                    return;
                var selectedLocations = this.GetLocationValues();
                this.GetRows().each((index, element) => {
                    var $locationDropDown = $(element).find('.ui-location-dropdown').GetControl('LocationDropdown');
                    var selectedLocation = $locationDropDown.SRVal();
                    var filteredLocations = this.availableLocations.filter(item => (item.Value === "-1" ||
                        item.Value === selectedLocation ||
                        selectedLocations.filter(value => value === item.Value).length < this.roomPreferencesModel.MaxPreferencesPerLocation));
                    this.FillDropDown(filteredLocations, $locationDropDown, selectedLocation);
                });
            }
            RefilterPreferenceDropDowns() {
                var selectedPreferences = this.GetPreferenceIDs();
                this.GetRows().each((index, element) => {
                    var $preferenceDropDown = $(element).find('.ui-preference-dropdown').GetControl('PreferenceDropdown');
                    var selectedPreference = $preferenceDropDown.SRVal();
                    var filteredPreferences;
                    if (this.roomPreferencesModel.SelectPreferencesWithoutLocations) {
                        filteredPreferences = this.availablePreferences.filter(item => (item.Value === "-1" || item.Value === selectedPreference || selectedPreferences.indexOf(item.Value) < 0));
                    }
                    else {
                        var $locationDropDown = $(element).find('.ui-location-dropdown').GetControl('LocationDropdown');
                        var selectedLocation = $locationDropDown.SRVal();
                        filteredPreferences = this.availablePreferences.filter(item => (item.LocationValue === selectedLocation && (item.Value === "-1" || item.Value === selectedPreference || selectedPreferences.indexOf(item.Value) < 0)));
                    }
                    this.FillDropDown(filteredPreferences, $preferenceDropDown, selectedPreference);
                });
            }
            FillDropDown(data, $dropdownCtrl, selected) {
                if (portal.Feature.PortalXFormControls) {
                    portal.pxcontrols.pxFillDropDown(data, $dropdownCtrl[0], selected);
                }
                else {
                    starrez.library.controls.dropdown.FillDropDown(data, $dropdownCtrl, "Value", "Text", selected, true);
                }
            }
            AttachDropDownEvents() {
                this.preferencesTable.$table.on('change', '.ui-location-dropdown', (e) => {
                    var $preferenceDropDown = $(e.currentTarget).closest(this.GetRowSelector()).find('.ui-preference-dropdown').GetControl('PreferenceDropdown');
                    starrez.library.controls.dropdown.Clear($preferenceDropDown);
                    this.RefilterLocationDropDowns();
                    this.RefilterPreferenceDropDowns();
                    this.UpdateAddAndSave();
                    var $locationDropDown = $(e.currentTarget).GetControl('LocationDropdown');
                    var locationValue = $locationDropDown.SRVal();
                    var locationText = $locationDropDown.SRCaption();
                    if (locationValue == "-1") {
                        this.ClearMessage();
                        return;
                    }
                    var selectedLocations = this.GetLocationValues();
                    var selectionCount = selectedLocations.filter(item => item === locationValue).length;
                    if (selectionCount < this.roomPreferencesModel.MaxPreferencesPerLocation) {
                        var message = this.roomPreferencesModel.RemainingPreferencesForLocationMessage;
                        message = message.replace("{location}", locationText).replace("{number}", starrez.library.convert.ToString(this.roomPreferencesModel.MaxPreferencesPerLocation - selectionCount));
                        this.ShowMessage(message);
                    }
                    else {
                        var message = this.roomPreferencesModel.MaximumNumberOfPreferencesReachedForLocationErrorMessage;
                        message = message.replace("{location}", locationText);
                        this.ShowMessage(message);
                    }
                });
                this.preferencesTable.$table.on('change', '.ui-preference-dropdown', (e) => {
                    var $preferenceDropDown = $(e.currentTarget).GetControl('PreferenceDropdown');
                    var $locationDropDown = $(e.currentTarget).closest(this.GetRowSelector()).find('.ui-location-dropdown').GetControl('LocationDropdown');
                    var preferenceValue = $preferenceDropDown.SRVal();
                    var locationValue = $locationDropDown.SRVal();
                    this.RefilterPreferenceDropDowns();
                    this.UpdateAddAndSave();
                    var studentFacingErrors = [];
                    if (locationValue === "-1") {
                        studentFacingErrors.push(this.roomPreferencesModel.LocationNotSelectedErrorMessage);
                    }
                    if (preferenceValue === "-1") {
                        studentFacingErrors.push(this.roomPreferencesModel.PreferenceNotSelectedErrorMessage);
                    }
                    if (studentFacingErrors.length > 0) {
                        portal.page.CurrentPage.SetErrorMessages(studentFacingErrors);
                        return false;
                    }
                    this.ClearMessage();
                });
            }
            UpdateAddAndSave() {
                if (this.MaximumPreferencesReached()) {
                    this.$addButton.prop("title", this.roomPreferencesModel.AddButtonHoverMessage);
                    this.$addButton.Disable();
                }
                else {
                    this.$addButton.prop("title", "");
                    this.$addButton.Enable();
                }
                this.isValid = !this.UnfinishedSelectionExists() && this.MinimumPreferencesReached();
                if (this.isValid) {
                    this.$saveButton.prop("title", "");
                    this.$saveButton.Enable();
                }
                else {
                    this.$saveButton.prop("title", this.roomPreferencesModel.SaveButtonHoverMessage);
                    this.$saveButton.Disable();
                }
            }
            UpdateRowOrder() {
                var $rowOrders = this.preferencesTable.$table.find('.ui-order-column');
                var preferenceNumber = 1;
                $rowOrders.each((index, element) => {
                    $(element).text(preferenceNumber);
                    preferenceNumber++;
                });
            }
            UnfinishedSelectionExists() {
                var unfinishedSelectionExists = false;
                this.GetRows().each((index, element) => {
                    if (!this.roomPreferencesModel.SelectPreferencesWithoutLocations) {
                        var $locationDropDown = $(element).find('.ui-location-dropdown').GetControl('LocationDropdown');
                        var locationValue = $locationDropDown.SRVal();
                        unfinishedSelectionExists = locationValue === "-1";
                        if (unfinishedSelectionExists)
                            return false;
                    }
                    var $preferenceDropDown = $(element).find('.ui-preference-dropdown').GetControl('PreferenceDropdown');
                    var preferenceValue = $preferenceDropDown.SRVal();
                    unfinishedSelectionExists = preferenceValue === "-1";
                    if (unfinishedSelectionExists)
                        return false;
                });
                return unfinishedSelectionExists;
            }
        }
    })(roompreferences = portal.roompreferences || (portal.roompreferences = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roompreferences.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function LocationModelModel($sys) {
            return {
                Text: $sys.data('text'),
                Value: $sys.data('value'),
            };
        }
        model.LocationModelModel = LocationModelModel;
        function PreferenceModelModel($sys) {
            return {
                LocationValue: $sys.data('locationvalue'),
                Text: $sys.data('text'),
                Value: $sys.data('value'),
            };
        }
        model.PreferenceModelModel = PreferenceModelModel;
        function RoomPreferencesBaseModel($sys) {
            return {
                AddButtonHoverMessage: $sys.data('addbuttonhovermessage'),
                AvailableLocations: $sys.data('availablelocations'),
                AvailablePreferences: $sys.data('availablepreferences'),
                LocationDropdownLabel: $sys.data('locationdropdownlabel'),
                LocationNotSelectedErrorMessage: $sys.data('locationnotselectederrormessage'),
                MaximumNumberOfPreferences: Number($sys.data('maximumnumberofpreferences')),
                MaximumNumberOfPreferencesReachedErrorMessage: $sys.data('maximumnumberofpreferencesreachederrormessage'),
                MaximumNumberOfPreferencesReachedForLocationErrorMessage: $sys.data('maximumnumberofpreferencesreachedforlocationerrormessage'),
                MaxPreferencesPerLocation: Number($sys.data('maxpreferencesperlocation')),
                MinimumNumberOfPreferences: Number($sys.data('minimumnumberofpreferences')),
                MinimumPreferencesErrorMessage: $sys.data('minimumpreferenceserrormessage'),
                PreferenceDropdownLabel: $sys.data('preferencedropdownlabel'),
                PreferenceNotSelectedErrorMessage: $sys.data('preferencenotselectederrormessage'),
                PreferenceRowDeleteButtonAriaLabelText: $sys.data('preferencerowdeletebuttonarialabeltext'),
                RemainingPreferencesForLocationMessage: $sys.data('remainingpreferencesforlocationmessage'),
                RemainingPreferencesMessage: $sys.data('remainingpreferencesmessage'),
                SaveButtonHoverMessage: $sys.data('savebuttonhovermessage'),
                SelectPreferencesWithoutLocations: starrez.library.convert.ToBoolean($sys.data('selectpreferenceswithoutlocations')),
                UnfinishedSelectionErrorMessage: $sys.data('unfinishedselectionerrormessage'),
            };
        }
        model.RoomPreferencesBaseModel = RoomPreferencesBaseModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var assignbed;
        (function (assignbed) {
            "use strict";
            function Initialise($container) {
                new AssignBedStep($container);
            }
            assignbed.Initialise = Initialise;
            class AssignBedStep {
                constructor($container) {
                    this.$container = $container;
                    this.roomPictures = {};
                    this.assignments = {};
                    this.newInvitations = {};
                    this.roomspaceSelectionClass = ".ui-roomspace-selection";
                    this.model = starrez.model.AssignBedStepModel($container);
                    this.baseModel = starrez.model.RoomSearchStepBaseModel($container);
                    this.$continueButton = portal.PageElements.$actions.find(".ui-btn-continue");
                    this.Initialise();
                }
                Initialise() {
                    if (this.model.AutoComplete) {
                        portal.page.CurrentPage.SubmitPage();
                    }
                    this.$myRoomContainer = this.$container.find(".ui-my-room-container");
                    this.$roommatesContainer = this.$container.find(".ui-roommates-container");
                    this.$newInvitationsContainer = this.$container.find(".ui-new-invitations-container");
                    // Find roomspace dropdowns and repopulate them when we're coming back from the confirmation page
                    this.$roomspaceSelectors = this.$container.find(this.roomspaceSelectionClass);
                    this.$roomspaceSelection = this.$roomspaceSelectors.GetControl("RoomSpaceID");
                    this.$invitationNameText = this.$container.GetControl("Invitation_Name");
                    this.$invitationEmailText = this.$container.GetControl("Invitation_Email");
                    this.$invitationNameText.each((index, elem) => { this.UpdateNewInvitationText($(elem)); });
                    this.$invitationEmailText.each((index, elem) => { this.UpdateNewInvitationText($(elem)); });
                    this.$myPictureContainer = this.$container.find(".ui-my-bed-picture");
                    this.$myPicturePlaceholder = this.$myPictureContainer.find(".ui-my-bed-picture-placeholder");
                    this.$myActualPicture = this.$myPictureContainer.find(".ui-my-bed-actual-picture");
                    for (var i = 0; i < this.model.RoomImageUrls.length; i++) {
                        var unparsedUrl = this.model.RoomImageUrls[i];
                        var urlWithKey = unparsedUrl.split("|", 2);
                        this.roomPictures[urlWithKey[0]] = urlWithKey[1];
                    }
                    for (var i = 0; i < this.$roomspaceSelectors.length; i++) {
                        var $bedAssigneeControl = $(this.$roomspaceSelectors[i]);
                        var entryID = $bedAssigneeControl.data("entryid");
                        var entryInvitationID = $bedAssigneeControl.data("entryinvitationid");
                        // replicate uniqueID from RoommateInfo.GetRoommateInfoUniqueID()
                        var uniqueID = entryID;
                        if (!starrez.library.stringhelper.IsUndefinedOrEmpty(entryInvitationID)) {
                            uniqueID += "_" + entryInvitationID;
                        }
                        var $bedDropdown = $bedAssigneeControl.GetControl("RoomSpaceID");
                        var assignedBeds = this.model.AssignedBeds;
                        for (var x = 0; x < assignedBeds.length; x++) {
                            var ids = assignedBeds[x].split("|");
                            var assignedEntryID = ids[0];
                            var assignedRoomSpaceID = Number(ids[1]);
                            if (starrez.library.stringhelper.Equals(uniqueID, assignedEntryID, false)) {
                                $bedDropdown.SRVal(assignedRoomSpaceID);
                                this.AssignBed($bedDropdown, $bedAssigneeControl);
                            }
                        }
                    }
                    portal.actionpanel.control.AutoAdjustActionPanelHeights(this.$roommatesContainer);
                    portal.actionpanel.control.AutoAdjustActionPanelHeights(this.$newInvitationsContainer);
                    this.AttachEvents();
                    portal.roomsearch.AttachResetButton();
                }
                HandleNewInvitationTextChange(e) {
                    var $currentText = $(e.currentTarget);
                    this.UpdateNewInvitationText($currentText);
                }
                UpdateNewInvitationText($currentText) {
                    var value = $currentText.SRVal();
                    var $selectedRoomSpace = $currentText.closest(this.roomspaceSelectionClass);
                    var $invalidNotificationContainer = $selectedRoomSpace.find(".ui-invalid-invitation-notification");
                    var currentAssigneeID = $selectedRoomSpace.data("bedassignmentid");
                    var $nameNotification = $invalidNotificationContainer.find(".ui-invalid-invitation-name");
                    var $emailNotification = $invalidNotificationContainer.find(".ui-invalid-invitation-email");
                    if (starrez.library.utils.IsNullOrUndefined(this.newInvitations[currentAssigneeID])) {
                        this.newInvitations[currentAssigneeID] = { InvitationName: null, InvitationEmail: null };
                    }
                    if (starrez.library.stringhelper.Equals("Invitation_Name", $currentText.SRName(), true)) {
                        this.newInvitations[currentAssigneeID].InvitationName = value;
                    }
                    if (starrez.library.stringhelper.Equals("Invitation_Email", $currentText.SRName(), true)) {
                        this.newInvitations[currentAssigneeID].InvitationEmail = value;
                    }
                    var isValid = true;
                    var oneFieldIsValid = false;
                    if (starrez.library.stringhelper.IsUndefinedOrEmpty(this.newInvitations[currentAssigneeID].InvitationName)) {
                        isValid = false;
                        $nameNotification.show();
                    }
                    else {
                        $nameNotification.hide();
                        oneFieldIsValid = true;
                    }
                    if (!this.IsEmailValid(this.newInvitations[currentAssigneeID].InvitationEmail)) {
                        isValid = false;
                        $emailNotification.show();
                    }
                    else {
                        $emailNotification.hide();
                        oneFieldIsValid = true;
                    }
                    var $dropdown = $selectedRoomSpace.GetControl("RoomSpaceID");
                    if (isValid) {
                        $invalidNotificationContainer.hide();
                    }
                    else {
                        $invalidNotificationContainer.show();
                    }
                    //Enable the dropdown as soon as one of the fields are populated
                    if (oneFieldIsValid) {
                        $dropdown.Enable();
                    }
                    else {
                        $dropdown.Disable();
                        $dropdown.SRVal(null);
                    }
                    //Remove the height style, then recalculate new height
                    $currentText.closest(".ui-action-panel-card .ui-contents").outerHeight("initial");
                    portal.actionpanel.control.AutoAdjustActionPanelHeights(this.$newInvitationsContainer);
                }
                IsEmailValid(email) {
                    //Regex copied from EmailAddress.cs
                    var emailPattern = /^[\w!#$%&'*\-/=?\^_`{|}~]+(([\w!#$%&'*\+\-/=?^_`{|}~]*)|(\.[^.]))*@((\[(\d{1,3}\.){3}\d{1,3}\])|(([\w\-]+\.)+[a-zA-Z]{2,}))$/;
                    return (!starrez.library.stringhelper.IsUndefinedOrEmpty(email) && emailPattern.test(email));
                }
                AssignBed($bedDropdown, $bedAssigneeControl) {
                    var currentAssigneeID = $bedAssigneeControl.data("bedassignmentid");
                    var takenByMessage = $bedAssigneeControl.data("takenbymessage");
                    var isCurrentUser = starrez.library.convert.ToBoolean($bedAssigneeControl.data("iscurrentuser"));
                    var selectedRoomSpaceID = $bedDropdown.SRVal();
                    var previouslySelectingSomething = starrez.library.utils.IsNotNullUndefined(this.assignments[currentAssigneeID]);
                    var currentlySelectingSomething = starrez.library.utils.IsNotNullUndefined(selectedRoomSpaceID);
                    if (previouslySelectingSomething || currentlySelectingSomething) {
                        var $otherDropdowns = this.$roomspaceSelection.not($("#" + $bedDropdown.id()));
                        if (previouslySelectingSomething) {
                            //Mark the one they've selected before (if it's not please select) as enabled and remove the extra label
                            var $optionToEnable = $otherDropdowns.find("option[value=" + this.assignments[currentAssigneeID] + "]");
                            $optionToEnable.Enable();
                            $optionToEnable.find(".ui-roomspace-taken").remove();
                        }
                        if (currentlySelectingSomething) {
                            //Mark the one they just selected as disabled, and put label saying "Taken By Bob" or something like that
                            var $optionToDisable = $otherDropdowns.find("option[value=" + selectedRoomSpaceID + "]");
                            $optionToDisable.Disable();
                            if (starrez.library.utils.IsNotNullUndefined(this.newInvitations[currentAssigneeID])) {
                                //For new invitations, we have to do basic text replacing here, because name & email won't be available until user type in this page
                                takenByMessage = this.model.TakenByNewInvitationMessage;
                                takenByMessage = takenByMessage.replace(/{Name}/g, this.newInvitations[currentAssigneeID].InvitationName);
                                takenByMessage = takenByMessage.replace(/{Email}/g, this.newInvitations[currentAssigneeID].InvitationEmail);
                            }
                            $optionToDisable.append("<span class=\"ui-roomspace-taken\">" + takenByMessage + "</span>");
                        }
                    }
                    this.assignments[currentAssigneeID] = selectedRoomSpaceID;
                    //Change the room image based on what room the current user is selecting
                    if (isCurrentUser) {
                        if (currentlySelectingSomething && !starrez.library.stringhelper.IsUndefinedOrEmpty(this.roomPictures[selectedRoomSpaceID])) {
                            this.$myPicturePlaceholder.hide();
                            this.$myActualPicture.css("background-image", "url('" + this.roomPictures[selectedRoomSpaceID] + "')");
                            this.$myActualPicture.show();
                        }
                        else {
                            this.$myPicturePlaceholder.show();
                            this.$myActualPicture.hide();
                        }
                    }
                }
                AttachEvents() {
                    this.$roomspaceSelection.on("change", (e) => {
                        var $bedDropdown = $(e.currentTarget);
                        var $bedAssigneeControl = $bedDropdown.closest(this.roomspaceSelectionClass);
                        this.AssignBed($bedDropdown, $bedAssigneeControl);
                    });
                    this.$invitationNameText.on("change", (e) => {
                        this.HandleNewInvitationTextChange(e);
                    });
                    this.$invitationEmailText.on("change", (e) => {
                        this.HandleNewInvitationTextChange(e);
                    });
                    this.$continueButton.SRClick(() => {
                        var call = new starrez.service.roomsearch.AssignBeds({
                            pageID: this.model.RoomSelectionPageID,
                            roomBaseIDs: this.model.RoomBaseIDs,
                            assignments: this.assignments,
                            newInvitations: this.newInvitations,
                            checkInDate: this.baseModel.DateStart,
                            checkOutDate: this.baseModel.DateEnd,
                            hash: this.$continueButton.data("hash")
                        });
                        call.Post().done((result) => {
                            portal.page.CurrentPage.SubmitPage();
                        });
                    });
                }
            }
        })(assignbed = roomsearch.assignbed || (roomsearch.assignbed = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.assignbed.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var confirmation;
        (function (confirmation) {
            "use strict";
            function Initialise($container) {
                portal.roomsearch.AttachResetButton();
                portal.PageElements.$actions.find(".ui-btn-continue").SRClick(() => {
                    portal.page.CurrentPage.SubmitPage();
                });
            }
            confirmation.Initialise = Initialise;
        })(confirmation = roomsearch.confirmation || (roomsearch.confirmation = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.confirmation.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var initial;
        (function (initial) {
            "use strict";
            let InitialFilterOption;
            (function (InitialFilterOption) {
                InitialFilterOption[InitialFilterOption["RoomType"] = 0] = "RoomType";
                InitialFilterOption[InitialFilterOption["RoomLocationArea"] = 1] = "RoomLocationArea";
                InitialFilterOption[InitialFilterOption["RoomLocation"] = 2] = "RoomLocation";
                InitialFilterOption[InitialFilterOption["DatesAndRates"] = 3] = "DatesAndRates";
            })(InitialFilterOption = initial.InitialFilterOption || (initial.InitialFilterOption = {}));
            function Initialise($container) {
                new InitialFilterStep($container);
            }
            initial.Initialise = Initialise;
            class InitialFilterStep {
                constructor($container) {
                    this.$container = $container;
                    this.model = starrez.model.InitialFilterStepModel($container);
                    this.baseModel = starrez.model.RoomSearchStepBaseModel($container);
                    this.$dateStart = this.$container.GetControl("DateStart");
                    this.$dateEnd = this.$container.GetControl("DateEnd");
                    this.$resultsContainer = this.$container.find(".ui-initial-filter-step-results-container");
                    this.Initialise();
                }
                ReloadResults() {
                    new starrez.service.roomsearch.GetInitialFilterStepResults({
                        pageID: this.model.RoomSelectionPageID,
                        dateStart: this.baseModel.DateStart,
                        dateEnd: this.baseModel.DateEnd,
                        classificationID: this.model.ClassificationID,
                        termID: this.model.TermID,
                        groupID: this.model.GroupID
                    }).Post().done(html => {
                        this.$resultsContainer.html(html);
                        this.AttachEvents();
                    });
                }
                Initialise() {
                    this.$dateStart.change(() => {
                        this.baseModel.DateStart = this.$dateStart.SRVal();
                        this.ReloadResults();
                    });
                    this.$dateEnd.change(() => {
                        this.baseModel.DateEnd = this.$dateEnd.SRVal();
                        this.ReloadResults();
                    });
                    this.AttachEvents();
                }
                AttachEvents() {
                    if (this.model.InitialFilterOption === InitialFilterOption[InitialFilterOption.DatesAndRates]) {
                        var $slider = this.$container.find(".ui-rates");
                        var updateDetails = () => {
                            this.lowerRoomRateValue = $slider.slider("values", 0);
                            this.upperRoomRateValue = $slider.slider("values", 1);
                            var rateText = this.model.CurrencySymbol + this.lowerRoomRateValue + " - " + this.model.CurrencySymbol + this.upperRoomRateValue;
                            this.$container.find(".ui-rates-value").text(rateText);
                        };
                        $slider.slider({
                            range: true,
                            min: this.model.MinimumRoomRateFilterValue,
                            max: this.model.MaximumRoomRateFilterValue,
                            values: [this.model.MinimumRoomRateFilterValue, this.model.MaximumRoomRateFilterValue],
                            stop: (event, ui) => {
                                updateDetails();
                            }
                        });
                        this.$container.find(".ui-select-action").SRClick(() => {
                            this.UpdateModuleContextAndContinue();
                        });
                        updateDetails();
                    }
                    this.$container.find(".ui-action-panel .ui-select-action").SRClick((e) => {
                        var $actionPanel = $(e.currentTarget).closest(".ui-action-panel");
                        this.objectID = Number($actionPanel.data("id"));
                        this.UpdateModuleContextAndContinue();
                    });
                    this.$container.find(".ui-async-flipper-container").each((index, element) => {
                        var manager = new portal.asyncflipper.control.AsyncFlipperManager($(element));
                        manager.OnClick().done(($asyncContainer) => {
                            new starrez.service.roomsearch.GetTermCardContent({
                                tableID: Number($asyncContainer.attr("id")),
                                pageID: portal.page.CurrentPage.PageID
                            }).Request({
                                ActionVerb: starrez.library.service.RequestType.Post,
                                ShowLoading: false
                            }).done(html => {
                                manager.AddFlipSideContent(html);
                            });
                        });
                    });
                    portal.actionpanel.control.AutoAdjustActionPanelHeights(this.$container);
                }
                UpdateModuleContextAndContinue() {
                    var filters = {
                        DateStart: this.baseModel.DateStart,
                        DateEnd: this.baseModel.DateEnd,
                        LowerRoomRateValue: this.lowerRoomRateValue,
                        UpperRoomRateValue: this.upperRoomRateValue,
                        RoomTypeID: null,
                        ProfileItemID: null,
                        RoomBaseIDs: null,
                        RoomLocationAreaID: null,
                        RoomLocationFloorSuiteID: null,
                        RoomLocationID: null,
                        UseRoommateClassifications: null
                    };
                    filters[this.model.RoomSelectionPropertyName] = [this.objectID];
                    portal.roomsearch.UpdateModuleContextWithFiltersAndCurrentPageNumber(filters, 1).done(() => {
                        portal.page.CurrentPage.SubmitPage();
                    });
                }
            }
        })(initial = roomsearch.initial || (roomsearch.initial = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.initial.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        "use strict";
        function UpdateModuleContextWithFiltersAndCurrentPageNumber(filter, currentPageNumber) {
            return new starrez.service.roomsearch.UpdateProcessContext({
                processID: portal.page.CurrentPage.ProcessID,
                filters: filter,
                currentPageNumber: currentPageNumber
            }).Post();
        }
        roomsearch.UpdateModuleContextWithFiltersAndCurrentPageNumber = UpdateModuleContextWithFiltersAndCurrentPageNumber;
        function AttachResetButton() {
            var $reset = portal.PageElements.$actions.find(".ui-restart-roomsearch");
            var roomSelectionPageID = Number($reset.data("roomselectionpageid"));
            var termID = Number($reset.data("termid"));
            var classificationID = Number($reset.data("classificationid"));
            var groupID = Number($reset.data("groupid"));
            $reset.SRClick(() => {
                // confirm they actually want to do this
                portal.ConfirmAction($reset.data("message"), $reset.data("title")).done(() => {
                    // wipe their cart
                    new starrez.service.roomsearch.Restart({
                        pageID: roomSelectionPageID,
                        processID: portal.page.CurrentPage.ProcessID,
                        termID: termID,
                        classificationID: classificationID,
                        groupID: groupID
                    }).Post().done(url => {
                        // go to the start of room search
                        if (!starrez.library.stringhelper.IsUndefinedOrEmpty(url)) {
                            location.href = url;
                        }
                    });
                });
            });
        }
        roomsearch.AttachResetButton = AttachResetButton;
        function InitRoomSearchRenewal($container) {
            new RoomSearchRenewal($container);
        }
        roomsearch.InitRoomSearchRenewal = InitRoomSearchRenewal;
        class RoomSearchRenewal {
            constructor($container) {
                this.AttachEvents($container);
            }
            AttachEvents(container) {
                container.find('.ui-renew-roombutton').each((index, element) => {
                    var $renewButton = $(element);
                    $renewButton.SRClick(() => {
                        new starrez.service.roomsearch.RenewRoom({
                            pageID: portal.page.CurrentPage.PageID,
                            hash: $renewButton.data("hash")
                        }).Post().done(url => {
                            location.href = url;
                        });
                    });
                });
            }
        }
        ;
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var main;
        (function (main) {
            "use strict";
            function Initialise($container) {
                main.Model = new MainFilterStep($container);
            }
            main.Initialise = Initialise;
            let AddingRoomOption;
            (function (AddingRoomOption) {
                AddingRoomOption[AddingRoomOption["Multiple"] = 0] = "Multiple";
                AddingRoomOption[AddingRoomOption["Single"] = 1] = "Single";
                AddingRoomOption[AddingRoomOption["None"] = 2] = "None";
            })(AddingRoomOption = main.AddingRoomOption || (main.AddingRoomOption = {}));
            ;
            let FilterType;
            (function (FilterType) {
                FilterType[FilterType["RoomTypeID"] = 0] = "RoomTypeID";
                FilterType[FilterType["RoomLocationAreaID"] = 1] = "RoomLocationAreaID";
                FilterType[FilterType["RoomLocationID"] = 2] = "RoomLocationID";
                FilterType[FilterType["RoomLocationFloorSuiteID"] = 3] = "RoomLocationFloorSuiteID";
                FilterType[FilterType["ProfileItemID"] = 4] = "ProfileItemID";
                FilterType[FilterType["None"] = 5] = "None";
            })(FilterType = main.FilterType || (main.FilterType = {}));
            //This class is being used when we don't want to show filters with no results in Room List
            class FilterModel {
                constructor(FilterName, $FilterControl, filterTsLink, filterType) {
                    this.FilterName = FilterName;
                    this.$FilterControl = $FilterControl;
                    this.filterTsLink = filterTsLink;
                    this.filterType = filterType;
                }
                GetFilterTsLink() {
                    return this.filterTsLink;
                }
                GetFilterType() {
                    return this.filterType;
                }
                GetVisibleFilterItems(filterData, filterType, filterModels) {
                    if (starrez.library.utils.IsNullOrUndefined(filterData)) {
                        return [];
                    }
                    var filterItems = filterData.FilterItems;
                    if (this.IsArrayEmpty(filterItems)) {
                        return [];
                    }
                    var visibleFilterIDs = [];
                    for (var i = 0; i < filterData.FilterItems.length; i++) {
                        var filterItem = filterData.FilterItems[i];
                        var skip = false;
                        for (var filterModelIndex = 0; filterModelIndex < filterModels.length; filterModelIndex++) {
                            var filterModel = filterModels[filterModelIndex];
                            if (filterType != filterModel.filterType && !this.IsArrayEmpty(filterModel.SelectedFilterIDs)) {
                                if (filterModel.SelectedFilterIDs.indexOf(filterItem.IDs[filterModel.filterType]) === -1) {
                                    skip = true;
                                    break;
                                }
                            }
                        }
                        if (!skip) {
                            visibleFilterIDs.push(filterItem.IDs[filterType]);
                        }
                    }
                    return this.GetUniqueArray(visibleFilterIDs);
                }
                IsArrayEmpty(array) {
                    return starrez.library.utils.IsNullOrUndefined(array) || array.length === 0;
                }
                GetUniqueArray(array) {
                    return array.filter(function (value, index, self) {
                        return self.indexOf(value) === index;
                    });
                }
            }
            class MainFilterStep {
                constructor($container) {
                    this.$container = $container;
                    this.isSliderInitialised = false;
                    this.isSearching = false;
                    this.isDirty = false;
                    this.suggestionGroupsNumber = 0;
                    this.suggestionGroupsLoaded = 0;
                    this.hasSuggestions = false;
                    this.roomSearchGuid = null;
                    this.filterModels = [];
                    this.model = starrez.model.MainFilterStepModel($container);
                    this.filterData = this.model.FilterData;
                    this.baseModel = starrez.model.RoomSearchStepBaseModel($container);
                    this.$filtersContainer = this.$container.find(".ui-filters");
                    this.$resultsContainer = this.$container.find(".ui-results");
                    this.$continueButtonContainer = this.$container.find(".ui-btn-continue-container");
                    this.$continueButton = this.$continueButtonContainer.find(".ui-btn-continue");
                    this.$filterIcon = this.$filtersContainer.find(".ui-filter-icon");
                    this.$filterBody = this.$filtersContainer.find(".ui-filter-body");
                    this.$dateStart = this.$container.GetControl("DateStart");
                    this.$dateEnd = this.$container.GetControl("DateEnd");
                    this.InitialiseUpdatableFilters();
                    this.Initialise();
                    portal.roomsearch.AttachResetButton();
                }
                InitialiseUpdatableFilters() {
                    this.$histoGram = this.$filtersContainer.find(".ui-roomrate-graph");
                    this.$useRoommateClassifications = this.$container.GetControl("UseRoommateClassifications");
                    //Populate filter models. The index is based on FilterType
                    this.filterModels[FilterType.RoomTypeID] = new FilterModel("RoomTypeID", this.$filtersContainer.GetControl("RoomTypeID"), ".ui-room-selection-type-filter", FilterType.RoomTypeID);
                    this.filterModels[FilterType.RoomLocationAreaID] = new FilterModel("RoomLocationAreaID", this.$filtersContainer.GetControl("RoomLocationAreaID"), ".ui-room-selection-area-filter", FilterType.RoomLocationAreaID);
                    this.filterModels[FilterType.RoomLocationID] = new FilterModel("RoomLocationID", this.$filtersContainer.GetControl("RoomLocationID"), ".ui-room-selection-location-filter", FilterType.RoomLocationID);
                    this.filterModels[FilterType.RoomLocationFloorSuiteID] = new FilterModel("RoomLocationFloorSuiteID", this.$filtersContainer.GetControl("RoomLocationFloorSuiteID"), ".ui-room-selection-floorsuite-filter", FilterType.RoomLocationFloorSuiteID);
                    this.filterModels[FilterType.ProfileItemID] = new FilterModel("ProfileItemID", this.$filtersContainer.GetControl("ProfileItemID"), ".ui-room-selection-profile-filter", FilterType.ProfileItemID);
                    this.$roomRateSlider = this.$filtersContainer.find(".ui-roomrate-slider");
                    this.InitSlider(this.model.MinimumRoomRateFilterValue, this.model.MaximumRoomRateFilterValue);
                    this.AttachFilterEvents();
                    this.$useRoommateClassifications.change(() => {
                        this.model.UseRoommateClassifications = this.$useRoommateClassifications.SRVal();
                        this.UpdateFilters().done(() => {
                            this.HideFilters(FilterType.None);
                            this.LoadResults(1);
                        });
                    });
                    this.HideFilters(FilterType.None);
                }
                Initialise() {
                    this.AttachEvents();
                    if (this.model.CurrentPageNumber == 0) {
                        this.model.CurrentPageNumber = 1;
                    }
                    this.LoadResults(this.model.CurrentPageNumber);
                }
                GetFilterVal(filterType) {
                    const $filterControl = this.filterModels[filterType].$FilterControl;
                    if (portal.Feature.PXAccessibleFilterGroupSystem) {
                        const filtersAreHiddenAsTextInput = $filterControl.isFound() && $filterControl.get()[0].HasClass("ui-text");
                        if (filtersAreHiddenAsTextInput) {
                            return starrez.library.convert.ToNumberArray($filterControl.SRVal());
                        }
                        const name = $filterControl.SRName();
                        return portal.pxcontrols.helpers.controls.multiSelect.value(name);
                    }
                    else {
                        // this is the older one...
                        if ($filterControl.isFound()) {
                            const value = $filterControl.SRVal();
                            if (starrez.library.utils.IsNotNullUndefined(value)) {
                                return starrez.library.convert.ToNumberArray(value);
                            }
                        }
                        return [];
                    }
                }
                // Slider number 0 is the lower value, 1 is the upper value
                GetRoomRateValue(slider) {
                    if (this.$roomRateSlider.isFound()) {
                        return this.$roomRateSlider.slider("values", slider);
                    }
                    return null;
                }
                AttachEvents() {
                    this.$dateStart.change(() => {
                        this.baseModel.DateStart = this.$dateStart.SRVal();
                        this.UpdateFilters().done(() => {
                            this.HideFilters(FilterType.None);
                            this.LoadResults(1);
                        });
                    });
                    this.$dateEnd.change(() => {
                        this.baseModel.DateEnd = this.$dateEnd.SRVal();
                        this.UpdateFilters().done(() => {
                            this.HideFilters(FilterType.None);
                            this.LoadResults(1);
                        });
                    });
                    this.$resultsContainer.on("click", ".ui-add-room-to-cart", (e) => {
                        var $addRoomToCart = $(e.currentTarget);
                        var $result = $addRoomToCart.closest(".ui-card-result");
                        var isRoomBase = false;
                        var roomBaseID;
                        var roomTypeID;
                        var roomLocationID;
                        if (starrez.library.utils.IsNotNullUndefined($result.data("roombaseid"))) {
                            roomBaseID = Number($result.data("roombaseid"));
                            isRoomBase = true;
                        }
                        else {
                            roomTypeID = Number($result.data("roomtypeid"));
                            roomLocationID = Number($result.data("roomlocationid"));
                        }
                        this.model.RoomRateID = Number($result.data("roomrateid"));
                        var multiSelect = AddingRoomOption[this.model.ActualAddingRoomToCartOption] === AddingRoomOption.Multiple;
                        if (isRoomBase) {
                            if (!multiSelect) {
                                new starrez.service.roomsearch
                                    .ValidateNumberOfRoomSpacesForSingleRoom({ pageID: this.model.RoomSelectionPageID, roomBaseID: roomBaseID })
                                    .Post()
                                    .done(() => { this.AddRoomToCart(roomBaseID, $addRoomToCart); });
                            }
                            else {
                                this.AddRoomToCart(roomBaseID, $addRoomToCart);
                            }
                        }
                        else {
                            this.AddRoomTypeLocationToCart(roomTypeID, roomLocationID, $addRoomToCart);
                        }
                    });
                    this.$resultsContainer.on("click", ".ui-remove-room-from-cart", (e) => {
                        var $removeFromCart = $(e.currentTarget);
                        var $result = $removeFromCart.closest(".ui-card-result");
                        this.removeFromCartHash = $removeFromCart.data("hash");
                        var roomBaseID = Number($result.data("roombaseid"));
                        var index = this.model.RoomBaseIDs.indexOf(roomBaseID);
                        if (index !== -1) {
                            var call = new starrez.service.roomsearch.RemoveRoomFromCart({
                                hash: this.removeFromCartHash,
                                processID: portal.page.CurrentPage.ProcessID,
                                roomBaseID: roomBaseID,
                                pageID: this.model.RoomSelectionPageID
                            });
                            call.Post().done((result) => {
                                for (var i = 0; i < result.UpdatedRoomBaseIDs.length; i++) {
                                    var roomIndex = this.model.RoomBaseIDs.indexOf(result.UpdatedRoomBaseIDs[i]);
                                    if (roomIndex >= 0) {
                                        this.model.RoomBaseIDs.splice(roomIndex, 1);
                                    }
                                }
                                this.SetResultsAddRemoveButton(result.UpdatedRoomBaseIDs, false);
                                portal.navigation.NavigationBar.UpdateShoppingCart().done(($shoppingCart) => {
                                    this.InitNavBarShoppingCart($shoppingCart);
                                });
                                this.SetSuggestedRoomAddRemoveButton(result.UpdatedRoomBaseIDs, false);
                            });
                        }
                    });
                    portal.mobile.SetupExpandAndCollapse(this.$filtersContainer);
                    this.$continueButton.SRClick(() => {
                        if (!this.model.CanAddRoomsToCart) {
                            portal.page.CurrentPage.SubmitPage();
                        }
                        else if (this.model.RoomBaseIDs.length > 0) {
                            new starrez.service.roomsearch.ValidateNumberOfRoomSpacesSelected({ pageID: this.model.RoomSelectionPageID })
                                .Post()
                                .done(() => {
                                this.UpdateModuleContextAndContinue();
                            });
                        }
                        else {
                            portal.page.CurrentPage.SetErrorMessage(this.model.MustSelectRoomMessage);
                            return;
                        }
                    });
                    this.$resultsContainer.on("click", ".ui-show-room-total-amount-link", (e) => {
                        var $calculateTotalLink = $(e.currentTarget);
                        var $result = $calculateTotalLink.closest(".ui-card-result");
                        var call = new starrez.service.roomsearch.CalculateTotalRoomPrice({
                            checkInDate: this.baseModel.DateStart,
                            checkOutDate: this.baseModel.DateEnd,
                            pageID: this.model.RoomSelectionPageID,
                            roomBaseID: Number($result.data("roombaseid")),
                            roomRateID: Number($result.data("roomrateid")),
                            hash: $calculateTotalLink.data("hash")
                        });
                        call.Post().done((result) => {
                            $calculateTotalLink.remove();
                            var $calcTotalLabel = $result.find(".ui-room-total-amount");
                            $calcTotalLabel.attr("aria-hidden", "false");
                            $calcTotalLabel.show();
                            $calcTotalLabel.html(result);
                        });
                    });
                    this.$resultsContainer.on("click", ".ui-show-type-location-total-amount-link", (e) => {
                        var $calculateTotalLink = $(e.currentTarget);
                        var $result = $calculateTotalLink.closest(".ui-card-result");
                        var call = new starrez.service.roomsearch.CalculateTotalRoomTypeLocationPrice({
                            checkInDate: this.baseModel.DateStart,
                            checkOutDate: this.baseModel.DateEnd,
                            pageID: this.model.RoomSelectionPageID,
                            roomRateID: Number($result.data("roomrateid")),
                            roomLocationID: Number($result.data("roomlocationid")),
                            roomTypeID: Number($result.data("roomtypeid")),
                            hash: $calculateTotalLink.data("hash")
                        });
                        call.Post().done((result) => {
                            $calculateTotalLink.remove();
                            var $calcTotalLabel = $result.find(".ui-room-total-amount");
                            $calcTotalLabel.attr("aria-hidden", "false");
                            $calcTotalLabel.show();
                            $calcTotalLabel.html(result);
                        });
                    });
                }
                InitNavBarShoppingCart($shoppingCart) {
                    if (portal.Feature.PortalxLandmarkRegionChanges) {
                        var shoppingcartdropdown = $shoppingCart.find(".ui-shopping-cart-dropdown")[0];
                        portal.shoppingcart.initShoppingCart(shoppingcartdropdown, {
                            cartExpireMessage: $(shoppingcartdropdown).data("cartexpiremessage"),
                            cartTimerHideText: $(shoppingcartdropdown).data("carttimerhidetext"),
                            cartTimerShowText: $(shoppingcartdropdown).data("carttimershowtext"),
                            holdSeconds: $(shoppingcartdropdown).data("holdseconds"),
                            timerAriaLabelPrefix: $(shoppingcartdropdown).data("carttimerprefixlabel"),
                            timerLimitWarning: $(shoppingcartdropdown).data("cartholdexpirywarningtext")
                        });
                    }
                }
                AttachFilterEvents() {
                    if (portal.Feature.PXAccessibleFilterGroupSystem) {
                        this.$filtersContainer.find("input[type='checkbox']").change((e) => {
                            const name = e.currentTarget.name;
                            this.HideFilters(FilterType[name]);
                            this.LoadResults(1);
                        });
                    }
                    else {
                        this.$filtersContainer.GetAllControls().find("select").change((e) => {
                            var $ctrl = $(e.currentTarget).closest(".ui-multiple-select-list");
                            var ctrlFieldName = $ctrl.data("fieldname").toString();
                            this.HideFilters(FilterType[ctrlFieldName]);
                            this.LoadResults(1);
                        });
                    }
                }
                //When dates, useRoommateClassifications, or rate filters changed,
                //the possible values for room types, areas, locations, floorsuites, and profile items will also change.
                //Hence, the filter controls and filter data will need to be updated.
                UpdateFilters() {
                    const def = $.Deferred();
                    const sliderClass = "ui-slider-handle";
                    let currentFocusedSlider;
                    if (document.activeElement.classList.contains(sliderClass)) {
                        currentFocusedSlider = document.activeElement === document.querySelectorAll(`.${sliderClass}`)[1]
                            ? 1 // the right slider
                            : 0; // the left slider
                    }
                    // Save current rate value
                    this.model.LowerRoomRateValue = this.GetRoomRateValue(0);
                    this.model.UpperRoomRateValue = this.GetRoomRateValue(1);
                    if (this.model.ShowFiltersWithoutRooms) {
                        def.resolve(true);
                    }
                    else {
                        new starrez.service.roomsearch.UpdateFilterData({
                            pageID: this.model.RoomSelectionPageID,
                            filters: this.GetRoomSearchFilters(),
                            termID: this.model.TermID,
                            classificationID: this.model.ClassificationID,
                            groupID: this.model.GroupID
                        }).Request({
                            ActionVerb: starrez.library.service.RequestType.Post,
                            ShowLoading: false
                        }).done((result) => {
                            this.$filterBody.html(result.FilterViewHtml);
                            this.filterData = result.FilterData;
                            this.InitialiseUpdatableFilters();
                            def.resolve(true);
                            if (currentFocusedSlider !== undefined) { //only check undefined because 0 is a valid value
                                const newFocusedSlider = document.querySelectorAll(`.${sliderClass}`)[currentFocusedSlider];
                                newFocusedSlider.focus();
                            }
                        });
                    }
                    return def.promise();
                }
                AddRoomToCart(roomBaseID, $addButton) {
                    var $result = $addButton.closest(".ui-card-result");
                    if (this.model.RoomBaseIDs.indexOf(roomBaseID) === -1) {
                        let call;
                        if (starrez.library.utils.IsNotNullUndefined(this.model.GroupID)) {
                            call = new starrez.service.roomsearch.AddRoomToCartForGroup({
                                hash: $addButton.data("hash"),
                                pageID: this.model.RoomSelectionPageID,
                                roomBaseID: roomBaseID,
                                roomRateID: Number($result.data("roomrateid")),
                                groupID: this.model.GroupID,
                                checkInDate: this.baseModel.DateStart,
                                checkOutDate: this.baseModel.DateEnd
                            });
                        }
                        else if (starrez.library.utils.IsNullOrUndefined(this.model.TermID)) {
                            call = new starrez.service.roomsearch.AddRoomToCart({
                                hash: $addButton.data("hash"),
                                pageID: this.model.RoomSelectionPageID,
                                roomBaseID: roomBaseID,
                                roomRateID: Number($result.data("roomrateid")),
                                checkInDate: this.baseModel.DateStart,
                                checkOutDate: this.baseModel.DateEnd
                            });
                        }
                        else {
                            call = new starrez.service.roomsearch.AddRoomToCartForTerm({
                                hash: $addButton.data("hash"),
                                pageID: this.model.RoomSelectionPageID,
                                roomBaseID: roomBaseID,
                                roomRateID: Number($result.data("roomrateid")),
                                termID: this.model.TermID,
                                checkInDate: this.baseModel.DateStart,
                                checkOutDate: this.baseModel.DateEnd
                            });
                        }
                        call.Post().done((result) => {
                            // Save the fact that room was successfully added to cart,
                            // so that when the filters are changed and the same room appears in the search results,
                            // it shows the Remove button instead of the Add button
                            this.model.RoomBaseIDs.push.apply(this.model.RoomBaseIDs, result.UpdatedRoomBaseIDs);
                            if (AddingRoomOption[this.model.ActualAddingRoomToCartOption] === AddingRoomOption.Multiple) {
                                this.SetResultsAddRemoveButton(result.UpdatedRoomBaseIDs, true);
                                portal.navigation.NavigationBar.UpdateShoppingCart().done(($shoppingCart) => {
                                    this.InitNavBarShoppingCart($shoppingCart);
                                });
                                this.SetSuggestedRoomAddRemoveButton(result.UpdatedRoomBaseIDs, true);
                            }
                            else {
                                this.UpdateModuleContextAndContinue();
                            }
                        });
                    }
                }
                AddRoomTypeLocationToCart(roomTypeID, roomLocationID, $addButton) {
                    var $result = $addButton.closest(".ui-card-result");
                    let call;
                    if (starrez.library.utils.IsNotNullUndefined(this.model.GroupID)) {
                        call = new starrez.service.roomsearch.AddRoomTypeLocationToCartForGroup({
                            hash: $addButton.data("hash"),
                            pageID: this.model.RoomSelectionPageID,
                            roomTypeID: roomTypeID,
                            roomLocationID: roomLocationID,
                            roomRateID: Number($result.data("roomrateid")),
                            groupID: this.model.GroupID,
                            checkInDate: this.baseModel.DateStart,
                            checkOutDate: this.baseModel.DateEnd
                        });
                    }
                    else if (starrez.library.utils.IsNullOrUndefined(this.model.TermID)) {
                        call = new starrez.service.roomsearch.AddRoomTypeLocationToCart({
                            hash: $addButton.data("hash"),
                            pageID: this.model.RoomSelectionPageID,
                            roomTypeID: roomTypeID,
                            roomLocationID: roomLocationID,
                            roomRateID: Number($result.data("roomrateid")),
                            checkInDate: this.baseModel.DateStart,
                            checkOutDate: this.baseModel.DateEnd
                        });
                    }
                    else {
                        call = new starrez.service.roomsearch.AddRoomTypeLocationToCartForTerm({
                            hash: $addButton.data("hash"),
                            pageID: this.model.RoomSelectionPageID,
                            roomTypeID: roomTypeID,
                            roomLocationID: roomLocationID,
                            roomRateID: Number($result.data("roomrateid")),
                            termID: this.model.TermID,
                            checkInDate: this.baseModel.DateStart,
                            checkOutDate: this.baseModel.DateEnd
                        });
                    }
                    call.Post().done((result) => {
                        this.UpdateModuleContextAndContinue();
                    });
                }
                // Toggles add/remove buttons for a suggested room that could potentially
                // be shown under multiple suggestion groups.
                SetSuggestedRoomAddRemoveButton(roomBaseIDs, isRoomInCart) {
                    this.SetAddRemoveButton(roomBaseIDs, isRoomInCart, this.$suggestionContainer);
                }
                SetResultsAddRemoveButton(roomBaseIDs, isRoomInCart) {
                    this.SetAddRemoveButton(roomBaseIDs, isRoomInCart, this.$resultsContainer);
                }
                SetAddRemoveButton(roomBaseIDs, isRoomInCart, $container) {
                    if (starrez.library.utils.IsNotNullUndefined($container)) {
                        $container.find(".ui-card-result").each((index, room) => {
                            var $room = $(room);
                            if (roomBaseIDs.indexOf(Number($room.data("roombaseid"))) >= 0) {
                                if (isRoomInCart) {
                                    $room.find(".ui-remove-room-from-cart").show();
                                    $room.find(".ui-add-room-to-cart").hide();
                                }
                                else {
                                    $room.find(".ui-remove-room-from-cart").hide();
                                    $room.find(".ui-add-room-to-cart").show();
                                }
                            }
                        });
                    }
                }
                UpdateModuleContextAndContinue() {
                    portal.roomsearch.UpdateModuleContextWithFiltersAndCurrentPageNumber(this.GetRoomSearchFilters(), this.currentPageNumber).done(() => {
                        portal.page.CurrentPage.SubmitPage();
                    });
                }
                InitSlider(min, max) {
                    min = Math.floor(min);
                    max = Math.ceil(max);
                    var currentLowerValue = this.model.LowerRoomRateValue;
                    var currentUpperValue = this.model.UpperRoomRateValue;
                    if (!starrez.library.utils.IsNotNullUndefined(currentLowerValue)) {
                        currentLowerValue = this.model.MinimumRoomRateFilterValue;
                    }
                    if (!starrez.library.utils.IsNotNullUndefined(currentUpperValue) || currentUpperValue === 0) {
                        currentUpperValue = this.model.MaximumRoomRateFilterValue;
                    }
                    if (min === max) {
                        max = max + 1;
                    }
                    this.$roomRateSlider.slider({
                        range: true,
                        min: min,
                        max: max,
                        values: [currentLowerValue, currentUpperValue],
                        stop: (event, ui) => {
                            this.UpdateSliderDataAndText();
                            this.UpdateFilters().done(() => {
                                this.HideFilters(FilterType.None);
                                this.LoadResults(1);
                            });
                        }
                    });
                    this.UpdateSliderDataAndText();
                    this.isSliderInitialised = true;
                }
                UpdateSliderDataAndText() {
                    var rateText = this.model.CurrencySymbol + this.$roomRateSlider.slider("values", 0) + " - " + this.model.CurrencySymbol + this.$roomRateSlider.slider("values", 1);
                    this.$filtersContainer.find(".ui-roomrate-slider-value").text(rateText);
                    if (portal.Feature.PortalXFormControls) {
                        var minSliderHandle = this.$roomRateSlider.find(".ui-slider-handle").first();
                        var maxSliderHandle = this.$roomRateSlider.find(".ui-slider-handle").last();
                        minSliderHandle.attr({
                            "role": "slider",
                            "aria-label": this.model.MinimumRoomRateFilterAriaLabel,
                            "aria-valuemin": this.model.MinimumRoomRateFilterValue,
                            "aria-valuemax": this.$roomRateSlider.slider("values", 1),
                            "aria-valuenow": this.$roomRateSlider.slider("values", 0)
                        });
                        maxSliderHandle.attr({
                            "role": "slider",
                            "aria-label": this.model.MaximumRoomRateFilterAriaLabel,
                            "aria-valuemin": this.$roomRateSlider.slider("values", 0),
                            "aria-valuemax": this.model.MaximumRoomRateFilterValue,
                            "aria-valuenow": this.$roomRateSlider.slider("values", 1)
                        });
                    }
                }
                BuildHistogram(values, min, max) {
                    starrez.library.controls.BuildHistogram(this.$histoGram, this.model.CurrencySymbol, values, min, max, ($ctnl) => {
                        var lowerVal = $ctnl.data("lower");
                        var upperVal = $ctnl.data("upper");
                        this.$roomRateSlider.slider("values", 0, lowerVal);
                        this.$roomRateSlider.slider("values", 1, upperVal + 1);
                        this.LoadResults(1);
                        this.UpdateSliderDataAndText();
                    });
                }
                HideFilters(ctrlFieldName) {
                    if (this.model.ShowFiltersWithoutRooms) {
                        return;
                    }
                    for (let filterType = 0; filterType < this.filterModels.length; filterType++) {
                        this.filterModels[filterType].SelectedFilterIDs = this.GetFilterVal(filterType);
                    }
                    if (starrez.library.utils.IsNullOrUndefined(ctrlFieldName)) {
                        ctrlFieldName = FilterType.None;
                    }
                    for (let filterType = 0; filterType < this.filterModels.length; filterType++) {
                        const filterModel = this.filterModels[filterType];
                        if (ctrlFieldName != filterType && filterModel.$FilterControl.isFound()) {
                            const visibleIDs = filterModel.GetVisibleFilterItems(this.filterData, filterType, this.filterModels);
                            if (portal.Feature.PXAccessibleFilterGroupSystem) {
                                filterModel.$FilterControl.each((_, filterCheckbox) => {
                                    if (visibleIDs.includes(parseInt(filterCheckbox.getAttribute("value"))))
                                        filterCheckbox.parentElement.Show("grid");
                                    else
                                        filterCheckbox.parentElement.Hide();
                                });
                            }
                            else {
                                starrez.library.controls.multipleselect.ShowItems(filterModel.$FilterControl, visibleIDs);
                            }
                        }
                    }
                }
                GetRoomSearchFilters() {
                    return {
                        DateStart: this.baseModel.DateStart, // not ideal cast but TSModel converts Dates to strings
                        DateEnd: this.baseModel.DateEnd, // not ideal cast but TSModel converts Dates to strings
                        RoomTypeID: this.GetFilterVal(FilterType.RoomTypeID),
                        RoomLocationAreaID: this.GetFilterVal(FilterType.RoomLocationAreaID),
                        RoomLocationID: this.GetFilterVal(FilterType.RoomLocationID),
                        RoomBaseIDs: this.model.RoomBaseIDs,
                        ProfileItemID: this.GetFilterVal(FilterType.ProfileItemID),
                        LowerRoomRateValue: this.GetRoomRateValue(0),
                        UpperRoomRateValue: this.GetRoomRateValue(1),
                        RoomLocationFloorSuiteID: this.GetFilterVal(FilterType.RoomLocationFloorSuiteID),
                        UseRoommateClassifications: this.model.UseRoommateClassifications
                    };
                }
                LoadResults(currentPageNumber) {
                    //without this model is undefined in thisRef.model.roomSelectionModel.RoomBaseIDs.indexOf(roomBaseID)
                    var thisRef = this;
                    this.currentPageNumber = currentPageNumber;
                    if (this.isSearching) {
                        // Prevent multiple searches from happening at once
                        this.isDirty = true;
                        return;
                    }
                    this.isSearching = true;
                    this.isDirty = false;
                    if (this.model.IsAuthenticated) {
                        new starrez.service.roomsearch.GetFilterResultsAuthenticated({
                            pageID: this.model.RoomSelectionPageID,
                            filters: this.GetRoomSearchFilters(),
                            processID: portal.page.CurrentPage.ProcessID,
                            currentPageNumber: this.currentPageNumber,
                            termID: this.model.TermID,
                            classificationID: this.model.ClassificationID,
                            groupID: this.model.GroupID,
                            hash: this.model.FilterResultsHash
                        }).Request({
                            ActionVerb: starrez.library.service.RequestType.Post,
                            ShowLoading: false,
                            LoadingFunc: (loading) => {
                                if (loading) {
                                    this.$resultsContainer.addClass("loading");
                                }
                                else {
                                    this.$resultsContainer.removeClass("loading");
                                }
                            }
                        }).done((result) => {
                            this.PopulateFilterResults(result, thisRef);
                        });
                    }
                    else {
                        new starrez.service.roomsearch.GetFilterResultsUnauthenticated({
                            pageID: this.model.RoomSelectionPageID,
                            filters: this.GetRoomSearchFilters(),
                            processID: portal.page.CurrentPage.ProcessID,
                            currentPageNumber: this.currentPageNumber,
                            termID: this.model.TermID,
                            classificationID: this.model.ClassificationID,
                            groupID: this.model.GroupID,
                            hash: this.model.FilterResultsHash
                        }).Request({
                            ActionVerb: starrez.library.service.RequestType.Post,
                            ShowLoading: false,
                            LoadingFunc: (loading) => {
                                if (loading) {
                                    this.$resultsContainer.addClass("loading");
                                }
                                else {
                                    this.$resultsContainer.removeClass("loading");
                                }
                            }
                        }).done((result) => {
                            this.PopulateFilterResults(result, thisRef);
                        });
                    }
                }
                PopulateFilterResults(result, thisRef) {
                    this.isSearching = false;
                    if (this.isDirty) {
                        this.LoadResults(this.currentPageNumber);
                        return;
                    }
                    //In IE, if the user clicks back button, the page won't be reloaded and will be using the last one from the cache (with the outdated information of RoomBaseIDs)
                    //The AJAX call is still calling the server though, so to fix this, we need to sync the RoomBaseIDs with the ones from the server.
                    this.model.RoomBaseIDs = result.RoomBaseIDs;
                    if (starrez.library.utils.IsNotNullUndefined(this.model.RoomBaseIDs) && this.model.RoomBaseIDs.length > 0) {
                        this.$continueButtonContainer.show();
                    }
                    this.RenderResults(this.$resultsContainer, result.ResultsHtml, thisRef);
                    portal.paging.AttachPagingClickEvent(this, this.$resultsContainer, this.LoadResults);
                    if (result.RoomSearchSuggestions != null && result.RoomSearchSuggestions.length > 0) {
                        this.$roomSearchLoading = this.$resultsContainer.find(".ui-room-search-loading");
                        this.SuggestRooms(result);
                    }
                    this.BuildHistogram(result.Rates, this.model.MinimumRoomRateFilterValue, this.model.MaximumRoomRateFilterValue);
                }
                SuggestRooms(result) {
                    this.suggestionGroupsNumber = result.RoomSearchSuggestions.length;
                    this.suggestionGroupsLoaded = 0;
                    this.hasSuggestions = false;
                    this.roomSearchGuid = result.RoomSearchGuid;
                    this.$suggestionContainer = this.$resultsContainer.find(".ui-room-suggestions");
                    this.$roomSearchLoading.show();
                    for (var i = 0; i < this.suggestionGroupsNumber; i++) {
                        new starrez.service.roomsearch.GetSuggestions({
                            pageID: this.model.RoomSelectionPageID,
                            processID: portal.page.CurrentPage.ProcessID,
                            suggestions: result.RoomSearchSuggestions[i],
                            roomSearchGuid: result.RoomSearchGuid,
                            termID: this.model.TermID,
                            classificationID: this.model.ClassificationID,
                            groupID: this.model.GroupID
                        }).Request({
                            ActionVerb: starrez.library.service.RequestType.Post,
                            ShowLoading: false
                        }).done((suggestions) => {
                            if (suggestions.RoomSearchGuid !== this.roomSearchGuid) {
                                //This seems like an outdated request, so just ignore
                                return;
                            }
                            this.suggestionGroupsLoaded++;
                            if (suggestions.HasResults) {
                                this.hasSuggestions = true;
                                this.AddSuggestionGroup(suggestions.Index, suggestions.ResultsHtml);
                            }
                            if (this.suggestionGroupsLoaded === this.suggestionGroupsNumber) {
                                this.$roomSearchLoading.hide();
                                if (!this.hasSuggestions) {
                                    this.$resultsContainer.find(".ui-no-suggestions-available").show();
                                }
                            }
                        });
                    }
                }
                AddSuggestionGroup(index, content) {
                    var $suggestionResultsContainer = $("<div>");
                    $suggestionResultsContainer.addClass("ui-suggestion-group");
                    $suggestionResultsContainer.attr("data-index", index);
                    var $otherResultsContainers = this.$suggestionContainer.children();
                    if ($otherResultsContainers.length == 0) {
                        this.$suggestionContainer.append($suggestionResultsContainer);
                    }
                    else {
                        var inserted = false;
                        for (var j = 0; j < $otherResultsContainers.length; j++) {
                            var $otherResultsContainer = $($otherResultsContainers[j]);
                            var otherResultsContainerIndex = Number($otherResultsContainer.data("index"));
                            var thisResultsContainerIndex = Number($suggestionResultsContainer.data("index"));
                            if (otherResultsContainerIndex > thisResultsContainerIndex) {
                                $suggestionResultsContainer.insertBefore($otherResultsContainer);
                                inserted = true;
                                break;
                            }
                        }
                        if (!inserted) {
                            this.$suggestionContainer.append($suggestionResultsContainer);
                        }
                    }
                    this.RenderResults($suggestionResultsContainer, content, this);
                }
                RenderResults($container, content, thisRef) {
                    $container.html(content);
                    // find all cards, check if the roombaseid is in the selected ids and toggle add/remove button accordingly
                    // this is in case rooms are selected and then filters are changed
                    var $cards = $container.find(".ui-add-room-to-cart");
                    $cards.each((index, item) => {
                        var $item = $(item);
                        var $result = $item.closest(".ui-card-result");
                        var roomBaseID = Number($result.data("roombaseid"));
                        if (!isNaN(roomBaseID) && thisRef.model.RoomBaseIDs.indexOf(roomBaseID) !== -1) {
                            var $removeButton = $item.siblings(".ui-remove-room-from-cart");
                            $item.hide();
                            $removeButton.show();
                        }
                    });
                }
            }
        })(main = roomsearch.main || (roomsearch.main = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.main.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var cache;
            (function (cache) {
                let _availableRoomIDs;
                let _expiration;
                function init(data) {
                    handleNavigation();
                    savePageState(data);
                    setExpiration(data.cache.cacheSeconds);
                    _availableRoomIDs = data.cache.availableRoomIDs;
                }
                cache.init = init;
                /** Stores the page's data in the window history */
                function savePageState(data) {
                    window.history.replaceState({
                        isCached: false,
                        events: data.events,
                        filter: data.filter,
                        headerPanel: data.headerOverviewPanel,
                        headings: data.headings,
                        level: data.roomListLevel,
                        templates: document.getElementById("vrs-templates").outerHTML,
                        showContentSwitcher: data.showContentSwitcher,
                        url: window.location.href
                    }, "");
                }
                cache.savePageState = savePageState;
                function getAvailableRoomIDs() {
                    if (shouldCache())
                        return _availableRoomIDs;
                }
                cache.getAvailableRoomIDs = getAvailableRoomIDs;
                function loadNextPage(html, url) {
                    updatePage(html);
                    updateHistory(url);
                }
                cache.loadNextPage = loadNextPage;
                function getPageState() {
                    return window.history.state;
                }
                function setExpiration(cacheSeconds) {
                    if (!cacheSeconds || cacheSeconds <= 0)
                        return;
                    const expiration = new Date;
                    expiration.setSeconds(expiration.getSeconds() + cacheSeconds);
                    _expiration = expiration;
                }
                function shouldCache() {
                    return _expiration > new Date;
                }
                /** Checks if we've navigated to a cached page */
                function handleNavigation() {
                    window.addEventListener('popstate', () => {
                        const page = getPageState();
                        if (page === null || page === void 0 ? void 0 : page.isCached) {
                            loadCachedPage(page);
                        }
                    });
                }
                function loadCachedPage(cachedPage) {
                    document.querySelector('.ui-roomlist').innerHTML += cachedPage.templates;
                    vrs.restore(cachedPage);
                }
                /** Sets the HTML, and fires the script to update components */
                function updatePage(html) {
                    var _a;
                    const container = document.getElementById('vrs-list');
                    container.querySelector('.ui-roomlist').outerHTML = html;
                    const script = (_a = container.querySelector('script')) === null || _a === void 0 ? void 0 : _a.textContent;
                    eval(script);
                }
                /** Caches the current page, and sets the URL to the next page  */
                function updateHistory(newURL) {
                    const cachedState = getPageState();
                    cachedState.isCached = true;
                    window.history.replaceState(cachedState, '');
                    window.history.pushState(null, '', newURL);
                }
            })(cache = vrs.cache || (vrs.cache = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.cache.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var contentswitcher;
            (function (contentswitcher) {
                "use strict";
                let locationAreaId;
                function init() {
                    const controls = getAllSelectControls();
                    controls.forEach((control, index) => {
                        hideDuplicateInAccessibilityTree(control, index);
                        control.addEventListener('change', function () {
                            setSelectedArea(control);
                            vrs.refreshResults();
                        });
                    });
                }
                contentswitcher.init = init;
                /** Shows or Hides the content switchers and their labels */
                function toggle(show) {
                    const contentSwitchers = document.querySelectorAll('.ui-vrs-content-switcher');
                    contentSwitchers.forEach(control => {
                        show ? control.Show()
                            : hideAndReset(control);
                    });
                    //if the DOM has reloaded after the page was cached
                    if (show && !(contentSwitchers === null || contentSwitchers === void 0 ? void 0 : contentSwitchers.length)) {
                        createControls();
                        init();
                    }
                }
                contentswitcher.toggle = toggle;
                function createControls() {
                    const template = document.getElementById("template-content-switcher");
                    const containers = document.querySelectorAll(".ui-vrs-top-content-switcher, .ui-vrs-list-container");
                    containers.forEach(container => {
                        container.innerHTML += template === null || template === void 0 ? void 0 : template.innerHTML;
                    });
                    const mobile = document.createElement('div');
                    mobile.className = 'vrs-mobile-content-switcher';
                    mobile.innerHTML = template === null || template === void 0 ? void 0 : template.innerHTML;
                    document.querySelector('.ui-vrs-layout').prepend(mobile);
                }
                /** Sets which AreaID is selected, then syncs all content switchers */
                function setSelectedArea(control) {
                    locationAreaId = $(control).SRVal();
                    syncDropdownControls(control);
                    vrs.filters.setArea(parseInt(locationAreaId));
                }
                function getAllSelectControls() {
                    return document.querySelectorAll('.ui-vrs-layout .ui-vrs-content-switcher-control');
                }
                function hideAndReset(control) {
                    control.Hide();
                    control.querySelector('select').selectedIndex = 0;
                }
                function syncDropdownControls(initiatingControl) {
                    const controls = getAllSelectControls();
                    controls.forEach((control) => {
                        if (control !== initiatingControl) {
                            $(control).SRVal(locationAreaId);
                        }
                    });
                }
                function hideDuplicateInAccessibilityTree(control, index) {
                    if (index === 1) {
                        control.ariaHidden = 'true';
                        control.tabIndex = -1;
                    }
                }
            })(contentswitcher = vrs.contentswitcher || (vrs.contentswitcher = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.contentswitcher.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var events;
            (function (events) {
                let eventName;
                let queryData;
                events.nextStepEvent = "nextStep";
                function init(eventData) {
                    eventName = eventData.eventName;
                    update(eventData);
                    document.addEventListener(events.nextStepEvent, (e) => {
                        executeEvents(e.detail.href);
                    });
                }
                events.init = init;
                function update(event) {
                    queryData = Object.assign({ hash: event.hash, pageID: event.pageID }, event.parentID && { parentID: event.parentID });
                }
                events.update = update;
                class ExecuteEvents extends starrez.library.service.AddInActionCallBase {
                    constructor(callData) {
                        super();
                        this.callData = callData;
                        this.Customer = "General";
                        this.Area = "VisualRoomSelection";
                        this.Controller = "VisualRoomSelection";
                        this.Action = eventName;
                    }
                    CallData() { return this.callData; }
                    ;
                    QueryData() { return queryData; }
                    ;
                }
                function executeEvents(href) {
                    new ExecuteEvents(getCallData(href)).Post().done((result) => {
                        if (eventName === 'GetNextStep' && result) {
                            vrs.cache.loadNextPage(result, href);
                        }
                        else {
                            window.location.href = href;
                        }
                    });
                }
                function getCallData(href) {
                    if (!vrs.level || !href)
                        return;
                    return {
                        level: vrs.level,
                        roomIDs: vrs.cache.getAvailableRoomIDs(),
                        queryString: getQueryString(href)
                    };
                }
                function getQueryString(href) {
                    return new URL(href).search;
                }
            })(events = vrs.events || (vrs.events = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.events.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var filters;
            (function (filters) {
                var desktop;
                (function (desktop) {
                    let roomType;
                    let minPrice;
                    let maxPrice;
                    let profileItem;
                    function init() {
                        let collection = document.querySelectorAll('.ui-vrs-filters:not(.ui-vrs-filters--clear-filters)');
                        collection.forEach((element) => {
                            element.addEventListener('click', (e) => {
                                let popover = document.getElementById(element.getAttribute('popovertarget'));
                                Popper.createPopper(element, popover, {
                                    placement: 'bottom',
                                    modifiers: [
                                        {
                                            name: 'offset',
                                            options: {
                                                offset: [-(element.clientWidth / 2), 0]
                                            }
                                        }
                                    ]
                                });
                            });
                        });
                        let clearFiltersButton = document.querySelector('.ui-vrs-filters--clear-filters');
                        clearFiltersButton.addEventListener('click', (e) => {
                            document.querySelectorAll('.ui-vrs-filters').forEach((el) => {
                                el.classList.remove('vrs-filters--active');
                            });
                        });
                        let menus = document.querySelectorAll('.vrs-filters-menu');
                        menus.forEach((element) => {
                            element.addEventListener('toggle', (e) => {
                                let node = e.target;
                                if (e.newState === "open") {
                                    node.previousElementSibling.classList.add('vrs-filters--active');
                                }
                                else {
                                    node.previousElementSibling.classList.remove('vrs-filters--active');
                                }
                            });
                        });
                        initFilterControls();
                    }
                    desktop.init = init;
                    function initFilterControls() {
                        document.querySelectorAll('.vrs-filters-menu input').forEach(element => {
                            element.addEventListener('change', (e) => {
                                _dispatchFilterOnChangeEvent();
                            });
                        });
                    }
                    function _dispatchFilterOnChangeEvent() {
                        document.dispatchEvent(new CustomEvent(filters.changeFilterEvent, {
                            bubbles: true,
                            detail: {
                                roomType: roomType,
                                minPrice: minPrice,
                                maxPrice: maxPrice,
                                profileItem: profileItem
                            }
                        }));
                    }
                })(desktop = filters.desktop || (filters.desktop = {}));
            })(filters = vrs.filters || (vrs.filters = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.filters.desktop.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var filters;
            (function (filters) {
                const storageName = 'VRS_Filters';
                let filter = { areaID: undefined, featureFlag: false, minPrice: 0, maxPrice: 0, roomType: [], profileItem: [] };
                filters.changeFilterEvent = "changeFilter";
                function init(initialFilter) {
                    loadFilter();
                    filter.featureFlag = initialFilter.featureFlag;
                    setArea(initialFilter.areaID);
                    if (!filter.featureFlag)
                        return;
                    document.addEventListener(filters.changeFilterEvent, () => vrs.refreshResults());
                    filters.desktop.init();
                    filters.mobile.init();
                }
                filters.init = init;
                /* For Theme Viewer */
                function themeViewerInit() {
                    loadFilter();
                    filters.desktop.init();
                    filters.mobile.init();
                }
                filters.themeViewerInit = themeViewerInit;
                /** Returns search results which meet the filter critera */
                function getFilteredResults(searchResults) {
                    return searchResults === null || searchResults === void 0 ? void 0 : searchResults.filter(room => filters.meetsCriteria(room));
                }
                filters.getFilteredResults = getFilteredResults;
                /** checks if a search result meets the filter criteria */
                function meetsCriteria(searchResult) {
                    var _a, _b;
                    let criteria = [];
                    criteria.push(filterArea(searchResult));
                    if (filter.featureFlag) {
                        //add profile, price, and type checks here
                        if (((_a = filter.roomType) === null || _a === void 0 ? void 0 : _a.length) > 0) {
                            criteria.push((_b = searchResult.roomTypeIds) === null || _b === void 0 ? void 0 : _b.some(id => filter.roomType.includes(id)));
                        }
                        criteria.push(filterByPrice(searchResult));
                    }
                    //check every condition is true
                    return criteria.every(check => check === true);
                }
                filters.meetsCriteria = meetsCriteria;
                /** Only show Locations from this Area */
                function setArea(areaID) {
                    if (vrs.level !== vrs.RoomListLevel.Location || isNaN(areaID)) {
                        return;
                    }
                    filter.areaID = areaID;
                }
                filters.setArea = setArea;
                /** If it's a RoomLocation, checks it belongs to the Area */
                function filterArea(searchResult) {
                    if (vrs.level !== vrs.RoomListLevel.Location || !filter.areaID)
                        return true;
                    return searchResult.parentID === filter.areaID;
                }
                function initCheckboxListFilter(element, data) {
                    let inputList = element.querySelectorAll('input');
                    const filterButton = element.querySelector('.ui-vrs-filters');
                    filterButton === null || filterButton === void 0 ? void 0 : filterButton.addEventListener('click', () => loadCheckboxesFilters(element, data.property));
                    inputList.forEach((el) => {
                        el.addEventListener('change', () => {
                            filter[data.property] = Array.from(inputList).filter((el) => el.checked).map((el) => parseInt(el.value));
                            if (filterButton) {
                                if (filter[data.property].length > 0) {
                                    filterButton.setAttribute('data-filter-count', filter[data.property].length.toString());
                                }
                                else {
                                    filterButton.removeAttribute('data-filter-count');
                                }
                            }
                            if (filterButton) //checks we're in desktop mode
                                saveFilter();
                        });
                    });
                }
                filters.initCheckboxListFilter = initCheckboxListFilter;
                function initPriceRangeFilter(element, data) {
                    let minPriceElement = element.querySelectorAll('input')[0];
                    let maxPriceElement = element.querySelectorAll('input')[1];
                    const filterButton = element.querySelector('.ui-vrs-filters');
                    filterButton === null || filterButton === void 0 ? void 0 : filterButton.addEventListener('click', () => loadPriceFilters(minPriceElement, maxPriceElement));
                    minPriceElement.addEventListener('change', () => {
                        filter[data.minPriceProperty] = parseFloat(minPriceElement.value);
                        if (filter[data.minPriceProperty] > 0 && filter[data.maxPriceProperty] > 0) {
                            filterButton === null || filterButton === void 0 ? void 0 : filterButton.setAttribute('data-price-range', `${data.currencySymbol}${filter[data.minPriceProperty]} to ${data.currencySymbol}${filter[data.maxPriceProperty]}`);
                        }
                        else {
                            filterButton === null || filterButton === void 0 ? void 0 : filterButton.removeAttribute('data-price-range');
                        }
                        if (filterButton)
                            saveFilter();
                    });
                    maxPriceElement.addEventListener('change', () => {
                        filter[data.maxPriceProperty] = parseFloat(maxPriceElement.value);
                        if (filter[data.minPriceProperty] > 0 && filter[data.maxPriceProperty] > 0) {
                            element.querySelector('.ui-vrs-filters').setAttribute('data-price-range', `${data.currencySymbol}${filter[data.minPriceProperty]} to ${data.currencySymbol}${filter[data.maxPriceProperty]}`);
                        }
                        else {
                            element.querySelector('.ui-vrs-filters').removeAttribute('data-price-range');
                        }
                        if (filterButton)
                            saveFilter();
                    });
                }
                filters.initPriceRangeFilter = initPriceRangeFilter;
                function filterByPrice(searchResult) {
                    return !(filter.minPrice > searchResult.maxPrice || filter.maxPrice < searchResult.minPrice)
                        //remove the condition below when we have added the auto-setting of min and max price values on the filter, as rooms should theoretically never have a min or max price of 0
                        || (filter.minPrice == 0 || filter.maxPrice == 0);
                }
                /** Loads the Price Filter inputs' values */
                function loadPriceFilters(minInput, maxInput) {
                    if (minInput) {
                        minInput.valueAsNumber = filter.minPrice;
                    }
                    if (maxInput) {
                        maxInput.valueAsNumber = filter.maxPrice;
                    }
                }
                /** Gets the selections for a Filter Type, and checks the checkboxes if they're selected */
                function loadCheckboxesFilters(container, filterType) {
                    if (!filter.hasOwnProperty(filterType)) {
                        console.error(`Couldn't find ${filterType} in our filters.`);
                        return;
                    }
                    const selections = filter[filterType];
                    const checkboxes = container === null || container === void 0 ? void 0 : container.querySelectorAll('input[type=checkbox]');
                    checkboxes.forEach(checkbox => checkbox.checked = selections.includes(Number(checkbox.value)));
                }
                /** Gets the filter from session storage, otherwise loads the default */
                function loadFilter() {
                    const savedFilter = JSON.parse(sessionStorage.getItem(storageName));
                    if (savedFilter) {
                        filter = savedFilter;
                    }
                    saveFilter();
                }
                /** Saves the filter to session storage */
                function saveFilter() {
                    sessionStorage.setItem(storageName, JSON.stringify(filter));
                }
                filters.saveFilter = saveFilter;
            })(filters = vrs.filters || (vrs.filters = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.filters.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var filters;
            (function (filters) {
                var mobile;
                (function (mobile) {
                    let dialog;
                    let dialogContainer;
                    let openMobileFiltersButton;
                    let closeMobileFiltersButton;
                    let applyMobileFiltersButton;
                    function init(container = document.querySelector(".vrs-list-tab-layout")) {
                        if (!container) {
                            return;
                        }
                        openMobileFiltersButton = container.querySelector(".ui-vrs-mobile-filters-button");
                        dialogContainer = document.querySelector(".ui-vrs-layout");
                        dialog = dialogContainer === null || dialogContainer === void 0 ? void 0 : dialogContainer.querySelector(".ui-vrs-mobile-filters-dialog");
                        if (!dialog) {
                            return;
                        }
                        closeMobileFiltersButton = dialog.querySelector(".ui-vrs-mobile-filters-close");
                        applyMobileFiltersButton = dialog.querySelector(".ui-vrs-apply-mobile-filters");
                        attachFilterButtonEvents();
                    }
                    mobile.init = init;
                    function attachFilterButtonEvents() {
                        openMobileFiltersButton.addEventListener("click", () => {
                            dialog.showModal();
                        });
                        closeMobileFiltersButton.addEventListener("click", () => {
                            dialog.close();
                        });
                        applyMobileFiltersButton === null || applyMobileFiltersButton === void 0 ? void 0 : applyMobileFiltersButton.addEventListener("click", () => {
                            vrs.refreshResults();
                            dialog.close();
                            filters.saveFilter();
                        });
                    }
                })(mobile = filters.mobile || (filters.mobile = {}));
            })(filters = vrs.filters || (vrs.filters = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.filters.mobile.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var headerpanel;
            (function (headerpanel) {
                let headerContainer;
                let headerPanelTemplate;
                function init(panel) {
                    headerPanelTemplate = document.getElementById("template-header-overview-panel");
                    headerContainer = document.querySelector(".ui-header-panel");
                    shouldShow(panel)
                        ? render()
                        : clear();
                }
                headerpanel.init = init;
                function clear() {
                    headerContainer.innerHTML = "";
                }
                function shouldShow(panel) {
                    return Boolean(panel && (panel.description || panel.photoComponent.src || panel.mapComponent.src));
                }
                function render() {
                    const header = headerPanelTemplate.content.cloneNode(true);
                    headerContainer === null || headerContainer === void 0 ? void 0 : headerContainer.append(header);
                    vrs.overviewpanel.init(headerContainer);
                }
                function update(panel) {
                    clear();
                    init(panel);
                    headerContainer.querySelectorAll('.ui-thumbnail-image').forEach(thumbnail => {
                        portal.locationthumbnailimage.initComponent(thumbnail.id);
                    });
                }
                headerpanel.update = update;
            })(headerpanel = vrs.headerpanel || (vrs.headerpanel = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.headerpanel.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var indexeddb;
            (function (indexeddb) {
                const dbPrefix = "VRS_";
                const dbName = dbPrefix + getSessionID();
                let dbRef;
                function init(pageChildPanels) {
                    return __awaiter(this, void 0, void 0, function* () {
                        if (window.indexedDB) {
                            try {
                                dbRef = yield createDatabase();
                                yield loadInitalDbData(pageChildPanels);
                                autoDeleteDB();
                            }
                            catch (error) {
                                console.error(`Error creating client side IndexedDB database. ${error}`);
                            }
                        }
                        else {
                            console.error("IndexedDB is not supported in this browser. Please update your browser to the latest.");
                        }
                    });
                }
                indexeddb.init = init;
                function update(pageChildPanels) {
                    return __awaiter(this, void 0, void 0, function* () {
                        if (pageChildPanels && window.indexedDB) {
                            try {
                                const clear = getObjectStore("readwrite").clear();
                                clear.onsuccess = () => loadInitalDbData(pageChildPanels)
                                    .then(() => { return; });
                            }
                            catch (error) {
                                console.error(`Error creating client side IndexedDB database. ${error}`);
                            }
                        }
                    });
                }
                indexeddb.update = update;
                /** Deletes an IndexedDB with this name */
                function deleteDatabase(dbName) {
                    return __awaiter(this, void 0, void 0, function* () {
                        return new Promise((resolve, reject) => {
                            const request = window.indexedDB.deleteDatabase(dbName);
                            request.onerror = function (event) {
                                const requestEventTarget = event.target;
                                reject(`Error deleting database: ${requestEventTarget.error}`);
                            };
                            request.onsuccess = function () {
                                resolve("Client side IndexedDB Database deleted successfully");
                            };
                        });
                    });
                }
                /**
             * Opens an IndexedDB database, and creates an object store if it doesn't exist.
             * @param {string} name - The name of the IndexedDB database to open.
             * @param {number} version - The version of the database. If the version specified is greater than the existing database version, or if the database does not exist, the 'onupgradeneeded' event is triggered where the database schema can be updated.
             * @returns {Promise} A promise that resolves with the opened database when the database is opened successfully, or rejects with an error message when the opening fails.
             */
                function createDatabase() {
                    return new Promise((resolve, reject) => {
                        const request = indexedDB.open(dbName);
                        request.onupgradeneeded = function (event) {
                            const upgradeEventTarget = event.target;
                            const db = upgradeEventTarget.result;
                            // Create an objectStore for all VRS overview panels
                            if (!db.objectStoreNames.contains(vrs.RoomListLevel[vrs.level])) {
                                CreateTables(db);
                            }
                        };
                        request.onerror = function (event) {
                            const requestEventTarget = event.target;
                            reject(`Error opening client side IndexedDB database. ${requestEventTarget.error}`);
                        };
                        request.onsuccess = function (event) {
                            const upgradeEventTarget = event.target;
                            resolve(upgradeEventTarget.result);
                        };
                    });
                }
                function CreateTables(db) {
                    const options = { keyPath: "id" };
                    db.createObjectStore(vrs.RoomListLevel[vrs.RoomListLevel.Location], options);
                    db.createObjectStore(vrs.RoomListLevel[vrs.RoomListLevel.Section], options);
                    db.createObjectStore(vrs.RoomListLevel[vrs.RoomListLevel.FloorSuite], options);
                    db.createObjectStore(vrs.RoomListLevel[vrs.RoomListLevel.Room], options);
                }
                function saveChildPanels(db, panels) {
                    const objectStore = getObjectStore("readwrite");
                    panels.forEach((panel) => {
                        const request = objectStore.put(panel);
                        request.onerror = function (event) {
                            throw new Error(`Error saving child panel to IndexedDB: ${event}`);
                        };
                    });
                }
                function loadInitalDbData(childPages) {
                    return new Promise((resolve, reject) => {
                        if (Array.isArray(childPages) && childPages.length > 0) {
                            try {
                                saveChildPanels(dbRef, childPages);
                                resolve(childPages);
                            }
                            catch (error) {
                                reject(`Failed to save child panels: ${error}`);
                            }
                        }
                        else {
                            resolve("No child panels to add");
                        }
                    });
                }
                /*** Gets all childpanels from the locally stored database (IndexedDB), without pagination */
                function getAllChildPanels() {
                    return new Promise((resolve, reject) => {
                        if (!dbRef) {
                            reject("Database not initialized. Please call init first.");
                        }
                        const panels = [];
                        const request = requestData();
                        request.onsuccess = (event) => {
                            const cursor = event.target.result;
                            if (cursor) {
                                if (vrs.filters.meetsCriteria(cursor.value)) {
                                    panels.push(cursor.value);
                                }
                                cursor.continue();
                            }
                            else {
                                panels.sort((x, y) => x.title > y.title ? 1 : x.title < y.title ? -1 : 0);
                                resolve(panels);
                            }
                        };
                        request.onerror = (event) => {
                            const requestEventTarget = event.target;
                            reject(`Error fetching child panels: ${requestEventTarget.error}`);
                        };
                    });
                }
                indexeddb.getAllChildPanels = getAllChildPanels;
                /** Gets childpanels from the locally stored database (IndexedDB), taking paging into account  */
                function getChildPanels(pagingInfo) {
                    return new Promise((resolve) => {
                        getAllChildPanels().then(panels => {
                            const startIndex = (pagingInfo.currentPageNumber - 1) * pagingInfo.pageSize;
                            resolve(panels.slice(startIndex, startIndex + pagingInfo.pageSize));
                        });
                    });
                }
                indexeddb.getChildPanels = getChildPanels;
                /** Deletes the client-side DB if it hasn't been used for a day */
                function autoDeleteDB() {
                    return __awaiter(this, void 0, void 0, function* () {
                        const databases = yield window.indexedDB.databases();
                        const sessions = [];
                        getAllSessions().forEach(session => {
                            const dbName = dbPrefix + session.id;
                            if (!databases.some(db => db.name === dbName))
                                return;
                            const expires = new Date();
                            expires.setDate(new Date(session.accessed).getDate() + 1);
                            if (new Date() > expires) {
                                deleteDatabase(dbName);
                            }
                            else {
                                sessions.push(session);
                            }
                        });
                        saveAllSessions(sessions);
                    });
                }
                /** Creates a random UUID; or falls back to a random string, if not using HTTPS or localhost.
                * Stores it in this tab's session */
                function createSessionID() {
                    const sessionID = crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).substring(2);
                    sessionStorage.setItem('VRS_sessionID', sessionID);
                    updateSession(sessionID);
                    return sessionID;
                }
                function getAllSessions() {
                    var _a;
                    return (_a = JSON.parse(localStorage.getItem('VRS_sessions'))) !== null && _a !== void 0 ? _a : [];
                }
                /** Creates a unique ID for this tab's session.
                *  Prevents multiple tabs overriding the indexedDB. */
                function getSessionID() {
                    const vrsSessionID = sessionStorage.getItem('VRS_sessionID');
                    return vrsSessionID
                        ? vrsSessionID
                        : createSessionID();
                }
                function getObjectStore(transactionMode = 'readonly') {
                    const transaction = dbRef.transaction(vrs.RoomListLevel[vrs.level], transactionMode);
                    return transaction.objectStore(vrs.RoomListLevel[vrs.level]);
                }
                function requestData() {
                    const objectStore = getObjectStore();
                    updateSession(getSessionID());
                    return objectStore.openCursor();
                }
                /** Updates the last time this database was accessed  */
                function updateSession(sessionID) {
                    const vrsSessions = getAllSessions();
                    const thisSession = vrsSessions.find(session => session.id === sessionID);
                    if (!thisSession) {
                        vrsSessions.push({ id: sessionID, accessed: new Date });
                    }
                    else {
                        thisSession.accessed = new Date;
                    }
                    saveAllSessions(vrsSessions);
                }
                function saveAllSessions(vrsSessions) {
                    localStorage.setItem('VRS_sessions', JSON.stringify(vrsSessions));
                }
            })(indexeddb = vrs.indexeddb || (vrs.indexeddb = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.indexeddb.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            let RoomListLevel;
            (function (RoomListLevel) {
                RoomListLevel[RoomListLevel["Location"] = 2] = "Location";
                RoomListLevel[RoomListLevel["Section"] = 3] = "Section";
                RoomListLevel[RoomListLevel["FloorSuite"] = 4] = "FloorSuite";
                RoomListLevel[RoomListLevel["Room"] = 5] = "Room";
            })(RoomListLevel = vrs.RoomListLevel || (vrs.RoomListLevel = {}));
            function init(_, data) {
                vrs.level = data.roomListLevel;
                vrs.cache.init(data);
                vrs.filters.init(data.filter);
                const filteredPanels = vrs.filters.getFilteredResults(data.overviewPanels);
                data.pagingInfo.totalResults = filteredPanels.length;
                vrs.layout.init();
                vrs.headerpanel.init(data.headerOverviewPanel);
                vrs.mapselector.init(data.overviewPanels, data.mapSelector);
                vrs.indexeddb.init(data.overviewPanels)
                    .then(() => { vrs.pagination.init(data.pagingInfo); })
                    .then(() => { vrs.contentswitcher.init(); });
                vrs.roomlist.init(getFirstPage(filteredPanels, data.pagingInfo.pageSize));
                vrs.events.init(data.events);
            }
            vrs.init = init;
            /** Loads new data */
            function update(_, data) {
                vrs.level = data.roomListLevel;
                vrs.cache.savePageState(data);
                vrs.events.update(data.events);
                vrs.layout.setHeadings(data.headings);
                vrs.indexeddb.update(data.overviewPanels);
                vrs.headerpanel.update(data.headerOverviewPanel);
                vrs.contentswitcher.toggle(data.showContentSwitcher);
                vrs.mapselector.init(data.overviewPanels, data.mapSelector);
                vrs.roomlist.init(getFirstPage(data.overviewPanels, data.pagingInfo.pageSize));
                vrs.pagination.resetPagination(data.pagingInfo.totalResults);
            }
            vrs.update = update;
            /** Loads cached data */
            function restore(cache) {
                vrs.level = cache.level;
                vrs.filters.setArea(cache.filter.areaID);
                vrs.indexeddb.getAllChildPanels()
                    .then(panels => {
                    vrs.contentswitcher.toggle(cache.showContentSwitcher);
                    vrs.layout.setHeadings(cache.headings);
                    vrs.headerpanel.update(cache.headerPanel);
                    vrs.mapselector.init(panels);
                    vrs.roomlist.init(getFirstPage(panels, vrs.pagination.paging.pageSize));
                    vrs.pagination.resetPagination(panels.length);
                    vrs.events.update(cache.events);
                })
                    .catch(() => window.location.reload());
            }
            vrs.restore = restore;
            /** Gets the latest search results, then updates the map selector, room list, and pagination */
            function refreshResults() {
                vrs.indexeddb.getAllChildPanels()
                    .then(panels => {
                    updateResults(panels);
                });
            }
            vrs.refreshResults = refreshResults;
            /** Updates the map selector, room list, and pagination */
            function updateResults(panels) {
                const pageSize = vrs.pagination.getPageSize();
                const firstPage = getFirstPage(panels, pageSize);
                vrs.roomlist.updateRoomList(firstPage);
                vrs.mapselector.init(panels);
                vrs.pagination.resetPagination(panels.length);
            }
            function getFirstPage(roomOverviews, pageSize) {
                return roomOverviews.slice(0, pageSize);
            }
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var layout;
            (function (layout_1) {
                "use strict";
                function init() {
                    const layout = document.querySelector('.ui-vrs-layout');
                    const listTab = layout.querySelector('[data-tab-id="list-tab"]');
                    const mapTab = layout.querySelector('[data-tab-id="map-tab"]');
                    const listButton = layout.querySelector('.ui-vrs-list-tab-button');
                    const mapButton = layout.querySelector('.ui-vrs-map-tab-button');
                    RestartButtonInit();
                    listButton === null || listButton === void 0 ? void 0 : listButton.addEventListener('click', () => {
                        mapTab.classList.add("hidden");
                        listTab.classList.remove("hidden");
                        listButton.setAttribute("aria-selected", "true");
                        mapButton.setAttribute("aria-selected", "false");
                    });
                    mapButton === null || mapButton === void 0 ? void 0 : mapButton.addEventListener('click', () => {
                        mapTab.classList.remove("hidden");
                        listTab.classList.add("hidden");
                        listButton.setAttribute("aria-selected", "false");
                        mapButton.setAttribute("aria-selected", "true");
                    });
                    document.querySelectorAll(".ui-overview-panel")
                        .forEach(panel => {
                        portal.roomsearch.vrs.overviewpanel.init(panel);
                    });
                }
                layout_1.init = init;
                function setHeadings(headings) {
                    portal.page.setTitle(headings.page);
                    document.querySelector('.ui-map-heading').innerHTML = headings.map;
                    document.querySelector('.ui-list-heading').innerHTML = headings.list;
                }
                layout_1.setHeadings = setHeadings;
                /**
                 * Attaches the reset button to the page actions
                 * @remarks Reset and restart terms are being used interchangeably for Before Save Button
                 */
                function RestartButtonInit() {
                    var _a;
                    const restartButton = document.querySelector('.ui-vrs-layout .ui-restart-roomsearch');
                    if (restartButton) {
                        (_a = document.querySelector('.ui-page-actions')) === null || _a === void 0 ? void 0 : _a.append(restartButton);
                        roomsearch.AttachResetButton();
                    }
                }
                layout_1.RestartButtonInit = RestartButtonInit;
            })(layout = vrs.layout || (vrs.layout = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.layout.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var mapselector;
            (function (mapselector) {
                var desktop;
                (function (desktop) {
                    "use strict";
                    /**
                     * Class for managing the Map Location Selector Component
                     */
                    class MapLocationSelector {
                        constructor(_container) {
                            this._container = _container;
                            this._event = (_name, _val) => { };
                            this.popupClass = ".room-selection-popup";
                            this._popupElement = _container.querySelector(this.popupClass);
                            this._d3 = d3.select(_container.querySelector("svg"));
                            try {
                                const template = _container.querySelector("template");
                                const Json = JSON.parse(template.innerHTML);
                                this.init(Json);
                            }
                            catch (e) {
                                console.error(JSON.stringify(e));
                            }
                        }
                        init(data) {
                            const { mapUrl = "", items = [], } = data;
                            const imageElement = this._container.querySelector('image');
                            if (mapUrl) {
                                if (imageElement) {
                                    imageElement.href.baseVal = decodeURIComponent(mapUrl);
                                }
                            }
                            else {
                                imageElement.href.baseVal = "";
                            }
                            if (Array.isArray(items) && (items === null || items === void 0 ? void 0 : items.length) > 0) {
                                this._clearAllPolygons();
                                const zoom = d3.zoom()
                                    .extent([[0, 0], [600, 400]])
                                    .scaleExtent([1, 8])
                                    .on("zoom", null)
                                    .on("zoom", (e) => {
                                    var _a, _b;
                                    switch ((_a = e.sourceEvent) === null || _a === void 0 ? void 0 : _a.type) {
                                        case "mousemove": {
                                            this._d3.selectAll("g[data-type='page']").attr("transform", e.transform);
                                            break;
                                        }
                                        case "wheel": {
                                            if ((_b = e.sourceEvent) === null || _b === void 0 ? void 0 : _b.ctrlKey) {
                                                this._d3.selectAll("g[data-type='page']").attr("transform", e.transform);
                                            }
                                            break;
                                        }
                                        default:
                                            this._d3.selectAll("g[data-type='page']").attr("transform", e.transform);
                                    }
                                });
                                this._d3.call(zoom);
                                items.forEach(location => {
                                    const g = this._d3
                                        .select("g[data-type='page']")
                                        .append('g')
                                        .attr("data-id", location.id)
                                        .attr("data-type", "location");
                                    g.append('a')
                                        .attr("href", location.buttonUrl)
                                        .attr("aria-label", location.caption)
                                        .on("focus", (e) => {
                                        this._selectLocation(e.target.firstElementChild, location);
                                    })
                                        .on("mouseover", (e) => {
                                        this._selectLocation(e.target, location);
                                    })
                                        .on("mouseleave", () => {
                                        this.unselectIfNotHovered();
                                    })
                                        .on("mousedown", (e) => {
                                        e.stopPropagation();
                                        e.preventDefault();
                                    })
                                        .on("click", (e) => {
                                        e.preventDefault();
                                        this._dispatchNextStepEvent(window.location.origin + location.buttonUrl);
                                    })
                                        .append('polygon')
                                        .attr('points', location.points)
                                        .attr('stroke', '#000AFF')
                                        .style('fill', "#000AFF66");
                                });
                                this._popupElement.addEventListener("mouseleave", () => {
                                    this._unSelectAllLocations();
                                });
                                // zoom in out buttons
                                this._container.querySelector(".ui-zoom-button-zoomin").addEventListener("click", e => {
                                    this._d3.transition().call(zoom.scaleBy, 2);
                                });
                                this._container.querySelector(".ui-zoom-button-zoomout").addEventListener("click", e => {
                                    this._d3.transition().call(zoom.scaleBy, 0.5);
                                });
                            }
                            else {
                                this._clearAllPolygons();
                            }
                        }
                        _clearAllPolygons() {
                            this._d3
                                .select("g[data-type='page']")
                                .selectAll("g[data-type='location']")
                                .remove();
                        }
                        onClick(e) {
                            this._event = e;
                        }
                        _selectLocation(element, location) {
                            this._unSelectAllLocations();
                            element.classList.add("selected");
                            this._displayHoverHelper(element, location);
                        }
                        _displayHoverHelper(element, location) {
                            const options = {
                                strategy: 'fixed',
                                modifiers: [
                                    {
                                        name: 'preventOverflow',
                                        options: {
                                            boundary: this._container,
                                        },
                                    },
                                ],
                                placement: 'bottom',
                            };
                            // show this new room
                            const heroImage = this._popupElement.querySelector(".ui-vrs-mapselector-heroimage");
                            heroImage.onerror = () => {
                                heroImage.classList.add("hidden");
                            };
                            const roomRate = this._popupElement.querySelector(".ui-plan-room-rate");
                            this._popupElement.querySelector("h2").innerText = location.caption;
                            this.setImageAttributes(location, heroImage);
                            if (location.roomRateValue > 0) {
                                roomRate.innerText = location.roomRateText;
                            }
                            else {
                                roomRate.innerText = "";
                            }
                            function getVisiblePolygonRect(polygon, container) {
                                const polygonBox = polygon.getBoundingClientRect();
                                const containerBox = container.getBoundingClientRect();
                                // Find the intersection of the polygon with the container
                                const visibleX = Math.max(polygonBox.left, containerBox.left);
                                const visibleY = Math.max(polygonBox.top, containerBox.top);
                                const visibleWidth = Math.max(0, Math.min(polygonBox.right, containerBox.right) - visibleX);
                                const visibleHeight = Math.max(0, Math.min(polygonBox.bottom, containerBox.bottom) - visibleY);
                                // Return the visible bounding rect as a reference
                                return {
                                    getBoundingClientRect: () => ({
                                        width: visibleWidth,
                                        height: visibleHeight,
                                        top: visibleY,
                                        left: visibleX,
                                        right: visibleX + visibleWidth,
                                        bottom: visibleY + visibleHeight,
                                    }),
                                    contextElement: polygon
                                };
                            }
                            // Get the visible part of the polygon that fits in the container
                            const visiblePolygon = getVisiblePolygonRect(element, this._container);
                            Popper.createPopper(visiblePolygon, this._popupElement, options);
                        }
                        setImageAttributes(location, heroImage) {
                            var _a;
                            const heroImageSrc = decodeURIComponent(location.heroImage);
                            if ((_a = heroImageSrc === null || heroImageSrc === void 0 ? void 0 : heroImageSrc.trim()) === null || _a === void 0 ? void 0 : _a.length) {
                                heroImage.classList.remove("hidden");
                                heroImage.src = heroImageSrc;
                                heroImage.alt = location.altText;
                            }
                            else {
                                heroImage.classList.add("hidden");
                            }
                        }
                        unselectIfNotHovered() {
                            if (this._container.querySelector(this.popupClass + ":hover")) {
                                return;
                            }
                            this._unSelectAllLocations();
                        }
                        _unSelectAllLocations() {
                            this._container.querySelectorAll(".selected").forEach(e => e.classList.remove("selected"));
                        }
                        _dispatchNextStepEvent(href) {
                            this._popupElement.dispatchEvent(new CustomEvent(vrs.events.nextStepEvent, {
                                bubbles: true,
                                detail: { href: href }
                            }));
                        }
                    }
                    desktop.MapLocationSelector = MapLocationSelector;
                    function updateDesktopMapSelector(mapSelectorData, showPlanLocationOnPortal, init = false) {
                        const desktopMapSelector = new MapLocationSelector(document.querySelector(".ui-vrs-map-selector"));
                        init && desktopMapSelector.init(mapSelectorData);
                        toggleMapSelector(showPlanLocationOnPortal && mapSelectorData.mapUrl !== '');
                    }
                    desktop.updateDesktopMapSelector = updateDesktopMapSelector;
                    function toggleMapSelector(display) {
                        if (display) {
                            document.querySelector(".ui-vrs-map-selector").Show();
                            document.querySelector('.image-picker-list-heading').Show();
                            document.querySelector('.ui-vrs-top-content-switcher').Show();
                        }
                        else {
                            document.querySelector(".ui-vrs-map-selector").Hide();
                            document.querySelector('.image-picker-list-heading').Hide();
                            document.querySelector('.ui-vrs-top-content-switcher').Hide();
                        }
                    }
                })(desktop = mapselector.desktop || (mapselector.desktop = {}));
            })(mapselector = vrs.mapselector || (vrs.mapselector = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.mapselector.desktop.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var mapselector;
            (function (mapselector) {
                let isMobile;
                let showMapSelector;
                let resizeTimeout;
                /** Starts the Map Selector component. If there is no mapSelectorData, it will be created from the search results */
                function init(searchResults, mapSelectorData = null) {
                    if (!(searchResults === null || searchResults === void 0 ? void 0 : searchResults.length))
                        return;
                    if (mapSelectorData === null) {
                        mapSelectorData = getMapSelectorData(searchResults);
                    }
                    if (!resizeTimeout) {
                        showOnResize();
                    }
                    isMobile = isMobileMode();
                    showMapSelector = isMapSelectorShown(searchResults);
                    update(mapSelectorData, true);
                }
                mapselector.init = init;
                function update(mapSelectorData, init = false) {
                    if (isMobile) {
                        mapselector.mobile.updateMobileMapSelector(mapSelectorData, showMapSelector, init);
                    }
                    else {
                        mapselector.desktop.updateDesktopMapSelector(mapSelectorData, showMapSelector, init);
                    }
                }
                mapselector.update = update;
                function getMapItem(item) {
                    return {
                        id: item.id.toString(),
                        buttonUrl: item.buttonUrl,
                        caption: item.title,
                        altText: item.photoComponent.alt,
                        heroImage: item.photoComponent.src,
                        points: item.mapComponent.points
                    };
                }
                function getMapSelectorData(searchResults) {
                    return {
                        mapUrl: searchResults[0].mapComponent.src,
                        items: searchResults.map(getMapItem)
                    };
                }
                function isMobileMode() {
                    return window.innerWidth < 961; //shared_media_desktop-min-width breakpoint
                }
                function isMapSelectorShown(searchResults) {
                    var _a;
                    return (_a = searchResults[0]) === null || _a === void 0 ? void 0 : _a.showPlanLocationOnPortal;
                }
                function showOnResize() {
                    const resize = new ResizeObserver((entries) => {
                        if (entries) {
                            clearTimeout(resizeTimeout);
                            resizeTimeout = setTimeout(() => {
                                if (isMobileMode() !== isMobile) {
                                    vrs.indexeddb.getAllChildPanels().then((panels) => {
                                        mapselector.init(panels);
                                    });
                                }
                            }, 250);
                        }
                    });
                    const container = document.querySelector('.ui-vrs-layout');
                    resize.observe(container);
                }
            })(mapselector = vrs.mapselector || (vrs.mapselector = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.mapselector.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var mapselector;
            (function (mapselector) {
                var mobile;
                (function (mobile) {
                    "use strict";
                    /**
                     * Class for managing the Map Location Selector Component
                     */
                    class MobileMapLocationSelector {
                        constructor(_container) {
                            this._container = _container;
                            this._event = (_name, _val) => { };
                            this._infoElement = _container.querySelector(".ui-room-selection-info");
                            const imageElement = this._infoElement.querySelector("img");
                            imageElement.onerror = () => {
                                this._infoElement.classList.add("no-image");
                            };
                            this._d3 = d3.select(_container.querySelector("svg"));
                            this._toastPopup = _container.querySelector(".ui-map-info-message");
                            this._initDialog(_container);
                            try {
                                const template = _container.querySelector("template");
                                const Json = JSON.parse(template.innerHTML);
                                this.init(Json);
                                portal.roomsearch.vrs.roomrateinfo.attachCalculateTotalClickEvent(_container);
                            }
                            catch (e) {
                                console.error(JSON.stringify(e));
                            }
                        }
                        _initDialog(container) {
                            const dialog = container.querySelector(".ui-map-selector");
                            const button = dialog.querySelector(".ui-lightbox-close");
                            // add click event
                            container.querySelector(".ui-enlarge-map").addEventListener("click", () => {
                                dialog.showModal();
                                vrs.filters.mobile.init(dialog);
                            });
                            button.addEventListener("click", () => {
                                dialog.close();
                            });
                        }
                        init(data) {
                            const { mapUrl = "", items = [], } = data;
                            this._container.querySelector("[data-action='select-room']").addEventListener("click", e => {
                                e.stopPropagation();
                                this._event("selected", this._currentSelected);
                            });
                            this._container.querySelector("[data-action='close']").addEventListener("click", e => {
                                this._currentSelected = null;
                                this._unSelectAllLocations();
                            });
                            this._updateDialogMapImage(mapUrl);
                            this._updateTapToEnlargeImage(mapUrl);
                            if (Array.isArray(items) && (items === null || items === void 0 ? void 0 : items.length) > 0) {
                                this._clearAllPolygons();
                                const zoom = d3.zoom()
                                    .extent([[0, 0], [600, 400]])
                                    .scaleExtent([1, 8])
                                    .on("zoom", null)
                                    .on("zoom", (e) => {
                                    var _a, _b;
                                    switch ((_a = e.sourceEvent) === null || _a === void 0 ? void 0 : _a.type) {
                                        case "mousemove": {
                                            this._d3.selectAll("g[data-type='page']").attr("transform", e.transform);
                                            break;
                                        }
                                        case "wheel": {
                                            if ((_b = e.sourceEvent) === null || _b === void 0 ? void 0 : _b.ctrlKey) {
                                                this._d3.selectAll("g[data-type='page']").attr("transform", e.transform);
                                            }
                                            break;
                                        }
                                        default:
                                            this._d3.selectAll("g[data-type='page']").attr("transform", e.transform);
                                    }
                                });
                                this._d3.call(zoom);
                                items.forEach(location => {
                                    const g = this._d3
                                        .select("g[data-type='page']")
                                        .append('g')
                                        .attr("data-id", location.id)
                                        .attr("data-type", "location");
                                    g.append('polygon')
                                        .attr('points', location.points)
                                        .attr('stroke', '#000AFF')
                                        .style('fill', "#000AFF3B")
                                        .on("click", (clickEvent) => {
                                        clickEvent.stopPropagation();
                                        // unselect other rooms
                                        this._unSelectAllLocations();
                                        // select this room
                                        this._selectLocation(clickEvent.target, location);
                                    });
                                });
                            }
                            else {
                                this._clearAllPolygons();
                            }
                        }
                        _updateDialogMapImage(mapUrl) {
                            const imageElement = this._container.querySelector('image');
                            if (imageElement) {
                                if (mapUrl) {
                                    imageElement.href.baseVal = decodeURIComponent(mapUrl);
                                }
                                else {
                                    imageElement.href.baseVal = "";
                                }
                            }
                        }
                        _updateTapToEnlargeImage(mapUrl) {
                            const imgElement = this._container.querySelector("img.ui-vrs-mobile-map-image");
                            if (imgElement) {
                                if (mapUrl) {
                                    imgElement.src = decodeURIComponent(mapUrl);
                                }
                                else {
                                    imgElement.src = "";
                                }
                            }
                        }
                        _clearAllPolygons() {
                            this._d3
                                .select("g[data-type='page']")
                                .selectAll("g[data-type='location']")
                                .remove();
                        }
                        onClick(e) {
                            this._event = e;
                        }
                        _selectLocation(element, location) {
                            element.classList.add("selected");
                            this._displaySelectionInfo(location);
                            this._event("selecting", location);
                            this._currentSelected = location;
                        }
                        _unSelectAllLocations() {
                            this._container.querySelectorAll(".selected").forEach(e => e.classList.remove("selected"));
                            this._infoElement.classList.remove("display");
                            this._toastPopup.classList.add("display");
                            this._currentSelected = undefined;
                        }
                        _displaySelectionInfo(location) {
                            this._infoElement.querySelector("h2").innerText = location.caption;
                            const anchor = this._infoElement.querySelector("a");
                            anchor.href = location.buttonUrl;
                            this._dispatchNextStepEvent(anchor);
                            this._infoElement.classList.add("display");
                            this._toastPopup.classList.remove("display");
                            if (location.heroImage) {
                                this._infoElement.classList.remove("no-image");
                                this._infoElement.querySelector("img")["src"] = decodeURIComponent(location.heroImage);
                                this._infoElement.querySelector("img")["alt"] = location.altText;
                            }
                            else {
                                this._infoElement.classList.add("no-image");
                            }
                            const roomRateInfo = this._infoElement.querySelector(".ui-plan-room-rate");
                            if (roomRateInfo) {
                                const calculateTotalButton = this._infoElement.querySelector(".ui-calculate-total-amount");
                                const calculateTotalLabel = this._infoElement.querySelector(".ui-room-total-amount");
                                if (location.roomRateValue > 0) {
                                    roomRateInfo.innerText = location.roomRateText;
                                    if (calculateTotalButton) {
                                        const calculateTotalData = vrs.roomrateinfo.getCalculateTotalButtonDataAttributes(location.calculateTotalAmountLinkText, location.calculateTotalAriaLabel, location.calculateTotalData);
                                        calculateTotalLabel.classList.add("hidden");
                                        calculateTotalButton.Show();
                                        this.renderCalculateTotalRoomRateButton(calculateTotalData, calculateTotalButton);
                                    }
                                }
                                else {
                                    calculateTotalLabel.classList.add("hidden");
                                    calculateTotalButton.Hide();
                                    roomRateInfo.innerText = "";
                                }
                            }
                        }
                        renderCalculateTotalRoomRateButton(content, button) {
                            button.innerText = content["buttonText"];
                            button.setAttribute("aria-label", content["ariaLabel"]);
                            for (const [key, value] of Object.entries(content)) {
                                if (key !== "buttonText" && key !== "ariaLabel" && value) {
                                    button.setAttribute(`data-${key}`, value.toString());
                                }
                            }
                        }
                        _dispatchNextStepEvent(anchor) {
                            anchor.addEventListener("click", (e) => {
                                e.preventDefault();
                                anchor.dispatchEvent(new CustomEvent(vrs.events.nextStepEvent, {
                                    bubbles: true,
                                    detail: { href: anchor.href }
                                }));
                            });
                        }
                    }
                    mobile.MobileMapLocationSelector = MobileMapLocationSelector;
                    function updateMobileMapSelector(mapSelectorData, showPlanLocationOnPortal, init = false) {
                        const mobileMapSelector = new MobileMapLocationSelector(document.querySelector(".ui-vrs-mobile-map-selector"));
                        init && mobileMapSelector.init(mapSelectorData);
                        toggleMobileMapSelector(showPlanLocationOnPortal && mapSelectorData.mapUrl !== '');
                    }
                    mobile.updateMobileMapSelector = updateMobileMapSelector;
                    function toggleMobileMapSelector(display) {
                        if (display) {
                            document.querySelector(".ui-vrs-mobile-map-selector").Show();
                            document.querySelector('.ui-vrs-mobile-map-selector-alert').Hide();
                        }
                        else {
                            document.querySelector(".ui-vrs-mobile-map-selector").Hide();
                            document.querySelector('.ui-vrs-mobile-map-selector-alert').Show();
                        }
                    }
                })(mobile = mapselector.mobile || (mapselector.mobile = {}));
            })(mapselector = vrs.mapselector || (vrs.mapselector = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.mapselector.mobile.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var overviewpanel;
            (function (overviewpanel) {
                function init(panel) {
                    let readmoreTimeout;
                    const description = panel.querySelector(".ui-description-paragraph");
                    const readmoreButton = panel.querySelector(".ui-description-readmore");
                    if (description) {
                        readmoreButton === null || readmoreButton === void 0 ? void 0 : readmoreButton.addEventListener("click", () => togglePressed());
                        showOnResize();
                    }
                    /** returns true if the total text height is greater than the container height */
                    function isOverflowing() {
                        return description.scrollHeight > description.clientHeight;
                    }
                    /** returns true if the total container height is greater than 8 lines */
                    function isMoreThan8Lines() {
                        const lineHeight = parseInt(document.defaultView.getComputedStyle(description).lineHeight, 10);
                        return description.clientHeight > lineHeight * 8;
                    }
                    /** returns false if closed or not a <details> element*/
                    function notClosed() {
                        return panel.open !== false;
                    }
                    function showOnResize() {
                        const resize = new ResizeObserver((entries) => {
                            if (entries) {
                                clearTimeout(readmoreTimeout);
                                readmoreTimeout = setTimeout(() => showReadMore(), 250);
                            }
                        });
                        resize.observe(description);
                    }
                    function showReadMore() {
                        if (readmoreButton) {
                            if (isOverflowing() || isMoreThan8Lines()) {
                                readmoreButton.classList.remove("hidden");
                            }
                            else if (notClosed()) {
                                readmoreButton.classList.add("hidden");
                            }
                        }
                    }
                    /** if aria-pressed is "true", set it to "false", otherwise set it to "true" */
                    function togglePressed() {
                        const pressed = readmoreButton.getAttribute("aria-pressed") === "true";
                        readmoreButton.setAttribute("aria-pressed", pressed ? "false" : "true");
                    }
                    roomsearch.vrs.roomrateinfo.attachCalculateTotalClickEvent(panel);
                }
                overviewpanel.init = init;
                function initOnRender(panel) {
                    const observer = new MutationObserver(function () {
                        if (document.contains(panel)) {
                            init(panel);
                            observer.disconnect();
                        }
                    });
                    observer.observe(document, { childList: true, subtree: true });
                }
                function render(room, panelTemplate, thumbnailTemplate) {
                    var _a, _b, _c, _d;
                    const panel = panelTemplate.content.cloneNode(true);
                    //set the title
                    const title = panel.querySelector(".ui-overview-title");
                    if (title) {
                        title.innerHTML = room.title;
                    }
                    //set the thumbnails
                    renderThumbnail(room.photoComponent, panel.querySelector(".ui-overview-photo"), thumbnailTemplate);
                    renderThumbnail(room.mapComponent, panel.querySelector(".ui-overview-plan"), thumbnailTemplate);
                    const hasRoomRate = room.showRoomRateValueInResults && room.roomRateValue > 0;
                    const showCalculateTotalAmountLink = room.showCalculateTotalAmountLink && hasRoomRate;
                    //set the text content
                    [
                        [room.description, ".ui-overview-description"],
                        [room.disabledAccess, ".ui-overview-access"],
                        [(_a = room.bedSpacesAvailable) === null || _a === void 0 ? void 0 : _a.toString(), ".ui-overview-bedspaces"],
                        [(_b = room.bedCapacity) === null || _b === void 0 ? void 0 : _b.toString(), ".ui-overview-bedrooms"],
                        [(_c = room.bathrooms) === null || _c === void 0 ? void 0 : _c.toString(), ".ui-overview-bathrooms"],
                        [room.roomType, ".ui-overview-roomtype"],
                        [room.gender, ".ui-overview-gender"],
                        [hasRoomRate && room.roomRateText, ".ui-overview-rate"],
                        [showCalculateTotalAmountLink ? vrs.roomrateinfo.getCalculateTotalButtonDataAttributes(room.calculateTotalAmountLinkText, room.calculateTotalAriaLabel, room.calculateTotalData) : null, ".ui-calculate-total-amount"]
                    ].forEach(([content, selector]) => renderContent(content, panel.querySelector(selector)));
                    //remove empty list
                    !room.bedCapacity && !room.bathrooms && ((_d = panel.querySelector(".ui-overview-details")) === null || _d === void 0 ? void 0 : _d.remove());
                    //set the title and button URL
                    panel.querySelectorAll(".ui-panel-navigate-link").forEach((link) => {
                        link.href = room.buttonUrl;
                        link.addEventListener("click", (e) => {
                            e.preventDefault();
                            dispatchNextStepEvent(link);
                        });
                    });
                    initOnRender(panel.querySelector(".ui-overview-panel"));
                    return panel;
                }
                overviewpanel.render = render;
                /** sets the text content, or removes it if null*/
                function renderContent(content, container) {
                    var _a;
                    if (content && ((_a = container === null || container === void 0 ? void 0 : container.classList) === null || _a === void 0 ? void 0 : _a.contains("ui-calculate-total-amount"))) {
                        renderCalculateTotalRoomRateButton(content, container);
                    }
                    else if (content) {
                        container === null || container === void 0 ? void 0 : container.querySelector("p").prepend(content.toString());
                    }
                    else {
                        container === null || container === void 0 ? void 0 : container.remove();
                    }
                }
                function renderCalculateTotalRoomRateButton(content, container) {
                    container === null || container === void 0 ? void 0 : container.prepend(content["buttonText"]);
                    container === null || container === void 0 ? void 0 : container.setAttribute("aria-label", content["ariaLabel"]);
                    for (const [key, value] of Object.entries(content)) {
                        if (key !== "buttonText" && key !== "ariaLabel" && value) {
                            container === null || container === void 0 ? void 0 : container.setAttribute(`data-${key}`, value.toString());
                        }
                    }
                }
                /** sets the thumbnail, or removes it if null */
                function renderThumbnail(image, container, thumbnailTemplate) {
                    if (image.src && thumbnailTemplate) {
                        container === null || container === void 0 ? void 0 : container.append(portal.locationthumbnailimage.render(image, thumbnailTemplate));
                    }
                    else {
                        container === null || container === void 0 ? void 0 : container.remove();
                    }
                }
                function dispatchNextStepEvent(link) {
                    link.dispatchEvent(new CustomEvent(vrs.events.nextStepEvent, {
                        bubbles: true,
                        detail: {
                            href: link.href
                        }
                    }));
                }
            })(overviewpanel = vrs.overviewpanel || (vrs.overviewpanel = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.overviewpanel.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var pagination;
            (function (pagination) {
                "use strict";
                function getPageSize() {
                    return pagination.paging.pageSize;
                }
                pagination.getPageSize = getPageSize;
                function init(paginingInfo) {
                    pagination.paging = paginingInfo;
                    initPaginationControls();
                }
                pagination.init = init;
                function resetPagination(totalResults) {
                    pagination.paging.currentPageNumber = 1;
                    pagination.paging.totalResults = totalResults;
                    updatePaginationControls();
                }
                pagination.resetPagination = resetPagination;
                function updatePaginationControls() {
                    if (!pagination.paging) {
                        return;
                    }
                    const totalPages = Math.ceil(pagination.paging.totalResults / pagination.paging.pageSize);
                    const paginationControls = document.querySelector('.ui-vrs-pagination-controls');
                    const prevButton = paginationControls === null || paginationControls === void 0 ? void 0 : paginationControls.querySelector('.ui-vrs-previous-button');
                    const nextButton = paginationControls === null || paginationControls === void 0 ? void 0 : paginationControls.querySelector('.ui-vrs-next-button');
                    ;
                    const currentPageSpan = paginationControls === null || paginationControls === void 0 ? void 0 : paginationControls.querySelector('.ui-vrs-currentpage-span');
                    if (currentPageSpan) {
                        currentPageSpan.textContent = `${pagination.paging.currentPageLabel.replace('{CurrentPageNumber}', pagination.paging.currentPageNumber.toString()).replace('{LastPageNumber}', totalPages.toString())}`;
                    }
                    if (prevButton && nextButton) {
                        if (pagination.paging.currentPageNumber === 1) {
                            prevButton["ariaDisabled"] = "true";
                        }
                        else {
                            prevButton["ariaDisabled"] = "false";
                        }
                        if (pagination.paging.currentPageNumber >= totalPages) {
                            nextButton["ariaDisabled"] = "true";
                        }
                        else {
                            nextButton["ariaDisabled"] = "false";
                        }
                    }
                }
                pagination.updatePaginationControls = updatePaginationControls;
                function initPaginationControls() {
                    const paginationControls = document.querySelector('.ui-vrs-pagination-controls');
                    if (paginationControls) {
                        updatePaginationControls();
                        paginationControls.addEventListener('click', (event) => {
                            const element = event.target;
                            if (element.classList.contains('ui-vrs-previous-button')) {
                                goToPreviousPage();
                            }
                            else if (element.classList.contains('ui-vrs-next-button')) {
                                goToNextPage();
                            }
                            ;
                        });
                    }
                }
                pagination.initPaginationControls = initPaginationControls;
                function goToPreviousPage() {
                    if (pagination.paging.currentPageNumber > 1) {
                        pagination.paging.currentPageNumber--;
                        updatePaginationControls();
                        vrs.indexeddb.getChildPanels(pagination.paging).then((panels) => {
                            goToRoomListOnLoad();
                            vrs.roomlist.updateRoomList((panels));
                        });
                    }
                }
                function goToNextPage() {
                    const totalPages = Math.ceil(pagination.paging.totalResults / pagination.paging.pageSize);
                    if (pagination.paging.currentPageNumber < totalPages) {
                        pagination.paging.currentPageNumber++;
                        updatePaginationControls();
                        vrs.indexeddb.getChildPanels(pagination.paging).then((panels) => {
                            goToRoomListOnLoad();
                            vrs.roomlist.updateRoomList(panels);
                        });
                    }
                }
                function goToRoomListOnLoad() {
                    document.addEventListener(vrs.roomlist.loadedEvent, () => {
                        const listContainer = document.getElementById("vrs-list");
                        scrollToRoomList(listContainer);
                        focusOnResult(listContainer);
                    }, { once: true });
                }
                function scrollToRoomList(roomList) {
                    var _a, _b;
                    const headerOffset = (_b = (_a = document.getElementById("main-navigation")) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) !== null && _b !== void 0 ? _b : 0;
                    const padding = 10;
                    window.scrollTo(0, (roomList === null || roomList === void 0 ? void 0 : roomList.getBoundingClientRect().top) + window.scrollY - headerOffset - padding);
                }
                function focusOnResult(roomList) {
                    var _a;
                    const firstItem = ((_a = roomList === null || roomList === void 0 ? void 0 : roomList.querySelector(".ui-overview-panel")) !== null && _a !== void 0 ? _a : roomList === null || roomList === void 0 ? void 0 : roomList.querySelector(".ui-page-information"));
                    firstItem === null || firstItem === void 0 ? void 0 : firstItem.focus();
                }
            })(pagination = vrs.pagination || (vrs.pagination = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.pagination.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var pricingpanel;
            (function (pricingpanel) {
                /** Init functions to Initialise the Pricing Panel. */
                /** Different flavours of Init functions exist based upon the Value of AddingRoomToCartOption */
                function init(container) {
                    attachAddToCartClickEvent(container[0]);
                    attachRemoveFromCartClickEvent(container[0]);
                    attachExecuteEventsClickEvent(container[0]);
                    roomsearch.vrs.roomrateinfo.attachCalculateTotalClickEvent(container[0]);
                }
                pricingpanel.init = init;
                function initAddToCartSingle(container) {
                    attachAddToCartForSingleClickEvent(container[0]);
                    attachRemoveFromCartClickEvent(container[0]);
                    roomsearch.vrs.roomrateinfo.attachCalculateTotalClickEvent(container[0]);
                }
                pricingpanel.initAddToCartSingle = initAddToCartSingle;
                function initAddToCartNone(container) {
                    roomsearch.vrs.roomrateinfo.attachCalculateTotalClickEvent(container[0]);
                }
                pricingpanel.initAddToCartNone = initAddToCartNone;
                /** Calls {@link addToCart()} when the button is clicked. */
                function attachAddToCartClickEvent(pricingPanel) {
                    const button = getAddToCartButton(pricingPanel);
                    button.addEventListener("click", () => {
                        addToCart(button, pricingPanel);
                    });
                }
                /** Makes a server call to Add to Cart, updates the UI if it succeeds. */
                function addToCart(button, container) {
                    // this is legacy caller, to be replaced with `starrez.postRequest()` once it supports area, and addins folder (ie: area is inside of the /General/)
                    const call = new starrez.service.visualroomselection.AddRoomToCart(getAddToCartData(button.dataset));
                    call.Post().done((result) => {
                        if (result.UpdatedRoomBaseIDs.includes(+button.dataset.roombaseid)) {
                            updateCart();
                            button.Hide();
                            container.querySelector(".ui-vrs-room-removed-message").Hide();
                            container.querySelector(".ui-vrs-room-added-message").Show();
                            const removeButton = getRemoveFromCartButton(container);
                            removeButton.removeAttribute('aria-hidden');
                            removeButton.Show();
                            removeButton.focus();
                            const saveAndContinueLink = getContinueLink(container);
                            enableContinueLink(button.dataset.continueurllink, saveAndContinueLink);
                        }
                    });
                }
                /** Calls {@link addToCartSingle()} when the button is clicked. */
                function attachAddToCartForSingleClickEvent(pricingPanel) {
                    const button = getAddToCartButton(pricingPanel);
                    button.addEventListener("click", () => {
                        addToCartSingle(button, pricingPanel);
                    });
                }
                function addToCartSingle(button, container) {
                    // this is legacy caller, to be replaced with `starrez.postRequest()` once it supports area, and addins folder (ie: area is inside of the /General/)
                    const call = new starrez.service.visualroomselection.AddRoomToCart(getAddToCartData(button.dataset), true);
                    call.Post().done((result) => {
                        let continueLink = button.dataset.continueurllink;
                        if (result.UpdatedRoomBaseIDs && continueLink) {
                            window.location.assign(continueLink);
                        }
                    });
                }
                /** Finds the Add To Cart button. */
                function getAddToCartButton(container) {
                    return container.querySelector(".ui-vrs-add-to-cart");
                }
                /** Gets the Add To Cart route data from the dataset provided. */
                function getAddToCartData(data) {
                    return Object.assign(Object.assign(Object.assign(Object.assign({ hash: data.hash, checkInDate: data.checkindate, checkOutDate: data.checkoutdate, pageID: Number(data.pageid), roomRateID: Number(data.roomrateid) }, data.roombaseid && { roomBaseID: Number(data.roombaseid) }), data.roomlocationid && { roomLocationID: Number(data.roomlocationid) }), data.roomtypeid && { roomTypeID: Number(data.roomtypeid) }), data.termid && { termID: Number(data.termid) });
                }
                /** Finds the Remove From Cart button. */
                function getRemoveFromCartButton(container) {
                    return container.querySelector(".ui-vrs-remove-from-cart");
                }
                /** Sets the values shown in the navigation's Shopping Cart. */
                function setCartData(cartButton) {
                    const cartDropdown = cartButton.querySelector(".ui-shopping-cart-dropdown");
                    const cartData = cartDropdown === null || cartDropdown === void 0 ? void 0 : cartDropdown.dataset;
                    if (portal.Feature.PortalxLandmarkRegionChanges) {
                        portal.shoppingcart.initShoppingCart(cartDropdown, {
                            cartExpireMessage: cartData === null || cartData === void 0 ? void 0 : cartData.cartexpiremessage,
                            cartTimerHideText: cartData === null || cartData === void 0 ? void 0 : cartData.carttimerhidetext,
                            cartTimerShowText: cartData === null || cartData === void 0 ? void 0 : cartData.carttimershowtext,
                            holdSeconds: Number(cartData === null || cartData === void 0 ? void 0 : cartData.holdseconds),
                            timerAriaLabelPrefix: cartData === null || cartData === void 0 ? void 0 : cartData.carttimerprefixlabel,
                            timerLimitWarning: cartData === null || cartData === void 0 ? void 0 : cartData.cartholdexpirywarningtext,
                        });
                    }
                }
                /** Updates the navigation's Shopping Cart. */
                function updateCart() {
                    portal.navigation.NavigationBar.UpdateShoppingCart().done((cartButton) => {
                        setCartData(cartButton[0]);
                    });
                }
                /** Calls {@link removeFromCart()} when the button is clicked. */
                function attachRemoveFromCartClickEvent(pricingPanel) {
                    const button = getRemoveFromCartButton(pricingPanel);
                    button.addEventListener("click", () => {
                        removeFromCart(button, pricingPanel);
                    });
                }
                /** Makes a server call to RemoveItemsFromCart, updates the UI if it succeeds. */
                function removeFromCart(button, container) {
                    // this is legacy caller, to be replaced with `starrez.postRequest()` once it supports area, and addins folder (ie: area is inside of the /General/)
                    const call = new starrez.service.visualroomselection.RemoveRoomFromCart(getRemoveFromCartData(button.dataset));
                    call.Post().done((success) => {
                        if (success === true) {
                            updateCart();
                            button.Hide();
                            container.querySelector(".ui-vrs-room-added-message").Hide();
                            container.querySelector(".ui-vrs-room-removed-message").Show();
                            const addToCartButton = getAddToCartButton(container);
                            addToCartButton.removeAttribute('aria-hidden');
                            addToCartButton.Show();
                            addToCartButton.focus();
                            const saveAndContinueLink = getContinueLink(container);
                            disableContinueLink(saveAndContinueLink);
                        }
                    });
                }
                /** Gets the Remove From Cart route data from the dataset provided. */
                function getRemoveFromCartData(data) {
                    return Object.assign(Object.assign(Object.assign(Object.assign({ hash: data.hash, checkInDate: data.checkindate, checkOutDate: data.checkoutdate, pageID: Number(data.pageid), roomRateID: Number(data.roomrateid) }, data.roombaseid && { roomBaseID: Number(data.roombaseid) }), data.roomlocationid && { roomLocationID: Number(data.roomlocationid) }), data.roomtypeid && { roomTypeID: Number(data.roomtypeid) }), data.termid && { termID: Number(data.termid) });
                }
                function attachExecuteEventsClickEvent(container) {
                    const link = container.querySelector("a.ui-vrs-execute-events");
                    vrs.events.init({ eventName: "ExecuteEvents", hash: link.dataset.hash, pageID: portal.page.CurrentPage.PageID });
                    link.addEventListener("click", (event) => {
                        event.preventDefault();
                        dispatchNextEvent(link);
                    });
                }
                function dispatchNextEvent(link) {
                    link.dispatchEvent(new CustomEvent(vrs.events.nextStepEvent, {
                        bubbles: true,
                        detail: { href: link.href }
                    }));
                }
                function getContinueLink(container) {
                    return container.querySelector(".vrs-pricing-panel > a");
                }
                /**
                 * Enables Save and Continue link in Pricing Panel
                 * @param continueUrlLink Url Link
                 * @param saveAndContinueLink Save and Continue anchor element
                 * @returns {void}
                 */
                function enableContinueLink(continueUrlLink, saveAndContinueLink) {
                    saveAndContinueLink.href = continueUrlLink;
                    saveAndContinueLink.removeAttribute('aria-disabled');
                    saveAndContinueLink.removeAttribute('role');
                }
                /**
                 * Disables Save and Continue link in Pricing Panel
                 * @param saveAndContinueLink Save and Continue anchor element
                 * @returns {void}
                 */
                function disableContinueLink(saveAndContinueLink) {
                    saveAndContinueLink.removeAttribute('href'); //removing href attribute creates a placeholder link - https://html.spec.whatwg.org/multipage/links.html#links-created-by-a-and-area-elements
                    saveAndContinueLink.setAttribute('aria-disabled', 'true'); //this announces to AT that link is disabled
                    saveAndContinueLink.setAttribute('role', 'link'); // this explicitly declares the role because after removal of href, implicit role becomes generic
                }
            })(pricingpanel = vrs.pricingpanel || (vrs.pricingpanel = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.pricingpanel.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var roomlist;
            (function (roomlist) {
                let roomList;
                let panelTemplate;
                let thumbnailTemplate;
                let notification;
                let noResultsMessage;
                roomlist.loadedEvent = "roomlist-loaded";
                function init(roomOverviews) {
                    roomList = document.querySelector('.ui-roomlist');
                    panelTemplate = document.getElementById("template-overview-panel");
                    thumbnailTemplate = document.getElementById("template-overview-thumbnail");
                    notification = document.querySelector(".ui-page-information");
                    noResultsMessage = document.getElementById("template-no-results").innerHTML;
                    updateRoomList(roomOverviews);
                }
                roomlist.init = init;
                function updateRoomList(roomSearchResults) {
                    roomList.innerHTML = "";
                    if (roomSearchResults.length) {
                        roomSearchResults.forEach(room => {
                            roomList.append(vrs.overviewpanel.render(room, panelTemplate, thumbnailTemplate));
                        });
                    }
                    else {
                        showNoResults();
                    }
                    roomList.dispatchEvent(new MouseEvent(roomlist.loadedEvent, {
                        view: window,
                        bubbles: true,
                        cancelable: true,
                    }));
                }
                roomlist.updateRoomList = updateRoomList;
                function showNoResults() {
                    const noResults = notification.cloneNode(true);
                    noResults.innerHTML = noResultsMessage;
                    noResults.classList.remove("hidden");
                    roomList.append(noResults);
                }
            })(roomlist = vrs.roomlist || (vrs.roomlist = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.roomlist.js.map
"use strict";
var portal;
(function (portal) {
    var roomsearch;
    (function (roomsearch) {
        var vrs;
        (function (vrs) {
            var roomrateinfo;
            (function (roomrateinfo) {
                class CalculateTotalRoomPrice extends starrez.library.service.AddInActionCallBase {
                    constructor(totalPrice) {
                        super();
                        this.totalPrice = totalPrice;
                        this.Customer = "General";
                        this.Area = "VisualRoomSelection";
                        this.Controller = "visualroomselection";
                        this.Action = "CalculateTotalRoomPrice";
                    }
                    QueryData() {
                        return this.totalPrice;
                    }
                }
                function getCalculateTotalData(data) {
                    return Object.assign(Object.assign(Object.assign(Object.assign({ hash: data.hash, checkInDate: data.checkindate, checkOutDate: data.checkoutdate, pageID: Number(data.pageid), roomRateID: Number(data.roomrateid) }, data.roombaseid && { roomBaseID: Number(data.roombaseid) }), data.roomlocationid && { roomLocationID: Number(data.roomlocationid) }), data.roomtypeid && { roomTypeID: Number(data.roomtypeid) }), data.termid && { termID: Number(data.termid) });
                }
                /** Makes a server call Calculate Total amount for room space, updates the UI if it succeeds. */
                function calculateTotal(button, container) {
                    const call = new CalculateTotalRoomPrice(getCalculateTotalData(button.dataset));
                    call.Post().done((result) => {
                        button.Hide();
                        const calcTotalLabel = container.querySelector(".ui-room-total-amount");
                        calcTotalLabel.setAttribute("aria-hidden", "false");
                        calcTotalLabel.classList.remove("hidden");
                        calcTotalLabel.innerHTML = result;
                    });
                }
                /** Finds the Calculate Total button */
                function getCalculateTotalButton(container) {
                    return container.querySelector(".ui-calculate-total-amount");
                }
                /** Calls {@link calculateTotal()} when the button is clicked. */
                function attachCalculateTotalClickEvent(pricingPanel) {
                    const button = getCalculateTotalButton(pricingPanel);
                    button === null || button === void 0 ? void 0 : button.addEventListener("click", () => {
                        calculateTotal(button, pricingPanel);
                    });
                }
                roomrateinfo.attachCalculateTotalClickEvent = attachCalculateTotalClickEvent;
                function getCalculateTotalButtonDataAttributes(buttonText, ariaLabel, attributes) {
                    return {
                        ariaLabel,
                        buttonText,
                        checkInDate: attributes.checkInDate,
                        checkOutDate: attributes.checkOutDate,
                        hash: attributes.hash,
                        pageID: attributes.pageID,
                        roomRateID: attributes.roomRateID,
                        roomTypeID: attributes.roomTypeID,
                        roomBaseID: attributes.roomBaseID,
                        termID: attributes.termID,
                        action: attributes.action,
                        controller: attributes.controller,
                        roomLocationID: attributes.roomLocationID
                    };
                }
                roomrateinfo.getCalculateTotalButtonDataAttributes = getCalculateTotalButtonDataAttributes;
            })(roomrateinfo = vrs.roomrateinfo || (vrs.roomrateinfo = {}));
        })(vrs = roomsearch.vrs || (roomsearch.vrs = {}));
    })(roomsearch = portal.roomsearch || (portal.roomsearch = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.roomsearch.vrs.roomrateinfo.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN

    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function AssignBedStepModel($sys) {
            return {
                AssignedBeds: ($sys.data('assignedbeds') === '') ? [] : ($sys.data('assignedbeds')).toString().split(','),
                AutoComplete: starrez.library.convert.ToBoolean($sys.data('autocomplete')),
                RoomBaseIDs: ($sys.data('roombaseids') === '') ? [] : ($sys.data('roombaseids')).toString().split(',').map(function (e) { return Number(e); }),
                RoomImageUrls: ($sys.data('roomimageurls') === '') ? [] : ($sys.data('roomimageurls')).toString().split(','),
                RoomSelectionPageID: Number($sys.data('roomselectionpageid')),
                TakenByNewInvitationMessage: $sys.data('takenbynewinvitationmessage'),
            };
        }
        model.AssignBedStepModel = AssignBedStepModel;
        function InitialFilterStepModel($sys) {
            return {
                ClassificationID: $sys.data('classificationid'),
                CurrencySymbol: $sys.data('currencysymbol'),
                GroupID: $sys.data('groupid'),
                InitialFilterOption: $sys.data('initialfilteroption'),
                MaximumRoomRateFilterValue: Number($sys.data('maximumroomratefiltervalue')),
                MinimumRoomRateFilterValue: Number($sys.data('minimumroomratefiltervalue')),
                RoomSelectionPageID: Number($sys.data('roomselectionpageid')),
                RoomSelectionPropertyName: $sys.data('roomselectionpropertyname'),
                TermID: $sys.data('termid'),
            };
        }
        model.InitialFilterStepModel = InitialFilterStepModel;
        function MainFilterStepModel($sys) {
            return {
                ActualAddingRoomToCartOption: $sys.data('actualaddingroomtocartoption'),
                CanAddRoomsToCart: starrez.library.convert.ToBoolean($sys.data('canaddroomstocart')),
                ClassificationID: $sys.data('classificationid'),
                CurrencySymbol: $sys.data('currencysymbol'),
                CurrentPageNumber: Number($sys.data('currentpagenumber')),
                FilterData: $sys.data('filterdata'),
                FilterResultsHash: $sys.data('filterresultshash'),
                FixPortalXRoomSelectionSessionDeletionIssue: starrez.library.convert.ToBoolean($sys.data('fixportalxroomselectionsessiondeletionissue')),
                GroupID: $sys.data('groupid'),
                IsAuthenticated: starrez.library.convert.ToBoolean($sys.data('isauthenticated')),
                LowerRoomRateValue: Number($sys.data('lowerroomratevalue')),
                MaximumRoomRateFilterAriaLabel: $sys.data('maximumroomratefilterarialabel'),
                MaximumRoomRateFilterValue: Number($sys.data('maximumroomratefiltervalue')),
                MinimumRoomRateFilterAriaLabel: $sys.data('minimumroomratefilterarialabel'),
                MinimumRoomRateFilterValue: Number($sys.data('minimumroomratefiltervalue')),
                MustSelectRoomMessage: $sys.data('mustselectroommessage'),
                RoomBaseIDs: ($sys.data('roombaseids') === '') ? [] : ($sys.data('roombaseids')).toString().split(',').map(function (e) { return Number(e); }),
                RoomRateID: Number($sys.data('roomrateid')),
                RoomSelectionPageID: Number($sys.data('roomselectionpageid')),
                ShowFiltersWithoutRooms: starrez.library.convert.ToBoolean($sys.data('showfilterswithoutrooms')),
                TermID: $sys.data('termid'),
                UpperRoomRateValue: Number($sys.data('upperroomratevalue')),
                UseRoommateClassifications: starrez.library.convert.ToBoolean($sys.data('useroommateclassifications')),
            };
        }
        model.MainFilterStepModel = MainFilterStepModel;
        function RoomSearchStepBaseModel($sys) {
            return {
                DateEnd: moment($sys.data('dateend')).toDate(),
                DateStart: moment($sys.data('datestart')).toDate(),
            };
        }
        model.RoomSearchStepBaseModel = RoomSearchStepBaseModel;
        function RoomSelectionModel($sys) {
            return {
                CurrencySymbol: $sys.data('currencysymbol'),
                DateEnd: moment($sys.data('dateend')).toDate(),
                DateStart: moment($sys.data('datestart')).toDate(),
                DifferentUnitsSelectedMessage: $sys.data('differentunitsselectedmessage'),
                LowerRoomRateValue: Number($sys.data('lowerroomratevalue')),
                MaximumRoomRateFilterAriaLabel: $sys.data('maximumroomratefilterarialabel'),
                MaximumRoomRateFilterValue: Number($sys.data('maximumroomratefiltervalue')),
                MinimumRoomRateFilterAriaLabel: $sys.data('minimumroomratefilterarialabel'),
                MinimumRoomRateFilterValue: Number($sys.data('minimumroomratefiltervalue')),
                ProfileItemID: ($sys.data('profileitemid') === '') ? [] : ($sys.data('profileitemid')).toString().split(',').map(function (e) { return Number(e); }),
                RoomBaseIDs: ($sys.data('roombaseids') === '') ? [] : ($sys.data('roombaseids')).toString().split(',').map(function (e) { return Number(e); }),
                RoomLocationAreaID: ($sys.data('roomlocationareaid') === '') ? [] : ($sys.data('roomlocationareaid')).toString().split(',').map(function (e) { return Number(e); }),
                RoomLocationFloorSuiteID: ($sys.data('roomlocationfloorsuiteid') === '') ? [] : ($sys.data('roomlocationfloorsuiteid')).toString().split(',').map(function (e) { return Number(e); }),
                RoomLocationID: ($sys.data('roomlocationid') === '') ? [] : ($sys.data('roomlocationid')).toString().split(',').map(function (e) { return Number(e); }),
                RoomTypeID: ($sys.data('roomtypeid') === '') ? [] : ($sys.data('roomtypeid')).toString().split(',').map(function (e) { return Number(e); }),
                UpperRoomRateValue: Number($sys.data('upperroomratevalue')),
            };
        }
        model.RoomSelectionModel = RoomSelectionModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var roomsearch;
        (function (roomsearch) {
            "use strict";
            class AddRoomToCart extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "AddRoomToCart";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        checkInDate: this.o.checkInDate,
                        checkOutDate: this.o.checkOutDate,
                        pageID: this.o.pageID,
                        roomBaseID: this.o.roomBaseID,
                        roomRateID: this.o.roomRateID,
                    };
                    return obj;
                }
            }
            roomsearch.AddRoomToCart = AddRoomToCart;
            class AddRoomToCartForGroup extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "AddRoomToCartForGroup";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        checkInDate: this.o.checkInDate,
                        checkOutDate: this.o.checkOutDate,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                        roomBaseID: this.o.roomBaseID,
                        roomRateID: this.o.roomRateID,
                    };
                    return obj;
                }
            }
            roomsearch.AddRoomToCartForGroup = AddRoomToCartForGroup;
            class AddRoomToCartForTerm extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "AddRoomToCartForTerm";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        checkInDate: this.o.checkInDate,
                        checkOutDate: this.o.checkOutDate,
                        pageID: this.o.pageID,
                        roomBaseID: this.o.roomBaseID,
                        roomRateID: this.o.roomRateID,
                        termID: this.o.termID,
                    };
                    return obj;
                }
            }
            roomsearch.AddRoomToCartForTerm = AddRoomToCartForTerm;
            class AddRoomTypeLocationToCart extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "AddRoomTypeLocationToCart";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        checkInDate: this.o.checkInDate,
                        checkOutDate: this.o.checkOutDate,
                        pageID: this.o.pageID,
                        roomLocationID: this.o.roomLocationID,
                        roomRateID: this.o.roomRateID,
                        roomTypeID: this.o.roomTypeID,
                    };
                    return obj;
                }
            }
            roomsearch.AddRoomTypeLocationToCart = AddRoomTypeLocationToCart;
            class AddRoomTypeLocationToCartForGroup extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "AddRoomTypeLocationToCartForGroup";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        checkInDate: this.o.checkInDate,
                        checkOutDate: this.o.checkOutDate,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                        roomLocationID: this.o.roomLocationID,
                        roomRateID: this.o.roomRateID,
                        roomTypeID: this.o.roomTypeID,
                    };
                    return obj;
                }
            }
            roomsearch.AddRoomTypeLocationToCartForGroup = AddRoomTypeLocationToCartForGroup;
            class AddRoomTypeLocationToCartForTerm extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "AddRoomTypeLocationToCartForTerm";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        checkInDate: this.o.checkInDate,
                        checkOutDate: this.o.checkOutDate,
                        pageID: this.o.pageID,
                        roomLocationID: this.o.roomLocationID,
                        roomRateID: this.o.roomRateID,
                        roomTypeID: this.o.roomTypeID,
                        termID: this.o.termID,
                    };
                    return obj;
                }
            }
            roomsearch.AddRoomTypeLocationToCartForTerm = AddRoomTypeLocationToCartForTerm;
            class AssignBeds extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "AssignBeds";
                }
                CallData() {
                    var obj = {
                        assignments: this.o.assignments,
                        newInvitations: this.o.newInvitations,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        checkInDate: this.o.checkInDate,
                        checkOutDate: this.o.checkOutDate,
                        pageID: this.o.pageID,
                        roomBaseIDs: this.o.roomBaseIDs,
                    };
                    return obj;
                }
            }
            roomsearch.AssignBeds = AssignBeds;
            class CalculateTotalRoomPrice extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "CalculateTotalRoomPrice";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        checkInDate: this.o.checkInDate,
                        checkOutDate: this.o.checkOutDate,
                        pageID: this.o.pageID,
                        roomBaseID: this.o.roomBaseID,
                        roomRateID: this.o.roomRateID,
                    };
                    return obj;
                }
            }
            roomsearch.CalculateTotalRoomPrice = CalculateTotalRoomPrice;
            class CalculateTotalRoomTypeLocationPrice extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "CalculateTotalRoomTypeLocationPrice";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        checkInDate: this.o.checkInDate,
                        checkOutDate: this.o.checkOutDate,
                        pageID: this.o.pageID,
                        roomLocationID: this.o.roomLocationID,
                        roomRateID: this.o.roomRateID,
                        roomTypeID: this.o.roomTypeID,
                    };
                    return obj;
                }
            }
            roomsearch.CalculateTotalRoomTypeLocationPrice = CalculateTotalRoomTypeLocationPrice;
            class GetFilterResults extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "GetFilterResults";
                }
                CallData() {
                    var obj = {
                        classificationID: this.o.classificationID,
                        currentPageNumber: this.o.currentPageNumber,
                        filters: this.o.filters,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                        termID: this.o.termID,
                    };
                    return obj;
                }
            }
            roomsearch.GetFilterResults = GetFilterResults;
            class GetFilterResultsAuthenticated extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "GetFilterResultsAuthenticated";
                }
                CallData() {
                    var obj = {
                        classificationID: this.o.classificationID,
                        currentPageNumber: this.o.currentPageNumber,
                        filters: this.o.filters,
                        groupID: this.o.groupID,
                        termID: this.o.termID,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            roomsearch.GetFilterResultsAuthenticated = GetFilterResultsAuthenticated;
            class GetFilterResultsUnauthenticated extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "GetFilterResultsUnauthenticated";
                }
                CallData() {
                    var obj = {
                        classificationID: this.o.classificationID,
                        currentPageNumber: this.o.currentPageNumber,
                        filters: this.o.filters,
                        groupID: this.o.groupID,
                        termID: this.o.termID,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            roomsearch.GetFilterResultsUnauthenticated = GetFilterResultsUnauthenticated;
            class GetInitialFilterStepResults extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "GetInitialFilterStepResults";
                }
                CallData() {
                    var obj = {
                        classificationID: this.o.classificationID,
                        dateEnd: this.o.dateEnd,
                        dateStart: this.o.dateStart,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                        termID: this.o.termID,
                    };
                    return obj;
                }
            }
            roomsearch.GetInitialFilterStepResults = GetInitialFilterStepResults;
            class GetSuggestions extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "GetSuggestions";
                }
                CallData() {
                    var obj = {
                        classificationID: this.o.classificationID,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                        roomSearchGuid: this.o.roomSearchGuid,
                        suggestions: this.o.suggestions,
                        termID: this.o.termID,
                    };
                    return obj;
                }
            }
            roomsearch.GetSuggestions = GetSuggestions;
            class GetTermCardContent extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "GetTermCardContent";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        tableID: this.o.tableID,
                    };
                    return obj;
                }
            }
            roomsearch.GetTermCardContent = GetTermCardContent;
            class RemoveRoomFromCart extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "RemoveRoomFromCart";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                        roomBaseID: this.o.roomBaseID,
                    };
                    return obj;
                }
            }
            roomsearch.RemoveRoomFromCart = RemoveRoomFromCart;
            class RenewRoom extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "RenewRoom";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roomsearch.RenewRoom = RenewRoom;
            class Restart extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "Restart";
                }
                CallData() {
                    var obj = {
                        classificationID: this.o.classificationID,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                        termID: this.o.termID,
                    };
                    return obj;
                }
            }
            roomsearch.Restart = Restart;
            class UpdateFilterData extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "UpdateFilterData";
                }
                CallData() {
                    var obj = {
                        classificationID: this.o.classificationID,
                        filters: this.o.filters,
                        groupID: this.o.groupID,
                        pageID: this.o.pageID,
                        termID: this.o.termID,
                    };
                    return obj;
                }
            }
            roomsearch.UpdateFilterData = UpdateFilterData;
            class UpdateProcessContext extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "UpdateProcessContext";
                }
                CallData() {
                    var obj = {
                        currentPageNumber: this.o.currentPageNumber,
                        filters: this.o.filters,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            roomsearch.UpdateProcessContext = UpdateProcessContext;
            class ValidateNumberOfRoomSpacesForSingleRoom extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "ValidateNumberOfRoomSpacesForSingleRoom";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        roomBaseID: this.o.roomBaseID,
                    };
                    return obj;
                }
            }
            roomsearch.ValidateNumberOfRoomSpacesForSingleRoom = ValidateNumberOfRoomSpacesForSingleRoom;
            class ValidateNumberOfRoomSpacesSelected extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSearch";
                    this.Controller = "roomsearch";
                    this.Action = "ValidateNumberOfRoomSpacesSelected";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                    };
                    return obj;
                }
            }
            roomsearch.ValidateNumberOfRoomSpacesSelected = ValidateNumberOfRoomSpacesSelected;
        })(roomsearch = service.roomsearch || (service.roomsearch = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var visualroomselection;
        (function (visualroomselection) {
            "use strict";
            class AddRoomToCart extends starrez.library.service.AddInActionCallBase {
                constructor(o, autoNavigateToNextPage = false) {
                    super();
                    this.o = o;
                    this.autoNavigateToNextPage = autoNavigateToNextPage;
                    this.Customer = "General";
                    this.Area = "VisualRoomSelection";
                    this.Controller = "visualroomselection";
                    this.Action = "AddRoomToCart";
                }
                CallData() {
                    var obj = {
                        autoNavigateToNextPage: this.autoNavigateToNextPage
                    };
                    return obj;
                }
                QueryData() {
                    var obj = Object.assign(Object.assign(Object.assign(Object.assign({ hash: this.o.hash, checkInDate: this.o.checkInDate, checkOutDate: this.o.checkOutDate, pageID: this.o.pageID, roomRateID: this.o.roomRateID }, this.o.roomBaseID && { roomBaseID: this.o.roomBaseID }), this.o.roomLocationID && { roomLocationID: this.o.roomLocationID }), this.o.roomTypeID && { roomTypeID: this.o.roomTypeID }), this.o.termID && { termID: this.o.termID });
                    return obj;
                }
            }
            visualroomselection.AddRoomToCart = AddRoomToCart;
            class AssignBeds extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "VisualRoomSelection";
                    this.Controller = "visualroomselection";
                    this.Action = "AssignBeds";
                }
                CallData() {
                    var obj = {
                        assignments: this.o.assignments,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        checkInDate: this.o.checkInDate,
                        checkOutDate: this.o.checkOutDate,
                        pageID: this.o.pageID,
                        roomBaseIDs: this.o.roomBaseIDs,
                    };
                    return obj;
                }
            }
            visualroomselection.AssignBeds = AssignBeds;
            class RemoveRoomFromCart extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "VisualRoomSelection";
                    this.Controller = "visualroomselection";
                    this.Action = "RemoveItemsFromCart";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = Object.assign(Object.assign(Object.assign(Object.assign({ hash: this.o.hash, checkInDate: this.o.checkInDate, checkOutDate: this.o.checkOutDate, pageID: this.o.pageID, roomRateID: this.o.roomRateID }, this.o.roomBaseID && { roomBaseID: this.o.roomBaseID }), this.o.roomLocationID && { roomLocationID: this.o.roomLocationID }), this.o.roomTypeID && { roomTypeID: this.o.roomTypeID }), this.o.termID && { termID: this.o.termID });
                    return obj;
                }
            }
            visualroomselection.RemoveRoomFromCart = RemoveRoomFromCart;
        })(visualroomselection = service.visualroomselection || (service.visualroomselection = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var roomswap;
        (function (roomswap) {
            var roomswapmanagement;
            (function (roomswapmanagement) {
                "use strict";
                let RoomSwapActionType;
                (function (RoomSwapActionType) {
                    RoomSwapActionType[RoomSwapActionType["None"] = 0] = "None";
                    RoomSwapActionType[RoomSwapActionType["sendRoomSwapRequest"] = 1] = "sendRoomSwapRequest";
                    RoomSwapActionType[RoomSwapActionType["cancelRoomSwapRequest"] = 2] = "cancelRoomSwapRequest";
                    RoomSwapActionType[RoomSwapActionType["acceptRoomSwapRequest"] = 3] = "acceptRoomSwapRequest";
                    RoomSwapActionType[RoomSwapActionType["declineRoomSwapRequest"] = 4] = "declineRoomSwapRequest";
                })(RoomSwapActionType = roomswapmanagement.RoomSwapActionType || (roomswapmanagement.RoomSwapActionType = {}));
                ;
                function Initialise($container) {
                    new ResourceManagement($container);
                }
                roomswapmanagement.Initialise = Initialise;
                class ResourceManagement {
                    constructor($container) {
                        this.$container = $container;
                        this.pageID = portal.page.CurrentPage.PageID;
                        this.model = starrez.model.RoomSwapManagementModel($container);
                        this.AttachEvents();
                        this.$container.find(".ui-preference-icon").tooltip();
                        this.$container.find(".ui-disabled").tooltip();
                        portal.actionpanel.control.AutoAdjustActionPanelHeights(this.$container);
                    }
                    AttachEvents() {
                        this.SetupActionRoomSwapRequestEvents();
                    }
                    ActionRoomSwap(roomSwapAction, $currentTarget, $button) {
                        var $actionPanel = $currentTarget.closest(".ui-card-result");
                        portal.ConfirmAction($button.data("confirmationtext"), $button.data("confirmationtitle")).done(() => {
                            var call = new starrez.service.roomswap.ActionRoomSwapRequest({
                                roomSpaceSwapRequestID: Number($actionPanel.data("roomspaceswapid")),
                                theirBookingID: Number($actionPanel.data("their_bookingid")),
                                roomSwapActionType: RoomSwapActionType[roomSwapAction], // Need to pass it in like this to force the string value to be used.
                                hash: $button.data("hash"),
                                pageID: this.pageID,
                                myBookingID: this.model.My_BookingID
                            }).Post().done((url) => {
                                location.href = url;
                            });
                        });
                    }
                    SetupActionRoomSwapRequestEvents() {
                        this.$container.find(".ui-accept-request").SRClick((e) => {
                            var $currentTarget = $(e.currentTarget);
                            var $button = $currentTarget.closest(".ui-accept-request");
                            this.ActionRoomSwap(RoomSwapActionType.acceptRoomSwapRequest, $currentTarget, $button);
                        });
                        this.$container.find(".ui-decline-request").SRClick((e) => {
                            var $currentTarget = $(e.currentTarget);
                            var $button = $currentTarget.closest(".ui-decline-request");
                            this.ActionRoomSwap(RoomSwapActionType.declineRoomSwapRequest, $currentTarget, $button);
                        });
                        this.$container.find(".ui-cancel-request").SRClick((e) => {
                            var $currentTarget = $(e.currentTarget);
                            var $button = $currentTarget.closest(".ui-cancel-request");
                            this.ActionRoomSwap(RoomSwapActionType.cancelRoomSwapRequest, $currentTarget, $button);
                        });
                        this.$container.find(".ui-book-request").SRClick((e) => {
                            var $currentTarget = $(e.currentTarget);
                            var $button = $currentTarget.closest(".ui-book-request");
                            location.href = $button.data("href");
                        });
                    }
                }
            })(roomswapmanagement = roomswap.roomswapmanagement || (roomswap.roomswapmanagement = {}));
        })(roomswap = general.roomswap || (general.roomswap = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.roomswap.roomswapmanagement.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var roomswap;
        (function (roomswap) {
            var roomswapsearch;
            (function (roomswapsearch) {
                "use strict";
                var isDefined = starrez.library.utils.IsNotNullUndefined;
                function InitRoomSwapSearchPage($container) {
                    roomswapsearch.Model = new RoomSwapSearchModel($container);
                }
                roomswapsearch.InitRoomSwapSearchPage = InitRoomSwapSearchPage;
                let MatchTypes;
                (function (MatchTypes) {
                    MatchTypes[MatchTypes["Predefined"] = 0] = "Predefined";
                    MatchTypes[MatchTypes["Custom"] = 1] = "Custom";
                })(MatchTypes || (MatchTypes = {}));
                let Preferences;
                (function (Preferences) {
                    Preferences[Preferences["Mine"] = 0] = "Mine";
                    Preferences[Preferences["Theirs"] = 1] = "Theirs";
                })(Preferences || (Preferences = {}));
                class RoomSwapSearchModel {
                    constructor($container) {
                        this.$container = $container;
                        this.$resultsContainer = this.$container.find(".ui-room-swap-search-results");
                        this.$locationFilters = $container.find(".ui-location-filters");
                        this.$typeFilters = $container.find(".ui-type-filters");
                        this.$myPreference = $container.GetControl("MyPreference");
                        this.$theirPreference = $container.GetControl("TheirPreference");
                        this.pageID = portal.page.CurrentPage.PageID;
                        this.model = starrez.model.RoomSwapSearchModel($container);
                        if (Number(MatchTypes[this.model.MyRequirementsFilterMatch]) === MatchTypes.Custom) {
                            this.$myPreference.SRVal(MatchTypes[this.model.MyRequirementsFilterMatch]);
                            this.SetGroupValues(this.model.MyRoomLocationIDs, this.model.MyRoomTypeIDs, Preferences.Mine);
                        }
                        if (Number(MatchTypes[this.model.TheirRequirementsFilterMatch]) === MatchTypes.Custom) {
                            this.$theirPreference.SRVal(MatchTypes[this.model.TheirRequirementsFilterMatch]);
                            this.SetGroupValues(this.model.TheirRoomLocationIDs, this.model.TheirRoomTypeIDs, Preferences.Theirs);
                        }
                        this.CheckFilters(this.$myPreference, Preferences.Mine);
                        this.CheckFilters(this.$theirPreference, Preferences.Theirs);
                        if (this.model.CurrentPageNumber <= 0) {
                            this.model.CurrentPageNumber = 1;
                        }
                        this.LoadResults(this.model.CurrentPageNumber);
                        this.AttachEvents();
                    }
                    ReloadResults() {
                        this.LoadResults(1); // load from the first page
                    }
                    LoadResults(currentPageNumber) {
                        this.currentPageNumber = currentPageNumber;
                        var location = this.GetGroupIDArray(this.$locationFilters);
                        var type = this.GetGroupIDArray(this.$typeFilters);
                        var myFilters = this.GetFiltersValue(this.$myPreference, location.Mine, type.Mine);
                        var theirFilters = this.GetFiltersValue(this.$theirPreference, location.Theirs, type.Theirs);
                        new starrez.service.roomswap.GetFilterResults({
                            pageID: this.pageID,
                            pageDetailID: this.model.DetailsPageID,
                            myBookingID: this.model.My_BookingID,
                            myRequirementFilters: myFilters,
                            theirRequirementFilters: theirFilters,
                            currentPageNumber: this.currentPageNumber
                        }).Post().done((result) => {
                            this.$resultsContainer.html(result);
                            portal.paging.AttachPagingClickEvent(this, this.$resultsContainer, this.LoadResults);
                            this.$resultsContainer.find(".ui-preference-icon").tooltip();
                            this.SetupRequestSwapAction();
                            portal.actionpanel.control.AutoAdjustActionPanelHeights(this.$container);
                        });
                    }
                    GetFiltersValue($dropdown, location, type) {
                        return {
                            FilterMatch: $dropdown.SRVal(),
                            LocationIDs: location,
                            RoomTypeIDs: type
                        };
                    }
                    GetGroupIDArray($group) {
                        var result = {
                            Mine: [],
                            Theirs: []
                        };
                        $group.each((item, elem) => {
                            var $elem = $(elem);
                            var value = $elem.data("item-id");
                            var isMine = starrez.library.convert.ToBoolean($elem.GetControl("Mine").SRVal());
                            var isTheres = starrez.library.convert.ToBoolean($elem.GetControl("Theirs").SRVal());
                            if (isMine) {
                                result.Mine.push(value);
                            }
                            if (isTheres) {
                                result.Theirs.push(value);
                            }
                        });
                        return result;
                    }
                    SetGroupValues(locationIDs, typeIDs, preferences) {
                        if (isDefined(locationIDs)) {
                            $.each(locationIDs, (index, item) => {
                                this.$locationFilters
                                    .siblings("[data-item-id='" + item + "']")
                                    .GetControl(Preferences[preferences])
                                    .SRVal(true);
                            });
                        }
                        if (isDefined(typeIDs)) {
                            $.each(typeIDs, (index, item) => {
                                this.$typeFilters
                                    .siblings("[data-item-id='" + item + "']")
                                    .GetControl(Preferences[preferences])
                                    .SRVal(true);
                            });
                        }
                    }
                    CheckFilters($dropdown, preferences) {
                        var matchType = Number($dropdown.SRVal());
                        var loopAndEnable = ($group, enable, controlName) => {
                            $group.each((i, elem) => {
                                var $control = $(elem).GetControl(controlName);
                                if (enable) {
                                    $control.Enable();
                                    $control.find('.ui-checkbox-controls-container').Enable();
                                }
                                else {
                                    $control.Disable();
                                    $control.find('.ui-checkbox-controls-container').Disable();
                                }
                                $control.SRVal(false);
                            });
                        };
                        var enableDisable = false;
                        if (matchType === MatchTypes.Custom) {
                            enableDisable = true;
                        }
                        else {
                            enableDisable = false;
                        }
                        var mineTheirs = "";
                        if (preferences === Preferences.Mine) {
                            mineTheirs = "Mine";
                        }
                        else {
                            mineTheirs = "Theirs";
                        }
                        loopAndEnable(this.$locationFilters, enableDisable, mineTheirs);
                        loopAndEnable(this.$typeFilters, enableDisable, mineTheirs);
                    }
                    SetupRequestSwapAction() {
                        this.$container.find(".ui-request-swap").SRClick((e) => {
                            var $button = $(e.currentTarget);
                            var $result = $button.closest(".ui-card-result");
                            portal.ConfirmAction($button.data("confirmationtext"), $button.data("confirmationtitle")).done(() => {
                                var call = new starrez.service.roomswap.RequestSwap({
                                    myBookingID: this.model.My_BookingID,
                                    theirEntryID: Number($result.data("theirentryid")),
                                    theirBookingID: Number($result.data("theirbookingid")),
                                    pageID: this.pageID,
                                    hash: $button.data("hash")
                                });
                                call.Post().done((url) => {
                                    location.href = url;
                                });
                            });
                        });
                    }
                    AttachEvents() {
                        this.$locationFilters.GetControl(Preferences[Preferences.Mine]).SRClick(e => {
                            this.ReloadResults();
                        });
                        this.$locationFilters.GetControl(Preferences[Preferences.Theirs]).SRClick(e => {
                            this.ReloadResults();
                        });
                        this.$typeFilters.GetControl(Preferences[Preferences.Mine]).SRClick(e => {
                            this.ReloadResults();
                        });
                        this.$typeFilters.GetControl(Preferences[Preferences.Theirs]).SRClick(e => {
                            this.ReloadResults();
                        });
                        //dropdowns
                        this.$myPreference.change(e => {
                            this.CheckFilters(this.$myPreference, Preferences.Mine);
                            this.ReloadResults();
                        });
                        this.$theirPreference.change(e => {
                            this.CheckFilters(this.$theirPreference, Preferences.Theirs);
                            this.ReloadResults();
                        });
                        portal.mobile.SetupExpandAndCollapse(this.$container);
                    }
                }
                ;
            })(roomswapsearch = roomswap.roomswapsearch || (roomswap.roomswapsearch = {}));
        })(roomswap = general.roomswap || (general.roomswap = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.roomswap.roomswapsearch.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function RoomSwapManagementModel($sys) {
            return {
                My_BookingID: Number($sys.data('my_bookingid')),
            };
        }
        model.RoomSwapManagementModel = RoomSwapManagementModel;
        function RoomSwapSearchModel($sys) {
            return {
                ConfirmRoomSwapRequestText: $sys.data('confirmroomswaprequesttext'),
                ConfirmRoomSwapRequestTitle: $sys.data('confirmroomswaprequesttitle'),
                CurrentPageNumber: Number($sys.data('currentpagenumber')),
                DetailsPageID: Number($sys.data('detailspageid')),
                My_BookingID: Number($sys.data('my_bookingid')),
                MyRequirementsFilterMatch: $sys.data('myrequirementsfiltermatch'),
                MyRoomLocationIDs: ($sys.data('myroomlocationids') === '') ? [] : ($sys.data('myroomlocationids')).toString().split(',').map(function (e) { return Number(e); }),
                MyRoomTypeIDs: ($sys.data('myroomtypeids') === '') ? [] : ($sys.data('myroomtypeids')).toString().split(',').map(function (e) { return Number(e); }),
                TheirRequirementsFilterMatch: $sys.data('theirrequirementsfiltermatch'),
                TheirRoomLocationIDs: ($sys.data('theirroomlocationids') === '') ? [] : ($sys.data('theirroomlocationids')).toString().split(',').map(function (e) { return Number(e); }),
                TheirRoomTypeIDs: ($sys.data('theirroomtypeids') === '') ? [] : ($sys.data('theirroomtypeids')).toString().split(',').map(function (e) { return Number(e); }),
            };
        }
        model.RoomSwapSearchModel = RoomSwapSearchModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var roomswap;
        (function (roomswap) {
            "use strict";
            class ActionRoomSwapRequest extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSwap";
                    this.Controller = "roomswap";
                    this.Action = "ActionRoomSwapRequest";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        myBookingID: this.o.myBookingID,
                        pageID: this.o.pageID,
                        roomSpaceSwapRequestID: this.o.roomSpaceSwapRequestID,
                        roomSwapActionType: this.o.roomSwapActionType,
                        theirBookingID: this.o.theirBookingID,
                    };
                    return obj;
                }
            }
            roomswap.ActionRoomSwapRequest = ActionRoomSwapRequest;
            class GetFilterResults extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSwap";
                    this.Controller = "roomswap";
                    this.Action = "GetFilterResults";
                }
                CallData() {
                    var obj = {
                        currentPageNumber: this.o.currentPageNumber,
                        myBookingID: this.o.myBookingID,
                        myRequirementFilters: this.o.myRequirementFilters,
                        pageDetailID: this.o.pageDetailID,
                        pageID: this.o.pageID,
                        theirRequirementFilters: this.o.theirRequirementFilters,
                    };
                    return obj;
                }
            }
            roomswap.GetFilterResults = GetFilterResults;
            class RequestSwap extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "RoomSwap";
                    this.Controller = "roomswap";
                    this.Action = "RequestSwap";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        myBookingID: this.o.myBookingID,
                        pageID: this.o.pageID,
                        theirBookingID: this.o.theirBookingID,
                        theirEntryID: this.o.theirEntryID,
                    };
                    return obj;
                }
            }
            roomswap.RequestSwap = RequestSwap;
        })(roomswap = service.roomswap || (service.roomswap = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var general;
    (function (general) {
        var products;
        (function (products) {
            "use strict";
            function InitProductDetails($container) {
                new ProductDetailsManager($container);
            }
            products.InitProductDetails = InitProductDetails;
            class ProductDetailsManager {
                constructor($container) {
                    this.$container = $container;
                    this.shoppingCartItemID = starrez.model.ProductDetailsModel(this.$container).ShoppingCartItemID;
                    this.$totalAmount = this.$container.find(".ui-quantity-total");
                    this.$qtyControl = this.$container.GetControl("SelectedQuantity");
                    this.getTotalAmountHash = this.$qtyControl.closest("li").data("hash").toString();
                    this.$qtyControl.on("change", (e) => {
                        var qty = Number(this.$qtyControl.SRVal());
                        var call = new starrez.service.shoppingcart.GetTotalAmount({
                            pageID: portal.page.CurrentPage.PageID,
                            shoppingCartItemID: this.shoppingCartItemID,
                            quantity: qty,
                            hash: this.getTotalAmountHash
                        });
                        call.Post().done((amount) => {
                            this.$totalAmount.text(amount);
                        });
                    });
                }
            }
            products.ProductDetailsManager = ProductDetailsManager;
        })(products = general.products || (general.products = {}));
    })(general = portal.general || (portal.general = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.general.products.js.map
"use strict";
var portal;
(function (portal) {
    var shoppingcart;
    (function (shoppingcart) {
        var shoppingcartcheckout;
        (function (shoppingcartcheckout) {
            "use strict";
            function CheckoutInit($container) {
                var cart = new ShoppingCartPageManager($container, starrez.model.ShoppingCartItemListSettingsModel($container));
                cart.Initialize();
            }
            shoppingcartcheckout.CheckoutInit = CheckoutInit;
            class ShoppingCartPageManager {
                constructor($container, model) {
                    this.$container = $container;
                    this.model = model;
                    this.itemDescriptionDataFieldName = "description";
                }
                Initialize() {
                    this.$removeButtons = this.$container.find(".ui-remove-from-cart");
                    this.$clearCartButton = portal.PageElements.$actions.find(".ui-clear-cart");
                    var table = this.$container.find(".ui-shopping-cart > .ui-active-table");
                    if (starrez.library.utils.IsNotNullUndefined(table)) {
                        var managers = starrez.tablesetup.CreateTableManager(table, this.$container);
                        if (starrez.library.utils.IsNotNullUndefined(managers) && managers.length > 0) {
                            this.cartTable = managers[0];
                        }
                    }
                    this.AddSubtotalRow();
                    this.AttachBaseEvents();
                    this.AttachEvents();
                    this.CheckEmptyCart();
                }
                HideHoldTimer() {
                    portal.navigation.NavigationBar.HideHoldTimer();
                }
                AddSubtotalRow() {
                    if (starrez.library.utils.IsNullOrUndefined(this.cartTable)) {
                        return;
                    }
                    var $tableFooter = this.cartTable.$table.find("tfoot");
                    if (!$tableFooter.isFound()) {
                        $tableFooter = $("<tfoot>");
                        $tableFooter.addClass("padded");
                        this.cartTable.$table.append($tableFooter);
                    }
                    var $newRow = $("<tr>").appendTo($tableFooter);
                    var totalHeadingDisplayed = false;
                    var $tableHeader = this.cartTable.$table.find("thead");
                    if ($tableHeader.isFound()) {
                        $tableHeader.find("th").each((index, element) => {
                            if ($(element).hasClass("ui-tax-total-column")) {
                                this.AddTotalLabel($newRow);
                                totalHeadingDisplayed = true;
                                var tax = this.GetTotalTax();
                                var subTotalTaxCell = $("<td>").text(tax).addClass("sub-total-tax");
                                $newRow.append(subTotalTaxCell);
                            }
                            else if ($(element).hasClass("ui-amount-column")) {
                                // format the cart sub total amount to show currency
                                if (!totalHeadingDisplayed) {
                                    this.AddTotalLabel($newRow);
                                }
                                var amount = this.GetTotalAmount();
                                var subTotalAmountCell = $("<td>").text(amount).addClass("sub-total");
                                $newRow.append(subTotalAmountCell);
                            }
                            else {
                                $newRow.append("<td>");
                            }
                        });
                    }
                }
                AddTotalLabel($newRow) {
                    $newRow.find("td").last().text("Total:").addClass("sub-total-label");
                }
                GetRemoveFromCartMessage(itemDescription) {
                    return "Do you want to remove '" + itemDescription + "' from your cart?";
                }
                /**
                * updates the sub total cost at the bottom of the table
                * @param $container the div containing the total total cost element
                * @param subTotal the new subtotal of the cart
                */
                UpdateSubTotal(subTotal) {
                    if (!starrez.library.stringhelper.IsUndefinedOrEmpty(subTotal)) {
                        var $subTotal = this.$container.find(".sub-total");
                        $subTotal.text(subTotal);
                        portal.navigation.NavigationBar.UpdateShoppingCart();
                    }
                }
                /**
                * updates the sub total tax at the bottom of the table
                * @param $container the div containing the total total cost element
                * @param subTotalTax the new subtotal tax of the cart
                */
                UpdateSubTotalTax(subTotalTax) {
                    if (!starrez.library.stringhelper.IsUndefinedOrEmpty(subTotalTax)) {
                        var $subTotalTax = this.$container.find(".sub-total-tax");
                        $subTotalTax.text(subTotalTax);
                    }
                }
                /**
                * makes the call to remove an item from the cart then updates the UI
                * @param $container the main container of the page
                * @param $row the row containing the item
                */
                RemoveItemFromCart($row, hash) {
                    var deferred = $.Deferred();
                    new starrez.service.shoppingcart.RemoveFromCart({
                        hash: hash,
                        tableName: $row.data("tablename"),
                        tableID: $row.data("table")
                    }).Post().done((cartSummary) => {
                        this.cartTable.RemoveRows($row);
                        this.UpdateSubTotal(cartSummary.CartTotalAmount);
                        this.UpdateSubTotalTax(cartSummary.CartTotalTax);
                        window.location.reload();
                        deferred.resolve();
                    });
                    return deferred.promise();
                }
                /**
                * makes the call to clear the cart
                */
                SendClearCart() {
                    const deffered = $.Deferred();
                    new starrez.service.shoppingcart.ClearCart().Post().done(() => {
                        window.location.reload();
                        deffered.resolve();
                    });
                    return deffered.promise();
                }
                /**
                 * clear the cart and update the UI
                 */
                ClearCart() {
                    this.SendClearCart().done(() => this.CheckEmptyCart());
                }
                AttachBaseEvents() {
                    // remove from cart button click
                    this.$removeButtons.SRClick((e) => {
                        // if a human clicked it
                        if (e.originalEvent !== undefined) {
                            var itemDescription = $(e.currentTarget).closest("tr").data(this.itemDescriptionDataFieldName);
                            portal.ConfirmAction(this.GetRemoveFromCartMessage(itemDescription), "Remove from cart?").done(() => {
                                this.RemoveItem($(e.currentTarget));
                            });
                        }
                        else {
                            this.RemoveItem($(e.currentTarget));
                        }
                    });
                    // as the clear cart button only appears when:
                    // - the user has enabled it
                    // - the FF is on
                    // - the cart has an item
                    if (this.$clearCartButton.isFound()) {
                        this.$clearCartButton.SRClick(() => {
                            portal.ConfirmAction("Are you sure you want to clear your cart? Note: This will remove all current items from your cart.", "Clear cart?").done(() => {
                                this.ClearCart();
                            });
                        });
                    }
                }
                RemoveItem($removeButton) {
                    var $row = $removeButton.closest("tr");
                    var hash = $removeButton.data("hash").toString();
                    this.RemoveItemFromCart($row, hash).done(() => {
                        this.CheckEmptyCart();
                    });
                }
                CheckEmptyCart() {
                    if (this.IsCartEmpty() && this.model.ExternalPaymentStatus !== 'Pending') {
                        this.HideCart();
                        this.HideHoldTimer();
                    }
                }
                AttachEvents() {
                    // quantity input change event
                    if (starrez.library.utils.IsNotNullUndefined(this.cartTable)) {
                        if (this.cartTable.HasRows()) {
                            this.cartTable.Rows().GetControl("quantity").on("change", (e) => {
                                var $quantityInput = $(e.currentTarget);
                                var $row = $quantityInput.closest("tr");
                                var tableName = $row.data("tablename");
                                var tableID = Number($row.data("table"));
                                var hashData = $quantityInput.closest(".ui-qty-dropdown-hash").data("hash").toString();
                                var call = new starrez.service.shoppingcart.UpdateShoppingCartItemQuantity({
                                    hash: hashData,
                                    tableName: tableName,
                                    tableID: tableID,
                                    newQuantity: $quantityInput.SRVal()
                                });
                                call.Post().done((cartItem) => {
                                    this.UpdateRow($row, cartItem);
                                    // update the quantity and sub total
                                    this.UpdateSubTotal(cartItem.CartTotalAmount);
                                    this.UpdateSubTotalTax(cartItem.CartTotalTax);
                                    $quantityInput.ResetChanged();
                                });
                            });
                        }
                    }
                }
                UpdateRow($row, cartItem) {
                    $row.find(".ui-amount").text(cartItem.TotalAmount);
                    $row.find(".ui-amount-ex-tax").text(cartItem.TotalAmountExTax);
                    $row.find(".ui-tax").text(cartItem.TaxAmount);
                    $row.find(".ui-tax2").text(cartItem.TaxAmount2);
                    $row.find(".ui-tax3").text(cartItem.TaxAmount3);
                    $row.find(".ui-tax-total").text(cartItem.TaxAmountTotal);
                    $row.data("quantity", cartItem.Quantity);
                }
                IsCartEmpty() {
                    if (starrez.library.utils.IsNullOrUndefined(this.cartTable)) {
                        return true;
                    }
                    return !this.cartTable.HasRows();
                }
                GetTotalAmount() {
                    return this.model.FormattedSubtotalAmount;
                }
                GetTotalTax() {
                    return this.model.FormattedSubtotalTax;
                }
                HideCart() {
                    // hide the cart list
                    if (starrez.library.utils.IsNotNullUndefined(this.cartTable)) {
                        this.cartTable.$table.SRHide();
                    }
                    var model = starrez.model.ShoppingCartItemListSettingsModel(this.$container);
                    if (model.HideContinueButtonWhenNoCartItems) {
                        // remove the submit/paynow button
                        $(".ui-submit-page-content").remove();
                    }
                    // show messsage and remove pay button if no items in cart
                    this.ShowEmptyCartMessage();
                }
                ShowEmptyCartMessage() {
                    var model = starrez.model.ShoppingCartItemListSettingsModel(this.$container);
                    portal.page.CurrentPage.AddErrorMessage(model.EmptyCartText);
                    portal.page.CurrentPage.ScrollToTop();
                }
            }
            shoppingcartcheckout.ShoppingCartPageManager = ShoppingCartPageManager;
        })(shoppingcartcheckout = shoppingcart.shoppingcartcheckout || (shoppingcart.shoppingcartcheckout = {}));
    })(shoppingcart = portal.shoppingcart || (portal.shoppingcart = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.shoppingcart.shoppingcartcheckout.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function CartListHelperExtensionsModel($sys) {
            return {};
        }
        model.CartListHelperExtensionsModel = CartListHelperExtensionsModel;
        function ProductDetailsModel($sys) {
            return {
                ShoppingCartItemID: Number($sys.data('shoppingcartitemid')),
            };
        }
        model.ProductDetailsModel = ProductDetailsModel;
        function ShoppingCartCheckoutModel($sys) {
            return {};
        }
        model.ShoppingCartCheckoutModel = ShoppingCartCheckoutModel;
        function ShoppingCartItemListSettingsModel($sys) {
            return {
                EmptyCartText: $sys.data('emptycarttext'),
                ExternalPaymentStatus: $sys.data('externalpaymentstatus'),
                FormattedSubtotalAmount: $sys.data('formattedsubtotalamount'),
                FormattedSubtotalTax: $sys.data('formattedsubtotaltax'),
                HideContinueButtonWhenNoCartItems: starrez.library.convert.ToBoolean($sys.data('hidecontinuebuttonwhennocartitems')),
            };
        }
        model.ShoppingCartItemListSettingsModel = ShoppingCartItemListSettingsModel;
        function ShoppingCartReceiptModel($sys) {
            return {
                FormattedPaidAmount: $sys.data('formattedpaidamount'),
            };
        }
        model.ShoppingCartReceiptModel = ShoppingCartReceiptModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var shoppingcart;
        (function (shoppingcart) {
            "use strict";
            class GetTotalAmount extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "ShoppingCart";
                    this.Controller = "shoppingcart";
                    this.Action = "GetTotalAmount";
                }
                CallData() {
                    var obj = {
                        quantity: this.o.quantity,
                    };
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        pageID: this.o.pageID,
                        shoppingCartItemID: this.o.shoppingCartItemID,
                    };
                    return obj;
                }
            }
            shoppingcart.GetTotalAmount = GetTotalAmount;
        })(shoppingcart = service.shoppingcart || (service.shoppingcart = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var surveys;
    (function (surveys) {
        "use strict";
        function InitSurveysPageCheckBoxList($container) {
            new SurveysCheckBoxList($container);
        }
        surveys.InitSurveysPageCheckBoxList = InitSurveysPageCheckBoxList;
        class SurveysCheckBoxList {
            constructor($container) {
                this.$container = $container;
                this.$label = $container.find(".label");
                this.$dropdown = $container.find(".ui-hosted-dropdown");
                this.$select = $container.find("select.hidden");
                this.AttachEvents();
                this.AttachPxValues();
            }
            AttachEvents() {
                this.$label.on('click', () => {
                    this.$dropdown.focus();
                });
            }
            AttachPxValues() {
                this.$select[0].pxValue = () => {
                    return Array.from(this.$select.find("option:selected")).map(x => x.value);
                };
            }
        }
    })(surveys = portal.surveys || (portal.surveys = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.surveys.js.map
"use strict";
var portal;
(function (portal) {
    var termselector;
    (function (termselector) {
        "use strict";
        function Initialise($container) {
            $container.find(".ui-select-action").SRClick((e) => {
                var $button = $(e.currentTarget);
                var termID = Number($button.closest(".ui-action-panel").data("termid"));
                $container.GetControl("TermID").SRVal(termID);
                portal.page.CurrentPage.SubmitPage();
            });
        }
        termselector.Initialise = Initialise;
    })(termselector = portal.termselector || (portal.termselector = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.termselector.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var touchnetregistration;
    (function (touchnetregistration) {
        "use strict";
        function InitialiseRegistrationPage($container) {
            new RegistrationPage($container);
        }
        touchnetregistration.InitialiseRegistrationPage = InitialiseRegistrationPage;
        class RegistrationPage {
            constructor($container) {
                this.$container = $container;
                this.$registerButton = $container.find(".ui-registerrecurringpayments");
                this.$cancelButton = $container.find(".ui-cancelrecurringpayments");
                this.AttachButtonEvents();
            }
            AttachButtonEvents() {
                this.$registerButton.SRClick(() => {
                    this.Register();
                });
                this.$cancelButton.SRClick(() => {
                    this.Cancel();
                });
            }
            Register() {
                new starrez.service.touchnetregistration.Register({
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                })
                    .Post()
                    .done((data, textStatus, jqXHR) => {
                    window.location.href = data;
                })
                    .fail((jqXHR, textStatus, errorThrown) => {
                    portal.page.CurrentPage.SetErrorMessage("Could not register for TouchNet");
                });
            }
            Cancel() {
                new starrez.service.touchnetregistration.Cancel({
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                })
                    .Post()
                    .done((data, textStatus, jqXHR) => {
                    window.location.href = data;
                })
                    .fail((jqXHR, textStatus, errorThrown) => {
                    portal.page.CurrentPage.SetErrorMessage("Could not cancel TouchNet registration");
                });
            }
        }
    })(touchnetregistration = starrez.touchnetregistration || (starrez.touchnetregistration = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.touchnetregistration.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function TouchNetRegistrationModel($sys) {
            return {};
        }
        model.TouchNetRegistrationModel = TouchNetRegistrationModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var touchnetregistration;
        (function (touchnetregistration) {
            "use strict";
            class Cancel extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "TouchNetRegistration";
                    this.Controller = "touchnetregistration";
                    this.Action = "Cancel";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            touchnetregistration.Cancel = Cancel;
            class Register extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "TouchNetRegistration";
                    this.Controller = "touchnetregistration";
                    this.Action = "Register";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            touchnetregistration.Register = Register;
        })(touchnetregistration = service.touchnetregistration || (service.touchnetregistration = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var historicalvisitorlist;
    (function (historicalvisitorlist) {
        "use strict";
        function InitHistoricalVisitorListWidget($container) {
            new HistoricalVisitorList($container);
        }
        historicalvisitorlist.InitHistoricalVisitorListWidget = InitHistoricalVisitorListWidget;
        class HistoricalVisitorList {
            constructor($container) {
                this.$container = $container;
                this.container = $container;
            }
            SetupReserveAgainButton() {
                this.container.find(".ui-reserveagain").each((index, element) => {
                    const button = $(element);
                    button.SRClick(() => {
                        const href = String(button.data("href"));
                        window.location.href = href;
                    });
                });
            }
            SetupEditVisitorButton() {
                this.container.find(".ui-editvisitor").each((index, element) => {
                    const button = $(element);
                    button.SRClick(() => {
                        const href = String(button.data("href"));
                        window.location.href = href;
                    });
                });
            }
        }
    })(historicalvisitorlist = portal.historicalvisitorlist || (portal.historicalvisitorlist = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.historicalvisitorlist.js.map
"use strict";
var portal;
(function (portal) {
    var newreservation;
    (function (newreservation) {
        "use strict";
        function InitNewReservation($container) {
            new VisitorList($container);
        }
        newreservation.InitNewReservation = InitNewReservation;
        class VisitorList {
            constructor($container) {
                this.$container = $container;
                this.container = $container;
                this.SetupNewVisitorButton();
            }
            SetupNewVisitorButton() {
                this.container.find(".ui-btn-newvisitor").SRClick((e) => {
                    const href = String($(e.currentTarget).data("href"));
                    window.location.href = href;
                });
            }
        }
    })(newreservation = portal.newreservation || (portal.newreservation = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.newreservation.js.map
"use strict";
var portal;
(function (portal) {
    var upcomingvisitorlist;
    (function (upcomingvisitorlist) {
        "use strict";
        function InitUpcomingVisitorListWidget($container) {
            new UpcomingVisitorList($container);
        }
        upcomingvisitorlist.InitUpcomingVisitorListWidget = InitUpcomingVisitorListWidget;
        class UpcomingVisitorList {
            constructor($container) {
                this.$container = $container;
                this.container = $container;
                this.SetupCancelReservationButton();
                this.model = starrez.model.UpcomingVisitorListModel($container);
            }
            SetupEditVisitorButton() {
                this.container.find(".ui-editvisitor").each((index, element) => {
                    const button = $(element);
                    button.SRClick(() => {
                        const href = String(button.data("href"));
                        window.location.href = href;
                    });
                });
            }
            SetupEditReservationButton() {
                this.container.find(".ui-editreservation").each((index, element) => {
                    const button = $(element);
                    button.SRClick(() => {
                        const href = String(button.data("href"));
                        window.location.href = href;
                    });
                });
            }
            SetupCancelReservationButton() {
                this.container.SRClickDelegate("cancelreservation", ".ui-cancelreservation", (event) => {
                    portal.ConfirmAction(this.model.CancelReservationConfirmationMessage, this.model.CancelReservationConfirmationMessageTitle).done(() => {
                        new starrez.service.visitors.CancelVisitorReservation({
                            hash: event.currentTarget.dataset.hash,
                            visitorReservationID: parseInt(event.currentTarget.dataset.entryvisitorid),
                            portalPageID: portal.page.CurrentPage.PageID,
                        }).Post().done((result) => {
                            // Refresh the page so that we get the updated visitor list
                            window.location.reload();
                        });
                    });
                });
            }
        }
    })(upcomingvisitorlist = portal.upcomingvisitorlist || (portal.upcomingvisitorlist = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.upcomingvisitorlist.js.map
"use strict";
var portal;
(function (portal) {
    var visitorlist;
    (function (visitorlist) {
        "use strict";
        function InitVisitorList($container) {
            new VisitorList($container);
        }
        visitorlist.InitVisitorList = InitVisitorList;
        class VisitorList {
            constructor($container) {
                this.$container = $container;
                this.container = $container;
                this.SetupNewReservationButton();
            }
            SetupNewReservationButton() {
                this.container.find(".ui-btn-newreservation").SRClick((e) => {
                    const href = String($(e.currentTarget).data("href"));
                    window.location.href = href;
                });
            }
        }
    })(visitorlist = portal.visitorlist || (portal.visitorlist = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.visitorlist.js.map
"use strict";
var portal;
(function (portal) {
    var visitorphotouploadwidget;
    (function (visitorphotouploadwidget) {
        "use strict";
        const update = "update";
        const del = "delete";
        function InitVisitorPhotoUploadWidget($container) {
            new VisitorPhotoUpload($container);
        }
        visitorphotouploadwidget.InitVisitorPhotoUploadWidget = InitVisitorPhotoUploadWidget;
        class VisitorPhotoUpload {
            constructor($container) {
                this.$container = $container;
                this.widgetID = Number($container.data('portalpagewidgetid'));
                this.model = starrez.model.VisitorPhotoUploadWidgetModel($container);
                this.$uploadContainer = portal.fileuploader.control.GetUploadContainer($container);
                this.$uploadContainer.data("upload-instance").CustomValidation = (files) => this.ValidateFile(files);
                portal.page.RegisterWidgetSaveData(this.widgetID, () => this.GetSaveData());
            }
            GetSaveData() {
                var saveData = new starrez.library.collections.KeyValue();
                var saveStatus = portal.fileuploader.control.GetSaveStatus(this.$uploadContainer);
                if (saveStatus.Update) {
                    saveData.Add(update, saveStatus.Update);
                }
                if (saveStatus.Delete) {
                    saveData.Add(del, saveStatus.Delete);
                }
                const data = saveData.ToArray();
                if (data.length === 0) {
                    return null;
                }
                return data;
            }
            ValidateFile(files) {
                var deferred = $.Deferred();
                var isValid = true;
                // Should only ever be 1 file in the list as we don't use multi upload in this case
                if (files.length > 0) {
                    // Validate file extensions
                    const validExtensions = this.model.ValidFileExtensions.split(",").map(fe => fe.toLowerCase().trim());
                    if ($.inArray(files[0].name.split(".").pop().toLowerCase(), validExtensions) < 0) {
                        this.SetWarning(this.model.ValidFileExtensionsErrorMessage + validExtensions.join(", "));
                        isValid = false;
                    }
                    // Validate file size
                    if (files[0].size > this.model.MaxAttachmentBytes) {
                        this.SetWarning(this.model.MaxAttachmentBytesErrorMessage);
                        isValid = false;
                    }
                }
                deferred.resolve(isValid);
                return deferred.promise();
            }
            SetWarning(message) {
                var $notification = portal.fileuploader.control.GetNotification(this.$uploadContainer);
                portal.fileuploader.control.ClearNotification($notification);
                portal.fileuploader.control.SetNotification($notification, "uploader-alert-warning", message);
            }
        }
    })(visitorphotouploadwidget = portal.visitorphotouploadwidget || (portal.visitorphotouploadwidget = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.visitorphotouploadwidget.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function UpcomingVisitorListModel($sys) {
            return {
                CancelReservationConfirmationMessage: $sys.data('cancelreservationconfirmationmessage'),
                CancelReservationConfirmationMessageTitle: $sys.data('cancelreservationconfirmationmessagetitle'),
            };
        }
        model.UpcomingVisitorListModel = UpcomingVisitorListModel;
        function VisitorPhotoUploadWidgetModel($sys) {
            return {
                MaxAttachmentBytes: Number($sys.data('maxattachmentbytes')),
                MaxAttachmentBytesErrorMessage: $sys.data('maxattachmentbyteserrormessage'),
                ValidFileExtensions: $sys.data('validfileextensions'),
                ValidFileExtensionsErrorMessage: $sys.data('validfileextensionserrormessage'),
            };
        }
        model.VisitorPhotoUploadWidgetModel = VisitorPhotoUploadWidgetModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var visitors;
        (function (visitors) {
            "use strict";
            class CancelVisitorReservation extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "Visitors";
                    this.Controller = "visitors";
                    this.Action = "CancelVisitorReservation";
                }
                CallData() {
                    var obj = {};
                    return obj;
                }
                QueryData() {
                    var obj = {
                        hash: this.o.hash,
                        portalPageID: this.o.portalPageID,
                        visitorReservationID: this.o.visitorReservationID,
                    };
                    return obj;
                }
            }
            visitors.CancelVisitorReservation = CancelVisitorReservation;
        })(visitors = service.visitors || (service.visitors = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var portal;
(function (portal) {
    var waitlist;
    (function (waitlist) {
        "use strict";
        function InitWaitListSearchPage($container) {
            new WaitListSearch($container);
        }
        waitlist.InitWaitListSearchPage = InitWaitListSearchPage;
        function InitAccessibleWaitListStatusPage($container) {
            new AccessibleWaitListStatus($container);
        }
        waitlist.InitAccessibleWaitListStatusPage = InitAccessibleWaitListStatusPage;
        class WaitListSearch {
            constructor($container) {
                this.$container = $container;
                this.$waitListResults = $container.find(".ui-waitlist-results");
                this.$roomType = $container.GetControl("RoomTypeIDs");
                this.$roomLocation = $container.GetControl("RoomLocationIDs");
                this.$selectedWaitList = $container.GetControl("Selected_WaitListID");
                this.$selectedWaitListSlot = $container.find(".ui-selected-waitlist-slot");
                this.AttachEvents();
            }
            AttachEvents() {
                if (portal.Feature.PortalXFormControls) {
                    this.$roomType.each((index, x) => x.addEventListener("change", () => {
                        this.GetWaitLists();
                    }));
                    this.$roomLocation.each((index, x) => x.addEventListener("change", () => {
                        this.GetWaitLists();
                    }));
                }
                else {
                    // we find the select element otherwise it triggers two change events
                    this.$roomType.find("select").on("change", () => {
                        this.GetWaitLists();
                    });
                    this.$roomLocation.find("select").on("change", () => {
                        this.GetWaitLists();
                    });
                }
                // clicking on the select wait list button
                this.$container.on("click", ".ui-add-waitlist", (e) => {
                    var $addButton = $(e.currentTarget);
                    var $card = $addButton.closest(".ui-card-result");
                    var waitListID = Number($card.data("waitlistid"));
                    this.$selectedWaitList.SRVal(waitListID);
                    // clone the selected card and place it in the selected wait list slot
                    var $clone = $card.clone();
                    $clone.addClass("horizontal");
                    $clone.find(".buttons").empty();
                    this.$selectedWaitListSlot.html($clone.html());
                    $.ScrollToWithAnimation(this.$selectedWaitListSlot);
                });
            }
            GetWaitLists() {
                if (portal.Feature.PortalXFormControls) {
                    new starrez.service.waitlist.GetWaitListsSearch({
                        roomTypeIDs: portal.pxcontrols.helpers.controls.multiSelect.value(this.$roomType.SRName()),
                        locationIDs: portal.pxcontrols.helpers.controls.multiSelect.value(this.$roomLocation.SRName()),
                        pageID: portal.page.CurrentPage.PageID
                    }).Post().done((searchResults) => {
                        this.$waitListResults.html(searchResults);
                    });
                }
                else {
                    new starrez.service.waitlist.GetWaitListsSearch({
                        roomTypeIDs: this.$roomType.SRVal(),
                        locationIDs: this.$roomLocation.SRVal(),
                        pageID: portal.page.CurrentPage.PageID
                    }).Post().done((searchResults) => {
                        this.$waitListResults.html(searchResults);
                    });
                }
            }
            ;
        }
        class AccessibleWaitListStatus {
            constructor($container) {
                this.Init($container);
            }
            Init($container) {
                this.$container = $container;
                this.$removeButtons = $container.find(".ui-btn-delete");
                this.$tableWaitList = $container.find(".ui-waitlist-status-table");
                this.$entryApplication = $container.GetControl("EntryApplicationID");
                this.AttachTableHandler();
                this.AttachRemoveEvents();
            }
            AttachRemoveEvents() {
                this.$removeButtons.SRClick((e) => {
                    this.RemoveWaitList(this.$container, $(e.currentTarget));
                });
            }
            AttachTableHandler() {
                var table = this.$container.find(".ui-active-table");
                var focusable = this.$container.find(".active-table-container");
                starrez.tablesetup.CreateTableManager(table, focusable);
            }
            RemoveWaitList($container, $button) {
                new starrez.service.waitlist.RemoveFromWaitList({
                    entryApplicationID: this.$entryApplication.SRVal(),
                    waitListID: $button.data("waitlist_id"),
                    pageID: $button.data("page_id")
                }).Post().done((removeResults) => {
                    portal.page.CurrentPage.ClearMessages();
                    this.$tableWaitList.html(removeResults);
                    this.Init($container);
                });
            }
        }
    })(waitlist = portal.waitlist || (portal.waitlist = {}));
})(portal || (portal = {}));
//# sourceMappingURL=portal.waitlist.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function WaitListSearchModel($sys) {
            return {};
        }
        model.WaitListSearchModel = WaitListSearchModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var waitlist;
        (function (waitlist) {
            "use strict";
            class GetWaitListsSearch extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "WaitList";
                    this.Controller = "waitlist";
                    this.Action = "GetWaitListsSearch";
                }
                CallData() {
                    var obj = {
                        locationIDs: this.o.locationIDs,
                        pageID: this.o.pageID,
                        roomTypeIDs: this.o.roomTypeIDs,
                    };
                    return obj;
                }
            }
            waitlist.GetWaitListsSearch = GetWaitListsSearch;
            class RemoveFromWaitList extends starrez.library.service.AddInActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Customer = "General";
                    this.Area = "WaitList";
                    this.Controller = "waitlist";
                    this.Action = "RemoveFromWaitList";
                }
                CallData() {
                    var obj = {
                        entryApplicationID: this.o.entryApplicationID,
                        pageID: this.o.pageID,
                        waitListID: this.o.waitListID,
                    };
                    return obj;
                }
            }
            waitlist.RemoveFromWaitList = RemoveFromWaitList;
        })(waitlist = service.waitlist || (service.waitlist = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var wpmregistration;
    (function (wpmregistration) {
        "use strict";
        function InitialiseRegistrationPage($container) {
            new RegistrationPage($container);
        }
        wpmregistration.InitialiseRegistrationPage = InitialiseRegistrationPage;
        class RegistrationPage {
            constructor($container) {
                this.$container = $container;
                this.$setupButton = $container.find(".ui-setup");
                this.AttachButtonEvents();
            }
            AttachButtonEvents() {
                this.$setupButton.SRClick(() => {
                    this.SetupPayment();
                });
            }
            SetupPayment() {
                var call = new starrez.service.wpmregistration.SetupPayment({
                    pageID: portal.page.CurrentPage.PageID,
                    processID: portal.page.CurrentPage.ProcessID
                });
                var url = starrez.library.service.CreateUrl(call.GetURLWithParameters());
                if (window.parent) {
                    parent.location.href = url;
                }
                else {
                    location.href = url;
                }
            }
        }
    })(wpmregistration = starrez.wpmregistration || (starrez.wpmregistration = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.wpmregistration.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
(function (starrez) {
    var service;
    (function (service) {
        var wpmregistration;
        (function (wpmregistration) {
            "use strict";
            class SetupPayment extends starrez.library.service.ActionCallBase {
                constructor(o) {
                    super();
                    this.o = o;
                    this.Area = "WPMRegistration";
                    this.Controller = "wpmregistration";
                    this.Action = "SetupPayment";
                }
                CallData() {
                    var obj = {
                        pageID: this.o.pageID,
                        processID: this.o.processID,
                    };
                    return obj;
                }
            }
            wpmregistration.SetupPayment = SetupPayment;
        })(wpmregistration = service.wpmregistration || (service.wpmregistration = {}));
    })(service = starrez.service || (starrez.service = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var youtube;
    (function (youtube) {
        "use strict";
        function Initialise($container) {
            SetYouTubeWidth($container);
            $(window).resize(() => {
                SetYouTubeWidth($container);
            });
        }
        youtube.Initialise = Initialise;
        function SetYouTubeWidth($container) {
            var widgetSectionWidth = $container.closest(".ui-widget-section").width();
            if (widgetSectionWidth > 560) {
                widgetSectionWidth = 560;
            }
            var $iframe = $container.children("iframe");
            $iframe.attr("width", widgetSectionWidth);
            $container.width(widgetSectionWidth);
        }
    })(youtube = starrez.youtube || (starrez.youtube = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.youtube.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
"use strict";
var starrez;
(function (starrez) {
    var zopimchat;
    (function (zopimchat) {
        "use strict";
        function Initialise($container) {
            var model = starrez.model.ZopimChatModel($container);
            $zopim(() => {
                $zopim.livechat.setName(model.EntryName);
                if (model.EntryEmail != "") {
                    $zopim.livechat.setEmail(model.EntryEmail);
                }
                $zopim.livechat.button.setPosition(model.ChatDisplayLocation);
            });
        }
        zopimchat.Initialise = Initialise;
    })(zopimchat = starrez.zopimchat || (starrez.zopimchat = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=portal.zopimchat.js.map
"use strict";
/*
    THIS FILE IS AUTO-GENERATED.  DO NOT EDIT IT.  ANY CHANGES YOU MAKE WILL BE OVERWRITTEN
    
    */
var starrez;
(function (starrez) {
    var model;
    (function (model) {
        "use strict";
        function ZopimChatModel($sys) {
            return {
                ChatDisplayLocation: $sys.data('chatdisplaylocation'),
                EntryEmail: $sys.data('entryemail'),
                EntryName: $sys.data('entryname'),
            };
        }
        model.ZopimChatModel = ZopimChatModel;
    })(model = starrez.model || (starrez.model = {}));
})(starrez || (starrez = {}));
//# sourceMappingURL=_starrez.generated.js.map
