var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
import config from 'src/config';
import { store } from 'src/app/redux/store';
import api from 'src/lib/api/services/api';
import { getCountryList } from 'src/lib/api/helpers';
import { action_map, action_map_default, defaultAppointment, defaultFilters, DOC_TYPE_TRANSLATE_BY_KEY, googleGeocodeApi, letterRegExp, milesInKm, QueryParams, searchTypes, SFDCPatientTypeMap, } from '../../constants';
import { distUnitMap, generateShortGuid, getCookie, isValidZip, makePath, setCookie, waitUntil, } from '../../utils';
import { DocLocViews, PatientType, SortTypes, Tiers, SFDCPatientType, } from '../../types/types';
export var recordAction = function (action) {
    if (typeof Storage !== 'undefined' && action_map[action] != undefined) {
        var amap = window.sessionStorage.getItem('amap');
        if (amap == undefined) {
            amap = action_map_default;
        }
        else {
            amap = JSON.parse(amap);
        }
        amap[action] = action_map[action];
        window.sessionStorage.setItem('amap', JSON.stringify(amap));
    }
};
export var getActionScore = function () {
    var score = 0;
    if (typeof Storage !== 'undefined') {
        var amap = window.sessionStorage.getItem('amap');
        if (amap != undefined)
            amap = JSON.parse(amap);
        // @ts-ignore
        for (var i in amap) {
            score += amap[i];
        }
    }
    // @ts-ignore
    return parseInt(score, 2);
};
export var getSortType = function (extSortType) {
    if (!extSortType)
        return;
    if (extSortType === 'distance')
        return SortTypes.distance;
    if (extSortType === 'name')
        return SortTypes.name;
    if (extSortType === 'teen')
        return SortTypes.teen;
    if (extSortType === 'itero')
        return SortTypes.itero;
    return SortTypes.experience;
};
export var getSearchType = function () {
    var _a = store.getState().filter.filters, address = _a.address, city = _a.city, doctorName = _a.doctorName;
    if (city !== '' && address === '' && doctorName === '')
        return searchTypes.CITY;
    if (address !== '' && doctorName === '')
        return searchTypes.ADDRESS;
    if (doctorName !== '')
        return searchTypes.NAME;
    return searchTypes.ZIP;
};
export var getVisitorId = function () {
    var savedId = getCookie('vid');
    if (savedId && savedId.length)
        return savedId;
    savedId = generateShortGuid();
    setCookie('vid', savedId, 365 * 5);
    return savedId;
};
export var getProfileUrl = function (item) {
    if (item.HasBio && !item.ProfilePhoto) {
        return 'https://images.ctfassets.net/vh25xg5i1h5l/5jVU9tu7kDhzo4aAVyLpFr/848a5fcb97d48119173896543b3b6ab4/profile-image.png';
    }
    return item.ProfilePhoto;
};
export var getLocationByAddress = function (address_1) {
    var args_1 = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        args_1[_i - 1] = arguments[_i];
    }
    return __awaiter(void 0, __spreadArray([address_1], __read(args_1), false), void 0, function (address, language, region) {
        var googleKey;
        if (language === void 0) { language = 'en'; }
        if (region === void 0) { region = 'us'; }
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    googleKey = store.getState().config.config.googleKey;
                    return [4 /*yield*/, api
                            .get("".concat(googleGeocodeApi, "?address=").concat(address, "&key=").concat(googleKey, "&language=").concat(language, "&region=").concat(region))
                            .then(function (response) {
                            if (response.status === 'ZERO_RESULTS')
                                return new Error();
                            var _a = response.results[0].geometry.location, lat = _a.lat, lng = _a.lng;
                            var address = response.results[0].formatted_address;
                            return { lat: lat, lng: lng, address: address };
                        }, function (error) {
                            console.error(error);
                            return error;
                        })];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
};
export var getAddressFromLatLng = function (lat_1, lng_1) {
    var args_1 = [];
    for (var _i = 2; _i < arguments.length; _i++) {
        args_1[_i - 2] = arguments[_i];
    }
    return __awaiter(void 0, __spreadArray([lat_1, lng_1], __read(args_1), false), void 0, function (lat, lng, language, region) {
        var googleKey;
        if (language === void 0) { language = 'en'; }
        if (region === void 0) { region = 'us'; }
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    googleKey = store.getState().config.config.googleKey;
                    return [4 /*yield*/, api
                            .get("".concat(googleGeocodeApi, "?latlng=").concat(lat, ",").concat(lng, "&key=").concat(googleKey, "&language=").concat(language, "&region=").concat(region))
                            .then(function (response) {
                            var address = {
                                address_compnents: response.results[0].address_components,
                                formatted_address: response.results[0].formatted_address,
                            };
                            return address;
                        }, function (error) {
                            console.error(error);
                            return error;
                        })];
                case 1: return [2 /*return*/, _a.sent()];
            }
        });
    });
};
export var getDistanceByLatLng = function (lat1, lat2, lon1, lon2, distUnit) {
    var _a;
    lon1 = (lon1 * Math.PI) / 180;
    lon2 = (lon2 * Math.PI) / 180;
    lat1 = (lat1 * Math.PI) / 180;
    lat2 = (lat2 * Math.PI) / 180;
    // Haversine formula
    var dlon = lon2 - lon1;
    var dlat = lat2 - lat1;
    var a = Math.pow(Math.sin(dlat / 2), 2) +
        Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(dlon / 2), 2);
    var c = 2 * Math.asin(Math.sqrt(a));
    var r = (_a = distUnitMap[distUnit]) !== null && _a !== void 0 ? _a : 3956; // radius of earth, defaults to miles
    return getRoundedDistanceWithUnit(c * r);
};
export var getMapsDirectionsLink = function (doc) {
    return "https://maps.google.com/maps?saddr=&daddr=".concat(doc.Line1, ", ").concat(doc.Line2, ", ").concat(doc.City, ", ").concat(doc.State, ", ").concat(doc.PostalCode);
};
export var getMapsDirectionsLinkForDoctor = function (doc) {
    return "https://maps.google.com/maps?saddr=&daddr=".concat(doc.line1).concat(doc.line2 ? ", ".concat(doc.line2) : "", ", ").concat(doc.city, ", ").concat(doc.state, ", ").concat(doc.postal_code);
};
export var getRoundedDistanceWithUnit = function (distance) {
    var _a, _b, _c, _d;
    var _e = store.getState().config.config, country = _e.country, countryData = _e.countryData, localeId = _e.localeId, language = _e.language, languageData = _e.languageData;
    var localeDistance = (localeId === null || localeId === void 0 ? void 0 : localeId.split('-')[1]) === 'CA' ? distance * milesInKm : distance;
    var dist = Math.round(localeDistance * 10) / 10;
    var distUnit = dist === 1
        ? (_b = (_a = countryData[country]) === null || _a === void 0 ? void 0 : _a.distUnit) !== null && _b !== void 0 ? _b : 'mile'
        : (_d = (_c = languageData[language]) === null || _c === void 0 ? void 0 : _c.miles) !== null && _d !== void 0 ? _d : 'miles';
    return "".concat(dist, " ").concat(distUnit);
};
export var getDoctorTypeText = function (docType) {
    if (!docType)
        return;
    var _a = store.getState().config.config, language = _a.language, languageData = _a.languageData;
    var t = languageData[language];
    var tKey = DOC_TYPE_TRANSLATE_BY_KEY[docType];
    return t[tKey] || tKey;
};
export var getMarkerPos = function (tier) {
    var tierPos = '';
    if (tier === Tiers.VIP)
        tierPos = '-163px 0px';
    if (tier === Tiers.PLATINUM_PLUS)
        tierPos = '-32px 0px';
    if (tier === Tiers.PLATINUM)
        tierPos = '-32px 0px';
    if (tier === Tiers.GOLD_PLUS)
        tierPos = '-64px 0px';
    if (tier === Tiers.GOLD)
        tierPos = '-64px -27px';
    if (tier === Tiers.SILVER_PLUS)
        tierPos = '-97px 0px';
    if (tier === Tiers.SILVER)
        tierPos = '-95px -27px';
    if (tier === Tiers.BRONZE)
        tierPos = '-129px -29px';
    return tierPos;
};
export var getMarkerHoverPos = function (tier) {
    var tierPos = '';
    if (tier === Tiers.VIP)
        tierPos = '-163px 0px';
    if (tier === Tiers.PLATINUM_PLUS)
        tierPos = '-32px 0px';
    if (tier === Tiers.PLATINUM)
        tierPos = '-32px 0px';
    if (tier === Tiers.GOLD_PLUS)
        tierPos = '-64px 0px';
    if (tier === Tiers.GOLD)
        tierPos = '-64px -27px';
    if (tier === Tiers.SILVER_PLUS)
        tierPos = '-97px 0px';
    if (tier === Tiers.SILVER)
        tierPos = '-95px -27px';
    if (tier === Tiers.BRONZE)
        tierPos = '-129px -29px';
    return tierPos;
};
export var getWebsiteLink = function (url) {
    if (!!!url)
        return '';
    if (url.includes('https://'))
        return url.replace('https://', '');
    if (url.includes('http://'))
        return url.replace('http://', '');
    return url;
};
export var getCountryName = function (name) {
    if (name === 'us')
        return 'USA';
    return name;
};
var getSessionId = function () {
    var sid = sessionStorage.getItem('sid');
    if (sid)
        return sid;
    var sId = generateShortGuid();
    sessionStorage.setItem('sid', sId);
    return sId;
};
export var getAppointmentForm = function () {
    var appFormCookie = getCookie('appointmentForm');
    var appForm = appFormCookie ? JSON.parse(appFormCookie) : defaultAppointment;
    return appForm;
};
export var hasParamsInUrl = function (countryData) {
    if (countryData === null || countryData === void 0 ? void 0 : countryData.query_param_profile)
        QueryParams.push(countryData.query_param_profile);
    var query = window.location.search;
    return query != '' && QueryParams.some(function (param) { return query.includes(param); });
};
export var getURLParameter = function (name) {
    // @ts-ignore
    return decodeURI((RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, null])[1]);
};
export var changePath = function (changeView, slug, urlParams, setAppView, callbackForChangeView) { return __awaiter(void 0, void 0, void 0, function () {
    var getPath, path, getParams, params;
    return __generator(this, function (_a) {
        switch (_a.label) {
            case 0:
                getPath = function () {
                    var path = window.location.pathname;
                    if (slug)
                        path = slug;
                    return makePath(path);
                };
                path = getPath();
                if (changeView)
                    changeView(slug, urlParams, callbackForChangeView);
                else {
                    getParams = function () {
                        if (!urlParams)
                            return '';
                        return urlParams.charAt(0) === '?' ? urlParams : "?".concat(urlParams);
                    };
                    params = getParams();
                    window.history.pushState(null, '', "".concat(path).concat(params));
                }
                if (!setAppView) return [3 /*break*/, 3];
                if (!(window.location.pathname !== path)) return [3 /*break*/, 2];
                return [4 /*yield*/, waitUntil(function () { return window.location.pathname !== path; }, setAppView, 50)];
            case 1:
                _a.sent();
                return [3 /*break*/, 3];
            case 2:
                setAppView();
                _a.label = 3;
            case 3: return [2 /*return*/];
        }
    });
}); };
export var getPageView = function (slugs, isCa, zipUtility, skipWelcome) {
    var doctorLocatorUrl = slugs.doctorLocatorUrl, doctorProfileUrl = slugs.doctorProfileUrl;
    var path = window.location.pathname;
    var filtersFromUrl = getFiltersFromUrl();
    var zipFromUrl = filtersFromUrl.zip;
    var hasLatLng = !isNaN(Number(filtersFromUrl.lat)) && !isNaN(Number(filtersFromUrl.lng));
    var isFadPage = makePath(doctorLocatorUrl).includes(path);
    if (isFadPage &&
        ((!skipWelcome && !zipFromUrl) || !isValidZip(zipFromUrl, isCa, zipUtility)) &&
        !hasLatLng) {
        return DocLocViews.WELCOME;
    }
    if (isFadPage && ((zipFromUrl && isValidZip(zipFromUrl, isCa, zipUtility)) || hasLatLng)) {
        return DocLocViews.RESULT;
    }
    if (makePath(doctorProfileUrl).includes(path))
        return DocLocViews.DOC_PROFILE;
    if (skipWelcome)
        return DocLocViews.RESULT;
    return DocLocViews.WELCOME;
};
export var getPageUrlForTracking = function () {
    var path = window.location.pathname.charAt(0) === '/'
        ? window.location.pathname.split('').splice(1, window.location.pathname.length).join('')
        : window.location.pathname;
    return path.replace('/', '_');
};
export var getFiltersFromUrl = function (countryData) {
    var _a;
    if (!hasParamsInUrl(countryData))
        return {};
    var params = window.location.search
        .substring(1)
        .split('&')
        .map(function (param) { return param.split('='); });
    var filtersFromUrl = Object.fromEntries(params);
    var decodedZip = decodeURIComponent(filtersFromUrl.zip);
    var getZip = function () {
        if (!decodedZip || decodedZip === 'undefined')
            return '';
        var countryCode = getCountryList(decodedZip);
        var formattedZip = decodedZip.includes('+') ? decodedZip.replace('+', ' ') : decodedZip;
        if (countryCode === 'CA' ||
            (decodedZip.includes('+') && getCountryList(formattedZip) === 'CA')) {
            if (formattedZip.length < 7)
                return '';
            return formattedZip.slice(0, 7);
        }
        if (countryCode.includes('US')) {
            if (formattedZip.split('').some(function (letter) {
                return letterRegExp.test(letter);
            })) {
                return '';
            }
            return decodedZip.slice(0, 5);
        }
        return decodedZip;
    };
    var zipFromUrl = getZip();
    filtersFromUrl.zip = zipFromUrl;
    var patientType = filtersFromUrl.searchType
        ? decodeURIComponent(filtersFromUrl.searchType).replace(/\+/g, ' ')
        : undefined;
    var vivera = filtersFromUrl.vivera ? filtersFromUrl.vivera === 'yes' : undefined;
    var program = filtersFromUrl.program ? filtersFromUrl.program : undefined;
    var trt = filtersFromUrl.trt ? filtersFromUrl.trt : undefined;
    var svc = filtersFromUrl.svc ? filtersFromUrl.svc : undefined;
    var address = filtersFromUrl.address ? decodeURIComponent(filtersFromUrl.address) : undefined;
    var formatted_address = (address === null || address === void 0 ? void 0 : address.includes('+'))
        ? address.replace(/(\+)/g, ' ')
        : address || undefined;
    var profile = (countryData === null || countryData === void 0 ? void 0 : countryData.query_param_profile)
        ? filtersFromUrl["".concat(countryData.query_param_profile)] || filtersFromUrl.profile
        : filtersFromUrl.profile;
    var sortType = filtersFromUrl.sort ? filtersFromUrl.sort : undefined;
    var treatments = __assign(__assign({}, (trt && (_a = {}, _a[trt] = true, _a))), (vivera && { vivera_retainers: true }));
    var fservice = [];
    if (svc) {
        fservice.push(svc);
    }
    var filters = __assign(__assign(__assign({}, filtersFromUrl), { address: formatted_address, profile: profile, program: program, treatments: treatments, fservice: fservice, sortType: sortType }), (svc === 'extended_hours' && { fehours: true }));
    var isSFDCPatientType = patientType && (patientType === SFDCPatientType.ADULT || patientType === SFDCPatientType.TEEN);
    if (patientType &&
        (patientType === PatientType.ADULT || patientType === PatientType.TEEN || isSFDCPatientType)) {
        filters.patientType = isSFDCPatientType ? SFDCPatientTypeMap[patientType] : patientType;
    }
    delete filters.searchType;
    for (var key in filters) {
        var value = filters[key];
        if (!value)
            delete filters[key];
    }
    return filters;
};
export var getAllFilters = function (view) {
    var _a;
    var filters = store.getState().filter.filters;
    var filtersFromUrl = getFiltersFromUrl();
    if (view === DocLocViews.RESULT) {
        var resultFilters = store.getState().filter.resultFilters;
        var _b = store.getState().config.config, availablePrograms = _b.availablePrograms, availableServices = _b.availableServices, availableTreatments = _b.availableTreatments, lanuagesFilterOptions_1 = _b.lanuagesFilterOptions, sortOptions = _b.sortOptions;
        filtersFromUrl.program =
            filtersFromUrl.program && (availablePrograms === null || availablePrograms === void 0 ? void 0 : availablePrograms.includes(filtersFromUrl.program))
                ? filtersFromUrl.program
                : '';
        filtersFromUrl.svc =
            filtersFromUrl.svc && (availableServices === null || availableServices === void 0 ? void 0 : availableServices.includes(filtersFromUrl.svc))
                ? filtersFromUrl.svc
                : '';
        filtersFromUrl.trt =
            filtersFromUrl.trt && (availableTreatments === null || availableTreatments === void 0 ? void 0 : availableTreatments.includes(filtersFromUrl.trt))
                ? filtersFromUrl.trt
                : '';
        filtersFromUrl.sortType =
            filtersFromUrl.sortType &&
                sortOptions.some(function (option) { return option.key === filtersFromUrl.sortType; })
                ? (_a = sortOptions.find(function (option) { return option.key === filtersFromUrl.sortType; })) === null || _a === void 0 ? void 0 : _a.value
                : undefined;
        filtersFromUrl.flan =
            filtersFromUrl.lan && lanuagesFilterOptions_1
                ? (function () {
                    var language = lanuagesFilterOptions_1.find(function (item) { return item.urlKey === filtersFromUrl.lan; });
                    return (language === null || language === void 0 ? void 0 : language.value) ? [language.value] : [];
                })()
                : [];
        if (resultFilters)
            return __assign(__assign({}, resultFilters), filtersFromUrl);
    }
    return __assign(__assign(__assign({}, defaultFilters), filters), filtersFromUrl);
};
export var getDefaultFilters = function () {
    var filtersFromUrl = getFiltersFromUrl();
    var sessionId = getSessionId();
    var visitorId = getVisitorId();
    var filters = __assign(__assign(__assign({}, defaultFilters), filtersFromUrl), { visitorId: visitorId, sessionId: sessionId });
    return filters;
};
export var getLandingButtonEvent = function (isTeen) {
    return isTeen
        ? 'inv_fad_doctor_locator_under_20_teen_button'
        : 'inv_fad_doctor_locator_20_and_over_adult_button';
};
export var pluralize = function (count, noun, suffix) {
    if (suffix === void 0) { suffix = 's'; }
    return "".concat(noun).concat(count !== 1 ? suffix : '');
};
export var formatPhoneNumber = function (phoneNumberString) {
    var cleaned = ('' + phoneNumberString).replace(/\D/g, '');
    var match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/);
    if (match) {
        var intlCode = match[1] ? '+1 ' : '';
        return [intlCode, '(', match[2], ') ', match[3], '-', match[4]].join('');
    }
    if (phoneNumberString)
        return phoneNumberString;
    return null;
};
export var convertToAMPM = function (time) {
    var offTime = time.split(':');
    var hours = Number(offTime[0]) > 12 ? Number(offTime[0]) - 12 : Number(offTime[0]);
    var mins = offTime[1];
    var ampm = Number(offTime[0]) < 12 ? 'AM' : 'PM';
    return "".concat(hours, ":").concat(mins, " ").concat(ampm);
};
// Generic helper function to check dynamic programs in LocatorDoctor results
export var hasDynamicProgram = function (item, program) {
    if (!item.DynamicPrograms)
        return false;
    return item.DynamicPrograms[program] === 't';
};
// Generic helper function to check program flags in DoctorProfile
export var hasProgram = function (data, program) {
    if (!data)
        return false;
    if (!data.dynamic_programs)
        return false;
    return data.dynamic_programs[program] === 't';
};
export var getDefaultConfig = function () { return config; };
export var getMobileSortMap = function () {
    var _a = store.getState().config.config, language = _a.language, languageData = _a.languageData, sortOptionsMobile = _a.sortOptionsMobile;
    var t = languageData[language];
    if (sortOptionsMobile && !!sortOptionsMobile.length) {
        return sortOptionsMobile === null || sortOptionsMobile === void 0 ? void 0 : sortOptionsMobile.map(function (sOption) {
            var _a, _b;
            return ({
                label: (!!((_a = sOption.label) === null || _a === void 0 ? void 0 : _a.useLanguageData) ? t[sOption.label.value] : (_b = sOption.label) === null || _b === void 0 ? void 0 : _b.value) || '',
                value: sOption.value,
                type: sOption.type,
                desc: sOption.desc,
            });
        });
    }
    return [
        {
            label: t.result_sort_overall_experience,
            value: 'experience',
            type: 'radio',
        },
        {
            label: t.result_sort_teen_experience,
            value: 'teen',
            type: 'radio',
        },
        {
            label: t.result_sort_distance,
            value: 'distance',
            type: 'radio',
        },
        {
            label: t.result_sort_last_name,
            value: 'name',
            type: 'radio',
        },
        {
            label: t.result_sort_itero_scanning,
            value: 'itero',
            type: 'radio',
            desc: t.result_sort_itero_desc,
        },
    ];
};
export var getMobileFilters = function (props) {
    var _a, _b, _c;
    var _d = store.getState().config.config, language = _d.language, languageData = _d.languageData, country = _d.country, countryData = _d.countryData;
    var distUnit = (_b = (_a = countryData[country]) === null || _a === void 0 ? void 0 : _a.shortDistUnit) !== null && _b !== void 0 ? _b : 'mi';
    var t = languageData[language];
    return [
        {
            label: t.result_filter_patient_label,
            filterName: 'patientType',
            options: [
                {
                    label: t.result_filter_teen,
                    value: PatientType.TEEN,
                    type: 'radio',
                },
                {
                    label: t.result_filter_adult,
                    value: PatientType.ADULT,
                    type: 'radio',
                },
            ],
        },
        {
            id: 'doctorType',
            label: t.result_filter_doctor_label,
            options: [
                {
                    label: t.result_filter_orthodontists,
                    filterName: 'isOrthoDoc',
                    type: 'checkbox',
                },
                {
                    label: t.result_filter_general_dentists,
                    filterName: 'isGeneralDoc',
                    type: 'checkbox',
                },
                {
                    label: t.pediatric_dentists,
                    filterName: 'isPediatric',
                    type: 'checkbox',
                },
            ],
        },
        {
            label: t.result_filter_address_label,
            filterName: 'address',
            options: [
                {
                    label: t.result_filter_address_city,
                    type: 'text',
                },
            ],
        },
        {
            label: t.result_filter_doctor_name_label,
            filterName: 'doctorName',
            options: [
                {
                    label: t.result_filter_doctor_name_search,
                    type: 'text',
                },
            ],
        },
        {
            label: t.result_filter_distance,
            filterName: 'radius',
            options: ((_c = props === null || props === void 0 ? void 0 : props.radiusOptions) === null || _c === void 0 ? void 0 : _c.filter(function (ro) { return !!ro.value; }).map(function (ro) { return (__assign(__assign({}, ro), { type: 'radio' })); })) || [
                { label: "1 ".concat(distUnit), value: '1', type: 'radio' },
                { label: "5 ".concat(distUnit), value: '5', type: 'radio' },
                { label: "10 ".concat(distUnit), value: '10', type: 'radio' },
                { label: "25 ".concat(distUnit), value: '25', type: 'radio' },
                { label: "30 ".concat(distUnit), value: '30', type: 'radio' },
                { label: "50 ".concat(distUnit), value: '50', type: 'radio' },
                { label: "100 ".concat(distUnit), value: '100', type: 'radio' },
            ],
        },
    ];
};
