/* Minification failed. Returning unminified contents.
(4295,13-20): run-time error JS1010: Expected identifier: default
(10,21,13,22): run-time error JS1314: Implicit property name must be identifier: openMobileMenu() {
                        document.querySelector('.u-app').classList.add('u-app--mobile-nav-active');
                        document.querySelector('.u-mobile-overlay').classList.add('u-overlay--active');
                    }
(14,21,17,22): run-time error JS1314: Implicit property name must be identifier: closeMobileMenu() {
                        document.querySelector('.u-app').classList.remove('u-app--mobile-nav-active');
                        document.querySelector('.u-mobile-overlay').classList.remove('u-overlay--active');
                    }
(19,17,24,18): run-time error JS1314: Implicit property name must be identifier: mounted() {
                    this.$nextTick(() => {
                        document.querySelector('.u-mobile-overlay').addEventListener('click', vm.closeMobileMenu);
                        window.addEventListener('resize', vm.closeMobileMenu);
                    });
                }
(29,17,114,18): run-time error JS1314: Implicit property name must be identifier: data() {
                    const appOptions = [];

                    if (!isSetupComplete || hasRealm || (!hasRealm && isAdmin)) {
                        appOptions.push({
                            img: 'realm.svg',
                            name: 'Realm',
                            description: isSetupComplete && !hasRealm ? 'A complete solution for pastors and staff' : null,
                            url: STRATUS.Config.SiteUrl,
                            isDisabled: isSetupComplete && !hasRealm,
                            isSelected: app === 'realm'
                        });
                    }

                    if (isSetupComplete) {
                        if (hasConnect || isAdmin) {
                            appOptions.push({
                                img: 'connect.svg',
                                name: 'Connect',
                                description: !hasConnect ? 'Mobile and web app for your congregation' : null,
                                url: STRATUS.Config.EngagementHost,
                                isDisabled: !hasConnect,
                                isSelected: app === 'connect'
                            });
                        }

                        if ((hasAccounting && hasAccountingRights) || (!hasAccounting && isAdmin)) {
                            appOptions.push({
                                img: 'accounting.svg',
                                name: 'Accounting',
                                description: !hasAccounting ? 'Payroll, Realm Contributions integration, and more' : null,
                                url: `${STRATUS.Config.SiteUrl}/LedgerVendors`,
                                isDisabled: !hasAccounting,
                                isSelected: app === 'accounting'
                            });
                        }

                        if ((hasRefreshSiteAccess && isStaff) || (!hasRefreshSiteAccess && isAdmin)) {
                            appOptions.push({
                                img: 'websites.svg',
                                name: 'Refresh Websites',
                                promo: hasRealm ? 'GET STARTED FOR FREE' : null,
                                description: !hasRefreshSiteAccess && !hasRealm ? 'A virtual front door to your organization' : null,
                                url: `${STRATUS.Config.SiteUrl}/Websites/Overview`,
                                isDisabled: !hasRefreshSiteAccess && !hasRealm,
                                isSelected: app === 'websites'
                            });
                        }

                        if ((hasStreaming && hasStreamingRights) || (!hasStreaming && isAdmin)) {
                            appOptions.push({
                                img: 'streaming.svg',
                                name: 'Streaming',
                                description: !hasStreaming ? 'Virtually reach, engage, and disciple your congregation' : null,
                                url: 'javascript:STRATUS.Common.launchStreaming()',
                                useNewWindow: true,
                                isDisabled: !hasStreaming
                            });
                        }

                        if (isStaff) {
                            appOptions.push({
                                img: 'ministrysmart.svg',
                                name: 'MinistrySmart',
                                description: 'Online product and ministry training',
                                url: 'javascript:STRATUS.Common.launchMinistrySmart()',
                                useNewWindow: true
                            });
                        }

                        if (isAdmin) {
                            appOptions.push({
                                img: 'settings.svg',
                                name: 'System Settings',
                                description: '',
                                url: `${STRATUS.Config.SiteUrl}/RealmAccount`,
                                isSelected: app === 'settings'
                            });
                        }
                    }

                    return {
                        siteName: STRATUS.Config.SiteName,
                        appOptions
                    };
                }
(6,9,126,10): run-time error JS1314: Implicit property name must be identifier: init(app, hasRealm, hasConnect, hasStreaming, hasAccounting, isStaff, isAdmin, hasStreamingRights, hasAccountingRights, hasRefreshSiteAccess, siteAlerts, hasSeenLms, isSetupComplete) {
            headerApp = new Vue({
                el: '.u-header',
                methods: {
                    openMobileMenu() {
                        document.querySelector('.u-app').classList.add('u-app--mobile-nav-active');
                        document.querySelector('.u-mobile-overlay').classList.add('u-overlay--active');
                    },
                    closeMobileMenu() {
                        document.querySelector('.u-app').classList.remove('u-app--mobile-nav-active');
                        document.querySelector('.u-mobile-overlay').classList.remove('u-overlay--active');
                    }
                },
                mounted() {
                    this.$nextTick(() => {
                        document.querySelector('.u-mobile-overlay').addEventListener('click', vm.closeMobileMenu);
                        window.addEventListener('resize', vm.closeMobileMenu);
                    });
                }
            });

            appSelectorApp = new Vue({
                el: '#app-selector',
                data() {
                    const appOptions = [];

                    if (!isSetupComplete || hasRealm || (!hasRealm && isAdmin)) {
                        appOptions.push({
                            img: 'realm.svg',
                            name: 'Realm',
                            description: isSetupComplete && !hasRealm ? 'A complete solution for pastors and staff' : null,
                            url: STRATUS.Config.SiteUrl,
                            isDisabled: isSetupComplete && !hasRealm,
                            isSelected: app === 'realm'
                        });
                    }

                    if (isSetupComplete) {
                        if (hasConnect || isAdmin) {
                            appOptions.push({
                                img: 'connect.svg',
                                name: 'Connect',
                                description: !hasConnect ? 'Mobile and web app for your congregation' : null,
                                url: STRATUS.Config.EngagementHost,
                                isDisabled: !hasConnect,
                                isSelected: app === 'connect'
                            });
                        }

                        if ((hasAccounting && hasAccountingRights) || (!hasAccounting && isAdmin)) {
                            appOptions.push({
                                img: 'accounting.svg',
                                name: 'Accounting',
                                description: !hasAccounting ? 'Payroll, Realm Contributions integration, and more' : null,
                                url: `${STRATUS.Config.SiteUrl}/LedgerVendors`,
                                isDisabled: !hasAccounting,
                                isSelected: app === 'accounting'
                            });
                        }

                        if ((hasRefreshSiteAccess && isStaff) || (!hasRefreshSiteAccess && isAdmin)) {
                            appOptions.push({
                                img: 'websites.svg',
                                name: 'Refresh Websites',
                                promo: hasRealm ? 'GET STARTED FOR FREE' : null,
                                description: !hasRefreshSiteAccess && !hasRealm ? 'A virtual front door to your organization' : null,
                                url: `${STRATUS.Config.SiteUrl}/Websites/Overview`,
                                isDisabled: !hasRefreshSiteAccess && !hasRealm,
                                isSelected: app === 'websites'
                            });
                        }

                        if ((hasStreaming && hasStreamingRights) || (!hasStreaming && isAdmin)) {
                            appOptions.push({
                                img: 'streaming.svg',
                                name: 'Streaming',
                                description: !hasStreaming ? 'Virtually reach, engage, and disciple your congregation' : null,
                                url: 'javascript:STRATUS.Common.launchStreaming()',
                                useNewWindow: true,
                                isDisabled: !hasStreaming
                            });
                        }

                        if (isStaff) {
                            appOptions.push({
                                img: 'ministrysmart.svg',
                                name: 'MinistrySmart',
                                description: 'Online product and ministry training',
                                url: 'javascript:STRATUS.Common.launchMinistrySmart()',
                                useNewWindow: true
                            });
                        }

                        if (isAdmin) {
                            appOptions.push({
                                img: 'settings.svg',
                                name: 'System Settings',
                                description: '',
                                url: `${STRATUS.Config.SiteUrl}/RealmAccount`,
                                isSelected: app === 'settings'
                            });
                        }
                    }

                    return {
                        siteName: STRATUS.Config.SiteName,
                        appOptions
                    };
                },
                methods: {
                    closeMobileMenu: headerApp.closeMobileMenu
                }
            });

            navApp = new Vue({
                el: '#main-nav',
                methods: {
                    closeMobileMenu: headerApp.closeMobileMenu
                }
            });
        }
(258,9,282,10): run-time error JS1314: Implicit property name must be identifier: trackEvent(category, action, label, value, namespace) {
            try {
                if (namespace && category) {
                    category = namespace + '-' + category;
                }

                if (value) {
                    value = parseInt(value);

                    if (isNaN(value)) {
                        value = undefined;
                    }
                }

                if (typeof (label) !== 'undefined' && typeof (value) !== 'undefined') {
                    _track(action, { category: category, label: label, value: value });
                } else if (typeof (label) !== 'undefined' && typeof (value) === 'undefined') {
                    _track(action, { category: category, label: label });
                } else if (typeof (label) === 'undefined' && typeof (value) === 'undefined') {
                    _track(action, { category: category });
                }
            } catch (e) {
                // ignore errors
            }
        }
(290,9,296,10): run-time error JS1314: Implicit property name must be identifier: track(action, metadata) {
            try {
                _track(action, metadata);
            } catch (e) {
                // ignore errors
            }
        }
(319,25,321,26): run-time error JS1314: Implicit property name must be identifier: error() {
                            // ignore errors
                        }
(306,9,332,10): run-time error JS1314: Implicit property name must be identifier: identify(individualId) {
            if (!window.analytics) {
                return;
            }

            const argsKey = `${individualId}.identifyArgs`;

            try {
                const cachedArgs = STRATUS.ClientStorage.getValue(argsKey);

                if (!cachedArgs || moment().diff(cachedArgs.DateAdded, 'minutes') > 5) {
                    $.ajax({
                        url: `${STRATUS.Config.SiteUrl}/Analytics/GetUserInformation`,
                        error() {
                            // ignore errors
                        }
                    }).done(function (args) {
                        args.DateAdded = moment();
                        identify(argsKey, args);
                    });
                } else {
                    identify(argsKey, cachedArgs);
                }
            } catch (e) {
                // ignore errors
            }
        }
(334,9,340,10): run-time error JS1314: Implicit property name must be identifier: load(writeKey) {
            var analytics = window.analytics = window.analytics || []; if (!analytics.initialize) if (analytics.invoked) window.console && console.error && console.error("Segment snippet included twice."); else {
                analytics.invoked = !0; analytics.methods = ["trackSubmit", "trackClick", "trackLink", "trackForm", "pageview", "identify", "reset", "group", "track", "ready", "alias", "debug", "page", "once", "off", "on", "addSourceMiddleware", "addIntegrationMiddleware", "setAnonymousId", "addDestinationMiddleware"]; analytics.factory = function (e) { return function () { var t = Array.prototype.slice.call(arguments); t.unshift(e); analytics.push(t); return analytics } }; for (var e = 0; e < analytics.methods.length; e++) { var key = analytics.methods[e]; analytics[key] = analytics.factory(key) } analytics.load = function (key, e) { var t = document.createElement("script"); t.type = "text/javascript"; t.async = !0; t.src = "https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js"; var n = document.getElementsByTagName("script")[0]; n.parentNode.insertBefore(t, n); analytics._loadOptions = e }; analytics._writeKey = writeKey; analytics.SNIPPET_VERSION = "4.15.2";
                analytics.load(writeKey);
                analytics.page();
            }
        }
(342,9,396,10): run-time error JS1314: Implicit property name must be identifier: loadGtag(measurementId, controller, action) {
            if (!controller && !action) {
                const pageTitle = $('title').text().trim();
                controller = pageTitle;
                action = pageTitle;
            }
            var gtag = window.gtag = window.gtag || [];
            if (!gtag.loaded) {
                gtag.loaded = true;
                gtag.load = function (id) {
                    var e = document.createElement("script");
                    e.type = "text/javascript";
                    e.async = !0;
                    e.src = ("https:" === document.location.protocol ? "https://" : "http://") + "www.googletagmanager.com/gtag/js?id=" + id;
                    document.getElementsByTagName('head')[0].appendChild(e);
                };
                gtag.configure = function (id, controller, action) {
                    var e = document.createElement("script");
                    e.type = "text/javascript";
                    e.text = `window.dataLayer = window.dataLayer || [];
                                function gtag(){dataLayer.push(arguments);}
                                gtag('js', new Date());
                                gtag('config', '${id}', {
                                    'send_page_view': true,
                                    'custom_map': {
                                    'dimension1': 'site_id',
                                    'dimension2': 'site_name',
                                    'dimension3': 'twa',
                                    'dimension4': 'tier',
                                    'dimension5': 'individual_id',
                                    'dimension6': 'individual_name'
                                    }
                                });
                                gtag('event',
                                'viewed ' + '${controller}',
                                {
                                    'site_id': STRATUS.Config.SiteId,
                                    'site_name': STRATUS.Config.SiteName,
                                    'twa': STRATUS.Config.AverageWeeklyAttendance,
                                    'tier': STRATUS.Config.RealmPackage,
                                    'individual_id': STRATUS.Config.IndividualId,
                                    'individual_name': STRATUS.Config.IndividualLabel,
                                    'event_category': 'Realm pageview',
                                    'event_label': '${action}'
                                });`;

                    document.getElementsByTagName('head')[0].appendChild(e);
                };
                // Load GA following the window load event so New Relic can record an accurate Apdex score.
                $(window).on('load', function () {
                    gtag.load(measurementId);
                    gtag.configure(measurementId, controller, action);
                });
            }
        }
(407,9,438,10): run-time error JS1314: Implicit property name must be identifier: addGtagEvent(action, category, label, value) {
            if (!window.gtag) {
                return;
            }

            if (!action) {
                return;
            }

            const data = {
                site_id: STRATUS.Config.SiteId,
                site_name: STRATUS.Config.SiteName,
                twa: STRATUS.Config.AverageWeeklyAttendance,
                tier: STRATUS.Config.RealmPackage,
                individual_id: STRATUS.Config.IndividualId,
                individual_name: STRATUS.Config.IndividualLabel
            };

            if (category) {
                data.event_category = category;
            }

            if (label) {
                data.event_label = label;
            }

            if (value) {
                data.value = value;
            }

            gtag('event', action, data);
        }
(440,9,443,10): run-time error JS1314: Implicit property name must be identifier: checkAccountingController(controller) {
            // Include payroll pages because it's not using accounting layout. Also note that some accounting controllers (e.g. PayableRecurringInvoiceController) can't be tracked through layout pages because they are rendered within JS files
            return controller.slice(0, 7).includes('payroll');
        }
(445,9,447,10): run-time error JS1314: Implicit property name must be identifier: getPageLoadTime() {
            _pageLoadTime = moment();
        }
(449,9,451,10): run-time error JS1314: Implicit property name must be identifier: getPageViewTime() {
            return moment.duration(moment() - _pageLoadTime).asMinutes();
        }
(465,5,479,6): run-time error JS1314: Implicit property name must be identifier: data() {
        return {
            isActive: false,
            apps: this.appOptions.map(function (app) {
                const copiedApp = Object.assign({}, app);

                copiedApp.isSelected = app.isSelected || false;
                copiedApp.isDisabled = app.isDisabled || false;
                copiedApp.useNewWindow = app.useNewWindow || false;
                copiedApp.isHighlighted = false;

                return copiedApp;
            })
        };
    }
(481,9,485,10): run-time error JS1314: Implicit property name must be identifier: activeApps() {
            return this.apps.filter(function (app) {
                return !app.isDisabled;
            });
        }
(486,9,490,10): run-time error JS1314: Implicit property name must be identifier: disabledApps() {
            return this.apps.filter(function (app) {
                return app.isDisabled;
            });
        }
(491,9,493,10): run-time error JS1314: Implicit property name must be identifier: selectedApp() {
            return this.apps.find((app) => app.isSelected);
        }
(494,9,496,10): run-time error JS1314: Implicit property name must be identifier: isDisabled() {
            return this.apps.length <= 1;
        }
(499,9,505,10): run-time error JS1314: Implicit property name must be identifier: toggleActive() {
            const vm = this;

            if (!vm.isDisabled) {
                vm.isActive = !vm.isActive;
            }
        }
(506,9,508,10): run-time error JS1314: Implicit property name must be identifier: getTarget(app) {
            return app.useNewWindow && app.url && !app.url.startsWith('javascript:') ? '_blank' : null;
        }
(509,9,513,10): run-time error JS1314: Implicit property name must be identifier: getImage(app) {
            const img = `${STRATUS.Config.Host}/Assets/Images/AppIcons/${app.img}`;

            return app.isDisabled && !app.isHighlighted ? img : img.replace('.svg', '-active.svg');
        }
(514,9,516,10): run-time error JS1314: Implicit property name must be identifier: addHighlight(app) {
            app.isHighlighted = true;
        }
(517,9,519,10): run-time error JS1314: Implicit property name must be identifier: removeHighlight(app) {
            app.isHighlighted = false;
        }
(520,9,525,10): run-time error JS1314: Implicit property name must be identifier: appSelected(app) {
            const vm = this;

            vm.isActive = false;
            vm.$emit('change', app);
        }
(527,5,537,6): run-time error JS1314: Implicit property name must be identifier: mounted() {
        const vm = this;

        vm.$nextTick(() => {
            document.addEventListener('click', function (event) {
                if (!event.target.closest('.u-app-selector')) {
                    vm.isActive = false;
                }
            });
        });
    }
(2436,5,2446,6): run-time error JS1314: Implicit property name must be identifier: data() {
        return {
            isActive: false,
            isLoaded: false,
            errorOccurred: false,
            emails: [],
            maxSubjectLength: 25,
            maxBodyLength: 33,
            allHistoryUrl: `${STRATUS.Config.SiteUrl}/Communications/EmailHistory`
        }
    }
(2448,9,2470,10): run-time error JS1314: Implicit property name must be identifier: getEmailList() {
            const vm = this;

            vm.isActive = !vm.isActive;

            if (vm.isLoaded) {
                return;
            }

            vm.reset();

            $.ajax({
                url: `${STRATUS.Config.SiteUrl}/Communications/GetLatestEmailHistorySummary`
            }).done(function (result) {
                if (result) {
                    vm.emails = result;
                    vm.isLoaded = true;
                }
            }).fail(function () {
                vm.errorOccurred = true;
                vm.isLoaded = false;
            });
        }
(2471,9,2473,10): run-time error JS1314: Implicit property name must be identifier: emailDetailUrl(id) {
            return `${STRATUS.Config.SiteUrl}/Communications/EmailDetail/${id || ''}`;
        }
(2474,9,2477,10): run-time error JS1314: Implicit property name must be identifier: reset() {
            this.errorOccurred = false;
            this.emails = [];
        }
(2479,5,2489,6): run-time error JS1314: Implicit property name must be identifier: mounted() {
        const vm = this;

        vm.$nextTick(() => {
            document.addEventListener('click', function (event) {
                if (!event.target.closest('.u-header__email-history')) {
                    vm.isActive = false;
                }
            });
        });
    }
(3440,5,3462,6): run-time error JS1314: Implicit property name must be identifier: data() {
        return {
            tabs: [
                {name: 'Profiles', icon: 'icon-profile', id: 'profiles'},
                {name: 'Groups', icon: 'icon-group', id: 'groups'}
            ],
            activeTab: null,
            isFocused: false,
            isSearching: false,
            isSearchComplete: false,
            searchText: null,
            selectedIndex: -1,
            minCharacters: 2,
            timeout: 350,
            timer: null,
            windowWidth: window.innerWidth,
            windowHeight: window.innerHeight,
            items: {
                profiles: [],
                groups: [],
            }
        };
    }
(3464,9,3471,10): run-time error JS1314: Implicit property name must be identifier: seeAllText() {
            switch (this.activeTab) {
                case 'profiles':
                    return 'profile';
                case 'groups':
                    return 'group';
            }
        }
(3472,9,3483,10): run-time error JS1314: Implicit property name must be identifier: seeAllUrl() {
            const vm = this;
            const query = encodeURIComponent(vm.searchText);

            // Engagement doesn't really have a search page for groups right now
            if (!vm.isEngagement && vm.activeTab === 'groups') {
                return `${STRATUS.Config.SiteUrl}/Groups?searchText=${query}`;
            }

            // Default to profiles
            return vm.isEngagement ? `${STRATUS.Config.EngagementHost}/directory/?search=${query}` : `${STRATUS.Config.SiteUrl}/Individual/Profiles?q=${query}&status=all`;
        }
(3504,9,3506,10): run-time error JS1314: Implicit property name must be identifier: setFocus() {
            this.isFocused = true;
        }
(3507,9,3514,10): run-time error JS1314: Implicit property name must be identifier: clearFocus() {
            const vm = this;

            vm.searchText = null;
            vm.$refs.input.blur();
            vm.isFocused = false;
            vm.activeTab = null;
        }
(3515,9,3521,10): run-time error JS1314: Implicit property name must be identifier: selectTab(tabName) {
            const vm = this;

            vm.activeTab = tabName;
            vm.selectedIndex = -1;
            vm.$refs.input.focus();
        }
(3522,9,3524,10): run-time error JS1314: Implicit property name must be identifier: processKeyDown(event) {
            event.preventDefault();
        }
(3525,9,3532,10): run-time error JS1314: Implicit property name must be identifier: getTabLength(tabName) {
            const vm = this;

            if (vm.items[tabName]) {
                return vm.items[tabName].length;
            }
            return 0;
        }
(3533,9,3551,10): run-time error JS1314: Implicit property name must be identifier: getWidth() {
            const vm = this;

            // TODO: Remove these references (isNewDesign, $refs.globalSearch, etc) #ui-redesign
            const isNewDesign = $(this.$el).closest('.u-header').length !== 0;

            if (vm.windowWidth <= 768) {
                return vm.windowWidth - (isNewDesign ? 16 : 24);
            }

            const wrapper = $(isNewDesign ? vm.$refs.wrapper : vm.$refs.globalSearch);

            if (isNewDesign) {
                return Math.min(wrapper.offset().left + wrapper.width() - (vm.windowWidth <= 768 ? 0 : 240), 600) - 16;
            } else {
                return Math.min(wrapper.offset().left + wrapper.width() - (vm.windowWidth <= 1024 ? 0 : 260), 600);
            }

        }
(3553,5,3568,6): run-time error JS1314: Implicit property name must be identifier: mounted() {
        const vm = this;

        Vue.nextTick(function () {
            window.addEventListener('resize', function () {
                vm.windowWidth = this.innerWidth;
                vm.windowHeight = this.innerHeight;
            });

            document.addEventListener('click', function (event) {
                if (!event.target.closest('.global-search')) {
                    vm.clearFocus();
                }
            });
        });
    }
(3573,9,3581,10): run-time error JS1314: Implicit property name must be identifier: close() {
            return this.each(function () {
                const obj = $(this);

                obj.css('opacity', 0).slideUp(250, function () {
                    obj.remove();
                });
            });
        }
(3682,5,3688,6): run-time error JS1314: Implicit property name must be identifier: data() {
        const vm = this;

        return {
            links: vm.mapLinkLevel(vm.linkOptions, 1)
        };
    }
(3690,9,3701,10): run-time error JS1314: Implicit property name must be identifier: expandedLevel() {
            const vm = this;
            let expandedLink = vm.links.find(link => link.isExpanded && link.Items.length);
            let level = 0;

            while (expandedLink) {
                level = expandedLink.level;
                expandedLink = expandedLink.Items.find(link => link.isExpanded && link.Items.length);
            }

            return level;
        }
(3704,9,3719,10): run-time error JS1314: Implicit property name must be identifier: mapLinkLevel(linkOptions, level) {
            const vm = this;

            return linkOptions.map(link => {
                const copiedLink = Object.assign({}, link);

                copiedLink.Items = vm.mapLinkLevel(link.Items, level + 1);
                copiedLink.Selected = link.Selected || false;

                copiedLink.isExpanded = copiedLink.Selected;
                copiedLink.isHighlighted = false;
                copiedLink.level = level;

                return copiedLink;
            });
        }
(3720,9,3724,10): run-time error JS1314: Implicit property name must be identifier: getImage(link) {
            const img = `${STRATUS.Config.Host}/Assets/Images/FeatureIcons/${link.Icon}`;

            return !link.Selected ? img : img.replace('.svg', '-active.svg');
        }
(3725,9,3727,10): run-time error JS1314: Implicit property name must be identifier: addHighlight(link) {
            link.isHighlighted = true;
        }
(3728,9,3730,10): run-time error JS1314: Implicit property name must be identifier: removeHighlight(link) {
            link.isHighlighted = false;
        }
(3731,9,3742,10): run-time error JS1314: Implicit property name must be identifier: linkClicked(link, event) {
            // Link functions as a toggle in this case
            if (link.Items.length) {
                link.isExpanded = !link.isExpanded;
                event.preventDefault();
            }

            // Already selected, nothing to do
            if (link.Selected) {
                event.preventDefault();
            }
        }
(4113,5,4118,6): run-time error JS1314: Implicit property name must be identifier: data() {
        return {
            lmsUrl: `${STRATUS.Config.SiteUrl}/Help/LMS`,
            showLmsTermsDialog: false
        };
    }
(4120,9,4126,10): run-time error JS1314: Implicit property name must be identifier: launchLms() {
            const vm = this;

            if (vm.checkHasSeenLms()) {
                window.open(vm.lmsUrl, '_blank');
            }
        }
(4127,9,4139,10): run-time error JS1314: Implicit property name must be identifier: checkHasSeenLms(event) {
            if (!this.hasSeenLms) {
                this.showLmsTermsDialog = true;

                if (event) {
                    event.preventDefault();
                }

                return false;
            }

            return true;
        }
(4140,9,4150,10): run-time error JS1314: Implicit property name must be identifier: confirmLmsTerms() {
            const vm = this;

            $.ajax({
                url: `${STRATUS.Config.SiteUrl}/Help/SetHasSeenLms`
            }).done(function () {
                vm.$emit('change', true);
                vm.showLmsTermsDialog = false;
                window.open(vm.lmsUrl, '_blank');
            });
        }
(4228,5,4239,6): run-time error JS1314: Implicit property name must be identifier: data() {
        const vm = this;

        return {
            steps: vm.list.map(function (step) {
                return {
                    name: step,
                    isActive: step === vm.activeStep
                };
            })
        }
    }
(4241,9,4247,10): run-time error JS1314: Implicit property name must be identifier: stepClicked(index) {
            const vm = this;

            vm.steps.forEach((step) => step.isActive = false);
            vm.steps[index].isActive = true;
            vm.$emit('change', vm.steps[index].name);
        }
(4295,13,4301,14): run-time error JS1314: Implicit property name must be identifier: default() {
                return {
                    FirstName: '',
                    PreferredName: '',
                    LastName: ''
                };
            }
(4304,5,4322,6): run-time error JS1314: Implicit property name must be identifier: data() {
        const vm = this;
        const returnUrl = encodeURIComponent(window.location.href);

        return {
            isActive: false,
            year: new Date().getFullYear(),
            realmProfileUrl: `${STRATUS.Config.SiteUrl}/Individual/Info/${STRATUS.Config.IndividualId}`,
            connectProfileUrl: `${STRATUS.Config.EngagementHost}/profiles/${STRATUS.Config.IndividualId}`,
            accountUrl: `${STRATUS.Config.SiteUrl}/Account?returnUrl=${returnUrl}`,
            privacyUrl: `${STRATUS.Config.SiteUrl}/Individual/Privacy?returnUrl=${returnUrl}`,
            paymentMethodsUrl: `${STRATUS.Config.SiteUrl}/Giving/Payments?returnUrl=${returnUrl}`,
            realmNotificationsUrl: `${STRATUS.Config.SiteUrl}/Account/ChangeEmailNotification${vm.isConnect ? '' : `?returnUrl=${returnUrl}`}`,
            connectNotificationsUrl: `${STRATUS.Config.EngagementHost}/settings`,
            signOutUrl: `${STRATUS.Config.SiteUrl}/Account/SignOut?returnUrl=${returnUrl}`,
            supportUrl: `${STRATUS.Config.SiteUrl}/Help?controller=${window.location.pathname.split('/')[2]}`,
            termsUrl: `${STRATUS.Config.Host}/About/Use`
        };
    }
(4324,9,4326,10): run-time error JS1314: Implicit property name must be identifier: preferredName() {
            return this.nameParts.PreferredName || this.nameParts.FirstName;
        }
(4327,9,4340,10): run-time error JS1314: Implicit property name must be identifier: initials() {
            const vm = this;
            let initials = '';

            if (vm.preferredName.length) {
                initials += vm.preferredName.substring(0, 1).toUpperCase();
            }

            if (vm.nameParts.LastName.length) {
                initials += vm.nameParts.LastName.substring(0, 1).toUpperCase();
            }

            return initials;
        }
(4341,9,4343,10): run-time error JS1314: Implicit property name must be identifier: isConnect() {
            return this.app === 'connect';
        }
(4345,5,4355,6): run-time error JS1314: Implicit property name must be identifier: mounted() {
        const vm = this;

        vm.$nextTick(() => {
            document.addEventListener('click', function (event) {
                if (!event.target.closest('.u-header__profile-menu')) {
                    vm.isActive = false;
                }
            });
        });
    }
(4723,5,4727,6): run-time error JS1314: Implicit property name must be identifier: data() {
        return {
            alerts: this.initializeAlerts()
        };
    }
(4729,9,4731,10): run-time error JS1314: Implicit property name must be identifier: list() {
            return this.initializeAlerts();
        }
(4734,9,4738,10): run-time error JS1314: Implicit property name must be identifier: initializeAlerts() {
            this.alerts = this.list.map((alert) => {
                return Object.assign({ isDismissed: false }, alert);
            });
        }
(4751,17,4753,18): run-time error JS1314: Implicit property name must be identifier: error() {
                    // Don't show error message if this fails.
                }
(4739,9,4755,10): run-time error JS1314: Implicit property name must be identifier: dismiss(alert, index) {
            const vm = this;

            alert.isDismissed = true;
            setTimeout(() => {
                vm.alerts.splice(index, 1);
                vm.$emit('change', vm.alerts);
            }, 250);

            $.ajax({
                url: `${STRATUS.Config.SiteUrl}/Account/DismissNotification`,
                data: { id: alert.NotificationId },
                error() {
                    // Don't show error message if this fails.
                }
            });
        }
(4766,5,4772,6): run-time error JS1314: Implicit property name must be identifier: data() {
        return {
            storageKey: `${STRATUS.Config.IndividualId}-streaming-disclaimer-seen`,
            streamingUrl: `${STRATUS.Config.SiteUrl}/Streaming/Redirect`,
            showStreamingTermsDialog: false
        };
    }
(4774,9,4782,10): run-time error JS1314: Implicit property name must be identifier: launchStreaming() {
            const vm = this;

            if (STRATUS.ClientStorage.getValue(vm.storageKey, false)) {
                window.open(vm.streamingUrl, '_blank');
            } else {
                vm.showStreamingTermsDialog = true;
            }
        }
(4783,9,4789,10): run-time error JS1314: Implicit property name must be identifier: confirmStreamingTerms() {
            const vm = this;

            STRATUS.ClientStorage.setValue(vm.storageKey, true, false);
            vm.showStreamingTermsDialog = false;
            window.open(vm.streamingUrl, '_blank');
        }
 */

