<template>
    <section class="card" role="region">
        <div class="card-header bg-primary-dark">
            <h3 class="card-title">
                <translate key="hdr">SoundExchange Report</translate>
            </h3>
        </div>

        <form id="report-form" class="form vue-form" method="GET" :action="apiUrl" target="_blank">
            <div class="card-body">
                <b-form-fieldset>
                    <p>This report is intended for licensing in the United States only, for webcasters paying royalties
                        via SoundExchange. Learn more about the requirements for reporting and classification on the
                        <a href="https://www.soundexchange.com/service-provider/reporting-requirements/"
                           target="_blank">
                            SoundExchange web site
                        </a>.
                    </p>

                    <ul>
                        <li>AzuraCast assumes that your station fits SoundExchange Transmission Category A, "Eligible
                            nonsubscription transmissions other than broadcast simulcasts and transmissions of non-music
                            programming." If your station does not fall within this category, update the transmission
                            category field accordingly.
                        <li>The data collected by AzuraCast meets the SoundExchange standard for Actual Total
                            Performances (ATP) by tracking unique listeners across all song plays. All other information
                            is derived from the metadata of the uploaded songs themselves, and may not be completely
                            accurate.
                        </li>
                        <li>Reporting requirements for SoundExchange may change at any time. AzuraCast is non-commercial
                            community-built software and cannot guarantee that its reporting format will always be
                            up-to-date.
                        </li>
                        <li>You should always verify the report generated by AzuraCast before sending it. In particular,
                            either the ISRC (International Standard Recording Code) or *both* the album and label are
                            required for every row, and may not be provided in the song metadata. To locate an ISRC for
                            a track, you should use <a href="https://isrc.soundexchange.com" target="_blank">SoundExchange's
                                ISRC search tool</a>.
                        </li>
                    </ul>
                </b-form-fieldset>

                <b-form-fieldset>
                    <b-wrapped-form-group name="start_date" id="form_start_date" :field="$v.form.start_date"
                                          input-type="date">
                        <template #label="{lang}">
                            <translate :key="lang">Start Date</translate>
                        </template>
                    </b-wrapped-form-group>

                    <b-wrapped-form-group name="end_date" id="form_end_date" :field="$v.form.end_date"
                                          input-type="date">
                        <template #label="{lang}">
                            <translate :key="lang">End Date</translate>
                        </template>
                    </b-wrapped-form-group>

                    <b-wrapped-form-checkbox name="fetch_isrc" id="form_edit_fetch_isrc" :field="$v.form.fetch_isrc">
                        <template #label="{lang}">
                            <translate :key="lang">Attempt to Automatically Retrieve ISRC When Missing</translate>
                        </template>
                        <template #description="{lang}">
                            <translate :key="lang">If enabled, AzuraCast will connect to the MusicBrainz database to attempt to find an ISRC for any files where one is missing. Disabling this may improve performance.</translate>
                        </template>
                    </b-wrapped-form-checkbox>
                </b-form-fieldset>

                <b-button type="submit" size="lg" :variant="($v.form.$invalid) ? 'danger' : 'primary'" class="mt-2">
                    <translate key="btn_submit">Generate Report</translate>
                </b-button>
            </div>
        </form>
    </section>
</template>

<script>
import Icon from "~/components/Common/Icon";
import BWrappedFormGroup from "~/components/Form/BWrappedFormGroup";
import {validationMixin} from "vuelidate";
import {required} from 'vuelidate/dist/validators.min.js';
import BFormFieldset from "~/components/Form/BFormFieldset";
import BWrappedFormCheckbox from "~/components/Form/BWrappedFormCheckbox";

export default {
    name: 'StationsReportsSoundExchange',
    props: {
        apiUrl: String,
        startDate: String,
        endDate: String
    },
    components: {Icon, BWrappedFormGroup, BFormFieldset, BWrappedFormCheckbox},
    mixins: [
        validationMixin
    ],
    validations() {
        return {
            form: {
                start_date: {required},
                end_date: {required},
                fetch_isrc: {}
            }
        }
    },
    data() {
        return {
            form: {
                start_date: this.startDate,
                end_date: this.endDate,
                fetch_isrc: false
            }
        }
    }
}
</script>
