diff --git a/package-lock.json b/package-lock.json index ea07ccf..3e77ffe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1448,6 +1448,11 @@ "integrity": "sha1-l6ERlkmyEa0zaR2fn0hqjsn74KM=", "dev": true }, + "alpine-magic-helpers": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/alpine-magic-helpers/-/alpine-magic-helpers-0.5.1.tgz", + "integrity": "sha512-zj1o/Er5WLCQbaDjQCsobrfPaxgHp6Mf2ZDXce7B4THrPdKXwOrIB4zHykjXA6qCEljyh4js2fA6QWLXp3w/nw==" + }, "alpinejs": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-2.8.0.tgz", diff --git a/package.json b/package.json index f7bdc3d..372e8a2 100644 --- a/package.json +++ b/package.json @@ -21,5 +21,8 @@ "resolve-url-loader": "^3.1.0", "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.1", "vue-template-compiler": "^2.6.12" + }, + "dependencies": { + "alpine-magic-helpers": "^0.5.1" } } diff --git a/public/js/app.js b/public/js/app.js index 709fb7a..71a2a5c 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -86,6 +86,2442 @@ /************************************************************************/ /******/ ({ +/***/ "./node_modules/alpine-magic-helpers/dist/index.js": +/*!*********************************************************!*\ + !*** ./node_modules/alpine-magic-helpers/dist/index.js ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(process) {(function (global, factory) { + true ? module.exports = factory() : + undefined; +}(this, (function () { 'use strict'; + + var checkForAlpine = function checkForAlpine() { + if (!window.Alpine) { + throw new Error('[Magic Helpers] Alpine is required for the magic helpers to function correctly.'); + } + + if (!window.Alpine.version || !isValidVersion('2.5.0', window.Alpine.version)) { + throw new Error('Invalid Alpine version. Please use Alpine version 2.5.0 or above'); + } + }; + var syncWithObservedComponent = function syncWithObservedComponent(data, observedComponent, callback) { + if (!observedComponent.getAttribute('x-bind:data-last-refresh')) { + observedComponent.setAttribute('x-bind:data-last-refresh', 'Date.now()'); + } + + var handler = function handler(scope) { + if (scope === void 0) { + scope = null; + } + + return { + get: function get(target, key) { + if (target[key] !== null && typeof target[key] === 'object') { + var path = scope ? scope + "." + key : key; + return new Proxy(target[key], handler(path)); + } + + return target[key]; + }, + set: function set(_target, key, value) { + if (!observedComponent.__x) { + throw new Error('Error communicating with observed component'); + } + + var path = scope ? scope + "." + key : key; + callback.call(observedComponent, observedComponent.__x.$data, path, value); + return true; + } + }; + }; + + return new Proxy(data, handler()); + }; + var updateOnMutation = function updateOnMutation(componentBeingObserved, callback) { + if (!componentBeingObserved.getAttribute('x-bind:data-last-refresh')) { + componentBeingObserved.setAttribute('x-bind:data-last-refresh', 'Date.now()'); + } + + var observer = new MutationObserver(function (mutations) { + for (var i = 0; i < mutations.length; i++) { + var mutatedComponent = mutations[i].target.closest('[x-data]'); + if (mutatedComponent && !mutatedComponent.isSameNode(componentBeingObserved)) continue; + callback(); + return; + } + }); + observer.observe(componentBeingObserved, { + attributes: true, + childList: true, + subtree: true + }); + }; // Borrowed from https://stackoverflow.com/a/54733755/1437789 + + var objectSetDeep = function objectSetDeep(object, path, value) { + path = path.toString().match(/[^.[\]]+/g) || []; // Iterate all of them except the last one + + path.slice(0, -1).reduce(function (a, currentKey, index) { + // If the key does not exist or its value is not an object, create/override the key + if (Object(a[currentKey]) !== a[currentKey]) { + // Is the next key a potential array-index? + a[currentKey] = Math.abs(path[index + 1]) >> 0 === +path[index + 1] ? [] // Yes: assign a new array object + : {}; // No: assign a new plain object + } + + return a[currentKey]; + }, object)[path[path.length - 1]] = value; // Finally assign the value to the last key + + return object; + }; // Returns component data if Alpine has made it available, otherwise computes it with saferEval() + + var componentData = function componentData(component) { + if (component.__x) { + return component.__x.getUnobservedData(); + } + + return saferEval(component.getAttribute('x-data'), component); + }; + + function isValidVersion(required, current) { + var requiredArray = required.split('.'); + var currentArray = current.split('.'); + + for (var i = 0; i < requiredArray.length; i++) { + if (!currentArray[i] || parseInt(currentArray[i]) < parseInt(requiredArray[i])) { + return false; + } + } + + return true; + } + + function saferEval(expression, dataContext, additionalHelperVariables) { + if (additionalHelperVariables === void 0) { + additionalHelperVariables = {}; + } + + if (typeof expression === 'function') { + return expression.call(dataContext); + } // eslint-disable-next-line no-new-func + + + return new Function(['$data'].concat(Object.keys(additionalHelperVariables)), "var __alpine_result; with($data) { __alpine_result = " + expression + " }; return __alpine_result").apply(void 0, [dataContext].concat(Object.values(additionalHelperVariables))); + } + + var AlpineComponentMagicMethod = { + start: function start() { + checkForAlpine(); + Alpine.addMagicProperty('parent', function ($el) { + if (typeof $el.$parent !== 'undefined') return $el.$parent; + var parentComponent = $el.parentNode.closest('[x-data]'); + if (!parentComponent) throw new Error('Parent component not found'); + $el.$parent = syncWithObservedComponent(componentData(parentComponent), parentComponent, objectSetDeep); + updateOnMutation(parentComponent, function () { + $el.$parent = syncWithObservedComponent(parentComponent.__x.getUnobservedData(), parentComponent, objectSetDeep); + + $el.__x.updateElements($el); + }); + return $el.$parent; + }); + Alpine.addMagicProperty('component', function ($el) { + return function (componentName) { + var _this = this; + + if (typeof this[componentName] !== 'undefined') return this[componentName]; + var componentBeingObserved = document.querySelector("[x-data][x-id=\"" + componentName + "\"], [x-data]#" + componentName); + if (!componentBeingObserved) throw new Error('Component not found'); + this[componentName] = syncWithObservedComponent(componentData(componentBeingObserved), componentBeingObserved, objectSetDeep); + updateOnMutation(componentBeingObserved, function () { + _this[componentName] = syncWithObservedComponent(componentBeingObserved.__x.getUnobservedData(), componentBeingObserved, objectSetDeep); + + $el.__x.updateElements($el); + }); + return this[componentName]; + }; + }); + } + }; + + var alpine = window.deferLoadingAlpine || function (alpine) { + return alpine(); + }; + + window.deferLoadingAlpine = function (callback) { + alpine(callback); + AlpineComponentMagicMethod.start(); + }; + + var bind = function bind(fn, thisArg) { + return function wrap() { + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + return fn.apply(thisArg, args); + }; + }; + + /*global toString:true*/ + + // utils is a library of generic helper functions non-specific to axios + + var toString = Object.prototype.toString; + + /** + * Determine if a value is an Array + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Array, otherwise false + */ + function isArray(val) { + return toString.call(val) === '[object Array]'; + } + + /** + * Determine if a value is undefined + * + * @param {Object} val The value to test + * @returns {boolean} True if the value is undefined, otherwise false + */ + function isUndefined(val) { + return typeof val === 'undefined'; + } + + /** + * Determine if a value is a Buffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Buffer, otherwise false + */ + function isBuffer(val) { + return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) + && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); + } + + /** + * Determine if a value is an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an ArrayBuffer, otherwise false + */ + function isArrayBuffer(val) { + return toString.call(val) === '[object ArrayBuffer]'; + } + + /** + * Determine if a value is a FormData + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an FormData, otherwise false + */ + function isFormData(val) { + return (typeof FormData !== 'undefined') && (val instanceof FormData); + } + + /** + * Determine if a value is a view on an ArrayBuffer + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false + */ + function isArrayBufferView(val) { + var result; + if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { + result = ArrayBuffer.isView(val); + } else { + result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); + } + return result; + } + + /** + * Determine if a value is a String + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a String, otherwise false + */ + function isString(val) { + return typeof val === 'string'; + } + + /** + * Determine if a value is a Number + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Number, otherwise false + */ + function isNumber(val) { + return typeof val === 'number'; + } + + /** + * Determine if a value is an Object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is an Object, otherwise false + */ + function isObject(val) { + return val !== null && typeof val === 'object'; + } + + /** + * Determine if a value is a plain Object + * + * @param {Object} val The value to test + * @return {boolean} True if value is a plain Object, otherwise false + */ + function isPlainObject(val) { + if (toString.call(val) !== '[object Object]') { + return false; + } + + var prototype = Object.getPrototypeOf(val); + return prototype === null || prototype === Object.prototype; + } + + /** + * Determine if a value is a Date + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Date, otherwise false + */ + function isDate(val) { + return toString.call(val) === '[object Date]'; + } + + /** + * Determine if a value is a File + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a File, otherwise false + */ + function isFile(val) { + return toString.call(val) === '[object File]'; + } + + /** + * Determine if a value is a Blob + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Blob, otherwise false + */ + function isBlob(val) { + return toString.call(val) === '[object Blob]'; + } + + /** + * Determine if a value is a Function + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Function, otherwise false + */ + function isFunction(val) { + return toString.call(val) === '[object Function]'; + } + + /** + * Determine if a value is a Stream + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a Stream, otherwise false + */ + function isStream(val) { + return isObject(val) && isFunction(val.pipe); + } + + /** + * Determine if a value is a URLSearchParams object + * + * @param {Object} val The value to test + * @returns {boolean} True if value is a URLSearchParams object, otherwise false + */ + function isURLSearchParams(val) { + return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; + } + + /** + * Trim excess whitespace off the beginning and end of a string + * + * @param {String} str The String to trim + * @returns {String} The String freed of excess whitespace + */ + function trim(str) { + return str.replace(/^\s*/, '').replace(/\s*$/, ''); + } + + /** + * Determine if we're running in a standard browser environment + * + * This allows axios to run in a web worker, and react-native. + * Both environments support XMLHttpRequest, but not fully standard globals. + * + * web workers: + * typeof window -> undefined + * typeof document -> undefined + * + * react-native: + * navigator.product -> 'ReactNative' + * nativescript + * navigator.product -> 'NativeScript' or 'NS' + */ + function isStandardBrowserEnv() { + if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || + navigator.product === 'NativeScript' || + navigator.product === 'NS')) { + return false; + } + return ( + typeof window !== 'undefined' && + typeof document !== 'undefined' + ); + } + + /** + * Iterate over an Array or an Object invoking a function for each item. + * + * If `obj` is an Array callback will be called passing + * the value, index, and complete array for each item. + * + * If 'obj' is an Object callback will be called passing + * the value, key, and complete object for each property. + * + * @param {Object|Array} obj The object to iterate + * @param {Function} fn The callback to invoke for each item + */ + function forEach(obj, fn) { + // Don't bother if no value provided + if (obj === null || typeof obj === 'undefined') { + return; + } + + // Force an array if not already something iterable + if (typeof obj !== 'object') { + /*eslint no-param-reassign:0*/ + obj = [obj]; + } + + if (isArray(obj)) { + // Iterate over array values + for (var i = 0, l = obj.length; i < l; i++) { + fn.call(null, obj[i], i, obj); + } + } else { + // Iterate over object keys + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + fn.call(null, obj[key], key, obj); + } + } + } + } + + /** + * Accepts varargs expecting each argument to be an object, then + * immutably merges the properties of each object and returns result. + * + * When multiple objects contain the same key the later object in + * the arguments list will take precedence. + * + * Example: + * + * ```js + * var result = merge({foo: 123}, {foo: 456}); + * console.log(result.foo); // outputs 456 + * ``` + * + * @param {Object} obj1 Object to merge + * @returns {Object} Result of all merge properties + */ + function merge(/* obj1, obj2, obj3, ... */) { + var result = {}; + function assignValue(val, key) { + if (isPlainObject(result[key]) && isPlainObject(val)) { + result[key] = merge(result[key], val); + } else if (isPlainObject(val)) { + result[key] = merge({}, val); + } else if (isArray(val)) { + result[key] = val.slice(); + } else { + result[key] = val; + } + } + + for (var i = 0, l = arguments.length; i < l; i++) { + forEach(arguments[i], assignValue); + } + return result; + } + + /** + * Extends object a by mutably adding to it the properties of object b. + * + * @param {Object} a The object to be extended + * @param {Object} b The object to copy properties from + * @param {Object} thisArg The object to bind function to + * @return {Object} The resulting value of object a + */ + function extend(a, b, thisArg) { + forEach(b, function assignValue(val, key) { + if (thisArg && typeof val === 'function') { + a[key] = bind(val, thisArg); + } else { + a[key] = val; + } + }); + return a; + } + + /** + * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) + * + * @param {string} content with BOM + * @return {string} content value without BOM + */ + function stripBOM(content) { + if (content.charCodeAt(0) === 0xFEFF) { + content = content.slice(1); + } + return content; + } + + var utils = { + isArray: isArray, + isArrayBuffer: isArrayBuffer, + isBuffer: isBuffer, + isFormData: isFormData, + isArrayBufferView: isArrayBufferView, + isString: isString, + isNumber: isNumber, + isObject: isObject, + isPlainObject: isPlainObject, + isUndefined: isUndefined, + isDate: isDate, + isFile: isFile, + isBlob: isBlob, + isFunction: isFunction, + isStream: isStream, + isURLSearchParams: isURLSearchParams, + isStandardBrowserEnv: isStandardBrowserEnv, + forEach: forEach, + merge: merge, + extend: extend, + trim: trim, + stripBOM: stripBOM + }; + + function encode(val) { + return encodeURIComponent(val). + replace(/%3A/gi, ':'). + replace(/%24/g, '$'). + replace(/%2C/gi, ','). + replace(/%20/g, '+'). + replace(/%5B/gi, '['). + replace(/%5D/gi, ']'); + } + + /** + * Build a URL by appending params to the end + * + * @param {string} url The base of the url (e.g., http://www.google.com) + * @param {object} [params] The params to be appended + * @returns {string} The formatted url + */ + var buildURL = function buildURL(url, params, paramsSerializer) { + /*eslint no-param-reassign:0*/ + if (!params) { + return url; + } + + var serializedParams; + if (paramsSerializer) { + serializedParams = paramsSerializer(params); + } else if (utils.isURLSearchParams(params)) { + serializedParams = params.toString(); + } else { + var parts = []; + + utils.forEach(params, function serialize(val, key) { + if (val === null || typeof val === 'undefined') { + return; + } + + if (utils.isArray(val)) { + key = key + '[]'; + } else { + val = [val]; + } + + utils.forEach(val, function parseValue(v) { + if (utils.isDate(v)) { + v = v.toISOString(); + } else if (utils.isObject(v)) { + v = JSON.stringify(v); + } + parts.push(encode(key) + '=' + encode(v)); + }); + }); + + serializedParams = parts.join('&'); + } + + if (serializedParams) { + var hashmarkIndex = url.indexOf('#'); + if (hashmarkIndex !== -1) { + url = url.slice(0, hashmarkIndex); + } + + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; + } + + return url; + }; + + function InterceptorManager() { + this.handlers = []; + } + + /** + * Add a new interceptor to the stack + * + * @param {Function} fulfilled The function to handle `then` for a `Promise` + * @param {Function} rejected The function to handle `reject` for a `Promise` + * + * @return {Number} An ID used to remove interceptor later + */ + InterceptorManager.prototype.use = function use(fulfilled, rejected) { + this.handlers.push({ + fulfilled: fulfilled, + rejected: rejected + }); + return this.handlers.length - 1; + }; + + /** + * Remove an interceptor from the stack + * + * @param {Number} id The ID that was returned by `use` + */ + InterceptorManager.prototype.eject = function eject(id) { + if (this.handlers[id]) { + this.handlers[id] = null; + } + }; + + /** + * Iterate over all the registered interceptors + * + * This method is particularly useful for skipping over any + * interceptors that may have become `null` calling `eject`. + * + * @param {Function} fn The function to call for each interceptor + */ + InterceptorManager.prototype.forEach = function forEach(fn) { + utils.forEach(this.handlers, function forEachHandler(h) { + if (h !== null) { + fn(h); + } + }); + }; + + var InterceptorManager_1 = InterceptorManager; + + /** + * Transform the data for a request or a response + * + * @param {Object|String} data The data to be transformed + * @param {Array} headers The headers for the request or response + * @param {Array|Function} fns A single function or Array of functions + * @returns {*} The resulting transformed data + */ + var transformData = function transformData(data, headers, fns) { + /*eslint no-param-reassign:0*/ + utils.forEach(fns, function transform(fn) { + data = fn(data, headers); + }); + + return data; + }; + + var isCancel = function isCancel(value) { + return !!(value && value.__CANCEL__); + }; + + var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) { + utils.forEach(headers, function processHeader(value, name) { + if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { + headers[normalizedName] = value; + delete headers[name]; + } + }); + }; + + /** + * Update an Error with the specified config, error code, and response. + * + * @param {Error} error The error to update. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The error. + */ + var enhanceError = function enhanceError(error, config, code, request, response) { + error.config = config; + if (code) { + error.code = code; + } + + error.request = request; + error.response = response; + error.isAxiosError = true; + + error.toJSON = function toJSON() { + return { + // Standard + message: this.message, + name: this.name, + // Microsoft + description: this.description, + number: this.number, + // Mozilla + fileName: this.fileName, + lineNumber: this.lineNumber, + columnNumber: this.columnNumber, + stack: this.stack, + // Axios + config: this.config, + code: this.code + }; + }; + return error; + }; + + /** + * Create an Error with the specified message, config, error code, request and response. + * + * @param {string} message The error message. + * @param {Object} config The config. + * @param {string} [code] The error code (for example, 'ECONNABORTED'). + * @param {Object} [request] The request. + * @param {Object} [response] The response. + * @returns {Error} The created error. + */ + var createError = function createError(message, config, code, request, response) { + var error = new Error(message); + return enhanceError(error, config, code, request, response); + }; + + /** + * Resolve or reject a Promise based on response status. + * + * @param {Function} resolve A function that resolves the promise. + * @param {Function} reject A function that rejects the promise. + * @param {object} response The response. + */ + var settle = function settle(resolve, reject, response) { + var validateStatus = response.config.validateStatus; + if (!response.status || !validateStatus || validateStatus(response.status)) { + resolve(response); + } else { + reject(createError( + 'Request failed with status code ' + response.status, + response.config, + null, + response.request, + response + )); + } + }; + + var cookies = ( + utils.isStandardBrowserEnv() ? + + // Standard browser envs support document.cookie + (function standardBrowserEnv() { + return { + write: function write(name, value, expires, path, domain, secure) { + var cookie = []; + cookie.push(name + '=' + encodeURIComponent(value)); + + if (utils.isNumber(expires)) { + cookie.push('expires=' + new Date(expires).toGMTString()); + } + + if (utils.isString(path)) { + cookie.push('path=' + path); + } + + if (utils.isString(domain)) { + cookie.push('domain=' + domain); + } + + if (secure === true) { + cookie.push('secure'); + } + + document.cookie = cookie.join('; '); + }, + + read: function read(name) { + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); + return (match ? decodeURIComponent(match[3]) : null); + }, + + remove: function remove(name) { + this.write(name, '', Date.now() - 86400000); + } + }; + })() : + + // Non standard browser env (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return { + write: function write() {}, + read: function read() { return null; }, + remove: function remove() {} + }; + })() + ); + + /** + * Determines whether the specified URL is absolute + * + * @param {string} url The URL to test + * @returns {boolean} True if the specified URL is absolute, otherwise false + */ + var isAbsoluteURL = function isAbsoluteURL(url) { + // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed + // by any combination of letters, digits, plus, period, or hyphen. + return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); + }; + + /** + * Creates a new URL by combining the specified URLs + * + * @param {string} baseURL The base URL + * @param {string} relativeURL The relative URL + * @returns {string} The combined URL + */ + var combineURLs = function combineURLs(baseURL, relativeURL) { + return relativeURL + ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') + : baseURL; + }; + + /** + * Creates a new URL by combining the baseURL with the requestedURL, + * only when the requestedURL is not already an absolute URL. + * If the requestURL is absolute, this function returns the requestedURL untouched. + * + * @param {string} baseURL The base URL + * @param {string} requestedURL Absolute or relative URL to combine + * @returns {string} The combined full path + */ + var buildFullPath = function buildFullPath(baseURL, requestedURL) { + if (baseURL && !isAbsoluteURL(requestedURL)) { + return combineURLs(baseURL, requestedURL); + } + return requestedURL; + }; + + // Headers whose duplicates are ignored by node + // c.f. https://nodejs.org/api/http.html#http_message_headers + var ignoreDuplicateOf = [ + 'age', 'authorization', 'content-length', 'content-type', 'etag', + 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', + 'last-modified', 'location', 'max-forwards', 'proxy-authorization', + 'referer', 'retry-after', 'user-agent' + ]; + + /** + * Parse headers into an object + * + * ``` + * Date: Wed, 27 Aug 2014 08:58:49 GMT + * Content-Type: application/json + * Connection: keep-alive + * Transfer-Encoding: chunked + * ``` + * + * @param {String} headers Headers needing to be parsed + * @returns {Object} Headers parsed into an object + */ + var parseHeaders = function parseHeaders(headers) { + var parsed = {}; + var key; + var val; + var i; + + if (!headers) { return parsed; } + + utils.forEach(headers.split('\n'), function parser(line) { + i = line.indexOf(':'); + key = utils.trim(line.substr(0, i)).toLowerCase(); + val = utils.trim(line.substr(i + 1)); + + if (key) { + if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { + return; + } + if (key === 'set-cookie') { + parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); + } else { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + } + }); + + return parsed; + }; + + var isURLSameOrigin = ( + utils.isStandardBrowserEnv() ? + + // Standard browser envs have full support of the APIs needed to test + // whether the request URL is of the same origin as current location. + (function standardBrowserEnv() { + var msie = /(msie|trident)/i.test(navigator.userAgent); + var urlParsingNode = document.createElement('a'); + var originURL; + + /** + * Parse a URL to discover it's components + * + * @param {String} url The URL to be parsed + * @returns {Object} + */ + function resolveURL(url) { + var href = url; + + if (msie) { + // IE needs attribute set twice to normalize properties + urlParsingNode.setAttribute('href', href); + href = urlParsingNode.href; + } + + urlParsingNode.setAttribute('href', href); + + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils + return { + href: urlParsingNode.href, + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', + host: urlParsingNode.host, + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', + hostname: urlParsingNode.hostname, + port: urlParsingNode.port, + pathname: (urlParsingNode.pathname.charAt(0) === '/') ? + urlParsingNode.pathname : + '/' + urlParsingNode.pathname + }; + } + + originURL = resolveURL(window.location.href); + + /** + * Determine if a URL shares the same origin as the current location + * + * @param {String} requestURL The URL to test + * @returns {boolean} True if URL shares the same origin, otherwise false + */ + return function isURLSameOrigin(requestURL) { + var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; + return (parsed.protocol === originURL.protocol && + parsed.host === originURL.host); + }; + })() : + + // Non standard browser envs (web workers, react-native) lack needed support. + (function nonStandardBrowserEnv() { + return function isURLSameOrigin() { + return true; + }; + })() + ); + + var xhr = function xhrAdapter(config) { + return new Promise(function dispatchXhrRequest(resolve, reject) { + var requestData = config.data; + var requestHeaders = config.headers; + + if (utils.isFormData(requestData)) { + delete requestHeaders['Content-Type']; // Let the browser set it + } + + var request = new XMLHttpRequest(); + + // HTTP basic authentication + if (config.auth) { + var username = config.auth.username || ''; + var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; + requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); + } + + var fullPath = buildFullPath(config.baseURL, config.url); + request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); + + // Set the request timeout in MS + request.timeout = config.timeout; + + // Listen for ready state + request.onreadystatechange = function handleLoad() { + if (!request || request.readyState !== 4) { + return; + } + + // The request errored out and we didn't get a response, this will be + // handled by onerror instead + // With one exception: request that using file: protocol, most browsers + // will return status as 0 even though it's a successful request + if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { + return; + } + + // Prepare the response + var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; + var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response; + var response = { + data: responseData, + status: request.status, + statusText: request.statusText, + headers: responseHeaders, + config: config, + request: request + }; + + settle(resolve, reject, response); + + // Clean up request + request = null; + }; + + // Handle browser request cancellation (as opposed to a manual cancellation) + request.onabort = function handleAbort() { + if (!request) { + return; + } + + reject(createError('Request aborted', config, 'ECONNABORTED', request)); + + // Clean up request + request = null; + }; + + // Handle low level network errors + request.onerror = function handleError() { + // Real errors are hidden from us by the browser + // onerror should only fire if it's a network error + reject(createError('Network Error', config, null, request)); + + // Clean up request + request = null; + }; + + // Handle timeout + request.ontimeout = function handleTimeout() { + var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; + if (config.timeoutErrorMessage) { + timeoutErrorMessage = config.timeoutErrorMessage; + } + reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', + request)); + + // Clean up request + request = null; + }; + + // Add xsrf header + // This is only done if running in a standard browser environment. + // Specifically not if we're in a web worker, or react-native. + if (utils.isStandardBrowserEnv()) { + // Add xsrf header + var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? + cookies.read(config.xsrfCookieName) : + undefined; + + if (xsrfValue) { + requestHeaders[config.xsrfHeaderName] = xsrfValue; + } + } + + // Add headers to the request + if ('setRequestHeader' in request) { + utils.forEach(requestHeaders, function setRequestHeader(val, key) { + if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { + // Remove Content-Type if data is undefined + delete requestHeaders[key]; + } else { + // Otherwise add header to the request + request.setRequestHeader(key, val); + } + }); + } + + // Add withCredentials to request if needed + if (!utils.isUndefined(config.withCredentials)) { + request.withCredentials = !!config.withCredentials; + } + + // Add responseType to request if needed + if (config.responseType) { + try { + request.responseType = config.responseType; + } catch (e) { + // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2. + // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function. + if (config.responseType !== 'json') { + throw e; + } + } + } + + // Handle progress if needed + if (typeof config.onDownloadProgress === 'function') { + request.addEventListener('progress', config.onDownloadProgress); + } + + // Not all browsers support upload events + if (typeof config.onUploadProgress === 'function' && request.upload) { + request.upload.addEventListener('progress', config.onUploadProgress); + } + + if (config.cancelToken) { + // Handle cancellation + config.cancelToken.promise.then(function onCanceled(cancel) { + if (!request) { + return; + } + + request.abort(); + reject(cancel); + // Clean up request + request = null; + }); + } + + if (!requestData) { + requestData = null; + } + + // Send the request + request.send(requestData); + }); + }; + + var DEFAULT_CONTENT_TYPE = { + 'Content-Type': 'application/x-www-form-urlencoded' + }; + + function setContentTypeIfUnset(headers, value) { + if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { + headers['Content-Type'] = value; + } + } + + function getDefaultAdapter() { + var adapter; + if (typeof XMLHttpRequest !== 'undefined') { + // For browsers use XHR adapter + adapter = xhr; + } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { + // For node use HTTP adapter + adapter = xhr; + } + return adapter; + } + + var defaults = { + adapter: getDefaultAdapter(), + + transformRequest: [function transformRequest(data, headers) { + normalizeHeaderName(headers, 'Accept'); + normalizeHeaderName(headers, 'Content-Type'); + if (utils.isFormData(data) || + utils.isArrayBuffer(data) || + utils.isBuffer(data) || + utils.isStream(data) || + utils.isFile(data) || + utils.isBlob(data) + ) { + return data; + } + if (utils.isArrayBufferView(data)) { + return data.buffer; + } + if (utils.isURLSearchParams(data)) { + setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); + return data.toString(); + } + if (utils.isObject(data)) { + setContentTypeIfUnset(headers, 'application/json;charset=utf-8'); + return JSON.stringify(data); + } + return data; + }], + + transformResponse: [function transformResponse(data) { + /*eslint no-param-reassign:0*/ + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (e) { /* Ignore */ } + } + return data; + }], + + /** + * A timeout in milliseconds to abort a request. If set to 0 (default) a + * timeout is not created. + */ + timeout: 0, + + xsrfCookieName: 'XSRF-TOKEN', + xsrfHeaderName: 'X-XSRF-TOKEN', + + maxContentLength: -1, + maxBodyLength: -1, + + validateStatus: function validateStatus(status) { + return status >= 200 && status < 300; + } + }; + + defaults.headers = { + common: { + 'Accept': 'application/json, text/plain, */*' + } + }; + + utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { + defaults.headers[method] = {}; + }); + + utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); + }); + + var defaults_1 = defaults; + + /** + * Throws a `Cancel` if cancellation has been requested. + */ + function throwIfCancellationRequested(config) { + if (config.cancelToken) { + config.cancelToken.throwIfRequested(); + } + } + + /** + * Dispatch a request to the server using the configured adapter. + * + * @param {object} config The config that is to be used for the request + * @returns {Promise} The Promise to be fulfilled + */ + var dispatchRequest = function dispatchRequest(config) { + throwIfCancellationRequested(config); + + // Ensure headers exist + config.headers = config.headers || {}; + + // Transform request data + config.data = transformData( + config.data, + config.headers, + config.transformRequest + ); + + // Flatten headers + config.headers = utils.merge( + config.headers.common || {}, + config.headers[config.method] || {}, + config.headers + ); + + utils.forEach( + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], + function cleanHeaderConfig(method) { + delete config.headers[method]; + } + ); + + var adapter = config.adapter || defaults_1.adapter; + + return adapter(config).then(function onAdapterResolution(response) { + throwIfCancellationRequested(config); + + // Transform response data + response.data = transformData( + response.data, + response.headers, + config.transformResponse + ); + + return response; + }, function onAdapterRejection(reason) { + if (!isCancel(reason)) { + throwIfCancellationRequested(config); + + // Transform response data + if (reason && reason.response) { + reason.response.data = transformData( + reason.response.data, + reason.response.headers, + config.transformResponse + ); + } + } + + return Promise.reject(reason); + }); + }; + + /** + * Config-specific merge-function which creates a new config-object + * by merging two configuration objects together. + * + * @param {Object} config1 + * @param {Object} config2 + * @returns {Object} New object resulting from merging config2 to config1 + */ + var mergeConfig = function mergeConfig(config1, config2) { + // eslint-disable-next-line no-param-reassign + config2 = config2 || {}; + var config = {}; + + var valueFromConfig2Keys = ['url', 'method', 'data']; + var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params']; + var defaultToConfig2Keys = [ + 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', + 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', + 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', + 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', + 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding' + ]; + var directMergeKeys = ['validateStatus']; + + function getMergedValue(target, source) { + if (utils.isPlainObject(target) && utils.isPlainObject(source)) { + return utils.merge(target, source); + } else if (utils.isPlainObject(source)) { + return utils.merge({}, source); + } else if (utils.isArray(source)) { + return source.slice(); + } + return source; + } + + function mergeDeepProperties(prop) { + if (!utils.isUndefined(config2[prop])) { + config[prop] = getMergedValue(config1[prop], config2[prop]); + } else if (!utils.isUndefined(config1[prop])) { + config[prop] = getMergedValue(undefined, config1[prop]); + } + } + + utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { + if (!utils.isUndefined(config2[prop])) { + config[prop] = getMergedValue(undefined, config2[prop]); + } + }); + + utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties); + + utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { + if (!utils.isUndefined(config2[prop])) { + config[prop] = getMergedValue(undefined, config2[prop]); + } else if (!utils.isUndefined(config1[prop])) { + config[prop] = getMergedValue(undefined, config1[prop]); + } + }); + + utils.forEach(directMergeKeys, function merge(prop) { + if (prop in config2) { + config[prop] = getMergedValue(config1[prop], config2[prop]); + } else if (prop in config1) { + config[prop] = getMergedValue(undefined, config1[prop]); + } + }); + + var axiosKeys = valueFromConfig2Keys + .concat(mergeDeepPropertiesKeys) + .concat(defaultToConfig2Keys) + .concat(directMergeKeys); + + var otherKeys = Object + .keys(config1) + .concat(Object.keys(config2)) + .filter(function filterAxiosKeys(key) { + return axiosKeys.indexOf(key) === -1; + }); + + utils.forEach(otherKeys, mergeDeepProperties); + + return config; + }; + + /** + * Create a new instance of Axios + * + * @param {Object} instanceConfig The default config for the instance + */ + function Axios(instanceConfig) { + this.defaults = instanceConfig; + this.interceptors = { + request: new InterceptorManager_1(), + response: new InterceptorManager_1() + }; + } + + /** + * Dispatch a request + * + * @param {Object} config The config specific for this request (merged with this.defaults) + */ + Axios.prototype.request = function request(config) { + /*eslint no-param-reassign:0*/ + // Allow for axios('example/url'[, config]) a la fetch API + if (typeof config === 'string') { + config = arguments[1] || {}; + config.url = arguments[0]; + } else { + config = config || {}; + } + + config = mergeConfig(this.defaults, config); + + // Set config.method + if (config.method) { + config.method = config.method.toLowerCase(); + } else if (this.defaults.method) { + config.method = this.defaults.method.toLowerCase(); + } else { + config.method = 'get'; + } + + // Hook up interceptors middleware + var chain = [dispatchRequest, undefined]; + var promise = Promise.resolve(config); + + this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { + chain.unshift(interceptor.fulfilled, interceptor.rejected); + }); + + this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { + chain.push(interceptor.fulfilled, interceptor.rejected); + }); + + while (chain.length) { + promise = promise.then(chain.shift(), chain.shift()); + } + + return promise; + }; + + Axios.prototype.getUri = function getUri(config) { + config = mergeConfig(this.defaults, config); + return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); + }; + + // Provide aliases for supported request methods + utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, config) { + return this.request(mergeConfig(config || {}, { + method: method, + url: url, + data: (config || {}).data + })); + }; + }); + + utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { + /*eslint func-names:0*/ + Axios.prototype[method] = function(url, data, config) { + return this.request(mergeConfig(config || {}, { + method: method, + url: url, + data: data + })); + }; + }); + + var Axios_1 = Axios; + + /** + * A `Cancel` is an object that is thrown when an operation is canceled. + * + * @class + * @param {string=} message The message. + */ + function Cancel(message) { + this.message = message; + } + + Cancel.prototype.toString = function toString() { + return 'Cancel' + (this.message ? ': ' + this.message : ''); + }; + + Cancel.prototype.__CANCEL__ = true; + + var Cancel_1 = Cancel; + + /** + * A `CancelToken` is an object that can be used to request cancellation of an operation. + * + * @class + * @param {Function} executor The executor function. + */ + function CancelToken(executor) { + if (typeof executor !== 'function') { + throw new TypeError('executor must be a function.'); + } + + var resolvePromise; + this.promise = new Promise(function promiseExecutor(resolve) { + resolvePromise = resolve; + }); + + var token = this; + executor(function cancel(message) { + if (token.reason) { + // Cancellation has already been requested + return; + } + + token.reason = new Cancel_1(message); + resolvePromise(token.reason); + }); + } + + /** + * Throws a `Cancel` if cancellation has been requested. + */ + CancelToken.prototype.throwIfRequested = function throwIfRequested() { + if (this.reason) { + throw this.reason; + } + }; + + /** + * Returns an object that contains a new `CancelToken` and a function that, when called, + * cancels the `CancelToken`. + */ + CancelToken.source = function source() { + var cancel; + var token = new CancelToken(function executor(c) { + cancel = c; + }); + return { + token: token, + cancel: cancel + }; + }; + + var CancelToken_1 = CancelToken; + + /** + * Syntactic sugar for invoking a function and expanding an array for arguments. + * + * Common use case would be to use `Function.prototype.apply`. + * + * ```js + * function f(x, y, z) {} + * var args = [1, 2, 3]; + * f.apply(null, args); + * ``` + * + * With `spread` this example can be re-written. + * + * ```js + * spread(function(x, y, z) {})([1, 2, 3]); + * ``` + * + * @param {Function} callback + * @returns {Function} + */ + var spread = function spread(callback) { + return function wrap(arr) { + return callback.apply(null, arr); + }; + }; + + /** + * Create an instance of Axios + * + * @param {Object} defaultConfig The default config for the instance + * @return {Axios} A new instance of Axios + */ + function createInstance(defaultConfig) { + var context = new Axios_1(defaultConfig); + var instance = bind(Axios_1.prototype.request, context); + + // Copy axios.prototype to instance + utils.extend(instance, Axios_1.prototype, context); + + // Copy context to instance + utils.extend(instance, context); + + return instance; + } + + // Create the default instance to be exported + var axios = createInstance(defaults_1); + + // Expose Axios class to allow class inheritance + axios.Axios = Axios_1; + + // Factory for creating new instances + axios.create = function create(instanceConfig) { + return createInstance(mergeConfig(axios.defaults, instanceConfig)); + }; + + // Expose Cancel & CancelToken + axios.Cancel = Cancel_1; + axios.CancelToken = CancelToken_1; + axios.isCancel = isCancel; + + // Expose all/spread + axios.all = function all(promises) { + return Promise.all(promises); + }; + axios.spread = spread; + + var axios_1 = axios; + + // Allow use of default import syntax in TypeScript + var _default = axios; + axios_1.default = _default; + + var axios$1 = axios_1; + + var AlpineFetchMagicMethod = { + start: function start() { + checkForAlpine(); + Alpine.addMagicProperty('fetch', function () { + return function () { + for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) { + parameters[_key] = arguments[_key]; + } + + if (typeof parameters[0] === 'string' && parameters[0].length) { + return axios$1.get(parameters[0]).then(function (response) { + return Object.prototype.hasOwnProperty.call(response, 'data') ? response.data : response; + }); + } + + if (typeof parameters[0] === 'object') { + return axios$1(parameters[0]); + } + + return parameters[0]; + }; + }); + } + }; + + var alpine$1 = window.deferLoadingAlpine || function (alpine) { + return alpine(); + }; + + window.deferLoadingAlpine = function (callback) { + AlpineFetchMagicMethod.start(); + alpine$1(callback); + }; + + var AlpineIntervalMagicMethod = { + start: function start() { + checkForAlpine(); + Alpine.addMagicProperty('interval', function () { + return function () { + var _this = this; + + for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) { + parameters[_key] = arguments[_key]; + } + + if (typeof parameters[0] !== 'function') return parameters[0]; + var timer = parameters[1]; + var delay = 0; + var forceInterval = false; // Users can pass in an object as a second parameter instead + + if (typeof parameters[1] === 'object') { + if (Object.prototype.hasOwnProperty.call(parameters[1], 'timer')) { + timer = parameters[1].timer; + } + + if (Object.prototype.hasOwnProperty.call(parameters[1], 'delay')) { + delay = parameters[1].delay; + } + + if (Object.prototype.hasOwnProperty.call(parameters[1], 'forceInterval')) { + forceInterval = parameters[1].forceInterval; + } + } + + var loop = function loop() { + var test = Object.prototype.hasOwnProperty.call(_this, 'autoIntervalTest') ? _this.autoIntervalTest : true; + setTimeout(function () { + if (!_this.autoIntervalLoop) return; + test && parameters[0].call(_this); + forceInterval ? _this.autoIntervalLoop() : requestAnimationFrame(_this.autoIntervalLoop); + }, timer); + }; + + this.autoIntervalLoop = loop; + setTimeout(function () { + if (!_this.autoIntervalLoop) return; + forceInterval ? _this.autoIntervalLoop() : requestAnimationFrame(_this.autoIntervalLoop); + }, delay); + this.$watch('autoIntervalTest', function (test) { + if (test) { + _this.autoIntervalLoop = loop; + forceInterval ? _this.autoIntervalLoop() : requestAnimationFrame(_this.autoIntervalLoop); + } else { + clearTimeout(_this.autoIntervalLoop); + _this.autoIntervalLoop = null; + } + }); + }; + }); + } + }; + + var alpine$2 = window.deferLoadingAlpine || function (alpine) { + return alpine(); + }; + + window.deferLoadingAlpine = function (callback) { + AlpineIntervalMagicMethod.start(); + alpine$2(callback); + }; + + var AlpineRangeMagicMethod = { + start: function start() { + checkForAlpine(); + Alpine.addMagicProperty('range', function () { + return function (start, stop, step) { + if (step === void 0) { + step = 1; + } + + // Accept $range(10) and expect 1...10 + if (typeof stop === 'undefined') { + stop = start; + start = start ? 1 : 0; + } // Accept $range(20, 10) and expect 20...10 + + + var reverse = start > stop; + + if (reverse) { + var _ref = [stop, start]; + start = _ref[0]; + stop = _ref[1]; + } // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Sequence_generator_range + + + var range = Array.from({ + length: (stop - start) / step + 1 + }, function (_, i) { + return start + i * step; + }); + return reverse ? range.reverse() : range; + }; + }); + } + }; + + var alpine$3 = window.deferLoadingAlpine || function (alpine) { + return alpine(); + }; + + window.deferLoadingAlpine = function (callback) { + AlpineRangeMagicMethod.start(); + alpine$3(callback); + }; + + var Config = /*#__PURE__*/function () { + function Config() { + var _this = this; + + this.values = { + breakpoints: { + xs: 0, + sm: 640, + md: 768, + lg: 1024, + xl: 1280, + '2xl': 1536 + } + }; // After all assets are loaded but before the page is actually ready when ALpine will kick in + + document.addEventListener('readystatechange', function () { + if (document.readyState === 'interactive' && window.AlpineMagicHelpersConfig) { + for (var index in window.AlpineMagicHelpersConfig) { + _this.values[index] = window.AlpineMagicHelpersConfig[index]; + } + } + }); + } + + var _proto = Config.prototype; + + _proto.get = function get(property) { + return this.values[property] ? this.values[property] : null; + }; + + return Config; + }(); + + var config = new Config(); + + var screenComponents = []; // Debounce `updateElements` method to prevent memory leak + + var debouncedScreensUpdate = function debouncedScreensUpdate() { + var update; // Update component if $el is in `screenComponents` + + var updateScreens = function updateScreens() { + clearTimeout(update); + update = setTimeout(function () { + screenComponents.forEach(function ($el) { + return $el && $el.__x && $el.__x.updateElements($el); + }); + }, 150); + }; + + return updateScreens; + }; + + var AlpineScreenMagicMethod = { + start: function start() { + // Bind `debouncedScreensUpdate` to resize event on window + // Note that `resize` event will be triggered on `orientationchange` event as well + window.addEventListener('resize', debouncedScreensUpdate()); + Alpine.addMagicProperty('screen', function ($el) { + // Push $el if it's not in the `screenComponents` + if (!screenComponents.includes($el)) { + screenComponents.push($el); + } + + return function (breakpoint) { + // Get current window width + var width = window.innerWidth; // Early return if breakpoint is provided as number + + if (Number.isInteger(breakpoint)) return breakpoint <= width; // Get breakpoints from Config + + var configBreakpoints = config.get('breakpoints'); // Check if breakpoint exists + + if (configBreakpoints[breakpoint] === undefined) { + throw Error('Undefined $screen property: ' + breakpoint); + } // Finally compare breakpoint with window width and return as boolean + + + return configBreakpoints[breakpoint] <= width; + }; + }); + } + }; + + var alpine$4 = window.deferLoadingAlpine || function (alpine) { + return alpine(); + }; + + window.deferLoadingAlpine = function (callback) { + AlpineScreenMagicMethod.start(); + alpine$4(callback); + }; + + function createCommonjsModule(fn, basedir, module) { + return module = { + path: basedir, + exports: {}, + require: function (path, base) { + return commonjsRequire(); + } + }, fn(module, module.exports), module.exports; + } + + function commonjsRequire () { + throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); + } + + var smoothscroll = createCommonjsModule(function (module, exports) { + /* smoothscroll v0.4.4 - 2019 - Dustan Kasten, Jeremias Menichelli - MIT License */ + (function () { + + // polyfill + function polyfill() { + // aliases + var w = window; + var d = document; + + // return if scroll behavior is supported and polyfill is not forced + if ( + 'scrollBehavior' in d.documentElement.style && + w.__forceSmoothScrollPolyfill__ !== true + ) { + return; + } + + // globals + var Element = w.HTMLElement || w.Element; + var SCROLL_TIME = 468; + + // object gathering original scroll methods + var original = { + scroll: w.scroll || w.scrollTo, + scrollBy: w.scrollBy, + elementScroll: Element.prototype.scroll || scrollElement, + scrollIntoView: Element.prototype.scrollIntoView + }; + + // define timing method + var now = + w.performance && w.performance.now + ? w.performance.now.bind(w.performance) + : Date.now; + + /** + * indicates if a the current browser is made by Microsoft + * @method isMicrosoftBrowser + * @param {String} userAgent + * @returns {Boolean} + */ + function isMicrosoftBrowser(userAgent) { + var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/']; + + return new RegExp(userAgentPatterns.join('|')).test(userAgent); + } + + /* + * IE has rounding bug rounding down clientHeight and clientWidth and + * rounding up scrollHeight and scrollWidth causing false positives + * on hasScrollableSpace + */ + var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0; + + /** + * changes scroll position inside an element + * @method scrollElement + * @param {Number} x + * @param {Number} y + * @returns {undefined} + */ + function scrollElement(x, y) { + this.scrollLeft = x; + this.scrollTop = y; + } + + /** + * returns result of applying ease math function to a number + * @method ease + * @param {Number} k + * @returns {Number} + */ + function ease(k) { + return 0.5 * (1 - Math.cos(Math.PI * k)); + } + + /** + * indicates if a smooth behavior should be applied + * @method shouldBailOut + * @param {Number|Object} firstArg + * @returns {Boolean} + */ + function shouldBailOut(firstArg) { + if ( + firstArg === null || + typeof firstArg !== 'object' || + firstArg.behavior === undefined || + firstArg.behavior === 'auto' || + firstArg.behavior === 'instant' + ) { + // first argument is not an object/null + // or behavior is auto, instant or undefined + return true; + } + + if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') { + // first argument is an object and behavior is smooth + return false; + } + + // throw error when behavior is not supported + throw new TypeError( + 'behavior member of ScrollOptions ' + + firstArg.behavior + + ' is not a valid value for enumeration ScrollBehavior.' + ); + } + + /** + * indicates if an element has scrollable space in the provided axis + * @method hasScrollableSpace + * @param {Node} el + * @param {String} axis + * @returns {Boolean} + */ + function hasScrollableSpace(el, axis) { + if (axis === 'Y') { + return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight; + } + + if (axis === 'X') { + return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth; + } + } + + /** + * indicates if an element has a scrollable overflow property in the axis + * @method canOverflow + * @param {Node} el + * @param {String} axis + * @returns {Boolean} + */ + function canOverflow(el, axis) { + var overflowValue = w.getComputedStyle(el, null)['overflow' + axis]; + + return overflowValue === 'auto' || overflowValue === 'scroll'; + } + + /** + * indicates if an element can be scrolled in either axis + * @method isScrollable + * @param {Node} el + * @param {String} axis + * @returns {Boolean} + */ + function isScrollable(el) { + var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y'); + var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X'); + + return isScrollableY || isScrollableX; + } + + /** + * finds scrollable parent of an element + * @method findScrollableParent + * @param {Node} el + * @returns {Node} el + */ + function findScrollableParent(el) { + while (el !== d.body && isScrollable(el) === false) { + el = el.parentNode || el.host; + } + + return el; + } + + /** + * self invoked function that, given a context, steps through scrolling + * @method step + * @param {Object} context + * @returns {undefined} + */ + function step(context) { + var time = now(); + var value; + var currentX; + var currentY; + var elapsed = (time - context.startTime) / SCROLL_TIME; + + // avoid elapsed times higher than one + elapsed = elapsed > 1 ? 1 : elapsed; + + // apply easing to elapsed time + value = ease(elapsed); + + currentX = context.startX + (context.x - context.startX) * value; + currentY = context.startY + (context.y - context.startY) * value; + + context.method.call(context.scrollable, currentX, currentY); + + // scroll more if we have not reached our destination + if (currentX !== context.x || currentY !== context.y) { + w.requestAnimationFrame(step.bind(w, context)); + } + } + + /** + * scrolls window or element with a smooth behavior + * @method smoothScroll + * @param {Object|Node} el + * @param {Number} x + * @param {Number} y + * @returns {undefined} + */ + function smoothScroll(el, x, y) { + var scrollable; + var startX; + var startY; + var method; + var startTime = now(); + + // define scroll context + if (el === d.body) { + scrollable = w; + startX = w.scrollX || w.pageXOffset; + startY = w.scrollY || w.pageYOffset; + method = original.scroll; + } else { + scrollable = el; + startX = el.scrollLeft; + startY = el.scrollTop; + method = scrollElement; + } + + // scroll looping over a frame + step({ + scrollable: scrollable, + method: method, + startTime: startTime, + startX: startX, + startY: startY, + x: x, + y: y + }); + } + + // ORIGINAL METHODS OVERRIDES + // w.scroll and w.scrollTo + w.scroll = w.scrollTo = function() { + // avoid action when no arguments are passed + if (arguments[0] === undefined) { + return; + } + + // avoid smooth behavior if not required + if (shouldBailOut(arguments[0]) === true) { + original.scroll.call( + w, + arguments[0].left !== undefined + ? arguments[0].left + : typeof arguments[0] !== 'object' + ? arguments[0] + : w.scrollX || w.pageXOffset, + // use top prop, second argument if present or fallback to scrollY + arguments[0].top !== undefined + ? arguments[0].top + : arguments[1] !== undefined + ? arguments[1] + : w.scrollY || w.pageYOffset + ); + + return; + } + + // LET THE SMOOTHNESS BEGIN! + smoothScroll.call( + w, + d.body, + arguments[0].left !== undefined + ? ~~arguments[0].left + : w.scrollX || w.pageXOffset, + arguments[0].top !== undefined + ? ~~arguments[0].top + : w.scrollY || w.pageYOffset + ); + }; + + // w.scrollBy + w.scrollBy = function() { + // avoid action when no arguments are passed + if (arguments[0] === undefined) { + return; + } + + // avoid smooth behavior if not required + if (shouldBailOut(arguments[0])) { + original.scrollBy.call( + w, + arguments[0].left !== undefined + ? arguments[0].left + : typeof arguments[0] !== 'object' ? arguments[0] : 0, + arguments[0].top !== undefined + ? arguments[0].top + : arguments[1] !== undefined ? arguments[1] : 0 + ); + + return; + } + + // LET THE SMOOTHNESS BEGIN! + smoothScroll.call( + w, + d.body, + ~~arguments[0].left + (w.scrollX || w.pageXOffset), + ~~arguments[0].top + (w.scrollY || w.pageYOffset) + ); + }; + + // Element.prototype.scroll and Element.prototype.scrollTo + Element.prototype.scroll = Element.prototype.scrollTo = function() { + // avoid action when no arguments are passed + if (arguments[0] === undefined) { + return; + } + + // avoid smooth behavior if not required + if (shouldBailOut(arguments[0]) === true) { + // if one number is passed, throw error to match Firefox implementation + if (typeof arguments[0] === 'number' && arguments[1] === undefined) { + throw new SyntaxError('Value could not be converted'); + } + + original.elementScroll.call( + this, + // use left prop, first number argument or fallback to scrollLeft + arguments[0].left !== undefined + ? ~~arguments[0].left + : typeof arguments[0] !== 'object' ? ~~arguments[0] : this.scrollLeft, + // use top prop, second argument or fallback to scrollTop + arguments[0].top !== undefined + ? ~~arguments[0].top + : arguments[1] !== undefined ? ~~arguments[1] : this.scrollTop + ); + + return; + } + + var left = arguments[0].left; + var top = arguments[0].top; + + // LET THE SMOOTHNESS BEGIN! + smoothScroll.call( + this, + this, + typeof left === 'undefined' ? this.scrollLeft : ~~left, + typeof top === 'undefined' ? this.scrollTop : ~~top + ); + }; + + // Element.prototype.scrollBy + Element.prototype.scrollBy = function() { + // avoid action when no arguments are passed + if (arguments[0] === undefined) { + return; + } + + // avoid smooth behavior if not required + if (shouldBailOut(arguments[0]) === true) { + original.elementScroll.call( + this, + arguments[0].left !== undefined + ? ~~arguments[0].left + this.scrollLeft + : ~~arguments[0] + this.scrollLeft, + arguments[0].top !== undefined + ? ~~arguments[0].top + this.scrollTop + : ~~arguments[1] + this.scrollTop + ); + + return; + } + + this.scroll({ + left: ~~arguments[0].left + this.scrollLeft, + top: ~~arguments[0].top + this.scrollTop, + behavior: arguments[0].behavior + }); + }; + + // Element.prototype.scrollIntoView + Element.prototype.scrollIntoView = function() { + // avoid smooth behavior if not required + if (shouldBailOut(arguments[0]) === true) { + original.scrollIntoView.call( + this, + arguments[0] === undefined ? true : arguments[0] + ); + + return; + } + + // LET THE SMOOTHNESS BEGIN! + var scrollableParent = findScrollableParent(this); + var parentRects = scrollableParent.getBoundingClientRect(); + var clientRects = this.getBoundingClientRect(); + + if (scrollableParent !== d.body) { + // reveal element inside parent + smoothScroll.call( + this, + scrollableParent, + scrollableParent.scrollLeft + clientRects.left - parentRects.left, + scrollableParent.scrollTop + clientRects.top - parentRects.top + ); + + // reveal parent in viewport unless is fixed + if (w.getComputedStyle(scrollableParent).position !== 'fixed') { + w.scrollBy({ + left: parentRects.left, + top: parentRects.top, + behavior: 'smooth' + }); + } + } else { + // reveal element in viewport + w.scrollBy({ + left: clientRects.left, + top: clientRects.top, + behavior: 'smooth' + }); + } + }; + } + + { + // commonjs + module.exports = { polyfill: polyfill }; + } + + }()); + }); + + smoothscroll.polyfill(); + var AlpineScrollMagicMethod = { + start: function start() { + Alpine.addMagicProperty('scroll', function () { + return function (target, options) { + if (options === void 0) { + options = {}; + } + + var originalTarget = target; // Check if we specified an offset + + var offset = options.offset ? parseInt(options.offset, 10) : 0; + delete options.offset; // Support integers specified as strings + // We do a strict check first because we don't whant to support things like "100foo" + + if (typeof target === 'string' && /^[0-9]+?/g.test(target)) { + target = parseInt(target, 10); + } // Support for CSS query selector + + + if (typeof target === 'string') { + target = document.querySelector(target); + } // If we got an element, get the y coordinate relative to the document + // This could happens if we trasform a selector or if we pass an Element in, + // for example using $ref['something'] + + + if (target instanceof Element) { + target = Math.floor(target.getBoundingClientRect().top + window.pageYOffset); + } // If target has been converted to the y coordinate or was an object to begin with + // we transform it to a ScrollToOptions dictionary + + + if (Number.isInteger(target)) { + target = { + top: target - offset, + behavior: 'smooth' // default to smooth + + }; + } // At this point target should be either be converted to a ScrollToOptions dictionary + // or should have been an object to begin with. If it isn't, it's time to give up. + + + if (typeof target !== 'object') { + throw Error('Unsupported $scroll target: ', originalTarget); + } // Override the dictionary with the options passed as second params + + + Object.assign(target, options); // Let's scroll eventually + + window.scroll(target); + }; + }); + } + }; + + var alpine$5 = window.deferLoadingAlpine || function (alpine) { + return alpine(); + }; + + window.deferLoadingAlpine = function (callback) { + AlpineScrollMagicMethod.start(); + alpine$5(callback); + }; + + var AlpineTruncateMagicMethod = { + start: function start() { + var _this = this; + + checkForAlpine(); + Alpine.addMagicProperty('truncate', function () { + return function () { + for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) { + parameters[_key] = arguments[_key]; + } + + if (typeof parameters[0] !== 'string') return parameters[0]; // If the second parameter isn't truthy, return the full string + + if (!parameters[1]) return parameters[0]; // if only a number or string is passed in, keep it simple + + if (typeof parameters[1] !== 'object') { + return _this.appendEllipsis(parameters[0].slice(0, parameters[1]), parameters); + } // If words or characters is set, also check that they are truthy. Setting to 0, for example, shoudld show all + + + if (Object.prototype.hasOwnProperty.call(parameters[1], 'words') && parameters[1].words) { + return _this.appendEllipsis(parameters[0].split(' ').splice(0, parameters[1].words).join(' '), parameters); + } + + if (Object.prototype.hasOwnProperty.call(parameters[1], 'characters') && parameters[1].characters) { + return _this.appendEllipsis(parameters[0].slice(0, parameters[1].characters), parameters); + } + + return parameters[0]; + }; + }); + }, + appendEllipsis: function appendEllipsis(string, parameters) { + if (parameters[0].length <= string.length) return string; + var ellipsis = '…'; // 3rd parameter is an optional '…' override (soon to be deprecated) + + if (typeof parameters[2] !== 'undefined') { + ellipsis = parameters[2]; + } // If the second parameter is an object + + + if (Object.prototype.hasOwnProperty.call(parameters[1], 'ellipsis')) { + ellipsis = parameters[1].ellipsis; + } + + return string + ellipsis; + } + }; + + var alpine$6 = window.deferLoadingAlpine || function (alpine) { + return alpine(); + }; + + window.deferLoadingAlpine = function (callback) { + AlpineTruncateMagicMethod.start(); + alpine$6(callback); + }; + + var index = { + AlpineComponentMagicMethod: AlpineComponentMagicMethod, + AlpineFetchMagicMethod: AlpineFetchMagicMethod, + AlpineIntervalMagicMethod: AlpineIntervalMagicMethod, + AlpineRangeMagicMethod: AlpineRangeMagicMethod, + AlpineScreenMagicMethod: AlpineScreenMagicMethod, + AlpineScrollMagicMethod: AlpineScrollMagicMethod, + AlpineTruncateMagicMethod: AlpineTruncateMagicMethod + }; + + return index; + +}))); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js"))) + +/***/ }), + /***/ "./node_modules/alpinejs/dist/alpine.js": /*!**********************************************!*\ !*** ./node_modules/alpinejs/dist/alpine.js ***! @@ -21295,6 +23731,8 @@ module.exports = function(module) { __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js"); +__webpack_require__(/*! alpine-magic-helpers */ "./node_modules/alpine-magic-helpers/dist/index.js"); + __webpack_require__(/*! alpinejs */ "./node_modules/alpinejs/dist/alpine.js"); /***/ }), @@ -21338,8 +23776,8 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -__webpack_require__(/*! /home/chris/PhpstormProjects/pfnj/resources/js/app.js */"./resources/js/app.js"); -module.exports = __webpack_require__(/*! /home/chris/PhpstormProjects/pfnj/resources/css/app.css */"./resources/css/app.css"); +__webpack_require__(/*! /Users/wellc/PhpstormProjects/pfnj/resources/js/app.js */"./resources/js/app.js"); +module.exports = __webpack_require__(/*! /Users/wellc/PhpstormProjects/pfnj/resources/css/app.css */"./resources/css/app.css"); /***/ }) diff --git a/resources/js/app.js b/resources/js/app.js index 2b7b706..31be905 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,3 +1,4 @@ require('./bootstrap'); +require('alpine-magic-helpers'); require('alpinejs'); diff --git a/resources/views/journal-entries/partials/entry-item-input.blade.php b/resources/views/journal-entries/partials/entry-item-input.blade.php index 6f0368e..76371b9 100644 --- a/resources/views/journal-entries/partials/entry-item-input.blade.php +++ b/resources/views/journal-entries/partials/entry-item-input.blade.php @@ -1,4 +1,4 @@ -
+
- +
+ +@once + @push('scripts') + + @endpush +@endonce