STRATUS.Common = function () {
    let siteAlertsApp, headerApp, appSelectorApp, navApp, dialogApp;

    return {
        init(app, hasRealm, hasConnect, hasStreaming, hasAccounting, isStaff, isAdmin, hasStreamingRights, hasAccountingRights, hasRefreshSiteAccess, siteAlerts, hasSeenLms, isSetupComplete) {
            headerApp = new Vue({
                el: '.u-header',
                methods: {
                    openMobileMenu() {
                        document.querySelector('.u-app').classList.add('u-app--mobile-nav-active');
                        document.querySelector('.u-mobile-overlay').classList.add('u-overlay--active');
                    },
                    closeMobileMenu() {
                        document.querySelector('.u-app').classList.remove('u-app--mobile-nav-active');
                        document.querySelector('.u-mobile-overlay').classList.remove('u-overlay--active');
                    }
                },
                mounted() {
                    this.$nextTick(() => {
                        document.querySelector('.u-mobile-overlay').addEventListener('click', vm.closeMobileMenu);
                        window.addEventListener('resize', vm.closeMobileMenu);
                    });
                }
            });

            appSelectorApp = new Vue({
                el: '#app-selector',
                data() {
                    const appOptions = [];

                    if (!isSetupComplete || hasRealm || (!hasRealm && isAdmin)) {
                        appOptions.push({
                            img: 'realm.svg',
                            name: 'Realm',
                            description: isSetupComplete && !hasRealm ? 'A complete solution for pastors and staff' : null,
                            url: STRATUS.Config.SiteUrl,
                            isDisabled: isSetupComplete && !hasRealm,
                            isSelected: app === 'realm'
                        });
                    }

                    if (isSetupComplete) {
                        if (hasConnect || isAdmin) {
                            appOptions.push({
                                img: 'connect.svg',
                                name: 'Connect',
                                description: !hasConnect ? 'Mobile and web app for your congregation' : null,
                                url: STRATUS.Config.EngagementHost,
                                isDisabled: !hasConnect,
                                isSelected: app === 'connect'
                            });
                        }

                        if ((hasAccounting && hasAccountingRights) || (!hasAccounting && isAdmin)) {
                            appOptions.push({
                                img: 'accounting.svg',
                                name: 'Accounting',
                                description: !hasAccounting ? 'Payroll, Realm Contributions integration, and more' : null,
                                url: `${STRATUS.Config.SiteUrl}/LedgerVendors`,
                                isDisabled: !hasAccounting,
                                isSelected: app === 'accounting'
                            });
                        }

                        if ((hasRefreshSiteAccess && isStaff) || (!hasRefreshSiteAccess && isAdmin)) {
                            appOptions.push({
                                img: 'websites.svg',
                                name: 'Refresh Websites',
                                promo: hasRealm ? 'GET STARTED FOR FREE' : null,
                                description: !hasRefreshSiteAccess && !hasRealm ? 'A virtual front door to your organization' : null,
                                url: `${STRATUS.Config.SiteUrl}/Websites/Overview`,
                                isDisabled: !hasRefreshSiteAccess && !hasRealm,
                                isSelected: app === 'websites'
                            });
                        }

                        if ((hasStreaming && hasStreamingRights) || (!hasStreaming && isAdmin)) {
                            appOptions.push({
                                img: 'streaming.svg',
                                name: 'Streaming',
                                description: !hasStreaming ? 'Virtually reach, engage, and disciple your congregation' : null,
                                url: 'javascript:STRATUS.Common.launchStreaming()',
                                useNewWindow: true,
                                isDisabled: !hasStreaming
                            });
                        }

                        if (isStaff) {
                            appOptions.push({
                                img: 'ministrysmart.svg',
                                name: 'MinistrySmart',
                                description: 'Online product and ministry training',
                                url: 'javascript:STRATUS.Common.launchMinistrySmart()',
                                useNewWindow: true
                            });
                        }

                        if (isAdmin) {
                            appOptions.push({
                                img: 'settings.svg',
                                name: 'System Settings',
                                description: '',
                                url: `${STRATUS.Config.SiteUrl}/RealmAccount`,
                                isSelected: app === 'settings'
                            });
                        }
                    }

                    return {
                        siteName: STRATUS.Config.SiteName,
                        appOptions
                    };
                },
                methods: {
                    closeMobileMenu: headerApp.closeMobileMenu
                }
            });

            navApp = new Vue({
                el: '#main-nav',
                methods: {
                    closeMobileMenu: headerApp.closeMobileMenu
                }
            });
        }
    };
}();
;
STRATUS.Addresses = function () {
    var verify = function (address, callback) {
        var url = '/addressverification/verify';
        STRATUS.Helpers.showProcessingMessage();
        $.ajax({
            url: STRATUS.Config.SiteUrl + url,
            data: address,
            success: function (result) {
                callback(result);
            },
            complete: function () {
                STRATUS.Helpers.hideProcessingMessage();
            }
        });
    };

    var save = function (address, isVerified, ignore, next, addressListArgs, callback) {
        var url = '/addressverification/resolve';
        STRATUS.Helpers.showProcessingMessage();
        var args = {
            "Address.AddressId": address.AddressId,
            "Address.Address1": address.Address1,
            "Address.Address2": address.Address2,
            "Address.City": address.City,
            "Address.Region": address.Region,
            "Address.PostalCode": address.PostalCode,
            "Address.Country": address.Country,
            "Address.Latitude": address.Latitude,
            "Address.Longitude": address.Longitude,
            "Verified": isVerified,
            "Ignore": ignore,
            "NextAddress": next,
            "AddressListArgs.CampusId": addressListArgs != undefined ? addressListArgs.CampusId : null,
            "AddressListArgs.FilterIgnored": addressListArgs != undefined ? addressListArgs.FilterIgnored : null,
            "AddressListArgs.Addresses": addressListArgs != undefined ? addressListArgs.Addresses : null,
            "AddressListArgs.IsExclude": addressListArgs != undefined ? addressListArgs.IsExclude : null,
            "AddressListArgs.SortBy": addressListArgs != undefined ? addressListArgs.SortName : null,
            "AddressListArgs.SortAscending": addressListArgs != undefined ? addressListArgs.SortAscending : null,
            "AddressListArgs.Page": 0
        };

        $.ajax({
            url: STRATUS.Config.SiteUrl + url,
            data: args,
            dataType: 'json',
            type: 'POST',
            success: function (result) {
                callback(result);
            },
            complete: function () {
                STRATUS.Helpers.hideProcessingMessage();
            }
        });
    };

    var areEqual = function (address, suggestion) {
        return (
            (suggestion.Address1 === address.Address1 || (!suggestion.Address1 && !address.Address2)) &&
            (suggestion.Address2 === address.Address2 || (!suggestion.Address2 && !address.Address2)) &&
            (suggestion.City === address.City || (!suggestion.City && !address.City)) &&
            (suggestion.Region === address.Region || (!suggestion.Region && !address.Region)) &&
            (suggestion.PostalCode === address.PostalCode || (!suggestion.PostalCode && !address.PostalCode)) &&
            (suggestion.Country === address.Country || (!suggestion.Country && !address.Country))
        );
    };

    return {
        verify: function (address, callback) {
            verify(address, callback);
        },
        areEqual: function (address, suggestion) {
            return areEqual(address, suggestion);
        },
        save: function (address, isVerified, ignore, next, addressListArgs, callback) {
            save(address, isVerified, ignore, next, addressListArgs, callback);
        }
    };
}();
;
/*
*  Analytics Using Segment.com integrations
*  Learn more using the link below
*  https://segment.com/docs/libraries/analytics.js/quickstart/#step-1-copy-the-snippet
*  
*  The analytics variable should be added to the global scope
*  - in Realm this is done in BaseLayout.cshtml
*/

