UNPKG

@amaui/style

Version:
1,227 lines (1,132 loc) 324 kB
/** @license AmauiStyle v1.1.21 * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.AmauiStyle = {})); })(this, (function (exports) { 'use strict'; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function getAugmentedNamespace(n) { if (n.__esModule) return n; var a = Object.defineProperty({}, '__esModule', {value: true}); Object.keys(n).forEach(function (k) { var d = Object.getOwnPropertyDescriptor(n, k); Object.defineProperty(a, k, d.get ? d : { enumerable: true, get: function () { return n[k]; } }); }); return a; } function commonjsRequire (path) { throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); } var variationWithRepetition$1 = {}; var permutationWithRepetition$1 = {}; var global$1 = (typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}); var is$5 = {exports: {}}; (function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); const optionsDefault = {}; const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined'; const isNodejs = !!(typeof global$1 !== 'undefined' && 'object' !== 'undefined' && module.exports); // Multiple is methods instead of one, // so it's lighter for tree shaking usability reasons function is(type, value, options_ = {}) { var _a; const options = Object.assign(Object.assign({}, optionsDefault), options_); const { variant } = options; const prototype = value && typeof value === 'object' && Object.getPrototypeOf(value); switch (type) { case 'string': return typeof value === 'string'; case 'number': return typeof value === 'number' && !Number.isNaN(value); case 'boolean': return typeof value === 'boolean'; case 'array': return Array.isArray(value); case 'object': const isObject = typeof value === 'object' && !!value && value.constructor === Object; return isObject; // Map, null, WeakMap, Date, etc. case 'object-like': return typeof value === 'object' && (value === null || value.constructor !== Object); case 'class': return ((typeof value === 'object' || typeof value === 'function') && (/class/gi.test(String(value)) || /class/gi.test(String(value === null || value === void 0 ? void 0 : value.constructor)))); case 'function': return !!(value && value instanceof Function); case 'async': // If it's browser avoid calling the method // to see if it's async func or not, // where as in nodejs we have no other choice // that i know of when using transpilation // And also it might not be always correct, as // a method that returns a promise is also async // but we can't know that until the method is called and // we inspect the method's return value return !!(is('function', value) && (isBrowser ? value.constructor.name === 'AsyncFunction' : value() instanceof Promise)); case 'map': return !!(prototype === Map.prototype); case 'weakmap': return !!(prototype === WeakMap.prototype); case 'set': return !!(prototype === Set.prototype); case 'weakset': return !!(prototype === WeakSet.prototype); case 'promise': return !!(prototype === Promise.prototype); case 'int8array': return !!(prototype === Int8Array.prototype); case 'uint8array': return !!(prototype === Uint8Array.prototype); case 'uint8clampedarray': return !!(prototype === Uint8ClampedArray.prototype); case 'int16array': return !!(prototype === Int16Array.prototype); case 'uint16array': return !!(prototype === Uint16Array.prototype); case 'int32array': return !!(prototype === Int32Array.prototype); case 'uint32array': return !!(prototype === Uint32Array.prototype); case 'float32array': return !!(prototype === Float32Array.prototype); case 'float64array': return !!(prototype === Float64Array.prototype); case 'bigint64array': return !!(prototype === BigInt64Array.prototype); case 'biguint64array': return !!(prototype === BigUint64Array.prototype); case 'typedarray': return is('int8array', value) || is('uint8array', value) || is('uint8clampedarray', value) || is('int16array', value) || is('uint16array', value) || is('int32array', value) || is('uint32array', value) || is('float32array', value) || is('float64array', value) || is('bigint64array', value) || is('biguint64array', value); case 'dataview': return !!(prototype === DataView.prototype); case 'arraybuffer': return !!(prototype === ArrayBuffer.prototype); case 'sharedarraybuffer': return typeof SharedArrayBuffer !== 'undefined' && !!(prototype === SharedArrayBuffer.prototype); case 'symbol': return !!(typeof value === 'symbol'); case 'error': return !!(value && value instanceof Error); case 'date': return !!(value && value instanceof Date); case 'regexp': return !!(value && value instanceof RegExp); case 'arguments': return !!(value && value.toString() === '[object Arguments]'); case 'null': return value === null; case 'undefined': return value === undefined; case 'blob': return isBrowser && value instanceof Blob; case 'buffer': return !!(isNodejs && typeof ((_a = value === null || value === void 0 ? void 0 : value.constructor) === null || _a === void 0 ? void 0 : _a.isBuffer) === 'function' && value.constructor.isBuffer(value)); case 'element': if (value) { switch (variant) { case undefined: case 'html': case 'element': return isBrowser && (typeof HTMLElement === 'object' ? value instanceof HTMLElement : value && typeof value === 'object' && value !== null && value.nodeType === 1 && typeof value.nodeName === 'string'); case 'node': return isBrowser && (typeof Node === 'object' ? value instanceof Node : value && typeof value === 'object' && value !== null && typeof value.nodeType === 'number' && typeof value.nodeName === 'string'); case 'react': return value.elementType || value.hasOwnProperty('$$typeof'); default: return false; } } return false; case 'simple': return (is('string', value, options) || is('number', value, options) || is('boolean', value, options) || is('undefined', value, options) || is('null', value, options)); case 'not-array-object': return !is('array', value, options) && !is('object', value, options); default: return false; } } exports.default = is; }(is$5, is$5.exports)); var unique$1 = {}; var getObjectValue$1 = {}; var getObjectPropertyValue = {}; var castParam$3 = {}; var __importDefault$v = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(castParam$3, "__esModule", { value: true }); const is_1$m = __importDefault$v(is$5.exports); const optionsDefault$q = { decode: false, decodeMethod: decodeURIComponent, }; const castParam$2 = (value, options_ = {}) => { const options = Object.assign(Object.assign({}, optionsDefault$q), options_); let newValue = value; try { if ((0, is_1$m.default)('string', value) && options.decode && (0, is_1$m.default)('function', options.decodeMethod)) newValue = options.decodeMethod(value); } catch (error) { } try { if ((0, is_1$m.default)('string', newValue)) { if ('undefined' === newValue) return undefined; if ('NaN' === newValue) return NaN; return JSON.parse(newValue); } return newValue; } catch (error) { } return newValue; }; var _default$q = castParam$3.default = castParam$2; (function (exports) { var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getObjectPropertyValue = void 0; const is_1 = __importDefault(is$5.exports); const castParam_1 = __importDefault(castParam$3); const getObjectPropertyValue = (object, keys) => { if (!object || !keys) return; if ((0, is_1.default)('string', keys)) { const keys_ = keys.split('.').filter(Boolean).map(key => (0, castParam_1.default)(key)); return (0, exports.getObjectPropertyValue)(object, keys_); } if ((0, is_1.default)('array', keys)) { const key = keys[0]; if (keys.length === 1) return object[key]; if (object.hasOwnProperty(key)) return (0, exports.getObjectPropertyValue)(object[key], keys.slice(1)); } }; exports.getObjectPropertyValue = getObjectPropertyValue; exports.default = exports.getObjectPropertyValue; }(getObjectPropertyValue)); var __importDefault$u = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(getObjectValue$1, "__esModule", { value: true }); const getObjectPropertyValue_1 = __importDefault$u(getObjectPropertyValue); const getObjectValue = (object, ...args) => { if (!object || !args.length) return; let value; const keys = args.filter(Boolean); for (const key of keys) { value = (0, getObjectPropertyValue_1.default)(object, key); if (value !== undefined) return value; } }; getObjectValue$1.default = getObjectValue; var __importDefault$t = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(unique$1, "__esModule", { value: true }); const is_1$l = __importDefault$t(is$5.exports); const getObjectValue_1 = __importDefault$t(getObjectValue$1); /** * It returns an array with unique simple values * and / or array and object values. * * Referenced values are only compared based on * values in those reference type values based on array * of keys provided in the second argument in the method. * * Uniqueness of array and object values is separatelly * evaluated based on keys value and returned in the result. */ const unique = (object, ...args) => { const cache = { simple: [], array: [], object: [], }; const output = []; if ((0, is_1$l.default)('array', object)) { object.forEach(item => { const isNotArrayObject = (0, is_1$l.default)('not-array-object', item); const isArray = (0, is_1$l.default)('array', item); const value = (isNotArrayObject || !args.length) ? item : (0, getObjectValue_1.default)(item, ...args); const cacheArray = cache[isNotArrayObject ? 'simple' : isArray ? 'array' : 'object']; const exists = cacheArray.find(cacheItem => value === cacheItem); if (!exists && value !== undefined) { output.push(item); cache[isNotArrayObject ? 'simple' : isArray ? 'array' : 'object'].push(value); } }); } return output; }; var _default$p = unique$1.default = unique; var __importDefault$s = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(permutationWithRepetition$1, "__esModule", { value: true }); const is_1$k = __importDefault$s(is$5.exports); const unique_1 = __importDefault$s(unique$1); const optionsDefault$p = { response: 'array', }; // m - array // m! / a! * b! * c! ... function permutationWithRepetition(value_, options_ = {}) { const options = Object.assign(Object.assign({}, optionsDefault$p), options_); if ((0, is_1$k.default)('array', value_)) { const value = (0, unique_1.default)(value_); const length = value.length; const items = (0, is_1$k.default)('number', options.items) ? options.items : length; if (items < 1) return [value]; if (items === 1) return value.map(item_ => [item_]); const item = new Array(items).fill(0); let index = items - 2; const response = []; // Starts with all 0 indexes for all items // it loops for the last position and makes each item for each index // then, it moves to the left and increments the index by 1 // once item on left index increment moves over amount of items // it resets to 0 index, and then it moves left and increments that item // using same methodology, etc. until item at index 0 has index value === items.length if (options.response === 'array') { while (index >= 0) { // Reset index = items - 2; for (let i = 0; i < length; i++) { item[items - 1] = i; response.push(item.map(index_ => value[index_])); } // Move to the left of the values while (true) { if (item[index] === length - 1) { item[index] = 0; index--; if (index < 0) break; } else { item[index]++; break; } } } return response; } if (options.response === 'yield') return function* () { while (index >= 0) { // Reset index = items - 2; for (let i = 0; i < length; i++) { item[items - 1] = i; const item_ = item.map(index_ => value[index_]); yield item_; response.push(item_); } // Move to the left of the values while (true) { if (item[index] === length - 1) { item[index] = 0; index--; if (index < 0) break; } else { item[index]++; break; } } } return response; }; } } permutationWithRepetition$1.default = permutationWithRepetition; var __importDefault$r = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(variationWithRepetition$1, "__esModule", { value: true }); const permutationWithRepetition_1 = __importDefault$r(permutationWithRepetition$1); const optionsDefault$o = { response: 'array', }; // m - array, n - items // m ** n function variationWithRepetition(value_, items = 0, options_ = {}) { const options = Object.assign(Object.assign({}, optionsDefault$o), options_); return (0, permutationWithRepetition_1.default)(value_, Object.assign(Object.assign({}, options), { items })); } var _default$o = variationWithRepetition$1.default = variationWithRepetition; var getEnvironment$3 = {}; Object.defineProperty(getEnvironment$3, "__esModule", { value: true }); const getEnvironment$2 = () => { if (typeof self !== 'undefined') return self; if (typeof window !== 'undefined') return window; if (typeof global$1 !== 'undefined') return global$1; }; var _default$n = getEnvironment$3.default = getEnvironment$2; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var is$4 = {exports: {}}; (function (module, exports) { Object.defineProperty(exports, "__esModule", { value: true }); const optionsDefault = {}; const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined'; const isNodejs = !!(typeof global$1 !== 'undefined' && 'object' !== 'undefined' && module.exports); // Multiple is methods instead of one, // so it's lighter for tree shaking usability reasons function is(type, value, options_ = {}) { var _a; const options = Object.assign(Object.assign({}, optionsDefault), options_); const { variant } = options; const prototype = value && typeof value === 'object' && Object.getPrototypeOf(value); switch (type) { case 'string': return typeof value === 'string'; case 'number': return typeof value === 'number' && !Number.isNaN(value); case 'boolean': return typeof value === 'boolean'; case 'array': return Array.isArray(value); case 'object': const isObject = typeof value === 'object' && !!value && value.constructor === Object; return isObject; // Map, null, WeakMap, Date, etc. case 'object-like': return typeof value === 'object' && (value === null || value.constructor !== Object); case 'class': return ((typeof value === 'object' || typeof value === 'function') && (/class/gi.test(String(value)) || /class/gi.test(String(value === null || value === void 0 ? void 0 : value.constructor)))); case 'function': return !!(value && value instanceof Function); case 'async': // If it's browser avoid calling the method // to see if it's async func or not, // where as in nodejs we have no other choice // that i know of when using transpilation // And also it might not be always correct, as // a method that returns a promise is also async // but we can't know that until the method is called and // we inspect the method's return value return !!(is('function', value) && (isBrowser ? value.constructor.name === 'AsyncFunction' : value() instanceof Promise)); case 'map': return !!(prototype === Map.prototype); case 'weakmap': return !!(prototype === WeakMap.prototype); case 'set': return !!(prototype === Set.prototype); case 'weakset': return !!(prototype === WeakSet.prototype); case 'promise': return !!(prototype === Promise.prototype); case 'int8array': return !!(prototype === Int8Array.prototype); case 'uint8array': return !!(prototype === Uint8Array.prototype); case 'uint8clampedarray': return !!(prototype === Uint8ClampedArray.prototype); case 'int16array': return !!(prototype === Int16Array.prototype); case 'uint16array': return !!(prototype === Uint16Array.prototype); case 'int32array': return !!(prototype === Int32Array.prototype); case 'uint32array': return !!(prototype === Uint32Array.prototype); case 'float32array': return !!(prototype === Float32Array.prototype); case 'float64array': return !!(prototype === Float64Array.prototype); case 'bigint64array': return !!(prototype === BigInt64Array.prototype); case 'biguint64array': return !!(prototype === BigUint64Array.prototype); case 'typedarray': return is('int8array', value) || is('uint8array', value) || is('uint8clampedarray', value) || is('int16array', value) || is('uint16array', value) || is('int32array', value) || is('uint32array', value) || is('float32array', value) || is('float64array', value) || is('bigint64array', value) || is('biguint64array', value); case 'dataview': return !!(prototype === DataView.prototype); case 'arraybuffer': return !!(prototype === ArrayBuffer.prototype); case 'sharedarraybuffer': return typeof SharedArrayBuffer !== 'undefined' && !!(prototype === SharedArrayBuffer.prototype); case 'symbol': return !!(typeof value === 'symbol'); case 'error': return !!(value && value instanceof Error); case 'date': return !!(value && value instanceof Date); case 'regexp': return !!(value && value instanceof RegExp); case 'arguments': return !!(value && value.toString() === '[object Arguments]'); case 'null': return value === null; case 'undefined': return value === undefined; case 'blob': return isBrowser && value instanceof Blob; case 'buffer': return !!(isNodejs && typeof ((_a = value === null || value === void 0 ? void 0 : value.constructor) === null || _a === void 0 ? void 0 : _a.isBuffer) === 'function' && value.constructor.isBuffer(value)); case 'element': if (value) { switch (variant) { case undefined: case 'html': case 'element': return isBrowser && (typeof HTMLElement === 'object' ? value instanceof HTMLElement : value && typeof value === 'object' && value !== null && value.nodeType === 1 && typeof value.nodeName === 'string'); case 'node': return isBrowser && (typeof Node === 'object' ? value instanceof Node : value && typeof value === 'object' && value !== null && typeof value.nodeType === 'number' && typeof value.nodeName === 'string'); case 'react': return value.elementType || value.hasOwnProperty('$$typeof'); default: return false; } } return false; case 'simple': return (is('string', value, options) || is('number', value, options) || is('boolean', value, options) || is('undefined', value, options) || is('null', value, options)); case 'not-array-object': return !is('array', value, options) && !is('object', value, options); default: return false; } } exports.default = is; }(is$4, is$4.exports)); var is$3 = /*@__PURE__*/getDefaultExportFromCjs(is$4.exports); var copy$5 = {}; Object.defineProperty(copy$5, "__esModule", { value: true }); const isArray$2 = value => Array.isArray(value); const isObject$2 = value => typeof value === 'object' && !!value && value.constructor === Object; // It keeps the references of the methods and classes, // unlike JSON.stringify usually used for deep simple copy const copy$4 = (value) => { if (isArray$2(value)) return value.map(item => copy$4(item)); if (isObject$2(value)) { const newValue = {}; Object.keys(value).forEach(key => newValue[key] = copy$4(value[key])); return newValue; } return value; }; var _default$m = copy$5.default = copy$4; var _try$1 = {}; var getEnvironment$1 = {}; Object.defineProperty(getEnvironment$1, "__esModule", { value: true }); const getEnvironment = () => { if (typeof self !== 'undefined') return self; if (typeof window !== 'undefined') return window; if (typeof global$1 !== 'undefined') return global$1; }; getEnvironment$1.default = getEnvironment; var setObjectValue$3 = {}; var cleanValue$1 = {}; var capitalize$4 = {}; var __importDefault$q = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(capitalize$4, "__esModule", { value: true }); const is_1$j = __importDefault$q(is$4.exports); const capitalize$3 = (value) => { if ((0, is_1$j.default)('string', value)) return `${value.charAt(0).toUpperCase()}${value.slice(1)}`; return value; }; capitalize$4.default = capitalize$3; (function (exports) { var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.optionsDefault = void 0; const is_1 = __importDefault(is$4.exports); const capitalize_1 = __importDefault(capitalize$4); exports.optionsDefault = { filters: [',', '.', '-', '_', '\s+'], replaceWith: ' ', trim: true, }; const cleanValue = (value_, options_ = {}) => { try { const options = Object.assign(Object.assign({}, exports.optionsDefault), options_); // Few predefined options // for className cammel case to regular // css property names convert if (options.className) { options.replaceWith = '-'; options.cammelCaseTransform = true; options.lowercase = true; } if ((0, is_1.default)('string', value_)) { let value = value_; if (options.url) { const parts = value.split('?').filter(Boolean); let path = parts[0]; const query = parts[1]; if (path.slice(-1) === '/') path = path.slice(0, -1); value = query ? [path, query].join('?') : path; return value; } if (options.cammelCaseTransform) value = value.split(/(?=[A-Z])/g).join(options.replaceWith || ' '); options.filters.forEach(filter => { const expression = `\\${filter}`; const regexp = new RegExp(expression, 'g'); value = value.replace(regexp, options.replaceWith || ' '); }); if (options.trim) value = value.trim(); if (options.capitalize) value = (0, capitalize_1.default)(value); if (options.lowercase) value = value.toLocaleLowerCase(); return value; } return value_; } catch (error) { } return value_; }; exports.default = cleanValue; }(cleanValue$1)); var castParam$1 = {}; var __importDefault$p = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(castParam$1, "__esModule", { value: true }); const is_1$i = __importDefault$p(is$4.exports); const optionsDefault$n = { decode: false, decodeMethod: decodeURIComponent, }; const castParam = (value, options_ = {}) => { const options = Object.assign(Object.assign({}, optionsDefault$n), options_); let newValue = value; try { if ((0, is_1$i.default)('string', value) && options.decode && (0, is_1$i.default)('function', options.decodeMethod)) newValue = options.decodeMethod(value); } catch (error) { } try { if ((0, is_1$i.default)('string', newValue)) { if ('undefined' === newValue) return undefined; if ('NaN' === newValue) return NaN; return JSON.parse(newValue); } return newValue; } catch (error) { } return newValue; }; castParam$1.default = castParam; var __importDefault$o = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(setObjectValue$3, "__esModule", { value: true }); const is_1$h = __importDefault$o(is$4.exports); const cleanValue_1$1 = __importDefault$o(cleanValue$1); const castParam_1$6 = __importDefault$o(castParam$1); const optionsDefault$m = { valueOverride: false, }; const setObjectValue$2 = (object, keys = '', value = undefined, options_ = {}) => { const options = Object.assign(Object.assign({}, optionsDefault$m), options_); if (!(object || keys)) return object; if ((0, is_1$h.default)('string', keys)) { const keys_ = keys.split('.').filter(Boolean).map(key => (0, castParam_1$6.default)(key)); return setObjectValue$2(object, keys_, value, options); } if ((0, is_1$h.default)('array', keys)) { const key = keys[0]; const keyClean = (0, cleanValue_1$1.default)(String(key), { filters: ['.', ','], replaceWith: '' }); if (keys.length === 1 && value !== undefined) { if (((0, is_1$h.default)('array', object) && (0, is_1$h.default)('number', key)) || ((0, is_1$h.default)('object', object) && (0, is_1$h.default)('string', key))) { object[(0, is_1$h.default)('string', key) ? keyClean : key] = value; } } else { // Add array or object as a value of the key, if that key doesn't exist atm if (!object.hasOwnProperty(key) || options.valueOverride) object[keyClean] = (0, is_1$h.default)('number', keys[1]) ? [] : {}; const value_ = object[keyClean]; // If we are trying to set a deeply nested value on a // simple value type, meaning if it's not an array or an object, // To override existing value use valueOverride: true option if (!((0, is_1$h.default)('object', value_) || (0, is_1$h.default)('array', value_))) return object; return setObjectValue$2(object[key], keys.slice(1), value, options); } } return object; }; setObjectValue$3.default = setObjectValue$2; var __importDefault$n = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(_try$1, "__esModule", { value: true }); const is_1$g = __importDefault$n(is$4.exports); const getEnvironment_1$1 = __importDefault$n(getEnvironment$1); const setObjectValue_1$1 = __importDefault$n(setObjectValue$3); const optionsDefault$l = {}; const Try$1 = (value, options_ = {}) => { var _a, _b, _c, _d; const options = Object.assign(Object.assign({}, optionsDefault$l), options_); try { return (0, is_1$g.default)('function', value) ? value() : undefined; } catch (error) { if (options.log) { console.error('Try: ', error); const env = (0, getEnvironment_1$1.default)(); if (((_a = env.AMAUI) === null || _a === void 0 ? void 0 : _a.env) === 'test') { if (!((_d = (_c = (_b = env.AMAUI) === null || _b === void 0 ? void 0 : _b.test) === null || _c === void 0 ? void 0 : _c.Try) === null || _d === void 0 ? void 0 : _d.logs)) (0, setObjectValue_1$1.default)(env, 'AMAUI.test.Try.logs', []); env.AMAUI.test.Try.logs.push(error); } } } }; var _default$l = _try$1.default = Try$1; const optionsDefault$k = { emit: { priorValue: true, copy: false, pre: {}, post: {} } }; class AmauiSubscription { constructor(value) { let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _defineProperty(this, "methods", []); this.value = value; this.options = options; this.options = { ...optionsDefault$k, ...this.options }; } get length() { return this.methods.length; } emit() { var _this$options$emit, _this$options$emit$pr, _this$options$emit$po; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } const value = args; // Important for use cases, // to be available pre emit, // Save value as last emitted value as a previous state optionally if ((_this$options$emit = this.options.emit) !== null && _this$options$emit !== void 0 && _this$options$emit.priorValue) this.value = value.length === 1 ? value[0] : value; // Pre // Value might be of simple type so we have to assign a new value to the value if (is$3('function', (_this$options$emit$pr = this.options.emit.pre) === null || _this$options$emit$pr === void 0 ? void 0 : _this$options$emit$pr.method)) this.options.emit.pre.method(...value); this.methods.map(method => { // Whether to send a copied value version or not, // it might be useful since if value is of reference type, // methods in the beginning might update the value, // and other following methods wouldn't get the // same value as it was sent to the first method. if (is$3('function', method)) method(...(this.options.emit.copy ? _default$m(value) : value)); }); // Post // Value might be of simple type so we have to assign a new value to the value if (is$3('function', (_this$options$emit$po = this.options.emit.post) === null || _this$options$emit$po === void 0 ? void 0 : _this$options$emit$po.method)) this.options.emit.post.method(...value); } forEach() { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } this.methods.forEach(method => _default$l(() => method(...args))); } map(value_) { if (!this.methods.length) return; let value = value_; for (const method of this.methods) value = _default$l(() => method(value)); return value; } subscribe(method) { if (this.methods.indexOf(method) === -1) this.methods.push(method); } unsubscribe(method) { if (this.methods.indexOf(method) > -1) { const index = this.methods.findIndex(method_ => method_ === method); if (index > -1) this.methods.splice(index, 1); } } } var AmauiSubscription$1 = AmauiSubscription; const cammelCaseToKebabCase = value => is$2('string', value) ? value.replace(/[A-Z]/g, v => "-".concat(v[0])).toLowerCase() : value; const kebabCasetoCammelCase = value => is$2('string', value) ? value.replace(/-./g, v => v[1] !== undefined ? v[1].toUpperCase() : '') : value; const capitalizedCammelCase = value => capitalize$2(kebabCasetoCammelCase(value)); const capitalize$2 = value => is$2('string', value) ? value.charAt(0).toUpperCase() + value.slice(1) : value; const is$2 = (version, value) => { switch (version) { case 'string': return typeof value === 'string'; case 'number': return typeof value === 'number' && !Number.isNaN(value); case 'array': return Array.isArray(value); case 'boolean': return typeof value === 'boolean'; case 'null': return value === null; case 'undefined': return value === undefined; case 'object': const isObject = typeof value === 'object' && !!value && value.constructor === Object; return isObject; case 'function': return !!(value && value instanceof Function); case 'simple': return is$2('string', value) || is$2('number', value) || is$2('boolean', value) || is$2('undefined', value) || is$2('null', value); default: return; } }; const isAmauiSubscription = value => value instanceof AmauiSubscription$1 || is$2('function', value === null || value === void 0 ? void 0 : value.emit); const getRefs = value => { const items = []; if (is$2('string', value)) { const regex = /\$[a-zA-Z1-9_]+/g; items.push(...(value.match(regex) || []).map(item => item.replace('$', ''))); } return items; }; const valueResolve = (property, value, amauiStyle) => { const response = { value: [], options: {} }; // Mange all the values if (is$2('string', property) && !!property.length && value !== undefined && amauiStyle) { // String if (is$2('string', value)) response.value = [value]; // Number else if (is$2('number', value)) { var _amauiStyle$subscript; const unit = (_amauiStyle$subscript = amauiStyle.subscriptions.rule.unit.map({ property, value })) === null || _amauiStyle$subscript === void 0 ? void 0 : _amauiStyle$subscript.value; response.value = [(unit === null || unit === void 0 ? void 0 : unit.value) || value]; } // Array of simple else if (is$2('array', value) && value.every(item => is$2('simple', item))) { response.value = [value.flatMap(item => valueResolve(property, item, amauiStyle).value).join(' ')]; } // Array of arrays // Array of objects else if (is$2('array', value) && value.every(item => is$2('array', item) || is$2('object', item))) { response.value = [value.flatMap(item => valueResolve(property, item, amauiStyle).value).join(', ')]; } // Object else if (is$2('object', value)) { // Object value if (value.value) { const fallbacks = (value.fallbacks || []).flatMap(item => valueResolve(property, item, amauiStyle).value); response.value = [fallbacks, valueResolve(property, value.value, amauiStyle).value].flat().filter(Boolean); if (value.rule) response.options.rule = value.rule; } else { var _amauiStyle$subscript2; // Value plugins const value_ = (_amauiStyle$subscript2 = amauiStyle.subscriptions.rule.value.map({ property, value })) === null || _amauiStyle$subscript2 === void 0 ? void 0 : _amauiStyle$subscript2.value; response.value = value_ || []; } } // Method // AmauiSubscription // For methods and AmauiSubscription leave as is // these are only used during add method else response.value = [value]; } return response; }; const dynamic = value => is$2('function', value) || isAmauiSubscription(value) || is$2('object', value) && Object.keys(value).some(prop => dynamic(value[prop])); function* makeName() { let length_ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2; let input_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'abcdefghijklmnopqrstuvwxyz'; const input = is$2('array', input_) ? input_ : input_.split(''); let length = length_; let value; let methodNameGenerator = _default$o(input, length, { response: 'yield' })(); while (true) { var _value; value = methodNameGenerator.next(); if ((_value = value) !== null && _value !== void 0 && _value.done) { methodNameGenerator = _default$o(input, ++length, { response: 'yield' })(); value = methodNameGenerator.next(); } yield value.value.join(''); } } const pxToRem = function (value) { let htmlFontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 16; return Number((value / htmlFontSize).toFixed(4)); }; const env$2 = _default$n(); env$2.amaui_methods = { makeName: makeName() }; const names = value => { if (is$2('object', value)) { // Update styles, className and class if (!value.hasOwnProperty('className')) Object.defineProperty(value, 'className', { get: function () { return Object.keys(value.classNames).map(item => value.classNames[item]).join(' '); } }); if (!value.hasOwnProperty('class')) Object.defineProperty(value, 'class', { get: function () { return Object.keys(value.classes).map(item => value.classes[item]).join(' '); } }); if (!value.hasOwnProperty('styles')) value.styles = function () { const values = []; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } args.forEach(arg => { if (value.classes[arg]) values.push(value.classes[arg]); }); return values.join(' '); }; return value; } return value; }; let i$1 = 0; const getID = () => "".concat(i$1++, "-").concat(new Date().getTime()); const minify = value => value.replace(/\n/g, '').replace(/ ?(\{|:|,|>|~) ?/g, '$1').replace(/;(\})/g, '$1'); var copy$3 = {}; Object.defineProperty(copy$3, "__esModule", { value: true }); const isArray$1 = value => Array.isArray(value); const isObject$1 = value => typeof value === 'object' && !!value && value.constructor === Object; // It keeps the references of the methods and classes, // unlike JSON.stringify usually used for deep simple copy const copy$2 = (value) => { if (isArray$1(value)) return value.map(item => copy$2(item)); if (isObject$1(value)) { const newValue = {}; Object.keys(value).forEach(key => newValue[key] = copy$2(value[key])); return newValue; } return value; }; var _default$k = copy$3.default = copy$2; var element$1 = {}; var isEnvironment$1 = {}; var __importDefault$m = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(isEnvironment$1, "__esModule", { value: true }); const is_1$f = __importDefault$m(is$5.exports); function isEnvironment(type, value) { let value_; switch (type) { case 'browser': return typeof window !== 'undefined' && typeof window.document !== 'undefined'; case 'worker': return typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope; case 'nodejs': return (new Function('try {return this===global;}catch(e){return false;}'))(); case 'localhost': value_ = value !== undefined ? value : (isEnvironment('browser') && window.location.hostname); return (0, is_1$f.default)('string', value_) && ['localhost', '127.0.0.1'].some(value__ => value_.indexOf(value__) > -1); default: return false; } } var _default$j = isEnvironment$1.default = isEnvironment; var _try = {}; var setObjectValue$1 = {}; var cleanValue = {}; var capitalize$1 = {}; var __importDefault$l = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(capitalize$1, "__esModule", { value: true }); const is_1$e = __importDefault$l(is$5.exports); const capitalize = (value) => { if ((0, is_1$e.default)('string', value)) return `${value.charAt(0).toUpperCase()}${value.slice(1)}`; return value; }; capitalize$1.default = capitalize; (function (exports) { var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.optionsDefault = void 0; const is_1 = __importDefault(is$5.exports); const capitalize_1 = __importDefault(capitalize$1); exports.optionsDefault = { filters: [',', '.', '-', '_', '\s+'], replaceWith: ' ', trim: true, }; const cleanValue = (value_, options_ = {}) => { try { const options = Object.assign(Object.assign({}, exports.optionsDefault), options_); // Few predefined options // for className cammel case to regular // css property names convert if (options.className) { options.replaceWith = '-'; options.cammelCaseTransform = true; options.lowercase = true; } if ((0, is_1.default)('string', value_)) { let value = value_; if (options.url) { const parts = value.split('?').filter(Boolean); let path = parts[0]; const query = parts[1]; if (path.slice(-1) === '/') path = path.slice(0, -1); value = query ? [path, query].join('?') : path; return value; } if (options.cammelCaseTransform) value = value.split(/(?=[A-Z])/g).join(options.replaceWith || ' '); options.filters.forEach(filter => { const expression = `\\${filter}`; const regexp = new RegExp(expression, 'g'); value = value.replace(regexp, options.replaceWith || ' '); }); if (options.trim) value = value.trim(); if (options.capitalize) value = (0, capitalize_1.default)(value); if (options.lowercase) value = value.toLocaleLowerCase(); return value; } return value_; } catch (error) { } return value_; }; exports.default = cleanValue; }(cleanValue)); var __importDefault$k = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(setObjectValue$1, "__esModule", { value: true }); const is_1$d = __importDefault$k(is$5.exports); const cleanValue_1 = __importDefault$k(cleanValue); const castParam_1$5 = __importDefault$k(castParam$3); const optionsDefault$j = { valueOverride: false, }; const setObjectValue = (object, keys = '', value = undefined, options_ = {}) => { const options = Object.assign(Object.assign({}, optionsDefault$j), options_); if (!(object || keys)) return object; if ((0, is_1$d.default)('string', keys)) { const keys_ = keys.split('.').filter(Boolean).map(key => (0, castParam_1$5.default)(key)); return setObjectValue(object, keys_, value, options); } if ((0, is_1$d.default)('array', keys)) { const key = keys[0]; const keyClean = (0, cleanValue_1.default)(String(key), { filters: ['.', ','], replaceWith: '' }); if (keys.length === 1 && value !== undefined) { if (((0, is_1$d.default)('array', object) && (0, is_1$d.default)('number', key)) || ((0, is_1$d.default)('object', object) && (0, is_1$d.default)('string', key))) { object[(0, is_1$d.default)('string', key) ? keyClean : key] = value; } } else { // Add array or object as a value of the key, if that key doesn't exist atm if (!object.hasOwnProperty(key) || options.valueOverride) object[keyClean] = (0, is_1$d.default)('number', keys[1]) ? [] : {}; const value_ = object[keyClean]; // If we are trying to set a deeply nested value on a // simple value type, meaning if it's not an array or an object, // To override existing value use valueOverride: true option if (!((0, is_1$d.default)('object', value_) || (0, is_1$d.default)('array', value_))) return object; return setObjectValue(object[key], keys.slice(1), value, options); } } return object; }; setObjectValue$1.default = setObjectValue; var __importDefault$j = (undefined && undefined.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(_try, "__esModule", { value: true }); const is_1$c = __importDefault$j(is$5.exports); const getEnvironment_1 = __importDefault$j(getEnvironment$3); const setObjectValue_1 = __importDefault$j(setObjectValue$1); const optionsDefault$i = {}; const Try = (value, options_ = {}) => { var _a, _b, _c, _d; const options = Object.assign(Object.assign({}, optio