<commit_before>import delegate from 'delegate'

// helpers
import Cache from './Cache'
import Link from './Link'
import transitionEnd from './transitionEnd'

// modules
import request from './modules/request'
import getDataFromHtml from './modules/getDataFromHtml'
import loadPage from './modules/loadPage'
import renderPage from './modules/renderPage'
import createState from './modules/createState'
import triggerEvent from './modules/triggerEvent'
import getUrl from './modules/getUrl'
import scrollTo from './modules/scrollTo'
import classify from './modules/classify'
import doScrolling from './modules/doScrolling'
import markSwupElements from './modules/markSwupElements'
import on from './modules/on'
import off from './modules/off'
import updateTransition from './modules/updateTransition'
import preloadPage from './modules/preloadPage'
import preloadPages from './modules/preloadPages'
import usePlugin from './modules/usePlugin'
import log from './modules/log'

export default class Swup {
    constructor(setOptions) {
        // default options
        let defaults = {
            cache: true,
            animationSelector: '[class*="transition-"]',
            elements: ['#swup'],
            pageClassPrefix: '',
            debugMode: false,
            scroll: true,

            doScrollingRightAway: false,
            animateScroll: true,
            scrollFriction: .3,
            scrollAcceleration: .04,

            preload: true,
            support: true,
            plugins: [],

            skipPopStateHandling: function(event){
                if (event.state && event.state.source == "swup") {
                    return false;
                }
                return true;
            },
            animateHistoryBrowsing: false,

            LINK_SELECTOR: 'a[href^="' + window.location.origin + '"]:not([data-no-swup]), a[href^="/"]:not([data-no-swup]), a[href^="#"]:not([data-no-swup])',
            FORM_SELECTOR: 'form[data-swup-form]',
        }

        /**
         * current transition object
         */
        this.transition = {}

        let options = {
            ...defaults,
            ...setOptions
        }

        /**
         * handler arrays
         */
        this._handlers = {
            willReplaceContent: [],
            contentReplaced: [],
            pageView: [],
            hoverLink: [],
            clickLink: [],
            samePage: [],
            samePageWithHash: [],
            animationOutStart: [],
            animationOutDone: [],
            animationSkipped: [],
            pagePreloaded: [],
            pageLoaded: [],
            scrollStart: [],
            scrollDone: [],
            animationInStart: [],
            animationInDone: [],
            pageRetrievedFromCache: [],
            popState: [],
            openPageInNewTab: [],
            submitForm: [],
            enabled: [],
            disabled: [],
        };

        /**
         * helper variables
         */
        // id of element to scroll to after render
        this.scrollToElement = null
        // promise used for preload, so no new loading of the same page starts while page is loading
        this.preloadPromise = null
        // save options
        this.options = options
        // plugins array
        this.plugins = []

        /**
         * make modules accessible in instance
         */
        this.getUrl = getUrl
        this.cache = new Cache()<commit_msg>Fix missing serverError handler list<commit_after>import delegate from 'delegate'

// helpers
import Cache from './Cache'
import Link from './Link'
import transitionEnd from './transitionEnd'

// modules
import request from './modules/request'
import getDataFromHtml from './modules/getDataFromHtml'
import loadPage from './modules/loadPage'
import renderPage from './modules/renderPage'
import createState from './modules/createState'
import triggerEvent from './modules/triggerEvent'
import getUrl from './modules/getUrl'
import scrollTo from './modules/scrollTo'
import classify from './modules/classify'
import doScrolling from './modules/doScrolling'
import markSwupElements from './modules/markSwupElements'
import on from './modules/on'
import off from './modules/off'
import updateTransition from './modules/updateTransition'
import preloadPage from './modules/preloadPage'
import preloadPages from './modules/preloadPages'
import usePlugin from './modules/usePlugin'
import log from './modules/log'

export default class Swup {
    constructor(setOptions) {
        // default options
        let defaults = {
            cache: true,
            animationSelector: '[class*="transition-"]',
            elements: ['#swup'],
            pageClassPrefix: '',
            debugMode: false,
            scroll: true,

            doScrollingRightAway: false,
            animateScroll: true,
            scrollFriction: .3,
            scrollAcceleration: .04,

            preload: true,
            support: true,
            plugins: [],

            skipPopStateHandling: function(event){
                if (event.state && event.state.source == "swup") {
                    return false;
                }
                return true;
            },
            animateHistoryBrowsing: false,

            LINK_SELECTOR: 'a[href^="' + window.location.origin + '"]:not([data-no-swup]), a[href^="/"]:not([data-no-swup]), a[href^="#"]:not([data-no-swup])',
            FORM_SELECTOR: 'form[data-swup-form]',
        }

        /**
         * current transition object
         */
        this.transition = {}

        let options = {
            ...defaults,
            ...setOptions
        }

        /**
         * handler arrays
         */
        this._handlers = {
            willReplaceContent: [],
            contentReplaced: [],
            pageView: [],
            hoverLink: [],
            clickLink: [],
            samePage: [],
            samePageWithHash: [],
            animationOutStart: [],
            animationOutDone: [],
            animationSkipped: [],
            pagePreloaded: [],
            pageLoaded: [],
            scrollStart: [],
            scrollDone: [],
            serverError: [],
            animationInStart: [],
            animationInDone: [],
            pageRetrievedFromCache: [],
            popState: [],
            openPageInNewTab: [],
            submitForm: [],
            enabled: [],
            disabled: [],
        };

        /**
         * helper variables
         */
        // id of element to scroll to after render
        this.scrollToElement = null
        // promise used for preload, so no new loading of the same page starts while page is loading
        this.preloadPromise = null
        // save options
        this.options = options
        // plugins array
        this.plugins = []

        /**
         * make modules accessible in instance
         */
        this.getUrl = getUrl
        this.cache = new Cache()
{'fraction_non_alphanumeric': 0.11707317073170732, 'fraction_numerical': 0.000860832137733142, 'mean_word_length': 1.78505793048342, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6220642', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1703, 'n_words': 452}