STRATUS.Analytics = function () {
    let _pageLoadTime;
    /*
    *  name: required, should be human readable; a good rule of thumb is to use a past-tense verb and a noun ex. "Clicked Help"
    *  properties: optional; an object with extra information you want to track with the event.  It's usually a good idea to pass this.
    *
    *  Read the full spec for track
    *  https://segment.com/docs/spec/track/
    */
    const _track = function (name, properties) {
        if (!window.analytics) {
            return;
        }

        window.analytics.ready(function () {
            window.analytics.track(name, properties);
        });
    };

    const identify = function (argsKey, args) {
        if (!args) {
            return;
        }

        // Identify user
        window.analytics.identify(args.IndividualId, args);

        STRATUS.ClientStorage.setValue(argsKey, args);
    };

    return {
        /*
        * trackEvent - method used to track an event with the necessary fields for google analytics
        *
        * category: required string. Typically the object that was interacted with (e.g. button)
        * action: required string. Should be human readable; a good rule of thumb is to use a past-tense verb and a noun ex. "Clicked Help"
        * label: optional string. Useful for categorizing events (e.g. name buttons)
        * value: optional integer. Values must be non-negative. Useful to pass counts (number than can be summed and totaled)
        * namespace: optional string. The area of Realm this event occurred in for reporting purposes.
        */
        trackEvent(category, action, label, value, namespace) {
            try {
                if (namespace && category) {
                    category = namespace + '-' + category;
                }

                if (value) {
                    value = parseInt(value);

                    if (isNaN(value)) {
                        value = undefined;
                    }
                }

                if (typeof (label) !== 'undefined' && typeof (value) !== 'undefined') {
                    _track(action, { category: category, label: label, value: value });
                } else if (typeof (label) !== 'undefined' && typeof (value) === 'undefined') {
                    _track(action, { category: category, label: label });
                } else if (typeof (label) === 'undefined' && typeof (value) === 'undefined') {
                    _track(action, { category: category });
                }
            } catch (e) {
                // ignore errors
            }
        },

        /*
        * track - method used to track an event with a predefined metadata object
        *
        * action: required string. Should be human readable; a good rule of thumb is to use a past-tense verb and a noun ex. "Clicked Help"
        * metadata: required object. Metadata you wish to include with the event (e.g. { individual_email: 'pi@example.org', individual_id: '12345' })
        */
        track(action, metadata) {
            try {
                _track(action, metadata);
            } catch (e) {
                // ignore errors
            }
        },

        /*
        *  identify: method used to identify a user; this is called from InternalLayout.cshtml on every page view
        *
        *  identifyArgs: object containing user id and traits (see UserInformationViewModel for structure)
        *
        *  Now uses cache to store and pull information. If it has been more than 5 minutes since the args have been populated
        *  it will make another API call on the next page the user visits. It uses STRATUS.ClientStorage to set the whole object.
        */
        identify(individualId) {
            if (!window.analytics) {
                return;
            }

            const argsKey = `${individualId}.identifyArgs`;

            try {
                const cachedArgs = STRATUS.ClientStorage.getValue(argsKey);

                if (!cachedArgs || moment().diff(cachedArgs.DateAdded, 'minutes') > 5) {
                    $.ajax({
                        url: `${STRATUS.Config.SiteUrl}/Analytics/GetUserInformation`,
                        error() {
                            // ignore errors
                        }
                    }).done(function (args) {
                        args.DateAdded = moment();
                        identify(argsKey, args);
                    });
                } else {
                    identify(argsKey, cachedArgs);
                }
            } catch (e) {
                // ignore errors
            }
        },

        load(writeKey) {
            var analytics = window.analytics = window.analytics || []; if (!analytics.initialize) if (analytics.invoked) window.console && console.error && console.error("Segment snippet included twice."); else {
                analytics.invoked = !0; analytics.methods = ["trackSubmit", "trackClick", "trackLink", "trackForm", "pageview", "identify", "reset", "group", "track", "ready", "alias", "debug", "page", "once", "off", "on", "addSourceMiddleware", "addIntegrationMiddleware", "setAnonymousId", "addDestinationMiddleware"]; analytics.factory = function (e) { return function () { var t = Array.prototype.slice.call(arguments); t.unshift(e); analytics.push(t); return analytics } }; for (var e = 0; e < analytics.methods.length; e++) { var key = analytics.methods[e]; analytics[key] = analytics.factory(key) } analytics.load = function (key, e) { var t = document.createElement("script"); t.type = "text/javascript"; t.async = !0; t.src = "https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js"; var n = document.getElementsByTagName("script")[0]; n.parentNode.insertBefore(t, n); analytics._loadOptions = e }; analytics._writeKey = writeKey; analytics.SNIPPET_VERSION = "4.15.2";
                analytics.load(writeKey);
                analytics.page();
            }
        },

        loadGtag(measurementId, controller, action) {
            if (!controller && !action) {
                const pageTitle = $('title').text().trim();
                controller = pageTitle;
                action = pageTitle;
            }
            var gtag = window.gtag = window.gtag || [];
            if (!gtag.loaded) {
                gtag.loaded = true;
                gtag.load = function (id) {
                    var e = document.createElement("script");
                    e.type = "text/javascript";
                    e.async = !0;
                    e.src = ("https:" === document.location.protocol ? "https://" : "http://") + "www.googletagmanager.com/gtag/js?id=" + id;
                    document.getElementsByTagName('head')[0].appendChild(e);
                };
                gtag.configure = function (id, controller, action) {
                    var e = document.createElement("script");
                    e.type = "text/javascript";
                    e.text = `window.dataLayer = window.dataLayer || [];
                                function gtag(){dataLayer.push(arguments);}
                                gtag('js', new Date());
                                gtag('config', '${id}', {
                                    'send_page_view': true,
                                    'custom_map': {
                                    'dimension1': 'site_id',
                                    'dimension2': 'site_name',
                                    'dimension3': 'twa',
                                    'dimension4': 'tier',
                                    'dimension5': 'individual_id',
                                    'dimension6': 'individual_name'
                                    }
                                });
                                gtag('event',
                                'viewed ' + '${controller}',
                                {
                                    'site_id': STRATUS.Config.SiteId,
                                    'site_name': STRATUS.Config.SiteName,
                                    'twa': STRATUS.Config.AverageWeeklyAttendance,
                                    'tier': STRATUS.Config.RealmPackage,
                                    'individual_id': STRATUS.Config.IndividualId,
                                    'individual_name': STRATUS.Config.IndividualLabel,
                                    'event_category': 'Realm pageview',
                                    'event_label': '${action}'
                                });`;

                    document.getElementsByTagName('head')[0].appendChild(e);
                };
                // Load GA following the window load event so New Relic can record an accurate Apdex score.
                $(window).on('load', function () {
                    gtag.load(measurementId);
                    gtag.configure(measurementId, controller, action);
                });
            }
        },

        /*
        * addGtagEvent - method used to track an event with the necessary fields for google analytics using the gtag.js approach
        *
        * action: (required) The string that will appear as the event action in Google Analytics Event reports. 
        *                    Should be human readable; a good rule of thumb is to use a past-tense verb and a noun. e.g. "Ran Family Directory Report"
        * category: (optional) The string that will appear as the event category. e.g. "Reports"
        * label: (optional). The string that will appear as the event label. Useful for categorizing events. e.g. "ReportSize = 1000 individuals"
        * value: (optional). A non-negative integer that will appear as the event value. e.g. "1000"
        */
        addGtagEvent(action, category, label, value) {
            if (!window.gtag) {
                return;
            }

            if (!action) {
                return;
            }

            const data = {
                site_id: STRATUS.Config.SiteId,
                site_name: STRATUS.Config.SiteName,
                twa: STRATUS.Config.AverageWeeklyAttendance,
                tier: STRATUS.Config.RealmPackage,
                individual_id: STRATUS.Config.IndividualId,
                individual_name: STRATUS.Config.IndividualLabel
            };

            if (category) {
                data.event_category = category;
            }

            if (label) {
                data.event_label = label;
            }

            if (value) {
                data.value = value;
            }

            gtag('event', action, data);
        },

        checkAccountingController(controller) {
            // Include payroll pages because it's not using accounting layout. Also note that some accounting controllers (e.g. PayableRecurringInvoiceController) can't be tracked through layout pages because they are rendered within JS files
            return controller.slice(0, 7).includes('payroll');
        },

        getPageLoadTime() {
            _pageLoadTime = moment();
        },

        getPageViewTime() {
            return moment.duration(moment() - _pageLoadTime).asMinutes();
        }
    };
}();;
Vue.component('app-selector', {
    props: {
        site: {
            type: String,
            default: ''
        },
        appOptions: {
            type: Array,
            default: () => []
        }
    },
    data() {
        return {
            isActive: false,
            apps: this.appOptions.map(function (app) {
                const copiedApp = Object.assign({}, app);

                copiedApp.isSelected = app.isSelected || false;
                copiedApp.isDisabled = app.isDisabled || false;
                copiedApp.useNewWindow = app.useNewWindow || false;
                copiedApp.isHighlighted = false;

                return copiedApp;
            })
        };
    },
    computed: {
        activeApps() {
            return this.apps.filter(function (app) {
                return !app.isDisabled;
            });
        },
        disabledApps() {
            return this.apps.filter(function (app) {
                return app.isDisabled;
            });
        },
        selectedApp() {
            return this.apps.find((app) => app.isSelected);
        },
        isDisabled() {
            return this.apps.length <= 1;
        }
    },
    methods: {
        toggleActive() {
            const vm = this;

            if (!vm.isDisabled) {
                vm.isActive = !vm.isActive;
            }
        },
        getTarget(app) {
            return app.useNewWindow && app.url && !app.url.startsWith('javascript:') ? '_blank' : null;
        },
        getImage(app) {
            const img = `${STRATUS.Config.Host}/Assets/Images/AppIcons/${app.img}`;

            return app.isDisabled && !app.isHighlighted ? img : img.replace('.svg', '-active.svg');
        },
        addHighlight(app) {
            app.isHighlighted = true;
        },
        removeHighlight(app) {
            app.isHighlighted = false;
        },
        appSelected(app) {
            const vm = this;

            vm.isActive = false;
            vm.$emit('change', app);
        }
    },
    mounted() {
        const vm = this;

        vm.$nextTick(() => {
            document.addEventListener('click', function (event) {
                if (!event.target.closest('.u-app-selector')) {
                    vm.isActive = false;
                }
            });
        });
    },
    template: `
<nav class="u-app-selector unselectable" v-bind:class="{ 'u-app-selector--active': isActive, 'u-app-selector--disabled': isDisabled }">
    <div class="u-app-selector__selection" v-on:click="toggleActive">
        <div class="u-app-selector__icon"></div>
        <div>
            <div class="u-app-selector__site">{{site}}</div>
            <div class="u-app-selector__app">{{selectedApp.name}}</div>
        </div>
    </div>
    <div v-show="isActive" class="u-app-selector__menu u-menu">
        <h6 class="u-app-selector__header">YOUR MINISTRY HUB</h6>
        <ul>
            <li v-for="(app, index) in activeApps" v-bind:key="index">
                <a v-bind:class="{ 'u-app-selector__item--selected': app.isSelected }" href="javascript:void(0)" v-on:mouseover="addHighlight(app)" v-on:mouseout="removeHighlight(app)" v-on:click="appSelected(app, $event)">
                    <img v-bind:src="getImage(app)" alt=""/>
                    <div>
                        <div>{{app.name}}</div>
                        <div v-if="app.promo" class="app-promo">{{app.promo}}</div>
                        <div v-if="app.description" class="text-small text-muted">{{app.description}}</div>
                    </div>
                    <span v-if="app.useNewWindow" class="icon ui-redesign icon-launch-outline text-muted"></span>
                </a>
            </li>
        </ul>
        <ul v-if="disabledApps.length" class="u-app-selector__divider">
            <li v-for="(app, index) in disabledApps" v-bind:key="index">
                <a class="js-pendo-link" v-bind:class="{ 'u-app-selector__item--selected': app.isSelected }" href="javascript:void(0);" v-on:mouseover="addHighlight(app)" v-on:mouseout="removeHighlight(app)">
                    <img v-bind:src="getImage(app)" alt=""/>
                    <div>
                        <div>{{app.name}}</div>
                        <div v-if="app.promo" class="app-promo">{{app.promo}}</div>
                        <div v-if="app.description" class="text-small text-muted">{{app.description}}</div>
                    </div>
                </a>
            </li>
        </ul>
    </div>
</nav>`
});;
STRATUS.Charts = function () {
    var _mobileResponsiveWidth = 480;

    var resetToDefaultHighChartColors = function () {
        //High Chart Default Colors
        return ['#319ACF', '#E07005', '#79B70E', '#A52001', '#8250A0', '#F1A421', '#C8DC3C', '#16607C', '#8ED0EA', '#14B4A0'];
    };

    return {
        radializeColor: function (color) {
            return {
                radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
                stops: [
                    [0, color],
                    [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
                ]
            };
        },
        setLegendHover: function (idName, chart) {
            $('#' + idName + ' .highcharts-legend-item').each(function (index, element) {
                $(element).hover(function () {
                    var point = chart.get(index);
                    point.slice(true);
                    point.series.setVisible(false); // Toggling visibility of the series fixes the render issues if hovering during animation
                    point.series.setVisible(true, true);
                    chart.tooltip.refresh(point);
                }, function () {
                    var point = chart.get(index);
                    point.slice(false);
                    point.series.setVisible(false);
                    point.series.setVisible(true, true);
                    chart.tooltip.hide();
                });
            });
        },
        drawPieChartNoLegend: function(options) {
            Highcharts.setOptions({
                global: {
                    useUTC: false
                },
                lang: {
                    decimalPoint: '.',
                    thousandsSep: ','
                }
            });

            var chartCursor = typeof options.chartCursor == 'undefined' ? 'pointer' : options.chartCursor;

            var seriesOptions = {
                type: 'pie',
                name: options.seriesTitle,
                data: options.data,
                states: { hover: { enabled: false } }
            };

            var chart = new Highcharts.Chart({
                chart: {
                    renderTo: options.elementId,
                    backgroundColor: null,
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false,
                 },
                credits: {
                    enabled: false
                },
                title: {
                    align: 'left',
                    text: options.chartTitle,
                    style: {
                        color: 'black'
                    }
                },
      
                tooltip: {
                    valuePrefix: 'series.name',
                    valueDecimals: 2,
                    pointFormat: '<b>{point.percentage:.1f}%</b>',
                    percentageDecimals: 1
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: chartCursor,
                        borderWidth: 0,
                        minPointLength: 3,
                        dataLabels: {
                            enable: true,
                            format: '<b>{point.name}</b>',
                          },
                        events: {
                            click: function (event) {
                                options.callback(event.point);
                            }
                        },
                        point: {
                            events: {
                                legendItemClick: function (event) {
                                    event.preventDefault();
                                    options.callback(this);
                                }
                            }
                        },
                        showInLegend: false
                    }
                },
                series: [seriesOptions]
            });

            return chart;
        },
        drawPieChart: function (options) {
            var buildDataArray = function () {
                var data = [];
                var len = options.labels.length;
                
                for (var i = 0; i < len; i++) {
                    var item = {
                        name: options.labels[i],
                        y: options.values[i],
                        legendIndex: typeof options.legendIndexes != 'undefined' ? options.legendIndexes[i] : i,
                        id: typeof options.legendIndexes != 'undefined' ? options.legendIndexes[i] : i,
                        subToolTip: options.valueLabel ? '<br>' + options.valueLabel + ': <b>' + (options.valueIsCurrency ? STRATUS.Formatters.formatCurrency(options.values[i], { addSymbol: true }) : options.values[i]) + '</b>' : '',
                        additionalData: typeof options.additionalData != 'undefined' ? options.additionalData[i] : null
                    };
                    data.push(item);
                }
                
                return data;
            };

            Highcharts.setOptions({
                global: {
                    useUTC: false
                },
                lang: {
                    decimalPoint: '.',
                    thousandsSep: ','
                }
            });

            var chartCursor = typeof options.chartCursor == 'undefined' ? 'pointer' : options.chartCursor;
            var legendCursor = typeof options.legendCursor == 'undefined' ? 'pointer' : options.legendCursor;

            var toolTipFormatter = null;

            if (options.tooltipFormatter !== undefined) {
                toolTipFormatter = options.tooltipFormatter;
            }

            var seriesOptions = {
                type: 'pie',
                name: options.seriesTitle,
                data: buildDataArray(),
                states: { hover: { enabled: false }}
            };

            if (options.colors === undefined) {
                options.colors = resetToDefaultHighChartColors();
            }

            var chart = new Highcharts.Chart({
                chart: {
                    renderTo: options.elementId,
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    backgroundColor: null,
                    plotShadow: false,
                },
                colors: options.colors,
                credits: {
                    enabled: false
                },
                title: {
                    align: 'left',
                    text: options.chartTitle,
                    style: {
                        color: 'black'
                    }
                },
                legend: {
                    borderRadius: 5,
                    borderColor: '#909090',
                    borderWidth: 1,
                    align: $(window).width() <= _mobileResponsiveWidth ? 'center' : 'right',
                    verticalAlign: $(window).width() <= _mobileResponsiveWidth ? 'bottom' : 'middle',
                    layout:  'vertical',
                    maxHeight: $(window).width() <= _mobileResponsiveWidth ? 80 : 160,
                    itemStyle: {
                        cursor: legendCursor,
                        fontWeight: 'normal',
                        color: '#3e576f'
                    }
                },
                tooltip: {
                    formatter: toolTipFormatter,
                    valuePrefix: 'series.name',
                    valueDecimals: 2,
                    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b> {point.subToolTip}',
                    percentageDecimals: 1
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: chartCursor,
                        borderWidth: 0,
                        minPointLength: 3,
                        dataLabels: {
                            distance: -25,
                            color: 'white',
                            formatter: function () {
                                var val = null;
                                if (this.percentage > 8) {
                                    val = this.percentage.toFixed(1) + '%';
                                }

                                return val;
                            },
                            crop: true,
                            overflow: 'justified',
                            enabled: true,
                            style: {
                                fontWeight: 'bold',
                                color: 'white',
                                textShadow: '0px 1px 2px black'
                            }
                        },
                        events: {
                            click: function (event) {
                                options.callback(event.point);
                            }
                        },
                        point: {
                            events: {
                                legendItemClick: function (event) {
                                    event.preventDefault();
                                    options.callback(this);
                                }
                            }
                        },
                        showInLegend: true
                    }
                },
                series: [seriesOptions]
            });

            return chart;
        },
        drawLineChart: function (options, data, chartOverride) {
            //Options are elementId, pointClickCallback, tooltipFomratter, yAxisLabelFormatter

            var buildPointObjects = function (series) {
                var points = [];
                var len = series.Points.length;
                for (var i = 0; i < len; i++) {
                    var item = null;
                    if (series.Points[i] !== null) {
                        item = {
                            name: series.Points[i].Name,
                            y: series.Points[i].Amount,
                            beginDate: series.Points[i].PeriodStartDate,
                            endDate: series.Points[i].PeriodStopDate
                        };
                    }

                    points.push(item);
                }

                return points;
            };

            var buildSeries = function () {
                var series = [];
                var len = data.Series.length;
                                
                var colors = resetToDefaultHighChartColors();

                for (var i = 0; i < len; i++) {
                    var seriesOptions = {
                        type: 'line',
                        cursor: 'pointer',
                        name: data.Series[i].Title,
                        data: buildPointObjects(data.Series[i]),
                        zIndex: 100 - i,
                        dashStyle: data.Series[i].DashStyle,
                        marker: {
                            symbol: data.Series[i].MarkerSymbol.toLocaleLowerCase(),
                            fillColor: colors[i % 2]
                        }
                    };

                    series.push(seriesOptions);
                }

                return series;
            };

            var chartParam = {
                chart: {
                    renderTo: options.elementId,
                    type: 'line',
                    marginRight: $(window).width() <= _mobileResponsiveWidth ? 25 : 130,
                    marginBottom: $(window).width() <= _mobileResponsiveWidth ? 95 : 25,
                    backgroundColor: null,
                    plotBackgroundColor: null,
                    plotBorderWidth: null
                },
                credits: {
                    enabled: false
                },
                title: {
                    text: data.Title,
                    align: 'left',
                    style: {
                        color: 'black'
                    }
                },
                xAxis: {
                    categories: data.XAxisLabels
                },
                yAxis: {
                    gridLineWidth: 1,
                    labels: {
                        formatter: options.yAxisLabelFormatter
                    },
                    minPadding: 0,
                    title: null
                },
                tooltip: {
                    formatter: options.tooltipFormatter
                },
                legend: {
                    layout: $(window).width() <= _mobileResponsiveWidth ? 'vertical' : 'vertical',
                    align: $(window).width() <= _mobileResponsiveWidth ? 'center' : 'right',
                    verticalAlign: 'bottom',
                    y: $(window).width() <= _mobileResponsiveWidth ? 0 : -50,
                    borderRadius: 5,
                    borderColor: '#909090',
                    borderWidth: 1,
                    itemStyle: {
                        fontWeight: 'normal',
                        color: '#3e576f'
                    }
                },
                plotOptions: {
                    line: {
                        events: {
                            click: function (event) {
                                if (options.pointClickCallback !== undefined) {
                                    options.pointClickCallback(event.point);
                                }
                            }
                        }
                    }
                },
                series: buildSeries()
            };

            if (chartOverride) {
                if (chartOverride.chart) {
                    $.extend(chartParam.chart, chartOverride.chart);
                }
                if (chartOverride.legend) {
                    $.extend(chartParam.legend, chartOverride.legend);
                }
                if (chartOverride.tooltip) {
                    $.extend(chartParam.tooltip, chartOverride.tooltip);
                }
                if (chartOverride.yAxis) {
                    $.extend(chartParam.yAxis, chartOverride.yAxis);
                }
            }

            var lineChart = new Highcharts.Chart(chartParam, function (chart) { // on complete
                if (data.CustomTextData !== null) {
                    var text = [];
                    for (var name in data.CustomTextData) {
                        if (data.CustomTextData.hasOwnProperty(name)) {
                            text.push('<span style="color: #3E576F">' + name + '</span> ' + STRATUS.Formatters.formatCurrency(data.CustomTextData[name], { addSymbol: true }));
                        }
                    }

                    chart.renderer.text(
                        text.join('<br />'),
                        chart.chartWidth - 195,
                        20
                    ).css({
                        color: 'green',
                    }).attr({
                        zIndex: 5
                    }).add();

                }
            });
        },
        drawTimeLine: function (chartSeriesData, container, callback) {
            
            var series = [];
            var xAxislabels = [];

            var colors = resetToDefaultHighChartColors();

            Highcharts.setOptions({
                global: {
                    useUTC: false
                },
                lang: {
                    decimalPoint: '.',
                    thousandsSep: ','
                }
            });

            for (var i = 0 ; i < chartSeriesData.Series.length; i++) {
                var c = chartSeriesData.Series[i];

                var dataPoints = [];
                for (var j = 0; j < c.Points.length; j++) {
                    var pointStartDate = STRATUS.Formatters.convertToJsDate(c.Points[j].MarkingDateStart);
                    var pointStopDate = STRATUS.Formatters.convertToJsDate(c.Points[j].MarkingDateStop);
                    var label = c.Points[j].Label;
                    dataPoints.push({ name: label, x: j, y: c.Points[j].MarkingCount, startDate: pointStartDate, stopDate: pointStopDate });
                    if (i === 0) {
                        xAxislabels.push(chartSeriesData.XAxisLabels[j]);
                    }
                }

                var opts = {
                    name: i === 0 ? 'Selected Year' : 'Previous Year',
                    data: dataPoints,
                    marker: { symbol: 'circle', fillColor: colors[i % 2] },
                    dashStyle: null,
                    color: null,
                    type: 'line',
                    tooltip: { valueDecimals: 0 },
                    zIndex: -1 * i
            };

                series.push(opts);
            }

            var lineChart = new Highcharts.Chart({
                chart: {
                    renderTo: $(container)[0], type: 'line',
                    backgroundColor: null,
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    marginRight: $(window).width() <= _mobileResponsiveWidth ? 25 : 150,
                    marginBottom: $(window).width() <= _mobileResponsiveWidth ? 75 : 25
                },
                credits: { enabled: false },
                title: {
                    text: chartSeriesData.Title,
                    align: 'left'
                },
                legend: {
                    borderRadius: 5,
                    borderColor: '#909090',
                    borderWidth: 1,
                    enabled: true,
                    layout: $(window).width() <= _mobileResponsiveWidth ? 'vertical' : 'vertical',
                    align: $(window).width() <= _mobileResponsiveWidth ? 'center' : 'right',
                    verticalAlign: 'bottom',
                    y: $(window).width() <= _mobileResponsiveWidth ? 0 : -150,
                    itemStyle: {
                        fontWeight: 'normal',
                        color: '#3e576f'
                    }
                },
                plotOptions: { series: { events: { click: callback } } },
                rangeSelector: { enabled: false },
                scrollbar: { enabled: false },
                navigator: { enabled: false },
                series: series,
                yAxis: { min: 0, gridLineWidth: 1, minPadding: 0, title: null, allowDecimals: false },
                xAxis: {
                    endOnTick: false,
                    min: 0,
                    minTickInterval: 1,
                    gridLineWidth: 0,
                    range: xAxislabels.length,
                    labels: { formatter: function () { return xAxislabels[this.value]; } }
                }
            });
        },
        
        drawTimeLineGeneric: function (options) {
            var defaults = {
                title: 'Chart Title',
                data: [],
                container: null,
                xAxisLabels: null,
                yAxisLabels: null,
                yAxisTitle: null,
                xAxisTitle: null,
                colors: null,
                colorByPoint: true,
                titleStyle: {
                    color: null,
                    fontWeight: null
                },
                xAxisStyle: {
                    color: null,
                    fontWeight: null
                },
                yAxisStyle: {
                    color: null,
                    fontWeight: null
                },
                yAxisLabelFormatter: null, //function
                pointClickCallback: null, //function
                tooltipFormatter: null, //function,
                legendEnabled: true,
                xAxis: null,
                yAxis: null
            };

            options = $.extend(defaults, options);
            var series = [];
            var xAxislabels = [];


            if (options.colors !== null) {
                options.colors = options.colors;
            } else {
                options.colors = resetToDefaultHighChartColors();
            }

            Highcharts.setOptions({
                global: {
                    useUTC: false
                },
                lang: {
                    decimalPoint: '.',
                    thousandsSep: ','
                }
            });

            for (var i = 0 ; i < options.data.Series.length; i++) {
                var c = options.data.Series[i];

                var dataPoints = [];
                for (var j = 0; j < c.Points.length; j++) {
                    var pointStartDate = STRATUS.Formatters.convertToJsDate(c.Points[j].DateStart);
                    var pointStopDate = STRATUS.Formatters.convertToJsDate(c.Points[j].DateEnd);
                    var label = c.Points[j].Label;
                    dataPoints.push({ name: label, x: j, y: c.Points[j].Amount, startDate: pointStartDate, stopDate: pointStopDate });
                    if (i === 0) {
                        xAxislabels.push(options.data.XAxisLabels[j]);
                    }
                }

                var opts = {
                    name: c.Title,
                    data: dataPoints,
                    marker: { symbol: 'circle', fillColor: options.colors[i % 2] },
                    dashStyle: null,
                    color: null,
                    type: 'line',
                    tooltip: { valueDecimals: 0 },
                    zIndex: -1 * i
                };

                series.push(opts);
            }

            var lineChart = new Highcharts.Chart({
                chart: {
                    renderTo: $(options.container)[0],
                    type: 'line',
                    backgroundColor: null,
                    plotBackgroundColor: null,
                    plotBorderWidth: null
                },
                credits: { enabled: false },
                title: {
                    text: options.data.Title,
                    align: 'left'
                },
                tooltip: {
                    formatter: options.tooltipFormatter
                },
                legend: {
                    borderRadius: 5,
                    borderColor: '#909090',
                    borderWidth: 1,
                    enabled: options.legendEnabled,
                    layout: $(window).width() <= _mobileResponsiveWidth ? 'vertical' : 'vertical',
                    align: $(window).width() <= _mobileResponsiveWidth ? 'center' : 'right',
                    verticalAlign: 'bottom',
                    y: $(window).width() <= _mobileResponsiveWidth ? 0 : -150,
                    itemStyle: {
                        fontWeight: 'normal',
                        color: '#3e576f'
                    }
                },
                plotOptions: { series: { events: { click: options.pointClickCallback } } },
                rangeSelector: { enabled: false },
                scrollbar: { enabled: false },
                navigator: { enabled: false },
                series: series,
                yAxis: Object.assign({
                            gridLineWidth: 1,
                            minPadding: 0,
                            title: null,
                            allowDecimals: true
                        }, options.yAxis),
                xAxis: Object.assign({
                            endOnTick: false,
                            min: 0,
                            minTickInterval: 1,
                            gridLineWidth: 0,
                            range: xAxislabels.length,
                            labels: { formatter: function () { return xAxislabels[this.value]; } }
                        }, options.xAxis)
            });
        },
        drawBarChart: function (options, series) {
            var defaults = {
                title: 'Chart Title',
                xAxisLabels: null,
                yAxisLabels: null,
                yAxisTitle: null,
                xAxisTitle: null,
                colors: null,
                colorByPoint: true,
                titleStyle: {
                    color: null,
                    fontWeight: null
                },
                xAxisStyle: {
                    color: null,
                    fontWeight: null
                },
                yAxisStyle: {
                    color: null,
                    fontWeight: null
                },
                yAxisLabelFormatter: null, //function
                pointClickCallback: null, //function
                tooltipFormatter: null //function
            };

            options = $.extend(defaults, options);

            Highcharts.setOptions({
                global: {
                    useUTC: false
                },
                lang: {
                    decimalPoint: '.',
                    thousandsSep: ','
                }
            });

            if (options.colors !== null) {
                options.colors = options.colors;
            } else {
                options.colors = resetToDefaultHighChartColors();
            }

            Highcharts.setOptions({
                colors: options.colors,
                lang: {
                    decimalPoint: '.',
                    thousandsSep: ','
                }
            });

            chart = new Highcharts.Chart({
                chart: {
                    type: 'column',
                    backgroundColor: null,
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    renderTo: options.elementId,
                    plotShadow: false,
                },
                credits: {
                    enabled: false
                },
                title: {
                    align: 'left',
                    text: options.chartTitle,
                    style: {
                        color: options.titleStyle.color,
                        fontWeight: options.titleStyle.fontWeight
                    }
                },
                xAxis: {
                    categories: options.xAxisLabels,
                    labels: {
                        formatter: function() {
                            return '<a>' + this.value + '</a>';
                        },
                        style: {
                            color: options.xAxisStyle.color
                        }
                    }
                },
                yAxis: {
                    labels: {
                        formatter: options.yAxisLabelFormatter
                    },
                    min: 0,
                    title: {
                        enabled: false,
                        text: options.yAxisTitle,
                        style: {
                            color: options.yAxisStyle.color,
                            fontWeight: options.yAxisStyle.fontWeight
                        }
                    }
                },
                tooltip: {
                    formatter: options.tooltipFormatter,
                    positioner: (!options.positioner) ? function (boxWidth, boxHeight, point) {
                        var locationValX = boxWidth + point.plotX;
                        if (locationValX <= chart.plotWidth) {
                            var x = point.plotX + 50;
                            return {
                                x: x,
                                y: point.plotY
                            };
                        }
                        var val = point.plotX - boxWidth + 15;
                        return {
                            x: val,
                            y: point.plotY
                        };
                    } : options.positioner
                },
                legend: {
                    enabled: true,
                    borderColor: '#909090',
                    borderWidth: 1,
                    borderRadius: 3,
                    itemStyle: { 'color': '#3e576f', 'fontWeight': 'normal' }
                },
                series: series,
                plotOptions: {
                    column: {
                        pointPadding: 0.2,
                        borderWidth: 0,
                        minPointLength: 3,
                        allowPointSelect: true,
                        cursor: 'pointer',
                        events: {
                            click: function (event) {
                                if (options.pointClickCallback !== null) {
                                    options.pointClickCallback(event.point);
                                }
                            }
                        }
                    }
                }
            });
        },
        drawGivingBarChart: function (options, data) {
            //TODO: PNB: Replace with drawRangeBarChart
            //TODO: MAF: improve default toolTipFormatter
            var defaults = {
                colors: null,
                colorByPoint: true,
                titleStyle: {
                    color: null,
                    fontWeight: null
                },
                xAxisStyle: {
                    color: null,
                    fontWeight: null
                },
                yAxisStyle: {
                    color: null,
                    fontWeight: null
                },
                yAxisLabelFormatter: null, //function
                pointClickCallback: null, //function
                tooltipFormatter: null //function
            };

            options = $.extend(defaults, options);

            var buildDataArray = function () {
                var points = [];
                var len = data.Points.length;
                for (var i = 0; i < len; i++) {
                    var item = {
                        name: data.Points[i].Label,
                        y: data.Points[i].YAxisValue,
                        numberOfGivers: data.Points[i].NumberOfGivers,
                        chartRangeId: data.Points[i].ChartRangeId,
                        isUnknownValue: data.Points[i].IsUnknownValue,
                        chartRangeIndex: data.Points[i].ChartRangeIndex,
                        getAverage: data.Points[i].GetAverage 
                    };
                    points.push(item);
                }
                return points;
            };

            Highcharts.setOptions({
                global: {
                    useUTC: false
                },
                lang: {
                decimalPoint: '.',
                thousandsSep: ','
            }
            });

            if (options.colors !== null) {
                options.colors = options.colors;
            } else {
                options.colors = resetToDefaultHighChartColors();
            }

            Highcharts.setOptions({
                colors: options.colors,
                lang: {
                    decimalPoint: '.',
                    thousandsSep: ','
                }
            });

            var seriesOptions = {
                type: 'column',
                name: options.seriesTitle,
                data: buildDataArray(),
                shadow: false
            };

            chart = new Highcharts.Chart({
                chart: {
                    renderTo: options.elementId,
                    backgroundColor: null,
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false,
                },
                credits: {
                    enabled: false
                },
                title: {
                    align: 'left',
                    text: data.Title,
                    style: {
                        color: options.titleStyle.color,
                        fontWeight: options.titleStyle.fontWeight
                    }
                },
                xAxis: {
                    categories: data.XAxisLabels,
                    labels: {
                        formatter: function () {
                            return '<a>' + this.value + '</a>';
                        },
                        style: {
                            color: options.xAxisStyle.color
                        }
                    },
                    title: {
                        text: data.XAxisTitle,
                        style: {
                            color: options.xAxisStyle.color,
                            fontWeight: options.xAxisStyle.fontWeight
                        }
                    }
                },
                yAxis: {
                    labels: {
                        formatter: options.yAxisLabelFormatter
                    },
                    min: 0,
                    title: {
                        text: data.YAxisTitle,
                        style: {
                            color: options.yAxisStyle.color,
                            fontWeight: options.yAxisStyle.fontWeight
                        }
                    },
                    allowDecimals: false
                },
                tooltip: {
                    formatter: options.tooltipFormatter,
                    positioner: (!options.positioner) ? function (boxWidth, boxHeight, point) {
                        var locationValX = boxWidth + point.plotX;
                        if (locationValX <= chart.plotWidth) {
                            var x = point.plotX + boxWidth - 5;
                            return {
                                x: x,
                                y: point.plotY
                            };
                        }
                        var val = point.plotX - 30;
                        return {
                            x: val,
                            y: point.plotY
                        };
                    } : options.positioner
                },
                legend: {
                    enabled: false
                },
                series: [seriesOptions],
                plotOptions: {
                    column: {
                        pointPadding: 0.2,
                        borderWidth: 0,
                        minPointLength: 3,
                        colorByPoint: options.colorByPoint,
                        allowPointSelect: true,
                        cursor: 'pointer',
                        events: {
                            click: function (event) {
                                if (options.pointClickCallback !== null) {
                                    options.pointClickCallback(event.point);
                                }
                            }
                        }
                    }
                }
            });
        },
        drawRangeBarChart: function (options, data) {
            var defaults = {
                colors: null,
                colorByPoint: true,
                titleStyle: {
                    color: null,
                    fontWeight: null
                },
                xAxisStyle: {
                    color: null,
                    fontWeight: null
                },
                yAxisStyle: {
                    color: null,
                    fontWeight: null
                },
                yAxisLabelFormatter: null, //function
                pointClickCallback: null, //function
                tooltipFormatter: null //function
            };

            options = $.extend(defaults, options);

            var buildDataArray = function () {
                var points = [];
                var len = data.Points.length;
                for (var i = 0; i < len; i++) {
                    var item = {
                        name: data.Points[i].Label,
                        y: data.Points[i].YAxisValue,
                        numberOfGivers: data.Points[i].NumberOfGivers,
                        chartRangeId: data.Points[i].ChartRangeId,
                        isUnknownValue: data.Points[i].IsUnknownValue,
                        chartRangeIndex: data.Points[i].ChartRangeIndex,
                        getAverage: data.Points[i].GetAverage
                    };
                    points.push(item);
                }
                return points;
            };

            Highcharts.setOptions({
                global: {
                    useUTC: false
                },
                lang: {
                    decimalPoint: '.',
                    thousandsSep: ','
                }
            });

            if (options.colors !== null) {
                options.colors = options.colors;
            } else {
                options.colors = resetToDefaultHighChartColors();
            }

            Highcharts.setOptions({
                colors: options.colors,
                lang: {
                    decimalPoint: '.',
                    thousandsSep: ','
                }
            });

            var seriesOptions = {
                type: 'column',
                name: options.seriesTitle,
                data: buildDataArray(),
                shadow: false
            };

            var toolTipFormatter = (options.tooltipFormatter === null || options.tooltipFormatter === undefined) ?
                function () {
                    return this.x + '<br />' + this.series.name  + ': <b>' + this.y + '</b>';
                } : options.tooltipFormatter;

            chart = new Highcharts.Chart({
                chart: {
                    renderTo: options.elementId,
                    backgroundColor: null,
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false,
                },
                credits: {
                    enabled: false
                },
                title: {
                    align: 'left',
                    text: data.Title,
                    style: {
                        color: options.titleStyle.color,
                        fontWeight: options.titleStyle.fontWeight
                    }
                },
                xAxis: {
                    categories: data.XAxisLabels,
                    labels: {
                        formatter: function () {
                            return '<a>' + this.value + '</a>';
                        },
                        style: {
                            color: options.xAxisStyle.color
                        }
                    },
                    title: {
                        text: data.XAxisTitle,
                        style: {
                            color: options.xAxisStyle.color,
                            fontWeight: options.xAxisStyle.fontWeight
                        }
                    }
                },
                yAxis: {
                    labels: {
                        formatter: options.yAxisLabelFormatter
                    },
                    min: 0,
                    title: {
                        text: data.YAxisTitle,
                        style: {
                            color: options.yAxisStyle.color,
                            fontWeight: options.yAxisStyle.fontWeight
                        }
                    },
                    allowDecimals: false
                },
                tooltip: {
                    formatter: toolTipFormatter,
                    positioner: (!options.positioner) ? function (boxWidth, boxHeight, point) {
                        var locationValX = boxWidth + point.plotX;
                        if (locationValX <= chart.plotWidth) {
                            var x = point.plotX + boxWidth - 5;
                            return {
                                x: x,
                                y: point.plotY
                            };
                        }
                        var val = point.plotX - 30;
                        return {
                            x: val,
                            y: point.plotY
                        };
                    } : options.positioner
                },
                legend: {
                    enabled: false
                },
                series: [seriesOptions],
                plotOptions: {
                    column: {
                        pointPadding: 0.2,
                        borderWidth: 0,
                        minPointLength: 3,
                        colorByPoint: options.colorByPoint,
                        allowPointSelect: true,
                        cursor: 'pointer',
                        events: {
                            click: function (event) {
                                if (options.pointClickCallback !== null) {
                                    options.pointClickCallback(event.point);
                                }
                            }
                        }
                    }
                }
            }, function (chart) { // on complete
                if (options.customTextOptions != undefined) {
                    if (options.customTextOptions.customTextFunction !== undefined) {
                        options.customTextOptions.customTextFunction(chart);
                    } else if (options.customTextOptions.customizeLinkId !== undefined && options.customTextOptions.customizeClickFunction !== undefined) {
                        chart.renderer.text('<a href="javascript:void(0)">Customize</a>',
                            chart.chartWidth - 100,
                            20
                        ).css({
                            color: '#319ACF',
                        }).attr({
                            id: options.customTextOptions.customizeLinkId,
                            zIndex: 5,
                        }).add();

                        $('#' + options.customTextOptions.customizeLinkId).click(function () {
                            options.customTextOptions.customizeClickFunction();
                        });
                    }
                }
            });
        }
    };
}();

