<commit_before>import Slider, { speedUp } from '../mixin/slider';
import SliderReactive from '../mixin/internal/slider-reactive';
import TransitionerPlugin from './internal/slider-transitioner';
import ParallaxPlugin from './internal/slider-parallax';

function plugin(UIkit) {

    if (plugin.installed) {
        return;
    }

    UIkit.use(Slider);

    var {mixin} = UIkit;
    var {$, $$, addClass, css, data, includes, isNumeric, isUndefined, toggleClass, toFloat} = UIkit.util;
    var Transitioner = TransitionerPlugin(UIkit);

    UIkit.component('slider-parallax', ParallaxPlugin(UIkit, 'slider'));

    UIkit.component('slider', {

        mixins: [mixin.class, mixin.slider, SliderReactive(UIkit)],

        props: {
            center: Boolean,
            sets: Boolean,
        },

        defaults: {
            center: false,
            sets: false,
            attrItem: 'uk-slider-item',
            selList: '.uk-slider-items',
            selNav: '.uk-slider-nav',
            clsContainer: 'uk-slider-container',
            Transitioner
        },

        computed: {

            avgWidth() {
                return Transitioner.getWidth(this.list) / this.length;
            },

            finite({finite}) {
                return finite || Transitioner.getWidth(this.list) < this.list.offsetWidth + Transitioner.getMaxWidth(this.list) + this.center;
            },

            maxIndex() {

                if (!this.finite || this.center && !this.sets) {
                    return this.length - 1;
                }

                if (this.center) {
                    return this.sets[this.sets.length - 1];
                }

                css(this.slides, 'order', '');

                var max = Transitioner.getMax(this.list), i = this.length;

                while (i--) {
                    if (Transitioner.getElLeft(this.list.children[i], this.list) < max) {
                        return Math.min(i + 1, this.length - 1);
                    }
                }

                return 0;
            },

            sets({sets}) {

                var width = this.list.offsetWidth / (this.center ? 2 : 1),
                    left = 0,
                    leftCenter = width;

                css(this.slides, 'order', '');

                sets = sets && this.slides.reduce((sets, slide, i) => {

                    var slideWidth = slide.offsetWidth,
                        slideLeft = Transitioner.getElLeft(slide, this.list),
                        slideRight = slideLeft + slideWidth;

                    if (slideRight > left) {

                        if (!this.center && i > this.maxIndex) {
                            i = this.maxIndex;
                        }

                        if (!includes(sets, i)) {

                            var cmp = this.slides[i + 1];
                            if (this.center && cmp && slideWidth < leftCenter - cmp.offsetWidth / 2) {
                                leftCenter -= slideWidth;
                            } else {
                                leftCenter = width;
                                sets.push(i);
                                left = slideLeft + width + (this.center ? slideWidth / 2 : 0);
                            }

                        }
                    }

                    return sets;

                }, []);

                return sets && sets.length && sets;

            },

            transitionOptions() {
                return {
                    center: this.center,
                    list: this.list
                };
            }

        },

        connected() {
            toggleClass(this.$el, this.clsContainer, !$(`.${this.clsContainer}`, this.$el));
        },

        update: {

            write() {

                $$(`[${this.attrItem}],[data-${this.attrItem}]`, this.$el).forEach(el => {
                    var index = data(el, this.attrItem);
                    this.maxIndex && toggleClass(el, 'uk-hidden', isNumeric(index) && (this.sets && !includes(this.sets, toFloat(index)) || index > this.maxIndex));
                });

            },

            events: ['load', 'resize']

        },

        events: {

            beforeitemshow(e) {

                if (!this.dragging && this.sets && this.stack.length < 2 && !includes(this.sets, this.index)) {
                    this.index = this.getValidIndex();
                }

                var diff = Math.abs(this.index + (this.dir > 0
                    ? this.index < this.prevIndex ? this.maxIndex + 1 : 0
                    : this.index > this.prevIndex ? -this.maxIndex : 0
                ) - this.prevIndex);

                if (!this.dragging && diff > 1) {

                    for (var i = 0; i < diff; i++) {
                        this.stack.splice(1, 0, this.dir > 0 ? 'next' : 'previous');
                    }

                    e.preventDefault();
                    return;
                }

                this.duration = speedUp(this.avgWidth / this.velocity)
                    * ((
                        this.dir < 0 || !this.slides[this.prevIndex]
                            ? this.slides[this.index]
                            : this.slides[this.prevIndex]
                    ).offsetWidth / this.avgWidth);

                this.reorder();

            },

            itemshow() {
                !isUndefined(this.prevIndex) && addClass(this._getTransitioner().getItemIn(), this.clsActive);
            },

            itemshown() {
                var actives = this._getTransitioner(this.index).getActives();
                this.slides.forEach(slide => toggleClass(slide, this.clsActive, this.clsActivated, includes(actives, slide)));
            }

        },

        methods: {

            reorder() {

                css(this.slides, 'order', '');

                if (this.finite) {
                    return;
                }

                this.slides.forEach((slide, i) =>
                    css(slide, 'order', this.dir > 0 && i < this.prevIndex
                        ? 1
                        : this.dir < 0 && i >= this.index
                            ? -1
                            : ''
                    )
                );<commit_msg>delay clsActivated for sets mode fix navigating to the left for sets over edge<commit_after>import Slider, { speedUp } from '../mixin/slider';
import SliderReactive from '../mixin/internal/slider-reactive';
import TransitionerPlugin from './internal/slider-transitioner';
import ParallaxPlugin from './internal/slider-parallax';

function plugin(UIkit) {

    if (plugin.installed) {
        return;
    }

    UIkit.use(Slider);

    var {mixin} = UIkit;
    var {$, $$, addClass, css, data, includes, isNumeric, isUndefined, toggleClass, toFloat} = UIkit.util;
    var Transitioner = TransitionerPlugin(UIkit);

    UIkit.component('slider-parallax', ParallaxPlugin(UIkit, 'slider'));

    UIkit.component('slider', {

        mixins: [mixin.class, mixin.slider, SliderReactive(UIkit)],

        props: {
            center: Boolean,
            sets: Boolean,
        },

        defaults: {
            center: false,
            sets: false,
            attrItem: 'uk-slider-item',
            selList: '.uk-slider-items',
            selNav: '.uk-slider-nav',
            clsContainer: 'uk-slider-container',
            Transitioner
        },

        computed: {

            avgWidth() {
                return Transitioner.getWidth(this.list) / this.length;
            },

            finite({finite}) {
                return finite || Transitioner.getWidth(this.list) < this.list.offsetWidth + Transitioner.getMaxWidth(this.list) + this.center;
            },

            maxIndex() {

                if (!this.finite || this.center && !this.sets) {
                    return this.length - 1;
                }

                if (this.center) {
                    return this.sets[this.sets.length - 1];
                }

                css(this.slides, 'order', '');

                var max = Transitioner.getMax(this.list), i = this.length;

                while (i--) {
                    if (Transitioner.getElLeft(this.list.children[i], this.list) < max) {
                        return Math.min(i + 1, this.length - 1);
                    }
                }

                return 0;
            },

            sets({sets}) {

                var width = this.list.offsetWidth / (this.center ? 2 : 1),
                    left = 0,
                    leftCenter = width;

                css(this.slides, 'order', '');

                sets = sets && this.slides.reduce((sets, slide, i) => {

                    var slideWidth = slide.offsetWidth,
                        slideLeft = Transitioner.getElLeft(slide, this.list),
                        slideRight = slideLeft + slideWidth;

                    if (slideRight > left) {

                        if (!this.center && i > this.maxIndex) {
                            i = this.maxIndex;
                        }

                        if (!includes(sets, i)) {

                            var cmp = this.slides[i + 1];
                            if (this.center && cmp && slideWidth < leftCenter - cmp.offsetWidth / 2) {
                                leftCenter -= slideWidth;
                            } else {
                                leftCenter = width;
                                sets.push(i);
                                left = slideLeft + width + (this.center ? slideWidth / 2 : 0);
                            }

                        }
                    }

                    return sets;

                }, []);

                return sets && sets.length && sets;

            },

            transitionOptions() {
                return {
                    center: this.center,
                    list: this.list
                };
            }

        },

        connected() {
            toggleClass(this.$el, this.clsContainer, !$(`.${this.clsContainer}`, this.$el));
        },

        update: {

            write() {

                $$(`[${this.attrItem}],[data-${this.attrItem}]`, this.$el).forEach(el => {
                    var index = data(el, this.attrItem);
                    this.maxIndex && toggleClass(el, 'uk-hidden', isNumeric(index) && (this.sets && !includes(this.sets, toFloat(index)) || index > this.maxIndex));
                });

            },

            events: ['load', 'resize']

        },

        events: {

            beforeitemshow(e) {

                if (!this.dragging && this.sets && this.stack.length < 2 && !includes(this.sets, this.index)) {
                    this.index = this.getValidIndex();
                }

                var diff = Math.abs(
                    this.index
                    - this.prevIndex
                    + (this.dir > 0 && this.index < this.prevIndex || this.dir < 0 && this.index > this.prevIndex ? (this.maxIndex + 1) * this.dir : 0)
                );

                if (!this.dragging && diff > 1) {

                    for (var i = 0; i < diff; i++) {
                        this.stack.splice(1, 0, this.dir > 0 ? 'next' : 'previous');
                    }

                    e.preventDefault();
                    return;
                }

                this.duration = speedUp(this.avgWidth / this.velocity)
                    * ((
                        this.dir < 0 || !this.slides[this.prevIndex]
                            ? this.slides[this.index]
                            : this.slides[this.prevIndex]
                    ).offsetWidth / this.avgWidth);

                this.reorder();

            },

            itemshow() {
                !isUndefined(this.prevIndex) && addClass(this._getTransitioner().getItemIn(), this.clsActive);
            },

            itemshown() {
                var actives = this._getTransitioner(this.index).getActives();
                this.slides.forEach(slide => toggleClass(slide, this.clsActive, includes(actives, slide)));
                (!this.sets || includes(this.sets, toFloat(this.index))) && this.slides.forEach(slide => toggleClass(slide, this.clsActivated, includes(actives, slide)));
            }

        },

        methods: {

            reorder() {

                css(this.slides, 'order', '');

                if (this.finite) {
                    return;
                }

                this.slides.forEach((slide, i) =>
                    css(slide, 'order', this.dir > 0 && i < this.prevIndex
                        ? 1
                        : this.dir < 0 && i >= this.index
                            ? -1
                            : ''
                    )
                );
{'fraction_non_alphanumeric': 0.12447224394057858, 'fraction_numerical': 0.004222048475371384, 'mean_word_length': 1.128994673768309, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '93581', 'n_tokens_mistral': 3527, 'n_tokens_neox': 3180, 'n_words': 626}