// SPDX-FileCopyrightText: 2024 John Livingston // // SPDX-License-Identifier: AGPL-3.0-only // FIXME: @stylistic/indent is buggy with strings literrals. /* eslint-disable @stylistic/indent */ import type { ChannelConfigurationElement } from '../channel-configuration' import type { DynamicFormHeader, DynamicFormSchema } from '../../../lib/elements/dynamic-table-form' import { ptTr } from '../../../lib/directives/translation' import { html, TemplateResult } from 'lit' import { classMap } from 'lit/directives/class-map.js' export function tplChannelConfiguration (el: ChannelConfigurationElement): TemplateResult { const tableHeaderList: Record = { forbiddenWords: { entries: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_DESC2) }, regexp: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REGEXP_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REGEXP_DESC) }, applyToModerators: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_APPLYTOMODERATORS_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_APPLYTOMODERATORS_DESC) }, label: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_LABEL_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_LABEL_DESC) }, reason: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_RETRACTATION_REASON_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_RETRACTATION_REASON_DESC) }, comments: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_DESC) } }, quotes: { messages: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_LABEL2), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC2) }, delay: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DELAY_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DELAY_DESC) } }, commands: { command: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_CMD_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_CMD_DESC) }, message: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_MESSAGE_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_MESSAGE_DESC) } } } const tableSchema: Record = { forbiddenWords: { entries: { inputType: 'tags', default: [], separator: '\n' }, regexp: { inputType: 'checkbox', default: false }, applyToModerators: { inputType: 'checkbox', default: false }, label: { inputType: 'text', default: '' }, reason: { inputType: 'text', default: '' }, comments: { inputType: 'textarea', default: '' } }, quotes: { messages: { inputType: 'textarea', default: [], separator: '\n' }, delay: { inputType: 'number', default: 10 } }, commands: { command: { inputType: 'text', default: '' }, message: { inputType: 'text', default: '' } } } return html`

${el.channelConfiguration?.channel.displayName} ${el.channelConfiguration?.channel.name}

${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_DESC)}

${el.renderFeedback('peertube-livechat-terms-feedback', 'terms')}
${el.renderFeedback('peertube-livechat-slowmode-duration-feedback', 'slowMode.duration')}
${el.renderFeedback('peertube-livechat-moderation-delay-feedback', 'moderation.delay')}
${!el.channelConfiguration?.configuration.bot.enabled ? '' : html`
{ if (event?.target && el.channelConfiguration) { el.channelConfiguration.configuration.bot.nickname = (event.target as HTMLInputElement).value } el.requestUpdate('channelConfiguration') } } value="${el.channelConfiguration?.configuration.bot.nickname ?? ''}" /> ${el.renderFeedback('peertube-livechat-bot-nickname-feedback', 'bot.nickname')}
${!el.channelConfiguration?.configuration.bot.forbidSpecialChars.enabled ? '' : html`
${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_SPECIAL_CHARS_TOLERANCE_DESC)} ${el.renderFeedback('peertube-livechat-forbid-special-chars-tolerance-feedback', 'bot.forbidSpecialChars.tolerance') }
${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_RETRACTATION_REASON_DESC)} ${el.renderFeedback('peertube-livechat-forbid-special-chars-reason-feedback', 'bot.forbidSpecialChars.reason') }
${ptTr(LOC_LIVECHAT_CONFIGURATION_APPLYTOMODERATORS_DESC)}
` }
${!el.channelConfiguration?.configuration.bot.noDuplicate.enabled ? '' : html`
${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_NO_DUPLICATE_DELAY_DESC)} ${el.renderFeedback('peertube-livechat-no-duplicate-delay-feedback', 'bot.noDuplicate.delay') }
${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_RETRACTATION_REASON_DESC)} ${el.renderFeedback('peertube-livechat-no-duplicate-reason-feedback', 'bot.noDuplicate.reason') }
${ptTr(LOC_LIVECHAT_CONFIGURATION_APPLYTOMODERATORS_DESC)}
` } { el.resetValidation(e) if (el.channelConfiguration) { el.channelConfiguration.configuration.bot.forbiddenWords = e.detail el.requestUpdate('channelConfiguration') } } } .formName=${'forbidden-words'} > { el.resetValidation(e) if (el.channelConfiguration) { el.channelConfiguration.configuration.bot.quotes = e.detail el.requestUpdate('channelConfiguration') } } } .formName=${'quote'} > { el.resetValidation(e) if (el.channelConfiguration) { el.channelConfiguration.configuration.bot.commands = e.detail el.requestUpdate('channelConfiguration') } } } .formName=${'command'} > `}
` }