STRATUS.ChartRange = function () {
    var _onSaveCallback;


    var createLogarithmicScale = function (minVal, maxVal, increment) {
        let logMax = Math.log(maxVal / increment);
        let logMin = minVal === 0 ? 0 : Math.log(minVal / increment);
        let scale = (logMax - logMin) / (maxVal - minVal);
        return {
            logMax: logMax,
            logMin: logMin,
            linMax: maxVal,
            linMin: minVal,
            increment: increment,
            scale: scale
        }
    }

    var linearToLog = function (position, logScale) {

        return Math.round(Math.exp((position + logScale.logMax - logScale.linMin) * logScale.scale + logScale.logMin)) * logScale.increment;
    }

    var logToLinear = function (position, logScale) {
        return Math.round(logScale.linMin + (Math.log(position / logScale.increment) - logScale.logMin) / logScale.scale);
    }

    var setMinNext = function (currentSlider, chartRanges, index) {
        var value, nextValues, minValue, maxValue;

        var currentListItem = $(currentSlider).parent().parent();
        var next = currentListItem.next('li').find('.rangeSlider');

        nextValues = $(next).slider('option', 'values');
        minValue = nextValues[0];
        maxValue = nextValues[1];

        value = $(currentSlider).slider('option', 'value');
        if (chartRanges.IsDiscrete) {
            value++;
        }

        if (value > maxValue)
            maxValue = value;

        if (minValue !== value) {
            $(next).slider('option', 'values', [value, maxValue]);
            if (chartRanges.UseLogarithmicScale) {
                chartRanges.ChartRangeRows[index + 1].PrevBeginVal = value;
                chartRanges.ChartRangeRows[index + 1].PrevEndVal = maxValue;
            }
        }
    };

    var setMaxPrev = function (currentSlider, chartRanges, index) {
        var value, previousValues, minValue, maxValue;

        var currentListItem = $(currentSlider).parent().parent();
        var previous = currentListItem.prev('li').find('.rangeSlider');

        previousValues = $(previous).slider('option', 'values');
        minValue = previousValues[0];
        maxValue = previousValues[1];

        value = $(currentSlider).slider('option', 'value');
        if (chartRanges.IsDiscrete) {
            value--;
        }

        if (value < minValue)
            minValue = value;

        if (maxValue !== value) {
            $(previous).slider('option', 'values', [minValue, value]);
            if (chartRanges.UseLogarithmicScale) {
                chartRanges.ChartRangeRows[index - 1].PrevBeginVal = minValue;
                chartRanges.ChartRangeRows[index - 1].PrevEndVal = value;
            }
        }
    };

    var setDefaultPrev = function (currentSlider, chartRanges, index) {
        var values, previousValues, minValue, previousMinValue, previousMaxValue;

        var currentListItem = $(currentSlider).parent().parent();
        var previous = currentListItem.prev('li').find('.rangeSlider');

        values = $(currentSlider).slider('option', 'values');
        minValue = values[0];

        if (chartRanges.IsDiscrete) {
            minValue--;
        }

        var previousType = $(previous).slider('option', 'range');

        if (previousType === 'min') {
            previousMinValue = $(previous).slider('option', 'value');

            if (previousMinValue !== minValue) {
                $(previous).slider('option', 'value', minValue);
            }
        } else {
            previousValues = $(previous).slider('option', 'values');
            previousMinValue = previousValues[0];
            previousMaxValue = previousValues[1];

            if (previousMinValue > minValue) {
                previousMinValue = minValue;
            }

            if (previousMaxValue !== minValue) {
                $(previous).slider('option', 'values', [previousMinValue, minValue]);
                if (chartRanges.UseLogarithmicScale) {
                    chartRanges.ChartRangeRows[index - 1].PrevBeginVal = previousMinValue;
                    chartRanges.ChartRangeRows[index - 1].PrevEndVal = minValue;
                }
            }
        }
    };

    var setDefaultNext = function (currentSlider, chartRanges, index) {
        var values, nextValues, maxValue, nextMinValue, nextMaxValue;

        var currentListItem = $(currentSlider).parent().parent();
        var next = currentListItem.next('li').find('.rangeSlider');

        values = $(currentSlider).slider('option', 'values');
        maxValue = values[1];
        if (chartRanges.IsDiscrete) {
            maxValue++;
        }

        var nextType = $(next).slider('option', 'range');

        if (nextType === 'max') {
            nextMaxValue = $(next).slider('option', 'value');

            if (nextMaxValue !== maxValue) {
                $(next).slider('option', 'value', maxValue);
            }
        } else {
            nextValues = $(next).slider('option', 'values');
            nextMinValue = nextValues[0];
            nextMaxValue = nextValues[1];

            if (nextMaxValue < maxValue) {
                nextMaxValue = maxValue;
            }

            if (nextMinValue !== maxValue) {
                $(next).slider('option', 'values', [maxValue, nextMaxValue]);
                if (chartRanges.UseLogarithmicScale) {
                    chartRanges.ChartRangeRows[index + 1].PrevBeginVal = maxValue;
                    chartRanges.ChartRangeRows[index + 1].PrevEndVal = nextMaxValue;
                }
            }
        }
    };

    var setDefaultPrevLog = function (currentSlider, chartRanges, index) {
        var previousValues, minValue, previousMinValue, previousMaxValue;

        var currentListItem = $(currentSlider).parent().parent();
        var previous = currentListItem.prev('li').find('.rangeSlider');
        let item = chartRanges.ChartRangeRows[index];
        let prevItem = chartRanges.ChartRangeRows[index - 1];

        minValue = item.BeginRangeLog;

        if (chartRanges.IsDiscrete) {
            minValue--;
        }

        var previousType = $(previous).slider('option', 'range');

        if (previousType === 'min') {
            previousMinValue = prevItem.BeginRangeLog;

            if (previousMinValue !== minValue) {
                chartRanges.ChartRangeRows[0].EndRangeLog = minValue;
                chartRanges.ChartRangeRows[0].PrevEndVal--;
            }
        } else {
            previousValues = [prevItem.BeginRangeLog, prevItem.EndRangeLog];
            previousMinValue = previousValues[0];
            previousMaxValue = previousValues[1];

            if (previousMinValue > minValue) {
                previousMinValue = minValue;
            }

            if (previousMaxValue !== minValue) {
                chartRanges.ChartRangeRows[index - 1].BeginRangeLog = previousMinValue;
                chartRanges.ChartRangeRows[index - 1].EndRangeLog = minValue;
            }
        }
    };

    var setDefaultNextLog = function (currentSlider, chartRanges, index) {
        var nextValues, maxValue, nextMinValue, nextMaxValue;

        var currentListItem = $(currentSlider).parent().parent();
        var next = currentListItem.next('li').find('.rangeSlider');
        let item = chartRanges.ChartRangeRows[index];
        let nextItem = chartRanges.ChartRangeRows[index + 1];

        maxValue = item.EndRangeLog + 1;

        var nextType = $(next).slider('option', 'range');

        if (nextType === 'max') {
            nextMaxValue = nextItem.BeginRangeLog;

            if (nextMaxValue !== maxValue) {
                chartRanges.ChartRangeRows[chartRanges.ChartRangeRows.length - 1].BeginRangeLog = maxValue;
                chartRanges.ChartRangeRows[chartRanges.ChartRangeRows.length - 1].PrevBeginVal++;
            }
        } else {
            nextValues = [nextItem.BeginRangeLog, nextItem.EndRangeLog];
            nextMinValue = nextValues[0];
            nextMaxValue = nextValues[1];
 
            if (nextMaxValue < maxValue) {
                nextMaxValue = maxValue;
            }

            if (nextMinValue !== maxValue) {
                chartRanges.ChartRangeRows[index + 1].BeginRangeLog = maxValue;
                chartRanges.ChartRangeRows[index + 1].EndRangeLog = nextMaxValue;
            }
        }
    };

    var setMaxPrevLog = function (chartRanges, index) {
        var value, minValue, maxValue;

        let item = chartRanges.ChartRangeRows[index];
        let prevItem = chartRanges.ChartRangeRows[index - 1];

        minValue = prevItem.BeginRangeLog;
        maxValue = prevItem.EndRangeLog;

        value = item.BeginRangeLog;
        if (chartRanges.IsDiscrete) {
            value--;
        }

        if (value < minValue)
            minValue = value;

        if (maxValue !== value) {
            chartRanges.ChartRangeRows[index - 1].BeginRangeLog = minValue;
            chartRanges.ChartRangeRows[index - 1].EndRangeLog = value;
        }
    };

    var setMinNextLog = function (chartRanges, index) {
        var value, minValue, maxValue;

        let item = chartRanges.ChartRangeRows[index];
        let nextItem = chartRanges.ChartRangeRows[index + 1];

        minValue = nextItem.BeginRangeLog;
        maxValue = nextItem.EndRangeLog;

        value = item.EndRangeLog + 1;

        if (value > maxValue)
            maxValue = value;

        if (minValue !== value) {
            chartRanges.ChartRangeRows[1].BeginRangeLog = value;
            chartRanges.ChartRangeRows[1].EndRangeLog = maxValue;
        }
    };

    var initializeSliders = function (chartRanges) {
        var items = chartRanges.ChartRangeRows;
        let useLogScale = chartRanges.UseLogarithmicScale;

        for (var i = 0; i < items.length; i++) {
            var rangeType,
                sliderMin,
                sliderMax;

            if (i === 0) {
                rangeType = 'min';
            } else if (i === items.length - 1) {
                rangeType = 'max';
            } else {
                rangeType = true;
            }

            if (chartRanges.IsDiscrete) {
                sliderMin = chartRanges.Min + i;
                sliderMax = chartRanges.Max - items.length + 1 + i;
            };

            if (useLogScale) {
                items[i].sliderMax = sliderMax;
                items[i].sliderMin = chartRanges.LogarithmicIncrement - (items.length - sliderMin) + 1;
            }
           
            var slider = {
                range: rangeType,
                min: chartRanges.IsDiscrete ? sliderMin : chartRanges.Min,
                max: chartRanges.IsDiscrete ? sliderMax : chartRanges.Max,
                step: 1,
                animate: true,
                change: function () {
                    var currentType = $(this).slider('option', 'range');
                    let index = parseInt($(this).attr('id').split('_')[1], 10);

                    if (currentType === true) {
                        if (useLogScale) {
                            setDefaultPrevLog($(this), chartRanges, index);
                            setDefaultNextLog($(this), chartRanges, index);
                        }
                        setDefaultPrev($(this), chartRanges, index);
                        setDefaultNext($(this), chartRanges, index);
                    } else if (currentType === 'max') {
                        if (useLogScale) {
                            setMaxPrevLog(chartRanges, index);
                        }
                        setMaxPrev($(this), chartRanges, index);
                    } else {
                        if (useLogScale) {
                            setMinNextLog(chartRanges, index);
                        }
                        setMinNext($(this), chartRanges, index);
                    }

                    var nameParts = $(this).attr('id').split('rangeSlider');
                    var chartType = nameParts[1].split('_');
                    rangeSliderChanged(chartType[0], chartRanges);
                },
                slide: function (event, ui) {
                    var current = $(this);
                    var type = current.slider('option', 'range');
                    if (type === true) {
                        let firstVal = useLogScale ? linearToLog(ui.values[0], chartRanges.logScale) : ui.values[0];
                        let lastVal = useLogScale ? linearToLog(ui.values[1], chartRanges.logScale) : ui.values[1];

                        if (useLogScale) {
                            let index = parseInt($(this).attr('id').split('_')[1], 10);
                            
                            if (lastVal > chartRanges.ChartRangeRows[index].sliderMax) {
                                lastVal = chartRanges.ChartRangeRows[index].sliderMax;
                            }

                            if (firstVal === chartRanges.LogarithmicIncrement) {
                                firstVal = chartRanges.ChartRangeRows[index].sliderMin;
                            }

                            if (chartRanges.ChartRangeRows[index].PrevBeginVal !== ui.values[0]) {
                                chartRanges.ChartRangeRows[index].BeginRangeLog = firstVal;
                                chartRanges.ChartRangeRows[index].PrevBeginVal = ui.values[0];
                            } else {
                                firstVal = chartRanges.ChartRangeRows[index].BeginRangeLog;
                            }

                            if (chartRanges.ChartRangeRows[index].PrevEndVal !== ui.values[1]) {
                                chartRanges.ChartRangeRows[index].EndRangeLog = lastVal;
                                chartRanges.ChartRangeRows[index].PrevEndVal = ui.values[1];
                            } else {
                                lastVal = chartRanges.ChartRangeRows[index].EndRangeLog;
                            }
                        } 

                        current.find('.ui-slider-handle:first').text(ui.values[0] ? firstVal.toLocaleString() : ui.values[0]);
                        current.find('.ui-slider-handle:last').text(ui.values[1] ? lastVal.toLocaleString() : ui.values[1]);
                    } else {
                        let val = useLogScale ? linearToLog(ui.value, chartRanges.logScale) : ui.value;

                        if (useLogScale) {
                            let index = parseInt($(this).attr('id').split('_')[1], 10);

                            if (val > chartRanges.ChartRangeRows[index].sliderMax) {
                                val = chartRanges.ChartRangeRows[index].sliderMax;
                            }

                            chartRanges.ChartRangeRows[index].BeginRangeLog = val;
                            chartRanges.ChartRangeRows[index].EndRangeLog = val;
                        }

                        current.find('.ui-slider-handle').text(ui.value ? val.toLocaleString() : ui.value);
                    }
                }
            };

            let br, er;
            if (rangeType === true) {
                br = useLogScale ? logToLinear(items[i].BeginRange, chartRanges.logScale) : items[i].BeginRange;
                er = useLogScale ? logToLinear(items[i].EndRange, chartRanges.logScale) : items[i].EndRange;

                if (chartRanges.IsDiscrete) {
                    br++;
                }
                slider.values = [br, er];
            } else if (rangeType === 'min') {
                er = useLogScale ? logToLinear(items[i].EndRange, chartRanges.logScale) : items[i].EndRange;
                slider.value = er;
            } else {
                br = useLogScale ? logToLinear(items[i].BeginRange, chartRanges.logScale) : items[i].BeginRange;
                if (chartRanges.IsDiscrete) {
                    br++;
                }
                slider.value = br;
            }

            if (useLogScale) {
                chartRanges.ChartRangeRows[i].BeginRangeLog = items[i].BeginRange + 1;
                chartRanges.ChartRangeRows[i].EndRangeLog = items[i].EndRange;
                chartRanges.ChartRangeRows[i].PrevBeginVal = br;
                chartRanges.ChartRangeRows[i].PrevEndVal = er;
            } 

            $('#rangeSlider' + chartRanges.ChartType + '_' + i).slider(slider);
        }
    };

    var rangeSliderChanged = function (chartRangeType, chartRanges) {
        $(".rangeSlider[id^='rangeSlider" + chartRangeType + "']").each(function (i) {
            var current = $(this);
            var values = current.slider('option', 'values');
            let useLogScale = chartRanges.UseLogarithmicScale;

            if (values == null) {
                values = [current.slider('option', 'value')];
            }

            let beginRange = useLogScale ? chartRanges.ChartRangeRows[i].BeginRangeLog : values[0];
            let endRange = useLogScale ? chartRanges.ChartRangeRows[i].EndRangeLog : values[1];

            if (useLogScale && current.slider('option', 'range') === 'min') {
                beginRange = endRange;
            }

            current.find('.ui-slider-handle:first').text(values[0] && beginRange != undefined ? beginRange.toLocaleString() : values[0]);
            current.find('.ui-slider-handle:last').text(values[1] && endRange != undefined ? endRange.toLocaleString() : values[1]);
        });
    };

    var saveRanges = function (chartRanges) {
        var chartRangeType = chartRanges.ChartType;
        let useLogScale = chartRanges.UseLogarithmicScale;
        var chartRangeRows = [];

        $(".rangeSlider[id^='rangeSlider" + chartRangeType + "']").each(function (i) {
            var beginRange, endRange;
            var current = $(this);
            let item = chartRanges.ChartRangeRows[i];

            var type = $(current).slider('option', 'range');

            var values = current.slider('option', 'values');

            if (values == null) {
                values = [current.slider('option', 'value')];
            }

            if (type === "min") {
                beginRange = chartRanges.Min;
                endRange = useLogScale ? item.EndRangeLog : values[0];
            } else if (type === "max") {
                beginRange = useLogScale ? item.BeginRangeLog : values[0];
                endRange = chartRanges.HasHardMax ? chartRanges.Max : null;
            } else {
                beginRange = useLogScale ? item.BeginRangeLog : values[0];
                endRange = useLogScale ? item.EndRangeLog : values[1];
            }

            if (chartRanges.IsDiscrete && type !== 'min') {
                beginRange--;
            }

            var nameParts = current.attr('id').split('_');

            var range = {
                ChartRangeRowId: current.data('chartRangeRowId'),
                RowIndex: nameParts[1],
                BeginRange: beginRange,
                EndRange: endRange
            };

            chartRangeRows.push(range);
        });

        var includeUnkownValue = $('#includeUnknownValue_' + +chartRangeType).prop('checked') || false;

        var args = {
            ChartRangeId: chartRanges.ChartRangeId,
            IncludeUnknownValue: includeUnkownValue,
            ChartRangeRows: chartRangeRows
        };
 
        $.ajax({
            url: STRATUS.Config.SiteUrl + '/Home/SaveChartRanges',
            data: {
                args: JSON.stringify(args),
                chartRangeType: chartRangeType
            },
            success: function () {
                $.lightBox('hide');
                if ($.isFunction(_onSaveCallback)) {
                    _onSaveCallback();
                } else {
                    location.reload();
                }
            }
        });
    };

    var resetToDefaults = function (chartRanges) {
        $.ajax({
            url: STRATUS.Config.SiteUrl + '/Home/ResetDefaultChartRanges',
            data: {
                chartRangeType: chartRanges.ChartType,
                min: chartRanges.Min,
                max: chartRanges.Max,
                isDiscrete: chartRanges.IsDiscrete,
                useLogarithmicScale: chartRanges.UseLogarithmicScale,
                logarithmicIncrement: chartRanges.LogarithmicIncrement
            },
            success: function (response) {
                if (response.UseLogarithmicScale) {
                    response.logScale =
                        createLogarithmicScale(response.Min, response.Max, response.LogarithmicIncrement);
                    chartRanges.ChartRangeRows = response.ChartRangeRows;
                    initializeSliders(chartRanges);
                } else {
                    initializeSliders(response);
                }

                if ($('#includeUnknownValue_' + chartRanges.ChartType).length > 0) {
                    $('#includeUnknownValue_' + chartRanges.ChartType).prop('checked', response.IncludeUnknownValue);
                }
            }
        });
    };

    return {
        init: function (chartRanges) {
            if (chartRanges && chartRanges.OnSaveCallback) {
                _onSaveCallback = eval(chartRanges.OnSaveCallback);
            }

            if (chartRanges.UseLogarithmicScale) {
                chartRanges.logScale = createLogarithmicScale(chartRanges.Min, chartRanges.Max, chartRanges.LogarithmicIncrement);
            }

            initializeSliders(chartRanges);

            $('#saveChartRanges_' + chartRanges.ChartType).click(function () {
                saveRanges(chartRanges);
            });

            $('#cancelChartRanges_' + chartRanges.ChartType).click(function () {
                initializeSliders(chartRanges);
                $.lightBox('hide');
            });

            $('#resetLevels_' + chartRanges.ChartType).click(function () {
                resetToDefaults(chartRanges);
            });

            $('#customize-age-range-dialog .ui-slider-handle, #customize-chart-range-dialog .ui-slider-handle')
                .mousedown(function () {
                    let zMax = 0;
                    $('#customize-age-range-dialog .ui-slider-handle, #customize-chart-range-dialog .ui-slider-handle').each(function () {
                        let curZIndex = parseInt($(this).css('z-index'));
                        if (curZIndex > zMax) {
                            zMax = curZIndex;
                        }
                    });

                    $(this).css('z-index', zMax + 1);
                });

            rangeSliderChanged(chartRanges.ChartType, chartRanges);
        }
    };
}();

