diff --git a/assets/scripts/app.js b/assets/scripts/app.js
index d968465..0f01ff3 100644
--- a/assets/scripts/app.js
+++ b/assets/scripts/app.js
@@ -29,8 +29,8 @@ function init() {
app.init(app);
- $html.classList.add(config.CLASS.LOADED);
- $html.classList.add(config.CLASS.READY);
- $html.classList.remove(config.CLASS.LOADING);
+ $html.classList.add(config.CLASS_NAME.LOADED);
+ $html.classList.add(config.CLASS_NAME.READY);
+ $html.classList.remove(config.CLASS_NAME.LOADING);
}
diff --git a/assets/scripts/config.js b/assets/scripts/config.js
index fbfb0ce..fff2fef 100644
--- a/assets/scripts/config.js
+++ b/assets/scripts/config.js
@@ -1,20 +1,15 @@
const env = process.env.NODE_ENV
-export default config = {
-
- // App
- APP_NAME: 'Boilerplate',
- DATA_API_KEY: '.data-api',
-
- // Env
+export default config = Object.freeze({
+ // Environments
ENV: env,
IS_PROD: env === 'production',
IS_DEV: env === 'development',
- // Classnames
- CLASS: {
+ // CSS class names
+ CLASS_NAME: {
LOADING: 'is-loading',
READY: 'is-ready',
LOADED: 'is-loaded',
},
-}
+})
diff --git a/www/assets/scripts/app.js b/www/assets/scripts/app.js
index d6f4716..40bd833 100644
--- a/www/assets/scripts/app.js
+++ b/www/assets/scripts/app.js
@@ -1616,18 +1616,16 @@
// assets/scripts/config.js
var env = "development";
- var config_default = config = {
- APP_NAME: "Boilerplate",
- DATA_API_KEY: ".data-api",
+ var config_default = config = Object.freeze({
ENV: env,
IS_PROD: env === "production",
IS_DEV: env === "development",
- CLASS: {
+ CLASS_NAME: {
LOADING: "is-loading",
READY: "is-ready",
LOADED: "is-loaded"
}
- };
+ });
// assets/scripts/modules/Load.js
var Load_default = class extends _default {
@@ -4246,9 +4244,9 @@
function init() {
globals_default();
app.init(app);
- $html.classList.add(config_default.CLASS.LOADED);
- $html.classList.add(config_default.CLASS.READY);
- $html.classList.remove(config_default.CLASS.LOADING);
+ $html.classList.add(config_default.CLASS_NAME.LOADED);
+ $html.classList.add(config_default.CLASS_NAME.READY);
+ $html.classList.remove(config_default.CLASS_NAME.LOADING);
}
})();
/*
diff --git a/www/assets/scripts/app.js.map b/www/assets/scripts/app.js.map
index effa44a..bc75144 100644
--- a/www/assets/scripts/app.js.map
+++ b/www/assets/scripts/app.js.map
@@ -1,7 +1,7 @@
{
"version": 3,
"sources": ["../../../node_modules/node_modules/babel-plugin-transform-async-to-promises/helpers.js", "../../../node_modules/@barba/core/src/modules/Logger.ts", "../../../node_modules/@barba/core/src/defs/hooks.ts", "../../../node_modules/node_modules/path-to-regexp/index.js", "../../../node_modules/@barba/core/src/schemas/attribute.ts", "../../../node_modules/@barba/core/src/utils/dom.ts", "../../../node_modules/@barba/core/src/utils/history.ts", "../../../node_modules/@barba/core/src/utils/helpers.ts", "../../../node_modules/@barba/core/src/utils/url.ts", "../../../node_modules/@barba/core/src/utils/request.ts", "../../../node_modules/node_modules/is-promise/index.js", "../../../node_modules/@barba/core/src/utils/run-async.ts", "../../../node_modules/@barba/core/src/hooks.ts", "../../../node_modules/@barba/core/src/modules/Ignore.ts", "../../../node_modules/@barba/core/src/modules/Cache.ts", "../../../node_modules/@barba/core/src/modules/Prevent.ts", "../../../node_modules/@barba/core/src/modules/Error.ts", "../../../node_modules/@barba/core/src/modules/Store.ts", "../../../node_modules/@barba/core/src/modules/Transitions.ts", "../../../node_modules/@barba/core/src/modules/Views.ts", "../../../node_modules/@barba/core/src/polyfills/index.ts", "../../../node_modules/@barba/core/src/schemas/page.ts", "../../../node_modules/@barba/core/src/core.ts", "../../../node_modules/svg4everybody/dist/svg4everybody.js", "../../../node_modules/modujs/dist/main.esm.js", "../../../assets/scripts/modules.js", "../../../assets/scripts/modules/Load.js", "../../../assets/scripts/config.js", "../../../assets/scripts/utils/image.js", "../../../node_modules/locomotive-scroll/dist/locomotive-scroll.esm.js", "../../../assets/scripts/modules/Scroll.js", "../../../assets/scripts/globals.js", "../../../assets/scripts/utils/dom.js", "../../../assets/scripts/app.js"],
- "sourcesContent": ["// A type of promise-like that resolves synchronously and supports only one observer\nexport const _Pact = /*#__PURE__*/(function() {\n\tfunction _Pact() {}\n\t_Pact.prototype.then = function(onFulfilled, onRejected) {\n\t\tconst result = new _Pact();\n\t\tconst state = this.s;\n\t\tif (state) {\n\t\t\tconst callback = state & 1 ? onFulfilled : onRejected;\n\t\t\tif (callback) {\n\t\t\t\ttry {\n\t\t\t\t\t_settle(result, 1, callback(this.v));\n\t\t\t\t} catch (e) {\n\t\t\t\t\t_settle(result, 2, e);\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t} else {\n\t\t\t\treturn this;\n\t\t\t}\n\t\t}\n\t\tthis.o = function(_this) {\n\t\t\ttry {\n\t\t\t\tconst value = _this.v;\n\t\t\t\tif (_this.s & 1) {\n\t\t\t\t\t_settle(result, 1, onFulfilled ? onFulfilled(value) : value);\n\t\t\t\t} else if (onRejected) {\n\t\t\t\t\t_settle(result, 1, onRejected(value));\n\t\t\t\t} else {\n\t\t\t\t\t_settle(result, 2, value);\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\t_settle(result, 2, e);\n\t\t\t}\n\t\t};\n\t\treturn result;\n\t}\n\treturn _Pact;\n})();\n\n// Settles a pact synchronously\nexport function _settle(pact, state, value) {\n\tif (!pact.s) {\n\t\tif (value instanceof _Pact) {\n\t\t\tif (value.s) {\n\t\t\t\tif (state & 1) {\n\t\t\t\t\tstate = value.s;\n\t\t\t\t}\n\t\t\t\tvalue = value.v;\n\t\t\t} else {\n\t\t\t\tvalue.o = _settle.bind(null, pact, state);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (value && value.then) {\n\t\t\tvalue.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));\n\t\t\treturn;\n\t\t}\n\t\tpact.s = state;\n\t\tpact.v = value;\n\t\tconst observer = pact.o;\n\t\tif (observer) {\n\t\t\tobserver(pact);\n\t\t}\n\t}\n}\n\nexport function _isSettledPact(thenable) {\n\treturn thenable instanceof _Pact && thenable.s & 1;\n}\n\n// Converts argument to a function that always returns a Promise\nexport function _async(f) {\n\treturn function() {\n\t\tfor (var args = [], i = 0; i < arguments.length; i++) {\n\t\t\targs[i] = arguments[i];\n\t\t}\n\t\ttry {\n\t\t\treturn Promise.resolve(f.apply(this, args));\n\t\t} catch(e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n}\n\n// Awaits on a value that may or may not be a Promise (equivalent to the await keyword in ES2015, with continuations passed explicitly)\nexport function _await(value, then, direct) {\n\tif (direct) {\n\t\treturn then ? then(value) : value;\n\t}\n\tif (!value || !value.then) {\n\t\tvalue = Promise.resolve(value);\n\t}\n\treturn then ? value.then(then) : value;\n}\n\n// Awaits on a value that may or may not be a Promise, then ignores it\nexport function _awaitIgnored(value, direct) {\n\tif (!direct) {\n\t\treturn value && value.then ? value.then(_empty) : Promise.resolve();\n\t}\n}\n\n// Proceeds after a value has resolved, or proceeds immediately if the value is not thenable\nexport function _continue(value, then) {\n\treturn value && value.then ? value.then(then) : then(value);\n}\n\n// Proceeds after a value has resolved, or proceeds immediately if the value is not thenable\nexport function _continueIgnored(value) {\n\tif (value && value.then) {\n\t\treturn value.then(_empty);\n\t}\n}\n\n// Asynchronously iterate through an object that has a length property, passing the index as the first argument to the callback (even as the length property changes)\nexport function _forTo(array, body, check) {\n\tvar i = -1, pact, reject;\n\tfunction _cycle(result) {\n\t\ttry {\n\t\t\twhile (++i < array.length && (!check || !check())) {\n\t\t\t\tresult = body(i);\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\t\tresult = result.v;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (pact) {\n\t\t\t\t_settle(pact, 1, result);\n\t\t\t} else {\n\t\t\t\tpact = result;\n\t\t\t}\n\t\t} catch (e) {\n\t\t\t_settle(pact || (pact = new _Pact()), 2, e);\n\t\t}\n\t}\n\t_cycle();\n\treturn pact;\n}\n\n// Asynchronously iterate through an object's properties (including properties inherited from the prototype)\n// Uses a snapshot of the object's properties\nexport function _forIn(target, body, check) {\n\tvar keys = [];\n\tfor (var key in target) {\n\t\tkeys.push(key);\n\t}\n\treturn _forTo(keys, function(i) { return body(keys[i]); }, check);\n}\n\n// Asynchronously iterate through an object's own properties (excluding properties inherited from the prototype)\n// Uses a snapshot of the object's properties\nexport function _forOwn(target, body, check) {\n\tvar keys = [];\n\tfor (var key in target) {\n\t\tif (Object.prototype.hasOwnProperty.call(target, key)) {\n\t\t\tkeys.push(key);\n\t\t}\n\t}\n\treturn _forTo(keys, function(i) { return body(keys[i]); }, check);\n}\n\nexport const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== \"undefined\" ? (Symbol.iterator || (Symbol.iterator = Symbol(\"Symbol.iterator\"))) : \"@@iterator\";\n\n// Asynchronously iterate through an object's values\n// Uses for...of if the runtime supports it, otherwise iterates until length on a copy\nexport function _forOf(target, body, check) {\n\tif (typeof target[_iteratorSymbol] === \"function\") {\n\t\tvar iterator = target[_iteratorSymbol](), step, pact, reject;\n\t\tfunction _cycle(result) {\n\t\t\ttry {\n\t\t\t\twhile (!(step = iterator.next()).done && (!check || !check())) {\n\t\t\t\t\tresult = body(step.value);\n\t\t\t\t\tif (result && result.then) {\n\t\t\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\t\t\tresult = result.v;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (pact) {\n\t\t\t\t\t_settle(pact, 1, result);\n\t\t\t\t} else {\n\t\t\t\t\tpact = result;\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\t_settle(pact || (pact = new _Pact()), 2, e);\n\t\t\t}\n\t\t}\n\t\t_cycle();\n\t\tif (iterator.return) {\n\t\t\tvar _fixup = function(value) {\n\t\t\t\ttry {\n\t\t\t\t\tif (!step.done) {\n\t\t\t\t\t\titerator.return();\n\t\t\t\t\t}\n\t\t\t\t} catch(e) {\n\t\t\t\t}\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (pact && pact.then) {\n\t\t\t\treturn pact.then(_fixup, function(e) {\n\t\t\t\t\tthrow _fixup(e);\n\t\t\t\t});\n\t\t\t}\n\t\t\t_fixup();\n\t\t}\n\t\treturn pact;\n\t}\n\t// No support for Symbol.iterator\n\tif (!(\"length\" in target)) {\n\t\tthrow new TypeError(\"Object is not iterable\");\n\t}\n\t// Handle live collections properly\n\tvar values = [];\n\tfor (var i = 0; i < target.length; i++) {\n\t\tvalues.push(target[i]);\n\t}\n\treturn _forTo(values, function(i) { return body(values[i]); }, check);\n}\n\nexport const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== \"undefined\" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol(\"Symbol.asyncIterator\"))) : \"@@asyncIterator\";\n\n// Asynchronously iterate on a value using it's async iterator if present, or its synchronous iterator if missing\nexport function _forAwaitOf(target, body, check) {\n\tif (typeof target[_asyncIteratorSymbol] === \"function\") {\n\t\tvar pact = new _Pact();\n\t\tvar iterator = target[_asyncIteratorSymbol]();\n\t\titerator.next().then(_resumeAfterNext).then(void 0, _reject);\n\t\treturn pact;\n\t\tfunction _resumeAfterBody(result) {\n\t\t\tif (check && check()) {\n\t\t\t\treturn _settle(pact, 1, iterator.return ? iterator.return().then(function() { return result; }) : result);\n\t\t\t}\n\t\t\titerator.next().then(_resumeAfterNext).then(void 0, _reject);\n\t\t}\n\t\tfunction _resumeAfterNext(step) {\n\t\t\tif (step.done) {\n\t\t\t\t_settle(pact, 1);\n\t\t\t} else {\n\t\t\t\tPromise.resolve(body(step.value)).then(_resumeAfterBody).then(void 0, _reject);\n\t\t\t}\n\t\t}\n\t\tfunction _reject(error) {\n\t\t\t_settle(pact, 2, iterator.return ? iterator.return().then(function() { return error; }) : error);\n\t\t}\n\t}\n\treturn Promise.resolve(_forOf(target, function(value) { return Promise.resolve(value).then(body); }, check));\n}\n\n// Asynchronously implement a generic for loop\nexport function _for(test, update, body) {\n\tvar stage;\n\tfor (;;) {\n\t\tvar shouldContinue = test();\n\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\tshouldContinue = shouldContinue.v;\n\t\t}\n\t\tif (!shouldContinue) {\n\t\t\treturn result;\n\t\t}\n\t\tif (shouldContinue.then) {\n\t\t\tstage = 0;\n\t\t\tbreak;\n\t\t}\n\t\tvar result = body();\n\t\tif (result && result.then) {\n\t\t\tif (_isSettledPact(result)) {\n\t\t\t\tresult = result.s;\n\t\t\t} else {\n\t\t\t\tstage = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (update) {\n\t\t\tvar updateValue = update();\n\t\t\tif (updateValue && updateValue.then && !_isSettledPact(updateValue)) {\n\t\t\t\tstage = 2;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tvar pact = new _Pact();\n\tvar reject = _settle.bind(null, pact, 2);\n\t(stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);\n\treturn pact;\n\tfunction _resumeAfterBody(value) {\n\t\tresult = value;\n\t\tdo {\n\t\t\tif (update) {\n\t\t\t\tupdateValue = update();\n\t\t\t\tif (updateValue && updateValue.then && !_isSettledPact(updateValue)) {\n\t\t\t\t\tupdateValue.then(_resumeAfterUpdate).then(void 0, reject);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tshouldContinue = test();\n\t\t\tif (!shouldContinue || (_isSettledPact(shouldContinue) && !shouldContinue.v)) {\n\t\t\t\t_settle(pact, 1, result);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (shouldContinue.then) {\n\t\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresult = body();\n\t\t\tif (_isSettledPact(result)) {\n\t\t\t\tresult = result.v;\n\t\t\t}\n\t\t} while (!result || !result.then);\n\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t}\n\tfunction _resumeAfterTest(shouldContinue) {\n\t\tif (shouldContinue) {\n\t\t\tresult = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t} else {\n\t\t\t\t_resumeAfterBody(result);\n\t\t\t}\n\t\t} else {\n\t\t\t_settle(pact, 1, result);\n\t\t}\n\t}\n\tfunction _resumeAfterUpdate() {\n\t\tif (shouldContinue = test()) {\n\t\t\tif (shouldContinue.then) {\n\t\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t} else {\n\t\t\t\t_resumeAfterTest(shouldContinue);\n\t\t\t}\n\t\t} else {\n\t\t\t_settle(pact, 1, result);\n\t\t}\n\t}\n}\n\n// Asynchronously implement a do ... while loop\nexport function _do(body, test) {\n\tvar awaitBody;\n\tdo {\n\t\tvar result = body();\n\t\tif (result && result.then) {\n\t\t\tif (_isSettledPact(result)) {\n\t\t\t\tresult = result.v;\n\t\t\t} else {\n\t\t\t\tawaitBody = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tvar shouldContinue = test();\n\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\tshouldContinue = shouldContinue.v;\n\t\t}\n\t\tif (!shouldContinue) {\n\t\t\treturn result;\n\t\t}\n\t} while (!shouldContinue.then);\n\tconst pact = new _Pact();\n\tconst reject = _settle.bind(null, pact, 2);\n\t(awaitBody ? result.then(_resumeAfterBody) : shouldContinue.then(_resumeAfterTest)).then(void 0, reject);\n\treturn pact;\n\tfunction _resumeAfterBody(value) {\n\t\tresult = value;\n\t\tfor (;;) {\n\t\t\tshouldContinue = test();\n\t\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\t\tshouldContinue = shouldContinue.v;\n\t\t\t}\n\t\t\tif (!shouldContinue) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (shouldContinue.then) {\n\t\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresult = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\tresult = result.v;\n\t\t\t\t} else {\n\t\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t_settle(pact, 1, result);\n\t}\n\tfunction _resumeAfterTest(shouldContinue) {\n\t\tif (shouldContinue) {\n\t\t\tdo {\n\t\t\t\tresult = body();\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tif (_isSettledPact(result)) {\n\t\t\t\t\t\tresult = result.v;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tshouldContinue = test();\n\t\t\t\tif (_isSettledPact(shouldContinue)) {\n\t\t\t\t\tshouldContinue = shouldContinue.v;\n\t\t\t\t}\n\t\t\t\tif (!shouldContinue) {\n\t\t\t\t\t_settle(pact, 1, result);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} while (!shouldContinue.then);\n\t\t\tshouldContinue.then(_resumeAfterTest).then(void 0, reject);\n\t\t} else {\n\t\t\t_settle(pact, 1, result);\n\t\t}\n\t}\n}\n\n// Asynchronously implement a switch statement\nexport function _switch(discriminant, cases) {\n\tvar dispatchIndex = -1;\n\tvar awaitBody;\n\touter: {\n\t\tfor (var i = 0; i < cases.length; i++) {\n\t\t\tvar test = cases[i][0];\n\t\t\tif (test) {\n\t\t\t\tvar testValue = test();\n\t\t\t\tif (testValue && testValue.then) {\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\t\t\t\tif (testValue === discriminant) {\n\t\t\t\t\tdispatchIndex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Found the default case, set it as the pending dispatch case\n\t\t\t\tdispatchIndex = i;\n\t\t\t}\n\t\t}\n\t\tif (dispatchIndex !== -1) {\n\t\t\tdo {\n\t\t\t\tvar body = cases[dispatchIndex][1];\n\t\t\t\twhile (!body) {\n\t\t\t\t\tdispatchIndex++;\n\t\t\t\t\tbody = cases[dispatchIndex][1];\n\t\t\t\t}\n\t\t\t\tvar result = body();\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tawaitBody = true;\n\t\t\t\t\tbreak outer;\n\t\t\t\t}\n\t\t\t\tvar fallthroughCheck = cases[dispatchIndex][2];\n\t\t\t\tdispatchIndex++;\n\t\t\t} while (fallthroughCheck && !fallthroughCheck());\n\t\t\treturn result;\n\t\t}\n\t}\n\tconst pact = new _Pact();\n\tconst reject = _settle.bind(null, pact, 2);\n\t(awaitBody ? result.then(_resumeAfterBody) : testValue.then(_resumeAfterTest)).then(void 0, reject);\n\treturn pact;\n\tfunction _resumeAfterTest(value) {\n\t\tfor (;;) {\n\t\t\tif (value === discriminant) {\n\t\t\t\tdispatchIndex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (++i === cases.length) {\n\t\t\t\tif (dispatchIndex !== -1) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\t_settle(pact, 1, result);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttest = cases[i][0];\n\t\t\tif (test) {\n\t\t\t\tvalue = test();\n\t\t\t\tif (value && value.then) {\n\t\t\t\t\tvalue.then(_resumeAfterTest).then(void 0, reject);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdispatchIndex = i;\n\t\t\t}\n\t\t}\n\t\tdo {\n\t\t\tvar body = cases[dispatchIndex][1];\n\t\t\twhile (!body) {\n\t\t\t\tdispatchIndex++;\n\t\t\t\tbody = cases[dispatchIndex][1];\n\t\t\t}\n\t\t\tvar result = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar fallthroughCheck = cases[dispatchIndex][2];\n\t\t\tdispatchIndex++;\n\t\t} while (fallthroughCheck && !fallthroughCheck());\n\t\t_settle(pact, 1, result);\n\t}\n\tfunction _resumeAfterBody(result) {\n\t\tfor (;;) {\n\t\t\tvar fallthroughCheck = cases[dispatchIndex][2];\n\t\t\tif (!fallthroughCheck || fallthroughCheck()) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdispatchIndex++;\n\t\t\tvar body = cases[dispatchIndex][1];\n\t\t\twhile (!body) {\n\t\t\t\tdispatchIndex++;\n\t\t\t\tbody = cases[dispatchIndex][1];\n\t\t\t}\n\t\t\tresult = body();\n\t\t\tif (result && result.then) {\n\t\t\t\tresult.then(_resumeAfterBody).then(void 0, reject);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t_settle(pact, 1, result);\n\t}\n}\n\n// Asynchronously call a function and pass the result to explicitly passed continuations\nexport function _call(body, then, direct) {\n\tif (direct) {\n\t\treturn then ? then(body()) : body();\n\t}\n\ttry {\n\t\tvar result = Promise.resolve(body());\n\t\treturn then ? result.then(then) : result;\n\t} catch (e) {\n\t\treturn Promise.reject(e);\n\t}\n}\n\n// Asynchronously call a function and swallow the result\nexport function _callIgnored(body, direct) {\n\treturn _call(body, _empty, direct);\n}\n\n// Asynchronously call a function and pass the result to explicitly passed continuations\nexport function _invoke(body, then) {\n\tvar result = body();\n\tif (result && result.then) {\n\t\treturn result.then(then);\n\t}\n\treturn then(result);\n}\n\n// Asynchronously call a function and swallow the result\nexport function _invokeIgnored(body) {\n\tvar result = body();\n\tif (result && result.then) {\n\t\treturn result.then(_empty);\n\t}\n}\n\n// Asynchronously call a function and send errors to recovery continuation\nexport function _catch(body, recover) {\n\ttry {\n\t\tvar result = body();\n\t} catch(e) {\n\t\treturn recover(e);\n\t}\n\tif (result && result.then) {\n\t\treturn result.then(void 0, recover);\n\t}\n\treturn result;\n}\n\n// Asynchronously await a promise and pass the result to a finally continuation\nexport function _finallyRethrows(body, finalizer) {\n\ttry {\n\t\tvar result = body();\n\t} catch (e) {\n\t\treturn finalizer(true, e);\n\t}\n\tif (result && result.then) {\n\t\treturn result.then(finalizer.bind(null, false), finalizer.bind(null, true));\n\t}\n\treturn finalizer(false, result);\n}\n\n// Asynchronously await a promise and invoke a finally continuation that always overrides the result\nexport function _finally(body, finalizer) {\n\ttry {\n\t\tvar result = body();\n\t} catch (e) {\n\t\treturn finalizer();\n\t}\n\tif (result && result.then) {\n\t\treturn result.then(finalizer, finalizer);\n\t}\n\treturn finalizer();\n}\n\n// Rethrow or return a value from a finally continuation\nexport function _rethrow(thrown, value) {\n\tif (thrown)\n\t\tthrow value;\n\treturn value;\n}\n\n// Empty function to implement break and other control flow that ignores asynchronous results\nexport function _empty() {\n}\n\n// Sentinel value for early returns in generators \nexport const _earlyReturn = /*#__PURE__*/ {};\n\n// Asynchronously call a function and send errors to recovery continuation, skipping early returns\nexport function _catchInGenerator(body, recover) {\n\treturn _catch(body, function(e) {\n\t\tif (e === _earlyReturn) {\n\t\t\tthrow e;\n\t\t}\n\t\treturn recover(e);\n\t});\n}\n\n// Asynchronous generator class; accepts the entrypoint of the generator, to which it passes itself when the generator should start\nexport const _AsyncGenerator = /*#__PURE__*/(function() {\n\tfunction _AsyncGenerator(entry) {\n\t\tthis._entry = entry;\n\t\tthis._pact = null;\n\t\tthis._resolve = null;\n\t\tthis._return = null;\n\t\tthis._promise = null;\n\t}\n\n\tfunction _wrapReturnedValue(value) {\n\t\treturn { value: value, done: true };\n\t}\n\tfunction _wrapYieldedValue(value) {\n\t\treturn { value: value, done: false };\n\t}\n\n\t_AsyncGenerator.prototype._yield = function(value) {\n\t\t// Yield the value to the pending next call\n\t\tthis._resolve(value && value.then ? value.then(_wrapYieldedValue) : _wrapYieldedValue(value));\n\t\t// Return a pact for an upcoming next/return/throw call\n\t\treturn this._pact = new _Pact();\n\t};\n\t_AsyncGenerator.prototype.next = function(value) {\n\t\t// Advance the generator, starting it if it has yet to be started\n\t\tconst _this = this;\n\t\treturn _this._promise = new Promise(function (resolve) {\n\t\t\tconst _pact = _this._pact;\n\t\t\tif (_pact === null) {\n\t\t\t\tconst _entry = _this._entry;\n\t\t\t\tif (_entry === null) {\n\t\t\t\t\t// Generator is started, but not awaiting a yield expression\n\t\t\t\t\t// Abandon the next call!\n\t\t\t\t\treturn resolve(_this._promise);\n\t\t\t\t}\n\t\t\t\t// Start the generator\n\t\t\t\t_this._entry = null;\n\t\t\t\t_this._resolve = resolve;\n\t\t\t\tfunction returnValue(value) {\n\t\t\t\t\t_this._resolve(value && value.then ? value.then(_wrapReturnedValue) : _wrapReturnedValue(value));\n\t\t\t\t\t_this._pact = null;\n\t\t\t\t\t_this._resolve = null;\n\t\t\t\t}\n\t\t\t\tvar result = _entry(_this);\n\t\t\t\tif (result && result.then) {\n\t\t\t\t\tresult.then(returnValue, function(error) {\n\t\t\t\t\t\tif (error === _earlyReturn) {\n\t\t\t\t\t\t\treturnValue(_this._return);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst pact = new _Pact();\n\t\t\t\t\t\t\t_this._resolve(pact);\n\t\t\t\t\t\t\t_this._pact = null;\n\t\t\t\t\t\t\t_this._resolve = null;\n\t\t\t\t\t\t\t_resolve(pact, 2, error);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturnValue(result);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Generator is started and a yield expression is pending, settle it\n\t\t\t\t_this._pact = null;\n\t\t\t\t_this._resolve = resolve;\n\t\t\t\t_settle(_pact, 1, value);\n\t\t\t}\n\t\t});\n\t};\n\t_AsyncGenerator.prototype.return = function(value) {\n\t\t// Early return from the generator if started, otherwise abandons the generator\n\t\tconst _this = this;\n\t\treturn _this._promise = new Promise(function (resolve) {\n\t\t\tconst _pact = _this._pact;\n\t\t\tif (_pact === null) {\n\t\t\t\tif (_this._entry === null) {\n\t\t\t\t\t// Generator is started, but not awaiting a yield expression\n\t\t\t\t\t// Abandon the return call!\n\t\t\t\t\treturn resolve(_this._promise);\n\t\t\t\t}\n\t\t\t\t// Generator is not started, abandon it and return the specified value\n\t\t\t\t_this._entry = null;\n\t\t\t\treturn resolve(value && value.then ? value.then(_wrapReturnedValue) : _wrapReturnedValue(value));\n\t\t\t}\n\t\t\t// Settle the yield expression with a rejected \"early return\" value\n\t\t\t_this._return = value;\n\t\t\t_this._resolve = resolve;\n\t\t\t_this._pact = null;\n\t\t\t_settle(_pact, 2, _earlyReturn);\n\t\t});\n\t};\n\t_AsyncGenerator.prototype.throw = function(error) {\n\t\t// Inject an exception into the pending yield expression\n\t\tconst _this = this;\n\t\treturn _this._promise = new Promise(function (resolve, reject) {\n\t\t\tconst _pact = _this._pact;\n\t\t\tif (_pact === null) {\n\t\t\t\tif (_this._entry === null) {\n\t\t\t\t\t// Generator is started, but not awaiting a yield expression\n\t\t\t\t\t// Abandon the throw call!\n\t\t\t\t\treturn resolve(_this._promise);\n\t\t\t\t}\n\t\t\t\t// Generator is not started, abandon it and return a rejected Promise containing the error\n\t\t\t\t_this._entry = null;\n\t\t\t\treturn reject(error);\n\t\t\t}\n\t\t\t// Settle the yield expression with the value as a rejection\n\t\t\t_this._resolve = resolve;\n\t\t\t_this._pact = null;\n\t\t\t_settle(_pact, 2, error);\n\t\t});\n\t};\n\n\t_AsyncGenerator.prototype[_asyncIteratorSymbol] = function() {\n\t\treturn this;\n\t};\n\t\n\treturn _AsyncGenerator;\n})();\n", "/**\n * @barba/core/modules/Logger\n *
\n * ## Logger.\n *\n * - Display informations via the console\n *\n * @module core/modules/Logger\n * @preferred\n */\n\n/***/\n\n/**\n * Log levels, all lower level messages are printed\n *\n * 0. mute\n * 1. error = `console.error()`\n * 2. warning= `console.warn()`\n * 3. info = `console.info()`\n * 4. debug = `console.log()`\n */\nexport enum LogLevels {\n off = 0,\n error = 1,\n warning = 2,\n info = 3,\n debug = 4,\n}\n\n/**\n * Global log level\n */\nlet _level: number = LogLevels.off;\n\nexport class Logger {\n /**\n * Get global log level.\n */\n public static getLevel(): number {\n return _level;\n }\n\n /**\n * Set global log level.\n */\n public static setLevel(name: keyof typeof LogLevels): number {\n _level = LogLevels[name];\n\n return _level;\n }\n\n /**\n * Log \"prefix\".\n */\n private _source: string;\n\n /**\n * Creates an instance of Logger.\n */\n constructor(source: string) {\n this._source = source;\n }\n\n /**\n * Permanent, unremovable log.\n */\n // public print(...objects: any[]): void {\n // this._log(console.info, LogLevels.off, objects);\n // }\n\n /**\n * Error log.\n */\n public error(...objects: any[]): void {\n this._log(console.error, LogLevels.error, objects);\n }\n\n /**\n * Warn log.\n */\n public warn(...objects: any[]): void {\n this._log(console.warn, LogLevels.warning, objects);\n }\n\n /**\n * Info log.\n */\n public info(...objects: any[]): void {\n this._log(console.info, LogLevels.info, objects);\n }\n\n /**\n * Debug log.\n */\n public debug(...objects: any[]): void {\n this._log(console.log, LogLevels.debug, objects);\n }\n\n /**\n * Internal logger.\n */\n private _log(fn: () => void, level: number, objects: any[]): void {\n if (level <= Logger.getLevel()) {\n fn.apply(console, ([`[${this._source}] `].concat(objects) as unknown) as [\n\n ]);\n }\n }\n}\n", "/**\n * @module typings/core\n */\nimport { ITransitionData, ITransitionPage, IViewData } from './index';\n\nexport type HooksBarba =\n | 'ready'\n | 'page'\n | 'reset'\n | 'currentAdded'\n | 'currentRemoved'\n | 'nextAdded'\n | 'nextRemoved';\n\nexport type HooksOnce = 'beforeOnce' | 'once' | 'afterOnce';\n\nexport type HooksPage =\n | 'before'\n | 'beforeLeave'\n | 'leave'\n | 'afterLeave'\n | 'beforeEnter'\n | 'enter'\n | 'afterEnter'\n | 'after';\n\nexport type HooksBefore = 'beforeOnce' | 'beforeLeave' | 'beforeEnter';\nexport type HooksAfter = 'afterOnce' | 'afterLeave' | 'afterEnter';\n\nexport type HooksTransition = HooksOnce | HooksPage;\nexport type HooksView = HooksBefore | HooksAfter;\nexport type HooksAll = HooksBarba | HooksTransition;\n\n// Allow optional \"dynamically created\" hooks\nexport type HooksTransitionMap = { [key in HooksTransition]?: any };\n\nexport type HookFunction = (\n data?: ITransitionData | IViewData,\n t?: ITransitionPage\n) => Promise | void;\n\nexport class HookMethods {\n public before: (fn: HookFunction, ctx?: any) => void;\n public beforeLeave: (fn: HookFunction, ctx?: any) => void;\n public leave: (fn: HookFunction, ctx?: any) => void;\n public afterLeave: (fn: HookFunction, ctx?: any) => void;\n public beforeEnter: (fn: HookFunction, ctx?: any) => void;\n public enter: (fn: HookFunction, ctx?: any) => void;\n public afterEnter: (fn: HookFunction, ctx?: any) => void;\n public after: (fn: HookFunction, ctx?: any) => void;\n}\n", "/**\n * Expose `pathToRegexp`.\n */\nmodule.exports = pathToRegexp\nmodule.exports.match = match\nmodule.exports.regexpToFunction = regexpToFunction\nmodule.exports.parse = parse\nmodule.exports.compile = compile\nmodule.exports.tokensToFunction = tokensToFunction\nmodule.exports.tokensToRegExp = tokensToRegExp\n\n/**\n * Default configs.\n */\nvar DEFAULT_DELIMITER = '/'\n\n/**\n * The main path matching regexp utility.\n *\n * @type {RegExp}\n */\nvar PATH_REGEXP = new RegExp([\n // Match escaped characters that would otherwise appear in future matches.\n // This allows the user to escape special characters that won't transform.\n '(\\\\\\\\.)',\n // Match Express-style parameters and un-named parameters with a prefix\n // and optional suffixes. Matches appear as:\n //\n // \":test(\\\\d+)?\" => [\"test\", \"\\d+\", undefined, \"?\"]\n // \"(\\\\d+)\" => [undefined, undefined, \"\\d+\", undefined]\n '(?:\\\\:(\\\\w+)(?:\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))?|\\\\(((?:\\\\\\\\.|[^\\\\\\\\()])+)\\\\))([+*?])?'\n].join('|'), 'g')\n\n/**\n * Parse a string for the raw tokens.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!Array}\n */\nfunction parse (str, options) {\n var tokens = []\n var key = 0\n var index = 0\n var path = ''\n var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER\n var whitelist = (options && options.whitelist) || undefined\n var pathEscaped = false\n var res\n\n while ((res = PATH_REGEXP.exec(str)) !== null) {\n var m = res[0]\n var escaped = res[1]\n var offset = res.index\n path += str.slice(index, offset)\n index = offset + m.length\n\n // Ignore already escaped sequences.\n if (escaped) {\n path += escaped[1]\n pathEscaped = true\n continue\n }\n\n var prev = ''\n var name = res[2]\n var capture = res[3]\n var group = res[4]\n var modifier = res[5]\n\n if (!pathEscaped && path.length) {\n var k = path.length - 1\n var c = path[k]\n var matches = whitelist ? whitelist.indexOf(c) > -1 : true\n\n if (matches) {\n prev = c\n path = path.slice(0, k)\n }\n }\n\n // Push the current path onto the tokens.\n if (path) {\n tokens.push(path)\n path = ''\n pathEscaped = false\n }\n\n var repeat = modifier === '+' || modifier === '*'\n var optional = modifier === '?' || modifier === '*'\n var pattern = capture || group\n var delimiter = prev || defaultDelimiter\n\n tokens.push({\n name: name || key++,\n prefix: prev,\n delimiter: delimiter,\n optional: optional,\n repeat: repeat,\n pattern: pattern\n ? escapeGroup(pattern)\n : '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']+?'\n })\n }\n\n // Push any remaining characters.\n if (path || index < str.length) {\n tokens.push(path + str.substr(index))\n }\n\n return tokens\n}\n\n/**\n * Compile a string to a template function for the path.\n *\n * @param {string} str\n * @param {Object=} options\n * @return {!function(Object=, Object=)}\n */\nfunction compile (str, options) {\n return tokensToFunction(parse(str, options), options)\n}\n\n/**\n * Create path match function from `path-to-regexp` spec.\n */\nfunction match (str, options) {\n var keys = []\n var re = pathToRegexp(str, keys, options)\n return regexpToFunction(re, keys)\n}\n\n/**\n * Create a path match function from `path-to-regexp` output.\n */\nfunction regexpToFunction (re, keys) {\n return function (pathname, options) {\n var m = re.exec(pathname)\n if (!m) return false\n\n var path = m[0]\n var index = m.index\n var params = {}\n var decode = (options && options.decode) || decodeURIComponent\n\n for (var i = 1; i < m.length; i++) {\n if (m[i] === undefined) continue\n\n var key = keys[i - 1]\n\n if (key.repeat) {\n params[key.name] = m[i].split(key.delimiter).map(function (value) {\n return decode(value, key)\n })\n } else {\n params[key.name] = decode(m[i], key)\n }\n }\n\n return { path: path, index: index, params: params }\n }\n}\n\n/**\n * Expose a method for transforming tokens into the path function.\n */\nfunction tokensToFunction (tokens, options) {\n // Compile all the tokens into regexps.\n var matches = new Array(tokens.length)\n\n // Compile all the patterns before compilation.\n for (var i = 0; i < tokens.length; i++) {\n if (typeof tokens[i] === 'object') {\n matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options))\n }\n }\n\n return function (data, options) {\n var path = ''\n var encode = (options && options.encode) || encodeURIComponent\n var validate = options ? options.validate !== false : true\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n path += token\n continue\n }\n\n var value = data ? data[token.name] : undefined\n var segment\n\n if (Array.isArray(value)) {\n if (!token.repeat) {\n throw new TypeError('Expected \"' + token.name + '\" to not repeat, but got array')\n }\n\n if (value.length === 0) {\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to not be empty')\n }\n\n for (var j = 0; j < value.length; j++) {\n segment = encode(value[j], token)\n\n if (validate && !matches[i].test(segment)) {\n throw new TypeError('Expected all \"' + token.name + '\" to match \"' + token.pattern + '\"')\n }\n\n path += (j === 0 ? token.prefix : token.delimiter) + segment\n }\n\n continue\n }\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n segment = encode(String(value), token)\n\n if (validate && !matches[i].test(segment)) {\n throw new TypeError('Expected \"' + token.name + '\" to match \"' + token.pattern + '\", but got \"' + segment + '\"')\n }\n\n path += token.prefix + segment\n continue\n }\n\n if (token.optional) continue\n\n throw new TypeError('Expected \"' + token.name + '\" to be ' + (token.repeat ? 'an array' : 'a string'))\n }\n\n return path\n }\n}\n\n/**\n * Escape a regular expression string.\n *\n * @param {string} str\n * @return {string}\n */\nfunction escapeString (str) {\n return str.replace(/([.+*?=^!:${}()[\\]|/\\\\])/g, '\\\\$1')\n}\n\n/**\n * Escape the capturing group by escaping special characters and meaning.\n *\n * @param {string} group\n * @return {string}\n */\nfunction escapeGroup (group) {\n return group.replace(/([=!:$/()])/g, '\\\\$1')\n}\n\n/**\n * Get the flags for a regexp from the options.\n *\n * @param {Object} options\n * @return {string}\n */\nfunction flags (options) {\n return options && options.sensitive ? '' : 'i'\n}\n\n/**\n * Pull out keys from a regexp.\n *\n * @param {!RegExp} path\n * @param {Array=} keys\n * @return {!RegExp}\n */\nfunction regexpToRegexp (path, keys) {\n if (!keys) return path\n\n // Use a negative lookahead to match only capturing groups.\n var groups = path.source.match(/\\((?!\\?)/g)\n\n if (groups) {\n for (var i = 0; i < groups.length; i++) {\n keys.push({\n name: i,\n prefix: null,\n delimiter: null,\n optional: false,\n repeat: false,\n pattern: null\n })\n }\n }\n\n return path\n}\n\n/**\n * Transform an array into a regexp.\n *\n * @param {!Array} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction arrayToRegexp (path, keys, options) {\n var parts = []\n\n for (var i = 0; i < path.length; i++) {\n parts.push(pathToRegexp(path[i], keys, options).source)\n }\n\n return new RegExp('(?:' + parts.join('|') + ')', flags(options))\n}\n\n/**\n * Create a path regexp from string input.\n *\n * @param {string} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction stringToRegexp (path, keys, options) {\n return tokensToRegExp(parse(path, options), keys, options)\n}\n\n/**\n * Expose a function for taking tokens and returning a RegExp.\n *\n * @param {!Array} tokens\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction tokensToRegExp (tokens, keys, options) {\n options = options || {}\n\n var strict = options.strict\n var start = options.start !== false\n var end = options.end !== false\n var delimiter = options.delimiter || DEFAULT_DELIMITER\n var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')\n var route = start ? '^' : ''\n\n // Iterate over the tokens and create our regexp string.\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i]\n\n if (typeof token === 'string') {\n route += escapeString(token)\n } else {\n var capture = token.repeat\n ? '(?:' + token.pattern + ')(?:' + escapeString(token.delimiter) + '(?:' + token.pattern + '))*'\n : token.pattern\n\n if (keys) keys.push(token)\n\n if (token.optional) {\n if (!token.prefix) {\n route += '(' + capture + ')?'\n } else {\n route += '(?:' + escapeString(token.prefix) + '(' + capture + '))?'\n }\n } else {\n route += escapeString(token.prefix) + '(' + capture + ')'\n }\n }\n }\n\n if (end) {\n if (!strict) route += '(?:' + escapeString(delimiter) + ')?'\n\n route += endsWith === '$' ? '$' : '(?=' + endsWith + ')'\n } else {\n var endToken = tokens[tokens.length - 1]\n var isEndDelimited = typeof endToken === 'string'\n ? endToken[endToken.length - 1] === delimiter\n : endToken === undefined\n\n if (!strict) route += '(?:' + escapeString(delimiter) + '(?=' + endsWith + '))?'\n if (!isEndDelimited) route += '(?=' + escapeString(delimiter) + '|' + endsWith + ')'\n }\n\n return new RegExp(route, flags(options))\n}\n\n/**\n * Normalize the given path string, returning a regular expression.\n *\n * An empty array can be passed in for the keys, which will hold the\n * placeholder key descriptions. For example, using `/user/:id`, `keys` will\n * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.\n *\n * @param {(string|RegExp|Array)} path\n * @param {Array=} keys\n * @param {Object=} options\n * @return {!RegExp}\n */\nfunction pathToRegexp (path, keys, options) {\n if (path instanceof RegExp) {\n return regexpToRegexp(path, keys)\n }\n\n if (Array.isArray(path)) {\n return arrayToRegexp(/** @type {!Array} */ (path), keys, options)\n }\n\n return stringToRegexp(/** @type {string} */ (path), keys, options)\n}\n", "/**\n * @barba/core/schemas\n *
\n * ## Schemas description.\n *\n * @module core/schemas\n * @preferred\n */\n\n/***/\n\n// Definitions\nimport { ISchemaAttribute } from '../defs';\n\n/**\n * See [[ISchemaAttribute]]\n */\nexport const schemaAttribute: ISchemaAttribute = {\n container: 'container',\n history: 'history',\n namespace: 'namespace',\n prefix: 'data-barba',\n prevent: 'prevent',\n wrapper: 'wrapper',\n};\n", "/**\n * @barba/core/utils/dom\n *
\n * ## Dom utils\n *\n * - Access DOM contents\n * - DOM vs string conversions\n *\n * @module core/utils/dom\n * @preferred\n */\n\n/***/\n\nimport path from 'path';\n\n// Definitions\nimport { ISchemaAttribute, Link, Scope, Wrapper } from '../defs';\n// Schemas\nimport { schemaAttribute } from '../schemas/attribute';\n\nexport class Dom {\n private _attr: ISchemaAttribute = schemaAttribute;\n private _parser: DOMParser = new DOMParser();\n\n /**\n * Convert HTMLDocument to string.\n */\n public toString(el: HTMLElement): string {\n return el.outerHTML;\n }\n\n /**\n * Parse HTML string to HTMLDocument.\n */\n // see https://github.com/barbajs/barba/issues/362\n // Seems that using DOMParser.parseFromString causes this issue.\n public toDocument(htmlString: string): HTMLDocument {\n return this._parser.parseFromString(htmlString, 'text/html');\n }\n\n /**\n * Parse HTML string to DIVElement.\n *\n * DOMParser.parseFromString fails with img[srcset] on iOS.\n * see https://github.com/barbajs/barba/issues/362\n */\n public toElement(htmlString: string): HTMLDivElement {\n const div = document.createElement('div');\n\n div.innerHTML = htmlString;\n return div;\n }\n\n /**\n * Get HTML content.\n */\n public getHtml(doc: HTMLDocument = document): string {\n return this.toString(doc.documentElement);\n }\n\n /**\n * Get full document content.\n */\n // getDocument(el = document.documentElement) {\n // return this.toStr(el);\n // },\n\n /**\n * Get `[data-barba=\"wrapper\"]`.\n */\n public getWrapper(scope: Scope = document): Wrapper {\n return scope.querySelector(\n `[${this._attr.prefix}=\"${this._attr.wrapper}\"]`\n );\n }\n\n /**\n * Get `[data-barba=\"container\"]`.\n */\n public getContainer(scope: Scope = document): HTMLElement | null {\n return scope.querySelector(\n `[${this._attr.prefix}=\"${this._attr.container}\"]`\n );\n }\n\n /**\n * Remove container and store next sibling (if applicable).\n */\n public removeContainer(container: HTMLElement) {\n if (document.body.contains(container)) {\n container.parentNode.removeChild(container);\n }\n }\n\n /**\n * Add container before next sibling or at the end of the wrapper.\n */\n public addContainer(container: HTMLElement, wrapper: HTMLElement) {\n const existingContainer = this.getContainer();\n\n if (existingContainer) {\n this._insertAfter(container, existingContainer);\n } else {\n wrapper.appendChild(container);\n }\n }\n\n /**\n * Get `[data-barba-namespace]`.\n */\n public getNamespace(scope: Scope = document): string | null {\n const ns = scope.querySelector(\n `[${this._attr.prefix}-${this._attr.namespace}]`\n );\n\n return ns\n ? ns.getAttribute(`${this._attr.prefix}-${this._attr.namespace}`)\n : null;\n }\n\n /**\n * Get URL from `href` value.\n */\n public getHref(el: Link): string | null {\n // HTML tagName is UPPERCASE, xhtml tagName keeps existing case.\n if (el.tagName && el.tagName.toLowerCase() === 'a') {\n // HTMLAnchorElement, full URL available\n if (typeof el.href === 'string') {\n return el.href;\n }\n\n // Probably a SVGAElement\u2026\n const href = el.getAttribute('href') || el.getAttribute('xlink:href');\n\n /* istanbul ignore else */\n if (href) {\n // When link comes from SVG, `href` returns an object, not a string.\n const attr: string =\n ((href as unknown) as SVGAnimatedString).baseVal || href;\n\n return this.resolveUrl(attr);\n }\n }\n return null;\n }\n\n // Copyright 2014 Simon Lydell\n // X11 (\u201CMIT\u201D) Licensed. (See LICENSE\n // https://github.com/lydell/resolve-url/blob/master/resolve-url.js\n /* istanbul ignore next */\n public resolveUrl(...urls: string[]) {\n const numUrls = urls.length;\n\n if (numUrls === 0) {\n throw new Error('resolveUrl requires at least one argument; got none.');\n }\n\n const base = document.createElement('base');\n base.href = arguments[0];\n\n if (numUrls === 1) {\n return base.href;\n }\n\n const head = document.getElementsByTagName('head')[0];\n head.insertBefore(base, head.firstChild);\n\n const a = document.createElement('a');\n let resolved;\n\n for (let index = 1; index < numUrls; index++) {\n a.href = arguments[index];\n resolved = a.href;\n base.href = resolved;\n }\n\n head.removeChild(base);\n\n return resolved;\n }\n\n /**\n * Insert node after another node.\n */\n private _insertAfter(newNode: Node, referenceNode: Node) {\n referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);\n }\n}\n\nconst dom = new Dom();\n\nexport { dom };\n", "import { HistoryAction, LinkEvent, Trigger } from '../defs';\n// Schemas\nimport { schemaAttribute } from '../schemas/attribute';\n\n/**\n * @barba/core/utils/history\n *
\n * ## History manager.\n *\n * - Keep track of the navigation history\n *\n * @module core/utils/history\n * @preferred\n */\n\n/**\n * State item.\n *\n * @property from\n * @property index\n */\ninterface IHistoryItem {\n /** origin */\n from: string;\n /** index */\n index: number;\n /** states */\n states: IStateItem[];\n}\n\n/***/\ninterface ICoords {\n x: number;\n y: number;\n}\n\n/**\n * History item.\n *\n * @property namespace\n * @property scroll\n * @property URL\n */\ninterface IStateItem {\n /** namespace */\n ns: string | undefined;\n /** Scroll position */\n scroll: ICoords;\n /** URL */\n url: string;\n}\n\nexport class History {\n private _session: string;\n private _states: IStateItem[] = [];\n private _pointer = -1;\n\n /**\n * Init with first state.\n */\n public init(url: string, ns: string): void {\n this._session = 'barba';\n const index = 0;\n\n const state: IStateItem = {\n ns,\n scroll: {\n x: window.scrollX,\n y: window.scrollY,\n },\n url,\n };\n\n this._states.push(state);\n this._pointer = index;\n\n const item: IHistoryItem = {\n from: this._session,\n index,\n states: [...this._states],\n };\n\n window.history && window.history.replaceState(item, '', url);\n }\n\n public change(\n url: string,\n trigger: Trigger,\n e?: LinkEvent | PopStateEvent\n ): Trigger {\n if (e && (e as PopStateEvent).state) {\n // If popstate, move to existing state\n // and get back/forward direction.\n const { state }: { state: IHistoryItem } = e as PopStateEvent;\n const { index } = state;\n const diff = this._pointer - index;\n\n trigger = this._getDirection(diff);\n\n // Work with previous states\n this.replace(state.states);\n this._pointer = index;\n } else {\n // Add new state\n this.add(url, trigger);\n }\n\n return trigger;\n }\n\n /**\n * Add a new state.\n */\n public add(url: string, trigger: Trigger): void {\n // If no state, it will be updated later.\n const ns = 'tmp';\n const index = this.size;\n const action = this._getAction(trigger);\n const state: IStateItem = {\n ns,\n scroll: {\n x: window.scrollX,\n y: window.scrollY,\n },\n url,\n };\n\n this._states.push(state);\n this._pointer = index;\n\n const item: IHistoryItem = {\n from: this._session,\n index,\n states: [...this._states],\n };\n\n switch (action) {\n case 'push':\n window.history && window.history.pushState(item, '', url);\n break;\n case 'replace':\n window.history && window.history.replaceState(item, '', url);\n break;\n /* istanbul ignore next */\n default:\n }\n }\n\n /**\n * Update state.\n */\n public update(data: any, i?: number): void {\n const index = i || this._pointer;\n const existing = this.get(index);\n const state: IStateItem = {\n ...existing,\n ...data,\n };\n\n this.set(index, state);\n }\n\n /**\n * Remove last state.\n */\n public remove(i?: number): void {\n if (i) {\n this._states.splice(i, 1);\n } else {\n this._states.pop();\n }\n\n this._pointer--;\n }\n\n /**\n * Delete all states.\n */\n public clear(): void {\n this._states = [];\n this._pointer = -1;\n }\n\n /**\n * Replace all states.\n */\n public replace(newStates: IStateItem[]): void {\n this._states = newStates;\n }\n\n /**\n * Get state by index.\n */\n public get(index: number) {\n return this._states[index];\n }\n\n /**\n * Set state by index.\n */\n public set(i: number, state: IStateItem) {\n return (this._states[i] = state);\n }\n\n /**\n * Get the current state.\n */\n get current(): IStateItem {\n return this._states[this._pointer];\n }\n\n /**\n * Get the last state (top of the history stack).\n */\n get state(): IStateItem {\n return this._states[this._states.length - 1];\n }\n\n /**\n * Get the previous state.\n */\n get previous(): IStateItem | null {\n return this._pointer < 1 ? null : this._states[this._pointer - 1];\n }\n\n /**\n * Get the state size.\n */\n get size(): number {\n return this._states.length;\n }\n\n /**\n * Get the history action: push vs replace\n */\n private _getAction(trigger: Trigger): HistoryAction {\n let action: HistoryAction = 'push';\n\n // Manage `data-barba-history` attribute\n // to get the right action (push vs replace).\n const el = trigger as HTMLAnchorElement;\n const attr = `${schemaAttribute.prefix}-${schemaAttribute.history}`;\n\n if (el.hasAttribute && el.hasAttribute(attr)) {\n action = el.getAttribute(attr) as HistoryAction;\n }\n\n return action;\n }\n\n /**\n * Get the direction of popstate change\n */\n private _getDirection(diff: number): Trigger {\n // Check if \"session switch\"\n if (Math.abs(diff) > 1) {\n // Ex 6-0 > 0 -> forward, 0-6 < 0 -> back\n return diff > 0 ? 'forward' : 'back';\n } else {\n if (diff === 0) {\n return 'popstate';\n } else {\n // Ex 6-5 > 0 -> back, 5-6 < 0 -> forward\n return diff > 0 ? 'back' : 'forward';\n }\n }\n }\n}\n\nconst history = new History();\n\nexport { history };\n", "/**\n * @barba/core/utils/helpers\n *
\n * ## Helpers\n *\n * - Update next page data\n *\n * @module core/utils/helpers\n * @preferred\n */\n\n/***/\n\n// Third-party\nimport ptr from 'path-to-regexp';\n// Definitions\nimport { ITransitionData } from '../defs';\n// Utils\nimport { dom } from './dom';\nimport { history } from './history';\n\n/**\n * Update `data.next`, the title and the history\n */\nexport const update = async (\n page: Promise,\n data: ITransitionData\n): Promise => {\n // If not already updated\n if (!data.next.html) {\n const html = await page;\n const { next } = data;\n\n if (html) {\n // see: https://github.com/barbajs/barba/issues/362\n // const nextDocument = dom.toDocument(html);\n const nextDocument = dom.toElement(html);\n\n next.namespace = dom.getNamespace(nextDocument);\n next.container = dom.getContainer(nextDocument);\n // see https://github.com/barbajs/barba/issues/362\n // next.html = dom.getHtml(nextDocument);\n // next.html = nextDocument.innerHTML;\n next.html = html;\n\n // Update history namespace (not available when initially set)\n history.update({ ns: next.namespace });\n\n // Update title.\n const { title } = dom.toDocument(html);\n\n document.title = title;\n }\n }\n};\n\n/**\n * Next tick\n */\nexport const nextTick = () =>\n new Promise(resolve => {\n window.requestAnimationFrame(resolve);\n // DEV: same result?\n // setTimeout(resolve, 0);\n });\n\n/**\n * Turn a route string such as `/user/:name` into a regular expression.\n *\n * Used for:\n *\n * - routes to ignore\n * - route transition resolution\n *\n * @see https://www.npmjs.com/package/path-to-regexp\n */\nconst pathToRegexp = ptr;\n\nexport { pathToRegexp };\n", "/**\n * @barba/core/utils/url\n *
\n * ## URL utils.\n *\n * - Collect and structure informations from URLs\n *\n * @module core/utils/url\n */\n\n/***/\n\n// Definitions\nimport { IGenericObject, IUrlBase } from '../defs';\n\n/**\n * Get location href.\n */\nexport const getHref = () => window.location.href;\n\n/**\n * Get location origin.\n */\nexport const getOrigin = () => window.location.origin;\n\n/**\n * Get port based on URL or location.\n */\nexport const getPort = (url: string = window.location.href) => parse(url).port;\n\n/**\n * Get path from URL.\n */\nexport const getPath = (url: string = window.location.href) => parse(url).path;\n\n/**\n * Get query object from URL.\n */\n// export const getQuery = (url: string): IGenericObject => parse(url).query;\n\n/**\n * Get hash from URL.\n */\n// export const getHash = (url: string): string => parse(url).hash;\n\n/**\n * Parse URL for path, query and hash and more.\n */\nexport const parse = (url: string): IUrlBase => {\n // Port\n let port;\n const matches = url.match(/:\\d+/);\n\n if (matches === null) {\n if (/^http/.test(url)) {\n port = 80;\n }\n\n if (/^https/.test(url)) {\n port = 443;\n }\n } else {\n const portString = matches[0].substring(1);\n\n port = parseInt(portString, 10);\n }\n\n // Path\n let path = url.replace(getOrigin(), '');\n let hash;\n let query = {};\n\n // Hash\n const hashIndex = path.indexOf('#');\n\n if (hashIndex >= 0) {\n hash = path.slice(hashIndex + 1);\n path = path.slice(0, hashIndex);\n }\n\n // Query\n const queryIndex = path.indexOf('?');\n\n if (queryIndex >= 0) {\n query = parseQuery(path.slice(queryIndex + 1));\n path = path.slice(0, queryIndex);\n }\n\n return {\n hash,\n path,\n port,\n query,\n };\n};\n\n/**\n * Parse a query string to object.\n */\nexport const parseQuery = (str: string) =>\n str.split('&').reduce((acc: IGenericObject, el: string) => {\n const [key, value] = el.split('=');\n\n acc[key] = value;\n\n return acc;\n }, {});\n\n/**\n * Clean URL, remove \"hash\" and/or \"trailing slash\".\n */\nexport const clean = (url: string = window.location.href) =>\n url.replace(/(\\/#.*|\\/|#.*)$/, '');\n", "/**\n * @barba/core/utils/request\n *
\n * ## Fetch pages for transitions.\n *\n * - Includes timeout\n * - Uses Fetch API\n * - Handles errors\n *\n * @module core/utils/request\n * @preferred\n */\n\n/***/\n\n// Definitions\nimport { RequestError } from '../defs';\n\n/**\n * Init a page request.\n * Fetch the page and returns a promise with the text content.\n */\nfunction request(\n url: string,\n ttl: number = 2e3,\n requestError: RequestError\n): Promise {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n\n xhr.onreadystatechange = () => {\n if (xhr.readyState === XMLHttpRequest.DONE) {\n if (xhr.status === 200) {\n resolve(xhr.responseText);\n } else if (xhr.status) {\n // HTTP code is not 200, reject with response.\n const res = {\n status: xhr.status,\n statusText: xhr.statusText,\n };\n requestError(url, res);\n reject(res);\n }\n }\n };\n xhr.ontimeout = () => {\n const err = new Error(`Timeout error [${ttl}]`);\n requestError(url, err);\n reject(err);\n };\n xhr.onerror = () => {\n const err = new Error(`Fetch error`);\n requestError(url, err);\n reject(err);\n };\n\n xhr.open('GET', url);\n xhr.timeout = ttl;\n xhr.setRequestHeader(\n 'Accept',\n 'text/html,application/xhtml+xml,application/xml'\n );\n xhr.setRequestHeader('x-barba', 'yes');\n xhr.send();\n });\n}\n\nexport { request };\n", "module.exports = isPromise;\n\nfunction isPromise(obj) {\n return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';\n}\n", "import isPromise from 'is-promise';\n\n// https://github.com/SBoudrias/run-async\n/* istanbul ignore next */\nexport function runAsync(\n func: (...args: any[]) => void | Promise,\n ctx: any = {}\n): (...args: any[]) => Promise {\n return (...args: any[]) => {\n let async = false;\n\n const promise = new Promise((resolve, reject) => {\n // Add async to context\n ctx.async = () => {\n async = true;\n\n return (err: any, value: any) => {\n if (err) {\n reject(err);\n } else {\n resolve(value);\n }\n };\n };\n\n const answer = func.apply(ctx, args as []);\n\n if (!async) {\n if (isPromise(answer)) {\n (answer as Promise).then(resolve, reject);\n } else {\n resolve(answer);\n }\n }\n });\n\n return promise;\n };\n}\n", "/**\n * @barba/core/modules/hooks\n *
\n * ## Hooks manager.\n *\n * - Register and trigger hooks\n *\n * Hooks can be easily registered:\n *\n * ```js\n * hooks.leave(callback, context);\n * ```\n *\n * @module core/modules/hooks\n * @preferred\n */\n\n/***/\n\n// Definitions\nimport { HookFunction, HookMethods, HooksAll } from './defs';\n// Modules\nimport { Logger } from './modules/Logger';\n// Utils\nimport { runAsync } from './utils';\n// Types\ninterface IHookInfos {\n ctx: any;\n fn: HookFunction;\n}\n\nexport class Hooks extends HookMethods {\n /**\n * Allow the use of `hooks[name](cb, ctx)`.\n */\n [key: string]: any;\n // [key in HooksAll]?: any;\n public logger: Logger = new Logger('@barba/core');\n /**\n * All available hooks.\n *\n * See [[HooksAll]]\n */\n // TODO: get hooks from defs (DRY)?\n public all: HooksAll[] = [\n 'ready',\n 'page',\n 'reset',\n 'currentAdded',\n 'currentRemoved',\n 'nextAdded',\n 'nextRemoved',\n 'beforeOnce',\n 'once',\n 'afterOnce',\n 'before',\n 'beforeLeave',\n 'leave',\n 'afterLeave',\n 'beforeEnter',\n 'enter',\n 'afterEnter',\n 'after',\n ];\n /**\n * Registered hooks.\n *\n * - Unique hook name\n * - Associated data set(s) (callback + context)\n */\n public registered: Map> = new Map();\n\n constructor() {\n super();\n this.init();\n }\n\n public init() {\n this.registered.clear();\n this.all.forEach(hook => {\n if (!this[hook]) {\n this[hook] = (fn: HookFunction, ctx?: any) => {\n if (!this.registered.has(hook)) {\n this.registered.set(hook, new Set());\n }\n const set = this.registered.get(hook);\n\n set.add({\n ctx: ctx || {},\n fn,\n });\n };\n }\n });\n }\n\n /**\n * Do hook.\n *\n * Trigger registered hooks.\n */\n public do(name: HooksAll, ...args: any): Promise {\n if (this.registered.has(name)) {\n // Let's start a chain of promises\n let chain = Promise.resolve();\n\n this.registered.get(name).forEach(hook => {\n // Chain async hooks promisified\n chain = chain.then(() => runAsync(hook.fn, hook.ctx)(...args));\n });\n\n return chain.catch(error => {\n this.logger.debug(`Hook error [${name}]`);\n this.logger.error(error);\n });\n }\n\n return Promise.resolve();\n }\n\n public clear(): void {\n this.all.forEach(hook => {\n delete this[hook];\n });\n\n this.init();\n }\n\n /**\n * Help, print available and registered hooks.\n */\n public help(): void {\n this.logger.info(`Available hooks: ${this.all.join(',')}`);\n const registered: string[] = [];\n this.registered.forEach((value, key) => registered.push(key));\n this.logger.info(`Registered hooks: ${registered.join(',')}`);\n }\n}\n\nconst hooks = new Hooks();\n\nexport { hooks };\n", "/**\n * @barba/core/modules/ignore\n *
\n * ## Manage ignore options.\n *\n * - cache\n * - prefetch\n *\n * @module core/modules/ignore\n * @preferred\n */\n\n/***/\n\n// Definitions\nimport { IgnoreOption } from '../defs';\n// Utils\nimport { pathToRegexp } from '../utils/helpers';\nimport { parse } from '../utils/url';\n\nexport class Ignore {\n private _ignoreAll: boolean;\n private _ignoreRegexes: RegExp[] = [];\n\n constructor(ignore: IgnoreOption) {\n if (typeof ignore === 'boolean') {\n this._ignoreAll = ignore;\n } else {\n const paths = Array.isArray(ignore) ? ignore : [ignore];\n\n this._ignoreRegexes = paths.map(p => pathToRegexp(p));\n }\n }\n\n public checkHref(href: string): boolean {\n if (typeof this._ignoreAll === 'boolean') {\n return this._ignoreAll;\n }\n\n const { path } = parse(href);\n\n return this._ignoreRegexes.some(regex => regex.exec(path) !== null);\n }\n}\n", "/**\n * @barba/core/modules/cache\n *
\n * ## Cache for storing URL / HTML.\n *\n * @module core/modules/cache\n * @preferred\n */\n\n/***/\n\n// Definitions\nimport { CacheAction, CacheRequest, ICacheData, IgnoreOption } from '../defs';\n// Modules\nimport { Ignore } from './Ignore';\n\nexport class Cache extends Ignore {\n private _state: Map = new Map();\n\n constructor(ignore: IgnoreOption) {\n super(ignore);\n }\n\n /**\n * Set value to cache\n */\n public set(\n href: string,\n request: CacheRequest,\n action: CacheAction\n ): ICacheData {\n this._state.set(href, {\n action,\n request,\n });\n\n return {\n action,\n request,\n };\n }\n\n /**\n * Get data from cache\n */\n public get(href: string): ICacheData {\n return this._state.get(href);\n }\n\n /**\n * Get request from cache\n */\n public getRequest(href: string): CacheRequest {\n return this._state.get(href).request;\n }\n\n /**\n * Get action from cache\n */\n public getAction(href: string): CacheAction {\n return this._state.get(href).action;\n }\n\n /**\n * Check if value exists into cache\n */\n public has(href: string): boolean {\n /* istanbul ignore else */\n if (this.checkHref(href)) {\n return false;\n }\n return this._state.has(href);\n }\n\n /**\n * Delete value from cache\n */\n public delete(href: string): boolean {\n return this._state.delete(href);\n }\n\n /**\n * Update cache value\n */\n public update(href: string, data: ICacheData): ICacheData {\n const state = {\n ...this._state.get(href),\n ...data,\n };\n this._state.set(href, state);\n\n return state;\n }\n}\n", "/**\n * @barba/core/modules/prevent\n *
\n * ## Prevent checks.\n *\n * - Gathers all the tests that allow Barba to work and play transitions\n *\n * @module core/modules/prevent\n * @preferred\n */\n\n/***/\n\n// Definitions\nimport { IgnoreOption, Link, PreventCheck } from '../defs';\n// Schemas\nimport { schemaAttribute } from '../schemas/attribute';\n// Utils\nimport { url } from '../utils';\n// Modules\nimport { Ignore } from './Ignore';\n\n/**\n * Make sure the browser supports `history.pushState`.\n */\nconst pushState: PreventCheck = () => !window.history.pushState;\n\n/**\n * Make sure there is an `el` and `href`.\n */\nconst exists: PreventCheck = ({ el, href }) => !el || !href;\n\n/**\n * If the user is pressing ctrl + click, the browser will open a new tab.\n */\nconst newTab: PreventCheck = ({ event }) =>\n (event as KeyboardEvent).which > 1 ||\n (event as KeyboardEvent).metaKey ||\n (event as KeyboardEvent).ctrlKey ||\n (event as KeyboardEvent).shiftKey ||\n (event as KeyboardEvent).altKey;\n\n/**\n * If the link has `_blank` target.\n */\nconst blank: PreventCheck = ({ el }) =>\n el.hasAttribute('target') && (el as Link).target === '_blank';\n\n/**\n * If the domain is the same (in order to avoid pushState cross origin security problem).\n * Note: SVGAElement do not have `protocol` neither `hostname` properties.\n */\nconst corsDomain: PreventCheck = ({ el }) =>\n ((el as HTMLAnchorElement).protocol !== undefined &&\n window.location.protocol !== (el as HTMLAnchorElement).protocol) ||\n ((el as HTMLAnchorElement).hostname !== undefined &&\n window.location.hostname !== (el as HTMLAnchorElement).hostname);\n\n/**\n * If the port is the same.\n * Note: SVGAElement do not have `port` property.\n */\nconst corsPort: PreventCheck = ({ el }) =>\n (el as HTMLAnchorElement).port !== undefined &&\n url.getPort() !== url.getPort((el as HTMLAnchorElement).href);\n\n/**\n * If the link has download attribute.\n */\nconst download: PreventCheck = ({ el }) =>\n el.getAttribute && typeof el.getAttribute('download') === 'string';\n\n/**\n * If the links contains [data-barba-prevent] or [data-barba-prevent=\"self\"].\n */\nconst preventSelf: PreventCheck = ({ el }) =>\n el.hasAttribute(`${schemaAttribute.prefix}-${schemaAttribute.prevent}`);\n\n/**\n * If some link ancestor contains [data-barba-prevent=\"all\"].\n */\nconst preventAll: PreventCheck = ({ el }) =>\n Boolean(\n el.closest(`[${schemaAttribute.prefix}-${schemaAttribute.prevent}=\"all\"]`)\n );\n\n/**\n * If the link is the current URL.\n *\n * > Not in the test suite.\n */\nconst sameUrl: PreventCheck = ({ href }) =>\n url.clean(href) === url.clean() && url.getPort(href) === url.getPort();\n\nexport class Prevent extends Ignore {\n public suite: string[] = [];\n public tests: Map = new Map();\n\n constructor(ignore: IgnoreOption) {\n super(ignore);\n this.init();\n }\n\n public init(): void {\n // Add defaults\n this.add('pushState', pushState);\n this.add('exists', exists);\n this.add('newTab', newTab);\n this.add('blank', blank);\n this.add('corsDomain', corsDomain);\n this.add('corsPort', corsPort);\n this.add('download', download);\n this.add('preventSelf', preventSelf);\n this.add('preventAll', preventAll);\n\n // Outside of the test suite\n this.add('sameUrl', sameUrl, false);\n }\n\n public add(name: string, check: PreventCheck, suite: boolean = true): void {\n this.tests.set(name, check);\n suite && this.suite.push(name);\n }\n\n /**\n * Run individual test\n */\n public run(name: string, el: Link, event: Event, href: string): boolean {\n return this.tests.get(name)({\n el,\n event,\n href,\n });\n }\n\n /**\n * Run test suite\n */\n public checkLink(el: Link, event: Event, href: string): boolean {\n return this.suite.some(name => this.run(name, el, event, href));\n }\n}\n", "// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error\nexport class BarbaError extends Error {\n /* istanbul ignore next */\n constructor(\n public error: Error,\n public label = 'Barba error',\n ...params: any[]\n ) {\n // Pass remaining arguments (including vendor specific ones) to parent constructor\n super(...params);\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n /* istanbul ignore else */\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, BarbaError);\n }\n\n this.name = 'BarbaError';\n }\n}\n", "/**\n * @barba/core/modules/store\n *
\n * ## Transitions store.\n *\n * - Resolve transition\n * - Manage rules\n *\n * @module core/modules/store\n * @preferred\n */\n\n/***/\n\n// Definitions\nimport {\n IRule,\n IRules,\n ITransitionData,\n ITransitionFilters,\n ITransitionOnce,\n ITransitionPage,\n RuleName,\n} from '../defs';\n\n// Modules\nimport { Logger } from './Logger';\n\nexport class Store {\n public logger: Logger = new Logger('@barba/core');\n /**\n * All registered transitions.\n */\n public all: ITransitionPage[] = [];\n /**\n * \"Page only\" registered transitions.\n */\n public page: ITransitionPage[] = [];\n /**\n * \"Once only\" registered transitions.\n */\n public once: ITransitionOnce[] = [];\n /**\n * Rules for transition resolution.\n *\n * Defaults:\n *\n * - namespace\n * - custom\n */\n private _rules: IRule[] = [\n {\n name: 'namespace',\n type: 'strings',\n },\n {\n name: 'custom',\n type: 'function',\n },\n ];\n\n /**\n * Init store.\n */\n constructor(transitions: ITransitionPage[] = []) {\n /* istanbul ignore else */\n if (transitions) {\n // TODO: add check for valid transitions? criteria? (once || enter && leave)\n this.all = this.all.concat(transitions);\n }\n this.update();\n }\n\n /**\n * Add rule or transition.\n */\n public add(type: 'rule' | 'transition', data: any): void {\n switch (type) {\n case 'rule':\n // TODO: check for valid rule\n this._rules.splice(data.position || 0, 0, data.value);\n break;\n case 'transition':\n default:\n // TODO: check for valid transition\n this.all.push(data);\n break;\n }\n\n this.update();\n }\n\n /**\n * Resolve transition.\n */\n public resolve(\n data: ITransitionData,\n filters: ITransitionFilters = {}\n ): ITransitionOnce | ITransitionPage {\n // Filter on \"once\"\n let transitions = filters.once ? this.once : this.page;\n\n // Filter on \"self\"\n if (filters.self) {\n transitions = transitions.filter(t => t.name && t.name === 'self');\n } else {\n transitions = transitions.filter(t => !t.name || t.name !== 'self');\n }\n\n // All matching transition infos\n const matching = new Map();\n\n // Active = first of valid transitions\n // sorted by directions (from/to, from || to, \u2026)\n const active = transitions.find(t => {\n let valid = true;\n const match = {};\n\n if (filters.self && t.name === 'self') {\n return true;\n }\n\n // Check rules\n this._rules.reverse().forEach(rule => {\n if (valid) {\n valid = this._check(t, rule, data, match);\n // From/to check\n if (t.from && t.to) {\n valid =\n this._check(t, rule, data, match, 'from') &&\n this._check(t, rule, data, match, 'to');\n }\n if (t.from && !t.to) {\n valid = this._check(t, rule, data, match, 'from');\n }\n if (!t.from && t.to) {\n valid = this._check(t, rule, data, match, 'to');\n }\n }\n });\n\n matching.set(t, match);\n\n return valid;\n });\n\n const activeMatch = matching.get(active);\n const transitionType = [];\n if (filters.once) {\n transitionType.push('once');\n } else {\n transitionType.push('page');\n }\n if (filters.self) {\n transitionType.push('self');\n }\n\n if (activeMatch) {\n // Log resolved transition\n const infos: any[] = [active];\n // Log if matching criteria\n Object.keys(activeMatch).length > 0 && infos.push(activeMatch);\n\n this.logger.info(\n `Transition found [${transitionType.join(',')}]`,\n ...infos\n );\n } else {\n this.logger.info(`No transition found [${transitionType.join(',')}]`);\n }\n\n return active;\n }\n\n /**\n * ### Update store.\n *\n * - Reorder transition by priorities\n * - Get wait indicator\n * - Get once transitions\n */\n public update(): void {\n // Reorder by priorities\n this.all = this.all\n .map(t => this._addPriority(t))\n .sort((a, b) => a.priority - b.priority)\n .reverse()\n .map(t => {\n delete t.priority;\n\n return t;\n });\n this.page = this.all.filter(\n t => t.leave !== undefined || t.enter !== undefined\n ) as ITransitionPage[];\n this.once = this.all.filter(t => t.once !== undefined) as ITransitionOnce[];\n }\n\n /**\n * ### Check if transition apply.\n *\n * Based on rule, page data and optional direction:\n *\n * 1. transition has no rule \"property\":\n * - always returns true\n * 2. transition has rule \"property\":\n * - \"strings\" should be present on both side (transition + page) and match\n * - \"function\" should return true\n */\n private _check(\n transition: ITransitionPage,\n rule: IRule,\n data: ITransitionData,\n match: any,\n direction?: 'from' | 'to'\n ): boolean {\n let isValid = true;\n let hasMatch = false;\n const t = transition;\n const { name, type } = rule;\n const strRule = name as IRules['strings'];\n const objRule = name as IRules['object'];\n const fnName = name as IRules['function'];\n const base = direction ? t[direction] : t; // = t || t.from || t.to\n const page = direction === 'to' ? data.next : data.current; // = current || next\n const exist = direction ? base && base[name] : base[name];\n\n // If transition rule exists\n if (exist) {\n switch (type) {\n case 'strings':\n default: {\n // Array support\n const names: string[] = Array.isArray(base[strRule])\n ? (base[strRule] as string[])\n : [base[strRule] as string];\n\n // For matching, prop should be present on both sides and match\n if (page[strRule] && names.indexOf(page[strRule]) !== -1) {\n hasMatch = true;\n }\n // If transition prop is different from current, not valid\n if (names.indexOf(page[strRule]) === -1) {\n isValid = false;\n }\n break;\n }\n\n case 'object': {\n // Array support\n const names: string[] = Array.isArray(base[objRule])\n ? (base[objRule] as string[])\n : [base[objRule] as string];\n\n // For matching, prop should be present on both sides and match\n if (page[objRule]) {\n if (\n page[objRule].name &&\n names.indexOf(page[objRule].name) !== -1\n ) {\n hasMatch = true;\n }\n // If transition prop is different from current, not valid\n if (names.indexOf(page[objRule].name) === -1) {\n isValid = false;\n }\n } else {\n isValid = false;\n }\n break;\n }\n\n case 'function':\n if (base[fnName](data)) {\n hasMatch = true;\n } else {\n isValid = false;\n }\n break;\n }\n\n if (hasMatch) {\n if (direction) {\n match[direction] = match[direction] || {};\n match[direction][name] = t[direction][name];\n } else {\n match[name] = t[name];\n }\n }\n }\n\n return isValid;\n }\n\n /**\n * ### Calculate transition priority.\n *\n * Based on:\n *\n * - rule \"position\" (index) give tens, hundreds, thousands, \u2026\n * - from/to properties give units (0, 1 or 2)\n */\n private _calculatePriority(\n t: ITransitionPage,\n ruleName: RuleName,\n ruleIndex: number\n ): number {\n let priority = 0;\n\n if (\n t[ruleName] ||\n (t.from && t.from[ruleName]) ||\n (t.to && t.to[ruleName])\n ) {\n priority += Math.pow(10, ruleIndex);\n\n if (t.from && t.from[ruleName]) {\n priority += 1;\n }\n if (t.to && t.to[ruleName]) {\n priority += 2;\n }\n }\n\n return priority;\n }\n\n private _addPriority(t: ITransitionPage): ITransitionPage {\n t.priority = 0;\n let priority = 0;\n\n this._rules.forEach((rule, i) => {\n const { name } = rule;\n const index = i + 1;\n\n priority += this._calculatePriority(t, name, index);\n });\n\n t.priority = priority;\n\n return t;\n }\n}\n", "/**\n * @barba/core/modules/transitions\n *
\n * ## Transitions manager.\n *\n * - Handle hooks and transition lifecycle\n *\n * @module core/modules/transitions\n * @preferred\n */\n\n/***/\n\n// Definitions\nimport {\n HooksTransition,\n HooksTransitionMap,\n ITransitionData,\n ITransitionFilters,\n ITransitionOnce,\n ITransitionPage,\n Wrapper,\n} from '../defs';\n// Hooks\nimport { hooks } from '../hooks';\n// Utils\nimport { dom, helpers, runAsync } from '../utils';\n// Modules\nimport { BarbaError } from './Error';\nimport { Logger } from './Logger';\nimport { Store } from './Store';\n\nexport class Transitions {\n public logger: Logger = new Logger('@barba/core');\n public store: Store;\n private _running: boolean = false;\n\n constructor(transitions: ITransitionPage[] = []) {\n this.store = new Store(transitions);\n }\n\n /**\n * Get resolved transition\n *\n * - based on data\n */\n public get(\n data: ITransitionData,\n filters?: ITransitionFilters\n ): ITransitionOnce | ITransitionPage {\n return this.store.resolve(data, filters);\n }\n\n /**\n * Animation running status.\n */\n get isRunning(): boolean {\n return this._running;\n }\n set isRunning(status: boolean) {\n this._running = status;\n }\n\n /**\n * Check for registered once transition(s).\n */\n get hasOnce(): boolean {\n return this.store.once.length > 0;\n }\n\n /**\n * Check for registered self transition.\n */\n get hasSelf(): boolean {\n return this.store.all.some(t => t.name === 'self');\n }\n\n /**\n * ### Wait indicator.\n *\n * Tells Barba to get next page data
\n * before starting the resolution
\n * because some registered transitions need
\n * next page data to be resolved (eg: `sync: true`, `to: { namespace }`, \u2026)\n */\n get shouldWait(): boolean {\n return this.store.all.some(t => (t.to && !t.to.route) || t.sync);\n }\n\n /**\n * ### Do \"once\" transition.\n *\n * Hooks: see [[HooksOnce]].\n */\n public async doOnce({\n data,\n transition,\n }: {\n data: ITransitionData;\n transition: ITransitionOnce;\n }) {\n const t = transition || {};\n this._running = true;\n\n try {\n await this._doAsyncHook('beforeOnce', data, t);\n await this.once(data, t);\n await this._doAsyncHook('afterOnce', data, t);\n } catch (error) {\n this._running = false;\n\n this.logger.debug('Transition error [before/after/once]');\n this.logger.error(error);\n }\n\n this._running = false;\n }\n\n /**\n * ### Do \"page\" transition.\n *\n * Hooks: see [[HooksPage]].\n *\n * `sync: false` (default) order:\n *\n * 1. before\n * 2. beforeLeave\n * 3. leave\n * 4. afterLeave\n * 5. beforeEnter\n * 6. enter\n * 7. afterEnter\n * 8. after\n *\n * `sync: true` order:\n *\n * 1. before\n * 2. beforeLeave\n * 3. beforeEnter\n * 4. leave & enter\n * 5. afterLeave\n * 6. afterEnter\n * 7. after\n */\n public async doPage({\n data,\n transition,\n page,\n wrapper,\n }: {\n data: ITransitionData;\n transition: ITransitionPage;\n page: Promise;\n wrapper: Wrapper;\n }) {\n const t = transition || {};\n const sync = t.sync === true || false;\n\n this._running = true;\n\n try {\n // Check sync mode, wait for next content\n if (sync) {\n await helpers.update(page, data);\n }\n\n await this._doAsyncHook('before', data, t);\n\n if (sync) {\n try {\n await this.add(data, wrapper);\n // Before actions\n await this._doAsyncHook('beforeLeave', data, t);\n await this._doAsyncHook('beforeEnter', data, t);\n\n // Actions\n await Promise.all([this.leave(data, t), this.enter(data, t)]);\n\n // After actions\n await this._doAsyncHook('afterLeave', data, t);\n await this._doAsyncHook('afterEnter', data, t);\n } catch (error) {\n // this.logger.debug('Transition error [sync]');\n // this.logger.error(error);\n if (this._isTransitionError(error)) {\n throw new BarbaError(error, 'Transition error [sync]');\n }\n }\n } else {\n let leaveResult: any = false;\n\n try {\n // Leave\n await this._doAsyncHook('beforeLeave', data, t);\n\n leaveResult = await Promise.all([\n this.leave(data, t),\n helpers.update(page, data),\n ]).then(values => values[0]);\n\n await this._doAsyncHook('afterLeave', data, t);\n\n // TODO: check here \"valid\" page result\n // before going further\n } catch (error) {\n // this.logger.debug('Transition error [before/after/leave]');\n // this.logger.error(error);\n if (this._isTransitionError(error)) {\n throw new BarbaError(\n error,\n 'Transition error [before/after/leave]'\n );\n }\n }\n\n try {\n // Enter\n /* istanbul ignore else */\n if (leaveResult !== false) {\n await this.add(data, wrapper);\n\n await this._doAsyncHook('beforeEnter', data, t);\n await this.enter(data, t, leaveResult);\n await this._doAsyncHook('afterEnter', data, t);\n }\n } catch (error) {\n // this.logger.debug('Transition error [before/after/enter]');\n // this.logger.error(error);\n if (this._isTransitionError(error)) {\n throw new BarbaError(\n error,\n 'Transition error [before/after/enter]'\n );\n }\n }\n }\n\n // Remove current contaienr\n await this.remove(data);\n\n await this._doAsyncHook('after', data, t);\n } catch (error) {\n this._running = false;\n\n // If \"custom/specific\" barba error.\n /* istanbul ignore else */\n if (error.name && error.name === 'BarbaError') {\n this.logger.debug(error.label);\n this.logger.error(error.error);\n\n throw error;\n }\n\n this.logger.debug('Transition error [page]');\n this.logger.error(error);\n\n throw error;\n }\n\n this._running = false;\n }\n\n /**\n * Once hook + async \"once\" transition.\n */\n public async once(data: ITransitionData, t: ITransitionOnce): Promise {\n await hooks.do('once', data, t);\n\n return t.once ? runAsync(t.once, t)(data) : Promise.resolve();\n }\n\n /**\n * Leave hook + async \"leave\" transition.\n */\n public async leave(data: ITransitionData, t: ITransitionPage): Promise {\n await hooks.do('leave', data, t);\n\n return t.leave ? runAsync(t.leave, t)(data) : Promise.resolve();\n }\n\n /**\n * Enter hook + async \"enter\" transition.\n */\n public async enter(\n data: ITransitionData,\n t: ITransitionPage,\n leaveResult?: any\n ): Promise {\n await hooks.do('enter', data, t);\n\n return t.enter\n ? runAsync(t.enter, t)(data, leaveResult)\n : Promise.resolve();\n }\n\n /**\n * Add next container.\n */\n public async add(data: ITransitionData, wrapper: Wrapper): Promise {\n dom.addContainer(data.next.container, wrapper);\n hooks.do('nextAdded', data);\n }\n\n /**\n * Remove current container.\n */\n public async remove(data: ITransitionData): Promise {\n dom.removeContainer(data.current.container);\n hooks.do('currentRemoved', data);\n }\n\n private _isTransitionError(error: any) {\n if (error.message) {\n // Errors from request\n return !/Timeout error|Fetch error/.test(error.message);\n }\n\n if (error.status) {\n // Errors from request\n return false;\n }\n\n return true;\n }\n\n /**\n * Do hooks + async transition methods.\n */\n private async _doAsyncHook(\n hook: HooksTransition,\n data: ITransitionData,\n t: HooksTransitionMap\n ): Promise {\n await hooks.do(hook, data, t);\n\n return t[hook] ? runAsync(t[hook], t)(data) : Promise.resolve();\n }\n}\n", "/**\n * @barba/core/modules/views\n *
\n * ## Views manager.\n *\n * @module core/modules/views\n * @preferred\n */\n\n/***/\n\n// Definitions\nimport { HooksView, IView, IViewData } from '../defs';\n// Hooks\nimport { hooks } from '../hooks';\n// Utils\nimport { runAsync } from '../utils';\n// Types\ntype Hook = (data: IViewData) => Promise;\n\nexport class Views {\n /**\n * Available hook names for views.\n */\n public names: HooksView[] = [\n 'beforeLeave',\n 'afterLeave',\n 'beforeEnter',\n 'afterEnter',\n ];\n /**\n * Registered views by namespace.\n */\n public byNamespace: Map = new Map();\n\n /**\n * Init views.\n */\n constructor(views: IView[]) {\n if (views.length === 0) {\n return;\n }\n\n // TODO: add check\n // for valid views? criteria? (namespace property, string ?)\n // or duplicate\n views.forEach(view => {\n this.byNamespace.set(view.namespace, view);\n });\n\n this.names.forEach(name => {\n hooks[name](this._createHook(name));\n });\n }\n\n /**\n * Create the hook method.\n *\n * - get view based on namespace\n * - execute callback with transition data\n */\n private _createHook(name: HooksView): Hook {\n return data => {\n const { namespace } = name.match(/enter/i) ? data.next : data.current;\n const view = this.byNamespace.get(namespace);\n\n // TODO: manage self\u2026\n // if (view && data.trigger !== 'self') {\n if (view && view[name]) {\n return runAsync(view[name], view)(data);\n }\n\n return Promise.resolve();\n };\n }\n}\n", "// Element.prototype.matches polyfill\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill\nif (!Element.prototype.matches) {\n Element.prototype.matches =\n (Element as any).prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n}\n\n// Element.prototype.closest polyfill\n// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill\nif (!Element.prototype.closest) {\n Element.prototype.closest = function closest(s: string) {\n let el = this;\n\n do {\n if (el.matches(s)) {\n return el;\n }\n\n el = (el.parentElement || el.parentNode) as Element;\n } while (el !== null && el.nodeType === 1);\n\n return null;\n };\n}\n", "/**\n * @module core/schemas\n */\n\n// Definitions\nimport { ISchemaPage } from '../defs';\n\n/**\n * See [[ISchemaPage]]\n */\nexport const schemaPage: ISchemaPage = {\n container: null,\n html: '',\n namespace: '',\n url: {\n hash: '',\n href: '',\n path: '',\n port: null,\n query: {},\n },\n};\n", "/**\n * @barba/core\n *
\n * ## Barba core object\n *\n * Main methods:\n *\n * - `.init()` for initialization with options\n * - `.use()` for plugins\n *\n * @module core\n */\n\n/***/\n\nimport { version } from '../package.json';\n// Definitions\nimport {\n IBarbaOptions,\n IBarbaPlugin,\n IgnoreOption,\n ISchemaPage,\n ITransitionData,\n ITransitionOnce,\n ITransitionPage,\n Link,\n LinkEvent,\n RequestCustomError,\n RequestErrorOrResponse,\n SchemaAttributeValues,\n Trigger,\n Wrapper,\n} from './defs';\n// Hooks\nimport { hooks } from './hooks';\n// Modules\nimport { Cache } from './modules/Cache';\nimport { Logger } from './modules/Logger';\nimport { Prevent } from './modules/Prevent';\nimport { Transitions } from './modules/Transitions';\nimport { Views } from './modules/Views';\n// Polyfills\nimport './polyfills';\n// Schemas\nimport { schemaAttribute } from './schemas/attribute';\nimport { schemaPage } from './schemas/page';\n// Utils\nimport { dom, helpers, history, request, url } from './utils';\n\nexport class Core {\n /**\n * Version.\n */\n public version: string = version;\n /**\n * Schemas.\n */\n public schemaPage: ISchemaPage = schemaPage;\n /**\n * Logger class, allows plugins to create Logger.\n */\n public Logger: typeof Logger = Logger;\n /**\n * Barba logger.\n */\n public logger: Logger = new Logger('@barba/core');\n /**\n * Plugins.\n */\n public plugins: Array> = [];\n /**\n * Options\n */\n public timeout: number;\n public cacheIgnore: IgnoreOption;\n public prefetchIgnore: IgnoreOption;\n public preventRunning: boolean;\n /**\n * Hooks\n */\n public hooks = hooks;\n /**\n * Modules.\n */\n // public history: History;\n public cache: Cache;\n public prevent: Prevent;\n public transitions: Transitions;\n public views: Views;\n /**\n * Utils.\n */\n public dom = dom;\n public helpers = helpers;\n public history = history;\n public request = request;\n public url = url;\n\n private _data: ITransitionData;\n private _requestCustomError: RequestCustomError;\n private _wrapper: Wrapper;\n\n /**\n * ### Init plugin with options.\n *\n * See [[IBarbaPlugin]] for more details.\n */\n public use(plugin: IBarbaPlugin, options?: T): void {\n const installedPlugins = this.plugins;\n\n // Plugin installation\n if (installedPlugins.indexOf(plugin) > -1) {\n this.logger.warn(`Plugin [${plugin.name}] already installed.`);\n\n return;\n }\n\n if (typeof plugin.install !== 'function') {\n this.logger.warn(`Plugin [${plugin.name}] has no \"install\" method.`);\n\n return;\n }\n\n plugin.install(this, options);\n installedPlugins.push(plugin);\n }\n\n /**\n * ### Init barba with options.\n *\n * See [[IBarbaOptions]] for more details.\n *\n * Default values are:\n *\n * - transitions: `[]`\n * - views: `[]`\n * - schema: [[SchemaAttribute]]\n * - timeout: `2e3`\n * - cacheIgnore: `false`\n * - prefetchIgnore: `false`\n * - preventRunning: `false`\n * - prevent: `null`,\n * - debug: `false`\n * - logLevel: `'debug'`\n */\n public init(\n /** @ignore */ {\n transitions = [],\n views = [],\n schema = schemaAttribute,\n requestError,\n timeout = 2e3,\n cacheIgnore = false,\n prefetchIgnore = false,\n /* istanbul ignore next */\n preventRunning = false,\n prevent: preventCustom = null,\n debug = false,\n logLevel = 'off',\n }: IBarbaOptions = {}\n ) {\n // 0. Set logger level and print version\n Logger.setLevel(debug === true ? 'debug' : logLevel);\n this.logger.info(this.version);\n\n // 1. Manage options\n Object.keys(schema).forEach(k => {\n const attr = k as SchemaAttributeValues;\n\n /* istanbul ignore else */\n if (schemaAttribute[attr]) {\n schemaAttribute[attr] = schema[attr];\n }\n });\n this._requestCustomError = requestError;\n this.timeout = timeout;\n this.cacheIgnore = cacheIgnore;\n this.prefetchIgnore = prefetchIgnore;\n this.preventRunning = preventRunning;\n\n // 2. Get and check wrapper\n this._wrapper = this.dom.getWrapper();\n if (!this._wrapper) {\n throw new Error('[@barba/core] No Barba wrapper found');\n }\n this._wrapper.setAttribute('aria-live', 'polite'); // A11y\n\n // 3. Init pages (get \"current\" data)\n this._resetData();\n\n const { current } = this.data;\n\n if (!current.container) {\n throw new Error('[@barba/core] No Barba container found');\n }\n\n // 4. Init other modules\n this.cache = new Cache(cacheIgnore);\n this.prevent = new Prevent(prefetchIgnore);\n this.transitions = new Transitions(transitions);\n this.views = new Views(views);\n\n // Add prevent custom\n if (preventCustom !== null) {\n if (typeof preventCustom !== 'function') {\n throw new Error('[@barba/core] Prevent should be a function');\n }\n\n this.prevent.add('preventCustom', preventCustom);\n }\n\n // 5. Use \"current\" data\n // Init history\n this.history.init(current.url.href, current.namespace);\n // Add to cache\n // TODO: do not cache renderer HTML, only request results\u2026\n // this.cache.set(current.url.href, Promise.resolve(current.html), 'init');\n\n // 6. Bind context\n this._onLinkEnter = this._onLinkEnter.bind(this);\n this._onLinkClick = this._onLinkClick.bind(this);\n this._onStateChange = this._onStateChange.bind(this);\n this._bind();\n\n // 7. Init plugins\n this.plugins.forEach(plugin => plugin.init());\n\n // 8. Barba ready\n // Set next + trigger for once and `beforeEnter`/`afterEnter` view on page load.\n const onceData = this.data;\n\n onceData.trigger = 'barba';\n onceData.next = onceData.current;\n onceData.current = { ...this.schemaPage };\n this.hooks.do('ready', onceData);\n\n // 9. Finally, do once\u2026\n this.once(onceData);\n\n // Clean data for first barba transition\u2026\n this._resetData();\n }\n\n public destroy(): void {\n this._resetData();\n this._unbind();\n this.history.clear();\n this.hooks.clear();\n this.plugins = [];\n }\n\n get data(): ITransitionData {\n return this._data;\n }\n\n get wrapper(): HTMLElement {\n return this._wrapper;\n }\n\n /**\n * ### Force a page change without Barba transition.\n */\n public force(href: string): void {\n // DEV\n // Can be used waiting animation cancellation management\u2026\n window.location.assign(href);\n }\n\n /**\n * ### Go for a Barba transition.\n *\n * Manage \"self page\" href:\n *\n * - if same url and no self transition, keep default behavior\n * - link: reload the page\n * - anchor: scroll to\n * - if same url with self transition, use it\n * - then start a page transition.\n */\n public go(\n href: string,\n trigger: Trigger = 'barba',\n e?: LinkEvent | PopStateEvent\n ): Promise {\n // If animation running, force reload\n if (this.transitions.isRunning) {\n this.force(href);\n\n return;\n }\n\n let self = false;\n\n // Check prevent sameURL against current history\n // + state check\n // + update trigger with direction\n if (trigger === 'popstate') {\n self =\n this.history.current &&\n this.url.getPath(this.history.current.url) === this.url.getPath(href);\n } else {\n self = this.prevent.run('sameUrl', null, null, href);\n }\n\n if (self && !this.transitions.hasSelf) {\n return;\n }\n\n trigger = this.history.change(href, trigger, e);\n\n if (e) {\n e.stopPropagation();\n e.preventDefault();\n }\n\n return this.page(href, trigger, self);\n }\n\n /**\n * ### Start an \"once\" transition.\n *\n * If some registered \"once\" transition,\n * get the \"resolved\" transition from the store and start it.\n */\n public async once(readyData: ITransitionData): Promise {\n await this.hooks.do('beforeEnter', readyData);\n\n // Check if once transition\n if (this.transitions.hasOnce) {\n const transition = this.transitions.get(readyData, {\n once: true,\n }) as ITransitionOnce;\n\n await this.transitions.doOnce({ transition, data: readyData });\n }\n\n await this.hooks.do('afterEnter', readyData);\n }\n\n /**\n * ### Start a \"page\" transition.\n *\n * 1. If no running transition, updates data with full URL properties and trigger.\n * 2. Get page from cache or init request.\n * 3. Wait if some transitions need \"next\" data (`sync: true`, `to: \u2026`).\n * 4. Manage the history, depending on trigger.\n * 5. Get \"data\" and trigger \"go\" hook.\n * 6. Get the \"resolved\" transition from the store and start it.\n * 7. Update title and reset data (current, next = undefined).\n *\n * > If \"self\", use the \"self\" transition\n */\n public async page(\n href: string,\n trigger: Trigger,\n self: boolean\n ): Promise {\n this.data.next.url = {\n href,\n ...this.url.parse(href),\n };\n this.data.trigger = trigger;\n\n const page = this.cache.has(href)\n ? this.cache.update(href, { action: 'click' }).request\n : this.cache.set(\n href,\n this.request(\n href,\n this.timeout,\n this.onRequestError.bind(this, trigger)\n ),\n 'click'\n ).request;\n\n // Need to wait before getting the right transition\n if (this.transitions.shouldWait) {\n await helpers.update(page, this.data);\n }\n\n const data = this.data;\n\n // Hook: between trigger and transition\n // Can be used to resolve \"route\"\u2026\n await this.hooks.do('page', data);\n\n try {\n const transition = this.transitions.get(data, {\n once: false,\n self,\n }) as ITransitionPage;\n\n await this.transitions.doPage({\n data,\n page,\n transition,\n wrapper: this._wrapper,\n });\n\n this._resetData();\n } catch (error) {\n // Something went wrong (rejected promise, error, 404, 505, other\u2026)\n // TODO: manage / use cases for cancellation\n // this.logger.debug('Transition cancelled');\n\n // If transition error and no debug mode, force reload page.\n /* istanbul ignore else */\n if (Logger.getLevel() === 0) {\n this.force(data.current.url.href);\n }\n }\n }\n\n /**\n * When a request error occurs.\n *\n * Allow the user to manage request error. (E.g: 404)\n */\n public onRequestError(trigger: Trigger, ...args: any): boolean {\n // Cancel transition status\n this.transitions.isRunning = false;\n\n const [href, response]: [string, RequestErrorOrResponse] = args;\n const action = this.cache.getAction(href);\n this.cache.delete(href);\n\n // Custom requestError returning false will return here.\n if (\n this._requestCustomError &&\n this._requestCustomError(trigger, action, href, response) === false\n ) {\n return false;\n }\n\n // Force page change\n if (action === 'click') {\n this.force(href);\n }\n return false;\n }\n\n /**\n * Programmatically prefetch\n */\n public prefetch(href: string) {\n // Already in cache\n /* istanbul ignore next */\n if (this.cache.has(href)) {\n return;\n }\n\n this.cache.set(\n href,\n this.request(\n href,\n this.timeout,\n this.onRequestError.bind(this, 'barba')\n ).catch((error: RequestErrorOrResponse) => {\n this.logger.error(error);\n }),\n 'prefetch'\n );\n }\n\n /**\n * Bind event listeners.\n */\n private _bind(): void {\n /* istanbul ignore else */\n if (this.prefetchIgnore !== true) {\n document.addEventListener('mouseover', this._onLinkEnter);\n document.addEventListener('touchstart', this._onLinkEnter);\n }\n document.addEventListener('click', this._onLinkClick);\n window.addEventListener('popstate', this._onStateChange);\n }\n\n /**\n * Bind event listeners.\n */\n private _unbind(): void {\n /* istanbul ignore else */\n if (this.prefetchIgnore !== true) {\n document.removeEventListener('mouseover', this._onLinkEnter);\n document.removeEventListener('touchstart', this._onLinkEnter);\n }\n document.removeEventListener('click', this._onLinkClick);\n window.removeEventListener('popstate', this._onStateChange);\n }\n\n /**\n * When a element is entered.\n *\n * Get valid link element.\n * Cache URL if needed.\n */\n private _onLinkEnter(e: LinkEvent): void {\n const link = this._getLinkElement(e);\n\n if (!link) {\n return;\n }\n\n const href = this.dom.getHref(link);\n\n if (this.prevent.checkHref(href)) {\n return;\n }\n\n // Already in cache\n if (this.cache.has(href)) {\n return;\n }\n\n this.cache.set(\n href,\n this.request(\n href,\n this.timeout,\n this.onRequestError.bind(this, link)\n ).catch((error: RequestErrorOrResponse) => {\n this.logger.error(error);\n }),\n 'enter'\n );\n }\n\n /**\n * When an element is clicked.\n *\n * Get valid link element.\n * Prevent same URL.\n * Go for a Barba transition.\n */\n private _onLinkClick(e: LinkEvent): void {\n // This use `prevent.checkLink` under the hood to get eligible link.\n const link = this._getLinkElement(e);\n\n if (!link) {\n return;\n }\n\n if (this.transitions.isRunning && this.preventRunning) {\n e.preventDefault();\n e.stopPropagation();\n\n return;\n }\n\n this.go(this.dom.getHref(link), link, e);\n }\n\n /**\n * When History state changes.\n *\n * Get \"href\" from URL\n * Go for a Barba transition.\n */\n private _onStateChange(e: PopStateEvent): void {\n this.go(this.url.getHref(), 'popstate', e);\n }\n\n /**\n * Get a valid link ancestor.\n *\n * Check for a \"href\" attribute.\n * Then check if eligible for Barba.\n */\n private _getLinkElement(e: LinkEvent): Link {\n let el = e.target as Link;\n\n while (el && !this.dom.getHref(el)) {\n el = (el as HTMLElement).parentNode as Link;\n }\n\n // Check prevent\n if (!el || this.prevent.checkLink(el, e, this.dom.getHref(el))) {\n return;\n }\n\n return el;\n }\n\n /**\n * Reset pages data.\n *\n * Set \"current\" and unset \"next\".\n */\n private _resetData() {\n const href = this.url.getHref();\n const current = {\n container: this.dom.getContainer(),\n html: this.dom.getHtml(),\n namespace: this.dom.getNamespace(),\n url: {\n href,\n ...this.url.parse(href),\n },\n };\n\n this._data = {\n current,\n next: { ...this.schemaPage },\n trigger: undefined,\n };\n\n this.hooks.do('reset', this.data);\n }\n}\n\nconst core = new Core();\n\nexport default core;\n", "!function(root, factory) {\n \"function\" == typeof define && define.amd ? // AMD. Register as an anonymous module unless amdModuleId is set\n define([], function() {\n return root.svg4everybody = factory();\n }) : \"object\" == typeof module && module.exports ? // Node. Does not work with strict CommonJS, but\n // only CommonJS-like environments that support module.exports,\n // like Node.\n module.exports = factory() : root.svg4everybody = factory();\n}(this, function() {\n /*! svg4everybody v2.1.9 | github.com/jonathantneal/svg4everybody */\n function embed(parent, svg, target) {\n // if the target exists\n if (target) {\n // create a document fragment to hold the contents of the target\n var fragment = document.createDocumentFragment(), viewBox = !svg.hasAttribute(\"viewBox\") && target.getAttribute(\"viewBox\");\n // conditionally set the viewBox on the svg\n viewBox && svg.setAttribute(\"viewBox\", viewBox);\n // copy the contents of the clone into the fragment\n for (// clone the target\n var clone = target.cloneNode(!0); clone.childNodes.length; ) {\n fragment.appendChild(clone.firstChild);\n }\n // append the fragment into the svg\n parent.appendChild(fragment);\n }\n }\n function loadreadystatechange(xhr) {\n // listen to changes in the request\n xhr.onreadystatechange = function() {\n // if the request is ready\n if (4 === xhr.readyState) {\n // get the cached html document\n var cachedDocument = xhr._cachedDocument;\n // ensure the cached html document based on the xhr response\n cachedDocument || (cachedDocument = xhr._cachedDocument = document.implementation.createHTMLDocument(\"\"), \n cachedDocument.body.innerHTML = xhr.responseText, xhr._cachedTarget = {}), // clear the xhr embeds list and embed each item\n xhr._embeds.splice(0).map(function(item) {\n // get the cached target\n var target = xhr._cachedTarget[item.id];\n // ensure the cached target\n target || (target = xhr._cachedTarget[item.id] = cachedDocument.getElementById(item.id)), \n // embed the target into the svg\n embed(item.parent, item.svg, target);\n });\n }\n }, // test the ready state change immediately\n xhr.onreadystatechange();\n }\n function svg4everybody(rawopts) {\n function oninterval() {\n // while the index exists in the live