import { Host, h } from "@stencil/core";
import { ZButton } from "../internal-component/z-button";
import { ZInput } from "../internal-component/z-input";
import { configStore, customFiltersStore, deviceModeStore, filterChatsStore, platformConnectionsStore } from "../../store/store";
import { formatFilterConnection, handleCreateChatFilter, handleDeleteChatFilter, handleGetUserStatuses, handleGetUserTags, handleUpdateChatFilter, haveConnectionFromZwizSME } from "../../store/chat";
import { useTranslation } from "../../utils/utils";
import { ZIconButton } from "../internal-component/z-icon-button";
import { openDialog } from "../../store/dialog";
import { t } from "i18next";
import { getProfileSelection } from "../../api/platform";
export class DialogSearch {
    connectionList = configStore.get('connectionList').flatMap(connection => (connection.type === 'zwiz'
        ? connection.channels.map(channel => ({
            iconName: connection.type,
            subIconName: channel.channel,
            label: channel.channel_name,
            value: channel.id,
            id: channel.id,
            name: channel.channel_name,
            channel: channel.channel,
        }))
        : [{
                iconName: connection.type,
                label: connection.name,
                value: connection.id,
                id: connection.id,
                name: connection.name,
                channel: connection.type,
            }]));
    answerList = configStore.get('memberList')?.map(connection => {
        const fullName = [connection.member_account.first_name || '', connection.member_account.last_name || ''].join(' ').trim();
        const label = fullName ? `${fullName} (${connection.member_login_data.email || connection.member_login_data.username || '-'})` : (connection.member_login_data.email || connection.member_login_data.username);
        return {
            label,
            value: connection.id,
            id: connection.id,
            name: label,
        };
    }) || [];
    verifySlipList = [
        { label: t('chat_filter.verify_slip'), value: 'total_completed_verify_slip' },
        { label: t('chat_filter.verify_slip_more_than'), value: 'total_completed_verify_slip_more_than' },
    ];
    zrmzShopList = [];
    zervaShopList = [];
    defaultFilter = {
        name: '',
        search: '',
        // spam: false,
        read: null,
        type: null,
        connections: this.connectionList.map(connection => ({
            id: connection.id,
            channel: [connection.channel],
        })),
        lastAnswerByIds: this.answerList.map(answer => answer.value) || [],
        statusIds: [],
        tagIds: [],
        userIds: [],
        zrmzCustomerIds: [],
        verifySlip: null,
        verifySlipValue: null,
        zrmz: {
            isOnlyCustomers: false,
            shopId: null,
            name: null,
            email: null,
            phoneNumber: null,
            totalPointType: null,
            totalPointMax: null,
            totalPointMin: null,
            remainingPointType: null,
            remainingPointMax: null,
            remainingPointMin: null,
            channel: 'all',
            channelStatus: 'all',
            channelUser: null,
            birthdateStart: null,
            birthdateEnd: null,
            gender: null,
        },
        zerva: {
            isOnlyCustomers: false,
            shopId: null,
            bookingNo: null,
            name: null,
            email: null,
            phoneNumber: null,
            bookingStartDate: null,
            bookingEndDate: null,
            paymentStatus: null,
            bookingStatus: null,
            branchIds: [],
            serviceIds: [],
            subIds: [],
        },
    };
    haveConnectionFromZwizSME = haveConnectionFromZwizSME();
    oldFilter;
    filterType = 'advanced';
    selectedFilter;
    filter = this.defaultFilter;
    isOpenDialogNameChatFilter = false;
    cancel;
    search;
    initialFilterType = () => {
        const _filterType = filterChatsStore.get('filterType');
        if (_filterType === 'advanced' && this.filterType === 'advanced') {
            this.filter = {
                ...this.oldFilter
            };
        }
        else if (this.filterType === 'custom' && this.selectedFilter) {
            this.filter = {
                name: this.selectedFilter.name,
                search: this.selectedFilter.search,
                read: this.selectedFilter.read ?? null,
                type: this.selectedFilter.type ?? null,
                connections: this.selectedFilter.connections,
                lastAnswerByIds: this.selectedFilter.last_answer_by_ids,
                statusIds: this.selectedFilter.status_ids,
                tagIds: this.selectedFilter.tag_ids,
                ...this.selectedFilter.total_completed_verify_slip != null ? {
                    verifySlip: 'total_completed_verify_slip',
                    verifySlipValue: this.selectedFilter.total_completed_verify_slip,
                } : this.selectedFilter.total_completed_verify_slip_more_than != null ? {
                    verifySlip: 'total_completed_verify_slip_more_than',
                    verifySlipValue: this.selectedFilter.total_completed_verify_slip_more_than,
                } : {},
            };
        }
        else {
            this.filter = this.defaultFilter;
        }
    };
    initialPlatformShops = async () => {
        const _connections = platformConnectionsStore.get('connections');
        const zervaBusinessIds = new Set();
        const zrmzBusinessIds = new Set();
        for (const con in _connections) {
            if (_connections[con].zrmz) {
                zrmzBusinessIds.add(_connections[con].zrmz.business_profile_id);
            }
            if (_connections[con].zerva) {
                zervaBusinessIds.add(_connections[con].zerva.business_profile_id);
            }
        }
        if (zrmzBusinessIds.size > 0) {
            const { data: { result: { channel_profile: zrmzShopProfile } } } = await getProfileSelection({ app_id: 3 });
            const _zrmzShopList = zrmzShopProfile.filter(profile => zrmzBusinessIds.has(profile.id)).map(connection => ({
                label: connection.name,
                value: connection.id,
            }));
            this.zrmzShopList = _zrmzShopList;
        }
        if (zervaBusinessIds.size > 0) {
            const { data: { result: { channel_profile: zervaShopProfile } } } = await getProfileSelection({ app_id: 1 });
            const _zervaShopList = zervaShopProfile.filter(profile => zervaBusinessIds.has(profile.id)).map(connection => ({
                label: connection.name,
                value: connection.id,
            }));
            this.zervaShopList = _zervaShopList;
        }
    };
    async componentWillLoad() {
        this.initialFilterType();
        await this.initialPlatformShops();
    }
    handleCancel = () => {
        this.filter = this.defaultFilter;
        this.cancel.emit();
    };
    handleChange = (field, value) => {
        const formattedValue = field === 'connections' && typeof value === 'object'
            ? formatFilterConnection(value)
            : value;
        this.filter = {
            ...this.filter,
            [field]: formattedValue
        };
    };
    handleSubmit = () => {
        filterChatsStore.set('filterType', 'advanced');
        this.search.emit(this.filter);
    };
    handleReset = () => {
        this.filter = { ...this.defaultFilter, name: this.selectedFilter ? this.selectedFilter.name : '' };
    };
    handleOpenDialogNameChatFilter = () => {
        this.isOpenDialogNameChatFilter = true;
    };
    handleCloseDialogNameChatFilter = () => {
        this.isOpenDialogNameChatFilter = false;
    };
    handleCreateAndSearchCustomFilter = async (name) => {
        const connections = formatFilterConnection(this.filter.connections.map(connection => connection.id));
        const result = await handleCreateChatFilter({
            ...this.filter,
            name: name || this.filter.name,
            type: this.filter.type || null,
            read: this.filter.read,
            connections: connections,
            last_answer_by_ids: this.filter.lastAnswerByIds,
            status_ids: this.filter.statusIds,
            tag_ids: this.filter.tagIds,
            total_completed_verify_slip: this.filter.verifySlip === 'total_completed_verify_slip' ? this.filter.verifySlipValue : null,
            total_completed_verify_slip_more_than: this.filter.verifySlip === 'total_completed_verify_slip_more_than' ? this.filter.verifySlipValue : null,
        });
        if (result) {
            filterChatsStore.set('filterType', 'custom');
            customFiltersStore.set('selectedFilter', result);
            this.cancel.emit();
            this.search.emit(result);
        }
    };
    handleCreateCustomFilter = async () => {
        const connections = formatFilterConnection(this.filter.connections.map(connection => connection.id));
        const result = await handleCreateChatFilter({
            ...this.filter,
            name: this.filter.name,
            type: this.filter.type || null,
            read: this.filter.read,
            connections: connections,
            last_answer_by_ids: this.filter.lastAnswerByIds,
            status_ids: this.filter.statusIds,
            tag_ids: this.filter.tagIds,
            total_completed_verify_slip: this.filter.verifySlip === 'total_completed_verify_slip' ? this.filter.verifySlipValue : null,
            total_completed_verify_slip_more_than: this.filter.verifySlip === 'total_completed_verify_slip_more_than' ? this.filter.verifySlipValue : null,
        });
        if (result) {
            this.cancel.emit();
        }
    };
    handleUpdateCustomFilter = async () => {
        const selectedFilterId = this.selectedFilter ? this.selectedFilter.id : '';
        const connections = formatFilterConnection(this.filter.connections.map(connection => connection.id));
        const result = await handleUpdateChatFilter({
            ...this.filter,
            id: selectedFilterId,
            name: this.filter.name,
            type: this.filter.type || null,
            read: this.filter.read,
            connections: connections,
            last_answer_by_ids: this.filter.lastAnswerByIds,
            status_ids: this.filter.statusIds,
            tag_ids: this.filter.tagIds,
            total_completed_verify_slip: this.filter.verifySlip === 'total_completed_verify_slip' ? this.filter.verifySlipValue : null,
            total_completed_verify_slip_more_than: this.filter.verifySlip === 'total_completed_verify_slip_more_than' ? this.filter.verifySlipValue : null,
        });
        if (result) {
            this.cancel.emit();
        }
    };
    handleDeleteCustomFilter = async () => {
        const t = useTranslation();
        const title = t('chat_filter.confirm_delete_filter') || 'Are you sure you want to delete this filter?';
        openDialog({
            open: true,
            type: "WARNING" /* DIALOG_TYPE.WARNING */,
            title,
            buttonName: t('confirm'),
            cancelButtonName: t('cancel'),
            onSubmitDialog: () => {
                const selectedFilterId = this.selectedFilter ? this.selectedFilter.id : '';
                handleDeleteChatFilter(selectedFilterId).then((result) => {
                    if (result) {
                        this.cancel.emit();
                    }
                });
            },
            onCloseDialog: () => {
                // Dialog closed without confirmation
            },
        });
    };
    isEnableUpdateCustomFilter = () => {
        const isNameChanged = this.filter.name !== (this.selectedFilter ? this.selectedFilter.name : '');
        const isTypeChanged = this.filter.type !== (this.selectedFilter ? this.selectedFilter.type : '');
        const isReadChanged = this.filter.read !== (this.selectedFilter && this.selectedFilter.read !== undefined ? this.selectedFilter.read : null);
        const isSearchChanged = this.filter.search !== (this.selectedFilter ? this.selectedFilter.search : '');
        // Helper function to check if arrays contain the same items regardless of order
        const areArraysEqual = (arr1, arr2) => {
            if (!arr1 && !arr2)
                return true;
            if (!arr1 || !arr2)
                return false;
            if (arr1.length !== arr2.length)
                return false;
            const set1 = new Set(arr1);
            const set2 = new Set(arr2);
            return arr1.every(item => set2.has(item)) && arr2.every(item => set1.has(item));
        };
        // Helper function to compare FilterConnection arrays
        const areConnectionsEqual = (arr1, arr2) => {
            if (!arr1 && !arr2)
                return true;
            if (!arr1 || !arr2)
                return false;
            if (arr1.length !== arr2.length)
                return false;
            // Sort both arrays by id for consistent comparison
            const sorted1 = [...arr1].sort((a, b) => a.id.localeCompare(b.id));
            const sorted2 = [...arr2].sort((a, b) => a.id.localeCompare(b.id));
            return sorted1.every((conn1, index) => {
                const conn2 = sorted2[index];
                if (conn1.id !== conn2.id)
                    return false;
                // Compare channel arrays (sorted for order-independent comparison)
                const channels1 = [...conn1.channel].sort();
                const channels2 = [...conn2.channel].sort();
                return channels1.length === channels2.length && channels1.every((ch, i) => ch === channels2[i]);
            });
        };
        const isConnectionsChanged = !areConnectionsEqual(this.filter.connections, this.selectedFilter ? this.selectedFilter.connections : []);
        const isLastAnswerByIdsChanged = !areArraysEqual(this.filter.lastAnswerByIds, this.selectedFilter ? this.selectedFilter.last_answer_by_ids : []);
        const isStatusIdsChanged = !areArraysEqual(this.filter.statusIds, this.selectedFilter ? this.selectedFilter.status_ids : []);
        const isTagIdsChanged = !areArraysEqual(this.filter.tagIds, this.selectedFilter ? this.selectedFilter.tag_ids : []);
        let isVerifySlipChanged = false;
        if (this.selectedFilter?.total_completed_verify_slip != null) {
            if (this.filter.verifySlip != 'total_completed_verify_slip') {
                isVerifySlipChanged = true;
            }
            else {
                isVerifySlipChanged = this.selectedFilter.total_completed_verify_slip != this.filter.verifySlipValue;
            }
        }
        else if (this.selectedFilter?.total_completed_verify_slip_more_than != null) {
            if (this.filter.verifySlip != 'total_completed_verify_slip_more_than') {
                isVerifySlipChanged = true;
            }
            else {
                isVerifySlipChanged = this.selectedFilter.total_completed_verify_slip_more_than != this.filter.verifySlipValue;
            }
        }
        else {
            if (this.filter.verifySlip != null) {
                isVerifySlipChanged = true;
            }
        }
        return isNameChanged || isTypeChanged || isReadChanged || isSearchChanged || isConnectionsChanged || isLastAnswerByIdsChanged || isStatusIdsChanged || isTagIdsChanged || isVerifySlipChanged;
    };
    isVerifySlipValid = () => {
        const { verifySlip, verifySlipValue } = this.filter;
        if (verifySlip == null && (verifySlipValue != null && verifySlipValue > 0)) {
            return false;
        }
        if (verifySlip != null) {
            return verifySlipValue != null && verifySlipValue > 0;
        }
        return true;
    };
    handleReadChange = (value) => () => {
        this.handleChange('read', value);
    };
    handleTypeChange = (value) => () => {
        this.handleChange('type', value);
    };
    render() {
        const t = useTranslation();
        const filterConfig = filterChatsStore.get('filterConfig');
        const selectReadOptions = [{ label: t('chat_tab.all_chat'), value: null }, { label: t('chat_tab.already_read'), value: true }, { label: t('chat_tab.unread'), value: false }];
        const selectChatTypeOptions = [{ label: t('chat_filter.all'), value: null }, { label: t('chat_filter.friend'), value: 'user' }, { label: t('chat_filter.group'), value: 'group' }];
        return (h(Host, { key: '76fb1a137e5e3ce692cc32d61d607e473acc3338' }, h("div", { key: '55176e03d4c39c4933d4c7a15d8631bc82ddaf3c', class: `dialog-search scroll-container ${deviceModeStore.get('mode') === 'mobile' ? 'w-xs' : 'w-xl'}` }, h("div", { key: '7d4360d09a0dbc95f4d0cff2f3eaba88598e1756', class: "dialog-search-toolbar-action" }, h("div", { key: '97e9964cea130fe820441579c5d5267aa4f3b78f', class: "dialog-search-toolbar-action-wrapper" }, h("span", { key: '611883bab1d06b28873eee6cdef33d3f688fd53c', class: "dialog-search-toolbar-action-reset", onClick: this.handleReset }, t('reset')), h(ZIconButton, { key: '44c4f9cbf1cc1ab0f2ce67eeaec8c766c4b6cd93', iconName: "X", variant: "none", onClick: this.handleCancel }))), h("h2", { key: 'e7102d6927c68b55b971c23f1a79673b68f6f09e', class: "dialog-search-toolbar-title" }, this.filterType === 'advanced' ? t('chat_tab.advanced_search') : this.selectedFilter ? t('chat_tab.edit_custom_filter') : t('chat_tab.add_custom_filter')), h("div", { key: 'b297cc039c2fc9759331e4c843c78dbd687f4669', class: "dialog-search-content" }, h("div", { key: '7c419b4abab2409b234744207b8ed0f9f035348d', class: "space-y-2" }, this.filterType === 'custom' && h("div", { key: '3ecdf2b6367f4212121b03f68cffc007997974d3' }, h("p", { key: 'e0d7499cbf9181b3ef4a25f0828c79c38027fc61', class: "dialog-search-text" }, t('chat_filter.filter_name'), "\u00A0"), h(ZInput, { key: '10827a4fb27b1c30336ac56aa9ad9c85e2ad3d43', placeholder: t('chat_filter.filter_name'), value: this.filter.name, onChange: value => this.handleChange('name', value) })), h("p", { key: '0f4869a24f27f56ccde4fc37a12572eb03ce7a20', class: "dialog-search-text" }, t('search'), "\u00A0", h("span", { key: '0e23e4b733ff125d9b2131d00af69c32ff08e858', class: "text-sm text-theme-gray" }, "(", t('chat_tab.filter_search_fields'), ")")), h(ZInput, { key: '4e20431b85bf3f1e74d8a4ae16b374a3b155e8df', placeholder: t('search'), value: this.filter.search, onChange: value => this.handleChange('search', value) }), h("p", { key: '62c93cea599aa37b4d2fe57628c2447f0faeb6cc', class: "dialog-search-text" }, t('chat_tab.read_status')), h("div", { key: '7df0cd800af6dc03fc56f01677b80d28fe459387', class: "dialog-search-read-option" }, selectReadOptions.map(({ label, value }) => {
            const isSelected = value === this.filter.read;
            return h(ZButton, { variant: isSelected ? 'primary' : 'outlined', label: label, title: label, onClick: this.handleReadChange(value) });
        })), h("p", { key: 'f21e7f671212ced2ebd43fc7fc5492f71a244b56', class: "dialog-search-text" }, t('channel')), h("div", { key: '7d36bdf2de1ac2dec0320b8ef64784f08a9308d5', class: 'mb-2', id: "filter-channel" }, h("autocomplete-multiple-select", { key: '15c5ae0c14c2d1741efb0707f028441487e84afd', selectedIds: this.filter.connections.map(connection => connection.id), fetchItems: async () => Promise.resolve(this.connectionList), onSelecting: event => this.handleChange('connections', event.detail), referenceSelector: "filter-channel", showSelectAllButton: true, showClearButton: true })), h("p", { key: '79fc81e0c28de93ec511cf6b1186a01b4019c7e7', class: "dialog-search-text" }, t('chat_tab.last_reply')), h("div", { key: '003191ded558d90cbc73b6d4e247a61b985e9ec9', class: 'mb-2', id: "filter-last-answer" }, h("autocomplete-multiple-select", { key: '8a6f236e8fde519d430c7f455c49296386b11635', selectedIds: this.filter.lastAnswerByIds, fetchItems: async () => Promise.resolve(this.answerList), onSelecting: event => this.handleChange('lastAnswerByIds', event.detail), referenceSelector: "filter-last-answer", showSelectAllButton: true, showClearButton: true })), filterConfig.config.isShowFilterType === true && (h(h.Fragment, null, h("p", { key: '6075fed4b5cd3107a8317ed01e4e99369f1445f9', class: "dialog-search-text" }, t('chat_filter.type'), "\u00A0", h("span", { key: '7f9d71ca7161eb4542375b37fcd18fc7fb509cda', class: "text-sm text-theme-gray" }, "(", t('chat_filter.type_for_line_oa'), ")")), h("div", { key: 'd062cef049cd8f1a1b24fda50c44284e9b62ee29', class: "dialog-search-read-option mt-2" }, selectChatTypeOptions.map(({ label, value }) => {
            const isSelected = value === this.filter.type;
            return h(ZButton, { variant: isSelected ? 'primary' : 'outlined', label: label, title: label, onClick: this.handleTypeChange(value) });
        })))), h("p", { key: '04c6e1b822fe98e7e094ac05b7623afb96100dd0', class: "dialog-search-text" }, t('status')), h("div", { key: 'ec85aaceb09c3d9e724feb9c5c5fadf89a5dfeb3', class: 'mb-2', id: "filter-status" }, h("autocomplete-multiple-select", { key: 'd2ded9e2a7e55d4bf088068fb37355474a018ead', selectedIds: this.filter.statusIds, fetchItems: handleGetUserStatuses, onSelecting: event => this.handleChange('statusIds', event.detail), referenceSelector: "filter-status", showClearButton: true })), h("p", { key: '92b0bacc7316ff5896d24102a00f328c4c6d5d6c', class: "dialog-search-text" }, t('tag')), h("div", { key: 'd471f25b7b127b5fe35dcbcbc3c8e5aa3a34e047', class: 'mb-2', id: "filter-tag" }, h("autocomplete-multiple-select", { key: '919b80ba29b1a0fbf556416479beb3f4c9eb2929', selectedIds: this.filter.tagIds, fetchItems: handleGetUserTags, onSelecting: event => this.handleChange('tagIds', event.detail), referenceSelector: "filter-tag", showClearButton: true })), this.haveConnectionFromZwizSME && (() => {
            return (h(h.Fragment, null, h("p", { class: "dialog-search-text" }, t('chat_filter.verify_slip')), h("div", { class: "flex my-2 gap-2", id: "filter-verify-slip" }, h("z-dropdown-input", { class: "flex-1", value: this.filter.verifySlip, options: this.verifySlipList, onValueChange: event => this.handleChange('verifySlip', event.detail), placeholder: t('chat_filter.verify_slip'), enableSearch: false, showClearButton: true }), h("div", { class: "w-1/4" }, h(ZInput, { placeholder: t('chat_filter.quantity'), value: this.filter.verifySlipValue ? (this.filter.verifySlipValue ? this.filter.verifySlipValue.toString() : '') : '', onChange: value => this.handleChange('verifySlipValue', Number.parseInt(value) || 0) })), h("p", { class: "text-surface text-sm mt-2" }, t('chat_filter.times')))));
        })(), (this.haveConnectionFromZwizSME && this.zrmzShopList.length > 0) && (h(h.Fragment, null, h("search-filter-zrmz", { key: '7c663ddb3eddf8cdd516d4a4d82d1386ecd9edc2', filter: this.filter.zrmz, shopList: this.zrmzShopList, onFilterChange: event => this.handleChange('zrmz', event.detail) }), h("div", { key: '80570272375b8ffe632995322b5605ade1050b3b', class: 'h-[8px]' }))), (this.haveConnectionFromZwizSME && this.zervaShopList.length > 0) && (h(h.Fragment, null, h("search-filter-zerva", { key: '32d5396a2814f5d11e72029f1c795acaca9009cf', filter: this.filter.zerva, shopList: this.zervaShopList, onFilterChange: event => this.handleChange('zerva', event.detail) }), h("div", { key: '1e2a7b78bc6e82aef11bfe922b4b73ab08b599a5', class: 'h-[8px]' }))), h("div", { key: '7362926d9cc5ea824285aca515f96a1f1683c4ad', class: 'h-[12px]' }))), this.filterType === 'advanced' && h("div", { key: '36b47a3256dc1e48a75161b99722fbbd7eae80b4', class: "dialog-search-action-wrapper" }, h(ZButton, { key: '1aefa2a9ce40c892835db55560bd0be89bb8854e', variant: 'outlined', label: t('search_data'), fullWidth: true, onClick: this.handleSubmit, disabled: !this.isVerifySlipValid() }), h(ZButton, { key: 'b817bc4ccff9e09b9f38cfaa5a81edc0b84a23fe', label: t('save_filter_and_search'), fullWidth: true, onClick: () => this.handleOpenDialogNameChatFilter(), disabled: !this.isVerifySlipValid() })), this.filterType === 'custom' && !this.selectedFilter && h("div", { key: '569091047a2bccb557fcd81d2dd015d586e11545', class: "dialog-search-action-wrapper" }, h(ZButton, { key: 'b197c4ca3642740eb14be369800635f1440aebe5', label: t('chat_filter.add_custom_filter'), fullWidth: true, onClick: this.handleCreateCustomFilter, disabled: !this.filter.name || !this.isVerifySlipValid() })), this.filterType === 'custom' && this.selectedFilter && h("div", { key: '52f8d85f5736527b150aa3905c1b22ec25c6ba3f', class: "dialog-search-action-wrapper" }, h(ZButton, { key: 'd443d383f61a74a49ece11a1f286d29dd801053b', label: t('save'), fullWidth: true, onClick: this.handleUpdateCustomFilter, disabled: !this.filter.name || !this.isEnableUpdateCustomFilter() || !this.isVerifySlipValid() }), h(ZButton, { key: '68be5c57b9ea88093b9a0e89311e40413dcc1add', variant: 'text-underline', label: t('delete'), fullWidth: true, onClick: this.handleDeleteCustomFilter })), this.isOpenDialogNameChatFilter &&
            h("div", { key: 'b5db9ebf082602e8c91b3c97829e9f108de18d4b', class: "dialog-backdrop" }, h("dialog-editor", { key: 'a4fbd4039242e49daaf951996752fc1d239dca7a', headerTitle: t('chat_filter.filter_name'), label: t('chat_filter.filter_name'), field: "name", onCancel: this.handleCloseDialogNameChatFilter, onSave: (event) => this.handleCreateAndSearchCustomFilter(event?.detail ?? ''), customSubmitName: t('save_filter_and_search') })))));
    }
    static get is() { return "dialog-search"; }
    static get originalStyleUrls() {
        return {
            "$": ["dialog-search.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["dialog-search.css"]
        };
    }
    static get properties() {
        return {
            "oldFilter": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "SearchChatsParams",
                    "resolved": "{ ignoreCache?: boolean; name?: string; search?: string; spam?: boolean; type?: \"user\" | \"group\"; read?: boolean; context?: string; connections?: FilterConnection[]; lastAnswerByIds?: string[]; statusIds?: string[]; tagIds?: string[]; userIds?: string[]; zrmzCustomerIds?: string[]; following?: boolean; verifySlip?: string; verifySlipValue?: number; zrmz?: { isOnlyCustomers?: boolean; businessId?: string; shopId?: string; name?: string; phoneNumber?: string; email?: string; totalPointType?: string; totalPointMin?: number; totalPointMax?: number; remainingPointType?: string; remainingPointMin?: number; remainingPointMax?: number; gender?: string; channel?: string; channelStatus?: string; channelUser?: string; birthdateStart?: string; birthdateEnd?: string; customFields?: Record<string, string>; }; zerva?: { isOnlyCustomers?: boolean; businessId?: string; shopId?: string; bookingNo?: string; name?: string; phoneNumber?: string; email?: string; bookingStartDate?: string; bookingEndDate?: string; paymentStatus?: string; bookingStatus?: string; branchIds?: string[]; serviceIds?: string[]; subIds?: string[]; }; }",
                    "references": {
                        "SearchChatsParams": {
                            "location": "import",
                            "path": "../../api/type",
                            "id": "src/api/type.ts::SearchChatsParams",
                            "referenceLocation": "SearchChatsParams"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "filterType": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "FilterType",
                    "resolved": "\"advanced\" | \"custom\" | \"quick\"",
                    "references": {
                        "FilterType": {
                            "location": "import",
                            "path": "../../api/type",
                            "id": "src/api/type.ts::FilterType",
                            "referenceLocation": "FilterType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "filter-type",
                "defaultValue": "'advanced'"
            },
            "selectedFilter": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ChatFilter",
                    "resolved": "{ id: string; name: string; search?: string; read?: boolean; type?: \"user\" | \"group\"; connections?: FilterConnection[]; last_answer_by_ids?: string[]; status_ids?: string[]; tag_ids?: string[]; total_completed_verify_slip?: number; total_completed_verify_slip_more_than?: number; created_at?: string; updated_at?: string; }",
                    "references": {
                        "ChatFilter": {
                            "location": "import",
                            "path": "../../api/type",
                            "id": "src/api/type.ts::ChatFilter",
                            "referenceLocation": "ChatFilter"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            }
        };
    }
    static get states() {
        return {
            "filter": {},
            "isOpenDialogNameChatFilter": {}
        };
    }
    static get events() {
        return [{
                "method": "cancel",
                "name": "cancel",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }, {
                "method": "search",
                "name": "search",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "SearchChatsParams",
                    "resolved": "{ ignoreCache?: boolean; name?: string; search?: string; spam?: boolean; type?: \"user\" | \"group\"; read?: boolean; context?: string; connections?: FilterConnection[]; lastAnswerByIds?: string[]; statusIds?: string[]; tagIds?: string[]; userIds?: string[]; zrmzCustomerIds?: string[]; following?: boolean; verifySlip?: string; verifySlipValue?: number; zrmz?: { isOnlyCustomers?: boolean; businessId?: string; shopId?: string; name?: string; phoneNumber?: string; email?: string; totalPointType?: string; totalPointMin?: number; totalPointMax?: number; remainingPointType?: string; remainingPointMin?: number; remainingPointMax?: number; gender?: string; channel?: string; channelStatus?: string; channelUser?: string; birthdateStart?: string; birthdateEnd?: string; customFields?: Record<string, string>; }; zerva?: { isOnlyCustomers?: boolean; businessId?: string; shopId?: string; bookingNo?: string; name?: string; phoneNumber?: string; email?: string; bookingStartDate?: string; bookingEndDate?: string; paymentStatus?: string; bookingStatus?: string; branchIds?: string[]; serviceIds?: string[]; subIds?: string[]; }; }",
                    "references": {
                        "SearchChatsParams": {
                            "location": "import",
                            "path": "../../api/type",
                            "id": "src/api/type.ts::SearchChatsParams",
                            "referenceLocation": "SearchChatsParams"
                        }
                    }
                }
            }];
    }
}