STRATUS.Charts.D3 = function () {
    var _colorPalette = [
        '#319ACF', '#79B70C', '#F0A422', '#17607C', '#A52000', '#77818B', '#78BDDF'
    ];

    var _numTicks = 5; // Approximate number of desired ticks

    var getDefaults = function () {
        return {
            axis: {
                y: {
                    label: {
                        position: 'outer-middle'
                    },

                    padding: {
                        bottom: 0 // Prevent double line near X-axis
                    },

                    tick: {
                        values: function (yExtremes) {
                            return d3.scaleLinear()
                                .domain(yExtremes)
                                .nice(_numTicks)
                                .ticks(_numTicks);
                        }
                    }
                },

                x: {
                    type: 'categories',
                    tick: {
                        outer: true,
                        multiline: false
                    }
                }
            },
            color: {
                pattern: _colorPalette
            },
            tooltip: {
                // Make tooltip table not-responsive
                contents: function (d, defaultTitleFormat, defaultValueFormat, color) {
                    return this.getTooltipContent(d, defaultTitleFormat, defaultValueFormat, color)
                        .replace('class=\'c3-tooltip\'', 'class=\'c3-tooltip not-responsive\'');
                }
            },
            legend: {
                item: {
                    onclick: function (id) {
                        if (this.d3.event.altKey) {
                            this.api.hide();
                            this.api.show(id);
                        } else {
                            this.api.toggle(id);
                            if (!this.isTargetToShow(id))
                                this.api.revert();
                        }
                    }
                }
            }
        }
    };

    var lineChart = function (options) {
        var defaultOptions = $.extend(true,
            getDefaults(),
            {
                data: {
                    type: 'line',
                    order: null
                },
                grid: {
                    y: {
                        show: true // Show gridlines
                    }
                },
                point: {
                    r: 4 // Make data points larger
                }
            }
        );

        var chart = c3.generate($.extend(true, defaultOptions, options));

        // Display data points on top of X axis.
        var chartLayer = d3.select(chart.element).select("." + c3.chart.internal.fn.CLASS.chart);
        var chartLayerParentNode = chartLayer.node().parentNode;
        var chartLayerNode = chartLayer.remove();

        chartLayerParentNode.appendChild(chartLayerNode.node());
        chartLayer.attr("clip-path", null);

        return chart;
    };

    var barChart = function (options) {
        var defaultOptions = $.extend(true,
            getDefaults(),
            {
                data: {
                    type: 'bar',
                    order: null
                },
                grid:
                {
                    y: {
                        show: true // Show gridlines
                    },
                    focus: {
                        show: false // Hide vertical line on hover
                    }
                }
            }
        );

        return c3.generate($.extend(true, defaultOptions, options));
    };

    return {
        lineChart: lineChart,
        barChart: barChart
    };
}();;
STRATUS.CustomFields = function () {
    return {
        getCustomFields: function (container) {
            container = container || 'body';

            var customFields = [];
            $(container + ' .form-field:visible').each(function () {
                var field = $(this),
                    fieldId = field.data('fieldId'),
                    fieldValue;

                if (field.find('.js-multi-select-list').length !== 0) {
                    fieldValue = field.find('.js-multi-select-list').multiSelectList('getValue');

                    if (fieldValue) {
                        fieldValue = fieldValue.join(',');
                    }
                }
                else if (field.find('.select-list').length !== 0) {
                    fieldValue = field.find('.select-list').selectList('getValue');
                } else if (field.find('.dateField').length !== 0) {
                    fieldValue = field.find('.dateField').datePicker('getValue');
                } else {
                    fieldValue = $.trim(field.find('input, select, textarea').val());
                }

                customFields.push({ Key: fieldId, Value: fieldValue });
            });

            return customFields;
        }
    };
}();;
// TODO: Remove EmailHistorySummary component from Particle. #ui-redesign
Vue.component('email-history', {
    data() {
        return {
            isActive: false,
            isLoaded: false,
            errorOccurred: false,
            emails: [],
            maxSubjectLength: 25,
            maxBodyLength: 33,
            allHistoryUrl: `${STRATUS.Config.SiteUrl}/Communications/EmailHistory`
        }
    },
    methods: {
        getEmailList() {
            const vm = this;

            vm.isActive = !vm.isActive;

            if (vm.isLoaded) {
                return;
            }

            vm.reset();

            $.ajax({
                url: `${STRATUS.Config.SiteUrl}/Communications/GetLatestEmailHistorySummary`
            }).done(function (result) {
                if (result) {
                    vm.emails = result;
                    vm.isLoaded = true;
                }
            }).fail(function () {
                vm.errorOccurred = true;
                vm.isLoaded = false;
            });
        },
        emailDetailUrl(id) {
            return `${STRATUS.Config.SiteUrl}/Communications/EmailDetail/${id || ''}`;
        },
        reset() {
            this.errorOccurred = false;
            this.emails = [];
        }
    },
    mounted() {
        const vm = this;

        vm.$nextTick(() => {
            document.addEventListener('click', function (event) {
                if (!event.target.closest('.u-header__email-history')) {
                    vm.isActive = false;
                }
            });
        });
    },
    template: `
<div class="u-header__email-history hidden-sm relative" v-bind:class="{ active: isActive }">
    <a class="u-header__icon icon icon-envelope-outline" href="javascript:void(0);" v-on:click="getEmailList()"></a>
    <div v-show="isActive && !errorOccurred" class="u-header__menu u-menu">
        <ul v-if="!isLoaded">
            <li>
                <a href="javascript:void(0);">Loading...</a>
            </li>
        </ul>
        <ul v-else>
            <li v-for="log in emails" v-bind:key="log.CommunicationId">
                <a v-bind:href="emailDetailUrl(log.CommunicationId)">\
                    <div class="flex">
                        <div class="text-bold flex__fill">{{log.Subject | truncate(maxSubjectLength)}}</div>
                        <div class="text-muted text-fine email-date">{{log.CommunicationDate | date('MMM DD')}}</div> 
                        <span class="icon icon-arrow-right text-medium"></span>
                    </div>
                    <div>{{log.Body | truncate(maxBodyLength)}}</div>
                </a>
            </li>
            <li v-if="emails.length"><a class="text-bold" v-bind:href="allHistoryUrl">See all email history</a></li>
            <li v-else>
                <a v-bind:href="allHistoryUrl"><em>No email history</em></a>
            </li>
        </ul>
    </div>
</div>`
});;
/*
* THIS FILE HAS BEEN AUTOMATICALLY GENERATED
*
* Changes to this file may cause incorrect behavior
* and will be lost when the file is regenerated.
**/

STRATUS.EnumImports = function () {
	return {
		PledgeSource: {
			None: {'Name':'None','Value':0,'Index':0,'Text':'','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeSource'},
			Staff: {'Name':'Staff','Value':1,'Index':1,'Text':'Staff','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeSource'},
			Mobile: {'Name':'Mobile','Value':2,'Index':2,'Text':'Mobile','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeSource'},
			Online: {'Name':'Online','Value':3,'Index':3,'Text':'Online','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeSource'},
			Embed: {'Name':'Embed','Value':4,'Index':4,'Text':'Embed','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeSource'}
		},
		PledgeFrequency: {
			AsCan: {'Name':'AsCan','Value':0,'Index':0,'Text':'As can','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeFrequency'},
			Weekly: {'Name':'Weekly','Value':1,'Index':1,'Text':'Once a week','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeFrequency'},
			BiWeekly: {'Name':'BiWeekly','Value':2,'Index':2,'Text':'Every two weeks','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeFrequency'},
			Monthly: {'Name':'Monthly','Value':3,'Index':3,'Text':'Once a month','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeFrequency'},
			SemiMonthly: {'Name':'SemiMonthly','Value':4,'Index':4,'Text':'Twice a month','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeFrequency'},
			Quarterly: {'Name':'Quarterly','Value':5,'Index':5,'Text':'Every three months','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeFrequency'},
			Annually: {'Name':'Annually','Value':6,'Index':6,'Text':'Annually','FullName':'AcsTech.Stratus.Core.Domain.Enums.PledgeFrequency'}
		},
		ImportPeopleField: {
			Title: {'Name':'Title','Value':0,'Index':0,'Text':'Title','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			FirstName: {'Name':'FirstName','Value':1,'Index':1,'Text':'First Name','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			MiddleName: {'Name':'MiddleName','Value':2,'Index':2,'Text':'Middle Name','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			LastName: {'Name':'LastName','Value':3,'Index':3,'Text':'Last Name','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			Suffix: {'Name':'Suffix','Value':4,'Index':4,'Text':'Suffix','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			PreferredName: {'Name':'PreferredName','Value':5,'Index':5,'Text':'Preferred Name','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			PrimaryAddress1: {'Name':'PrimaryAddress1','Value':6,'Index':6,'Text':'Primary Address Line 1','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			PrimaryAddress2: {'Name':'PrimaryAddress2','Value':7,'Index':7,'Text':'Primary Address Line 2','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			PrimaryCity: {'Name':'PrimaryCity','Value':8,'Index':8,'Text':'Primary Address City','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			PrimaryRegion: {'Name':'PrimaryRegion','Value':9,'Index':9,'Text':'Primary Address Region','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			PrimaryPostalCode: {'Name':'PrimaryPostalCode','Value':10,'Index':10,'Text':'Primary Address Postal Code','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			PrimaryCountry: {'Name':'PrimaryCountry','Value':11,'Index':11,'Text':'Primary Address Country','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			AlternateAddress1: {'Name':'AlternateAddress1','Value':12,'Index':12,'Text':'Alternate Address Line 1','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			AlternateAddress2: {'Name':'AlternateAddress2','Value':13,'Index':13,'Text':'Alternate Address Line 2','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			AlternateCity: {'Name':'AlternateCity','Value':14,'Index':14,'Text':'Alternate Address City','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			AlternateRegion: {'Name':'AlternateRegion','Value':15,'Index':15,'Text':'Alternate Address Region','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			AlternatePostalCode: {'Name':'AlternatePostalCode','Value':16,'Index':16,'Text':'Alternate Address Postal Code','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			AlternateCountry: {'Name':'AlternateCountry','Value':17,'Index':17,'Text':'Alternate Address Country','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			HomePhone: {'Name':'HomePhone','Value':18,'Index':18,'Text':'Home Phone','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			MobilePhone: {'Name':'MobilePhone','Value':19,'Index':19,'Text':'Mobile Phone','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			WorkPhone: {'Name':'WorkPhone','Value':20,'Index':20,'Text':'Work Phone','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			OtherPhone: {'Name':'OtherPhone','Value':21,'Index':21,'Text':'Other Phone','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			PrimaryEmail: {'Name':'PrimaryEmail','Value':22,'Index':22,'Text':'Primary Email','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			AlternateEmail: {'Name':'AlternateEmail','Value':23,'Index':23,'Text':'Alternate Email','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			Birthdate: {'Name':'Birthdate','Value':24,'Index':24,'Text':'Birthdate','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			FamilyPosition: {'Name':'FamilyPosition','Value':25,'Index':25,'Text':'Family Position','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			MaritalStatus: {'Name':'MaritalStatus','Value':26,'Index':26,'Text':'Marital Status','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			Gender: {'Name':'Gender','Value':27,'Index':27,'Text':'Gender','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			MemberStatus: {'Name':'MemberStatus','Value':28,'Index':28,'Text':'Member Status','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			Campus: {'Name':'Campus','Value':29,'Index':29,'Text':'Campus','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			FamilyKey: {'Name':'FamilyKey','Value':30,'Index':30,'Text':'Family Key','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			_ErrorMessage: {'Name':'_ErrorMessage','Value':31,'Index':31,'Text':'[Error]','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'},
			_FamilyId: {'Name':'_FamilyId','Value':32,'Index':32,'Text':'[Family Id]','FullName':'AcsTech.Stratus.Core.Domain.Enums.ImportPeople.ImportPeopleField'}
		},
		RecurringGiftFrequency: {
			OneTime: {'Name':'OneTime','Value':0,'Index':0,'Text':'Once','FullName':'AcsTech.Stratus.Core.Domain.Enums.OnlinePayments.RecurringGiftFrequency'},
			Weekly: {'Name':'Weekly','Value':1,'Index':1,'Text':'Every week','FullName':'AcsTech.Stratus.Core.Domain.Enums.OnlinePayments.RecurringGiftFrequency'},
			EveryTwoWeeks: {'Name':'EveryTwoWeeks','Value':2,'Index':2,'Text':'Every two weeks','FullName':'AcsTech.Stratus.Core.Domain.Enums.OnlinePayments.RecurringGiftFrequency'},
			Monthly: {'Name':'Monthly','Value':3,'Index':3,'Text':'Every month','FullName':'AcsTech.Stratus.Core.Domain.Enums.OnlinePayments.RecurringGiftFrequency'},
			TwiceAMonth: {'Name':'TwiceAMonth','Value':4,'Index':4,'Text':'Twice a month','FullName':'AcsTech.Stratus.Core.Domain.Enums.OnlinePayments.RecurringGiftFrequency'},
			EveryThreeMonths: {'Name':'EveryThreeMonths','Value':5,'Index':5,'Text':'Every three months','FullName':'AcsTech.Stratus.Core.Domain.Enums.OnlinePayments.RecurringGiftFrequency'}
		},
		WitnessTypes: {
			None: {'Name':'None','Value':0,'Index':0,'Text':'None','FullName':'AcsTech.Realm.System.Data.Enums.Clergy.WitnessTypes'},
			Witness: {'Name':'Witness','Value':1,'Index':1,'Text':'Witness','FullName':'AcsTech.Realm.System.Data.Enums.Clergy.WitnessTypes'},
			Officiant: {'Name':'Officiant','Value':2,'Index':2,'Text':'Officiant','FullName':'AcsTech.Realm.System.Data.Enums.Clergy.WitnessTypes'},
			Presider: {'Name':'Presider','Value':3,'Index':3,'Text':'Presider','FullName':'AcsTech.Realm.System.Data.Enums.Clergy.WitnessTypes'},
			License: {'Name':'License','Value':4,'Index':4,'Text':'License Witness','FullName':'AcsTech.Realm.System.Data.Enums.Clergy.WitnessTypes'}
		},
		IncludedLabelParts: {
			Title: {'Name':'Title','Value':1,'Index':0,'Text':'Title','FullName':'AcsTech.Realm.Data.Enums.System.IncludedLabelParts'},
			FirstOrPreferred: {'Name':'FirstOrPreferred','Value':2,'Index':1,'Text':'First Or Preferred','FullName':'AcsTech.Realm.Data.Enums.System.IncludedLabelParts'},
			FirstName: {'Name':'FirstName','Value':4,'Index':2,'Text':'First Or Preferred','FullName':'AcsTech.Realm.Data.Enums.System.IncludedLabelParts'},
			MiddleName: {'Name':'MiddleName','Value':8,'Index':3,'Text':'Middle Name','FullName':'AcsTech.Realm.Data.Enums.System.IncludedLabelParts'},
			LastName: {'Name':'LastName','Value':16,'Index':4,'Text':'Last Name','FullName':'AcsTech.Realm.Data.Enums.System.IncludedLabelParts'},
			Suffix: {'Name':'Suffix','Value':32,'Index':5,'Text':'Suffix','FullName':'AcsTech.Realm.Data.Enums.System.IncludedLabelParts'},
			MaidenName: {'Name':'MaidenName','Value':64,'Index':6,'Text':'Maiden Name','FullName':'AcsTech.Realm.Data.Enums.System.IncludedLabelParts'},
			TitleIfDoctor: {'Name':'TitleIfDoctor','Value':128,'Index':7,'Text':'Title If Doctor','FullName':'AcsTech.Realm.Data.Enums.System.IncludedLabelParts'},
			LastNameIfDifferent: {'Name':'LastNameIfDifferent','Value':256,'Index':8,'Text':'Last Name If Different','FullName':'AcsTech.Realm.Data.Enums.System.IncludedLabelParts'},
			FirstNameIfLastNameDiff: {'Name':'FirstNameIfLastNameDiff','Value':512,'Index':9,'Text':'First Name If Last Name Different','FullName':'AcsTech.Realm.Data.Enums.System.IncludedLabelParts'}
		},
		ChangeLogAction: {
			Add: {'Name':'Add','Value':0,'Index':0,'Text':'Add','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Edit: {'Name':'Edit','Value':1,'Index':1,'Text':'Edit','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Delete: {'Name':'Delete','Value':2,'Index':2,'Text':'Delete','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Deactivate: {'Name':'Deactivate','Value':3,'Index':3,'Text':'Deactivate','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Reactivate: {'Name':'Reactivate','Value':4,'Index':4,'Text':'Reactivate','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Merge: {'Name':'Merge','Value':5,'Index':5,'Text':'Merge','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Cancel: {'Name':'Cancel','Value':6,'Index':6,'Text':'Cancel','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			MassChange: {'Name':'MassChange','Value':7,'Index':7,'Text':'Edit Multiple','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			SacramentsMigration: {'Name':'SacramentsMigration','Value':8,'Index':8,'Text':'Sacraments Migration','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Move: {'Name':'Move','Value':9,'Index':9,'Text':'Move','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			MakePrivate: {'Name':'MakePrivate','Value':10,'Index':10,'Text':'Make Private','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Reinstate: {'Name':'Reinstate','Value':11,'Index':11,'Text':'Reinstate','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Reopen: {'Name':'Reopen','Value':12,'Index':12,'Text':'Reopen as Draft','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Approve: {'Name':'Approve','Value':13,'Index':13,'Text':'Approve','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Deceased: {'Name':'Deceased','Value':14,'Index':14,'Text':'Marked as Deceased','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			SkillsMigration: {'Name':'SkillsMigration','Value':15,'Index':15,'Text':'Skills Migration','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			InterestsMigration: {'Name':'InterestsMigration','Value':16,'Index':16,'Text':'Interests Migration','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			PersonnelMigration: {'Name':'PersonnelMigration','Value':17,'Index':17,'Text':'Personnel Migration','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			MakePublic: {'Name':'MakePublic','Value':18,'Index':18,'Text':'Make Public','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			AddAccount: {'Name':'AddAccount','Value':19,'Index':19,'Text':'Add Account','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			RemoveAccount: {'Name':'RemoveAccount','Value':20,'Index':20,'Text':'Remove Account','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			EnableSync: {'Name':'EnableSync','Value':21,'Index':21,'Text':'Enable Sync','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			DailySync: {'Name':'DailySync','Value':22,'Index':22,'Text':'Daily Sync','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			DisableSync: {'Name':'DisableSync','Value':23,'Index':23,'Text':'Disable Sync','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			AddList: {'Name':'AddList','Value':24,'Index':24,'Text':'Add List','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			UpdateList: {'Name':'UpdateList','Value':25,'Index':25,'Text':'Update List','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			ReplaceList: {'Name':'ReplaceList','Value':26,'Index':26,'Text':'Replace List','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			PrivacyChange: {'Name':'PrivacyChange','Value':27,'Index':27,'Text':'Privacy Change','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'},
			Decline: {'Name':'Decline','Value':28,'Index':28,'Text':'Decline','FullName':'AcsTech.Realm.Data.Enums.System.ChangeLogAction'}
		},
		DataType: {
			Text: {'Name':'Text','Value':0,'Index':0,'Text':'Text','FullName':'AcsTech.Realm.Data.Enums.System.DataType'},
			Date: {'Name':'Date','Value':1,'Index':1,'Text':'Date','FullName':'AcsTech.Realm.Data.Enums.System.DataType'},
			Number: {'Name':'Number','Value':2,'Index':2,'Text':'Number','FullName':'AcsTech.Realm.Data.Enums.System.DataType'},
			Boolean: {'Name':'Boolean','Value':3,'Index':3,'Text':'Yes/No','FullName':'AcsTech.Realm.Data.Enums.System.DataType'},
			List: {'Name':'List','Value':4,'Index':4,'Text':'List','FullName':'AcsTech.Realm.Data.Enums.System.DataType'},
			Individual: {'Name':'Individual','Value':5,'Index':5,'Text':'Individual','FullName':'AcsTech.Realm.Data.Enums.System.DataType'},
			MultiList: {'Name':'MultiList','Value':6,'Index':6,'Text':'MultiList','FullName':'AcsTech.Realm.Data.Enums.System.DataType'},
			Business: {'Name':'Business','Value':7,'Index':7,'Text':'Business','FullName':'AcsTech.Realm.Data.Enums.System.DataType'},
			Church: {'Name':'Church','Value':8,'Index':8,'Text':'Church','FullName':'AcsTech.Realm.Data.Enums.System.DataType'}
		},
		PersonnelStatus: {
			None: {'Name':'None','Value':0,'Index':0,'Text':'None','FullName':'AcsTech.Realm.Data.Enums.System.PersonnelStatus'},
			Clergy: {'Name':'Clergy','Value':1,'Index':1,'Text':'Clergy','FullName':'AcsTech.Realm.Data.Enums.System.PersonnelStatus'},
			Religious: {'Name':'Religious','Value':2,'Index':2,'Text':'Religious','FullName':'AcsTech.Realm.Data.Enums.System.PersonnelStatus'},
			Staff: {'Name':'Staff','Value':3,'Index':3,'Text':'Staff','FullName':'AcsTech.Realm.Data.Enums.System.PersonnelStatus'}
		},
		IndividualTypeFlags: {
			Profile: {'Name':'Profile','Value':1,'Index':0,'Text':'Profile','FullName':'AcsTech.Realm.Data.Enums.System.IndividualTypeFlags'},
			Vendor: {'Name':'Vendor','Value':2,'Index':1,'Text':'Vendor','FullName':'AcsTech.Realm.Data.Enums.System.IndividualTypeFlags'},
			Employee: {'Name':'Employee','Value':4,'Index':2,'Text':'Employee','FullName':'AcsTech.Realm.Data.Enums.System.IndividualTypeFlags'},
			NamedGuest: {'Name':'NamedGuest','Value':8,'Index':3,'Text':'NamedGuest','FullName':'AcsTech.Realm.Data.Enums.System.IndividualTypeFlags'},
			Contact: {'Name':'Contact','Value':16,'Index':4,'Text':'Contact','FullName':'AcsTech.Realm.Data.Enums.System.IndividualTypeFlags'},
			Church: {'Name':'Church','Value':32,'Index':5,'Text':'Church','FullName':'AcsTech.Realm.Data.Enums.System.IndividualTypeFlags'},
			CoveredIndividual: {'Name':'CoveredIndividual','Value':64,'Index':6,'Text':'CoveredIndividual','FullName':'AcsTech.Realm.Data.Enums.System.IndividualTypeFlags'},
			SiteChurch: {'Name':'SiteChurch','Value':128,'Index':7,'Text':'SiteChurch','FullName':'AcsTech.Realm.Data.Enums.System.IndividualTypeFlags'}
		},
		SystemFieldName: {
			Status: {'Name':'Status','Value':0,'Index':0,'Text':'Member Status','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			MaritalStatus: {'Name':'MaritalStatus','Value':1,'Index':1,'Text':'Marital Status','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			Suffix: {'Name':'Suffix','Value':2,'Index':2,'Text':'Suffix','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			Title: {'Name':'Title','Value':3,'Index':3,'Text':'Title','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			Gender: {'Name':'Gender','Value':5,'Index':4,'Text':'Gender','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			ProfileAlert: {'Name':'ProfileAlert','Value':6,'Index':5,'Text':'Profile Alert','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			Facebook: {'Name':'Facebook','Value':7,'Index':6,'Text':'Facebook Link','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			Twitter: {'Name':'Twitter','Value':8,'Index':7,'Text':'Twitter Link','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			LinkedIn: {'Name':'LinkedIn','Value':9,'Index':8,'Text':'LinkedIn Link','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			DateOfBirth: {'Name':'DateOfBirth','Value':10,'Index':9,'Text':'Birthday','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			FamilyPosition: {'Name':'FamilyPosition','Value':11,'Index':10,'Text':'Family Position','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			GivingNumber: {'Name':'GivingNumber','Value':13,'Index':11,'Text':'Giving Number','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			CheckInNumber: {'Name':'CheckInNumber','Value':14,'Index':12,'Text':'Check-In Number','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			Allergies: {'Name':'Allergies','Value':15,'Index':13,'Text':'Allergies','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			Instagram: {'Name':'Instagram','Value':16,'Index':14,'Text':'Instagram Link','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			Skills: {'Name':'Skills','Value':17,'Index':15,'Text':'Skills','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			Interests: {'Name':'Interests','Value':18,'Index':16,'Text':'Interests','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			ReligiousOrders: {'Name':'ReligiousOrders','Value':19,'Index':17,'Text':'Religious Order','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			OrdinationStatuses: {'Name':'OrdinationStatuses','Value':20,'Index':18,'Text':'Ordination Status','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			AssignmentStatuses: {'Name':'AssignmentStatuses','Value':21,'Index':19,'Text':'Assignment Status','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			OrgLookupID: {'Name':'OrgLookupID','Value':22,'Index':20,'Text':'Constituent ID','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			OrgChurchID: {'Name':'OrgChurchID','Value':24,'Index':21,'Text':'Church ID','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			DateFounded: {'Name':'DateFounded','Value':25,'Index':22,'Text':'Date Founded','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			DateClosed: {'Name':'DateClosed','Value':26,'Index':23,'Text':'Date Closed','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			WebSite: {'Name':'WebSite','Value':27,'Index':24,'Text':'Website','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'},
			None: {'Name':'None','Value':2147483647,'Index':25,'Text':'None','FullName':'AcsTech.Realm.Data.Enums.System.SystemFieldName'}
		},
		SickReason: {
			None: {'Name':'None','Value':0,'Index':0,'Text':'None','FullName':'AcsTech.Realm.Data.Enums.Payroll.SickReason'},
			QuarantineOrIsolationOrder: {'Name':'QuarantineOrIsolationOrder','Value':1,'Index':1,'Text':'Quarantine or isolation order','FullName':'AcsTech.Realm.Data.Enums.Payroll.SickReason'},
			AdvisedToSelfQuarantine: {'Name':'AdvisedToSelfQuarantine','Value':2,'Index':2,'Text':'Advised to self quarantine','FullName':'AcsTech.Realm.Data.Enums.Payroll.SickReason'},
			SymptomsAndSeekingDiagnosis: {'Name':'SymptomsAndSeekingDiagnosis','Value':3,'Index':3,'Text':'Symptoms and seeking diagnosis','FullName':'AcsTech.Realm.Data.Enums.Payroll.SickReason'},
			CaringForAnIndividual: {'Name':'CaringForAnIndividual','Value':4,'Index':4,'Text':'Caring for an individual','FullName':'AcsTech.Realm.Data.Enums.Payroll.SickReason'},
			CaringForAChild: {'Name':'CaringForAChild','Value':5,'Index':5,'Text':'Caring for a child','FullName':'AcsTech.Realm.Data.Enums.Payroll.SickReason'},
			OtherSimilarCondition: {'Name':'OtherSimilarCondition','Value':6,'Index':6,'Text':'Other similar condition','FullName':'AcsTech.Realm.Data.Enums.Payroll.SickReason'},
			ObtainingVaccination: {'Name':'ObtainingVaccination','Value':7,'Index':7,'Text':'Obtaining COVID-19 vaccination','FullName':'AcsTech.Realm.Data.Enums.Payroll.SickReason'},
			RecoveringVaccination: {'Name':'RecoveringVaccination','Value':8,'Index':8,'Text':'Recovering from vaccination','FullName':'AcsTech.Realm.Data.Enums.Payroll.SickReason'},
			AwaitingResults: {'Name':'AwaitingResults','Value':9,'Index':9,'Text':'Awaiting COVID-19 test results','FullName':'AcsTech.Realm.Data.Enums.Payroll.SickReason'}
		},
		ImportErrorStatus: {
			MissingCoreAccount: {'Name':'MissingCoreAccount','Value':1,'Index':0,'Text':'Missing Core Account','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			MissingFund: {'Name':'MissingFund','Value':2,'Index':1,'Text':'Missing Fund','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			MissingPayee: {'Name':'MissingPayee','Value':4,'Index':2,'Text':'Missing Payee','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			MissingTransactionType: {'Name':'MissingTransactionType','Value':8,'Index':3,'Text':'Missing Transaction Type','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			OutOfBalance: {'Name':'OutOfBalance','Value':16,'Index':4,'Text':'Out of Balance','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			Wash: {'Name':'Wash','Value':32,'Index':5,'Text':'Debit and Credit Net Zero','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			MissingCashAccount: {'Name':'MissingCashAccount','Value':64,'Index':6,'Text':'Missing Cash Account','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			PriorPeriodDate: {'Name':'PriorPeriodDate','Value':128,'Index':7,'Text':'Prior Period Date','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			ZeroDetailAmount: {'Name':'ZeroDetailAmount','Value':256,'Index':8,'Text':'Zero Detail Amount','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			InvalidDistributionCount: {'Name':'InvalidDistributionCount','Value':512,'Index':9,'Text':'Invalid Distribution Count','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			MissingDate: {'Name':'MissingDate','Value':1024,'Index':10,'Text':'Missing Date','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			Entry13thMonth: {'Name':'Entry13thMonth','Value':2048,'Index':11,'Text':'13th Month Entry','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			InvalidBankAccountAssociation: {'Name':'InvalidBankAccountAssociation','Value':4096,'Index':12,'Text':'Invalid Bank Account Association','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			MissingCheckingCreditCardAccount: {'Name':'MissingCheckingCreditCardAccount','Value':8192,'Index':13,'Text':'Missing Checking/Credit Card Account','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			CrossingBankAccounts: {'Name':'CrossingBankAccounts','Value':16384,'Index':14,'Text':'Crossing Bank Accounts','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			InvalidAccount: {'Name':'InvalidAccount','Value':32768,'Index':15,'Text':'Invalid Account','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'},
			InvalidEntryType: {'Name':'InvalidEntryType','Value':65536,'Index':16,'Text':'Invalid Entry','FullName':'AcsTech.Realm.Data.Enums.Ledger.ImportErrorStatus'}
		},
		ClergyRole: {
			Default: {'Name':'Default','Value':1,'Index':0,'Text':'Conversion Use Only','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			CanonToTheOrdinary: {'Name':'CanonToTheOrdinary','Value':100,'Index':1,'Text':'Canon to the Ordinary','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Archbishop: {'Name':'Archbishop','Value':101,'Index':2,'Text':'Archbishop','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Bishop: {'Name':'Bishop','Value':102,'Index':3,'Text':'Bishop','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Dean: {'Name':'Dean','Value':103,'Index':4,'Text':'Dean','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Canon: {'Name':'Canon','Value':104,'Index':5,'Text':'Canon','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			SeniorPastor: {'Name':'SeniorPastor','Value':105,'Index':6,'Text':'Senior Pastor','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			PriestPastor: {'Name':'PriestPastor','Value':106,'Index':7,'Text':'Priest/Pastor','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			AssociatePriestPastor: {'Name':'AssociatePriestPastor','Value':107,'Index':8,'Text':'Associate Priest/Pastor','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			ParochialVicar: {'Name':'ParochialVicar','Value':108,'Index':9,'Text':'Parochial Vicar','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Presbyter: {'Name':'Presbyter','Value':109,'Index':10,'Text':'Presbyter','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Rector: {'Name':'Rector','Value':110,'Index':11,'Text':'Rector','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			AssociateRector: {'Name':'AssociateRector','Value':111,'Index':12,'Text':'Associate Rector','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Deacon: {'Name':'Deacon','Value':112,'Index':13,'Text':'Deacon','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Chaplain: {'Name':'Chaplain','Value':113,'Index':14,'Text':'Chaplain','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Superintendent: {'Name':'Superintendent','Value':114,'Index':15,'Text':'Superintendent','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			ExecutivePastorMinister: {'Name':'ExecutivePastorMinister','Value':115,'Index':16,'Text':'Executive Pastor/Minister','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			AssociatePastorMinister: {'Name':'AssociatePastorMinister','Value':116,'Index':17,'Text':'Associate Pastor/Minister','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			ChildrenYouthPastorMinister: {'Name':'ChildrenYouthPastorMinister','Value':117,'Index':18,'Text':'Children/Youth Pastor/Minister','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			LayMinister: {'Name':'LayMinister','Value':118,'Index':19,'Text':'Lay Minister','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Exhorter: {'Name':'Exhorter','Value':119,'Index':20,'Text':'Exhorter','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Elder: {'Name':'Elder','Value':120,'Index':21,'Text':'Elder','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Supply: {'Name':'Supply','Value':121,'Index':22,'Text':'Supply','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			TeamMinistry: {'Name':'TeamMinistry','Value':122,'Index':23,'Text':'Team Ministry','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Brother: {'Name':'Brother','Value':200,'Index':24,'Text':'Brother','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			SisterNun: {'Name':'SisterNun','Value':201,'Index':25,'Text':'Sister/Nun','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Friar: {'Name':'Friar','Value':202,'Index':26,'Text':'Friar','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Monk: {'Name':'Monk','Value':203,'Index':27,'Text':'Monk','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Cantor: {'Name':'Cantor','Value':204,'Index':28,'Text':'Cantor','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Warden: {'Name':'Warden','Value':205,'Index':29,'Text':'Warden','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Accounting: {'Name':'Accounting','Value':300,'Index':30,'Text':'Accounting','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			AdministrativeStaff: {'Name':'AdministrativeStaff','Value':301,'Index':31,'Text':'Administrative Staff','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			AdultEducation: {'Name':'AdultEducation','Value':302,'Index':32,'Text':'Adult Education','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			ChildrenYouthMinistries: {'Name':'ChildrenYouthMinistries','Value':303,'Index':33,'Text':'Children/Youth Ministries','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			Counseling: {'Name':'Counseling','Value':304,'Index':34,'Text':'Counseling','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			DatabaseManagement: {'Name':'DatabaseManagement','Value':305,'Index':35,'Text':'Database Management','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			EventFacilityStaff: {'Name':'EventFacilityStaff','Value':306,'Index':36,'Text':'Event/Facility Staff','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			ExecutiveStaff: {'Name':'ExecutiveStaff','Value':307,'Index':37,'Text':'Executive Staff','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			GivingDevelopment: {'Name':'GivingDevelopment','Value':308,'Index':38,'Text':'Giving/Development','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			ItNetwork: {'Name':'ItNetwork','Value':309,'Index':39,'Text':'IT/Network','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			LiturgicalMusic: {'Name':'LiturgicalMusic','Value':310,'Index':40,'Text':'Liturgical/Music','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			MediaCommunications: {'Name':'MediaCommunications','Value':311,'Index':41,'Text':'Media/Communications','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			MissionsOutreach: {'Name':'MissionsOutreach','Value':312,'Index':42,'Text':'Missions/Outreach','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			ParishPastoralCare: {'Name':'ParishPastoralCare','Value':313,'Index':43,'Text':'Parish/Pastoral Care','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			PastoralDepartment: {'Name':'PastoralDepartment','Value':314,'Index':44,'Text':'Pastoral Department','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			RelEducationFaithFormation: {'Name':'RelEducationFaithFormation','Value':315,'Index':45,'Text':'Rel. Education/Faith Formation','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			SchoolDaycare: {'Name':'SchoolDaycare','Value':316,'Index':46,'Text':'School/Daycare','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			AdultSeniorMinistries: {'Name':'AdultSeniorMinistries','Value':317,'Index':47,'Text':'Adult/Senior Ministries','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			CongregantCare: {'Name':'CongregantCare','Value':318,'Index':48,'Text':'Congregant Care','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			EducationDiscipleship: {'Name':'EducationDiscipleship','Value':319,'Index':49,'Text':'Education/Discipleship','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'},
			MusicWorshipStaff: {'Name':'MusicWorshipStaff','Value':320,'Index':50,'Text':'Music/Worship Staff','FullName':'AcsTech.Realm.Data.Enums.Clergy.ClergyRole'}
		},
		PersonnelInfoType: {
			Assignment: {'Name':'Assignment','Value':1,'Index':0,'Text':'Assignment','FullName':'AcsTech.Realm.Data.Enums.Clergy.PersonnelInfoType'},
			ReligiousOrder: {'Name':'ReligiousOrder','Value':2,'Index':1,'Text':'Religious Order','FullName':'AcsTech.Realm.Data.Enums.Clergy.PersonnelInfoType'},
			Ordination: {'Name':'Ordination','Value':3,'Index':2,'Text':'Ordination','FullName':'AcsTech.Realm.Data.Enums.Clergy.PersonnelInfoType'},
			OrdinationStatus: {'Name':'OrdinationStatus','Value':4,'Index':3,'Text':'Ordination Status','FullName':'AcsTech.Realm.Data.Enums.Clergy.PersonnelInfoType'},
			AdditionalInfo: {'Name':'AdditionalInfo','Value':5,'Index':4,'Text':'Additional Info','FullName':'AcsTech.Realm.Data.Enums.Clergy.PersonnelInfoType'}
		}
	}
}();;
STRATUS.Enums = {
    phoneTypes: {
        0: 'Home',
        1: 'Mobile',
        2: 'Office',
        3: 'Other'
    },

    privacySettings: function () {
        return {
            0: 'Anyone',
            1: 'People in my groups/' + STRATUS.Formatters.getPersonalizedTerm('serving team', true),
            2: 'Leaders',
            3: 'Users with permission only'
        };
    },

    privacySettingText: function () {
        return {
            0: 'Anyone in the ' + STRATUS.Formatters.getPersonalizedTerm('church'),
            1: 'Leaders & group/' + STRATUS.Formatters.getPersonalizedTerm('serving team') + ' members',
            2: 'Leaders',
            3: 'Users with permission only'
        };
    },

    privacySettingEnumName: {
        0: 'All',
        1: 'Group',
        2: 'Leader',
        3: 'Staff'
    },

    // Reports return the privacy setting name instead of integer value
    privacySettingNames: {
        'All': 'Anyone',
        'Group': 'Leaders & Group Members',
        'Leader': 'Leaders',
        'Staff': 'Staff only'
    },

    sacramentSponsorTypes: {
        0: 'Christian Witness',
        1: 'Godparent',
        2: 'Proxy',
        3: 'Witness',
        4: 'Sponsor'
    },

    sacramentFieldTypes: {
        ProfessionOfFaith: 0,
        Parish: 1,
        SpouseName: 2,
        Father: 3,
        Mother: 4,
        MotherMaidenName: 5,
        Birthplace: 6,
        Saint: 7,
        CertificateOnFile: 8,
        CertificateSent: 9,
        Verified: 10,
        VolumePageEntry: 11,
        Sponsors: 12,
        Clergy: 13,
        Name: 14,
        FullMaidenName: 15
    },

    sacramentFieldTypeNames: {
        0: 'ProfessionOfFaith',
        1: 'Parish',
        2: 'SpouseName',
        3: 'Father',
        4: 'Mother',
        5: 'MotherMaidenName',
        6: 'Birthplace',
        7: 'Saint',
        8: 'CertificateOnFile',
        9: 'CertificateSent',
        10: 'Verified',
        11: 'VolumePageEntry',
        12: 'Sponsors',
        13: 'Clergy',
        14: 'Name',
        15: 'FullMaidenName'
    },

    sacramentFieldTypeText: {
        0: 'Profession of Faith',
        1: 'Parish',
        2: 'Spouse\'s Name',
        3: 'Father\'s Name',
        4: 'Mother\'s Name',
        5: 'Mother\'s Full Maiden Name',
        6: 'Birthplace',
        7: 'Saint Name',
        8: 'Certificate On File',
        9: 'Certificate Sent',
        10: 'Verified',
        11: 'Volume, Page, Entry',
        12: 'Sponsors',
        13: 'Clergy',
        14: 'Name',
        15: 'Full Maiden Name'
    },

    sacramentsCustomWordingFieldTypes: {
        Title: 1,
        SacramentCertify: 2,
        OrdinanceCertify: 3,
        SacramentRegisterOfChurch: 4,
        SacramentBaptismAction: 5,
        OrdinanceBaptismAction: 6,
        SacramentBaptismAuthority: 7,
        SacramentCommunionAction: 8,
        SacramentConfirmationAction: 9,
        SacramentMatrimonyAction: 10,
        OrdinanceMatrimonyAction: 11,
        SacramentMatrimonyAuthority: 12,
        OrdinanceMatrimonyAuthority: 13
    },

    sacramentsCustomWordingFieldTypesText: {
        1: '',
        2: 'This is to certify',
        3: 'This certifies that',
        4: '',
        5: 'Baptized',
        6: 'was baptized in the name of the Father, the Son, and the Holy Spirit',
        7: 'According to the Rite of the Roman Catholic Church',
        8: 'Received First Holy Communion',
        9: 'Received the Sacrament of Confirmation from',
        10: 'Were Married',
        11: 'were united in holy matrimony',
        12: 'According to the Rite of the Roman Catholic Church',
        13: 'by virtue of the power vested in me'
    },

    sacramentReportType: {
        Certificate: 0,
        Notation: 1,
        NotificationLetter: 2,
        RciaCertificate: 3
    },

    sacramentType: {
        Baptism: 0,
        Reconciliation: 1,
        Communion: 2,
        Confirmation: 3,
        Matrimony: 4,
        HolyOrders: 5,
        AnnointingOfTheSick: 6
    },

    sacramentTypeText: {
        0: 'Baptism',
        1: 'First Reconciliation',
        2: 'First Communion',
        3: 'Confirmation',
        4: 'Matrimony',
        5: 'Holy Orders',
        6: 'Annointing Of The Sick'
    },

    // Used by the RedshiftQuery micro service for the sacraments dashboard
    protobufSacramentType: {
        Empty: 0,
        Baptism: 1,
        Reconciliation: 2,
        Communion: 3,
        Confirmation: 4,
        Matrimony: 5,
        HolyOrders: 6,
        AnointingOfTheSick: 7
    },

    // Used by the RedshiftQuery micro service for the sacraments dashboard
    protobufSacramentTypeText: {
        0: 'Empty',
        1: 'Baptism',
        2: 'First Reconciliation',
        3: 'First Communion',
        4: 'Confirmation',
        5: 'Matrimony',
        6: 'Holy Orders',
        7: 'Anointing Of The Sick'
    },

    // Used by the RedshiftQuery micro service for the sacraments dashboard
    protobufIDType: {
        Empty: 0,
        Org: 1,
        Site: 2
    },

    sacramentReportTypeText: {
        0: 'Certificate',
        1: 'Notation',
        2: 'Notification Letter',
        3: 'Certificate'
    },

    sacramentReportTokenTypes: {
        SiteName: 0,
        SiteAddress: 1,
        SitePhone: 2,
        SiteEmail: 3,
        SacramentDate: 4,
        TodaysDate: 5,
        ParishOfBaptismName: 6,
        ParishOfBaptismAddress: 7,
        BaptismalName: 8,
        BaptismDate: 9,
        SpouseName: 10,
        Father: 11,
        MotherMaidenName: 12,
        Saint: 13,
        Sponsors: 14,
        Clergy: 15,
        ParishName: 16,
        ParishAddress: 17,
        Birthplace: 18,
        BirthDate: 19,
        ConfirmationSaint: 20,
        ProfessionOfFaith: 21,
        IndividualId: 22,
        ParishCityState: 23,
        Mother: 24,
        OfficiantSignature: 25,
        AuthorityWording: 26,
        NewlywedSignatures: 27,
        OneSponsorSignature: 28,
        TwoSponsorSignatures: 29,
        Name: 30,
        SignatureDate: 31,
        FullMaidenName: 32,
        SpousesFullMaidenName: 33
    },

    sacramentsDtoExperienceTypes: {
        Sacraments: 0,
        Ordinances: 1
    },

    systemFieldNames: {
        Status: 0,
        MaritalStatus: 1,
        ProfileAlert: 6
    },

    displayContactInfo: {
        None: 0,
        All: 1,
        LabelOnly: 2
    },

    operators: {
        Equal: 0,
        NotEqual: 1,
        Blank: 2,
        NotBlank: 3,
        Contains: 4,
        StartsWith: 5,
        EndsWith: 6,
        LessThanEqualTo: 7,
        GreaterThanEqualTo: 8,
        Between: 9,
        ThisYear: 10,
        ThisMonth: 11,
        Today: 12,
        NextMonth: 13,
        Before: 14,
        After: 15,
        LastYear: 16,
        LastMonth: 17,
        True: 18,
        False: 19,
        DoesNotHaveLogin: 20,
        HasLogin: 21,
        GreaterThan: 22,
        LessThan: 23,
        ThisWeek: 24,
        LastWeek: 25,
        NextWeek: 26,
        Inactive: 27,
        Active: 28,
        InMonthOf: 29,
        Complete: 30,
        NotComplete: 31,
        IsSet: 32,
        IsNotSet: 33,
        Deceased: 34,
        Last12Months: 35,
        Pending: 36,
        Approved: 37
    },

    operatorsText: {
        0: "is equal to",
        1: "is not equal to",
        2: "is blank",
        3: "is not blank",
        4: "contains",
        5: "starts with",
        6: "ends with",
        7: "is less than/equal to",
        8: "is greater than/equal to",
        9: "is between",
        10: "is this year",
        11: "is this month",
        12: "is today",
        13: "is next month",
        14: "is before",
        15: "is after",
        16: "was last year",
        17: "was last month",
        18: "is yes",
        19: "is no",
        20: "doesn't have an account",
        21: "has an account",
        22: "is greater than",
        23: "is less than",
        24: "is this week",
        25: "was last week",
        26: "is next week",
        27: "is inactive",
        28: "is active",
        29: "is month of",
        30: "is complete",
        31: "is not complete",
        32: "is set",
        33: "is not set",
        34: "is deceased",
        35: "last 12 months",
        36: "is pending",
        37: "is approved",
        38: "is next year",
    },

    unitsText: {
        0: 'Years',
        1: 'Months',
    },

    queryDataTypes: {
        Text: 0,
        Date: 1,
        Integer: 2,
        Float: 3,
        Boolean: 4,
        List: 5,
        MultiList: 6,
        Individual: 7,
        MinistryArea: 8,
        UtcDateTime: 9,
        LocalDateTime: 10,
        Business: 11,
        Church: 12
    },

    profileRecordType: {
        Adult: 0,
        Child: 1,
        Business: 2,
        Church: 3,
        Personnel: 4
    },

    displayFor: {
        All: 'All Profile Types',
        People: 'People',
        Family: 'People (Family field)',
        Adults: 'Only Adults',
        Children: 'Only Children',
        Church: 'Churches',
        Business: 'Orgs/Businesses',
        Personnel: 'Personnel'
    },

    // TODO: This can go away once the Realm Plus experiment goes away
    fieldType: {
        All: 'All',
        Family: 'Families',
        People: 'People',
        Business: 'Businesses',
        Adults: 'Adults',
        Children: 'Children',
        Personnel: 'Personnel'
    },

    dataType: function () {
        return {
            Text: 'Text',
            Date: 'Date',
            Number: 'Number',
            Boolean: 'Yes/No',
            List: 'List',
            Individual: 'People Search',
            Church: STRATUS.Formatters.capitalize(STRATUS.Formatters.getPersonalizedTerm('church')) + ' Search',
            Business: 'Org/Business Search',
            Multilist: 'MultiList'
        };
    },

    churchPhoneType: {
        0: 'Main',
        1: 'Mobile',
        2: 'Fax',
        3: 'Other'
    },

    fieldRestriction: {
        Enabled: 1,
        Required: 2,
        AvailableOnAdd: 3,
        Editable: 4,
        Viewable: 5,
        Rename: 6
    },

    reasonDeactivated: {
        None: 0,
        SacramentsMigration: 1,
        DeceasedMigration: 2
    },

    mediaImageType: {
        Logo: 0,
        Group: 1,
        Profile: 2,
        Family: 3,
        KioskLogo: 4,
        KioskBackground: 5,
        Announcements: 6,
        MinistryArea: 7,
        Pathways: 8,
        Signature: 9,
        Engagement: 10,
        DeceasedFamily: 11,
        Business: 12,
        Church: 13,
        Diocese: 14
    },

    contactsGender: {
        0: 'None',
        1: 'Female',
        2: 'Male'
    },

    contactAlertColor: {
        0: 'None',
        1: 'Blue',
        2: 'Pink',
        3: 'Yellow',
        4: 'Green',
        5: 'Purple',
        6: 'Red'
    },

    changeLogArea: {
        NoArea: 0,
        PeopleProfile: 1,
        BusinessProfile: 2,
        ChurchProfile: 3,
        Family: 4,
        PersonnelProfile: 5
    },

    changeLogAction: {
        NoAction: 0,
        Add: 1,
        Edit: 2,
        Deactivate: 3,
        Reactivate: 4,
        MarkAsDeceased: 5,
        Delete: 6,
        UpdateChurchAssociation: 7,
        UpdateChurchRegistration: 8,
        UpdatePastChurchRegistrations: 9,
        SeparateHousehold: 10,
        GetMarried: 11,
        StartNewHousehold: 12,
        ChangeHousehold: 13,
        AddFamilyMember: 14,
        AddExistingChild: 15,
        MergeRecord: 16
    },

    smsSubscriptionType: {
        0: 'None',
        1: '500 texts ($10/month)',
        2: '1,000 texts ($20/month)',
        3: '1,500 texts ($30/month)',
        4: '2,000 texts ($40/month)',
        5: '2,500 texts ($50/month)',
        6: '5,000 texts ($100/month)',
        7: '10,000 texts ($200/month)',
        8: '15,000 texts ($300/month)',
        9: '25,000 texts ($500/month)'
    },

    smsSolutionCountType: {
        0: 'DAILY',
        1: 'WEEKLY',
        2: 'MONTHLY'
    },

    smsDateRanges: {
        0: 'Year to date',
        1: 'This quarter',
        2: 'This month',
        3: 'Last year',
        4: 'Last 12 months',
        5: 'Last month',
        6: 'Last 30 days',
        7: 'Last 7 days'
    },

    smsChartOptions: function () {
        return {
            0: 'All Text Usage',
            1: 'Group Text Usage',
            2: STRATUS.Formatters.capitalizeEach(STRATUS.Formatters.getPersonalizedTerm('serving team')) + ' Text Usage'
        };
    },

    weekdayFlags: {
        0: '',
        1: 'Sunday',
        2: 'Monday',
        4: 'Tuesday',
        8: 'Wednesday',
        16: 'Thursday',
        32: 'Friday',
        64: 'Saturday'
    },

    teamCommunicationSettings: function () {
        return {
            0: 'No one',
            1: 'Any approved volunteer on the team',
            2: STRATUS.Formatters.capitalize(STRATUS.Formatters.getPersonalizedTerm('serving team')) + ' leaders only'
        };
    },

    teamParticipationRanges: {
        //0: 'Do Not Calculate',
        1: 'Last 30 Days',
        2: 'Last 90 Days',
        3: 'Last 6 Months',
        4: 'Last 12 Months'
    },

    siteAddons: {
        LmsPremium: 128
    },

// Convert entire enum into list for selectList
    forSelectList: function (theEnum) {
        var dataList = [];

        for (var item in theEnum) {
            dataList.push({ Text: theEnum[item], Value: item, SearchTerms: [item], Selected: false });
        }

        return dataList;
    },

    // Convert enum into list for selectList including only values that are included in the whitelist.  
    // Whitelist might be like ['Selection A', 'Selection B'] meaning it is the text representations of the enum
    forSelectListByText: function (theEnum, whitelistText) {
        var dataList = [];

        for (var item in theEnum) {
            var text = theEnum[item];

            if (whitelistText.indexOf(text) !== -1) {
                dataList.push({ Text: text, Value: item, SearchTerms: [item], Selected: false });
            }
        }

        return dataList;
    },

    ageRangeType: {
        Empty: 0,
        NoAge: 1,
        YearlyAgeRange: 2,
        AverageAge: 3
    },

    mobileCheckInType: {
        None: 0,
        Kiosk: 1,
        Contactless: 2
    }
};
;
Vue.component('global-search-demo', {
    template: `
<div ref="wrapper" class="global-search-wrapper" v-bind:class="{ 'relative': windowWidth > 768 || !isFocused }">
    <div ref="globalSearch" class="global-search" v-bind:class="{ 'global-search-focused': isFocused }" v-bind:style="{ 'width': isFocused ? getWidth() + 'px' : null }">
        <input ref="input" class="search-text" v-bind:class="{ 'search-text--no-tabs': !activeTab }" v-model="searchText" v-bind:placeholder="placeholder" v-on:focus="setFocus" v-on:keydown="processKeyDown($event)" type="text" autocomplete="new-password">
        <a v-if="isSearching" class="button button-secondary not-clickable" href="javascript:void(0);"><i class="icon icon-spinner icon-spin"></i></a>
        <a v-else-if="isSearchComplete" v-on:click="clearSearch()" class="button button-secondary" href="javascript:void(0);"><i class="icon icon-times"></i></a>
        <a v-else class="button button-secondary not-clickable" href="javascript:void(0);"><i class="icon icon-search"></i></a>
        <div v-show="isFocused && activeTab" class="search-results">
            <ul v-if="!profilesOnly" class="tabs">
                <li v-for="(tab, tabIndex) in tabs" v-bind:key="tabIndex" v-bind:class="{ 'active': getTabLength(tab.id) !== 0 && activeTab === tab.id, 'disabled': getTabLength(tab.id) === 0 }">
                    <a v-on:click="selectTab(tab.id)" href="javascript:void(0);">{{tab.name}}</a>
                </li>
            </ul>
            <div v-if="activeTab && items[activeTab].length === 0" class="global-search-no-results text-center">
                <div class="global-search-no-results-icon"><i class="icon icon-search text-muted text-3x"></i></div>
                <div>We couldn't find any matches</div>
            </div>
            <ul v-else-if="activeTab" class="scrollable" v-bind:style="{ 'max-height': (windowHeight - 170) + 'px' }">
                <li class="hide-actions" v-for="(item, itemIndex) in items[activeTab]" v-bind:key="itemIndex" v-bind:class="{ 'active': selectedIndex === itemIndex }" v-on:mouseover="selectedIndex = itemIndex" v-on:click="redirectToUrl(item)">
                    <div class="media">
                        <div class="img"><img class="framed" v-bind:src="item.image_url" width="50" height="50" /></div>
                        <div class="bd">
                            <div>
                                <a v-bind:href="getItemUrl(item)" v-html="getHighlightedText(item.label)"></a>
                            </div>
                            <div v-if="item.is_deceased" class="text-small">{{item.details || 'Passed away'}}</div>
                            <template v-else>
                                <div v-if="item.position_title" class="text-small text-bold">{{item.position_title}}</div>
                                <div v-if="item.is_deactivated" class="text-small">Inactive</div>
                                <div v-if="item.details" class="text-small text-muted">{{item.details}}</div>
                                <div v-if="item.age" class="text-small text-muted">{{item.age}}</div>
                            </template>
                            <div v-if="item.leader_names" class="text-small text-muted" v-html="getLeaderNames(item)"></div>
                        </div>
                    </div>
                </li>
                <li v-if="!isEngagement || activeTab === 'profiles'" class="see-all-results" v-bind:class="{ 'active': selectedIndex === items[activeTab].length }" v-on:mouseover="selectedIndex = items[activeTab].length"><a class="text-info" v-bind:href="seeAllUrl">See all {{seeAllText}} results<i class="icon icon-caret-right text-xlarge"></i></a></li>
            </ul>
        </div>
    </div>
</div>`,
    props: {
        placeholder: {
            type: String,
            default: 'Search...'
        },
        profilesOnly: {
            type: Boolean,
            default: false
        },
        isEngagement: {
            type: Boolean,
            default: false
        }
    },
    data() {
        return {
            tabs: [
                {name: 'Profiles', icon: 'icon-profile', id: 'profiles'},
                {name: 'Groups', icon: 'icon-group', id: 'groups'}
            ],
            activeTab: null,
            isFocused: false,
            isSearching: false,
            isSearchComplete: false,
            searchText: null,
            selectedIndex: -1,
            minCharacters: 2,
            timeout: 350,
            timer: null,
            windowWidth: window.innerWidth,
            windowHeight: window.innerHeight,
            items: {
                profiles: [],
                groups: [],
            }
        };
    },
    computed: {
        seeAllText() {
            switch (this.activeTab) {
                case 'profiles':
                    return 'profile';
                case 'groups':
                    return 'group';
            }
        },
        seeAllUrl() {
            const vm = this;
            const query = encodeURIComponent(vm.searchText);

            // Engagement doesn't really have a search page for groups right now
            if (!vm.isEngagement && vm.activeTab === 'groups') {
                return `${STRATUS.Config.SiteUrl}/Groups?searchText=${query}`;
            }

            // Default to profiles
            return vm.isEngagement ? `${STRATUS.Config.EngagementHost}/directory/?search=${query}` : `${STRATUS.Config.SiteUrl}/Individual/Profiles?q=${query}&status=all`;
        }
    },
    watch: {
        searchText: function () {
            const vm = this;

            if (vm.timer) {
                clearTimeout(vm.timer);
                vm.timer = null;
            }

            if (!vm.searchText || vm.searchText.length === 0) {
                vm.clearSearchResults();
            }

            if (vm.searchText && vm.searchText.trim().length >= vm.minCharacters) {
                vm.timer = setTimeout(vm.processSearch, vm.timeout);
            }
        }
    },
    methods: {
        setFocus() {
            this.isFocused = true;
        },
        clearFocus() {
            const vm = this;

            vm.searchText = null;
            vm.$refs.input.blur();
            vm.isFocused = false;
            vm.activeTab = null;
        },
        selectTab(tabName) {
            const vm = this;

            vm.activeTab = tabName;
            vm.selectedIndex = -1;
            vm.$refs.input.focus();
        },
        processKeyDown(event) {
            event.preventDefault();
        },
        getTabLength(tabName) {
            const vm = this;

            if (vm.items[tabName]) {
                return vm.items[tabName].length;
            }
            return 0;
        },
        getWidth() {
            const vm = this;

            // TODO: Remove these references (isNewDesign, $refs.globalSearch, etc) #ui-redesign
            const isNewDesign = $(this.$el).closest('.u-header').length !== 0;

            if (vm.windowWidth <= 768) {
                return vm.windowWidth - (isNewDesign ? 16 : 24);
            }

            const wrapper = $(isNewDesign ? vm.$refs.wrapper : vm.$refs.globalSearch);

            if (isNewDesign) {
                return Math.min(wrapper.offset().left + wrapper.width() - (vm.windowWidth <= 768 ? 0 : 240), 600) - 16;
            } else {
                return Math.min(wrapper.offset().left + wrapper.width() - (vm.windowWidth <= 1024 ? 0 : 260), 600);
            }

        }
    },
    mounted() {
        const vm = this;

        Vue.nextTick(function () {
            window.addEventListener('resize', function () {
                vm.windowWidth = this.innerWidth;
                vm.windowHeight = this.innerHeight;
            });

            document.addEventListener('click', function (event) {
                if (!event.target.closest('.global-search')) {
                    vm.clearFocus();
                }
            });
        });
    }
});
;
(function ($) {
    const methods = {
        close() {
            return this.each(function () {
                const obj = $(this);

                obj.css('opacity', 0).slideUp(250, function () {
                    obj.remove();
                });
            });
        }
    };

    const setGrowlerCloseTimer = function (obj, options) {
        const delay = typeof options.delay === 'number' ? options.delay : 10000,
            timerInterval = 1000;
        let timer,
            timerDelay;

        if (delay >= 1) {
            obj.data('growl-delay', delay);

            timer = setInterval(function () {
                timerDelay = parseInt(obj.data('growl-delay'), 10) - timerInterval;
                obj.data('growl-delay', timerDelay);

                if (timerDelay <= 0) {
                    clearInterval(timer);
                    methods.close.call(obj);
                }
            }, timerInterval);
        }
    };

    $.fn.growler_New = function (methodName) {
        // If a methodName is passed, we call the method.  Otherwise, we initialize the plugin.
        if (typeof methodName === 'string') {
            return STRATUS.Plugins.callMethod(this, methods, methodName, arguments);
        }

        return this.each(function () {
            const obj = $(this),
                options = obj.data('options');

            if (obj.hasClass('js-growler-initialized')) {
                return;
            }

            obj.children('.icon-times').on('click', function () {
                methods.close.call(obj);
            });

            setGrowlerCloseTimer(obj, options);

            obj.addClass('js-growler-initialized');
        });
    };

    const buildHtml = function (options) {
        const allowDismiss = typeof options.allowDismiss === 'boolean' ? options.allowDismiss : true;
        const obj = $(`
            <div class="u-growler-alert u-growler-alert-${options.type || 'info'}">
                <div>${options.content || ''}</div>
                <a class="icon icon-times${allowDismiss ? '' : ' hidden'}" href="javascript:void(0);"></a>
            </div>`);

        $('.growler-container').append(obj);

        return obj;
    };

    $.growler_New = function (options) {
        return buildHtml(options).data('options', options).growler_New();
    };
})(jQuery);;
STRATUS.Image = function () {
    return {
        //Used for shared giving to try show family then first primary then second primary
        setAltSrc: function () {
            var swapImage = function (imageElement, newImage) {
                var altSrc = imageElement.data('alt-src');
                if (altSrc.length > 0) {
                    newImage.attr('src', altSrc[0]);
                    altSrc.shift();
                    imageElement.data('alt-src', altSrc);
                }
            };

            $('img[data-alt-src]').each(function (index, image) {
                var imageElement = $(image),
                    newImage = $(new Image());

                swapImage(imageElement, newImage);

                newImage.on('error', function () {
                    swapImage(imageElement, newImage);
                }).on('load', function () {
                    imageElement.attr('src', newImage.attr('src'));
                    imageElement.removeAttr('data-alt-src');
                });
            });
        }
    };
}();;
Vue.component('main-nav', {
    props: {
        linkOptions: {
            type: Array,
            default: () => []
        }
    },
    data() {
        const vm = this;

        return {
            links: vm.mapLinkLevel(vm.linkOptions, 1)
        };
    },
    computed: {
        expandedLevel() {
            const vm = this;
            let expandedLink = vm.links.find(link => link.isExpanded && link.Items.length);
            let level = 0;

            while (expandedLink) {
                level = expandedLink.level;
                expandedLink = expandedLink.Items.find(link => link.isExpanded && link.Items.length);
            }

            return level;
        }
    },
    methods: {
        mapLinkLevel(linkOptions, level) {
            const vm = this;

            return linkOptions.map(link => {
                const copiedLink = Object.assign({}, link);

                copiedLink.Items = vm.mapLinkLevel(link.Items, level + 1);
                copiedLink.Selected = link.Selected || false;

                copiedLink.isExpanded = copiedLink.Selected;
                copiedLink.isHighlighted = false;
                copiedLink.level = level;

                return copiedLink;
            });
        },
        getImage(link) {
            const img = `${STRATUS.Config.Host}/Assets/Images/FeatureIcons/${link.Icon}`;

            return !link.Selected ? img : img.replace('.svg', '-active.svg');
        },
        addHighlight(link) {
            link.isHighlighted = true;
        },
        removeHighlight(link) {
            link.isHighlighted = false;
        },
        linkClicked(link, event) {
            // Link functions as a toggle in this case
            if (link.Items.length) {
                link.isExpanded = !link.isExpanded;
                event.preventDefault();
            }

            // Already selected, nothing to do
            if (link.Selected) {
                event.preventDefault();
            }
        }
    },
    template: `
<nav class="u-main-nav unselectable" v-bind:class="{ 'u-main-nav--expanded': expandedLevel }">
        <ul class="u-main-nav__list">
            <template v-for="(link, index) in links">
                <li v-bind:key="index">
                    <a class="nav-item" v-bind:class="{ 'nav-item--selected': link.Selected, 'nav-item--has-children': link.Items.length }" href="javascript:void(0)" v-on:mouseover="addHighlight(link)" v-on:mouseout="removeHighlight(link)" v-on:click="linkClicked(link, $event)">
                        <img v-if="link.Icon" v-bind:src="getImage(link)" alt=""/>
                        <div><span v-bind:class="{ 'nav-item--unread': link.UnreadCount }">{{link.Text}}</span></div>
                    </a>
                </li>
                <li v-if="link.isExpanded && link.Items.length" class="u-main-nav__level-1">
                    <ul>
                        <li>
                            <a class="nav-item" href="javascript:void(0);" v-on:click="linkClicked(link, $event)">
                                <span class="icon icon-caret-left"></span>
                                <div>Back</div>
                            </a>
                        </li>
                        <li class="nav-item-header" v-bind:class="{ 'nav-item--selected': link.Selected }">
                            <img v-if="link.Icon" v-bind:src="getImage(link)" alt=""/>
                            <div>{{link.Text}}</div>
                        </li>
                        <template v-for="(level1Child, level1Index) in link.Items">
                            <li v-bind:key="level1Index">
                                <a class="nav-item" v-bind:class="{ 'nav-item--selected': level1Child.Selected, 'nav-item--has-children': level1Child.Items.length, 'nav-item--expanded': level1Child.isExpanded }" href="javascript:void(0);" v-on:mouseover="addHighlight(level1Child)" v-on:mouseout="removeHighlight(level1Child)" v-on:click="linkClicked(level1Child, $event)">
                                    <div><span v-bind:class="{ 'nav-item--unread': level1Child.UnreadCount }">{{level1Child.Text}}</span></div>
                                </a>
                            </li>
                            <li v-if="level1Child.isExpanded && level1Child.Items.length" class="u-main-nav__level-2">
                                <ul>
                                    <li v-for="(level2Child, level2Index) in level1Child.Items" v-bind:key="level2Index">
                                        <a class="nav-item" v-bind:class="{ 'nav-item--selected': level2Child.Selected }" href="javascript:void(0)" v-on:mouseover="addHighlight(level2Child)" v-on:mouseout="removeHighlight(level2Child)" v-on:click="linkClicked(level2Child, $event)">
                                            <div><span v-bind:class="{ 'nav-item--unread': level2Child.UnreadCount }">{{level2Child.Text}}</span></div>
                                        </a>
                                    </li>
                                </ul>
                            </li>
                        </template>
                    </ul>
                </li>
            </template>
        </ul>
    </div>
</nav>`
});;
// STRATUS.MapLoader
//
// Provides a Promise to queue map functions and lazy loads the Google Maps
// API scripts.
//
// This prevents having to include the Google Maps API on pages where it's not needed.
STRATUS.MapLoader = function () {
    var _loader = $.Deferred();

    return {
        queue: function (fn, context) {
            _loader.done($.proxy(fn, context));
            return this; // Return the MapLoader so we can chain
        },

        // Load the Google Maps API
        // this.apiLoaded will be fired once the script is loaded.
        load: function () {
            if ($('#google-maps-api').length !== 0) {
                return;
            }

            var script = document.createElement('script');
            script.id = 'google-maps-api';
            script.src = 'https://maps.googleapis.com/maps/api/js?v=3&client=gme-acstechnologies&channel=stratus&callback=STRATUS.MapLoader.apiLoaded';
            document.head.appendChild(script);
        },

        // Google Maps callback
        apiLoaded: function () {
            // Remove the loader object. Doesnt need to be used again.
            delete STRATUS.MapLoader;

            // Initialize the STRATUS.Map object as it would have
            // if it was self-executing.
            STRATUS.Map = STRATUS.Map();

            // Resolve our promise to execute the queued functions
            _loader.resolve();
        }
    };
}();

STRATUS.Map = function () {
    var _map = null;
    var _infoWindow = null;
    var _bounds = null;
    var _geoCoder = null;
    var _defaultOptions = {
        center: new google.maps.LatLng(34.19643160, -79.83802720),
        zoom: 11,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var _containerId = null;
    var _addressDetails = [];

    var _plotQueue = [];
    var _okayToPlot = true;
    var _cache = {};
    var _maxGoogleApiHits = 50;
    var _numGoogleApiHits = 0;
    var _debugMode = false;

    var buildAddressInfoWindow = function (label, address1, address2, cityRegionPostalCode, phoneNumber, primaryEmail, imageUrl, individuals) {
        var hasMultiple = individuals && individuals.length > 1;
        var markup = [];
        markup.push('<div class="map-content media">');
        
        //Container for image
        if (!hasMultiple) {
            markup.push('<div class="img">');
            markup.push('<img alt="" src="' + imageUrl + '" class="framed">');
            markup.push('</div>');
        }

        //Container for contact info
        markup.push('<div class="bd">');
        markup.push('<h6>' + label + '</h6>');

        if (address1) {
            markup.push('<p class="text-small text-muted">' + address1 + '</p>');
        }
        if (address2) {
            markup.push('<p class="text-small text-muted">' + address2 + '</p>');
        }

        if (cityRegionPostalCode) {
            markup.push('<p class="text-small text-muted">' + cityRegionPostalCode + '</p>');
        }

        if (phoneNumber) {
            markup.push('<p class="text-small text-muted">' + phoneNumber + '</p>');
        }

        if (primaryEmail) {
            markup.push('<p class="text-small text-muted">' + primaryEmail + '</p>');
        }
        
        if (hasMultiple) {
            var index = _addressDetails.length;
            markup.push('<p class="text-small"><a href="javascript: void(0)" class="js-show-address-details" data-address-details-index="' + index + '">See all details</a></p>');
            _addressDetails.push(individuals);
            $('#' + _containerId).data('addressDetails', _addressDetails);
        }

        markup.push('</div>');
        markup.push('</div>');
        return markup.join('');
    };

    var plotStreetAddress = function (address, addressId, infoWindowContent, data) {
        if (_cache[address]) {
            var cachedResults = _cache[address];
            
            //save LatLng to db
            if (addressId.length > 0) {
                saveLatLng(addressId, cachedResults[0].geometry.location.lat(), cachedResults[0].geometry.location.lng());
            }

            plotLatLng(cachedResults[0].geometry.location, infoWindowContent);

            if (_debugMode) {
                console.log(_plotQueue.length + ' FROM CACHE ' + address);
            }
        }
        else if (_numGoogleApiHits < _maxGoogleApiHits) {
            _geoCoder.geocode({ 'address': address }, function(results, status) {
                if (status === google.maps.GeocoderStatus.OK) {
                    _cache[address] = results;

                    //save LatLng to db
                    if (addressId.length > 0) {
                        saveLatLng(addressId, results[0].geometry.location.lat(), results[0].geometry.location.lng());
                    }

                    plotLatLng(results[0].geometry.location, infoWindowContent);

                    if (_debugMode) {
                        console.log(_plotQueue.length + ' GEOCODE    ' + address);
                    }

                    _numGoogleApiHits++;
                } else if (status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
                    _okayToPlot = false;
                    pushToPlotQueue(data);

                    if (_debugMode) {
                        console.log(_plotQueue.length + ' WAIT       ' + address);
                    }

                    window.setTimeout(function() {
                        _okayToPlot = true;
                        plotNextAddress();
                    }, 1000);
                }
            });
        }
        else if(_debugMode) {
            console.log('Exceeded max api hits');
        }
    };

    var plotLatLng = function (latLng, infoWindowContent, data) {
        var marker = new google.maps.Marker({
            map: _map,
            position: latLng
        });

        _bounds.extend(latLng);

        google.maps.event.addListener(marker, 'mouseover', function () {
            _infoWindow.setContent(infoWindowContent);
            _infoWindow.open(_map, marker);
        });
        _map.fitBounds(_bounds);
    };

    var buildAddressToPlot = function (address1, address2, cityRegionPostalCode) {
        return address1 + ' ' + (address2 ? (address2 + ' ') : '') + (cityRegionPostalCode ? ' ' + cityRegionPostalCode : '');
    };

    var saveLatLng = function (addressId, lat, lng) {
        $.ajax({
            url: STRATUS.Config.SiteUrl + '/Individual/SaveLatLng',
            data: {
                addressId: addressId,
                lat: lat,
                lng: lng
            }
        });
    };

    var plotAddress = function (data) {
        var address1 = data.Address1;
        var address2 = data.Address2;
        var cityRegionPostalCode = data.CityRegionPostalCode;
        var infoWindowAddress = buildAddressInfoWindow(data.Label, address1, address2, cityRegionPostalCode, data.PhoneNumber, data.PrimaryEmail, data.ImageUrl, data.Individuals);

        if (data.Latitude && data.Longitude) {
            var latLng = new google.maps.LatLng(data.Latitude, data.Longitude);
            plotLatLng(latLng, infoWindowAddress, data);
            
            if (_debugMode) {
                console.log(_plotQueue.length + ' FROM DB      ' + data.Address1);
            }
        }
        else {
            var addressToPlot = buildAddressToPlot(address1, address2, cityRegionPostalCode);
            plotStreetAddress(addressToPlot, data.AddressId, infoWindowAddress, data);
        }
    };

    var plotNextAddress = function () {
        if (_plotQueue.length === 0 || !_okayToPlot) {
            return;
        }

        var data = _plotQueue.shift();
        plotAddress(data);
        
        window.setTimeout(plotNextAddress, 1);
    };

    var pushToPlotQueue = function (data) {
        if (data.Latitude && data.Longitude) {
            plotAddress(data);
        }
        else {
            _plotQueue.push(data);

            if (_plotQueue.length === 1) {
                window.setTimeout(plotNextAddress, 1);
            }
        }
    };

    var showAddressDetails = function (addressDetails) {
        var markup = [];

        $.each(addressDetails, function (index, value) {
            markup.push('<div class="map-content media">');
            markup.push('<div class="img"><img alt="" src="' + value.ImageUrl + '" class="framed"></div>');
            markup.push('<div class="bd">');
            markup.push('<h6>' + value.Label + '</h6>');
            if (value.Address1) {
                markup.push('<p class="text-small text-muted">' + value.Address1 + '</p>');
            }
            if (value.Address2) {
                markup.push('<p class="text-small text-muted">' + value.Address2 + '</p>');
            }

            if (value.CityRegionPostalCode) {
                markup.push('<p class="text-small text-muted">' + value.CityRegionPostalCode + '</p>');
            }

            if (value.PhoneNumber) {
                markup.push('<p class="text-small text-muted">' + value.PhoneNumber + '</p>');
            }

            if (value.PrimaryEmail) {
                markup.push('<p class="text-small text-muted">' + value.PrimaryEmail + '</p>');
            }

            markup.push('</div>');
            markup.push('</div>');
        });

        $.lightBox('show', {
            header: 'Addresses',
            message: markup.join(''),
            okButtonText: 'Close',
            isScrollable: true
        });
    };

    return {
        mapInit: function (containerId, options, centerPoint) {
            _containerId = containerId;
            _geoCoder = new google.maps.Geocoder();
            if (!options) {
                options = {};
            }

            options.center = _defaultOptions.center;
            if (centerPoint && centerPoint.Lat && centerPoint.Long) {
                options.center = new google.maps.LatLng(centerPoint.Lat, centerPoint.Long);
            }

            if (!options.zoom) {
                options.zoom = _defaultOptions.zoom;
            }

            if (!options.mapTypeId) {
                options.mapTypeId = _defaultOptions.mapTypeId;
            }

            _map = new google.maps.Map(document.getElementById(_containerId), options);
            _infoWindow = new google.maps.InfoWindow();
            _bounds = new google.maps.LatLngBounds();

            $(document).on('click', '.js-show-address-details', STRATUS.Map.showAddressDetails);
        },
        plotAddress: function (data) {
            pushToPlotQueue(data);
        },
        showAddressDetails: function () {
            var self = $(this);
            var addressDetailsIndex = self.data('addressDetailsIndex');
            var addressDetails = $('#' + _containerId).data('addressDetails')[addressDetailsIndex];
            showAddressDetails(addressDetails);
        }
    };
};;
Vue.component('ministry-smart-link', {
    model: {
        prop: 'hasSeenLms',
        event: 'change'
    },
    props: {
        hasSeenLms: {
            type: Boolean,
            default: false
        }
    },
    data() {
        return {
            lmsUrl: `${STRATUS.Config.SiteUrl}/Help/LMS`,
            showLmsTermsDialog: false
        };
    },
    methods: {
        launchLms() {
            const vm = this;

            if (vm.checkHasSeenLms()) {
                window.open(vm.lmsUrl, '_blank');
            }
        },
        checkHasSeenLms(event) {
            if (!this.hasSeenLms) {
                this.showLmsTermsDialog = true;

                if (event) {
                    event.preventDefault();
                }

                return false;
            }

            return true;
        },
        confirmLmsTerms() {
            const vm = this;

            $.ajax({
                url: `${STRATUS.Config.SiteUrl}/Help/SetHasSeenLms`
            }).done(function () {
                vm.$emit('change', true);
                vm.showLmsTermsDialog = false;
                window.open(vm.lmsUrl, '_blank');
            });
        }
    },
    template: `
<div class="hidden-sm">
    <a class="u-header__icon icon icon-ministry-smart" target="_blank" v-bind:href="lmsUrl" v-on:click="checkHasSeenLms"></a>
    <modal-dialog v-model="showLmsTermsDialog" size="medium" pattern="warning" v-cloak>
        <h3>Before we send you to MinistrySmart...</h3>
        <div class="lightbox-content">
            <p class="text-margined">
                When you click <strong>Yes, I understand</strong>, you're leaving Realm and visiting MinistrySmart, which utilizes a
                <span class="text-nowrap">third-party</span> platform provided by Thought Industries. As such, you're now
                subject to their <a href="https://www.thoughtindustries.com/privacy-policy" target="_blank">Privacy Policy</a>
                and <a href="https://www.thoughtindustries.com/terms-and-conditions" target="_blank">Terms and Conditions</a>.
            </p>
            <p class="text-margined">
                Note: If you're a staff user for more than one {{'church' | personalizedTerm}}, you can only have one MinistrySmart account.
                Access MinistrySmart from your primary Realm account to avoid losing your progress.
            </p>
        </div>

        <div class="buttons">
            <input type="button" class="button button-warning" value="Yes, I understand" v-on:click="confirmLmsTerms" />
            <a href="javascript:void(0);" v-on:click="showLmsTermsDialog = false">Cancel</a>
        </div>
    </modal-dialog>
</div>`
});;
STRATUS.ObjectPaging = function () {
    var _resultsArray = [];

    var getObjectPage = function (dataId, page) {
        return $.ajax({
            url: STRATUS.Config.SiteUrl + '/ObjectPaging/GetObjectPage',
            data: {
                dataId: dataId,
                page: page
            },
            pageData: page,
            success: function (results) {
                _resultsArray[this.pageData] = results;
            }
        });
    };

    return {
        getPagedObject: function (id, pages, successCallback, errorCallback) {
            _resultsArray = new Array(pages);
            var promises = [];
            //spin off ajax calls to get the data
            for (var i = 0; i < pages; i++) {
                promises.push(getObjectPage(id, i, _resultsArray[i]));
            }

            $.when.apply(this, promises)
                .then(function () {
                    try {
                        var returnObj = JSON.parse(_resultsArray.join(''));
                        successCallback(returnObj);
                    }
                    catch (e) {
                        errorCallback();
                    }
                    
                }, errorCallback);
        }
    }
}();;
Vue.component('page-stepper', {
    props: {
        list: {
            type: Array,
            default: () => []
        },
        activeStep: {
            type: String,
            required: true
        }
    },
    data() {
        const vm = this;

        return {
            steps: vm.list.map(function (step) {
                return {
                    name: step,
                    isActive: step === vm.activeStep
                };
            })
        }
    },
    methods: {
        stepClicked(index) {
            const vm = this;

            vm.steps.forEach((step) => step.isActive = false);
            vm.steps[index].isActive = true;
            vm.$emit('change', vm.steps[index].name);
        }
    },
    template: `
<ol class="u-page-stepper unselectable">
    <li v-for="(step, index) in steps" v-bind:key="" class="page-step" v-bind:class="{ 'page-step--active': step.isActive }" v-on:click="stepClicked(index)">
        <a href="javascript:void(0);">
            <div class="page-step-number">{{index + 1}}</div>
            <div class="page-step-name">{{step.name}}</div>
        </a>
    </li>
</ol>`
});;
Vue.component('profile-menu', {
    props: {
        app: {
            type: String,
            default: 'realm'
        },
        isStaff: {
            type: Boolean,
            default: false
        },
        showRealmProfile: {
            type: Boolean,
            default: false
        },
        showConnectProfile: {
            type: Boolean,
            default: false
        },
        showPaymentMethods: {
            type: Boolean,
            default: false
        },
        showRealmNotifications: {
            type: Boolean,
            default: false
        },
        showConnectNotifications: {
            type: Boolean,
            default: false
        },
        signOutOnly: {
            type: Boolean,
            default: false
        },
        nameParts: {
            type: Object,
            default() {
                return {
                    FirstName: '',
                    PreferredName: '',
                    LastName: ''
                };
            }
        }
    },
    data() {
        const vm = this;
        const returnUrl = encodeURIComponent(window.location.href);

        return {
            isActive: false,
            year: new Date().getFullYear(),
            realmProfileUrl: `${STRATUS.Config.SiteUrl}/Individual/Info/${STRATUS.Config.IndividualId}`,
            connectProfileUrl: `${STRATUS.Config.EngagementHost}/profiles/${STRATUS.Config.IndividualId}`,
            accountUrl: `${STRATUS.Config.SiteUrl}/Account?returnUrl=${returnUrl}`,
            privacyUrl: `${STRATUS.Config.SiteUrl}/Individual/Privacy?returnUrl=${returnUrl}`,
            paymentMethodsUrl: `${STRATUS.Config.SiteUrl}/Giving/Payments?returnUrl=${returnUrl}`,
            realmNotificationsUrl: `${STRATUS.Config.SiteUrl}/Account/ChangeEmailNotification${vm.isConnect ? '' : `?returnUrl=${returnUrl}`}`,
            connectNotificationsUrl: `${STRATUS.Config.EngagementHost}/settings`,
            signOutUrl: `${STRATUS.Config.SiteUrl}/Account/SignOut?returnUrl=${returnUrl}`,
            supportUrl: `${STRATUS.Config.SiteUrl}/Help?controller=${window.location.pathname.split('/')[2]}`,
            termsUrl: `${STRATUS.Config.Host}/About/Use`
        };
    },
    computed: {
        preferredName() {
            return this.nameParts.PreferredName || this.nameParts.FirstName;
        },
        initials() {
            const vm = this;
            let initials = '';

            if (vm.preferredName.length) {
                initials += vm.preferredName.substring(0, 1).toUpperCase();
            }

            if (vm.nameParts.LastName.length) {
                initials += vm.nameParts.LastName.substring(0, 1).toUpperCase();
            }

            return initials;
        },
        isConnect() {
            return this.app === 'connect';
        }
    },
    mounted() {
        const vm = this;

        vm.$nextTick(() => {
            document.addEventListener('click', function (event) {
                if (!event.target.closest('.u-header__profile-menu')) {
                    vm.isActive = false;
                }
            });
        });
    },
    template: `
<div class="u-header__profile-menu relative" v-bind:class="{ active: isActive }">
    <a class="u-header__profile-menu__header" href="javascript:void(0);" v-on:click="isActive = !isActive">
        <div class="u-header__profile-menu__avatar">{{initials}}</div>
        <div class="u-header__profile-menu__name hidden-md">{{preferredName}}</div>
        <span class="icon ui-redesign icon-caret-down icon-animate hidden-md" v-bind:class="{ 'icon-rotate-180': isActive }"></span>
    </a>
    <div v-show="isActive" class="u-header__menu u-menu">
        <template v-if="!signOutOnly">
            <template v-if="showRealmProfile && showConnectProfile">
                <h5 class="u-header__menu__section">My Profile Views</h5>
            </template>
            <ul class="u-header__menu__section">
                <li v-if="showRealmProfile"><a href="javascript:void(0);">{{showConnectProfile ? 'Realm' : 'View My Profile'}}<span v-if="isConnect" class="icon ui-redesign icon-launch-outline"></span></a></li>
                <li v-if="showConnectProfile"><a href="javascript:void(0);">{{showRealmProfile ? 'Connect' : 'View My Profile'}}<span v-if="!isConnect" class="icon ui-redesign icon-launch-outline"></span></a></li>
            </ul>
            <h5 class="u-header__menu__section">Account Settings</h5>
            <ul>
                <li><a href="javascript:void(0);">My Account</a></li>
                <li><a href="javascript:void(0);">Privacy</a></li>
                <li v-if="showPaymentMethods"><a href="javascript:void(0);">Payment Methods</a></li>
            </ul>
            <template v-if="showRealmNotifications || showConnectNotifications">
                <h5 class="u-header__menu__section">Notifications</h5>
                <ul>
                    <li v-if="showRealmNotifications"><a href="javascript:void(0);">{{isStaff ? 'Realm' : 'Leader'}}<span v-if="isConnect" class="icon ui-redesign icon-launch-outline"></span></a></li>
                    <li v-if="showConnectNotifications"><a href="javascript:void(0);">{{isStaff ? 'Connect' : 'Participant'}}<span v-if="!isConnect" class="icon ui-redesign icon-launch-outline"></span></a></li>
                </ul>
            </template>
        </template>
        <ul>
            <li><a href="javascript:void(0);">Sign Out</a></li>
        </ul>
        <footer v-if="!signOutOnly">
            <a href="javascript:void(0);">Support</a>
            <span class="bullet">&bull;</span>
            <a href="javascript:void(0);">Privacy</a>
            <span class="bullet">&bull;</span>
            <a href="javascript:void(0);">Terms of Use</a>
            <div class="text-muted">Copyright &copy; {{year}} ACS Technologies.</div>
        </footer>
    </div>
</div>`
});;
STRATUS.RealmStreaming = function () {
    let storageKey;

    const goToRealmStreaming = function () {
        STRATUS.ClientStorage.setValue(storageKey, true, false);
        $.lightBox('hide');
        window.open(STRATUS.Config.SiteUrl + '/Streaming/Redirect');
    };

    const displayDisclaimer = function () {
        $.lightBox('show',
            {
                header: 'Before we send you to Realm Streaming...',
                message: `When you click <strong>Yes, I understand</strong>, you'll be visiting Realm Streaming, an integrated third-party platform powered by our partner, Worldplay. As such, you're subject to their <a target="_blank" href="https://ir.worldplaynetworks.com/en/terms-of-use.3">Terms of Use and Privacy Policy</a>.`,
                okButtonText: 'Yes, I understand',
                showCancelButton: true,
                lightboxType: 'warning',
                callback: goToRealmStreaming
            });
    };

    const navigateToRealmStreaming = function () {
        storageKey = STRATUS.Config.IndividualId + '-streaming-disclaimer-seen';

        if (STRATUS.ClientStorage.getValue(storageKey, false)) {
            goToRealmStreaming();
        } else {
            displayDisclaimer();
        }
    };

    return {
        navigateToRealmStreaming
    };
}();;
STRATUS.Reports = function () {
    var pollStatus = function (options) {
        $.ajax({
            url: STRATUS.Config.SiteUrl + '/Reports/IsComplete/' + options.id,
            success: function (result) {
                if (result === true) {
                    var url = STRATUS.Config.SiteUrl + '/Reports/Download/' + options.id + '?';
                    var urlParams = {
                        attachment: options.newTab === false,
                        fileType: options.fileType || 'pdf'
                    };

                    url += $.param(urlParams);

                    var growlOptions;
             
                    if (!options.manualOpen) {
                        window.open(url, '_parent');
                        growlOptions = {
                            content: 'Your report has finished.',
                            type: 'success'
                        };
                    } else {
                        growlOptions = {
                            content: 'Your report is ready to <a target="_blank" href="' + url + '">download</a>.',
                            type: 'success',
                            delay: 0
                        };
                    }

                    $.growler(growlOptions);

                    if (options.callback) {
                        options.callback();
                    }
                    
                    return;
                }

                setTimeout(function () { pollStatus(options); }, 2500);
            }
        });
    };

    var scheduleReport = function (options) {
        STRATUS.Helpers.showProcessingMessage();

        return $.ajax({
            type: 'POST',
            url: options.url,
            data: options.data,
            success: function (scheduleId) {
                STRATUS.Reports.dialog(scheduleId, null, options.closeCallback, options.title, undefined, { fileType: options.fileType || 'pdf' }, undefined, options.deleteLightboxContent);

                if (options.callback) {
                    options.callback();
                }
            },
            complete: function () {
                STRATUS.Helpers.hideProcessingMessage();
            }
        });
    };

    var scheduleCsv = function (options) {
        STRATUS.Helpers.showProcessingMessage();
        $.ajax({
            type: 'POST',
            url: options.url,
            data: options.data,
            success: function (scheduleId) {
                $.growler({
                    content: 'Your csv report has been scheduled.',
                    type: 'success'
                });

                var pollOptions = {
                    id: scheduleId,
                    newTab: false,
                    fileType: 'csv',
                    manualOpen: false
                };

                pollStatus(pollOptions);

                if (options.callback) {
                    options.callback();
                }
            },
            complete: function () {
                STRATUS.Helpers.hideProcessingMessage();
            }
        });
    };

    var printAttendanceMarking = function(url) {
        var id = $('#attendance-report-entity-id').val();
        var dateRange = $('#date-range-selector').dateRangeSelector('getValue');
        var orientation = $('input[name=attendance-report-layout-radio]:checked').val();
        var includeEventName = $('#attendance-report-include-event-name').is(':checked');
        var includeEventTime = $('#attendance-report-include-event-time').is(':checked');
        var includeEmail = $('#attendance-report-include-email').is(':checked');
        var includePhone = $('#attendance-report-include-phone').is(':checked');
        var includePrimaryContact = $('#attendance-report-include-primary-contact').is(':checked');
        var includeBirthday = $('#attendance-report-include-birthday').is(':checked');
        var includeAllergies = $('#attendance-report-include-allergies').is(':checked');
        var includeInactiveProfiles = $('#attendance-include-inactive-profiles').is(':checked');

        var data = {
            id: id,
            attendanceSheetPrintOption: dateRange.DateRangeType,
            beginDate: dateRange.BeginDate,
            endDate: dateRange.EndDate,
            orientation: orientation,
            includeEventName: includeEventName,
            includeEventTime: includeEventTime,
            includeEmail: includeEmail,
            includePhone: includePhone,
            includePrimaryContact: includePrimaryContact,
            includeBirthday: includeBirthday,
            includeAllergies: includeAllergies,
            includeInactiveProfiles: includeInactiveProfiles
        };
        
        var options = {
            url: url,
            data: data
        };
        
        $.lightBox('hide', function () {
            STRATUS.Reports.schedule(options);
        });
    };

    var printRoster = function (url, data) {
        var id = $('#roster-report-entity-id').val();
        var orientation = $('input[name=roster-report-layout-radio]:checked').val();
        var includeEmail = $('#roster-report-include-email').is(':checked');
        var includePhone = $('#roster-report-include-phone').is(':checked');
        var includeAddress = $('#roster-report-include-address').is(':checked');
        var includePrimaryContact = $('#roster-report-include-primary-contact').is(':checked');
        var includeBirthday = $('#roster-report-include-birthday').is(':checked');
        var includeAllergies = $('#roster-report-include-allergies').is(':checked');
        var includeInactiveProfiles = $('#include-inactive-profiles').is(':checked');
        var includeAttributes = $('#roster-report-include-attributes').is(':checked');
        var showAll = $('#roster-report-show-all').prop('checked');

        var data = {
            id: id,
            orientation: orientation,
            includeEmail: includeEmail,
            includePhone: includePhone,
            includeAddress: includeAddress,
            includePrimaryContact: includePrimaryContact,
            includeBirthday: includeBirthday,
            includeAllergies: includeAllergies,
            includeInactiveProfiles: includeInactiveProfiles,
            includeAttributes: includeAttributes,
            includeInactiveGroups: true,
            isExclusion: showAll ? false : data.isExclusion,
            selectedList: showAll ? [] : data.selectedList
        };

        var options = {
            url: url,
            data: data
        };

        $.lightBox('hide', function () {
            STRATUS.Reports.schedule(options);
        });
    };

    var printEventRegistrationReport = function (url, data) {
        var options = {
            url: url,
            data: data
        };

        $.lightBox('hide', function () {
            STRATUS.Reports.schedule(options);
        });
    };

    var removeLightBox = function (dialog, callback, deleteLightboxContent) {
        $.lightBox('hide', function() {
            dialog.remove();
            
            if (typeof callback === 'function') {
                callback();
            }
        }, deleteLightboxContent);
    };

    var getReportUrl = function (reportId, fileType) {
        return STRATUS.Config.SiteUrl + '/Reports/Download/' + reportId + '?' + $.param({ attachment: true, fileType: (fileType || 'pdf') });
    };

    var buildDialog = function (reportId, downloadUrl, fileType) {
        var html = [];

        html.push('<div id="report-viewer-dialog-' + reportId + '" class="lightbox full report-viewer-dialog">');
        html.push('<h3 class="text-capitalize"></h3>');
        html.push('<div class="report-message hidden"></div>');

        if (fileType === "csv") {
            html.push('<div class="report-container-sm js-report-viewer" data-report-id="' + reportId + '">');
        } else {
            html.push('<div class="report-container js-report-viewer" data-report-id="' + reportId + '">');
        }

        html.push('</div>');
        html.push('<div class="buttons">');
        html.push('    <a class="button js-download-button" disabled="disabled" href="' + downloadUrl + '" >Download</a>');
        html.push('    or <a class="js-close-button" href="javascript:void(0);">Close</a>');
        html.push('</div>');
        html.push('</div>');

        var dialog = $(html.join(''));

        return dialog;
    };

    return {
        schedule: function (options) {
            // options: url, data, manualOpen, newTab, callback, closeCallback, title, deleteLightboxContent
            return scheduleReport(options);
        },
        scheduleCsv: function (options) {
            // options: url, data, callback
            scheduleCsv(options);
        },
        printAttendanceMarkingReport: function(url) {
            printAttendanceMarking(url);
        },
        printRosterReport: function (url, data) {
            printRoster(url, data);
        },
        printEventRegistrationReport: function (url, data) {
            printEventRegistrationReport(url, data);
        },
        pollStatus: function (options) {
            //options: id, manualOpen, newTab, callback
            pollStatus(options);
        },
        getReportUrl,
        dialog: function (reportId, callback, closecallback, title, endpoints, additionalData, downloadUrl, deleteLightboxContent) {
            var fileType = additionalData ? additionalData.fileType : null;
            downloadUrl = downloadUrl || getReportUrl(reportId, fileType);
            var dialog = buildDialog(reportId, downloadUrl, fileType);
            $('body').append(dialog);
            $('#' + dialog.attr('id')).data('completeCallback', function () {
                $('.js-report-viewer', dialog).reportViewer({
                    reportLoaded: function (report) {
                        let reportName = title || report.Name;
                        reportName = reportName.split(' ').length > 1 ? reportName : STRATUS.Formatters.splitOnCamelCase(reportName);
                        $('h3', dialog).text(reportName);
                    },
                    reportFinished: function () {
                        $('.js-download-button').removeAttr('disabled');
                    },
                    endpoints: endpoints,
                    additionalData: additionalData
                });

                $('.js-close-button', dialog).click(function () {
                    removeLightBox(dialog, closecallback, deleteLightboxContent);
                });

                if (typeof callback === 'function') {
                    callback();
                }
            }).lightBox('show', deleteLightboxContent);
        }
    };
}();
;
Vue.component('site-alerts', {
    model: {
        prop: 'list',
        event: 'change'
    },
    props: {
        list: {
            type: Array,
            default: () => []
        }
    },
    data() {
        return {
            alerts: this.initializeAlerts()
        };
    },
    watch: {
        list() {
            return this.initializeAlerts();
        }
    },
    methods: {
        initializeAlerts() {
            this.alerts = this.list.map((alert) => {
                return Object.assign({ isDismissed: false }, alert);
            });
        },
        dismiss(alert, index) {
            const vm = this;

            alert.isDismissed = true;
            setTimeout(() => {
                vm.alerts.splice(index, 1);
                vm.$emit('change', vm.alerts);
            }, 250);

            $.ajax({
                url: `${STRATUS.Config.SiteUrl}/Account/DismissNotification`,
                data: { id: alert.NotificationId },
                error() {
                    // Don't show error message if this fails.
                }
            });
        }
    },
    template: `
<div class="u-site-alerts">
    <div v-for="(alert, index) in alerts" v-bind:key="alert.NotificationId" class="u-site-alert hidden-print" v-bind:class="{ 'u-site-alert--dismissed': alert.isDismissed }">
        {{alert.Message}}
        <a class="icon icon-times" href="javascript:void(0)" v-on:click="dismiss(alert, index)"></a>
    </div>
</div>`
});;
Vue.component('streaming-link', {
    data() {
        return {
            storageKey: `${STRATUS.Config.IndividualId}-streaming-disclaimer-seen`,
            streamingUrl: `${STRATUS.Config.SiteUrl}/Streaming/Redirect`,
            showStreamingTermsDialog: false
        };
    },
    methods: {
        launchStreaming() {
            const vm = this;

            if (STRATUS.ClientStorage.getValue(vm.storageKey, false)) {
                window.open(vm.streamingUrl, '_blank');
            } else {
                vm.showStreamingTermsDialog = true;
            }
        },
        confirmStreamingTerms() {
            const vm = this;

            STRATUS.ClientStorage.setValue(vm.storageKey, true, false);
            vm.showStreamingTermsDialog = false;
            window.open(vm.streamingUrl, '_blank');
        }
    },
    template: `
<modal-dialog v-model="showStreamingTermsDialog" size="medium" pattern="warning" v-cloak>
    <h3>Before we send you to Realm Streaming...</h3>
    <div class="lightbox-content">
        <p>
            When you click <strong>Yes, I understand</strong>, you'll be visiting Realm Streaming, an integrated third-party platform powered by our partner, Worldplay.
            As such, you're subject to their <a target="_blank" href="https://ir.worldplaynetworks.com/en/terms-of-use.3">Terms of Use and Privacy Policy</a>.
        </p>
    </div>
    <div class="buttons">
        <input type="button" class="button button-warning" value="Yes, I understand" v-on:click="confirmStreamingTerms" />
        <a href="javascript:void(0);" v-on:click="showStreamingTermsDialog = false">Cancel</a>
    </div>
</modal-dialog>`
});;
STRATUS.Testing = function() {
    return {
        init: function () {
            // Helper for ATs... clicking a gear's parent will show the gear.
            $(document).on('click', '.hide-actions', function (e) {
                // Needed to stop propagation so nested actions don't all appear (REALM-58915)
                e.stopPropagation();
                $(this).find('.actions').first().css('visibility', 'visible');
            });
            
            $(document).on('mouseout', '.hide-actions', function () {
                $(this).find('.actions').first().css('visibility', '');
            });
        }
    };
}();;
