@onesy/style-react
Version:
Onesy CSS in JS styling solution for React
9,506 lines • 347 kB
JavaScript
/** @license StyleReact v1.0.2
*
* 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, require('react')) :
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.StyleReact = {}, global.React));
})(this, (function (exports, React) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
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$3 = {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$3, is$3.exports));
var is$2 = /*@__PURE__*/getDefaultExportFromCjs(is$3.exports);
var unique$1 = {};
var getObjectValue$1 = {};
var getObjectPropertyValue = {};
var castParam$3 = {};
var __importDefault$r = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(castParam$3, "__esModule", { value: true });
const is_1$i = __importDefault$r(is$3.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$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;
};
var _default$n = 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$3.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$q = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(getObjectValue$1, "__esModule", { value: true });
const getObjectPropertyValue_1 = __importDefault$q(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$p = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(unique$1, "__esModule", { value: true });
const is_1$h = __importDefault$p(is$3.exports);
const getObjectValue_1 = __importDefault$p(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$h.default)('array', object)) {
object.forEach(item => {
const isNotArrayObject = (0, is_1$h.default)('not-array-object', item);
const isArray = (0, is_1$h.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$m = unique$1.default = unique;
var __importDefault$o = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(permutationWithRepetition$1, "__esModule", { value: true });
const is_1$g = __importDefault$o(is$3.exports);
const unique_1 = __importDefault$o(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$g.default)('array', value_)) {
const value = (0, unique_1.default)(value_);
const length = value.length;
const items = (0, is_1$g.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$n = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(variationWithRepetition$1, "__esModule", { value: true });
const permutationWithRepetition_1 = __importDefault$n(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$l = variationWithRepetition$1.default = variationWithRepetition;
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;
};
var _default$k = getEnvironment$1.default = getEnvironment;
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function toPropertyKey(t) {
var i = toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
function _defineProperty(e, r, t) {
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[r] = t, e;
}
var copy$1 = {};
Object.defineProperty(copy$1, "__esModule", { value: true });
const isArray = value => Array.isArray(value);
const isObject = 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 = (value, values_) => {
const values = !values_ ? new WeakSet() : values_;
// Ref circular value
if (values.has(value))
return value;
if (isObject(value) || isArray(value))
values.add(value);
if (isArray(value))
return value.map(item => copy(item, values));
if (isObject(value)) {
const newValue = {};
Object.keys(value).forEach(key => newValue[key] = copy(value[key], values));
return newValue;
}
return value;
};
var _default$j = copy$1.default = copy;
var _try = {};
var setObjectValue$1 = {};
var cleanValue = {};
var capitalize$2 = {};
var __importDefault$m = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(capitalize$2, "__esModule", { value: true });
const is_1$f = __importDefault$m(is$3.exports);
const capitalize$1 = (value) => {
if ((0, is_1$f.default)('string', value))
return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
return value;
};
capitalize$2.default = capitalize$1;
(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$3.exports);
const capitalize_1 = __importDefault(capitalize$2);
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$l = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(setObjectValue$1, "__esModule", { value: true });
const is_1$e = __importDefault$l(is$3.exports);
const cleanValue_1 = __importDefault$l(cleanValue);
const castParam_1$5 = __importDefault$l(castParam$3);
const optionsDefault$n = {
valueOverride: false
};
const setObjectValue = (object, keys = '', value = undefined, options_ = {}) => {
const options = Object.assign(Object.assign({}, optionsDefault$n), options_);
if (!(object || keys))
return object;
if ((0, is_1$e.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$e.default)('array', keys)) {
const key = keys[0];
const keyClean = (0, cleanValue_1.default)(String(key), { filters: ['.', ','], replaceWith: '' });
if (keys.length === 1) {
if (((0, is_1$e.default)('array', object) && (0, is_1$e.default)('number', key)) ||
(0, is_1$e.default)('object', object)) {
// Add array or object as a value of the key, if that key doesn't exist atm
if (!(object === null || object === void 0 ? void 0 : object.hasOwnProperty(key)) ||
options.valueOverride)
object[keyClean] = (0, is_1$e.default)('number', keys[1]) ? [] : {};
object[(0, is_1$e.default)('string', key) ? keyClean : key] = value;
}
}
else {
if (((0, is_1$e.default)('array', object) && (0, is_1$e.default)('number', key)) ||
(0, is_1$e.default)('object', object)) {
// Add array or object as a value of the key, if that key doesn't exist atm
if (!(object === null || object === void 0 ? void 0 : object.hasOwnProperty(key)) ||
options.valueOverride)
object[keyClean] = (0, is_1$e.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$e.default)('object', value_) || (0, is_1$e.default)('array', value_)))
return object;
return setObjectValue(object[key], keys.slice(1), value, options);
}
}
return object;
};
setObjectValue$1.default = setObjectValue;
var __importDefault$k = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(_try, "__esModule", { value: true });
const is_1$d = __importDefault$k(is$3.exports);
const getEnvironment_1 = __importDefault$k(getEnvironment$1);
const setObjectValue_1 = __importDefault$k(setObjectValue$1);
const optionsDefault$m = {};
const Try = (value, options_ = {}) => {
var _a, _b, _c, _d;
const options = Object.assign(Object.assign({}, optionsDefault$m), options_);
try {
return (0, is_1$d.default)('function', value) ? value() : undefined;
}
catch (error) {
if (options.log) {
console.error('Try: ', error);
const env = (0, getEnvironment_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.default)(env, 'AMAUI.test.Try.logs', []);
env.AMAUI.test.Try.logs.push(error);
}
}
}
};
var _default$i = _try.default = Try;
const optionsDefault$l = {
emit: {
priorValue: true,
copy: false,
pre: {},
post: {}
}
};
class OnesySubscription {
constructor(value) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_defineProperty(this, "methods", []);
_defineProperty(this, "push", this.emit);
this.value = value;
this.options = options;
this.options = { ...optionsDefault$l,
...this.options
};
}
get length() {
return this.methods.length;
}
emit(value) {
var _this$options$emit, _this$options$emit$pr, _this$options$emit$po;
for (var _len = arguments.length, other = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
other[_key - 1] = arguments[_key];
}
const values = [value, ...other]; // 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 = values.length === 1 ? values[0] : values; // Pre
// Value might be of simple type so we have to assign a new value to the value
if (is$2('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(...values); // 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.
const methodValue = this.options.emit.copy ? _default$j(values) : values;
const methods = this.methods.filter(method => is$2('function', method)); // Emit to methods
for (const method of methods) _default$i(() => method(...methodValue)); // Post
// Value might be of simple type so we have to assign a new value to the value
if (is$2('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(...values);
} // alias
forEach() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
this.methods.forEach(method => _default$i(() => method(...args)));
}
map(value_) {
if (!this.methods.length) return;
let value = value_;
for (const method of this.methods) value = _default$i(() => method(value));
return value;
}
subscribe(method) {
if (is$2('function', method) && this.methods.indexOf(method) === -1) this.methods.push(method);
const instance = this;
return {
unsubscribe: () => {
instance.unsubscribe(method);
}
};
}
unsubscribe(method) {
if (is$2('function', method) && this.methods.indexOf(method) > -1) {
const index = this.methods.findIndex(method_ => method_ === method);
if (index > -1) this.methods.splice(index, 1);
}
}
}
var OnesySubscription$1 = OnesySubscription;
const cammelCaseToKebabCase = value => is$1('string', value) ? value.replace(/[A-Z]/g, v => "-".concat(v[0])).toLowerCase() : value;
const kebabCasetoCammelCase = value => is$1('string', value) ? value.replace(/-./g, v => v[1] !== undefined ? v[1].toUpperCase() : '') : value;
const capitalizedCammelCase = value => capitalize(kebabCasetoCammelCase(value));
const capitalize = value => is$1('string', value) ? value.charAt(0).toUpperCase() + value.slice(1) : value;
const is$1 = (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$1('string', value) || is$1('number', value) || is$1('boolean', value) || is$1('undefined', value) || is$1('null', value);
default:
return;
}
};
const isOnesySubscription = value => value instanceof OnesySubscription$1 || is$1('function', value === null || value === void 0 ? void 0 : value.emit);
const getRefs = value => {
const items = [];
if (is$1('string', value)) {
const regex = /\$[a-zA-Z1-9_]+/g;
items.push(...(value.match(regex) || []).map(item => item.replace('$', '')));
}
return items;
};
const valueResolve = (property, value, onesyStyle) => {
const response = {
value: [],
options: {}
}; // Mange all the values
if (is$1('string', property) && !!property.length && value !== undefined && onesyStyle) {
// String
if (is$1('string', value)) response.value = [value]; // Number
else if (is$1('number', value)) {
var _onesyStyle$subscript;
const unit = (_onesyStyle$subscript = onesyStyle.subscriptions.rule.unit.map({
property,
value
})) === null || _onesyStyle$subscript === void 0 ? void 0 : _onesyStyle$subscript.value;
response.value = [(unit === null || unit === void 0 ? void 0 : unit.value) || value];
} // Array of simple
else if (is$1('array', value) && value.every(item => is$1('simple', item))) {
response.value = [value.flatMap(item => valueResolve(property, item, onesyStyle).value).join(' ')];
} // Array of arrays
// Array of objects
else if (is$1('array', value) && value.every(item => is$1('array', item) || is$1('object', item))) {
response.value = [value.flatMap(item => valueResolve(property, item, onesyStyle).value).join(', ')];
} // Object
else if (is$1('object', value)) {
// Object value
if (value.value) {
const fallbacks = (value.fallbacks || []).flatMap(item => valueResolve(property, item, onesyStyle).value);
response.value = [fallbacks, valueResolve(property, value.value, onesyStyle).value].flat().filter(Boolean);
if (value.rule) response.options.rule = value.rule;
} else {
var _onesyStyle$subscript2;
// Value plugins
const value_ = (_onesyStyle$subscript2 = onesyStyle.subscriptions.rule.value.map({
property,
value
})) === null || _onesyStyle$subscript2 === void 0 ? void 0 : _onesyStyle$subscript2.value;
response.value = value_ || [];
}
} // Method
// OnesySubscription
// For methods and OnesySubscription leave as is
// these are only used during add method
else response.value = [value];
}
return response;
};
const dynamic = value => is$1('function', value) || isOnesySubscription(value) || is$1('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$1('array', input_) ? input_ : input_.split('');
let length = length_;
let value;
let methodNameGenerator = _default$l(input, length, {
response: 'yield'
})();
while (true) {
var _value;
value = methodNameGenerator.next();
if ((_value = value) !== null && _value !== void 0 && _value.done) {
methodNameGenerator = _default$l(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$k();
env$2.onesy_methods = {
makeName: makeName()
};
const names = value => {
if (is$1('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 element$1 = {};
var isEnvironment$1 = {};
var __importDefault$j = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(isEnvironment$1, "__esModule", { value: true });
const is_1$c = __importDefault$j(is$3.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$c.default)('string', value_) && ['localhost', '127.0.0.1'].some(value__ => value_.indexOf(value__) > -1);
default:
return false;
}
}
var _default$h = isEnvironment$1.default = isEnvironment;
var __importDefault$i = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(element$1, "__esModule", { value: true });
const is_1$b = __importDefault$i(is$3.exports);
const isEnvironment_1$2 = __importDefault$i(isEnvironment$1);
const try_1 = __importDefault$i(_try);
function element(value) {
const object = {};
object.value = value;
if ((0, is_1$b.default)('string', value))
object.value = window.document.querySelector(value);
if (!(0, is_1$b.default)('element', object.value))
delete object.value;
const matches = (value_ = object.value) => {
const method = (0, is_1$b.default)('element', value_) && (value_.matches || value_['webkitMatchesSelector'] || value_['mozMatchesSelector'] || value_['oMatchesSelector'] || value_['msMatchesSelector']);
if (!method)
return () => false;
return method.bind(value_);
};
// Parent
object.parent = function () {
if (this.value && (0, isEnvironment_1$2.default)('browser') && this.value.parentNode)
return this.value.parentNode;
};
// Parents
object.parents = function (selectors, arrayMethod = 'some') {
const parents = [];
let parent = this.value;
while (parent && parent !== document) {
parent = element(parent).parent();
if (parent &&
(!(selectors === null || selectors === void 0 ? void 0 : selectors.length) ||
selectors[arrayMethod] && selectors[arrayMethod](item => (0, try_1.default)(() => matches(parent)(item)))))
parents.push(parent);
}
return parents;
};
// Nearest
object.nearest = function (selectors, arrayMethod = 'some') {
// Value matches
// return itself in that use case
if (!(selectors === null || selectors === void 0 ? void 0 : selectors.length) ||
selectors[arrayMethod] && selectors[arrayMethod](item => (0, try_1.default)(() => matches(this.value)(item))))
return this.value;
let parent = this.value;
while (parent && parent !== document) {
parent = element(parent).parent();
if (parent &&
(!(selectors === null || selectors === void 0 ? void 0 : selectors.length) ||
selectors[arrayMethod] && selectors[arrayMethod](item => (0, try_1.default)(() => matches(parent)(item)))))
return parent;
}
};
// Furthest
object.furthest = function (selectors, arrayMethod = 'some') {
const parents = this.parents(selectors, arrayMethod);
return parents[parents.length - 1];
};
// hasParent
object.hasParent = function (selectors, grandparents = true, arrayMethod = 'some') {
let parent = this.value;
if (!grandparents)
return (!(selectors === null || selectors === void 0 ? void 0 : selectors.length) ||
selectors[arrayMethod] && selectors[arrayMethod](item => (0, try_1.default)(() => matches(this.parent())(item))));
while (parent && parent !== document) {
parent = element(parent).parent();
if (parent &&
(!(selectors === null || selectors === void 0 ? void 0 : selectors.length) ||
selectors[arrayMethod] && selectors[arrayMethod](item => (0, try_1.default)(() => matches(parent)(item)))))
return true;
}
return false;
};
// hasParents
// If unique is true, sort selectors argument by most specifc first
// and lowest specificty last for the most proper result
object.hasParents = function (selectors, unique = true, arrayMethod = 'some') {
if (!(selectors === null || selectors === void 0 ? void 0 : selectors.length))
return !!this.parent();
const parents = this.parents();
return !!(this.value &&
((selectors === null || selectors === void 0 ? void 0 : selectors.length) &&
(selectors[arrayMethod] && selectors[arrayMethod](selector => {
const index = parents.findIndex((item) => (0, is_1$b.default)('string', selector) ? (0, try_1.default)(() => matches(item)(selector)) : item === selector);
if (index > -1) {
if (unique)
parents.splice(index, 1);
return true;
}
return false;
}))));
};
return object;
}
var _default$g = element$1.default = element;
var merge$1 = {};
var __importDefault$h = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(merge$1, "__esModule", { value: true });
const is_1$a = __importDefault$h(is$3.exports);
const copy_1 = __importDefault$h(copy$1);
const optionsDefault$k = {
copy: false,
merge: {
array: false,
},
};
const merge = (target, source, options_ = {}) => {
const options = Object.assign(Object.assign({}, optionsDefault$k), options_);
if (options.merge.array &&
(0, is_1$a.default)('array', target) && (0, is_1$a.default)('array', source)) {
const length = Math.max(target.length, source.length);
for (let i = 0; i < length; i++) {
if (target[i] === undefined)
target[i] = source[i];
if (((0, is_1$a.default)('object', target[i]) && (0, is_1$a.default)('object', source[i])) ||
(0, is_1$a.default)('array', target[i]) && (0, is_1$a.default)('array', source[i]))
target[i] = merge(target[i], source[i], options);
}
}
if ((0, is_1$a.default)('object', target) && (0, is_1$a.default)('object', source)) {
Object.keys(source).forEach(key => {
// We only care about direct target object properties
// not about inherited properties from a prototype chain
if (target.hasOwnProperty(key)) {
if ((0, is_1$a.default)('object', target[key]) && (0, is_1$a.default)('object', source[key]))
target[key] = merge(target[key], source[key], options);
}
else
target[key] = options.copy ? (0, copy_1.default)(source[key]) : source[key];
});
}
return target;
};
var _default$f = merge$1.default = merge;
const unix = () => Math.floor(new Date().getTime() / 1000);
const optionsDefault$j = {
value: {
copy: false
},
add: {
override: true
}
};
class OnesyMeta {
static meta = new WeakMap();
static options_ = optionsDefault$j;
static get options() {
return this.options_;
}
static set options(value) {
this.options_ = { ...this.options,
...value
};
} // Class decorator
static class() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return object => {
const [key, value] = args; // Add key and value to object which is a class itself
this.add(key, value, object);
};
} // Method decorator
static method() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return (object_, property) => {
const object = object_.constructor;
const [key, value] = args; // Add key and value to object property which is a class's method
this.add(key, value, object, property);
};
} // Property decorator
static property() {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
return (object_, property) => {
const object = object_.constructor;
const [key, value] = args; // Add key and value to object property which is a class's property
this.add(key, value, object, property);
};
} // Parameter decorator
static parameter() {
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
return (object_, property, parameterIndex) => {
const object = object_.constructor;
const [value] = args; // Add key and value to object property which is a class's method
this.add("onesy-meta-param:".concat(parameterIndex), value, object, property);
};
}
static add(key, value, object, property) {
// A WeakMap's key can only be
// of a reference value type
if (!is$2('simple', object)) {
const value_ = this.options.value.copy ? _default$j(value) : value;
let mapObject = this.meta.get(object);
if (!mapObject) {
// Add a new map for the object
mapObject = new Map();
this.meta.set(object, mapObject);
}
if (property !== undefined) {
let mapProperty = mapObject.get(property);
if (!mapProperty) {
// Add a new map for the object's property
mapProperty = new Map();
mapObject.set(property, mapProperty);
}
if (!mapProperty.has(key) || this.options.add.override) {
// Set map property's key and value
mapProperty.set(key, {
value: this.options.value.copy ? _default$j(value) : value,
added_at: unix()
});
return value_;
}
} else {
if (!mapObject.has(key) || this.options.add.override) {
// Set map object's key and value
mapObject.set(key, {
value: this.options.value.copy ? _default$j(value) : value,
added_at: unix()
});
return value_;
}
}
}
}
static update(key, value, object, property) {
// A WeakMap's key can only be
// of a reference value type
if (!is$2('simple', object)) {
const value_ = this.options.value.copy ? _default$j(value) : value;
let mapObject = this.meta.get(object);
if (!mapObject) {
// Add a new map for the object
mapObject = new Map();
this.meta.set(object, mapObject);
}
if (property !== undefined) {
let mapProperty = mapObject.get(property);
if (!mapProperty) {
// Add a new map for the object's property
mapProperty = new Map();
mapObject.set(property, mapProperty);
}
if (mapProperty.has(key)) {
// Set map property's key and value
const atmValue = mapProperty.get(key);
atmValue.value = value_;
atmValue.updated_at = unix();
mapProperty.set(key, atmValue);
return value_;
}
} else {
if (mapObject.has(key)) {
// Set map object's key and value
const atmValue = mapObject.get(key);
atmValue.value = value_;
atmValue.updated_at = unix();
mapObject.set(key, atmValue);
return value_;
}
}
}
}
static get(key, object, property) {
// A WeakMap's key can only be
// of a reference value type
if (!is$2('simple', object)) {
const mapObject = this.meta.get(object);
if (!mapObject) return;
if (property !== undefined) {
const mapProperty = mapObject.get(property);
if (!mapProperty) return;
if (!mapProperty.has(key)) return; // Get map property key's and value
return this.options.value.copy ? _default$j(mapProperty.get(key).value) : mapProperty.get(key).value;
}
if (!mapObject.has(key)) return; // Get map object key's and value
return this.options.value.copy ? _default$j(mapObject.get(key).value) : mapObject.get(key).value;
}
}
static has(key, object, property) {
// A WeakMap's key can only be
// of a reference value type
if (!is$2('simple', object)) {
const mapObject = this.meta.get(object);
if (!mapObject) return false;
if (property !== undefined) {
const mapProperty = mapObject.get(property);
if (!mapProperty) return false; // Map has property key
return mapProperty.has(key);
} // Map has object key's and value
return mapObject.has(key);
}
}
static remove(key, object, property) {
// A WeakMap's key can only be
// of a reference value type
if (!is$2('simple', object)) {
const mapObject = this.meta.get(object);
if (!mapObject) return;
if (property !== undefined) {
const mapProperty = mapObject.get(property);
if (!mapProperty) return; // Remove map property's key and value
mapProperty.delete(key);
} else {
// Remove map object's key and value
mapObject.delete(key);
}
}
}
static values(object, property) {
// A WeakMap's key can only be
// of a reference value type
if (!is$2('simple', object)) {
const mapObject = this.meta.get(object);
if (!mapObject) return;
if (property !== undefined) {
const mapProperty = mapObject.get(property); // Return object property's values as array
return mapProperty && Array.from(mapProperty.values());
} // Return object's values as array
return mapObject && Array.from(mapObject.values()).map(item => item.value);
}
}
static keys(object, property) {
// A WeakMap's key can only be
// of a reference value type
if (!is$2('simple', object)) {
const mapObject = this.meta.get(object);
if (!mapObject) return;
if (property !== undefined) {
const mapProperty = mapObject.get(property); // Return object property's keys as array
return mapProperty && Array.from(mapProperty.keys());
} // Return object's keys as array
return mapObject && Array.from(mapObject.keys());
}
}
static reset() {
this.meta = new WeakMap();
this.options = optionsDefault$j;
}
}
var OnesyMeta$1 = OnesyMeta;
class OnesyStyleRenderer {
make() {
let attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
element: {},
data: {}
};
let version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'style';
// Append to the bottom of head element
if (_default$h('browser')) {
const element = window.document.createElement(version);
Object.keys((attributes === null || attributes === void 0 ? void 0 : attributes.element) || {}).forEach(attribute => element.setAttribute(attribute, attributes.element[attribute])); // Add attributes
Object.keys((attributes === null || attributes === void 0 ? void 0 : attributes.data) || {}).forEach(attribute => {
element[attribute] = attributes.data[attribute];
element.setAttribute(attribute.indexOf('data-') === 0 ? attribute : "data-".concat(attribute), attributes.data[attribute]);
});
return element;
}
}
add(value) {
let priority = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'lower';
let attributes = arguments.length > 2 ? arguments[2] : undefined;
// Append to the bottom of head element
if (_default$h('browser')) {
const styleSheets = window.document.styleSheets;
if (!styleSheets.length || priority === 'upper') window.document.head.append(value);else {
var _attributes$data, _styleSheets$;
const reset = Array.from(styleSheets).find(item => item.ownerNode.method === 'reset');
let pure = Array.from(styleSheets).filter(item => item.ownerNode.method === 'pure');
pure = pure[pure.length - 1];
if ((attributes === null || attributes === void 0 ? void 0 : (_attributes$data = attributes.data) === null || _attributes$data === void 0 ? void 0 : _attributes$data.method) === 'reset' || priority === 'lower' && !(pure || reset)) window.document.head.insertBefore(value, ((_styleSheets$ = styleSheets[0]) === null || _styleSheets$ === void 0 ? void 0 : _styleSheets$.ownerNode) || null);else if (priority === 'lower') {
if (pure) window.document.head.insertBefore(value, pure.ownerNode.nextElementSibling);else if (reset) window.document.head.insertBefore(value, reset.ownerNode.nextElementSibling);
} else window.document.head.append(value);
}
return value;
}
}
remove(value) {
var _element;
let element = value;
if (value !== null && value !== void 0 && value.ownerNode) element = element.ownerNode;
if ((_element = element) !== null && _element !== void 0 && _element.remove) element.remove();
}
}
var OnesyStyleRenderer$1 = OnesyStyleRenderer;
const optionsDefault$i = {
mode: 'regular',
rule: {
sort: true,
prefix: true,
rtl: false
},
minify: true,
optimize: false,
classNamePrefix: ''
};
class OnesyStyle {
// Any new property
constructor() {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _default$j(optionsDefault$i);
_defineProperty(this, "mode", 'regular');
_defineProperty(this, "subscriptions", {
className: {
pre: new OnesySubscription$1(),
name: new OnesySubscription$1(),
post: new OnesySubscription$1()
},
keyframes: {
pre: new OnesySubscription$1(),
name: new OnesySubscription$1(),
post: new OnesySubscription$1()
},
rule: {
pre: new OnesySubscription$1(),
unit: new OnesySubscription$1(),
value: new OnesySubscription$1(),
prefix: new OnesySubscription$1(),
rtl: new OnesySubscription$1(),
add: new OnesySubscription$1(),
update: new OnesySubscription$1(),
update_props: new OnesySubscription$1(),
remove: new OnesySubscription$1(),
post: new OnesySubscription$1()
},
rules: {
sort: new OnesySubscription$1()
},
sheet: {
add: new OnesySubscription$1(),
update: new OnesySubscription$1(),
update_props: new OnesySubscription$1(),
remove: new OnesySubscription$1()
},
sheet_manager: {
add: new OnesySubscription$1(),
update: new OnesySubscription$1(),
update_props: new OnesySubscription$1(),
remove: new OnesySubscription$1()
}
});
_defineProperty(this, "values", {
css: ''
});
_defineProperty(this, "refs", {});
_defineProperty(this, "sheets", []);
_defineProperty(this, "sheet_managers", []);
this.options = options;
this.options = _default$f(options, optionsDefault$i, {
copy: true
});
this.init();
}
get response() {
this.values.css = "";
this.sheets.forEach(sheet => {
const css = sheet.css;
if (css) {
this.values.css += css;
}
});
if (this.values.css) this.values.css = "\n".concat(this.values.css, "\n");
if (this.options.minify) this.values.css = minify(this.values.css);
return this.values;
}
get css() {
return this.response.css;
}
get plugins() {
const onesyStyle = this;
return {
// Add plugins
set add(value_) {
const value = is$1('array', value_) ? value_ : [value_];
value.filter(item => is$1('object', item) && is$1('function', item.method) && !OnesyMeta$1.get(item.method, onesyStyle, 'plugin') || is$1('function', item) && !OnesyMeta$1.get(item, onesyStyle, 'plugin')).forEach(item => {
try {
const method = is$1('function', item) ? item : item.method;
const args = is$1('object', item) ? item.arguments : [];
const response = method(onesyStyle, ...args);
OnesyMeta$1.add(method, response, onesyStyle, 'plugin');
} catch (error) {
console.error('OnesyStyle use: ', error);
}
});
},
// Remove plugins
set remove(value_) {
const value = is$1('array', value_) ? value_ : [value_];
value.filter(item => is$1('object', item) && is$1('function', item.method) && !OnesyMeta$1.get(item.method, onesyStyle, 'plugin') || is$1('function', item) && !OnesyMeta$1.get(item, onesyStyle, 'plugin')).forEach(item => {
try {
const method = is$1('function', item) ? item : item.method;
const response = OnesyMeta$1.get(method, onesyStyle, 'plugin');
if (is$1('function', response === null || response === void 0 ? void 0 : response.remove)) response.remove();
} catch (error) {
console.error('OnesyStyle remove plugin: ', error);
}
});
}
};
}
init() {
// Options
this.element = this.options.element || this.element;
this.mode = this.options.mode || 'regular';
this.renderer = this.options.renderer || new OnesyStyleRenderer$1();
if (this.id === undefined) this.id = getID();
if (_default$h('browser')) {
if (!this.element) this.element = window.document.body; // OnesyStyle in element
this.element.setAttribute('data-onesy-style', 'true');
this.element['onesy-style'] = true;
this.element.onesy_style = this; // Ltr
const style = _default$i(() => window.getComputedStyle(this.element));
this.direction = (style === null || style === void 0 ? void 0 : style.direction) || _default$i(() => window.getComputedStyle(document.documentElement).direction) || 'ltr';
this.options.rule.rtl = this.direction === 'rtl';
}
}
static get(value) {
let index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
const themes = this.all(value);
return themes[index === -1 ? themes.length - 1 : index];
}
static first(value) {
return this.get(value);
}
static last(value) {
return this.get(value, -1);
}
static nearest(value) {
var _element$nearest;
return (_element$nearest = _default$g(value).nearest(this.attributes.map(item => "[".concat(item, "]")))) === null || _element$nearest === void 0 ? void 0 : _element$nearest.onesy_style;
}
static furthest(value) {
var _element$furthest;
return (_element$furthest = _default$g(value).furthest(this.attributes.map(item => "[".concat(item, "]")))) === null || _element$furthest === void 0 ? void 0 : _element$furthest.onesy_style;
}
static all(value) {
const elements = [value, ..._default$g(value).parents(this.attributes.map(item => "[".concat(item, "]")))];
return elements.filter(Boolean).map(item => item.onesy_style).filter(Boolean) || [];
}
}
_defineProperty(OnesyStyle, "counter", {
className: 0,
keyframesName: 0
});
_defineProperty(OnesyStyle, "attributes", ['data-onesy-style', 'onesy-style']);
var OnesyStyle$1 = OnesyStyle;
var hash$3 = {};
var sha256 = {exports: {}};
var core = {exports: {}};
(function (module, exports) {
(function (root, factory) {
{
// CommonJS
module.exports = factory();
}
}(this, function () {
/*globals window, global, require*/
/**
* CryptoJS core components.
*/
var CryptoJS = CryptoJS || (function (Math, undefined$1) {
var crypto;
// Native crypto from window (Browser)
if (typeof window !== 'undefined' && window.crypto) {
crypto = window.crypto;
}
// Native crypto in web worker (Browser)
if (typeof self !== 'undefined' && self.crypto) {
crypto = self.crypto;
}
// Native crypto from worker
if (typeof globalThis !== 'undefined' && globalThis.crypto) {
crypto = globalThis.crypto;
}
// Native (experimental IE 11) crypto from window (Browser)
if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
crypto = window.msCrypto;
}
// Native crypto from global (NodeJS)
if (!crypto && typeof global$1 !== 'undefined' && global$1.crypto) {
crypto = global$1.crypto;
}
// Native crypto import via require (NodeJS)
if (!crypto && typeof commonjsRequire === 'function') {
try {
crypto = require('crypto');
} catch (err) {}
}
/*
* Cryptographically secure pseudorandom number generator
*
* As Math.random() is cryptographically not safe to use
*/
var cryptoSecureRandomInt = function () {
if (crypto) {
// Use getRandomValues method (Browser)
if (typeof crypto.getRandomValues === 'function') {
try {
return crypto.getRandomValues(new Uint32Array(1))[0];
} catch (err) {}
}
// Use randomBytes method (NodeJS)
if (typeof crypto.randomBytes === 'function') {
try {
return crypto.randomBytes(4).readInt32LE();
} catch (err) {}
}
}
throw new Error('Native crypto module could not be used to get secure random number.');
};
/*
* Local polyfill of Object.create
*/
var create = Object.create || (function () {
function F() {}
return function (obj) {
var subtype;
F.prototype = obj;
subtype = new F();
F.prototype = null;
return subtype;
};
}());
/**
* CryptoJS namespace.
*/
var C = {};
/**
* Library namespace.
*/
var C_lib = C.lib = {};
/**
* Base object for prototypal inheritance.
*/
var Base = C_lib.Base = (function () {
return {
/**
* Creates a new object that inherits from this object.
*
* @param {Object} overrides Properties to copy into the new object.
*
* @return {Object} The new object.
*
* @static
*
* @example
*
* var MyType = CryptoJS.lib.Base.extend({
* field: 'value',
*
* method: function () {
* }
* });
*/
extend: function (overrides) {
// Spawn
var subtype = create(this);
// Augment
if (overrides) {
subtype.mixIn(overrides);
}
// Create default initializer
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
subtype.init = function () {
subtype.$super.init.apply(this, arguments);
};
}
// Initializer's prototype is the subtype object
subtype.init.prototype = subtype;
// Reference supertype
subtype.$super = this;
return subtype;
},
/**
* Extends this object and runs the init method.
* Arguments to create() will be passed to init().
*
* @return {Object} The new object.
*
* @static
*
* @example
*
* var instance = MyType.create();
*/
create: function () {
var instance = this.extend();
instance.init.apply(instance, arguments);
return instance;
},
/**
* Initializes a newly created object.
* Override this method to add some logic when your objects are created.
*
* @example
*
* var MyType = CryptoJS.lib.Base.extend({
* init: function () {
* // ...
* }
* });
*/
init: function () {
},
/**
* Copies properties into this object.
*
* @param {Object} properties The properties to mix in.
*
* @example
*
* MyType.mixIn({
* field: 'value'
* });
*/
mixIn: function (properties) {
for (var propertyName in properties) {
if (properties.hasOwnProperty(propertyName)) {
this[propertyName] = properties[propertyName];
}
}
// IE won't copy toString using the loop above
if (properties.hasOwnProperty('toString')) {
this.toString = properties.toString;
}
},
/**
* Creates a copy of this object.
*
* @return {Object} The clone.
*
* @example
*
* var clone = instance.clone();
*/
clone: function () {
return this.init.prototype.extend(this);
}
};
}());
/**
* An array of 32-bit words.
*
* @property {Array} words The array of 32-bit words.
* @property {number} sigBytes The number of significant bytes in this word array.
*/
var WordArray = C_lib.WordArray = Base.extend({
/**
* Initializes a newly created word array.
*
* @param {Array} words (Optional) An array of 32-bit words.
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
*
* @example
*
* var wordArray = CryptoJS.lib.WordArray.create();
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
*/
init: function (words, sigBytes) {
words = this.words = words || [];
if (sigBytes != undefined$1) {
this.sigBytes = sigBytes;
} else {
this.sigBytes = words.length * 4;
}
},
/**
* Converts this word array to a string.
*
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
*
* @return {string} The stringified word array.
*
* @example
*
* var string = wordArray + '';
* var string = wordArray.toString();
* var string = wordArray.toString(CryptoJS.enc.Utf8);
*/
toString: function (encoder) {
return (encoder || Hex).stringify(this);
},
/**
* Concatenates a word array to this word array.
*
* @param {WordArray} wordArray The word array to append.
*
* @return {WordArray} This word array.
*
* @example
*
* wordArray1.concat(wordArray2);
*/
concat: function (wordArray) {
// Shortcuts
var thisWords = this.words;
var thatWords = wordArray.words;
var thisSigBytes = this.sigBytes;
var thatSigBytes = wordArray.sigBytes;
// Clamp excess bits
this.clamp();
// Concat
if (thisSigBytes % 4) {
// Copy one byte at a time
for (var i = 0; i < thatSigBytes; i++) {
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
}
} else {
// Copy one word at a time
for (var j = 0; j < thatSigBytes; j += 4) {
thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
}
}
this.sigBytes += thatSigBytes;
// Chainable
return this;
},
/**
* Removes insignificant bits.
*
* @example
*
* wordArray.clamp();
*/
clamp: function () {
// Shortcuts
var words = this.words;
var sigBytes = this.sigBytes;
// Clamp
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
words.length = Math.ceil(sigBytes / 4);
},
/**
* Creates a copy of this word array.
*
* @return {WordArray} The clone.
*
* @example
*
* var clone = wordArray.clone();
*/
clone: function () {
var clone = Base.clone.call(this);
clone.words = this.words.slice(0);
return clone;
},
/**
* Creates a word array filled with random bytes.
*
* @param {number} nBytes The number of random bytes to generate.
*
* @return {WordArray} The random word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.lib.WordArray.random(16);
*/
random: function (nBytes) {
var words = [];
for (var i = 0; i < nBytes; i += 4) {
words.push(cryptoSecureRandomInt());
}
return new WordArray.init(words, nBytes);
}
});
/**
* Encoder namespace.
*/
var C_enc = C.enc = {};
/**
* Hex encoding strategy.
*/
var Hex = C_enc.Hex = {
/**
* Converts a word array to a hex string.
*
* @param {WordArray} wordArray The word array.
*
* @return {string} The hex string.
*
* @static
*
* @example
*
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
*/
stringify: function (wordArray) {
// Shortcuts
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
// Convert
var hexChars = [];
for (var i = 0; i < sigBytes; i++) {
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
hexChars.push((bite >>> 4).toString(16));
hexChars.push((bite & 0x0f).toString(16));
}
return hexChars.join('');
},
/**
* Converts a hex string to a word array.
*
* @param {string} hexStr The hex string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
*/
parse: function (hexStr) {
// Shortcut
var hexStrLength = hexStr.length;
// Convert
var words = [];
for (var i = 0; i < hexStrLength; i += 2) {
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
}
return new WordArray.init(words, hexStrLength / 2);
}
};
/**
* Latin1 encoding strategy.
*/
var Latin1 = C_enc.Latin1 = {
/**
* Converts a word array to a Latin1 string.
*
* @param {WordArray} wordArray The word array.
*
* @return {string} The Latin1 string.
*
* @static
*
* @example
*
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
*/
stringify: function (wordArray) {
// Shortcuts
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
// Convert
var latin1Chars = [];
for (var i = 0; i < sigBytes; i++) {
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
latin1Chars.push(String.fromCharCode(bite));
}
return latin1Chars.join('');
},
/**
* Converts a Latin1 string to a word array.
*
* @param {string} latin1Str The Latin1 string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
*/
parse: function (latin1Str) {
// Shortcut
var latin1StrLength = latin1Str.length;
// Convert
var words = [];
for (var i = 0; i < latin1StrLength; i++) {
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
}
return new WordArray.init(words, latin1StrLength);
}
};
/**
* UTF-8 encoding strategy.
*/
var Utf8 = C_enc.Utf8 = {
/**
* Converts a word array to a UTF-8 string.
*
* @param {WordArray} wordArray The word array.
*
* @return {string} The UTF-8 string.
*
* @static
*
* @example
*
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
*/
stringify: function (wordArray) {
try {
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
} catch (e) {
throw new Error('Malformed UTF-8 data');
}
},
/**
* Converts a UTF-8 string to a word array.
*
* @param {string} utf8Str The UTF-8 string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
*/
parse: function (utf8Str) {
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
}
};
/**
* Abstract buffered block algorithm template.
*
* The property blockSize must be implemented in a concrete subtype.
*
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
*/
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
/**
* Resets this block algorithm's data buffer to its initial state.
*
* @example
*
* bufferedBlockAlgorithm.reset();
*/
reset: function () {
// Initial values
this._data = new WordArray.init();
this._nDataBytes = 0;
},
/**
* Adds new data to this block algorithm's buffer.
*
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
*
* @example
*
* bufferedBlockAlgorithm._append('data');
* bufferedBlockAlgorithm._append(wordArray);
*/
_append: function (data) {
// Convert string to WordArray, else assume WordArray already
if (typeof data == 'string') {
data = Utf8.parse(data);
}
// Append
this._data.concat(data);
this._nDataBytes += data.sigBytes;
},
/**
* Processes available data blocks.
*
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
*
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
*
* @return {WordArray} The processed data.
*
* @example
*
* var processedData = bufferedBlockAlgorithm._process();
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
*/
_process: function (doFlush) {
var processedWords;
// Shortcuts
var data = this._data;
var dataWords = data.words;
var dataSigBytes = data.sigBytes;
var blockSize = this.blockSize;
var blockSizeBytes = blockSize * 4;
// Count blocks ready
var nBlocksReady = dataSigBytes / blockSizeBytes;
if (doFlush) {
// Round up to include partial blocks
nBlocksReady = Math.ceil(nBlocksReady);
} else {
// Round down to include only full blocks,
// less the number of blocks that must remain in the buffer
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
}
// Count words ready
var nWordsReady = nBlocksReady * blockSize;
// Count bytes ready
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
// Process blocks
if (nWordsReady) {
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
// Perform concrete-algorithm logic
this._doProcessBlock(dataWords, offset);
}
// Remove processed words
processedWords = dataWords.splice(0, nWordsReady);
data.sigBytes -= nBytesReady;
}
// Return processed words
return new WordArray.init(processedWords, nBytesReady);
},
/**
* Creates a copy of this object.
*
* @return {Object} The clone.
*
* @example
*
* var clone = bufferedBlockAlgorithm.clone();
*/
clone: function () {
var clone = Base.clone.call(this);
clone._data = this._data.clone();
return clone;
},
_minBufferSize: 0
});
/**
* Abstract hasher template.
*
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
*/
C_lib.Hasher = BufferedBlockAlgorithm.extend({
/**
* Configuration options.
*/
cfg: Base.extend(),
/**
* Initializes a newly created hasher.
*
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
*
* @example
*
* var hasher = CryptoJS.algo.SHA256.create();
*/
init: function (cfg) {
// Apply config defaults
this.cfg = this.cfg.extend(cfg);
// Set initial values
this.reset();
},
/**
* Resets this hasher to its initial state.
*
* @example
*
* hasher.reset();
*/
reset: function () {
// Reset data buffer
BufferedBlockAlgorithm.reset.call(this);
// Perform concrete-hasher logic
this._doReset();
},
/**
* Updates this hasher with a message.
*
* @param {WordArray|string} messageUpdate The message to append.
*
* @return {Hasher} This hasher.
*
* @example
*
* hasher.update('message');
* hasher.update(wordArray);
*/
update: function (messageUpdate) {
// Append
this._append(messageUpdate);
// Update the hash
this._process();
// Chainable
return this;
},
/**
* Finalizes the hash computation.
* Note that the finalize operation is effectively a destructive, read-once operation.
*
* @param {WordArray|string} messageUpdate (Optional) A final message update.
*
* @return {WordArray} The hash.
*
* @example
*
* var hash = hasher.finalize();
* var hash = hasher.finalize('message');
* var hash = hasher.finalize(wordArray);
*/
finalize: function (messageUpdate) {
// Final message update
if (messageUpdate) {
this._append(messageUpdate);
}
// Perform concrete-hasher logic
var hash = this._doFinalize();
return hash;
},
blockSize: 512/32,
/**
* Creates a shortcut function to a hasher's object interface.
*
* @param {Hasher} hasher The hasher to create a helper for.
*
* @return {Function} The shortcut function.
*
* @static
*
* @example
*
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
*/
_createHelper: function (hasher) {
return function (message, cfg) {
return new hasher.init(cfg).finalize(message);
};
},
/**
* Creates a shortcut function to the HMAC's object interface.
*
* @param {Hasher} hasher The hasher to use in this HMAC helper.
*
* @return {Function} The shortcut function.
*
* @static
*
* @example
*
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
*/
_createHmacHelper: function (hasher) {
return function (message, key) {
return new C_algo.HMAC.init(hasher, key).finalize(message);
};
}
});
/**
* Algorithm namespace.
*/
var C_algo = C.algo = {};
return C;
}(Math));
return CryptoJS;
}));
}(core));
(function (module, exports) {
(function (root, factory) {
{
// CommonJS
module.exports = factory(core.exports);
}
}(this, function (CryptoJS) {
(function (Math) {
// Shortcuts
var C = CryptoJS;
var C_lib = C.lib;
var WordArray = C_lib.WordArray;
var Hasher = C_lib.Hasher;
var C_algo = C.algo;
// Initialization and round constants tables
var H = [];
var K = [];
// Compute constants
(function () {
function isPrime(n) {
var sqrtN = Math.sqrt(n);
for (var factor = 2; factor <= sqrtN; factor++) {
if (!(n % factor)) {
return false;
}
}
return true;
}
function getFractionalBits(n) {
return ((n - (n | 0)) * 0x100000000) | 0;
}
var n = 2;
var nPrime = 0;
while (nPrime < 64) {
if (isPrime(n)) {
if (nPrime < 8) {
H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
}
K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
nPrime++;
}
n++;
}
}());
// Reusable object
var W = [];
/**
* SHA-256 hash algorithm.
*/
var SHA256 = C_algo.SHA256 = Hasher.extend({
_doReset: function () {
this._hash = new WordArray.init(H.slice(0));
},
_doProcessBlock: function (M, offset) {
// Shortcut
var H = this._hash.words;
// Working variables
var a = H[0];
var b = H[1];
var c = H[2];
var d = H[3];
var e = H[4];
var f = H[5];
var g = H[6];
var h = H[7];
// Computation
for (var i = 0; i < 64; i++) {
if (i < 16) {
W[i] = M[offset + i] | 0;
} else {
var gamma0x = W[i - 15];
var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
((gamma0x << 14) | (gamma0x >>> 18)) ^
(gamma0x >>> 3);
var gamma1x = W[i - 2];
var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
((gamma1x << 13) | (gamma1x >>> 19)) ^
(gamma1x >>> 10);
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
}
var ch = (e & f) ^ (~e & g);
var maj = (a & b) ^ (a & c) ^ (b & c);
var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
var t1 = h + sigma1 + ch + K[i] + W[i];
var t2 = sigma0 + maj;
h = g;
g = f;
f = e;
e = (d + t1) | 0;
d = c;
c = b;
b = a;
a = (t1 + t2) | 0;
}
// Intermediate hash value
H[0] = (H[0] + a) | 0;
H[1] = (H[1] + b) | 0;
H[2] = (H[2] + c) | 0;
H[3] = (H[3] + d) | 0;
H[4] = (H[4] + e) | 0;
H[5] = (H[5] + f) | 0;
H[6] = (H[6] + g) | 0;
H[7] = (H[7] + h) | 0;
},
_doFinalize: function () {
// Shortcuts
var data = this._data;
var dataWords = data.words;
var nBitsTotal = this._nDataBytes * 8;
var nBitsLeft = data.sigBytes * 8;
// Add padding
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
data.sigBytes = dataWords.length * 4;
// Hash final blocks
this._process();
// Return final computed hash
return this._hash;
},
clone: function () {
var clone = Hasher.clone.call(this);
clone._hash = this._hash.clone();
return clone;
}
});
/**
* Shortcut function to the hasher's object interface.
*
* @param {WordArray|string} message The message to hash.
*
* @return {WordArray} The hash.
*
* @static
*
* @example
*
* var hash = CryptoJS.SHA256('message');
* var hash = CryptoJS.SHA256(wordArray);
*/
C.SHA256 = Hasher._createHelper(SHA256);
/**
* Shortcut function to the HMAC's object interface.
*
* @param {WordArray|string} message The message to hash.
* @param {WordArray|string} key The secret key.
*
* @return {WordArray} The HMAC.
*
* @static
*
* @example
*
* var hmac = CryptoJS.HmacSHA256(message, key);
*/
C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
}(Math));
return CryptoJS.SHA256;
}));
}(sha256));
var SHA256 = sha256.exports;
var serialize$3 = {};
var __importDefault$g = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(serialize$3, "__esModule", { value: true });
const is_1$9 = __importDefault$g(is$3.exports);
const resolve$1 = (value) => {
if (value === undefined)
return 'undefined';
if (value instanceof Function ||
value instanceof Object)
return value.toString();
return value;
};
const clean$1 = (value) => {
if ((0, is_1$9.default)('string', value))
return value.replace(/(\s|\r|\n)+/, ' ');
return value;
};
const serializeValue$1 = (value_, method) => {
let value = method(value_);
// Ref circular value
if (value === undefined)
return '';
// Is object-like make into an object
try {
if ((0, is_1$9.default)('object-like', value) && (0, is_1$9.default)('not-array-object', value) && value !== null)
value = Object.assign({}, value);
}
catch (error) { }
if ((0, is_1$9.default)('object', value))
return `{${Object.keys(value)
.sort()
.map(key => `"${key}":${serializeValue$1(value[key], method)}`)
.filter(item => item.slice(-1) !== ':')
.join(',')}}`;
if ((0, is_1$9.default)('array', value))
return `[${value
.map((value__) => serializeValue$1(value__, method))
.filter(Boolean)
.join(',')}]`;
if ((0, is_1$9.default)('string', value))
return `"${value}"`;
return clean$1(JSON.stringify(resolve$1(value)));
};
const serialize$2 = (value) => {
const values = new WeakSet();
const getValue = (value_) => {
if (typeof value_ === 'object' && value_ !== null) {
if (values.has(value_))
return;
values.add(value_);
}
return value_;
};
return serializeValue$1(value, getValue);
};
serialize$3.default = serialize$2;
var __importDefault$f = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(hash$3, "__esModule", { value: true });
const sha256_1 = __importDefault$f(sha256.exports);
const serialize_1 = __importDefault$f(serialize$3);
const optionsDefault$h = {
serialize: true,
withPrefix: true,
};
const hash$2 = (value_, options_ = {}) => {
const options = Object.assign(Object.assign({}, optionsDefault$h), options_);
let value = value_;
if (options.serialize)
value = (0, serialize_1.default)(value);
value = (0, sha256_1.default)(value).toString();
return options.withPrefix ? `0x${value}` : value;
};
var _default$e = hash$3.default = hash$2;
const optionsDefault$g = {
value_version: 'value',
pure: false,
parents: [],
sort: true,
prefix: true,
rtl: true
};
class OnesyStyleRuleProperty {
constructor(value, property) {
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : optionsDefault$g;
_defineProperty(this, "value_version", 'value');
_defineProperty(this, "pure", false);
_defineProperty(this, "parents", []);
_defineProperty(this, "values", {
property: '',
value: '',
css: ''
});
this.value = value;
this.property = property;
this.options = options;
this.init();
}
get parent() {
return this.parents[this.parents.length - 1];
}
get response() {
return {
css: this.values.css
};
}
get css() {
return this.response.css;
}
updateValues() {
// Response
this.values.css = "".concat(this.values.property, ": ").concat(this.values.value, ";"); // For undefined animation name value
if (this.values.css.indexOf('undefined') > -1) this.values.css = '';
}
init(value) {
var _this$onesyStyleSheet, _this$parent, _this$onesyStyleSheet2, _this$parent2;
// Update values
this.values.property = cammelCaseToKebabCase(this.property);
this.values.value = value !== undefined ? value : this.value; // Options
this.value_version = this.options.value_version || 'value';
this.pure = this.options.pure !== undefined ? this.options.pure : false;
this.owner = this.options.owner;
this.parents = this.options.parents || [];
this.onesyStyle = this.options.onesyStyle;
this.onesyStyleSheet = this.options.onesyStyleSheet;
this.onesyStyleRule = this.options.onesyStyleRule;
if (this.id === undefined) this.id = getID();
if (this.level === undefined) this.level = this.parents.length - 1; // Add to rules_owned to all parents
this.parents.filter(parent => !(parent instanceof OnesyStyleSheet$1)).forEach(parent => parent.rules_owned.push(this)); // method or OnesySubscription
if (value === undefined && ['method', 'onesy_subscription'].indexOf(this.value_version) > -1) {
if (this.value_version === 'method') this.values.value = _default$i(() => this.value(this.onesyStyleSheet.props));else if (this.value_version === 'onesy_subscription') {
this.values.value = this.value.value;
if (!this.value.subscribed) this.value.subscribed = [];
if (this.value.subscribed.indexOf(this) === -1) {
this.value.subscribe(this.update.bind(this));
this.value.subscribed.push(this);
}
} // Value
this.values.value = is$1('function', this.values.value) ? _default$i(() => this.values.value(this.onesyStyleSheet.props)) : this.values.value;
} // Value
this.values.value = valueResolve(this.values.property, this.values.value, this.onesyStyle).value[0]; // Move through plugins
// rtl
const useRtl = this.onesyStyle.options.rule.rtl && (this.onesyStyleSheet === undefined || this.onesyStyleSheet.options.rule.rtl !== false) && (((_this$onesyStyleSheet = this.onesyStyleSheet) === null || _this$onesyStyleSheet === void 0 ? void 0 : _this$onesyStyleSheet.onesyTheme) === undefined || this.onesyStyleSheet.onesyTheme.options.rule.rtl) && // by default is true
((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.options.rtl) !== false;
if (useRtl) {
const rtl = this.onesyStyle.subscriptions.rule.rtl.map(this.values);
if (rtl !== null && rtl !== void 0 && rtl.value) {
var _rtl$value, _rtl$value2;
if (rtl !== null && rtl !== void 0 && (_rtl$value = rtl.value) !== null && _rtl$value !== void 0 && _rtl$value.property) this.values.property = rtl.value.property;
if (rtl !== null && rtl !== void 0 && (_rtl$value2 = rtl.value) !== null && _rtl$value2 !== void 0 && _rtl$value2.value) this.values.value = rtl.value.value;
}
} // prefix
const usePrefix = this.onesyStyle.options.rule.prefix && (this.onesyStyleSheet === undefined || this.onesyStyleSheet.options.rule.prefix !== false) && (((_this$onesyStyleSheet2 = this.onesyStyleSheet) === null || _this$onesyStyleSheet2 === void 0 ? void 0 : _this$onesyStyleSheet2.onesyTheme) === undefined || this.onesyStyleSheet.onesyTheme.options.rule.prefix !== false) && // by default is true
((_this$parent2 = this.parent) === null || _this$parent2 === void 0 ? void 0 : _this$parent2.options.prefix) !== false;
if (usePrefix && this.values.property.indexOf('-') !== 0 && _default$i(() => this.values.value.indexOf('-') !== 0)) {
var _this$onesyStyle$subs;
const prefixes = ((_this$onesyStyle$subs = this.onesyStyle.subscriptions.rule.prefix.map({
value: this.values.value,
property: this.values.property
})) === null || _this$onesyStyle$subs === void 0 ? void 0 : _this$onesyStyle$subs.value) || [];
if (!!prefixes.length) {
prefixes.forEach(item => {
var _this$parent3;
const exists = (((_this$parent3 = this.parent) === null || _this$parent3 === void 0 ? void 0 : _this$parent3.rules) || []).find(rule_ => rule_ instanceof OnesyStyleRuleProperty && rule_.values.property === item.property && rule_.values.value === item.value);
if (!exists && this.parent) {
OnesyStyleRuleProperty.make(item.value, item.property, {
value_version: 'value',
pure: this.pure,
owner: this.parent,
parents: this.parents,
onesyStyleRule: this.onesyStyleRule,
onesyStyleSheet: this.parent.onesyStyleSheet,
onesyStyle: this.parent.onesyStyle
});
}
});
}
} // Add itself to owner rules
if (this.owner) {
const exists = this.owner.rules.find(rule => rule.value.id === this.id);
if (!exists) this.owner.rules.push({
property: this.property,
value: this
});
this.level_actual = this.owner.level_actual + 1;
} // Update values
this.updateValues();
} // Update only if onesyStyleSheet is version 'dynamic'
update(value) {
var _domElement$style;
// Init with value
if (value !== undefined) this.init(value); // Make selector
// ie. for animation, and animation-name
this.makeSelector(); // Update the rule
// method or OnesySubscription
if (value === undefined && ['method', 'onesy_subscription'].indexOf(this.value_version) > -1) {
if (this.value_version === 'method') this.values.value = _default$i(() => this.value(this.onesyStyleSheet.props));else if (this.value_version === 'onesy_subscription') this.values.value = this.value.value; // Value
this.values.value = is$1('function', this.values.value) ? _default$i(() => this.values.value(this.onesyStyleSheet.props)) : this.values.value;
this.values.value = valueResolve(this.values.property, this.values.value, this.onesyStyle).value[0];
} // Update values
this.updateValues();
const domElement = this.onesyStyleSheet.domElementForTesting || _default$h('browser') && window.document.createElement('div');
if (domElement) domElement.style[this.values.property] = this.values.value;
const valueNew = (domElement === null || domElement === void 0 ? void 0 : (_domElement$style = domElement.style) === null || _domElement$style === void 0 ? void 0 : _domElement$style[this.values.property]) || this.values.value; // Only if rule reference exists
if (this.owner.rule) {
// Only update if value is diff from previous update
if (this.owner.rule.style[this.values.property] !== valueNew) {
var _this$values$value;
const rule = this.owner.owner.rule || this.owner.owner.sheet; // For some reason important will not update the style property
// updating it through rule.style[property]
// only way is to fully remove the CSSStyleRule
// and insert a new one with new value
if (is$1('string', this.values.value) && (_this$values$value = this.values.value) !== null && _this$values$value !== void 0 && _this$values$value.includes('!important')) {
let index = Array.from((rule === null || rule === void 0 ? void 0 : rule.cssRules) || []).findIndex(item => item === this.owner.rule);
if (index > -1) {
_default$i(() => rule.deleteRule(index)); // Update owner values so it includes
// new update for this property value
this.owner.updateValues();
index = _default$i(() => rule.insertRule(this.owner.values.css));
if (index > -1) this.owner.rule = rule.cssRules[index];
}
} else _default$i(() => this.owner.rule.style[this.values.property] = this.values.value); // Update the values css string value
this.values.css = "".concat(this.values.property, ": ").concat(this.values.value, ";");
}
}
}
remove() {
this.clear();
}
makeSelector() {
if (['animation', 'animation-name'].some(item => this.values.property.indexOf(item) > -1)) {
const refs = getRefs(this.values.value);
const refValues = refs.map(item => this.onesyStyleSheet.onesyStyleSheetManager.names.keyframes[item]).filter(Boolean);
refs.forEach((ref, i) => this.values.value = this.values.value.replace("$".concat(ref), refValues[i])); // Update values
this.updateValues();
}
}
clear() {
var _this$owner;
// rule
if ((_this$owner = this.owner) !== null && _this$owner !== void 0 && _this$owner.rule) this.owner.rule.style[this.values.property] = ''; // rules
if (this.owner) {
const index = this.owner.rules.findIndex(item => item.value === this);
if (index > -1) this.owner.rules.splice(index, 1);
} // rules owned
this.parents.filter(parent => !(parent instanceof OnesyStyleSheet$1)).forEach(parent => {
const index = parent.rules_owned.findIndex(item => item.value === this);
if (index > -1) parent.rules_owned.splice(index, 1);
});
}
static make(value, property) {
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
value_version: 'value',
pure: false,
parents: [this]
};
return new OnesyStyleRuleProperty(value, property, options);
}
}
var OnesyStyleRuleProperty$1 = OnesyStyleRuleProperty;
function classNames(value) {
let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
let array = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
let classNameValues = [];
const method = (item, prop) => {
if (is$1('string', item) && item.length) classNameValues.push(item);else if (is$1('object', item)) Object.keys(item).forEach(prop_ => method(item[prop_], prop_));else if (is$1('array', item)) item.forEach(item_ => method(item_));else if (prop && !!item) classNameValues.push(prop);
}; // Move through the value
method(value);
classNameValues = classNameValues.filter(Boolean).map(item_ => {
let item = item_.trim();
if (['.', '#'].indexOf(item[0]) > -1) item = item.slice(1);
return "".concat(prefix || '').concat(item);
});
classNameValues = _default$m(classNameValues);
return array ? classNameValues : classNameValues.join(' ');
}
const optionsDefault$f = {
mode: 'regular',
value_version: 'value',
version: 'property',
pure: false,
index: 0,
sort: true,
prefix: true,
rtl: true
};
const env$1 = _default$k();
class OnesyStyleRule {
constructor(value, property) {
var _this = this;
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : optionsDefault$f;
_defineProperty(this, "value_version", 'value');
_defineProperty(this, "mode", 'regular');
_defineProperty(this, "version", 'property');
_defineProperty(this, "pure", false);
_defineProperty(this, "index", 0);
_defineProperty(this, "parents", []);
_defineProperty(this, "status", 'idle');
_defineProperty(this, "isVariable", false);
_defineProperty(this, "static", true);
_defineProperty(this, "rules_owned", []);
_defineProperty(this, "className_", '');
_defineProperty(this, "selector_", '');
_defineProperty(this, "classNames_", '');
_defineProperty(this, "keyframesName_", '');
_defineProperty(this, "values", {
value: undefined,
css: ''
});
_defineProperty(this, "rules", []);
_defineProperty(this, "makeRuleClassNameDefault", function () {
var _this$onesyStyle$opti;
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'a';
return "".concat(((_this$onesyStyle$opti = _this.onesyStyle.options) === null || _this$onesyStyle$opti === void 0 ? void 0 : _this$onesyStyle$opti.classNamePrefix) || '').concat(value, "-").concat(++_this.counter.className);
});
_defineProperty(this, "makeRuleKeyframesNameDefault", function () {
var _this$onesyStyle$opti2;
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'a';
return "".concat(((_this$onesyStyle$opti2 = _this.onesyStyle.options) === null || _this$onesyStyle$opti2 === void 0 ? void 0 : _this$onesyStyle$opti2.classNamePrefix) || '').concat(value, "-").concat(++_this.counter.keyframesName);
});
this.value = value;
this.property = property;
this.options = options;
this.options = { ...optionsDefault$f,
...this.options
};
this.init();
}
get selector() {
return this.selector_;
}
set selector(value) {
this.selector_ = value;
}
get className() {
return this.className_;
}
set className(value) {
const parentKeyframes = this.parent.version === 'at-rule';
if (!parentKeyframes) {
this.className_ = value; // Update classNames
if (!this.classNames.match(new RegExp("^(.)?".concat(this.className, " | (.)?").concat(this.className, " | (.)?").concat(this.className, "$"), 'g'))) this.classNames = "".concat(this.className, " ").concat(this.classNames).trim();
this.onesyStyleSheet.names.classNames[this.property] = this.className; // in onesyStyleSheetManager only for static sheets
if (this.onesyStyleSheet.version === 'static' && this.onesyStyleSheet.onesyStyleSheetManager) {
this.onesyStyleSheet.onesyStyleSheetManager.names.classNames[this.property] = this.className;
}
}
}
get classNames() {
return this.classNames_;
}
set classNames(value) {
this.classNames_ = value;
this.onesyStyleSheet.names.classes[this.property] = this.classNames; // in onesyStyleSheetManager only for static sheets
if (this.onesyStyleSheet.version === 'static' && this.onesyStyleSheet.onesyStyleSheetManager) {
this.onesyStyleSheet.onesyStyleSheetManager.names.classes[this.property] = this.classNames;
}
}
get keyframesName() {
return this.keyframesName_;
}
set keyframesName(value) {
this.keyframesName_ = value;
const property = this.property.indexOf('@') === 0 ? this.property.split(' ')[1] : this.property; // Update onesyStyleSheet keyframes
this.onesyStyleSheet.names.keyframes[property] = this.keyframesName; // in onesyStyleSheetManager only for static sheets
if (this.onesyStyleSheet.version === 'static' && this.onesyStyleSheet.onesyStyleSheetManager) {
if (!this.onesyStyleSheet.onesyStyleSheetManager.names.keyframes[property]) {
this.onesyStyleSheet.onesyStyleSheetManager.names.keyframes[property] = this.keyframesName;
}
}
}
get hash() {
return this.hash_;
}
get parent() {
return this.parents[this.parents.length - 1];
}
get response() {
return {
css: this.values.css
};
}
get css() {
return this.response.css;
}
get allOwnedCss() {
let value = this.values.css;
this.rules_owned.filter(item => item instanceof OnesyStyleRule).forEach(item => value += "\n\n".concat(item.allOwnedCss)); // Replace its own property selector with a constant
value = value.replace("".concat(this.selector || this.property, " {"), 'AMAUI_ITEM {');
return value;
}
get counter() {
return OnesyStyle$1.counter;
}
updateValues() {
let hash_ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
// Response
const selector = this.selector || this.property;
this.values.css = "".concat(selector, " {\n");
let empty = true;
this.rules.forEach((rule, index) => {
const css = rule.value.css;
if (css) {
empty = false;
this.values.css += "".concat(' '.repeat(rule.value.level_actual)).concat(css).concat('\n'.repeat(rule.value instanceof OnesyStyleRule && index !== this.rules.length - 1 ? 2 : 1));
}
});
this.values.css += "".concat(' '.repeat(this.level_actual), "}"); // Empty
// Only if it's a variable,
// in some use cases if there are no props in css,
// we still have to insertRule for dynamic rules
// so we have a rule ref for that onesyStyleRuleProperty to
// update with a new value on update
if (empty && (!this.className || this.onesyStyleSheet.version === 'static')) this.values.css = ''; // Hash
if (hash_) this.makeHash();
}
makeHash() {
if (!this.hash && this.static && this.onesyStyleSheet.onesyStyle.options.optimize && this.onesyStyleSheet.version === 'static' && this.version === 'property' && !(this.isVariable && this.onesyStyleSheet.mode === 'atomic')) this.hash_ = _default$e(this.onesyStyleSheet.mode === 'atomic' ? this.css : this.allOwnedCss);
}
init(value_) {
var _this$property,
_this2 = this;
let value = value_ !== undefined ? value_ : this.value; // Options
this.mode = this.options.mode || 'regular';
this.version = this.options.version || 'property';
this.pure = this.options.pure !== undefined ? this.options.pure : this.pure;
this.index = this.options.index !== undefined ? this.options.index : this.index;
this.owner = this.options.owner;
this.parents = this.options.parents || [];
this.onesyStyleSheet = this.options.onesyStyleSheet;
this.onesyStyle = this.options.onesyStyle;
if (this.id === undefined) this.id = getID();
if (this.level === undefined) this.level = this.parents.length - 1;
if (this.owner) this.level_actual = this.owner.level_actual === undefined ? 0 : this.owner.level_actual + 1; // Add to rules_owned to all parents
this.parents.filter(parent => !(parent instanceof OnesyStyleSheet$1)).forEach(parent => parent.rules_owned.push(this)); // Make string template value into an object
const valueString = () => {
const rule = {};
value.trim().split('\n').filter(Boolean).map(item => item.trim()).forEach(item => {
if (item) {
const items = item.split(':');
let value__ = items[1];
const property = items[0];
value__ = value__ && value__.trim().replace(';', '');
if (property && value__) rule[property] = _default$n(value__, {
decode: false
});
}
});
return rule;
};
if (is$1('string', value)) value = valueString();
if (is$1('object', value)) {
if (value['@pure'] !== undefined) this.pure = !!value['@pure'];
if (value['@p'] !== undefined) this.pure = !!value['@p'];
}
if (!this.pure && this.level === 0 && this.property.indexOf('@') !== 0) this.isVariable = true; // value method or onesySubscription
if (is$1('function', value)) this.value_version = 'method';else if (isOnesySubscription(value)) {
this.value_version = 'onesy_subscription';
if (!value.subscribed) value.subscribed = [];
if (value.subscribed.indexOf(this) === -1) {
value.subscribe(this.update.bind(this));
value.subscribed.push(this);
}
} else {
this.values.value = value;
}
const atRule = ((_this$property = this.property) === null || _this$property === void 0 ? void 0 : _this$property.indexOf('@')) === 0;
this.version = atRule ? 'at-rule' : 'property'; // method or OnesySubscription
if (['method', 'onesy_subscription'].indexOf(this.value_version) > -1) {
if (this.value_version === 'method') this.values.value = _default$i(() => value(this.onesyStyleSheet.props));else if (this.value_version === 'onesy_subscription') this.values.value = this.value.value; // Value
this.values.value = is$1('function', this.values.value) ? _default$i(() => this.values.value(this.onesyStyleSheet.props)) : this.values.value;
}
value = this.values.value;
if (is$1('object', value)) {
// Additional @classNames provided
if (value['@classNames'] || value['@cs']) {
const classNames$1 = classNames(value['@classNames'] || value['@cs']);
if (!this.classNames.match(new RegExp("^".concat(classNames$1, " | ").concat(classNames$1, " | ").concat(classNames$1, "$"), 'g'))) this.classNames = "".concat(this.classNames || '', " ").concat(classNames$1).trim();
} // Options
if (value['@options'] || value['@o']) this.options = _default$f(value['@options'] || value['@o'] || {}, this.options);
const props = Object.keys(value); // rules owned
const rules_owned = this.rules_owned; // Reset rules and rules owned
this.rules = [];
this.rules_owned = []; // Add all new rules
// and it adds new and existing again
props.forEach(prop => this.addProperty(prop, value[prop], this.rules.length, false, false)); // Remove all the previous rules
rules_owned.forEach(rule => rule.remove()); // Sort and making unique rules
this.unique; // Dynamic
const dynamic = function () {
let rule = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this2;
return rule.rules.some(item => is$1('function', item.value.value) || isOnesySubscription(item.value.value) || item.value instanceof OnesyStyleRule && dynamic(item.value));
}; // Static
this.static = !dynamic();
} // Add itself to owner rules
if (this.owner) {
const exists = this.owner.rules.find(rule => rule.value.id === this.id);
if (!exists) this.owner.rules.push({
property: this.property,
value: this
});
} // With this we have allOwnedCss
// available for hash value
this.updateValues(); // Status
this.status = 'inited';
}
addProperty(prop, value) {
var _parent$property;
let index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.rules.length;
let unique = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
let add = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
const atRule_ = prop.indexOf('@') === 0;
const parent = this;
const parentAtRule = this.version === 'at-rule';
const parentKeyFrames = parentAtRule && ((_parent$property = parent.property) === null || _parent$property === void 0 ? void 0 : _parent$property.indexOf('@keyframes')) > -1;
const selector = prop.indexOf('&') > -1 || parentAtRule || parentKeyFrames;
const isProperty = !(atRule_ || selector) || ['@font-face'].includes(parent.property);
const toSkip = ['@classNames', '@cs', '@options', '@o', '@pure', '@p'].indexOf(prop) > -1;
if (toSkip) return; // if it's a css property
if (isProperty) {
const property = cammelCaseToKebabCase(prop);
const {
value: ruleValues = [],
options
} = valueResolve(property, value, this.onesyStyle); // Add to rules
ruleValues.forEach(item => {
if (this.onesyStyleSheet.mode === 'regular' || !parent.isVariable) {
if (!!item) {
OnesyStyleRuleProperty$1.make(item, property, {
value_version: is$1('function', item) || isOnesySubscription(item) ? is$1('function', item) ? 'method' : 'onesy_subscription' : 'value',
pure: this.pure,
owner: parent,
parents: [...parent.parents, parent],
onesyStyleRule: parent,
onesyStyleSheet: parent.onesyStyleSheet,
onesyStyle: parent.onesyStyle,
...options.rule
});
}
} else if (this.onesyStyleSheet.mode === 'atomic' && parent.isVariable) {
OnesyStyleRule.make({
[property]: item
}, env$1.onesy_methods.makeName.next().value, {
mode: 'atomic',
version: 'property',
pure: this.pure,
index: this.index + 1 + index,
owner: parent.parent,
parents: [...parent.parents, parent],
onesyStyleSheet: parent.onesyStyleSheet,
onesyStyle: parent.onesyStyle
});
}
});
} else {
// Pre
this.onesyStyle.subscriptions.rule.pre.emit(null);
let rule;
const parents = [...parent.parents, parent]; // if its an at-rule
const atTopLevel = ['@import', '@charset', '@namespace', '@color-profile', '@property', '@font-feature-values', '@counter-style', '@keyframes', '@font-face', '@page'];
const atNested = ['@media', '@supports']; // if parent is keyframes
if (parentKeyFrames) {
rule = OnesyStyleRule.make(value, prop, {
mode: 'regular',
version: atRule_ ? 'at-rule' : 'property',
pure: false,
index,
owner: parent,
parents,
onesyStyleSheet: parent.onesyStyleSheet,
onesyStyle: parent.onesyStyle
});
} // if it's a top level at-rule
else if (atRule_ && atTopLevel.some(item => prop.indexOf(item) === 0)) {
rule = OnesyStyleRule.make(value, prop, {
mode: 'regular',
version: atRule_ ? 'at-rule' : 'property',
pure: false,
index,
owner: this.onesyStyleSheet,
parents,
onesyStyleSheet: parent.onesyStyleSheet,
onesyStyle: parent.onesyStyle
});
} // if it's @media or @supports or
// it's & or a $ ref value
else if (atRule_ && atNested.some(item => prop.indexOf(item) === 0) || selector) {
let owner;
for (let i = parents.length - 1; i >= 0; i--) {
owner = parents[i]; // Move it to nearest @media or @supports or OnesyStyleSheet parent as a rule in rules value
// only if the parent is at-rule @media or @supports, or OnesyStyleSheet
if (owner.version === 'at-rule' && atNested.some(item => owner.property.indexOf(item) === 0) || owner instanceof OnesyStyleSheet$1) break;
}
rule = OnesyStyleRule.make(value, prop, {
mode: 'regular',
version: atRule_ ? 'at-rule' : 'property',
pure: false,
index,
owner,
parents,
onesyStyleSheet: parent.onesyStyleSheet,
onesyStyle: parent.onesyStyle
});
} // Post
this.onesyStyle.subscriptions.rule.post.emit(rule);
} // Adding individual new prop
// Sort and making unique rules
if (unique) this.unique;
if (add) {
// Add
const added = this.add(); // Update
if (!added) this.rules_owned.forEach(rule => rule.update());
}
}
add() {
let update = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
// Update values
// manually adding the rule
if (!this.css) this.updateValues(); // Make selector
this.makeSelector(); // add for onesyStyleRule value
this.rules_owned.filter(rule => rule instanceof OnesyStyleRule).forEach(rule => rule.add()); // Update values
if (update) this.updateValues(); // Add rule if sheet is active
if (this.onesyStyleSheet.status === 'active') return this.addRuleToCss();
this.status = 'active';
}
updateProps() {
if (['method', 'onesy_subscription'].indexOf(this.value_version) > -1) this.init(); // Add
this.add(false); // Update
this.rules_owned.forEach(rule => rule.update()); // Update values
this.updateValues();
this.onesyStyle.subscriptions.rule.update_props.emit(this);
}
update(value) {
// Manual update
if (value !== undefined || ['method', 'onesy_subscription'].indexOf(this.value_version) > -1) this.init(value); // Add
this.add(false); // Update
this.rules_owned.forEach(rule => rule.update()); // Update values
this.updateValues();
this.onesyStyle.subscriptions.rule.update.emit(this);
}
remove() {
// Remove all own onesyStyleRules
this.rules_owned.filter(rule => rule instanceof OnesyStyleRule).forEach(rule => rule.remove()); // Only if rule and onesyStyleSheet.sheet exists
// find index of the rule in the sheet
// remove the rule from the sheet
const ref = this.onesyStyle.refs[this.hash]; // No ref or ref is main and ref.refs are empty
if (!ref || ref.main.rule === this && !ref.refs.length) {
if (ref) delete this.onesyStyle.refs[this.hash];
if (this.onesyStyleSheet.sheet) {
const index = Array.from(this.onesyStyleSheet.sheet.cssRules).findIndex(item => item === this.rule);
if (index > -1) this.onesyStyleSheet.sheet.deleteRule(index);
}
this.clear();
} else if (ref && ref.main.rule !== this) {
const indexRef = ref.refs.indexOf(this.onesyStyleSheet);
if (indexRef > -1) ref.refs.splice(indexRef, 1); // if ref is removed and there are no more refs trigger sheet remove
// which if that sheet has no more refs will be removed
if (!ref.refs.length && ref.main.sheet.status === 'remove') ref.main.sheet.remove();
this.clear();
}
}
addRuleToCss() {
// if !rule ref &
// if not a ref rule
if (!this.rule && !this.ref) {
const css = this.css;
if (css) {
const rule = this.owner.sheet || this.owner.rule;
if (rule !== null && rule !== void 0 && rule.cssRules) {
let index = rule.cssRules.length;
index = _default$i(() => rule.insertRule(css, index));
if (index !== undefined) {
const ruleCSS = rule.cssRules[index];
this.rule = ruleCSS;
this.onesyStyle.subscriptions.rule.add.emit(this);
return true;
}
}
}
}
}
addRuleRef() {
if (!this.rule) {
const rule = this.owner.sheet || this.owner.rule;
if (rule !== null && rule !== void 0 && rule.cssRules) {
const ref = Array.from(rule.cssRules).find(item => item.selectorText === this.selector);
if (ref !== undefined) this.rule = ref; // Move through rules
this.rules_owned.filter(rule_ => rule_ instanceof OnesyStyleRule).forEach(rule_ => rule_.addRuleRef());
}
}
}
makeSelector() {
if (!this.selector) {
// Make hash first so we can use refs
if (!this.hash) this.makeHash();
const parentAtRule = this.parent.version === 'at-rule';
const isKeyframes = this.property.indexOf('@keyframes') === 0; // Variable
if (this.isVariable || this.mode === 'atomic' || isKeyframes) {
// if it's a variable
this.makeRuleClassName(); // if it's a keyframes rule
this.makeRuleKeyframesName();
} else {
// Make property the selector
this.selector = this.property; // level 0 property inside an at-rule
if (parentAtRule && this.version === 'property') {
// & ref
let parent = this.parent;
while (parent.version === 'at-rule') parent = parent.parent;
this.selector = this.selector.replace(/&/g, parent.selector); // properties ie. body should remain the same targeting html element
// we only replace $ ref values in properties
// $ ref
const refs = getRefs(this.property);
refs.forEach(ref => {
const className = this.makeClassName(ref);
const regex = new RegExp("\\$".concat(ref), 'g');
this.selector = this.property.replace(regex, ".".concat(className));
});
} // other regular selectors
// and & value rules
else {
// & ref
this.selector = this.selector.replace(/&/g, this.parent.selector); // $ ref
const refs = getRefs(this.selector);
refs.forEach(ref => {
const className = this.makeClassName(ref);
const regex = new RegExp("\\$".concat(ref), 'g');
this.selector = this.selector.replace(regex, ".".concat(className));
});
}
} // Move through the rules
this.rules.forEach(rule => rule.value.makeSelector()); // Update values without hash
this.updateValues(false);
}
}
makeClassName(property, rule) {
var _this$onesyStyleSheet, _this$onesyStyle$subs;
const names = ((_this$onesyStyleSheet = this.onesyStyleSheet.onesyStyleSheetManager) === null || _this$onesyStyleSheet === void 0 ? void 0 : _this$onesyStyleSheet.names) || this.onesyStyleSheet.names;
const cached = names.classNames[property];
if (cached) return cached; // onesyStyle ref
// ref className already exists for the same hash
const ref = this.onesyStyle.refs[this.hash]; // Only reuse classNames for static onesyStyleSheets and for variables only not & rules
if (rule instanceof OnesyStyleRule && (rule.isVariable || rule.mode === 'atomic') && this.hash && ref && this.onesyStyleSheet.version === 'static') {
// Push onesyStyleSheet ref if it doesn't already exist in refs
if (ref.main.sheet !== this.onesyStyleSheet && ref.refs.indexOf(this.onesyStyleSheet) === -1) ref.refs.push(this.onesyStyleSheet); // Update rule ref
rule.ref = ref;
return ref.className;
} // Make a className
const className = // Make with plugin/s
((_this$onesyStyle$subs = this.onesyStyle.subscriptions.className.name.map({
property,
value: rule === null || rule === void 0 ? void 0 : rule.value
})) === null || _this$onesyStyle$subs === void 0 ? void 0 : _this$onesyStyle$subs.value) || // Make with a default method
this.makeRuleClassNameDefault(property); // Add to onesyStyle ref,
// only reuse classNames for static onesyStyleSheets
if (rule instanceof OnesyStyleRule && (rule.isVariable || rule.mode === 'atomic') && this.hash && this.onesyStyleSheet.version === 'static') {
this.onesyStyle.refs[this.hash] = {
main: {
sheet: this.onesyStyleSheet,
rule: this
},
className,
refs: []
};
} // if no rule, means it's a non-existent (or dynamic) variable
// so cache the className value as this value
if (!rule) {
this.onesyStyleSheet.names.classNames[property] = className;
this.onesyStyleSheet.names.classes[property] = className;
if (this.onesyStyleSheet.version === 'static' && this.onesyStyleSheet.onesyStyleSheetManager) {
this.onesyStyleSheet.onesyStyleSheetManager.names.classNames[property] = className;
this.onesyStyleSheet.onesyStyleSheetManager.names.classes[property] = className;
}
}
return className;
}
makeRuleClassName() {
let property = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.property;
let rule = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
if (rule instanceof OnesyStyleRule && (rule.isVariable || rule.mode === 'atomic') && !rule.className) {
var _this$onesyStyleSheet2;
const names = ((_this$onesyStyleSheet2 = this.onesyStyleSheet.onesyStyleSheetManager) === null || _this$onesyStyleSheet2 === void 0 ? void 0 : _this$onesyStyleSheet2.names) || this.onesyStyleSheet.names;
const cached = names.classNames[rule.property];
if (cached && rule.className) return cached; // Make a className
// Pre
this.onesyStyle.subscriptions.className.pre.emit(null); // Name
const className = this.makeClassName(property, rule); // Post
this.onesyStyle.subscriptions.className.post.emit(className);
rule.className = className;
rule.selector = ".".concat(className);
return className;
}
}
makeRuleKeyframesName() {
let property_ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.property;
let rule = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
if (rule instanceof OnesyStyleRule && !rule.keyframesName && rule.property.indexOf('@keyframes') === 0) {
var _this$onesyStyleSheet3, _this$onesyStyle$subs2;
const keyframe = property_.indexOf('@keyframes') === 0;
const property = keyframe ? property_.split(' ')[1] : property_;
const names = ((_this$onesyStyleSheet3 = this.onesyStyleSheet.onesyStyleSheetManager) === null || _this$onesyStyleSheet3 === void 0 ? void 0 : _this$onesyStyleSheet3.names) || this.onesyStyleSheet.names;
const cached = names.keyframes[property];
if (cached) return cached; // Make a keyframes name value
// Pre
this.onesyStyle.subscriptions.keyframes.pre.emit(null); // Name
const keyframesName = // Make with plugin/s
((_this$onesyStyle$subs2 = this.onesyStyle.subscriptions.keyframes.name.map({
property,
value: rule.value
})) === null || _this$onesyStyle$subs2 === void 0 ? void 0 : _this$onesyStyle$subs2.value) || // Make with a default method
this.makeRuleKeyframesNameDefault(property); // Post
this.onesyStyle.subscriptions.keyframes.post.emit(keyframesName);
rule.keyframesName = keyframesName; // Add to selector as well
rule.selector = "@keyframes ".concat(keyframesName);
}
}
get rule() {
return this.rule_;
}
set rule(rule) {
var _this$rule, _this$rule$cssRules;
// Update active status
this.status = 'active';
this.rule_ = rule;
if (!!((_this$rule = this.rule) !== null && _this$rule !== void 0 && (_this$rule$cssRules = _this$rule.cssRules) !== null && _this$rule$cssRules !== void 0 && _this$rule$cssRules.length)) {
Array.from(this.rule.cssRules).forEach(item => {
let selector = item.selectorText;
if (item instanceof CSSMediaRule) selector = "@media ".concat(item.conditionText);else if (item instanceof CSSSupportsRule) selector = "@supports ".concat(item.conditionText);
const rule_ = this.rules.find(rule__ => rule__.value.selector === selector);
if (rule_) rule_.value.rule = item;
});
}
}
get unique() {
var _this$onesyStyleSheet4, _this$onesyStyleSheet5;
// Remove duplicate rules
const values = [];
this.rules.forEach((rule, index) => {
const exists = rule instanceof OnesyStyleRuleProperty$1 && values.find(item => item instanceof OnesyStyleRuleProperty$1 && item.values.property === rule.values.property && item.values.value === rule.values.value);
if (exists) this.rules.splice(index, 1);else values.push(rule);
}); // Native sort based on levels first
// for making, updating & refs
this.rules.sort((a, b) => {
if (a.value.level === b.value.level) return 0;
return a.value.level < b.value.level ? -1 : 1;
});
const atRule = this.version === 'at-rule'; // Sort
const useSort = !atRule && this.onesyStyle.options.rule.sort && (this.onesyStyleSheet !== undefined || this.onesyStyleSheet.options.rule.sort !== false) && (((_this$onesyStyleSheet4 = this.onesyStyleSheet) === null || _this$onesyStyleSheet4 === void 0 ? void 0 : _this$onesyStyleSheet4.onesyTheme) !== undefined || ((_this$onesyStyleSheet5 = this.onesyStyleSheet.onesyTheme) === null || _this$onesyStyleSheet5 === void 0 ? void 0 : _this$onesyStyleSheet5.options.rule.sort) !== false) && // by default is true
this.options.sort !== false;
if (useSort) {
this.onesyStyle.subscriptions.rules.sort.map(this.rules); // Post
this.onesyStyle.subscriptions.rules.sort.emit(this);
}
return this.rules;
}
clear() {
this.rule = undefined;
this.ref = undefined;
this.status = 'idle'; // rules
if (this.owner) {
const index = this.owner.rules.findIndex(item => item.value === this);
if (index > -1) this.owner.rules.splice(index, 1);
} // rules owned
this.parents.filter(parent => !(parent instanceof OnesyStyleSheet$1)).forEach(parent => {
const index = parent.rules_owned.findIndex(item => item.value === this);
if (index > -1) parent.rules_owned.splice(index, 1);
}); // remove it's selector
// or keyframes name from
// sheet and sheetManager
if (this.className) {
delete this.onesyStyleSheet.names.classNames[this.property];
delete this.onesyStyleSheet.names.classes[this.property];
delete this.onesyStyleSheet.onesyStyleSheetManager.names.classNames[this.property];
delete this.onesyStyleSheet.onesyStyleSheetManager.names.classes[this.property];
} else if (this.keyframesName) {
const property = this.property.split(' ')[1];
delete this.onesyStyleSheet.names.keyframes[property];
delete this.onesyStyleSheet.onesyStyleSheetManager.names.keyframes[property];
}
this.onesyStyle.subscriptions.rule.remove.emit(this);
}
static make(value, property) {
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
mode: 'regular',
version: 'property',
pure: false,
index: 0,
parents: [this]
};
return new OnesyStyleRule(value, property, options);
}
}
var OnesyStyleRule$1 = OnesyStyleRule;
const env = _default$k();
const optionsDefault$e = {
style: {
attributes: {}
},
rule: {
sort: true,
prefix: true,
rtl: true
}
};
class OnesyStyleSheet {
constructor(value) {
var _this = this;
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _default$j(optionsDefault$e);
_defineProperty(this, "version", 'static');
_defineProperty(this, "mode", 'regular');
_defineProperty(this, "pure", false);
_defineProperty(this, "priority", 'upper');
_defineProperty(this, "status", 'idle');
_defineProperty(this, "props_", {});
_defineProperty(this, "values", {
css: ''
});
_defineProperty(this, "rules", []);
_defineProperty(this, "names", {
classNames: {},
classes: {},
keyframes: {},
styles: function () {
const value = [];
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
args.forEach(arg => {
if (_this.names.classes[arg]) value.push(_this.names.classes[arg]);
});
return value.join(' ');
}
});
this.value = value;
this.options = options;
this.options = _default$f(options, optionsDefault$e, {
copy: true
});
this.init();
}
get props() {
return this.props_;
}
set props(props) {
if (this.propsAreNew(props)) {
this.props_ = _default$j(props); // Update if new props are set
this.updateProps();
}
}
get response() {
// Response
this.values.css = "";
this.rules.filter(rule => !rule.value.ref).forEach(rule => {
const css = rule.value.css;
if (css) {
this.values.css += "\n".concat(css, "\n");
}
});
return this.values;
}
get css() {
return this.response.css;
}
get sort() {
// Sort
// Native sort based on levels first
// for making, updating & refs
this.rules.sort((a, b) => {
if (a.value.level === b.value.level) return 0;
return a.value.level < b.value.level ? -1 : 1;
}); // and then based on pure
// pure rules have lower priority, are on top
// more specific rules are on bottom have higher specificity
this.rules.sort((a, b) => {
if (a.value.pure && !b.value.pure) return -1;
if (b.value.pure && !a.value.pure) return 1;
return 0;
});
return this.rules;
}
init() {
var _this$onesyStyleSheet;
// Options
this.version = this.options.version || this.version;
this.mode = this.options.mode || this.mode;
this.pure = this.options.pure || this.pure;
this.priority = this.options.priority || this.priority;
this.onesyTheme = this.options.onesyTheme;
this.onesyStyleSheetManager = this.options.onesyStyleSheetManager;
this.onesyStyle = this.options.onesyStyle;
this.props = this.options.props;
this.id = getID(); // Inherits first from onesyStyle
this.mode = this.onesyStyle.mode || this.mode; // Reset rules
this.rules = []; // If value is an object
if (is$1('object', this.value)) {
// Sort all properties so at-rules are at the start (ie. @keyframes for animation makeSelector value)
// but @media rules go at the bottom
const props = Object.keys(this.value).sort((a, b) => {
if (a.indexOf('@keyframes') > -1) return -1;
if (b.indexOf('@') > -1) return 1;
return 0;
});
const ignore = ['@pure', '@p']; // Make an OnesyStyleRule for all lvl 0 props
const propsAll = props.filter(prop => ignore.indexOf(prop) === -1).flatMap(prop => is$1('array', this.value[prop]) ? this.value[prop].map(item => ({
property: prop,
value: item
})) : {
property: prop,
value: this.value[prop]
});
propsAll.forEach((item, index) => this.makeRule(item.property, item.value, {
index
})); // Pure
const pure = { ...(this.value['@p'] || {}),
...(this.value['@pure'] || {})
};
const pureAll = Object.keys(pure).flatMap(prop => ({
property: prop,
value: pure[prop]
}));
pureAll.forEach((item, index) => this.makeRule(item.property, item.value, {
index: props.length + index,
pure: true
})); // Sort
this.sort; // Make selectors
// on init so they are
// available on init in node for
// critical css extraction
this.rules.forEach(rule => {
// Update values
rule.value.updateValues(false); // Update owned rules css
// to use for allCss and hash value
rule.value.rules_owned.filter(rule_ => rule_ instanceof OnesyStyleRule$1).forEach(rule_ => rule_.updateValues()); // Make selectors
rule.value.makeSelector();
});
} // Add to onesyStyle and onesyStyleSheetManager
if (this.onesyStyleSheetManager) (_this$onesyStyleSheet = this.onesyStyleSheetManager.sheets[this.version]) === null || _this$onesyStyleSheet === void 0 ? void 0 : _this$onesyStyleSheet.push(this);
if (this.onesyStyleSheetManager && this.onesyStyleSheetManager.options.onesy_style_cache) this.onesyStyle.sheets.push(this); // Update inited status
this.status = 'inited';
}
addRule(value, property_) {
let add = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
const isDynamic = dynamic(value);
if (value !== undefined && (this.version === 'static' && !isDynamic || this.version === 'dynamic' && isDynamic)) {
let property = property_ !== undefined ? property_ : env.onesy_methods.makeName.next().value;
const props = is$1('object', this.value) && Object.keys(this.value) || [];
if (!!props.length) while (props.indexOf(property) > -1) property = env.onesy_methods.makeName.next().value;
const isPure = ['@pure', '@p'];
if (isPure.indexOf(property) > -1 && is$1('object', value)) {
Object.keys(value).forEach(item => this.makeRule(item, value[item]));
} else {
const rule = this.makeRule(property, value); // Add
if (add) rule.add();
if (rule.status === 'active') {
const response = {
className: rule.className,
classNames: rule.classNames,
keyframeName: rule.keyframesName
};
return response;
}
}
}
}
add(props) {
// Update props
if (props !== undefined) this.props = props;
if (this.status !== 'active' && !!this.rules.length && this.rules.some(rule => rule.value && !!rule.value.rules.length)) {
// If in browser only
if (_default$h('browser')) {
var _this$options$style;
// Make a style tag
const attributes = {
element: {
type: 'text/css',
id: 'a' + this.id
},
data: { ...(((_this$options$style = this.options.style) === null || _this$options$style === void 0 ? void 0 : _this$options$style.attributes) || {}),
onesy: true,
mode: this.mode,
pure: this.pure,
version: this.version,
name: this.options.name
}
};
this.element = this.onesyStyle.renderer.make(attributes); // Add to the DOM
this.onesyStyle.renderer.add(this.element, this.priority, attributes); // Add
this.rules.filter(item => !item.value.ref).forEach(item => {
item.value.add();
}); // Make css
// Only if it's not a ref rule
// this.rules.filter(item => !item.value.ref).forEach(item => item.value.addRuleToCss());
this.element.innerHTML = this.response.css; // Make a sheet ref
this.sheet = this.element.sheet; // Move through rules
this.rules.forEach(rule => rule.value.addRuleRef()); // Update active status
this.status = 'active';
this.onesyStyle.subscriptions.sheet.add.emit(this);
} // Node only make names
else {
this.rules.filter(item => !item.value.ref).forEach(item => {
// Add
item.value.add();
});
} // Dom
this.domElementForTesting = _default$h('browser') && window.document.createElement('div');
}
}
update(value) {
if (is$1('object', value)) {
// Update active status
if (this.status === 'remove') this.status = 'active'; // Update all the items to pure
if (this.pure) Object.keys(value).forEach(item => {
if (is$1('object', value[item])) value[item]['@p'] = true;
});
const properties = {
add: [],
update: [],
remove: []
};
const items = {
previous: this.rules,
new: []
};
const pure = { ...(value['@pure'] || {}),
...(value['@p'] || {})
}; // Props
Object.keys(value).filter(item => ['@pure', '@p'].indexOf(item) === -1).forEach(prop => {
if (is$1('array', value[prop])) value[prop].forEach(item => items.new.push({
property: prop,
value: item,
parents: prop
}));else items.new.push({
property: prop,
value: value[prop],
parents: prop
});
}); // Pure
Object.keys(pure).forEach(prop => {
items.new.push({
property: prop,
value: pure[prop],
parents: prop
});
}); // Extract any & ref rules from new and add 'em to new
const add = [];
const refValues = (item, parents_) => {
if (is$1('object', item)) Object.keys(item).forEach(key => {
if (key !== null && key !== void 0 && key.includes('&')) add.push({
property: key,
value: item[key],
parents: parents_
});
refValues(item[key], parents_ + ' ' + key);
});
};
items.new.forEach(item => refValues(item.value, item.property));
items.new.push(...add);
const parents = item => {
const parents_ = item.value.parents.filter(item_ => !(item_ instanceof OnesyStyleSheet));
return parents_.map(item_ => item_.property).join(' ') || item.value.property;
}; // To update, add
items.new.forEach(itemNew => {
const previouses = items.previous.filter(itemPrevious => (itemPrevious.value.pure === !!itemNew.value['@pure'] || itemNew.value['@p']) && itemPrevious.property === itemNew.property && parents(itemPrevious) === itemNew.parents); // Add or update
if (!previouses.length) properties.add.push(itemNew);else if (previouses.some(item => parents(item) === itemNew.parents && _default$e(item.value.values.value) !== _default$e(itemNew.value))) properties.update.push(itemNew);
}); // To remove
items.previous.forEach(itemPrevious => {
const newItem = items.new.find(itemNew => itemPrevious.value.pure === !!(itemNew.value['@pure'] || itemNew.value['@p']) && itemPrevious.property === itemNew.property && parents(itemPrevious) === itemNew.parents); // Remove
if (!newItem) properties.remove.push(itemPrevious);
}); // Activity
Object.keys(properties).forEach(activity => {
// Activity items
properties[activity].forEach(item => {
const rule = this.rules.find(rule_ => rule_ === item || rule_.value.pure === !!(item.value['@pure'] || item.value['@p']) && rule_.value.property === item.property && item.parents === parents(rule_));
switch (activity) {
case 'add':
this.addRule(item.value, item.property);
break;
case 'remove':
if (rule) rule.value.remove();
break;
case 'update':
if (rule) rule.value.update(item.value);
break;
}
});
});
this.onesyStyle.subscriptions.sheet.update.emit(this);
}
}
remove() {
// Remove all the rules
const rules = this.rules.map(item => item.value);
rules.forEach(rule => rule.remove()); // Remove the style tag, only if all the rules are removed
if (!this.rules.length) {
var _this$element;
if (is$1('function', (_this$element = this.element) === null || _this$element === void 0 ? void 0 : _this$element.remove)) this.onesyStyle.renderer.remove(this.element); // Remove from onesystyle
let index = this.onesyStyle.sheets.findIndex(sheet => sheet.id === this.id);
if (index > -1) this.onesyStyle.sheets.splice(index, 1); // Remove from onesyStyleSheetManager
index = this.onesyStyleSheetManager.sheets[this.version].findIndex(sheet => sheet.id === this.id);
if (index > -1) this.onesyStyleSheetManager.sheets[this.version].splice(index, 1); // Update idle status
this.status = 'idle';
this.element = undefined;
this.sheet = undefined;
this.onesyStyle.subscriptions.sheet.remove.emit(this);
} else {
// Update remove status
this.status = 'remove';
}
}
updateProps() {
this.rules.forEach(rule => rule.value.updateProps());
this.onesyStyle.subscriptions.sheet.update_props.emit(this);
}
propsAreNew(props) {
return (props && Object.keys(props).reduce((result, item) => result += item + String(props[item]), '')) !== (this.props && Object.keys(this.props).reduce((result, item) => result += item + String(this.props[item]), ''));
}
makeRule(property, value) {
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
index: this.rules.length,
pure: false
};
// Pre
this.onesyStyle.subscriptions.rule.pre.emit(null);
const rule = OnesyStyleRule$1.make(value, property, {
mode: 'regular',
version: 'property',
pure: options.pure !== undefined ? options.pure : this.pure,
index: options.index,
owner: this,
parents: [this],
onesyStyleSheet: this,
onesyStyle: this.onesyStyle
}); // Post
this.onesyStyle.subscriptions.rule.post.emit(rule);
return rule;
}
}
var OnesyStyleSheet$1 = OnesyStyleSheet;
const optionsDefault$d = {
mode: 'regular',
pure: false,
priority: 'upper',
style: {
attributes: {}
},
rule: {
sort: true,
prefix: true,
rtl: true
},
onesy_style_cache: true
};
class OnesyStyleSheetManager {
constructor(value) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : optionsDefault$d;
_defineProperty(this, "status", 'idle');
_defineProperty(this, "mode", 'regular');
_defineProperty(this, "pure", false);
_defineProperty(this, "priority", 'upper');
_defineProperty(this, "values", {
css: ''
});
_defineProperty(this, "properties", {
static: [],
dynamic: []
});
_defineProperty(this, "sheets", {
static: [],
dynamic: []
});
_defineProperty(this, "names", {
classNames: {},
classes: {},
keyframes: {}
});
_defineProperty(this, "users", 0);
this.value = value;
this.options = options;
this.options = _default$f(options, optionsDefault$d, {
copy: true
});
this.init();
}
propertiesVersion() {
let version = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'static';
let properties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.properties;
const value = {
'@pure': {}
};
properties[version].forEach(item => {
if (item.value['@pure']) value['@pure'][item.property] = item.value;else value[item.property] = item.value;
});
if (!Object.keys(value['@pure']).length) delete value['@pure'];
return value;
}
set props(value) {
const ids = is$1('array', value.ids) ? value.ids : [value.ids]; // Update all dynamic sheets from ids value
this.sheets.dynamic.filter(sheet => ids.some(id => sheet.id === id)).forEach(sheet => {
// Update
sheet.props = value.props;
});
this.onesyStyle.subscriptions.sheet_manager.update_props.emit(this, value);
}
get ids() {
const ids = {
static: [],
dynamic: []
};
Object.keys(this.sheets).forEach(version => {
this.sheets[version].forEach(sheet => ids[version].push(sheet.id));
});
return ids;
}
get response() {
// Response
this.values.css = ""; // Static
this.sheets.static.forEach(sheet => {
const {
css
} = sheet.response;
if (css) {
this.values.css += "\n".concat(css, "\n");
}
}); // Dynamic
this.sheets.dynamic.forEach(sheet => {
const {
css
} = sheet.response;
if (css) {
this.values.css += "\n".concat(css, "\n");
}
});
return this.values;
}
get css() {
return this.response.css;
}
init() {
var _this$options$style, _this$options$style$a;
this.id = getID(); // Options
this.mode = this.options.mode || this.mode;
this.pure = this.options.pure !== undefined ? this.options.pure : this.pure;
this.priority = this.options.priority || this.priority;
this.onesyTheme = this.options.onesyTheme;
this.onesyStyle = this.options.onesyStyle; // Inherits first from onesyStyle
this.mode = this.onesyStyle.mode || this.mode;
this.options.name = this.options.name || ((_this$options$style = this.options.style) === null || _this$options$style === void 0 ? void 0 : (_this$options$style$a = _this$options$style.attributes) === null || _this$options$style$a === void 0 ? void 0 : _this$options$style$a.method) || this.mode; // if value is an object
if (is$1('object', this.value)) {
// Props put into values.static and values.dynamic
const versions = this.versions(this.value); // Add values to the properties
Object.keys(versions).forEach(version => {
versions[version].forEach(item => {
this.properties[version].push(item);
});
}); // Make a static sheet only if it doesn't already exist
if (!!this.properties.static.length && !this.sheets.static.length) {
new OnesyStyleSheet$1(this.propertiesVersion(), {
version: 'static',
mode: this.mode,
pure: this.pure,
priority: this.priority,
onesyStyleSheetManager: this,
onesyTheme: this.onesyTheme,
onesyStyle: this.onesyStyle,
props: {},
...this.options
});
}
} // Update names with methods
names(this.names); // Add to onesyStyle
this.onesyStyle.sheet_managers.push(this); // Update inited status
this.status = 'inited';
}
add(props) {
let response = {
ids: {
static: this.ids.static,
dynamic: []
}
};
response = _default$f(response, this.names, {
copy: true
});
const sheets = [...this.sheets.static]; // If no static sheet
// Usecase React.StrictMode purposefull add / remove / add of elements
// while preserving their state meaning it will add, remove the static sheet
// yet reuse the OnesyStyleSheetManager instance
if (!this.sheets.static.length) {
if (!!this.properties.static.length) {
const sheet = new OnesyStyleSheet$1(this.propertiesVersion(), {
version: 'static',
mode: this.mode,
pure: this.pure,
priority: this.priority,
onesyStyleSheetManager: this,
onesyTheme: this.onesyTheme,
onesyStyle: this.onesyStyle,
props: {},
...this.options
});
sheets.push(sheet); // Add dynamic names into the response
response = _default$f(response, sheet.names, {
copy: true
}); // Add id to the response
response.ids.static.push(sheet.id);
}
} // Reviving the static status removed
if (!!this.sheets.static.length) this.sheets.static.filter(sheet => sheet.status === 'remove').forEach(sheet => sheet.update(this.propertiesVersion())); // Static
sheets.filter(sheet => sheet.version === 'static').forEach(sheet => {
// Add
sheet.add(props);
}); // if values.dynamic min 1 prop make a dynamic sheet
if (!!this.properties.dynamic.length) {
const sheet = new OnesyStyleSheet$1(this.propertiesVersion('dynamic'), {
version: 'dynamic',
mode: this.mode,
pure: this.pure,
priority: this.priority,
onesyStyleSheetManager: this,
onesyTheme: this.onesyTheme,
onesyStyle: this.onesyStyle,
props: {},
...this.options
}); // Add
sheet.add(props); // atm
sheets.push(sheet); // Add dynamic names into the response
response = _default$f(response, sheet.names, {
copy: true
}); // Add id to the response
response.ids.dynamic.push(sheet.id);
}
if (_default$h('browser')) {
// Status
this.status = 'active';
} // Update object names value
names(response); // Update users value
this.users++;
this.onesyStyle.subscriptions.sheet_manager.add.emit(this);
return response;
} // Make sure to also call all the update hooks
update(value) {
// Make all props into remove, add, update props
if (is$1('object', value)) {
const versions = {
previous: {
static: this.properties.static,
dynamic: this.properties.dynamic
},
new: {
static: [],
dynamic: []
}
}; // Props put into values.static and values.dynamic
const versions_values = this.versions(value); // Add values to the versions new
Object.keys(versions_values).forEach(version => {
versions_values[version].forEach(item => {
versions.new[version].push(item);
});
}); // Update
// Static
if (!!versions.new.static.length) this.sheets.static.forEach(sheet => sheet.update(this.propertiesVersion('static', versions_values))); // Dynamic
if (!!versions.new.dynamic.length) this.sheets.dynamic.forEach(sheet => sheet.update(this.propertiesVersion('dynamic', versions_values)));
}
const response = {
ids: this.ids,
...this.names
};
this.onesyStyle.subscriptions.sheet_manager.update.emit(this);
return response;
}
remove() {
let ids_ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
const ids = is$1('array', ids_) ? ids_ : [ids_]; // Remove all dynamic sheets from ids value
this.sheets.dynamic.filter(sheet => ids.some(id => sheet.id === id)).forEach(sheet => {
// Remove
sheet.remove();
}); // Update users value
this.users--; // If no more users
if (!this.users) {
this.sheets.static.forEach(sheet => {
// Remove
sheet.remove();
}); // If no more !sheets.static.length and !sheets.dynamic.length
// update status to idle else update status to remove
this.status = !this.sheets.static.length && !this.sheets.dynamic.length ? 'idle' : 'remove';
this.onesyStyle.subscriptions.sheet_manager.remove.emit(ids, this);
}
}
versions(value) {
const response = {
static: [],
dynamic: []
};
if (is$1('object', value)) {
const pureValues = {
static: {},
dynamic: {}
}; // pure props
Object.keys(value).filter(prop => value[prop]['@pure'] === true || value[prop]['@p'] === true).forEach(prop => {
pureValues[!dynamic(value[prop]) ? 'static' : 'dynamic'][prop] = value[prop];
}); // @pure object
const pure = _default$f(value['@pure'] || {}, value['@p'] || {});
Object.keys(pure).forEach(prop => {
const isStatic = !dynamic(pure[prop]);
pureValues[isStatic ? 'static' : 'dynamic'][prop] = { ..._default$f(pureValues[isStatic ? 'static' : 'dynamic'][prop] || {}, pure[prop]),
'@pure': true
};
}); // regular props
Object.keys(value).filter(prop => ['@pure', '@p'].indexOf(prop) === -1 && !(value[prop]['@pure'] === true || value[prop]['@p'] === true)).forEach(prop => {
response[!dynamic(value[prop]) ? 'static' : 'dynamic'].push({
property: prop,
value: value[prop]
});
}); // Merge pure and regular props
response.static = [...Object.keys(pureValues.static).map(prop => ({
property: prop,
value: pureValues.static[prop]
})), ...response.static];
response.dynamic = [...Object.keys(pureValues.dynamic).map(prop => ({
property: prop,
value: pureValues.dynamic[prop]
})), ...response.dynamic];
}
return response;
}
}
var OnesyStyleSheetManager$1 = OnesyStyleSheetManager;
var alpha$1 = {};
var colorToRgb$1 = {};
var isValid$1 = {};
// Unique ID creation requires a high quality random # generator. In the browser we therefore
// require the crypto API and do not support built-in fallback to lower quality random number
// generators (like Math.random()).
var getRandomValues;
var rnds8 = new Uint8Array(16);
function rng() {
// lazy load so that environments that need to polyfill have a chance to do so
if (!getRandomValues) {
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
// find the complete implementation of crypto (msCrypto) on IE11.
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
if (!getRandomValues) {
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
}
}
return getRandomValues(rnds8);
}
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
function validate(uuid) {
return typeof uuid === 'string' && REGEX.test(uuid);
}
/**
* Convert array of 16 byte values to UUID string format of the form:
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
*/
var byteToHex = [];
for (var i = 0; i < 256; ++i) {
byteToHex.push((i + 0x100).toString(16).substr(1));
}
function stringify(arr) {
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
// Note: Be careful editing this code! It's been tuned for performance
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
// of the following:
// - One or more input array values don't map to a hex octet (leading to
// "undefined" in the uuid)
// - Invalid input values for the RFC `version` or `variant` fields
if (!validate(uuid)) {
throw TypeError('Stringified UUID is invalid');
}
return uuid;
}
//
// Inspired by https://github.com/LiosK/UUID.js
// and http://docs.python.org/library/uuid.html
var _nodeId;
var _clockseq; // Previous uuid creation time
var _lastMSecs = 0;
var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
function v1(options, buf, offset) {
var i = buf && offset || 0;
var b = buf || new Array(16);
options = options || {};
var node = options.node || _nodeId;
var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
// specified. We do this lazily to minimize issues related to insufficient
// system entropy. See #189
if (node == null || clockseq == null) {
var seedBytes = options.random || (options.rng || rng)();
if (node == null) {
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
}
if (clockseq == null) {
// Per 4.2.2, randomize (14 bit) clockseq
clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
}
} // UUID timestamps are 100 nano-second units since the Gregorian epoch,
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
// cycle to simulate higher resolution clock
var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
if (dt < 0 && options.clockseq === undefined) {
clockseq = clockseq + 1 & 0x3fff;
} // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
// time interval
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
nsecs = 0;
} // Per 4.2.1.2 Throw error if too many uuids are requested
if (nsecs >= 10000) {
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
}
_lastMSecs = msecs;
_lastNSecs = nsecs;
_clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
msecs += 12219292800000; // `time_low`
var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
b[i++] = tl >>> 24 & 0xff;
b[i++] = tl >>> 16 & 0xff;
b[i++] = tl >>> 8 & 0xff;
b[i++] = tl & 0xff; // `time_mid`
var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
b[i++] = tmh >>> 8 & 0xff;
b[i++] = tmh & 0xff; // `time_high_and_version`
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
b[i++] = clockseq & 0xff; // `node`
for (var n = 0; n < 6; ++n) {
b[i + n] = node[n];
}
return buf || stringify(b);
}
function parse(uuid) {
if (!validate(uuid)) {
throw TypeError('Invalid UUID');
}
var v;
var arr = new Uint8Array(16); // Parse ########-....-....-....-............
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
arr[1] = v >>> 16 & 0xff;
arr[2] = v >>> 8 & 0xff;
arr[3] = v & 0xff; // Parse ........-####-....-....-............
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
arr[5] = v & 0xff; // Parse ........-....-####-....-............
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
arr[7] = v & 0xff; // Parse ........-....-....-####-............
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
arr[9] = v & 0xff; // Parse ........-....-....-....-############
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
arr[11] = v / 0x100000000 & 0xff;
arr[12] = v >>> 24 & 0xff;
arr[13] = v >>> 16 & 0xff;
arr[14] = v >>> 8 & 0xff;
arr[15] = v & 0xff;
return arr;
}
function stringToBytes(str) {
str = unescape(encodeURIComponent(str)); // UTF8 escape
var bytes = [];
for (var i = 0; i < str.length; ++i) {
bytes.push(str.charCodeAt(i));
}
return bytes;
}
var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
var URL$1 = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
function v35 (name, version, hashfunc) {
function generateUUID(value, namespace, buf, offset) {
if (typeof value === 'string') {
value = stringToBytes(value);
}
if (typeof namespace === 'string') {
namespace = parse(namespace);
}
if (namespace.length !== 16) {
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
} // Compute hash of namespace and value, Per 4.3
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
// hashfunc([...namespace, ... value])`
var bytes = new Uint8Array(16 + value.length);
bytes.set(namespace);
bytes.set(value, namespace.length);
bytes = hashfunc(bytes);
bytes[6] = bytes[6] & 0x0f | version;
bytes[8] = bytes[8] & 0x3f | 0x80;
if (buf) {
offset = offset || 0;
for (var i = 0; i < 16; ++i) {
buf[offset + i] = bytes[i];
}
return buf;
}
return stringify(bytes);
} // Function#name is not settable on some platforms (#270)
try {
generateUUID.name = name; // eslint-disable-next-line no-empty
} catch (err) {} // For CommonJS default export support
generateUUID.DNS = DNS;
generateUUID.URL = URL$1;
return generateUUID;
}
/*
* Browser-compatible JavaScript MD5
*
* Modification of JavaScript MD5
* https://github.com/blueimp/JavaScript-MD5
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* https://opensource.org/licenses/MIT
*
* Based on
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
function md5(bytes) {
if (typeof bytes === 'string') {
var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
bytes = new Uint8Array(msg.length);
for (var i = 0; i < msg.length; ++i) {
bytes[i] = msg.charCodeAt(i);
}
}
return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
}
/*
* Convert an array of little-endian words to an array of bytes
*/
function md5ToHexEncodedArray(input) {
var output = [];
var length32 = input.length * 32;
var hexTab = '0123456789abcdef';
for (var i = 0; i < length32; i += 8) {
var x = input[i >> 5] >>> i % 32 & 0xff;
var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
output.push(hex);
}
return output;
}
/**
* Calculate output length with padding and bit length
*/
function getOutputLength(inputLength8) {
return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function wordsToMd5(x, len) {
/* append padding */
x[len >> 5] |= 0x80 << len % 32;
x[getOutputLength(len) - 1] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for (var i = 0; i < x.length; i += 16) {
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5ff(a, b, c, d, x[i], 7, -680876936);
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
b = md5gg(b, c, d, a, x[i], 20, -373897302);
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
d = md5hh(d, a, b, c, x[i], 11, -358537222);
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
a = md5ii(a, b, c, d, x[i], 6, -198630844);
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
a = safeAdd(a, olda);
b = safeAdd(b, oldb);
c = safeAdd(c, oldc);
d = safeAdd(d, oldd);
}
return [a, b, c, d];
}
/*
* Convert an array bytes to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*/
function bytesToWords(input) {
if (input.length === 0) {
return [];
}
var length8 = input.length * 8;
var output = new Uint32Array(getOutputLength(length8));
for (var i = 0; i < length8; i += 8) {
output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
}
return output;
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safeAdd(x, y) {
var lsw = (x & 0xffff) + (y & 0xffff);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return msw << 16 | lsw & 0xffff;
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bitRotateLeft(num, cnt) {
return num << cnt | num >>> 32 - cnt;
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5cmn(q, a, b, x, s, t) {
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
}
function md5ff(a, b, c, d, x, s, t) {
return md5cmn(b & c | ~b & d, a, b, x, s, t);
}
function md5gg(a, b, c, d, x, s, t) {
return md5cmn(b & d | c & ~d, a, b, x, s, t);
}
function md5hh(a, b, c, d, x, s, t) {
return md5cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5ii(a, b, c, d, x, s, t) {
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
}
var v3 = v35('v3', 0x30, md5);
var v3$1 = v3;
function v4(options, buf, offset) {
options = options || {};
var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
rnds[6] = rnds[6] & 0x0f | 0x40;
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
if (buf) {
offset = offset || 0;
for (var i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];
}
return buf;
}
return stringify(rnds);
}
// Adapted from Chris Veness' SHA1 code at
// http://www.movable-type.co.uk/scripts/sha1.html
function f(s, x, y, z) {
switch (s) {
case 0:
return x & y ^ ~x & z;
case 1:
return x ^ y ^ z;
case 2:
return x & y ^ x & z ^ y & z;
case 3:
return x ^ y ^ z;
}
}
function ROTL(x, n) {
return x << n | x >>> 32 - n;
}
function sha1(bytes) {
var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
if (typeof bytes === 'string') {
var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
bytes = [];
for (var i = 0; i < msg.length; ++i) {
bytes.push(msg.charCodeAt(i));
}
} else if (!Array.isArray(bytes)) {
// Convert Array-like to Array
bytes = Array.prototype.slice.call(bytes);
}
bytes.push(0x80);
var l = bytes.length / 4 + 2;
var N = Math.ceil(l / 16);
var M = new Array(N);
for (var _i = 0; _i < N; ++_i) {
var arr = new Uint32Array(16);
for (var j = 0; j < 16; ++j) {
arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
}
M[_i] = arr;
}
M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
M[N - 1][14] = Math.floor(M[N - 1][14]);
M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
for (var _i2 = 0; _i2 < N; ++_i2) {
var W = new Uint32Array(80);
for (var t = 0; t < 16; ++t) {
W[t] = M[_i2][t];
}
for (var _t = 16; _t < 80; ++_t) {
W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
}
var a = H[0];
var b = H[1];
var c = H[2];
var d = H[3];
var e = H[4];
for (var _t2 = 0; _t2 < 80; ++_t2) {
var s = Math.floor(_t2 / 20);
var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
e = d;
d = c;
c = ROTL(b, 30) >>> 0;
b = a;
a = T;
}
H[0] = H[0] + a >>> 0;
H[1] = H[1] + b >>> 0;
H[2] = H[2] + c >>> 0;
H[3] = H[3] + d >>> 0;
H[4] = H[4] + e >>> 0;
}
return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
}
var v5 = v35('v5', 0x50, sha1);
var v5$1 = v5;
var nil = '00000000-0000-0000-0000-000000000000';
function version(uuid) {
if (!validate(uuid)) {
throw TypeError('Invalid UUID');
}
return parseInt(uuid.substr(14, 1), 16);
}
var esmBrowser = /*#__PURE__*/Object.freeze({
__proto__: null,
v1: v1,
v3: v3$1,
v4: v4,
v5: v5$1,
NIL: nil,
version: version,
validate: validate,
stringify: stringify,
parse: parse
});
var require$$0 = /*@__PURE__*/getAugmentedNamespace(esmBrowser);
var equalDeep$1 = {};
Object.defineProperty(equalDeep$1, "__esModule", { value: true });
const isObjectLike = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
const equalDeep = (valueA, valueB) => {
if (valueA === valueB)
return true;
if (Number.isNaN(valueA) && Number.isNaN(valueB))
return true;
if ((typeof valueA !== typeof valueB) &&
!(isObjectLike(valueA) && isObjectLike(valueB)))
return false;
if (Array.isArray(valueA) &&
Array.isArray(valueB) &&
valueA.length === valueB.length)
return valueA.every((item, index) => equalDeep(item, valueB[index]));
if (isObjectLike(valueA)) {
const valueA_ = Object.assign({}, valueA);
const valueB_ = Object.assign({}, valueB);
return Object.keys(valueA_).every(key => equalDeep(valueA_[key], valueB_[key]));
}
return false;
};
equalDeep$1.default = equalDeep;
var __importDefault$e = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(isValid$1, "__esModule", { value: true });
const uuid_1 = require$$0;
const is_1$8 = __importDefault$e(is$3.exports);
const isEnvironment_1$1 = __importDefault$e(isEnvironment$1);
const equalDeep_1 = __importDefault$e(equalDeep$1);
const optionsDefault$c = {};
function isValid(type, value, options_ = {}) {
var _a;
const options = Object.assign(Object.assign({}, optionsDefault$c), options_);
let valueA;
let valueB;
let operator;
let operators;
let pattern;
let value_;
switch (type) {
case 'date':
return isValid('timestamp', new Date(value).getTime());
case 'unix':
return (Number.isInteger(value) &&
String(value).length === 10 &&
new Date(value * 1000).getTime() > 0);
case 'timestamp':
return (Number.isInteger(value) &&
String(value).length >= 10 &&
(new Date(value).getTime() > 0 ||
new Date(value * 1000).getTime() > 0));
case 'uuid':
return (0, uuid_1.validate)(value);
case 'binary-string':
value_ = ['0', '1'];
return (0, is_1$8.default)('string', value) && [...value].every(item => value_.indexOf(item) > -1);
case 'hexadecimal-string':
value_ = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
return (0, is_1$8.default)('string', value) && [...value].every(item => value_.indexOf(item) > -1);
case 'url':
pattern = /^(https?:\/\/)?([\w.-]+)(\.[\w.-]+)+(\/[\w\-.~:\/?#[\]@!$&'()*+,;=%]*)?$/;
return pattern.test(value);
case 'url-path':
pattern = /^\/([^\/][A-Za-z0-9\-._~!$&'()*+,;=:@\/?#%]*)?$/;
return pattern.test(value);
case 'domain-name':
pattern = /^[a-z0-9\-]+$/;
const valueCleanedUp = value.replace(/--/g, '-');
const length = value === null || value === void 0 ? void 0 : value.length;
return pattern.test(value) && !value.startsWith('-') && !value.endsWith('-') && valueCleanedUp.length === value.length && length > 1 && length < 254;
case 'compare':
({ valueA, valueB, operator } = options);
operators = {
'less-than': valueA < valueB,
'less-than-equal': valueA <= valueB,
'equal': (0, equalDeep_1.default)(valueA, valueB),
'not-equal': !(0, equalDeep_1.default)(valueA, valueB),
'greater-than-equal': valueA >= valueB,
'greater-than': valueA > valueB,
'array-all': (0, is_1$8.default)('array', valueA) && (0, is_1$8.default)('array', valueB) && valueA.every((_, index) => (0, equalDeep_1.default)(valueA[index], valueB[index])),
'array-some': (0, is_1$8.default)('array', valueA) && (0, is_1$8.default)('array', valueB) && valueA.some((_, index) => (0, equalDeep_1.default)(valueA[index], valueB[index])),
'starts-with': (0, is_1$8.default)('string', valueA) && valueA.indexOf(valueB) === 0,
'contains': (0, is_1$8.default)('string', valueA) && valueA.indexOf(valueB) > -1,
};
return operators[operator];
case 'semver':
pattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
return pattern.test(value);
case 'semver-compare':
({ valueA, valueB, operator } = options);
if (!(isValid('semver', valueA) && isValid('semver', valueB)))
return false;
valueA = (valueA.match(/\d+(\.|\-|\+){0,1}/g) || []).map((item) => item.replace(/[,\-\+\.]/g, ''));
valueB = (valueB.match(/\d+(\.|\-|\+){0,1}/g) || []).map((item) => item.replace(/[,\-\+\.]/g, ''));
operators = {
'less-than': false,
'less-than-equal': false,
'equal': valueA.every((item, index) => item === valueB[index]),
'greater-than-equal': false,
'greater-than': false,
};
// Less then
valueA.forEach((item, index) => {
if (!operators['less-than'])
operators['less-than'] = item < valueB[index];
});
// Greater then
valueA.forEach((item, index) => {
if (!operators['greater-than'])
operators['greater-than'] = item > valueB[index];
});
// Other or operator values
operators['less-than-equal'] = operators['less-than'] || operators['equal'];
operators['greater-than-equal'] = operators['greater-than'] || operators['equal'];
return operators[operator];
case 'mobile':
pattern = /^(\+\d{1,2}\s?)?1?-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/;
return pattern.test(value) && !Number.isInteger(value);
case 'email':
pattern = /\S+@\S+\.\S+/;
return pattern.test(value);
case 'password':
const values = [];
if (!(0, is_1$8.default)('string', value))
return false;
const min_ = options.min !== undefined ? options.min : 7;
const max_ = options.max !== undefined ? options.max : 440;
// min 7, max 440 characters
if (value.length >= min_ && value.length <= max_)
values.push('length');
// lowercase characters
if (value.match(/[a-z]+/))
values.push('lowercase');
// uppercase characters
if (value.match(/[A-Z]+/))
values.push('uppercase');
// numbers
if (value.match(/[0-9]+/))
values.push('number');
return options.variant === 'value' ? values : values.length >= 4;
case 'hash':
pattern = /^(0x)?[a-f0-9]{64}$/gi;
return (0, is_1$8.default)('string', value) && pattern.test(value);
case 'color':
return isValid('color-rgb', value, options) || isValid('color-hex', value, options) || isValid('color-hsl', value, options);
case 'color-rgb':
// Matches rgb() and rgba(), with values divided with ',' and spaces (optionaly)
pattern = /rgb(a)?\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))(\.\d+)?,\s*(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))(\.\d+)?,\s*(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]))(\.\d+)?(,\s*(?:0(?:\.[0-9]{1,2})?|1(?:\.00?)?))?\)/;
return pattern.test(value);
case 'color-hex':
// Matches #nnn, #nnnnnn and #nnnnnnnn (where last nn's are for alpha (optionaly))
pattern = /^#((?:[0-9a-fA-F]){3}|(?:[0-9a-fA-F]){6}|(?:[0-9a-fA-F]){8})$/;
return pattern.test(value);
case 'color-hsl':
// Matches hsl() and hsla(), with values divided with ',' and spaces (optionaly)
pattern = /hsl(a)?\((0|[1-9][0-9]?|[12][0-9][0-9]|3[0-5][0-9])(\.\d+)?,\s*([0-9]|[1-9][0-9]|100)(\.\d+)?%,\s*([0-9]|[1-9][0-9]|100)(\.\d+)?%(,\s*(?:0(?:\.[0-9]{1,2})?|1(?:\.00?)?))?\)/;
return pattern.test(value);
case 'json':
try {
value_ = JSON.parse(value);
}
catch (error) {
return false;
}
return (0, is_1$8.default)('object', value_, options) || (0, is_1$8.default)('array', value_, options);
case 'min':
return value >= options.min;
case 'max':
return value <= options.max;
case 'min-max':
return isValid('min', value, options) && isValid('max', value, options);
case 'same-origin':
try {
value_ = new URL(value);
}
catch (error) { }
return (0, isEnvironment_1$1.default)('browser') && (isValid('url-path', value, options) || (window.location.hostname === ((_a = value_) === null || _a === void 0 ? void 0 : _a.hostname)));
case 'js-chunk':
return (0, is_1$8.default)('object', value, options) && !!value.__esModule && (value.default instanceof Function || value.default instanceof Object);
case 'http-method':
const methods = ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS', 'PATCH'];
return (0, is_1$8.default)('string', value, options) && methods.indexOf(value.toUpperCase()) > -1;
case 'base64':
value_ = typeof value === 'string' ? value.trim() : value;
return (0, is_1$8.default)('string', value_, options) && value_.length >= 1 && /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}(==)?|[A-Za-z0-9+\\/]{3}=?)?$/gi.test(value_);
case 'datauri':
value_ = typeof value === 'string' ? value.trim() : value;
return ((0, is_1$8.default)('string', value_, options) &&
/^data:\w+\/[-+.\w]+;base64,(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}(==)?|[A-Za-z0-9+\\/]{3}=?)?$/gi.test(value_) ||
/^data:(\w+\/[-+.\w]+)?(;charset=[\w-]+)?,(.*)?/gi.test(value_));
case 'pascal-case':
pattern = /^[A-Z][a-z]+(?:[A-Z][a-z]+)*$/;
return pattern.test(value);
case 'camel-case':
pattern = /^[a-z]+(?:[A-Z][a-z]+)*$/;
return pattern.test(value);
default:
return false;
}
}
isValid$1.default = isValid;
var rgbToRgba$1 = {};
var clamp$1 = {};
var __importDefault$d = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(clamp$1, "__esModule", { value: true });
const is_1$7 = __importDefault$d(is$3.exports);
const clamp = (value, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) => {
if ((0, is_1$7.default)('number', value)) {
if (value < min)
return min;
if (value > max)
return max;
return value;
}
return value;
};
var _default$d = clamp$1.default = clamp;
var __importDefault$c = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(rgbToRgba$1, "__esModule", { value: true });
const is_1$6 = __importDefault$c(is$3.exports);
const isValid_1$5 = __importDefault$c(isValid$1);
const castParam_1$4 = __importDefault$c(castParam$3);
const clamp_1$6 = __importDefault$c(clamp$1);
const rgbToRgba = (value, opacity = undefined, array = false) => {
if ((0, isValid_1$5.default)('color-rgb', value)) {
let values = value.replace(/rgb|a|\(|\s|\)/g, '').split(',').map((value_, index) => {
if (index < 3)
return Math.round((0, castParam_1$4.default)(value_));
return (0, castParam_1$4.default)(value_);
});
const a = opacity !== undefined ? +(opacity > 1 ? (opacity / 100).toFixed(2) : (0, clamp_1$6.default)(opacity, 0, 1)) : values[3];
values = [...values.slice(0, 3).map(item => Math.round((0, castParam_1$4.default)(item))), (0, is_1$6.default)('number', a) && +a];
const [r, g, b] = values;
return array ? values.filter(value_ => (0, is_1$6.default)('number', value_)) : `rgb${(0, is_1$6.default)('number', a) ? 'a' : ''}(${r}, ${g}, ${b}${(0, is_1$6.default)('number', a) ? `, ${a}` : ''})`;
}
};
var _default$c = rgbToRgba$1.default = rgbToRgba;
var hexToRgb$1 = {};
var __importDefault$b = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(hexToRgb$1, "__esModule", { value: true });
const is_1$5 = __importDefault$b(is$3.exports);
const isValid_1$4 = __importDefault$b(isValid$1);
const clamp_1$5 = __importDefault$b(clamp$1);
const castParam_1$3 = __importDefault$b(castParam$3);
const hexToRgb = (value, opacity = undefined, array = false) => {
if ((0, isValid_1$4.default)('color-hex', value)) {
const hex = value.slice(1);
let r = parseInt(hex.length === 3 ? `${hex[0]}${hex[0]}` : hex.slice(0, 2), 16);
let g = parseInt(hex.length === 3 ? `${hex[1]}${hex[1]}` : hex.slice(2, 4), 16);
let b = parseInt(hex.length === 3 ? `${hex[2]}${hex[2]}` : hex.slice(4, 6), 16);
let a = opacity !== undefined ? opacity > 1 ? (opacity / 100).toFixed(2) : (0, clamp_1$5.default)(opacity, 0, 1) : (hex.length === 8) && (parseInt(hex.slice(6), 16) / 255).toFixed(2);
const values = [...[r, g, b].map(item => Math.round((0, castParam_1$3.default)(item))), (0, is_1$5.default)('number', a) && +a];
[r, g, b, a] = values;
return array ? values.filter(value_ => (0, is_1$5.default)('number', value_)) : `rgb${(0, is_1$5.default)('number', a) ? 'a' : ''}(${r}, ${g}, ${b}${(0, is_1$5.default)('number', a) ? `, ${a}` : ''})`;
}
};
var _default$b = hexToRgb$1.default = hexToRgb;
var hslToRgb$1 = {};
var __importDefault$a = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(hslToRgb$1, "__esModule", { value: true });
const is_1$4 = __importDefault$a(is$3.exports);
const isValid_1$3 = __importDefault$a(isValid$1);
const castParam_1$2 = __importDefault$a(castParam$3);
const clamp_1$4 = __importDefault$a(clamp$1);
const hslToRgb = (value, opacity = undefined, array = false) => {
if ((0, isValid_1$3.default)('color-hsl', value)) {
let values = value.replace(/hsl|a|\(|%|\s|\)/g, '').split(',');
let [h, s, l, a] = [...values.slice(0, 3).map((item) => +(0, castParam_1$2.default)(item).toFixed(0)), values[3]];
h = parseInt(h, 10);
s = parseInt(s, 10) / 100;
l = parseInt(l, 10) / 100;
a = opacity !== undefined ? (opacity > 1 ? (opacity / 100).toFixed(2) : (0, clamp_1$4.default)(opacity, 0, 1)) : parseFloat(a);
const k = (n) => (n + h / 30) % 12;
const u = s * Math.min(l, 1 - l);
const f = (n) => l - u * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
let r = 255 * f(0);
let g = 255 * f(8);
let b = 255 * f(4);
values = [...[r, g, b].map(item => Math.round((0, castParam_1$2.default)(item))), (0, is_1$4.default)('number', a) && +a];
[r, g, b, a] = values;
return array ? values.filter((value_) => (0, is_1$4.default)('number', value_)) : `rgb${(0, is_1$4.default)('number', a) ? 'a' : ''}(${r}, ${g}, ${b}${(0, is_1$4.default)('number', a) ? `, ${a}` : ''})`;
}
};
var _default$a = hslToRgb$1.default = hslToRgb;
var __importDefault$9 = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(colorToRgb$1, "__esModule", { value: true });
const isValid_1$2 = __importDefault$9(isValid$1);
const rgbToRgba_1 = __importDefault$9(rgbToRgba$1);
const hexToRgb_1 = __importDefault$9(hexToRgb$1);
const hslToRgb_1 = __importDefault$9(hslToRgb$1);
const colorToRgb = (value, opacity = undefined, array = false) => {
if ((0, isValid_1$2.default)('color-rgb', value))
return (0, rgbToRgba_1.default)(value, opacity, array);
if ((0, isValid_1$2.default)('color-hex', value))
return (0, hexToRgb_1.default)(value, opacity, array);
if ((0, isValid_1$2.default)('color-hsl', value))
return (0, hslToRgb_1.default)(value, opacity, array);
};
var _default$9 = colorToRgb$1.default = colorToRgb;
var __importDefault$8 = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(alpha$1, "__esModule", { value: true });
const colorToRgb_1$3 = __importDefault$8(colorToRgb$1);
const alpha = (value, opacity) => (0, colorToRgb_1$3.default)(value, opacity);
var _default$8 = alpha$1.default = alpha;
var darken$1 = {};
var __importDefault$7 = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(darken$1, "__esModule", { value: true });
const is_1$3 = __importDefault$7(is$3.exports);
const clamp_1$3 = __importDefault$7(clamp$1);
const colorToRgb_1$2 = __importDefault$7(colorToRgb$1);
const darken = (value, coefficient) => {
const values = (0, colorToRgb_1$2.default)(value, undefined, true);
if ((0, is_1$3.default)('array', values) && values.length >= 3) {
values.slice(0, 3).forEach((_, index) => values[index] *= 1 - (0, clamp_1$3.default)(coefficient, 0, 1));
const [r, g, b, a] = [...values.slice(0, 3).map(item => Math.round(Number(item))), values[3]];
return `rgb${a ? 'a' : ''}(${r}, ${g}, ${b}${a ? `, ${a}` : ''})`;
}
};
var _default$7 = darken$1.default = darken;
var emphasize$1 = {};
var getLuminance$1 = {};
var __importDefault$6 = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(getLuminance$1, "__esModule", { value: true });
const is_1$2 = __importDefault$6(is$3.exports);
const colorToRgb_1$1 = __importDefault$6(colorToRgb$1);
const getLuminance = (value) => {
let values = (0, colorToRgb_1$1.default)(value, undefined, true);
if ((0, is_1$2.default)('array', values) && values.length >= 3) {
values = values.slice(0, 3).map(item => {
// Normalize
item /= 255;
return item <= 0.03928 ? item / 12.92 : ((item + 0.055) / 1.055) ** 2.4;
});
const [r, g, b] = values;
return Number((r * 0.2126 + g * 0.7152 + b * 0.0722).toFixed(2));
}
};
var _default$6 = getLuminance$1.default = getLuminance;
var lighten$1 = {};
var __importDefault$5 = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(lighten$1, "__esModule", { value: true });
const is_1$1 = __importDefault$5(is$3.exports);
const clamp_1$2 = __importDefault$5(clamp$1);
const colorToRgb_1 = __importDefault$5(colorToRgb$1);
const lighten = (value, coefficient) => {
const values = (0, colorToRgb_1.default)(value, undefined, true);
if ((0, is_1$1.default)('array', values) && values.length >= 3) {
values.slice(0, 3).forEach((item, index) => values[index] += (255 - item) * (0, clamp_1$2.default)(coefficient, 0, 1));
const [r, g, b, a] = [...values.slice(0, 3).map(item => Math.round(Number(item))), values[3]];
return `rgb${a ? 'a' : ''}(${r}, ${g}, ${b}${a ? `, ${a}` : ''})`;
}
};
var _default$5 = lighten$1.default = lighten;
var __importDefault$4 = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(emphasize$1, "__esModule", { value: true });
const getLuminance_1$1 = __importDefault$4(getLuminance$1);
const lighten_1 = __importDefault$4(lighten$1);
const darken_1 = __importDefault$4(darken$1);
const emphasize = (value, coefficient = 0.14) => {
const luminance = (0, getLuminance_1$1.default)(value);
if (luminance !== undefined) {
return (0, getLuminance_1$1.default)(value) > 0.5 ? (0, darken_1.default)(value, coefficient) : (0, lighten_1.default)(value, coefficient);
}
};
var _default$4 = emphasize$1.default = emphasize;
var getContrastRatio$1 = {};
var __importDefault$3 = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(getContrastRatio$1, "__esModule", { value: true });
const getLuminance_1 = __importDefault$3(getLuminance$1);
const getContrastRatio = (valueA, valueB) => {
const lumA = (0, getLuminance_1.default)(valueA);
const lumB = (0, getLuminance_1.default)(valueB);
if (lumA !== undefined && lumB !== undefined) {
return +((Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05)).toFixed(2);
}
};
var _default$3 = getContrastRatio$1.default = getContrastRatio;
var imageToPalette$1 = {};
var quantize$1 = {};
Object.defineProperty(quantize$1, "__esModule", { value: true });
const colorRange = (value) => {
const min = new Array(3).fill(Number.MAX_VALUE);
const max = new Array(3).fill(Number.MIN_VALUE);
value.forEach(item => {
item.forEach((value_, index) => {
min[index] = Math.min(min[index], value_);
max[index] = Math.max(max[index], value_);
});
});
const ranges = min.map((item, index) => max[index] - item);
const maxRange = Math.max(...ranges);
if (maxRange === ranges[0])
return 0;
else if (maxRange === ranges[1])
return 1;
return 2;
};
const quantizeMethod = (value, depth = 0) => {
const MAX_DEPTH = 7;
if (!value.length)
return [];
if (MAX_DEPTH === depth) {
const color = value.reduce((result, item) => {
item.forEach((value_, index) => result[index] += value_);
return result;
}, [0, 0, 0]);
return [color.map(item => Math.round(item / value.length))];
}
const sortIndex = colorRange(value);
value.sort((a, b) => a[sortIndex] - b[sortIndex]);
const mid = value.length / 2;
// Reverse so primary is a first value
return [
...quantizeMethod(value.slice(0, mid), depth + 1),
...quantizeMethod(value.slice(mid + 1), depth + 1),
].reverse();
};
const quantize = (value, amount = 4) => {
const depth = 7 - Math.ceil(Math.log2(amount));
return quantizeMethod(value, depth).slice(0, amount);
};
quantize$1.default = quantize;
var __importDefault$2 = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(imageToPalette$1, "__esModule", { value: true });
const isEnvironment_1 = __importDefault$2(isEnvironment$1);
const quantize_1 = __importDefault$2(quantize$1);
const imageToPalette = (value, options = { amount: 4, size: 400, allowCrossOrigin: false }) => new Promise(resolve => {
if ((0, isEnvironment_1.default)('browser')) {
const img = new Image();
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
if (options.allowCrossOrigin)
img.crossOrigin = 'Anonymous';
img.onload = () => {
const size = options.size || 140;
let width = img.naturalWidth || img.offsetWidth || img.width;
let height = img.naturalHeight || img.offsetHeight || img.height;
// resize
if (width > size) {
height /= width / size;
width = size;
}
if (height > size) {
width /= height / size;
height = size;
}
canvas.width = width;
canvas.height = height;
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
// image data
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imageData.data;
const length = data.length;
const values = [];
// array of rgb values
for (let i = 0; i < length; i += 4)
values.push([data[i], data[i + 1], data[i + 2]]);
// quantize image values to a palette
const result = (0, quantize_1.default)(values, options.amount || 4);
return resolve(result.map(item => `rgb(${item[0]}, ${item[1]}, ${item[2]})`));
};
img.onerror = () => resolve([]);
// src
img.src = value;
}
else
resolve(undefined);
});
var _default$2 = imageToPalette$1.default = imageToPalette;
var rgbToHex$1 = {};
var __importDefault$1 = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(rgbToHex$1, "__esModule", { value: true });
const isValid_1$1 = __importDefault$1(isValid$1);
const clamp_1$1 = __importDefault$1(clamp$1);
const castParam_1$1 = __importDefault$1(castParam$3);
const intToHex = (value) => {
const hex = (0, castParam_1$1.default)(value).toString(16);
return hex.length === 1 ? `0${hex}` : hex;
};
const rgbToHex = (value, opacity_ = undefined, array = false) => {
if ((0, isValid_1$1.default)('color-rgb', value)) {
let values = value.replace(/rgb|a|\(|\s|\)/g, '').split(',').filter(Boolean);
// If alpha value exists, multiply it by 255 rgb max range value
if (values[3])
values[3] = Math.round(parseFloat(values[3]) * 255);
const opacity = opacity_ !== undefined && (opacity_ > 1 ? +(opacity_ / 100).toFixed(2) : (0, clamp_1$1.default)(opacity_, 0, 1));
if (opacity)
values.push(Math.round(parseFloat(opacity) * 255));
values = values.map(item => intToHex(item));
const [r, g, b, a] = values;
return array ? values.filter(Boolean) : `#${r}${g}${b}${a ? a : ''}`;
}
};
var _default$1 = rgbToHex$1.default = rgbToHex;
var rgbToHsl$1 = {};
var __importDefault = (undefined && undefined.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(rgbToHsl$1, "__esModule", { value: true });
const is_1 = __importDefault(is$3.exports);
const isValid_1 = __importDefault(isValid$1);
const clamp_1 = __importDefault(clamp$1);
const castParam_1 = __importDefault(castParam$3);
const rgbToHsl = (value, opacity = undefined, array = false) => {
if ((0, isValid_1.default)('color-rgb', value)) {
let values = value.replace(/rgb|a|\(|\s|\)/g, '').split(',').filter(Boolean);
let [r, g, b, a] = values;
r /= 255;
g /= 255;
b /= 255;
// find greatest and smallest channel values
const cmin = Math.min(r, g, b);
const cmax = Math.max(r, g, b);
const delta = cmax - cmin;
let h = 0;
let s = 0;
let l = 0;
if (delta === 0)
h = 0;
else if (cmax === r)
h = ((g - b) / delta) % 6;
else if (cmax === g)
h = (b - r) / delta + 2;
else
h = (r - g) / delta + 4;
h = Math.round(h * 60);
if (h < 0)
h += 360;
l = (cmax + cmin) / 2;
s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
s = +(s * 100).toFixed(0);
l = +(l * 100).toFixed(0);
a = opacity !== undefined ? +(opacity > 1 ? (opacity / 100).toFixed(2) : (0, clamp_1.default)(opacity, 0, 1)) : a;
values = [...[h, s, l].map(value_ => Math.round((0, castParam_1.default)(value_))), (0, is_1.default)('number', a) && +a];
return array ? values.filter(value_ => (0, is_1.default)('number', value_)) : `hsl${(0, is_1.default)('number', a) ? 'a' : ''}(${h}, ${s}%, ${l}%${(0, is_1.default)('number', a) ? `, ${a}` : ''})`;
}
};
var _default = rgbToHsl$1.default = rgbToHsl;
const colors = {
red: {
'50': '#FFEBEE',
'100': '#FFCDD2',
'200': '#EF9A9A',
'300': '#E57373',
'400': '#EF5350',
'500': '#F44336',
'600': '#E53935',
'700': '#D32F2F',
'800': '#C62828',
'900': '#B71C1C',
'A100': '#FF8A80',
'A200': '#FF5252',
'A400': '#FF1744',
'A700': '#D50000'
},
pink: {
'50': '#FCE4EC',
'100': '#F8BBD0',
'200': '#F48FB1',
'300': '#F06292',
'400': '#EC407A',
'500': '#E91E63',
'600': '#D81B60',
'700': '#C2185B',
'800': '#AD1457',
'900': '#880E4F',
'A100': '#FF80AB',
'A200': '#FF4081',
'A400': '#F50057',
'A700': '#C51162'
},
purple: {
'50': '#F3E5F5',
'100': '#E1BEE7',
'200': '#CE93D8',
'300': '#BA68C8',
'400': '#AB47BC',
'500': '#9C27B0',
'600': '#8E24AA',
'700': '#7B1FA2',
'800': '#6A1B9A',
'900': '#4A148C',
'A100': '#EA80FC',
'A200': '#E040FB',
'A400': '#D500F9',
'A700': '#AA00FF'
},
deeppurple: {
'50': '#EDE7F6',
'100': '#D1C4E9',
'200': '#B39DDB',
'300': '#9575CD',
'400': '#7E57C2',
'500': '#673AB7',
'600': '#5E35B1',
'700': '#512DA8',
'800': '#4527A0',
'900': '#311B92',
'A100': '#B388FF',
'A200': '#7C4DFF',
'A400': '#651FFF',
'A700': '#6200EA'
},
indigo: {
'50': '#E8EAF6',
'100': '#C5CAE9',
'200': '#9FA8DA',
'300': '#7986CB',
'400': '#5C6BC0',
'500': '#3F51B5',
'600': '#3949AB',
'700': '#303F9F',
'800': '#283593',
'900': '#1A237E',
'A100': '#8C9EFF',
'A200': '#536DFE',
'A400': '#3D5AFE',
'A700': '#304FFE'
},
blue: {
'50': '#E3F2FD',
'100': '#BBDEFB',
'200': '#90CAF9',
'300': '#64B5F6',
'400': '#42A5F5',
'500': '#2196F3',
'600': '#1E88E5',
'700': '#1976D2',
'800': '#1565C0',
'900': '#0D47A1',
'A100': '#82B1FF',
'A200': '#448AFF',
'A400': '#2979FF',
'A700': '#2962FF'
},
lightblue: {
'50': '#E1F5FE',
'100': '#B3E5FC',
'200': '#81D4FA',
'300': '#4FC3F7',
'400': '#29B6F6',
'500': '#03A9F4',
'600': '#039BE5',
'700': '#0288D1',
'800': '#0277BD',
'900': '#01579B',
'A100': '#80D8FF',
'A200': '#40C4FF',
'A400': '#00B0FF',
'A700': '#0091EA'
},
cyan: {
'50': '#E0F7FA',
'100': '#B2EBF2',
'200': '#80DEEA',
'300': '#4DD0E1',
'400': '#26C6DA',
'500': '#00BCD4',
'600': '#00ACC1',
'700': '#0097A7',
'800': '#00838F',
'900': '#006064',
'A100': '#84FFFF',
'A200': '#18FFFF',
'A400': '#00E5FF',
'A700': '#00B8D4'
},
teal: {
'50': '#E0F2F1',
'100': '#B2DFDB',
'200': '#80CBC4',
'300': '#4DB6AC',
'400': '#26A69A',
'500': '#009688',
'600': '#00897B',
'700': '#00796B',
'800': '#00695C',
'900': '#004D40',
'A100': '#A7FFEB',
'A200': '#64FFDA',
'A400': '#1DE9B6',
'A700': '#00BFA5'
},
green: {
'50': '#E8F5E9',
'100': '#C8E6C9',
'200': '#A5D6A7',
'300': '#81C784',
'400': '#66BB6A',
'500': '#4CAF50',
'600': '#43A047',
'700': '#388E3C',
'800': '#2E7D32',
'900': '#1B5E20',
'A100': '#B9F6CA',
'A200': '#69F0AE',
'A400': '#00E676',
'A700': '#00C853'
},
lightgreen: {
'50': '#F1F8E9',
'100': '#DCEDC8',
'200': '#C5E1A5',
'300': '#AED581',
'400': '#9CCC65',
'500': '#8BC34A',
'600': '#7CB342',
'700': '#689F38',
'800': '#558B2F',
'900': '#33691E',
'A100': '#CCFF90',
'A200': '#B2FF59',
'A400': '#76FF03',
'A700': '#64DD17'
},
lime: {
'50': '#F9FBE7',
'100': '#F0F4C3',
'200': '#E6EE9C',
'300': '#DCE775',
'400': '#D4E157',
'500': '#CDDC39',
'600': '#C0CA33',
'700': '#AFB42B',
'800': '#9E9D24',
'900': '#827717',
'A100': '#F4FF81',
'A200': '#EEFF41',
'A400': '#C6FF00',
'A700': '#AEEA00'
},
yellow: {
'50': '#FFFDE7',
'100': '#FFF9C4',
'200': '#FFF59D',
'300': '#FFF176',
'400': '#FFEE58',
'500': '#FFEB3B',
'600': '#FDD835',
'700': '#FBC02D',
'800': '#F9A825',
'900': '#F57F17',
'A100': '#FFFF8D',
'A200': '#FFFF00',
'A400': '#FFEA00',
'A700': '#FFD600'
},
amber: {
'50': '#FFF8E1',
'100': '#FFECB3',
'200': '#FFE082',
'300': '#FFD54F',
'400': '#FFCA28',
'500': '#FFC107',
'600': '#FFB300',
'700': '#FFA000',
'800': '#FF8F00',
'900': '#FF6F00',
'A100': '#FFE57F',
'A200': '#FFD740',
'A400': '#FFC400',
'A700': '#FFAB00'
},
orange: {
'50': '#FFF3E0',
'100': '#FFE0B2',
'200': '#FFCC80',
'300': '#FFB74D',
'400': '#FFA726',
'500': '#FF9800',
'600': '#FB8C00',
'700': '#F57C00',
'800': '#EF6C00',
'900': '#E65100',
'A100': '#FFD180',
'A200': '#FFAB40',
'A400': '#FF9100',
'A700': '#FF6D00'
},
deeporange: {
'50': '#FBE9E7',
'100': '#FFCCBC',
'200': '#FFAB91',
'300': '#FF8A65',
'400': '#FF7043',
'500': '#FF5722',
'600': '#F4511E',
'700': '#E64A19',
'800': '#D84315',
'900': '#BF360C',
'A100': '#FF9E80',
'A200': '#FF6E40',
'A400': '#FF3D00',
'A700': '#DD2C00'
},
brown: {
'50': '#EFEBE9',
'100': '#D7CCC8',
'200': '#BCAAA4',
'300': '#A1887F',
'400': '#8D6E63',
'500': '#795548',
'600': '#6D4C41',
'700': '#5D4037',
'800': '#4E342E',
'900': '#3E2723'
},
gray: {
'50': '#FAFAFA',
'100': '#F5F5F5',
'200': '#EEEEEE',
'300': '#E0E0E0',
'400': '#BDBDBD',
'500': '#9E9E9E',
'600': '#757575',
'700': '#616161',
'800': '#424242',
'900': '#212121'
},
'blue gray': {
'50': '#ECEFF1',
'100': '#CFD8DC',
'200': '#B0BEC5',
'300': '#90A4AE',
'400': '#78909C',
'500': '#607D8B',
'600': '#546E7A',
'700': '#455A64',
'800': '#37474F',
'900': '#263238'
},
'black': '#000000',
'white': '#FFFFFF'
};
var colors$1 = colors;
const FONT_FAMILY$1 = {
primary: ['Montserrat', 'Helvetica', 'Helvetica Neue', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'sans-serif'].join(', '),
secondary: ['Outfit', 'Helvetica', 'Helvetica Neue', '-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'sans-serif'].join(', '),
tertiary: ['Roboto Mono', 'monospace'].join(', ')
};
const optionsDefault$b = {
rule: {
sort: true,
prefix: true,
rtl: false
},
updateFontSize: true,
motion: true
};
const media = {};
for (let i = 100; i <= 4000; i += 100) {
media[i] = "(max-width: ".concat(i, "px)");
media["".concat(i, "-up")] = "(min-width: ".concat(i, "px)");
}
const onesyThemeValueDefault = {
preference: {
background: {
default: 'neutral'
},
text: {
default: 'neutral'
},
shadow: {
default: 'neutral'
},
visual_contrast: {
default: 'regular'
}
},
palette: {
light: true,
accessibility: 'regular',
visual_contrast: {
low: {
opacity: {
primary: .77,
secondary: .44,
tertiary: .27,
quaternary: .14,
divider: .11,
active: .44,
disabled: .34,
drag: .27,
press: .21,
focus: .17,
selected: .14,
hover: .07
},
contrast_threshold: 2.4
},
regular: {
opacity: {
primary: .87,
secondary: .54,
tertiary: .37,
quaternary: .24,
divider: .14,
active: .54,
disabled: .37,
drag: .31,
press: .27,
focus: .21,
selected: .17,
hover: .1
},
contrast_threshold: 3
},
high: {
opacity: {
primary: 1,
secondary: .74,
tertiary: .57,
quaternary: .44,
divider: .24,
active: .74,
disabled: .57,
drag: .37,
press: .31,
focus: .24,
selected: .21,
hover: .14
},
contrast_threshold: 4
}
},
color: {
primary: {
light: colors$1.yellow[300],
main: colors$1.yellow[500],
dark: colors$1.yellow[700]
},
secondary: {
light: colors$1.lightgreen[300],
main: colors$1.lightgreen[500],
dark: colors$1.lightgreen[700]
},
tertiary: {
light: colors$1.amber[300],
main: colors$1.amber[500],
dark: colors$1.amber[700]
},
quaternary: {
light: colors$1.cyan[300],
main: colors$1.cyan[500],
dark: colors$1.cyan[700]
},
info: {
light: colors$1.lightblue[300],
main: colors$1.lightblue[500],
dark: colors$1.lightblue[700]
},
success: {
light: colors$1.green[300],
main: colors$1.green[500],
dark: colors$1.green[700]
},
warning: {
light: colors$1.orange[300],
main: colors$1.orange[500],
dark: colors$1.orange[700]
},
error: {
light: colors$1.deeporange[300],
main: colors$1.deeporange[500],
dark: colors$1.deeporange[700]
},
neutral: {
main: colors$1.black
}
},
text: {},
background: {}
},
shape: {
radius: {
values: {
xxs: 0.25,
xs: 0.5,
sm: 1,
rg: 2,
md: 3,
lg: 4,
xl: 5,
xxl: 7
},
unit: 8
}
},
breakpoints: {
keys: Object.keys(media),
media,
unit: 'px'
},
space: {
values: {
xxs: 0.25,
xs: 0.5,
sm: 1,
rg: 2,
md: 3,
lg: 4,
xl: 5,
xxl: 6,
xxxl: 7
},
unit: 8
},
shadows: {
values: {},
opacities: [.05, .02, .08]
},
typography: {
unit: 'px',
font_size: {
html: 16
},
font_family: {
primary: FONT_FAMILY$1.primary,
secondary: FONT_FAMILY$1.secondary,
tertiary: FONT_FAMILY$1.tertiary
},
values: {
d1: {
fontSize: "".concat(pxToRem(57, 16), "rem"),
fontFamily: FONT_FAMILY$1.primary,
fontWeight: 700,
lineHeight: 64 / 57,
letterSpacing: '0px'
},
d2: {
fontSize: "".concat(pxToRem(45, 16), "rem"),
fontFamily: FONT_FAMILY$1.primary,
fontWeight: 700,
lineHeight: 52 / 45,
letterSpacing: '0px'
},
d3: {
fontSize: "".concat(pxToRem(35, 16), "rem"),
fontFamily: FONT_FAMILY$1.primary,
fontWeight: 700,
lineHeight: 44 / 35,
letterSpacing: '0px'
},
h1: {
fontSize: "".concat(pxToRem(32, 16), "rem"),
fontFamily: FONT_FAMILY$1.primary,
fontWeight: 700,
lineHeight: 40 / 32,
letterSpacing: '0px'
},
h2: {
fontSize: "".concat(pxToRem(27, 16), "rem"),
fontFamily: FONT_FAMILY$1.primary,
fontWeight: 700,
lineHeight: 35 / 27,
letterSpacing: '0px'
},
h3: {
fontSize: "".concat(pxToRem(24, 16), "rem"),
fontFamily: FONT_FAMILY$1.primary,
fontWeight: 700,
lineHeight: 32 / 24,
letterSpacing: '0px'
},
t1: {
fontSize: "".concat(pxToRem(21, 16), "rem"),
fontFamily: FONT_FAMILY$1.primary,
fontWeight: 600,
lineHeight: 28 / 21,
letterSpacing: '0px'
},
t2: {
fontSize: "".concat(pxToRem(16, 16), "rem"),
fontFamily: FONT_FAMILY$1.primary,
fontWeight: 600,
lineHeight: 24 / 16,
letterSpacing: '.15px'
},
t3: {
fontSize: "".concat(pxToRem(14, 16), "rem"),
fontFamily: FONT_FAMILY$1.primary,
fontWeight: 600,
lineHeight: 20 / 14,
letterSpacing: '.1px'
},
l1: {
fontSize: "".concat(pxToRem(16, 16), "rem"),
fontFamily: FONT_FAMILY$1.secondary,
fontWeight: 600,
lineHeight: 24 / 16,
letterSpacing: '.5px'
},
l2: {
fontSize: "".concat(pxToRem(14, 16), "rem"),
fontFamily: FONT_FAMILY$1.secondary,
fontWeight: 600,
lineHeight: 20 / 14,
letterSpacing: '.25px'
},
l3: {
fontSize: "".concat(pxToRem(12, 16), "rem"),
fontFamily: FONT_FAMILY$1.secondary,
fontWeight: 600,
lineHeight: 16 / 12,
letterSpacing: '.4px'
},
b1: {
fontSize: "".concat(pxToRem(16, 16), "rem"),
fontFamily: FONT_FAMILY$1.secondary,
fontWeight: 400,
lineHeight: 24 / 16,
letterSpacing: '.5px'
},
b2: {
fontSize: "".concat(pxToRem(14, 16), "rem"),
fontFamily: FONT_FAMILY$1.secondary,
fontWeight: 400,
lineHeight: 20 / 14,
letterSpacing: '.25px'
},
b3: {
fontSize: "".concat(pxToRem(12, 16), "rem"),
fontFamily: FONT_FAMILY$1.secondary,
fontWeight: 400,
lineHeight: 16 / 12,
letterSpacing: '.4px'
},
m1: {
fontSize: "".concat(pxToRem(16, 16), "rem"),
fontFamily: FONT_FAMILY$1.tertiary,
fontWeight: 400,
lineHeight: 24 / 16,
letterSpacing: '.5px'
},
m2: {
fontSize: "".concat(pxToRem(14, 16), "rem"),
fontFamily: FONT_FAMILY$1.tertiary,
fontWeight: 400,
lineHeight: 20 / 14,
letterSpacing: '.25px'
},
m3: {
fontSize: "".concat(pxToRem(12, 16), "rem"),
fontFamily: FONT_FAMILY$1.tertiary,
fontWeight: 400,
lineHeight: 16 / 12,
letterSpacing: '.4px'
}
}
},
transitions: {
timing_function: {
standard: 'cubic-bezier(.4, 0, .2, 1)',
emphasized: 'cubic-bezier(.4, 0, .6, 1)',
decelerated: 'cubic-bezier(0, 0, .2, 1)',
accelerated: 'cubic-bezier(.4, 0, 1, 1)'
},
duration: {
xxs: 100,
xs: 200,
sm: 250,
rg: 300,
enter: 250,
leave: 200,
complex: 500
}
},
z_index: {
tooltip: 1700,
modal: 1500,
menu_modal: 1400,
menu: 1300,
button_float: 1200,
app_bar: 1100,
main: 1000,
text: 0
}
};
class OnesyTheme {
// Preference
// Mode
// Colors
// Shape
// Breakpoints
// Space
// Shadows
// Typography
// Transitions
// zIndex
// Methods
// Any new property
constructor() {
var _this = this;
let _value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : onesyThemeValueDefault;
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _default$j(optionsDefault$b);
_defineProperty(this, "subscriptions", {
update: new OnesySubscription$1()
});
_defineProperty(this, "direction", 'ltr');
_defineProperty(this, "preference", _default$j(onesyThemeValueDefault.preference));
_defineProperty(this, "mode", 'regular');
_defineProperty(this, "palette", _default$j(onesyThemeValueDefault.palette));
_defineProperty(this, "shape", _default$j(onesyThemeValueDefault.shape));
_defineProperty(this, "breakpoints", _default$j(onesyThemeValueDefault.breakpoints));
_defineProperty(this, "space", _default$j(onesyThemeValueDefault.space));
_defineProperty(this, "shadows", _default$j(onesyThemeValueDefault.shadows));
_defineProperty(this, "typography", _default$j(onesyThemeValueDefault.typography));
_defineProperty(this, "transitions", _default$j(onesyThemeValueDefault.transitions));
_defineProperty(this, "z_index", _default$j(onesyThemeValueDefault.z_index));
_defineProperty(this, "methods", {
palette: {
image: async function (image) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const values = await _default$2(image, {
amount: 4,
size: 140,
allowCrossOrigin: false,
...options
});
return values || [];
},
color: {
value: function (version, tone) {
let light = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
let palette = arguments.length > 3 ? arguments[3] : undefined;
const color = palette || (version === 'default' ? _this.palette.color.neutral : _this.palette.color[version]);
if (color) return _this.palette.light === light ? color[tone] : color[Math.abs(100 - tone)];
},
text: function (background) {
let max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
let prefer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'light';
let maxOpacity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'primary';
const preferenceText = _this.preference.text.default || 'neutral';
const luminances = {
background: _default$6(background),
text: _default$6(_this.palette.text.default.primary)
};
let valueLighten = false;
let tone = preferenceText === 'neutral' ? _this.palette.light ? 0 : 100 : 50;
let contrastRatio = _default$3(background, _this.palette.text.default.primary);
let color = _this.palette.text.default.primary;
if (prefer === 'light' && !valueLighten) valueLighten = _default$3(background, '#fff') >= 1.74;else if (prefer === 'dark' && valueLighten) valueLighten = _default$3(background, '#000') >= 1.74;
if (max) {
tone = valueLighten ? 100 : 0;
color = _default$9(_this.palette.color[preferenceText][tone], _this.palette.visual_contrast.default.opacity[maxOpacity]);
} else {
valueLighten = luminances.text >= luminances.background;
while (contrastRatio < _this.palette.visual_contrast.default.contrast_threshold) {
// Update tone
valueLighten ? tone += 10 : tone -= 10;
tone = _default$d(tone, 0, 100);
color = _default$9(_this.palette.color[preferenceText][tone], _this.palette.visual_contrast.default.opacity.primary);
contrastRatio = _default$3(background, color);
}
}
return color;
},
alpha: _default$8,
emphasize: _default$4,
lighten: _default$5,
darken: _default$7,
getLuminance: _default$6,
getContrastRatio: _default$3,
colorToRgb: _default$9,
rgbToRgba: _default$c,
rgbToHsl: _default,
rgbToHex: _default$1,
hslToRgb: _default$a,
hexToRgb: _default$b
}
},
color: value => OnesyTheme.make.color(value),
shadow: function () {
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.palette.color.primary.main;
let opacities = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.shadows.opacities;
return OnesyTheme.make.shadow(value, opacities);
},
space: {
value: function (value, unit) {
let add = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
let value_;
if (value === 'round') value_ = _this.space.values[value];else value_ = _this.space.unit * (_this.space.values[value] !== undefined ? _this.space.values[value] : value);
return unit ? value_ + add + unit : value_ + add;
}
},
shape: {
radius: {
value: function (value, unit) {
let add = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
const value_ = _this.shape.radius.unit * (_this.shape.radius.values[value] !== undefined ? _this.shape.radius.values[value] : value);
return unit ? value_ + add + unit : value_ + add;
}
}
},
transitions: {
make: function (properties) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
duration: 'rg',
timing_function: 'standard'
};
const props = is$1('array', properties) ? properties : [properties];
const duration = _this.transitions.duration[options === null || options === void 0 ? void 0 : options.duration] || (is$1('number', options === null || options === void 0 ? void 0 : options.duration) ? options === null || options === void 0 ? void 0 : options.duration : _this.transitions.duration.rg);
const timing_function = _this.transitions.timing_function[options === null || options === void 0 ? void 0 : options.timing_function] || is$1('string', options === null || options === void 0 ? void 0 : options.timing_function) && (options === null || options === void 0 ? void 0 : options.timing_function) || _this.transitions.timing_function.standard;
const delay = _this.transitions.duration[options === null || options === void 0 ? void 0 : options.delay] || (is$1('number', options === null || options === void 0 ? void 0 : options.delay) ? options === null || options === void 0 ? void 0 : options.delay : 0);
const motion = [true, undefined].includes(_this.options.motion);
return props.map(prop => "".concat(prop, " ").concat(motion ? duration : 0, "ms ").concat(timing_function, " ").concat(delay, "ms")).join(', ');
}
}
});
_defineProperty(this, "ui", {
className: {
static: true
},
features: 'regular'
});
_defineProperty(this, "elements", {});
this.options = options;
this.options = _default$f(options, optionsDefault$b, {
copy: true
});
this.init(_value);
}
init() {
var _this$preference$visu, _this$palette$visual_5, _this$palette$visual_6, _this$palette$visual_7, _this$palette$visual_8, _this$palette$visual_9, _this$palette$visual_10, _this$palette$visual_11, _this$palette$visual_12, _this$palette$visual_13, _this$palette$visual_14, _this$palette$visual_15, _this$palette$visual_16;
let value_ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this;
const {
mode,
preference,
palette = {},
shape = {},
breakpoints = {},
space = {},
shadows = {},
typography = {},
transitions,
z_index = {},
id,
subscriptions,
methods,
element,
options = {},
direction,
...other
} = _default$j(value_ || {});
const {
light,
color = {},
background = {},
text = {},
visual_contrast = {},
accessibility
} = palette || {};
if (this.id === undefined) this.id = getID(); // Options
this.options = _default$f(options, this.options, {
copy: true
});
this.element = element || this.options.element || this.element; // Direction
if (_default$h('browser')) {
if (!this.element) this.element = window.document.body; // OnesyStyle in element
this.element.setAttribute('data-onesy-theme', 'true');
this.element['onesy-theme'] = true;
this.element.onesy_theme = this;
const style = _default$i(() => window.getComputedStyle(this.element));
this.direction = (style === null || style === void 0 ? void 0 : style.direction) || _default$i(() => window.getComputedStyle(document.documentElement).direction) || 'ltr';
this.options.rule.rtl = this.direction === 'rtl';
} // Light
if (light !== undefined) this.palette.light = light; // Mode
if (mode !== undefined) this.mode = mode; // Preference
if (is$1('object', preference)) this.preference = _default$f(preference, this.preference); // Visual contrast
if (is$1('object', visual_contrast)) this.palette.visual_contrast = _default$f(visual_contrast, this.palette.visual_contrast);
this.palette.visual_contrast.default = this.palette.visual_contrast[((_this$preference$visu = this.preference.visual_contrast) === null || _this$preference$visu === void 0 ? void 0 : _this$preference$visu.default) || 'regular']; // Colors
const defaults = ['primary', 'secondary', 'tertiary', 'quaternary', 'info', 'success', 'warning', 'error', 'neutral']; // Normalize
Object.keys(color).forEach(prop => {
const item = color[prop];
if (is$1('string', item)) color[prop] = {
main: item
};
}); // Defaults if not provided add 'em
defaults.forEach(item => {
if (!is$1('object', color[item])) color[item] = this.palette.color[item];
if (!(is$1('string', color[item].light) || is$1('string', color[item].main) || is$1('string', color[item].dark))) {
color[item].main = this.palette.color[item].main;
}
}); // Accessibility
if (accessibility !== undefined) this.palette.accessibility = accessibility;
if (this.palette.accessibility !== 'regular') {
switch (this.palette.accessibility) {
case 'colorblind':
// Primary
color.primary = this.methods.color(colors$1.blue[500]);
color.primary.light = colors$1.blue[300];
color.primary.main = colors$1.blue[500];
color.primary.dark = colors$1.blue[700]; // Secondary
color.secondary = this.methods.color(colors$1.orange[500]);
color.secondary.light = colors$1.orange[300];
color.secondary.main = colors$1.orange[500];
color.secondary.dark = colors$1.orange[700]; // Tertiary
color.tertiary = this.methods.color(colors$1.yellow[500]);
color.tertiary.light = colors$1.yellow[300];
color.tertiary.main = colors$1.yellow[500];
color.tertiary.dark = colors$1.yellow[700]; // Quaternary
color.quaternary = this.methods.color(colors$1.gray[500]);
color.quaternary.light = colors$1.gray[300];
color.quaternary.main = colors$1.gray[500];
color.quaternary.dark = colors$1.gray[700];
break;
case 'tritanopia':
// Primary
color.primary = this.methods.color(colors$1.blue[500]);
color.primary.light = colors$1.blue[300];
color.primary.main = colors$1.blue[500];
color.primary.dark = colors$1.blue[700]; // Secondary
color.secondary = this.methods.color(colors$1.red[500]);
color.secondary.light = colors$1.red[300];
color.secondary.main = colors$1.red[500];
color.secondary.dark = colors$1.red[700]; // Tertiary
color.tertiary = this.methods.color(colors$1.cyan[500]);
color.tertiary.light = colors$1.cyan[300];
color.tertiary.main = colors$1.cyan[500];
color.tertiary.dark = colors$1.cyan[700]; // Quaternary
color.quaternary = this.methods.color(colors$1.gray[500]);
color.quaternary.light = colors$1.gray[300];
color.quaternary.main = colors$1.gray[500];
color.quaternary.dark = colors$1.gray[700];
break;
}
}
Object.keys(color).forEach(prop => {
const item = color[prop];
const value = OnesyTheme.make.color(color[prop].main || color[prop].light || color[prop].dark);
if (value) {
this.palette.color[prop] = value; // User overrides, add instead of the premade value
if (is$1('object', item)) Object.keys(item).forEach(version => this.palette.color[prop][version] = item[version]);
}
}); // text
Object.keys(text).forEach(prop => {
this.palette.text[prop] = text[prop];
});
Object.keys(this.palette.color).forEach(item => {
var _text$item, _this$palette$visual_, _text$item2, _this$palette$visual_2, _text$item3, _this$palette$visual_3, _text$item4, _this$palette$visual_4;
const version = this.palette.color[item];
if (!this.palette.text[item]) this.palette.text[item] = {};
const colorValue = this.palette.light ? version[item === 'neutral' ? 0 : 30] : version[item === 'neutral' ? 100 : 70];
this.palette.text[item].primary = ((_text$item = text[item]) === null || _text$item === void 0 ? void 0 : _text$item.primary) || _default$9(colorValue, (_this$palette$visual_ = this.palette.visual_contrast.default) === null || _this$palette$visual_ === void 0 ? void 0 : _this$palette$visual_.opacity.primary);
this.palette.text[item].secondary = ((_text$item2 = text[item]) === null || _text$item2 === void 0 ? void 0 : _text$item2.secondary) || _default$9(colorValue, (_this$palette$visual_2 = this.palette.visual_contrast.default) === null || _this$palette$visual_2 === void 0 ? void 0 : _this$palette$visual_2.opacity.secondary);
this.palette.text[item].tertiary = ((_text$item3 = text[item]) === null || _text$item3 === void 0 ? void 0 : _text$item3.tertiary) || _default$9(colorValue, (_this$palette$visual_3 = this.palette.visual_contrast.default) === null || _this$palette$visual_3 === void 0 ? void 0 : _this$palette$visual_3.opacity.tertiary);
this.palette.text[item].quaternary = ((_text$item4 = text[item]) === null || _text$item4 === void 0 ? void 0 : _text$item4.quaternary) || _default$9(colorValue, (_this$palette$visual_4 = this.palette.visual_contrast.default) === null || _this$palette$visual_4 === void 0 ? void 0 : _this$palette$visual_4.opacity.quaternary);
}); // light
const colorLight = this.palette.color.neutral[100];
this.palette.text.light = {};
this.palette.text.light.primary = _default$9(colorLight, (_this$palette$visual_5 = this.palette.visual_contrast.default) === null || _this$palette$visual_5 === void 0 ? void 0 : _this$palette$visual_5.opacity.primary);
this.palette.text.light.secondary = _default$9(colorLight, (_this$palette$visual_6 = this.palette.visual_contrast.default) === null || _this$palette$visual_6 === void 0 ? void 0 : _this$palette$visual_6.opacity.secondary);
this.palette.text.light.tertiary = _default$9(colorLight, (_this$palette$visual_7 = this.palette.visual_contrast.default) === null || _this$palette$visual_7 === void 0 ? void 0 : _this$palette$visual_7.opacity.tertiary);
this.palette.text.light.quaternary = _default$9(colorLight, (_this$palette$visual_8 = this.palette.visual_contrast.default) === null || _this$palette$visual_8 === void 0 ? void 0 : _this$palette$visual_8.opacity.quaternary); // dark
const colorDark = this.palette.color.neutral[0];
this.palette.text.dark = {};
this.palette.text.dark.primary = _default$9(colorDark, (_this$palette$visual_9 = this.palette.visual_contrast.default) === null || _this$palette$visual_9 === void 0 ? void 0 : _this$palette$visual_9.opacity.primary);
this.palette.text.dark.secondary = _default$9(colorDark, (_this$palette$visual_10 = this.palette.visual_contrast.default) === null || _this$palette$visual_10 === void 0 ? void 0 : _this$palette$visual_10.opacity.secondary);
this.palette.text.dark.tertiary = _default$9(colorDark, (_this$palette$visual_11 = this.palette.visual_contrast.default) === null || _this$palette$visual_11 === void 0 ? void 0 : _this$palette$visual_11.opacity.tertiary);
this.palette.text.dark.quaternary = _default$9(colorDark, (_this$palette$visual_12 = this.palette.visual_contrast.default) === null || _this$palette$visual_12 === void 0 ? void 0 : _this$palette$visual_12.opacity.quaternary); // background
Object.keys(background).forEach(prop => {
this.palette.background[prop] = background[prop];
});
Object.keys(this.palette.color).forEach(item => {
var _background$item, _background$item2, _background$item3, _background$item4;
const version = this.palette.color[item];
if (!this.palette.background[item]) this.palette.background[item] = {};
this.palette.background[item].primary = ((_background$item = background[item]) === null || _background$item === void 0 ? void 0 : _background$item.primary) || version[!this.palette.light ? 0 : 100];
this.palette.background[item].secondary = ((_background$item2 = background[item]) === null || _background$item2 === void 0 ? void 0 : _background$item2.secondary) || version[!this.palette.light ? 1 : 99];
this.palette.background[item].tertiary = ((_background$item3 = background[item]) === null || _background$item3 === void 0 ? void 0 : _background$item3.tertiary) || version[!this.palette.light ? 5 : 95];
this.palette.background[item].quaternary = ((_background$item4 = background[item]) === null || _background$item4 === void 0 ? void 0 : _background$item4.quaternary) || version[!this.palette.light ? 10 : 90];
}); // light
this.palette.background.light = {};
this.palette.background.light.primary = this.palette.color.neutral[100];
this.palette.background.light.secondary = this.palette.color.neutral[99];
this.palette.background.light.tertiary = this.palette.color.neutral[95];
this.palette.background.light.quaternary = this.palette.color.neutral[90]; // dark
this.palette.background.dark = {};
this.palette.background.dark.primary = this.palette.color.neutral[0];
this.palette.background.dark.secondary = this.palette.color.neutral[1];
this.palette.background.dark.tertiary = this.palette.color.neutral[5];
this.palette.background.dark.quaternary = this.palette.color.neutral[10]; // default
this.palette.background.default = this.palette.background[this.preference.background.default || 'white'];
this.palette.text.default = this.palette.text[this.preference.text.default || 'neutral']; // other
this.palette.text.divider = _default$9(this.palette.text.default.primary, (_this$palette$visual_13 = this.palette.visual_contrast.default) === null || _this$palette$visual_13 === void 0 ? void 0 : _this$palette$visual_13.opacity.divider);
this.palette.text.active = this.palette.text.default.secondary;
this.palette.text.hover = _default$9(this.palette.text.default.primary, (_this$palette$visual_14 = this.palette.visual_contrast.default) === null || _this$palette$visual_14 === void 0 ? void 0 : _this$palette$visual_14.opacity.hover);
this.palette.text.selected = _default$9(this.palette.text.default.primary, (_this$palette$visual_15 = this.palette.visual_contrast.default) === null || _this$palette$visual_15 === void 0 ? void 0 : _this$palette$visual_15.opacity.selected);
this.palette.text.focus = _default$9(this.palette.text.default.primary, (_this$palette$visual_16 = this.palette.visual_contrast.default) === null || _this$palette$visual_16 === void 0 ? void 0 : _this$palette$visual_16.opacity.focus);
this.palette.text.disabled = this.palette.text.default.tertiary; // Shape
if (is$1('object', shape)) this.shape = _default$f(shape, this.shape); // Radius
if (is$1('object', shape.radius)) {
this.shape.radius.unit = shape.radius.unit !== undefined ? shape.radius.unit : this.shape.radius.unit;
}
if (!this.shape.radius.keys) Object.defineProperty(this.shape.radius, 'keys', {
get() {
return Object.keys(instance.shape.radius.values);
}
}); // Breakpoints
if (is$1('object', breakpoints)) this.breakpoints = _default$f(breakpoints, this.breakpoints);
const instance = this; // Space
if (is$1('object', space)) {
this.space = _default$f(space, this.space);
this.space.unit = space.unit !== undefined ? space.unit : this.space.unit;
}
if (!this.space.keys) Object.defineProperty(this.space, 'keys', {
get() {
return Object.keys(instance.space.values);
}
}); // Shadows
if (is$1('object', shadows)) this.shadows = _default$f(shadows, this.shadows);
Object.keys(this.palette.color).forEach(item => {
const version = this.palette.color[item];
this.shadows.values[item] = OnesyTheme.make.shadow(version.main, this.shadows.opacities);
}); // Default
this.shadows.values.default = OnesyTheme.make.shadow(this.palette.color[this.preference.shadow.default].main, this.shadows.opacities); // Typography
if (is$1('object', typography)) this.typography = _default$f(typography, this.typography); // Transitions
if (is$1('object', transitions)) this.transitions = _default$f(transitions, this.transitions); // zIndex
if (is$1('object', z_index)) this.z_index = _default$f(z_index, this.z_index); // Other
Object.keys(other).forEach(prop => this[prop] = other[prop]); // updates
if (_default$h('browser')) {
if (this.options.updateFontSize) {
const fontSizeHTML = is$1('number', this.typography.font_size.html) ? "".concat(this.typography.font_size.html, "px") : this.typography.font_size.html;
window.document.documentElement.style.fontSize = fontSizeHTML;
}
}
}
async image(value_) {
let other = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
// Image
if (value_) {
const values = await this.methods.palette.image(value_, options);
if (!!values.length) {
const palette = {
color: {
primary: {},
secondary: {},
tertiary: {},
quaternary: {}
}
};
palette.color.primary.main = values[0];
palette.color.secondary.main = values[1];
palette.color.tertiary.main = values[2];
palette.color.quaternary.main = values[3];
const value = _default$f({
palette
}, other, {
copy: true
});
this.init(value); // Add image to the palette
this.palette.image = value_;
}
}
}
update(value) {
if (value !== undefined) {
this.init(_default$j(value));
this.subscriptions.update.emit(value, this);
}
}
static get onesy_theme() {
return new OnesyTheme();
}
static get make() {
return {
color: value => {
const rgb = _default$9(value);
if (rgb) {
const values = {};
const [hue, saturation, light] = _default(rgb, 1, true);
const tones = [];
for (let i = 0; i <= 100; i += 1) tones.push(i); // Tones
tones.forEach(tone => values[tone] = _default$a("hsl(".concat(hue, ", ").concat(saturation, "%, ").concat(tone, "%)"))); // Main
values.main = rgb;
const mainTone = Math.round(_default$n(light) / 10) * 10;
const mainIndex = tones.findIndex(item => item === mainTone); // Light
// max light 90 value
if (mainIndex >= 10) values.light = values[90]; // min light 10 value
else if (mainIndex === 0) values.light = values[10];else values.light = values[tones[mainIndex + 2]]; // Dark
// min dark 10 value
if (mainIndex < 5) values.dark = values[10]; // max dark 90 value
else if (mainIndex === 14) values.dark = values[90];else values.dark = values[tones[mainIndex - 2]];
return values;
}
},
shadow: function (value) {
let opacities = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
const shadow = {
'0': 'none'
};
const values = [['1', [0, 1, 1, 0, 0, 2, 1, -1, 0, 1, 3, 0]], ['2', [0, 2, 2, 0, 0, 3, 3, -2, 0, 1, 8, 0]], ['3', [0, 3, 4, 0, 0, 3, 3, -2, 0, 1, 8, 0]], ['4', [0, 4, 5, 0, 0, 1, 10, 0, 0, 2, 4, -1]], ['6', [0, 6, 10, 0, 0, 1, 18, 0, 0, 3, 5, -1]], ['8', [0, 8, 10, 1, 0, 3, 14, 2, 0, 5, 5, -3]], ['9', [0, 9, 12, 1, 0, 3, 16, 2, 0, 5, 6, -3]], ['12', [0, 12, 17, 2, 0, 5, 22, 4, 0, 7, 7, -4]], ['16', [0, 16, 24, 2, 0, 6, 30, 5, 0, 8, 10, -5]], ['24', [0, 24, 37, 3, 0, 9, 46, 8, 0, 11, 15, -7]]];
values.forEach(_ref => {
let [item, v] = _ref;
return shadow[item] = ["".concat(v[0], "px ").concat(v[1], "px ").concat(v[2], "px ").concat(v[3], "px ").concat(_default$9(value, opacities[0])), "".concat(v[4], "px ").concat(v[5], "px ").concat(v[6], "px ").concat(v[7], "px ").concat(_default$9(value, opacities[1])), "".concat(v[8], "px ").concat(v[9], "px ").concat(v[10], "px ").concat(v[11], "px ").concat(_default$9(value, opacities[2]))].join(', ');
});
return shadow;
}
};
}
static get(value) {
let index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
const themes = this.all(value);
return themes[index === -1 ? themes.length - 1 : index];
}
static first(value) {
return this.get(value);
}
static last(value) {
return this.get(value, -1);
}
static nearest(value) {
var _elementMethod$neares;
return (_elementMethod$neares = _default$g(value).nearest(this.attributes.map(item => "[".concat(item, "]")))) === null || _elementMethod$neares === void 0 ? void 0 : _elementMethod$neares.onesy_theme;
}
static furthest(value) {
var _elementMethod$furthe;
return (_elementMethod$furthe = _default$g(value).furthest(this.attributes.map(item => "[".concat(item, "]")))) === null || _elementMethod$furthe === void 0 ? void 0 : _elementMethod$furthe.onesy_theme;
}
static all(value) {
const elements = [value, ..._default$g(value).parents(this.attributes.map(item => "[".concat(item, "]")))];
return elements.filter(Boolean).map(item => item.onesy_theme).filter(Boolean) || [];
}
}
_defineProperty(OnesyTheme, "attributes", ['data-onesy-theme', 'onesy-theme']);
var OnesyTheme$1 = OnesyTheme;
const optionsDefault$a = {
mode: 'regular',
onesy_style: {
get: OnesyStyle$1.first.bind(OnesyStyle$1)
},
onesy_theme: {
get: OnesyTheme$1.first.bind(OnesyTheme$1)
}
};
function style$1(value_) {
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const options = _default$f(options_, optionsDefault$a, {
copy: true
}); // Onesy style
let onesyStyle = options.onesy_style.value || is$1('function', options.onesy_style.get) && options.onesy_style.get(options.element);
if (onesyStyle === undefined) onesyStyle = new OnesyStyle$1(); // Onesy theme
const onesyTheme = options.onesy_theme.value || is$1('function', options.onesy_theme.get) && options.onesy_theme.get(options.element); // Make value if it's a function
const value = is$1('function', value_) ? _default$i(() => value_(onesyTheme)) : value_; // Make an instance of onesyStyleSheetManager
const onesyStyleSheetManager = new OnesyStyleSheetManager$1(value, {
mode: options.mode,
pure: false,
priority: 'upper',
onesyTheme,
onesyStyle,
name: options.name,
style: {
attributes: {
method: 'style'
}
}
});
const response = {
ids: onesyStyleSheetManager.ids,
onesy_style_sheet_manager: onesyStyleSheetManager,
sheets: onesyStyleSheetManager.sheets,
add: onesyStyleSheetManager.add.bind(onesyStyleSheetManager),
set props(value__) {
onesyStyleSheetManager.props = value__;
},
update: onesyStyleSheetManager.update.bind(onesyStyleSheetManager),
remove: onesyStyleSheetManager.remove.bind(onesyStyleSheetManager),
addRule: onesyStyleSheetManager.sheets.static[0] && onesyStyleSheetManager.sheets.static[0].addRule.bind(onesyStyleSheetManager.sheets.static[0])
}; // if add
if (options.add) {
const addResponse = response.add(); // return
return options.return ? addResponse[options.return] || addResponse : addResponse;
} // Response
return response;
}
const optionsDefault$9 = {
onesy_style: {
get: OnesyStyle$1.first.bind(OnesyStyle$1)
},
onesy_theme: {
get: OnesyTheme$1.first.bind(OnesyTheme$1)
}
};
function pure$1(value_) {
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const options = _default$f(options_, optionsDefault$9, {
copy: true
}); // Onesy style
let onesyStyle = options.onesy_style.value || is$1('function', options.onesy_style.get) && options.onesy_style.get(options.element);
if (onesyStyle === undefined) onesyStyle = new OnesyStyle$1(); // Onesy theme
const onesyTheme = options.onesy_theme.value || is$1('function', options.onesy_theme.get) && options.onesy_theme.get(options.element); // Make value if it's a function
const value = is$1('function', value_) ? _default$i(() => value_(onesyTheme)) : value_; // Make an instance of onesyStyleSheetManager
const onesyStyleSheetManager = new OnesyStyleSheetManager$1(value, {
mode: 'regular',
pure: true,
priority: 'lower',
onesyTheme,
onesyStyle,
name: options.name,
style: {
attributes: {
method: 'pure'
}
}
});
const response = {
ids: onesyStyleSheetManager.ids,
onesy_style_sheet_manager: onesyStyleSheetManager,
sheets: onesyStyleSheetManager.sheets,
add: onesyStyleSheetManager.add.bind(onesyStyleSheetManager),
set props(value__) {
onesyStyleSheetManager.props = value__;
},
update: onesyStyleSheetManager.update.bind(onesyStyleSheetManager),
remove: onesyStyleSheetManager.remove.bind(onesyStyleSheetManager),
addRule: onesyStyleSheetManager.sheets.static[0] && onesyStyleSheetManager.sheets.static[0].addRule.bind(onesyStyleSheetManager.sheets.static[0])
}; // Response
return response;
}
const FONT_FAMILY = {
primary: ['DM Sans', 'Helvetica', '"Helvetica Neue"', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Arial', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"', 'sans-serif'].join(', '),
secondary: ['DM Sans', 'Helvetica', '"Helvetica Neue"', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Arial', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"', 'sans-serif'].join(', '),
mono: ['Roboto Mono', 'monospace'].join(', ')
};
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
const normalize = {
html: {
lineHeight: '1.15',
'-webkit-text-size-adjust': '100%'
},
main: {
display: 'block'
},
h1: {
fontSize: '2em'
},
hr: {
boxSizing: 'content-box',
height: '0px',
overflow: 'visible'
},
pre: {
fontFamily: 'monospace, monospace',
fontSize: '1em'
},
a: {
backgroundColor: 'transparent'
},
'abbr[title]': {
borderBottom: 'none',
textDecoration: {
value: 'underline',
fallbacks: ['underline dotted']
}
},
'b, strong': {
fontWeight: 'bolder'
},
'code, kbd, samp': {
fontFamily: 'monospace, monospace',
fontSize: '1em'
},
small: {
fontSize: '80%'
},
'sub, sup': {
fontSize: '75%',
lineHeight: '0',
position: 'relative',
verticalAlign: 'baseline'
},
sub: {
bottom: '-0.25em'
},
sup: {
top: '-0.5em'
},
img: {
borderStyle: 'none'
},
'button, input, optgroup, select, textarea': {
fontFamily: 'inherit',
fontSize: '100%',
lineHeight: '1.15',
margin: '0px'
},
'button, input': {
overflow: 'visible'
},
'button, select': {
textTransform: 'none'
},
'button, [type="button"], [type="reset"], [type="submit"]': {
'-webkit-appearance': 'button'
},
'button::-moz-focus-inner, [type="button"]::-moz-focus-inner, [type="reset"]::-moz-focus-inner, [type="submit"]::-moz-focus-inner': {
borderStyle: 'none',
padding: '0px'
},
'button:-moz-focusring, [type="button"]:-moz-focusring, [type="reset"]:-moz-focusring, [type="submit"]:-moz-focusring': {
outline: '1px dotted ButtonText'
},
fieldset: {
padding: '0.35em 0.75em 0.625em'
},
legend: {
boxSizing: 'border-box',
color: 'inherit',
display: 'table',
maxWidth: '100%',
padding: '0px',
whiteSpace: 'normal'
},
progress: {
verticalAlign: 'baseline'
},
textarea: {
overflow: 'auto'
},
'[type="checkbox"], [type="radio"]': {
boxSizing: 'border-box',
padding: '0px'
},
'[type="number"]::-webkit-inner-spin-button, [type="number"]::-webkit-outer-spin-button': {
height: 'auto'
},
'[type="search"]': {
'-webkit-appearance': 'textfield',
outlineOffset: '-2px'
},
'[type="search"]::-webkit-search-decoration': {
'-webkit-appearance': 'none'
},
'::-webkit-file-upload-button': {
'-webkit-appearance': 'button',
font: 'inherit'
},
details: {
display: 'block'
},
summary: {
display: 'list-item'
},
template: {
display: 'none'
},
'[hidden]': {
display: 'none'
}
};
const resetDefault = {
'*': {
margin: '0px',
padding: '0px',
border: 'none',
outline: 'none',
fontSize: '100%',
background: 'transparent',
boxSizing: 'border-box',
touchAction: 'manipulation',
'-webkit-tap-highlight-color': 'transparent',
'-webkit-focus-ring-color': 'transparent',
'&[contenteditable]': {
userSelect: 'text'
},
'&[contenteditable]:empty:before': {
display: 'block',
content: "attr(data-placeholder)",
color: 'inherit',
fontStyle: 'inherit',
fontFamily: 'inherit',
fontSize: 'inherit',
fontWeight: 'inherit',
opacity: '0.24'
}
},
body: {
fontSize: '0.875rem',
fontFamily: FONT_FAMILY.secondary,
fontWeight: 'normal',
fontStyle: 'normal',
position: 'relative',
overflowX: 'hidden',
backgroundColor: '#fff',
wordBreak: 'break-word',
// visibility hidden ui elements
'& .onesy-hidden': {
width: '0px',
height: '0px',
opacity: '0',
overflow: 'hidden',
visibility: 'hidden',
userSelect: 'none',
pointerEvents: 'none'
}
},
'img, embed, object, video': {
maxWidth: '100%',
height: 'auto'
},
a: {
textDecoration: 'none',
cursor: 'pointer'
},
form: {
width: '100%'
},
span: {
wordWrap: 'break-word'
},
hr: {
height: '1px',
background: '#ddd',
width: '100%',
margin: '24px 0'
},
'pre, code, kbd, samp': {
fontFamily: FONT_FAMILY.mono
},
code: {
'& span': {
whiteSpace: 'pre-wrap'
}
},
':focus': {
outline: 'none'
},
'::-webkit-scrollbar': {
width: '16px',
height: '16px'
},
'::-webkit-scrollbar-track, ::-webkit-scrollbar-corner': {
background: 'transparent'
},
'::-webkit-scrollbar-thumb': {
borderRadius: '8px',
border: '4px solid transparent',
backgroundClip: 'content-box',
backgroundColor: 'rgba(221, 221, 221, 0.4)',
'&:hover': {
backgroundColor: 'rgba(221, 221, 221, 0.7)'
}
}
};
const optionsDefault$8 = {
mode: 'regular',
onesy_style: {
get: OnesyStyle$1.first.bind(OnesyStyle$1)
},
onesy_theme: {
get: OnesyTheme$1.first.bind(OnesyTheme$1)
}
};
function reset$1(value_) {
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const options = _default$f(options_, optionsDefault$8, {
copy: true
}); // Onesy style
let onesyStyle = options.onesy_style.value || is$1('function', options.onesy_style.get) && options.onesy_style.get(options.element);
if (onesyStyle === undefined) onesyStyle = new OnesyStyle$1(); // Onesy theme
const onesyTheme = options.onesy_theme.value || is$1('function', options.onesy_theme.get) && options.onesy_theme.get(options.element); // Make value if it's a function
let value = is$1('function', value_) ? _default$i(() => value_(onesyTheme)) : value_;
if (!is$1('object', value)) value = {}; // Default
const valueDefault = _default$f(resetDefault, normalize, {
copy: true
}); // Add reset defaults
// user provided values override reset default values
if (options.override) value = { ...valueDefault,
...value
};else value = _default$f(value, valueDefault, {
copy: true
}); // Make an instance of onesyStyleSheetManager
const onesyStyleSheetManager = new OnesyStyleSheetManager$1(value, {
mode: 'regular',
pure: true,
priority: 'lower',
onesyTheme,
onesyStyle,
name: options.name,
style: {
attributes: {
method: 'reset'
}
}
});
const response = {
ids: onesyStyleSheetManager.ids,
onesy_style_sheet_manager: onesyStyleSheetManager,
sheets: onesyStyleSheetManager.sheets,
add: onesyStyleSheetManager.add.bind(onesyStyleSheetManager),
set props(value__) {
onesyStyleSheetManager.props = value__;
},
update: onesyStyleSheetManager.update.bind(onesyStyleSheetManager),
remove: onesyStyleSheetManager.remove.bind(onesyStyleSheetManager),
addRule: onesyStyleSheetManager.sheets.static[0] && onesyStyleSheetManager.sheets.static[0].addRule.bind(onesyStyleSheetManager.sheets.static[0])
}; // Response
return response;
}
const optionsDefault$7 = {
onesy_style: {
get: OnesyStyle$1.first.bind(OnesyStyle$1)
},
onesy_theme: {
get: OnesyTheme$1.first.bind(OnesyTheme$1)
},
response: 'css',
response_json_property_version: 'cammel'
};
function inline$1(value_, props) {
let options_ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
const options = { ...optionsDefault$7,
...options_
}; // Onesy style
let onesyStyle = options.onesy_style.value || is$1('function', options.onesy_style.get) && options.onesy_style.get(options.element);
if (onesyStyle === undefined) onesyStyle = new OnesyStyle$1(); // Onesy theme
const onesyTheme = options.onesy_theme.value || is$1('function', options.onesy_theme.get) && options.onesy_theme.get(options.element); // Make value if it's a function
const value = is$1('function', value_) ? _default$i(() => value_(onesyTheme)) : value_; // Go through all properties
// make an OnesyStyleRuleProperty for each prop
// and then make css string from each one
let response = '';
if (is$1('object', value)) {
const properties = Object.keys(value);
const valueNew = {}; // Filter out at-rule and dynamic properies
properties.filter(prop => prop.indexOf('@') !== 0 && !(is$1('function', value[prop]) || isOnesySubscription(value[prop]))).forEach(prop => valueNew[prop] = value[prop]); // Parse dynamic properties into static
const propertiesDynamic = properties.filter(prop => prop.indexOf('@') !== 0 && (is$1('function', value[prop]) || isOnesySubscription(value[prop])));
propertiesDynamic.forEach(prop => {
const valueProp = value[prop];
if (is$1('function', valueProp)) valueNew[prop] = _default$i(() => valueProp(props));else if (isOnesySubscription(valueProp)) valueNew[prop] = _default$i(() => valueProp.value);
}); // Make an instance of onesyStyleSheetManager
const onesyStyleSheetManager = new OnesyStyleSheetManager$1({
a: valueNew
}, {
mode: 'regular',
pure: false,
priority: 'upper',
onesyTheme,
onesyStyle,
onesy_style_cache: false,
style: {
attributes: {
method: 'inline'
}
}
});
const rules = onesyStyleSheetManager.sheets.static[0].rules[0].value.rules;
rules.map(rule => rule.value).forEach(rule => response += " ".concat(rule.css)); // Make into json
if (options.response === 'json') {
const values = response.split(';').filter(Boolean);
response = {};
values.forEach(item => {
var _property, _value__;
let [property, value__] = item.split(':').filter(Boolean);
property = (_property = property) === null || _property === void 0 ? void 0 : _property.trim();
value__ = (_value__ = value__) === null || _value__ === void 0 ? void 0 : _value__.trim();
if (property && value__) {
response[options.response_json_property_version === 'cammel' ? kebabCasetoCammelCase(property) : cammelCaseToKebabCase(property)] = value__;
}
});
}
}
if (options.response === 'css') response = response.trim(); // Response
return response;
}
if (typeof global$1.setTimeout === 'function') ;
if (typeof global$1.clearTimeout === 'function') ;
// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
var performance = global$1.performance || {};
performance.now ||
performance.mozNow ||
performance.msNow ||
performance.oNow ||
performance.webkitNow ||
function(){ return (new Date()).getTime() };
const optionsDefault$6 = {
production: _default$h('browser') || _default$h('nodejs') && ['prod', 'production'].indexOf("development") > -1
};
let onesyMakeClassNameInc = 0;
function makeClassName(onesyStyle) {
var _onesyStyle$options;
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const options = { ...optionsDefault$6,
...options_
};
const prefix = (onesyStyle === null || onesyStyle === void 0 ? void 0 : (_onesyStyle$options = onesyStyle.options) === null || _onesyStyle$options === void 0 ? void 0 : _onesyStyle$options.classNamePrefix) || ''; // If both dev and prod are false, then dev is true
const production = options.production !== undefined ? options.production : optionsDefault$6.production;
const makeNameMethodClassName = makeName();
const makeNameMethodKeyframesName = makeName();
const domUnique = value => {
const allClassNames = [...new Set(Array.from(window.document.querySelectorAll('[class]')).flatMap(item => [...item.classList]))];
return allClassNames.indexOf(value) === -1;
};
const method = function () {
let method_ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : makeNameMethodClassName;
const made = [];
return value_ => {
const value = {
arguments: {
value: value_
}
}; // Make a class name
// Production
if (production) {
value.value = "".concat(prefix).concat(method_.next().value);
while (true) {
var _options$dom;
if (made.includes(value.value) || (_options$dom = options.dom) !== null && _options$dom !== void 0 && _options$dom.unique && !domUnique(value.value)) {
value.value = "".concat(prefix).concat(method_.next().value);
} else break;
}
} // Development
else {
value.value = "".concat(prefix).concat(value_.property, "-").concat(++onesyMakeClassNameInc);
while (true) {
var _options$dom2;
if ((_options$dom2 = options.dom) !== null && _options$dom2 !== void 0 && _options$dom2.unique && !domUnique(value.value)) {
value.value = "".concat(prefix).concat(value_ === null || value_ === void 0 ? void 0 : value_.property, "-").concat(++onesyMakeClassNameInc);
} else break;
}
}
made.push(value);
return value;
};
};
const methodClassName = method();
const methodKeyframesName = method(makeNameMethodKeyframesName); // Add methods to subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.className.name.subscribe(methodClassName);
onesyStyle.subscriptions.keyframes.name.subscribe(methodKeyframesName);
}
const remove = () => {
// Remove methods from subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.className.name.unsubscribe(methodClassName);
onesyStyle.subscriptions.keyframes.name.unsubscribe(methodKeyframesName);
}
};
const response = {
methods: {
method: methodClassName
},
remove
};
return response;
}
const optionsDefault$5 = {
ssr: {
all: true
}
}; // As of April, 01, 2022 all prefixed required for some of the browser versions
const mapAllPropertyPrefixes = {
'appearance': ['-webkit-', '-moz-'],
'backdrop-filter': ['-webkit-'],
'background-clip': ['-webkit-'],
'box-decoration-break': ['-webkit-'],
'clip-path': ['-webkit-'],
'color-adjust': ['-webkit-'],
'font-smooth': ['-webkit-', '-moz-'],
'hyphens': ['-webkit-', '-ms-', '-moz-'],
'initial-letter': ['-webkit-'],
'line-clamp': ['-webkit-'],
'writing-mode': ['-webkit-'],
'text-decoration': ['-webkit-', '-moz-'],
'text-emphasis': ['-webkit-'],
'text-orientation': ['-webkit-'],
'text-size-adjust': ['-webkit-', '-ms-', '-moz-'],
'user-select': ['-webkit-', '-ms-', '-moz-'],
'font-kerning': ['-webkit-'],
'tab-size': ['-o-', '-moz-'],
'wrap-flow': ['-ms-'],
'wrap-through': ['-ms-'],
'grid': ['-ms-'],
'mask': ['-webkit-'],
'reflect': ['-webkit-'],
'flow-into': ['-webkit-', '-ms-'],
'flow-from': ['-webkit-', '-ms-'],
'region-fragment': ['-webkit-', '-ms-'],
'scroll-snap': ['-webkit-', '-ms-'],
'text-stroke': ['-webkit-'],
'text-fill': ['-webkit-'],
'max-content': ['-webkit-', '-moz-'],
'min-content': ['-webkit-', '-moz-'],
'fit-content': ['-webkit-', '-moz-'],
'stretch': ['-webkit-', '-moz-'],
'available': ['-webkit-', '-moz-'],
'resolution': ['-webkit-', '-o-'],
'min-resolution': ['-webkit-', '-o-'],
'max-resolution': ['-webkit-', '-o-'],
'keyframe': ['-webkit-', '-o-', '-moz-'],
'animation': ['-webkit-', '-moz-'],
'transform': ['-webkit-', '-o-', '-ms-', '-moz-'],
'transition': ['-webkit-', '-o-', '-moz-']
}; // Where property index is > -1 and value index is > -1 and replace it with
const mapAllValuePrefixes = {
'position': {
'sticky': ['-webkit-']
},
'background-clip': {
'text': ['-webkit-', '-ms-']
},
'background-image': {
'crossfade': ['-webkit-'],
'image-set': ['-webkit-', '-o-', '-ms-', '-moz-'],
'element': ['-moz-'],
'canvas': ['-webkit-']
},
'background': {
'crossfade': ['-webkit-'],
'image-set': ['-webkit-', '-o-', '-ms-', '-moz-'],
'element': ['-moz-'],
'canvas': ['-webkit-']
}
};
function prefix(onesyStyle) {
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const options = { ...optionsDefault$5,
...options_
};
const valid = (value, property) => {
if (_default$h('browser')) {
const element = document.createElement('a');
const props = [property];
if (property.indexOf('-webkit-') === 0) props.push("webkit".concat(capitalizedCammelCase(property.slice(8))));
if (property.indexOf('-o-') === 0) props.push("o".concat(capitalizedCammelCase(property.slice(3))));
if (property.indexOf('-ms-') === 0) props.push("ms".concat(capitalizedCammelCase(property.slice(4))));
if (property.indexOf('-moz-') === 0) props.push("moz".concat(capitalizedCammelCase(property.slice(5))));
for (const prop of props) {
if (prop in element.style) {
try {
element.style[prop] = value;
if (!!element.style[prop].length) return true;
} catch (error) {}
}
}
return false;
}
return options.ssr.all;
};
const method = value_ => {
const value = {
value: [],
arguments: {
value: value_
}
}; // if initial value property are valid return
if (_default$h('browser') && valid(value_.value, value_.property)) return value; // make mix of all prefix versions for value and property and all mixes other than the original
const propertyPrefixesKey = Object.keys(mapAllPropertyPrefixes).find(item => value_.property.indexOf(item) > -1);
const propertyPrefixes = mapAllPropertyPrefixes[propertyPrefixesKey] || [];
const properties = [value_.property, ...propertyPrefixes.map(prefix_ => "".concat(prefix_).concat(value_.property))];
const valuePrefixesProps = mapAllValuePrefixes[value_.property];
const valuePrefixesKey = valuePrefixesProps && Object.keys(valuePrefixesProps).find(item => value_.value.indexOf(item) > -1);
const valuePrefixes = valuePrefixesProps && valuePrefixesProps[valuePrefixesKey] || [];
const values = [value_.value, ...valuePrefixes.map(prefix_ => "".concat(prefix_).concat(value_.value))];
const items = [];
properties.forEach(property__ => {
values.forEach(value__ => {
if (!(property__ === value_.property && value__ === value_.value)) {
items.push({
property: property__,
value: value__
});
}
});
}); // for each one that works push it to value.value
items.forEach(item => {
if (valid(item.value, item.property)) value.value.push(item);
});
return value;
}; // Add methods to subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.rule.prefix.subscribe(method);
}
const remove = () => {
// Remove methods from subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.rule.prefix.unsubscribe(method);
}
};
const response = {
methods: {
method
},
remove
};
return response;
}
function rtl(onesyStyle) {
const method = value_ => {
const value = {
value: {
value: '',
property: ''
},
arguments: {
value: value_
}
};
if (is$1('string', value_.value)) {
if (value_.value.indexOf('left') > -1) value.value.value = value_.value.replace(/left/ig, 'right');else if (value_.value.indexOf('right') > -1) value.value.value = value_.value.replace(/right/ig, 'left');else value.value.value = value_.value;
}
if (is$1('string', value_.property)) {
if (value_.property.indexOf('left') > -1) value.value.property = value_.property.replace(/left/ig, 'right');else if (value_.property.indexOf('right') > -1) value.value.property = value_.property.replace(/right/ig, 'left');else value.value.property = value_.property;
}
return value;
}; // Add method to subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.rule.rtl.subscribe(method);
}
const remove = () => {
// Remove method from subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.rule.rtl.unsubscribe(method);
}
};
const response = {
methods: {
method
},
remove
};
return response;
}
const optionsDefault$4 = {
priority: 'individual'
};
function sort(onesyStyle) {
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const options = { ...optionsDefault$4,
...options_
};
const method = values => {
const value = {
arguments: {
values
}
};
if (is$1('array', values)) {
const priority = options.priority; // Sort by grouping all rules
values.sort((a, b) => {
if (a.value instanceof OnesyStyleRuleProperty$1 && !(b.value instanceof OnesyStyleRuleProperty$1)) return -1;
if (a.constructor === b.constructor || is$1('simple', a.value) && is$1('simple', b.value)) return 0;
return 1;
}); // Order by priority
if (priority !== 'original') values.sort((a, b) => {
if (!(a.value instanceof OnesyStyleRuleProperty$1 && b.value instanceof OnesyStyleRuleProperty$1 || is$1('simple', a.value) && is$1('simple', b.value))) return 0;
if ((a === null || a === void 0 ? void 0 : a.property) < (b === null || b === void 0 ? void 0 : b.property)) return priority === 'individual' ? -1 : 1;
if ((a === null || a === void 0 ? void 0 : a.property) > (b === null || b === void 0 ? void 0 : b.property)) return priority === 'individual' ? 1 : -1;
}); // Add sorted array to value
value.value = values;
}
return value;
}; // Add method to subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.rules.sort.subscribe(method);
}
const remove = () => {
// Remove method from subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.rules.sort.unsubscribe(method);
}
};
const response = {
methods: {
method
},
remove
};
return response;
}
const optionsDefault$3 = {
units: {}
};
const unitsDefault = {
'animation': 's',
'animation-delay': 's',
'animation-duration': 's',
'ascent-override': '%',
'background': '%',
'background-position': '%',
'background-size': '%',
'background-position-x': '%',
'background-position-y': '%',
'border': 'px',
'border-top': 'px',
'border-right': 'px',
'border-bottom': 'px',
'border-left': 'px',
'border-radius': 'px',
'border-top-left-radius': 'px',
'border-top-right-radius': 'px',
'border-bottom-left-radius': 'px',
'border-bottom-right-radius': 'px',
'border-width': 'px',
'border-top-width': 'px',
'border-right-width': 'px',
'border-bottom-width': 'px',
'border-left-width': 'px',
'border-image': '%',
'border-image-outset': 'px',
'border-image-slice': '%',
'border-image-width': 'px',
'border-spacing': 'px',
'block-size': 'px',
'border-block': 'px',
'border-block-end': 'px',
'border-block-end-width': 'px',
'border-block-start': 'px',
'border-block-start-width': 'px',
'border-block-width': 'px',
'border-end-end-radius': 'px',
'border-end-start-radius': 'px',
'border-inline': 'px',
'border-inline-end': 'px',
'border-inline-end-width': 'px',
'border-inline-start': 'px',
'border-inline-start-width': 'px',
'border-inline-width': 'px',
'border-style': 'px',
'border-start-end-radius': 'px',
'border-start-start-radius': 'px',
'box-shadow': 'px',
'bottom': '%',
'columns': 'px',
'column-width': 'px',
'column-gap': 'px',
'column-rule': 'px',
'column-rule-width': 'px',
'contain-intrinsic-block-size': 'px',
'contain-intrinsic-height': 'px',
'contain-intrinsic-inline-size': 'px',
'contain-intrinsic-size': 'px',
'contain-intrinsic-width': 'px',
'cx': '%',
'cy': '%',
'descent-override': '%',
'flex': '%',
'flex-basis': '%',
'font': 'px',
'font-size': 'px',
'font-synthesis': 'px',
'font-synthesis-weight': 'px',
'gap': 'px',
'grid': 'px',
'grid-auto-columns': 'px',
'grid-auto-rows': 'px',
'grid-column-gap': 'px',
'grid-gap': 'px',
'grid-row-gap': 'px',
'grid-template': 'px',
'grid-template-rows': 'px',
'grid-template-columns': 'px',
'height': 'px',
'inline-size': 'px',
'inset': 'px',
'inset-block': 'px',
'inset-block-end': 'px',
'inset-block-start': 'px',
'inset-inline': 'px',
'inset-inline-end': 'px',
'inset-inline-start': 'px',
'left': '%',
'letter-spacing': 'px',
'line-gap-override': '%',
'margin': 'px',
'margin-top': 'px',
'margin-right': 'px',
'margin-bottom': 'px',
'margin-left': 'px',
'margin-block': 'px',
'margin-block-end': 'px',
'margin-block-start': 'px',
'margin-inline': 'px',
'margin-inline-end': 'px',
'margin-inline-start': 'px',
'mask': 'px',
'mask-position': '%',
'mask-size': '%',
'max-block-size': 'px',
'max-inline-size': 'px',
'min-block-size': 'px',
'min-inline-size': 'px',
'max-height': 'px',
'max-width': 'px',
'min-height': 'px',
'min-width': 'px',
'object-position': '%',
'outline': 'px',
'outline-offset': 'px',
'outline-width': 'px',
'offset': 'px',
'offset-anchor': '%',
'offset-distance': '%',
'offset-position': '%',
'offset-rotate': 'deg',
'padding': 'px',
'padding-top': 'px',
'padding-right': 'px',
'padding-bottom': 'px',
'padding-left': 'px',
'padding-block': 'px',
'padding-block-end': 'px',
'padding-block-start': 'px',
'padding-inline': 'px',
'padding-inline-end': 'px',
'padding-inline-start': 'px',
'perspective': 'px',
'right': '%',
'row-gap': 'px',
'scroll-margin': 'px',
'scroll-margin-block': 'px',
'scroll-margin-block-end': 'px',
'scroll-margin-block-start': 'px',
'scroll-margin-bottom': 'px',
'scroll-margin-inline': 'px',
'scroll-margin-inline-end': 'px',
'scroll-margin-inline-start': 'px',
'scroll-margin-left': 'px',
'scroll-margin-right': 'px',
'scroll-margin-top': 'px',
'scroll-padding': 'px',
'scroll-padding-block': 'px',
'scroll-padding-block-end': 'px',
'scroll-padding-block-start': 'px',
'scroll-padding-bottom': 'px',
'scroll-padding-inline': 'px',
'scroll-padding-inline-end': 'px',
'scroll-padding-inline-start': 'px',
'scroll-padding-left': 'px',
'scroll-padding-right': 'px',
'scroll-padding-top': 'px',
'shape-margin': 'px',
'size': 'in',
'size-adjust': '%',
'text-decoration': 'px',
'text-decoration-thickness': 'px',
'text-indent': 'px',
'text-size-adjust': '%',
'text-shadow': 'px',
'text-underline-offset': 'px',
'top': '%',
'transform-origin': '%',
'transition': 's',
'transition-delay': 's',
'transition-duration': 's',
'width': 'px',
'word-spacing': 'px',
'zoom': '%'
};
function unit(onesyStyle) {
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const options = { ...optionsDefault$3,
...options_
};
const units = { ...unitsDefault,
...(options.units || {})
};
const method = value_ => {
// Normalize property
const property = {
cammel: cammelCaseToKebabCase(value_.property),
kebab: kebabCasetoCammelCase(value_.property)
};
const method_ = item => is$1('function', item) ? item(value_.value) : {
value: "".concat(value_.value).concat(item || ''),
unit: item || ''
};
const value = {
value: method_(units[property.cammel]) || method_(units[property.kebab]) || '',
arguments: {
value: _default$j(value_)
}
};
return value;
}; // Add method to subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.rule.unit.subscribe(method);
}
const remove = () => {
// Remove method from subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.rule.unit.unsubscribe(method);
}
};
const response = {
methods: {
method
},
remove
};
return response;
}
function valueObject(onesyStyle) {
const method = function () {
let value_ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
const value = {
arguments: {
value: value_
}
};
const {
property
} = value_;
if (is$1('object', value_.value)) {
// Object extendable
let top;
let right;
let bottom;
let left;
let width;
let height;
let horizontal;
let vertical;
let templateRows;
let templateColumns;
let position;
let duration;
let delay;
let easingFunction;
switch (property) {
case 'animation':
duration = valueResolve('animation-duration', value_.value['duration'], onesyStyle).value[0];
duration = duration !== undefined ? duration : value_.value['duration'];
delay = valueResolve('andimation-delay', value_.value['delay'], onesyStyle).value[0];
delay = delay !== undefined ? delay : value_.value['delay'];
easingFunction = value_.value['easing-function'] || value_.value['easingFunction'];
const iterationCount = value_.value['iterationCount'] !== undefined ? value_.value['iterationCount'] : value_.value['iteration-count'];
const fillMode = value_.value['fillMode'] !== undefined ? value_.value['fillMode'] : value_.value['fill-mode'];
const playState = value_.value['playState'] !== undefined ? value_.value['playState'] : value_.value['play-state'];
value.value = [[value_.value['name'], duration, easingFunction, delay, iterationCount, value_.value['direction'], fillMode, playState].filter(item => item !== undefined).join(' ')];
break;
case 'background':
position = valueResolve('background-position', value_.value['position'], onesyStyle).value[0];
position = position !== undefined ? position : value_.value['position'];
value.value = [[value_.value['color'], value_.value['image'], value_.value['repeat'], position].filter(item => item !== undefined).join(' ')];
break;
case 'border':
case 'border-top':
case 'border-right':
case 'border-bottom':
case 'border-left':
case 'border-block':
case 'border-block-end':
case 'border-block-start':
case 'border-inline-end':
case 'border-inline-start':
case 'column-rule':
width = valueResolve(property, value_.value['width'], onesyStyle).value[0];
width = width !== undefined ? width : value_.value['width'];
value.value = [[width, value_.value['style'], value_.value['color']].filter(item => item !== undefined).join(' ')];
break;
case 'outline':
width = valueResolve('outline-width', value_.value['width'], onesyStyle).value[0] || value_.value['width'];
width = width !== undefined ? width : value_.value['width'];
value.value = [[value_.value['color'], value_.value['style'], width].filter(item => item !== undefined).join(' ')];
break;
case 'border-color':
case 'border-top-color':
case 'border-right-color':
case 'border-bottom-color':
case 'border-left-color':
top = value_.value['top'] !== undefined ? value_.value['top'] : 'transparent';
right = value_.value['right'] !== undefined ? value_.value['right'] : 'transparent';
bottom = value_.value['bottom'] !== undefined ? value_.value['bottom'] : 'transparent';
left = value_.value['left'] !== undefined ? value_.value['left'] : 'transparent';
value.value = [[top, right, bottom, left].filter(item => item !== undefined).join(' ')];
break;
case 'background-position':
const keys = Object.keys(value_.value);
value.value = [[]];
keys.forEach(item => {
let value__ = valueResolve('background-position', value_.value[item], onesyStyle).value[0];
value__ = value__ !== undefined ? value__ : value_.value[item];
if (value__ !== undefined) value.value[0].push(value__);
});
value.value[0] = value.value[0].join(' ');
break;
case 'font':
const lineHeight = value_.value['line-height'] || value_.value['lineHeight'] || value_.value['height'];
let fontSize = valueResolve('font-size', value_.value['size'], onesyStyle).value[0];
fontSize = fontSize !== undefined ? fontSize : value_.value['size'];
let fontFamily = valueResolve('font-family', value_.value['family'], onesyStyle).value[0];
fontFamily = fontFamily !== undefined ? fontFamily : value_.value['family'];
const other = fontSize && lineHeight ? ["".concat(fontSize, "/").concat(lineHeight)] : [fontSize, lineHeight];
value.value = [[value_.value['style'], value_.value['weight'], ...other, fontFamily].filter(item => item !== undefined).join(' ')];
break;
case 'margin':
case 'padding':
case 'border-width':
case 'border-image-outset':
top = valueResolve(property, value_.value['top'], onesyStyle).value[0];
top = top !== undefined ? top : value_.value['top'] !== undefined ? value_.value['top'] : 0;
right = valueResolve(property, value_.value['right'], onesyStyle).value[0];
right = right !== undefined ? right : value_.value['right'] !== undefined ? value_.value['right'] : 0;
bottom = valueResolve(property, value_.value['bottom'], onesyStyle).value[0];
bottom = bottom !== undefined ? bottom : value_.value['bottom'] !== undefined ? value_.value['bottom'] : 0;
left = valueResolve(property, value_.value['left'], onesyStyle).value[0];
left = left !== undefined ? left : value_.value['left'] !== undefined ? value_.value['left'] : 0;
value.value = [[top, right, bottom, left].filter(item => item !== undefined).join(' ')];
break;
case 'scroll-margin':
case 'scroll-padding':
top = valueResolve(property, value_.value['top'], onesyStyle).value[0];
top = top !== undefined ? top : value_.value['top'] !== undefined ? value_.value['top'] : 0;
right = valueResolve(property, value_.value['right'], onesyStyle).value[0];
right = right !== undefined ? right : value_.value['right'] !== undefined ? value_.value['right'] : 0;
bottom = valueResolve(property, value_.value['bottom'], onesyStyle).value[0];
bottom = bottom !== undefined ? bottom : value_.value['bottom'] !== undefined ? value_.value['bottom'] : 0;
left = valueResolve(property, value_.value['left'], onesyStyle).value[0];
left = left !== undefined ? left : value_.value['left'] !== undefined ? value_.value['left'] : 0;
value.value = [[bottom, left, right, top].filter(item => item !== undefined).join(' ')];
break;
case 'overflow':
case 'background-repeat':
value.value = [[value_.value['x'], value_.value['y']].filter(item => item !== undefined).join(' ')];
break;
case 'background-size':
width = valueResolve(property, value_.value['width'], onesyStyle).value[0];
width = width !== undefined ? width : value_.value['width'] !== undefined ? value_.value['width'] : 0;
height = valueResolve(property, value_.value['height'], onesyStyle).value[0];
height = height !== undefined ? height : value_.value['height'] !== undefined ? value_.value['height'] : 0;
value.value = [[width, height].filter(item => item !== undefined).join(' ')];
break;
case 'border-bottom-left-radius':
case 'border-bottom-right-radius':
case 'border-top-left-radius':
case 'border-top-right-radius':
case 'border-end-end-radius':
case 'border-end-start-radius':
case 'border-start-end-radius':
case 'border-start-start-radius':
horizontal = valueResolve('border-radius', value_.value['horizontal'], onesyStyle).value[0];
horizontal = horizontal !== undefined ? horizontal : value_.value['horizontal'] !== undefined ? value_.value['horizontal'] : 0;
vertical = valueResolve('border-radius', value_.value['vertical'], onesyStyle).value[0];
vertical = vertical !== undefined ? vertical : value_.value['vertical'] !== undefined ? value_.value['vertical'] : 0;
value.value = [[horizontal, vertical].filter(item => item !== undefined).join(' ')];
break;
case 'border-image':
width = valueResolve('border-image-width', value_.value['width'], onesyStyle).value[0];
width = width !== undefined ? width : value_.value['width'];
let outset = valueResolve('border-image-outset', value_.value['outset'], onesyStyle).value[0];
outset = outset !== undefined ? outset : value_.value['outset'];
const slice = value_.value['slice'];
const widthAndSlice = width && slice ? "".concat(slice, " / ").concat(width) : width ? width : slice;
value.value = [[value_.value['source'], widthAndSlice, outset, value_.value['repeat']].filter(item => item !== undefined).join(' ')];
break;
case 'border-radius':
let topLeft = valueResolve('border-top-left-radius', value_.value['top-left'] !== undefined ? value_.value['top-left'] : value_.value['topLeft'], onesyStyle).value[0];
topLeft = topLeft !== undefined ? topLeft : value_.value['top-left'] !== undefined ? value_.value['top-left'] : value_.value['topLeft'] || 0;
let topRight = valueResolve('border-top-right-radius', value_.value['top-right'] !== undefined ? value_.value['top-right'] : value_.value['topRight'], onesyStyle).value[0];
topRight = topRight !== undefined ? topRight : value_.value['top-right'] !== undefined ? value_.value['top-right'] : value_.value['topRight'] || 0;
let bottomRight = valueResolve('border-bottom-right-radius', value_.value['bottom-right'] !== undefined ? value_.value['bottom-right'] : value_.value['bottomRight'], onesyStyle).value[0];
bottomRight = bottomRight !== undefined ? bottomRight : value_.value['bottom-right'] !== undefined ? value_.value['bottom-right'] : value_.value['bottomRight'] || 0;
let bottomLeft = valueResolve('border-bottom-left-radius', value_.value['bottom-left'] !== undefined ? value_.value['bottom-left'] : value_.value['bottomLeft'], onesyStyle).value[0];
bottomLeft = bottomLeft !== undefined ? bottomLeft : value_.value['bottom-left'] !== undefined ? value_.value['bottom-left'] : value_.value['bottomLeft'] || 0;
value.value = [[topLeft, topRight, bottomRight, bottomLeft].filter(item => item !== undefined).join(' ')];
break;
case 'border-style':
top = value_.value['top'] !== undefined ? value_.value['top'] : 'transparent';
right = value_.value['right'] !== undefined ? value_.value['right'] : 'transparent';
bottom = value_.value['bottom'] !== undefined ? value_.value['bottom'] : 'transparent';
left = value_.value['left'] !== undefined ? value_.value['left'] : 'transparent';
value.value = [[top, right, bottom, left].filter(item => item !== undefined).join(' ')];
break;
case 'columns':
width = valueResolve('column-width', value_.value['width'], onesyStyle).value[0];
width = width !== undefined ? width : value_.value['width'];
value.value = [[width, value_.value['count']].filter(item => item !== undefined).join(' ')];
break;
case 'flex':
let basis = valueResolve('flex-basis', value_.value['basis'], onesyStyle).value[0];
basis = basis !== undefined ? basis : value_.value['basis'];
value.value = [[value_.value['grow'], value_.value['shrink'], basis].filter(item => item !== undefined).join(' ')];
break;
case 'flex-flow':
value.value = [[value_.value['direction'], value_.value['wrap']].filter(item => item !== undefined).join(' ')];
break;
case 'gap':
let row = valueResolve('gap', value_.value['row'], onesyStyle).value[0];
row = row !== undefined ? row : value_.value['row'];
let column = valueResolve('gap', value_.value['column'], onesyStyle).value[0];
column = column !== undefined ? column : value_.value['column'];
value.value = [[row, column].filter(item => item !== undefined).join(' ')];
break;
case 'grid':
let autoRows = valueResolve('grid-auto-rows', value_.value['autoRows'] !== undefined ? value_.value['autoRows'] : value_.value['auto-rows'], onesyStyle).value[0];
autoRows = autoRows !== undefined ? autoRows : value_.value['autoRows'] !== undefined ? value_.value['autoRows'] : value_.value['auto-rows'];
let autoColumns = valueResolve('grid-auto-columns', value_.value['autoColumns'] !== undefined ? value_.value['autoColumns'] : value_.value['auto-columns'], onesyStyle).value[0];
autoColumns = autoColumns !== undefined ? autoColumns : value_.value['autoColumns'] !== undefined ? value_.value['autoColumns'] : value_.value['auto-columns'];
templateRows = valueResolve('grid-template-rows', value_.value['templateRows'] !== undefined ? value_.value['templateRows'] : value_.value['template-rows'], onesyStyle).value[0];
templateRows = templateRows !== undefined ? templateRows : value_.value['templateRows'] !== undefined ? value_.value['templateRows'] : value_.value['template-rows'];
templateColumns = valueResolve('grid-template-rows', value_.value['templateColumns'] !== undefined ? value_.value['templateColumns'] : value_.value['template-columns'], onesyStyle).value[0];
templateColumns = templateColumns !== undefined ? templateColumns : value_.value['templateColumns'] !== undefined ? value_.value['templateColumns'] : value_.value['template-columns'];
if (templateRows) {
value.value = [[templateRows, '/', value_.value['auto-flow'] !== undefined ? value_.value['auto-flow'] : value_.value['autoFlow'], autoColumns].filter(item => item !== undefined).join(' ')];
} else {
value.value = [[value_.value['auto-flow'] !== undefined ? value_.value['auto-flow'] : value_.value['autoFlow'], autoRows, '/', templateColumns].filter(item => item !== undefined).join(' ')];
}
break;
case 'grid-area':
value.value = [[(value_.value['row-start'] !== undefined ? value_.value['row-start'] : value_.value['rowStart']) || 0, '/', (value_.value['column-start'] !== undefined ? value_.value['column-start'] : value_.value['columnStart']) || 0, '/', (value_.value['row-end'] !== undefined ? value_.value['row-end'] : value_.value['rowEnd']) || 0, '/', (value_.value['column-end'] !== undefined ? value_.value['column-end'] : value_.value['columnEnd']) || 0].filter(item => item !== undefined).join(' ')];
break;
case 'grid-column':
case 'grid-row':
value.value = [[value_.value['end'] || 0, '/', value_.value['start'] || 0].filter(item => item !== undefined).join(' ')];
break;
case 'grid-template':
templateRows = valueResolve('grid-template-rows', value_.value['rows'], onesyStyle).value[0];
templateRows = templateRows !== undefined ? templateRows : value_.value['rows'];
templateColumns = valueResolve('grid-template-columns', value_.value['columns'], onesyStyle).value[0];
templateColumns = templateColumns !== undefined ? templateColumns : value_.value['columns'];
value.value = [[value_.value['areas'], templateRows, '/', templateColumns].filter(item => item !== undefined).join(' ')];
break;
case 'list-style':
value.value = [[value_.value['type'], value_.value['image'], value_.value['position']].filter(item => item !== undefined).join(' ')];
break;
case 'mask':
value.value = [[value_.value['image'], value_.value['mode'], value_.value['repeat'], value_.value['position'], value_.value['clip'], value_.value['origin'], value_.value['size'], value_.value['composite']].filter(item => item !== undefined).join(' ')];
break;
case 'offset':
let anchor = valueResolve('offset-anchor', value_.value['anchor'], onesyStyle).value[0];
anchor = anchor !== undefined ? anchor : value_.value['anchor'];
let distance = valueResolve('offset-distance', value_.value['distance'], onesyStyle).value[0];
distance = distance !== undefined ? distance : value_.value['distance'];
let rotate = valueResolve('offset-rotate', value_.value['rotate'], onesyStyle).value[0];
rotate = rotate !== undefined ? rotate : value_.value['rotate'];
position = valueResolve('offset-position', value_.value['position'], onesyStyle).value[0];
position = position !== undefined ? position : value_.value['position'];
value.value = [[value_.value['path'], distance, rotate, '/', position, anchor].filter(item => item !== undefined).join(' ')];
break;
case 'place-items':
case 'place-self':
case 'place-content':
value.value = [[value_.value['align'], value_.value['justify']].filter(item => item !== undefined).join(' ')];
break;
case 'text-decoration':
let thickness = valueResolve('text-decoration-thickness', value_.value['thickness'], onesyStyle).value[0];
thickness = thickness !== undefined ? thickness : value_.value['thickness'];
value.value = [[value_.value['line'], value_.value['style'], value_.value['color'], thickness].filter(item => item !== undefined).join(' ')];
break;
case 'text-emphasis':
value.value = [[value_.value['style'], value_.value['color']].filter(item => item !== undefined).join(' ')];
break;
case 'transition':
duration = valueResolve('transition-duration', value_.value['duration'], onesyStyle).value[0];
duration = duration !== undefined ? duration : value_.value['duration'];
delay = valueResolve('transition-delay', value_.value['delay'], onesyStyle).value[0] || value_.value['delay'];
delay = delay !== undefined ? delay : value_.value['delay'];
easingFunction = value_.value['easing-function'] || value_.value['easingFunction'];
easingFunction = easingFunction !== undefined ? easingFunction : value_.value['easingFunction'];
value.value = [[value_.value['name'], duration, easingFunction, delay].filter(item => item !== undefined).join(' ')];
break;
}
}
return value;
}; // Add method to subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.rule.value.subscribe(method);
}
const remove = () => {
// Remove method from subscriptions
if (onesyStyle) {
onesyStyle.subscriptions.rule.value.unsubscribe(method);
}
};
const response = {
methods: {
method
},
remove
};
return response;
}
const StyleContext = /*#__PURE__*/React__default["default"].createContext(new OnesyStyle$1());
var StyleContext$1 = StyleContext;
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
function _objectWithoutPropertiesLoose(r, e) {
if (null == r) return {};
var t = {};
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
if (-1 !== e.indexOf(n)) continue;
t[n] = r[n];
}
return t;
}
function _objectWithoutProperties(e, t) {
if (null == e) return {};
var o,
r,
i = _objectWithoutPropertiesLoose(e, t);
if (Object.getOwnPropertySymbols) {
var n = Object.getOwnPropertySymbols(e);
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
}
return i;
}
const _excluded$2 = ["root", "remove", "value", "children"];
function makeOnesyStyle(element) {
const onesyStyle = new OnesyStyle$1({
element
});
// Add all the plugins
onesyStyle.plugins.add = [unit, makeClassName, prefix, sort, rtl, valueObject];
return onesyStyle;
}
const Style = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
const {
root = false,
remove,
value: value_,
children
} = props,
other = _objectWithoutProperties(props, _excluded$2);
const refs = {
root: React__default["default"].useRef(undefined)
};
const [value, setValue] = React__default["default"].useState(() => {
if (value_ === undefined || !(value_ instanceof OnesyStyle$1)) return makeOnesyStyle();
value_.remove = remove;
return value_;
});
React__default["default"].useEffect(() => {
if (refs.root.current) {
value.element = refs.root.current;
value.remove = remove;
// Init
value.init();
const valueNew = new OnesyStyle$1();
// Copy over from value
Object.keys(value).forEach(prop => valueNew[prop] = value[prop]);
setValue(valueNew);
}
}, []);
const update = updateValue => {
if (updateValue !== undefined) {
const valueNew = new OnesyStyle$1();
valueNew.remove = remove;
Object.keys(value).forEach(prop => valueNew[prop] = value[prop]);
is$2('object', updateValue) && Object.keys(updateValue).forEach(prop => valueNew[prop] = updateValue[prop]);
setValue(valueNew);
return valueNew;
}
};
// Update method
value.updateWithRerender = update;
if (root) return /*#__PURE__*/React__default["default"].createElement(StyleContext$1.Provider, {
value: value
}, /*#__PURE__*/React__default["default"].createElement("div", _extends({
ref: item => {
refs.root.current = item;
if (ref?.current) ref.current = item;
}
}, other), children));
return /*#__PURE__*/React__default["default"].createElement(StyleContext$1.Provider, {
value: value
}, children);
});
var Style$1 = Style;
function useOnesyStyle() {
const value = React__default["default"].useContext(StyleContext$1);
return value;
}
const ThemeContext = /*#__PURE__*/React__default["default"].createContext(new OnesyTheme$1());
var ThemeContext$1 = ThemeContext;
function useOnesyTheme() {
const value = React__default["default"].useContext(ThemeContext$1);
return value;
}
const _excluded$1 = ["root", "value", "addCssVariables", "children"];
const l = value => value;
const hashValue = value => {
const allowed = ['direction', 'preference', 'mode', 'palette', 'shape', 'breakpoints', 'space', 'shadows', 'typography', 'transitions', 'z_index'];
const valueNew = {};
Object.keys(value).filter(item => allowed.includes(item)).forEach(item => valueNew[item] = value[item]);
return _default$e(valueNew);
};
const resolveValue = value => {
const notAllowed = ['subscriptions', 'id', 'element', 'updateWithRerender'];
const valueNew = {};
Object.keys(value).filter(item => !notAllowed.includes(item)).forEach(item => valueNew[item] = value[item]);
return valueNew;
};
const Theme = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
const [init, setInit] = React__default["default"].useState(false);
const {
root = false,
value: valueLocal = {},
addCssVariables = true,
children
} = props,
other = _objectWithoutProperties(props, _excluded$1);
const refs = {
root: React__default["default"].useRef(undefined),
init: React__default["default"].useRef(undefined),
id: React__default["default"].useId(),
styleSheet: React__default["default"].useRef(undefined)
};
refs.init.current = init;
const valueParent = useOnesyTheme() || {};
const [value, setValue] = React__default["default"].useState(() => new OnesyTheme$1(_default$f(resolveValue(is$2('function', valueLocal) ? valueLocal(valueParent) : valueLocal), resolveValue(valueParent), {
copy: true
})));
const addCssVariablesMethod = React__default["default"].useCallback(() => {
if (!refs.styleSheet.current) {
refs.styleSheet.current = window.document.createElement('style');
refs.styleSheet.current.setAttribute('data-onesy', 'true');
refs.styleSheet.current.setAttribute('data-version', 'static');
refs.styleSheet.current.setAttribute('data-name', 'vars');
window.document.head.append(refs.styleSheet.current);
}
const values = [];
const prefix = 'onesy';
// Palette
// Color
Object.keys(value.palette.color).forEach(item => {
Object.keys(value.palette.color[item]).forEach(itemValue => {
values.push(`--${prefix}-palette-color-${item}-${itemValue}: ${value.palette.color[item][itemValue]}`);
});
});
// Text
Object.keys(value.palette.text).filter(item => !['active', 'divider', 'disabled', 'hover', 'focus', 'selected'].includes(item)).forEach(item => {
Object.keys(value.palette.text[item]).forEach(itemValue => {
values.push(`--${prefix}-palette-text-${item}-${itemValue}: ${value.palette.text[item][itemValue]}`);
});
});
Object.keys(value.palette.text).filter(item => ['active', 'divider', 'disabled', 'hover', 'focus', 'selected'].includes(item)).forEach(item => {
values.push(`--${prefix}-palette-text-${item}: ${value.palette.text[item]}`);
});
// Background
Object.keys(value.palette.background).forEach(item => {
Object.keys(value.palette.background[item]).forEach(itemValue => {
values.push(`--${prefix}-palette-background-${item}-${itemValue}: ${value.palette.background[item][itemValue]}`);
});
});
// Visual contrast
Object.keys(value.palette.visual_contrast).forEach(item => {
Object.keys(value.palette.visual_contrast[item].opacity).forEach(itemValue => {
values.push(`--${prefix}-palette-visual-contrast-${item}-opacity-${itemValue}: ${value.palette.visual_contrast[item].opacity[itemValue]}`);
});
});
// Shape
values.push(`--${prefix}-shape-radius-unit: ${value.shape.radius.unit}`);
Object.keys(value.shape.radius.values).forEach(item => {
values.push(`--${prefix}-shape-radius-values-${item}: ${value.shape.radius.values[item]}`);
});
// Space
values.push(`--${prefix}-space-unit: ${value.space.unit}`);
Object.keys(value.space.values).forEach(item => {
values.push(`--${prefix}-space-values-${item}: ${value.space.values[item]}`);
});
// Shadows
Object.keys(value.shadows.values).forEach(item => {
Object.keys(value.shadows.values[item]).forEach(itemValue => {
values.push(`--${prefix}-shadows-${item}-${itemValue}: ${value.shadows.values[item][itemValue]}`);
});
});
// Typography
Object.keys(value.typography.font_family).forEach(item => values.push(`--${prefix}-typography-font-family-${item}: ${value.typography.font_family[item]}`));
values.push(`--${prefix}-typography-font-size-html: ${value.typography.font_size.html}`);
values.push(`--${prefix}-typography-unit: ${value.typography.unit}`);
// Transitions
Object.keys(value.transitions.duration).forEach(item => values.push(`--${prefix}-transitions-duration-${item}: ${value.transitions.duration[item]}`));
Object.keys(value.transitions.timing_function).forEach(item => values.push(`--${prefix}-transitions-timing-function-${item}: ${value.transitions.timing_function[item]}`));
// zIndex
Object.keys(value.z_index).forEach(item => values.push(`--${prefix}-z-index-${item}: ${value.z_index[item]}`));
// Add to styleSheet innerHTML
refs.styleSheet.current.innerHTML = `
${refs.root.current ? `#${refs.id}` : ':root'} {
${values.map(item => `\t${item};`).join('\n')}
}
`;
}, [value]);
React__default["default"].useEffect(() => {
if (refs.root.current) {
const onesyTheme = new OnesyTheme$1(value, {
element: refs.root.current
});
onesyTheme.id = value.id;
onesyTheme.subscriptions = value.subscriptions;
// Init
setValue(onesyTheme);
}
setInit(true);
}, []);
React__default["default"].useEffect(() => {
addCssVariablesMethod();
}, [refs.root.current, valueParent, value]);
React__default["default"].useEffect(() => {
if (init) {
value.update(_default$f(resolveValue(is$2('function', valueLocal) ? valueLocal(valueParent) : valueLocal), resolveValue(valueParent), {
copy: true
}));
const onesyTheme = new OnesyTheme$1(value, {
element: refs.root?.current
});
onesyTheme.id = value.id;
onesyTheme.subscriptions = value.subscriptions;
setValue(onesyTheme);
}
}, [hashValue(valueLocal), valueParent?.palette?.light]);
const update = updateValue => {
if (updateValue !== undefined) {
// Update
value.update(updateValue);
const onesyTheme = new OnesyTheme$1(value, {
element: refs.root?.current || _default$h('browser') && window.document.body
});
onesyTheme.id = value.id;
onesyTheme.subscriptions = value.subscriptions;
// Init
setValue(onesyTheme);
return value;
}
};
// Update method
value.updateWithRerender = update;
// locale method
value.l = value.l || l;
if (root) {
return /*#__PURE__*/React__default["default"].createElement(ThemeContext$1.Provider, {
value: value
}, /*#__PURE__*/React__default["default"].createElement("div", _extends({
ref: item => {
refs.root.current = item;
if (ref?.current) ref.current = item;
}
}, other, {
id: refs.id,
className: classNames(other?.className)
}), children));
}
return /*#__PURE__*/React__default["default"].createElement(ThemeContext$1.Provider, {
value: value
}, children);
});
var Theme$1 = Theme;
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
const propsAreNew = props => props && Object.keys(props).reduce((result, item) => result += item + String(props[item]), '');
function style(value) {
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let responses_ = arguments.length > 2 ? arguments[2] : undefined;
const responses = responses_ || [];
const {
name,
remove
} = options_;
function useStyle(props_) {
const onesyStyle = useOnesyStyle();
const onesyTheme = useOnesyTheme();
const refs = {
update: React__default["default"].useRef(undefined),
remove: React__default["default"].useRef(remove),
onesyStyle: React__default["default"].useRef(onesyStyle),
onesyTheme: React__default["default"].useRef(onesyTheme)
};
refs.onesyStyle.current = onesyStyle;
refs.onesyTheme.current = onesyTheme;
const resolve = function () {
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : onesyTheme;
let valueNew = value;
if (is$2('function', value)) valueNew = value(theme);
// Add style add & overrides
if (onesyTheme.ui?.elements?.[name]?.style) {
const {
add,
override
} = onesyTheme.ui.elements[name].style;
// Add
if (add) {
const object = is$2('function', add) ? add(theme) : add;
valueNew = _default$f(object, valueNew, {
copy: true
});
}
// Override
if (override) {
const object = is$2('function', override) ? override(theme) : override;
valueNew = _objectSpread$2(_objectSpread$2({}, valueNew), object);
}
}
return valueNew;
};
// Updates for onesyTheme
const method = React__default["default"].useCallback((updateValue, updatedTheme) => {
if (is$2('function', value)) {
const valueNew = resolve(updatedTheme);
// Update
if (response?.update !== undefined) response.update(valueNew);
}
}, []);
const makeResponse = () => {
// Object
let response_ = is$2('object', value) && responses[0];
if (response_) return response_;
// Method
// If it's a new instance of onesyTheme
// make a new responses with it
response_ = responses.find(item => item.onesyTheme.id === onesyTheme.id);
if (response_) return response_;
// If there's not add a new response and use it
const options = {
onesy_style: {
value: undefined
},
onesy_theme: {
value: undefined
}
};
// OnesyStyle
if (onesyStyle !== undefined) options.onesy_style.value = onesyStyle;
// OnesyTheme
if (onesyTheme !== undefined) options.onesy_theme.value = onesyTheme;
response_ = style$1(resolve(), _default$f(options, options_, {
copy: true
}));
// Add the onesyTheme to the response_
response_.onesyTheme = onesyTheme;
// Add value to the responses
responses.push(response_);
// Update
if (onesyTheme) onesyTheme.subscriptions.update.subscribe(method);
return response_;
};
const response = React__default["default"].useState(makeResponse())[0];
let props = props_;
if (is$2('object', props)) {
const newProps = {};
const allowed = Object.keys(props).filter(prop => is$2('array', props[prop]) ? !props[prop].some(item => /*#__PURE__*/React__default["default"].isValidElement(item)) : ! /*#__PURE__*/React__default["default"].isValidElement(props[prop]));
allowed.forEach(prop => newProps[prop] = props[prop]);
props = newProps;
}
const [values, setValues] = React__default["default"].useState(() => response.add(props));
// Add
React__default["default"].useEffect(() => {
if (!values || ['refresh'].includes(refs.update.current)) setValues(() => {
refs.update.current = undefined;
return response.add(props);
});
// Clean up
return () => {
// If in the iframe
// don't remove the elements by default
const toRemove = refs.remove.current !== undefined ? refs.remove.current : refs.onesyStyle.current.remove !== undefined ? refs.onesyStyle.current.remove : true;
// Remove
if (toRemove) response?.remove(values?.ids?.dynamic);
// Refresh
refs.update.current = 'refresh';
// Remove response from the responses
// if users is 0 in onesyStyleSheetManager
if (toRemove && !response?.onesy_style_sheet_manager?.users) {
const index = responses.findIndex(item => item.onesyTheme.id === onesyTheme.id);
if (index > -1) {
responses.splice(index, 1);
// Unsubscribe
if (onesyTheme) onesyTheme.subscriptions.update.unsubscribe(method);
}
}
};
}, []);
// Update props
React__default["default"].useEffect(() => {
if (response !== undefined && values?.ids) response.props = {
ids: values.ids.dynamic,
props
};
// Only 1 lvl of values
}, [propsAreNew(props)]);
return values;
}
return useStyle;
}
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function reset() {
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const responses = [];
const {
name = 'Reset'
} = options_;
function useReset(props_) {
const onesyStyle = useOnesyStyle();
const onesyTheme = useOnesyTheme();
const refs = {
update: React__default["default"].useRef(undefined)
};
const resolve = function () {
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : onesyTheme;
let valueNew = value;
if (is$2('function', value)) valueNew = value(theme);
// Add style add & overrides
if (onesyTheme.ui?.elements?.[name]?.style) {
const {
add,
override
} = onesyTheme.ui.elements[name].style;
// Add
if (add) {
const object = is$2('function', add) ? add(theme) : add;
valueNew = _default$f(object, valueNew, {
copy: true
});
}
// Override
if (override) {
const object = is$2('function', override) ? override(theme) : override;
valueNew = _objectSpread$1(_objectSpread$1({}, valueNew), object);
}
}
return valueNew;
};
// Updates for onesyTheme
const method = React__default["default"].useCallback((updateValue, updatedTheme) => {
if (is$2('function', value)) {
const valueNew = resolve(updatedTheme);
// Update
if (response?.update !== undefined) response.update(valueNew);
}
}, []);
const makeResponse = () => {
let response_;
// Method
// If it's a new instance of onesyTheme
// make a new responses with it
response_ = responses.find(item => item.onesyTheme.id === onesyTheme.id);
if (response_) return response_;
// If there's not add a new response and use it
const options = {
onesy_style: {
value: undefined
},
onesy_theme: {
value: undefined
}
};
// OnesyStyle
if (onesyStyle !== undefined) options.onesy_style.value = onesyStyle;
// OnesyTheme
if (onesyTheme !== undefined) options.onesy_theme.value = onesyTheme;
response_ = reset$1(resolve(), _default$f(options, options_, {
copy: true
}));
// Add the onesyTheme to the response_
response_.onesyTheme = onesyTheme;
// Add value to the responses
responses.push(response_);
// Update
if (onesyTheme) onesyTheme.subscriptions.update.subscribe(method);
return response_;
};
const response = React__default["default"].useState(makeResponse())[0];
let props = props_;
if (is$2('object', props)) {
const newProps = {};
const allowed = Object.keys(props).filter(prop => is$2('array', props[prop]) ? !props[prop].some(item => /*#__PURE__*/React__default["default"].isValidElement(item)) : ! /*#__PURE__*/React__default["default"].isValidElement(props[prop]));
allowed.forEach(prop => newProps[prop] = props[prop]);
props = newProps;
}
const [values, setValues] = React__default["default"].useState(() => response.add(props));
// Add
React__default["default"].useEffect(() => {
if (!values || ['refresh'].includes(refs.update.current)) setValues(() => {
refs.update.current = undefined;
return response.add(props);
});
// Clean up
return () => {
// Remove
response?.remove(values?.ids?.dynamic);
// Refresh
refs.update.current = 'refresh';
// Remove response from the responses
// if users is 0 in onesyStyleSheetManager
if (!response?.onesy_style_sheet_manager?.users) {
const index = responses.findIndex(item => item.onesyTheme.id === onesyTheme.id);
if (index > -1) {
responses.splice(index, 1);
// Unsubscribe
if (onesyTheme) onesyTheme.subscriptions.update.unsubscribe(method);
}
}
};
}, []);
// Update props
React__default["default"].useEffect(() => {
if (response !== undefined && values?.ids) response.props = {
ids: values.ids.dynamic,
props
};
// Only 1 lvl of values
}, [propsAreNew(props)]);
return values;
}
return useReset;
}
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function pure(value) {
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const responses = [];
const {
name
} = options_;
function usePure(props_) {
const onesyStyle = useOnesyStyle();
const onesyTheme = useOnesyTheme();
const refs = {
update: React__default["default"].useRef(undefined)
};
const resolve = function () {
let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : onesyTheme;
let valueNew = value;
if (is$2('function', value)) valueNew = value(theme);
// Add style add & overrides
if (onesyTheme.ui?.elements?.[name]?.style) {
const {
add,
override
} = onesyTheme.ui.elements[name].style;
// Add
if (add) {
const object = is$2('function', add) ? add(theme) : add;
valueNew = _default$f(object, valueNew, {
copy: true
});
}
// Override
if (override) {
const object = is$2('function', override) ? override(theme) : override;
valueNew = _objectSpread(_objectSpread({}, valueNew), object);
}
}
return valueNew;
};
// Updates for onesyTheme
const method = React__default["default"].useCallback((updateValue, updatedTheme) => {
if (is$2('function', value)) {
const valueNew = resolve(updatedTheme);
// Update
if (response?.update !== undefined) response.update(valueNew);
}
}, []);
const makeResponse = () => {
// Object
let response_ = is$2('object', value) && responses[0];
if (response_) return response_;
// Method
// If it's a new instance of onesyTheme
// make a new responses with it
response_ = responses.find(item => item.onesyTheme.id === onesyTheme.id);
if (response_) return response_;
// If there's not add a new response and use it
const options = {
onesy_style: {
value: undefined
},
onesy_theme: {
value: undefined
}
};
// OnesyStyle
if (onesyStyle !== undefined) options.onesy_style.value = onesyStyle;
// OnesyTheme
if (onesyTheme !== undefined) options.onesy_theme.value = onesyTheme;
response_ = pure$1(resolve(), _default$f(options, options_, {
copy: true
}));
// Add the onesyTheme to the response_
response_.onesyTheme = onesyTheme;
// Add value to the responses
responses.push(response_);
// Update
if (onesyTheme) onesyTheme.subscriptions.update.subscribe(method);
return response_;
};
const response = React__default["default"].useState(makeResponse())[0];
let props = props_;
if (is$2('object', props)) {
const newProps = {};
const allowed = Object.keys(props).filter(prop => is$2('array', props[prop]) ? !props[prop].some(item => /*#__PURE__*/React__default["default"].isValidElement(item)) : ! /*#__PURE__*/React__default["default"].isValidElement(props[prop]));
allowed.forEach(prop => newProps[prop] = props[prop]);
props = newProps;
}
const [values, setValues] = React__default["default"].useState(() => response.add(props));
// Add
React__default["default"].useEffect(() => {
if (!values || ['refresh'].includes(refs.update.current)) setValues(() => {
refs.update.current = undefined;
return response.add(props);
});
// Clean up
return () => {
// Remove
response?.remove(values?.ids?.dynamic);
// Refresh
refs.update.current = 'refresh';
// Remove response from the responses
// if users is 0 in onesyStyleSheetManager
if (!response?.onesy_style_sheet_manager?.users) {
const index = responses.findIndex(item => item.onesyTheme.id === onesyTheme.id);
if (index > -1) {
responses.splice(index, 1);
// Unsubscribe
if (onesyTheme) onesyTheme.subscriptions.update.unsubscribe(method);
}
}
};
}, []);
// Update props
React__default["default"].useEffect(() => {
if (response !== undefined && values?.ids) response.props = {
ids: values.ids.dynamic,
props
};
// Only 1 lvl of values
}, [propsAreNew(props)]);
return values;
}
return usePure;
}
function inline(value_, props) {
let options_ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
response: 'json'
};
const [value, setValue] = React__default["default"].useState(undefined);
const onesyStyle = useOnesyStyle();
const onesyTheme = useOnesyTheme();
const update = function () {
let update_ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
const options = _default$f(options_, {
onesy_style: {
value: onesyStyle
},
onesy_theme: {
value: onesyTheme
}
}, {
copy: true
});
// Options response value
options.response = 'json';
const valueNew = inline$1(value_, props, options);
if (update_) setValue(valueNew);
return valueNew;
};
// Update
React__default["default"].useEffect(() => {
update();
if (onesyTheme) onesyTheme.subscriptions.update.subscribe(update);
// Clean up
return () => {
// Unsubscribe
if (onesyTheme) onesyTheme.subscriptions.update.unsubscribe(update);
};
}, []);
// Update props
React__default["default"].useEffect(() => {
update();
}, [_default$e(props)]);
// Important for ssr value
const value__ = value || update(false);
return value__;
}
const optionsDefault$2 = {};
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
const isNodejs = !!(typeof global$1 !== 'undefined' && typeof module !== 'undefined' && module.exports); // Multiple is methods instead of one,
// so it's lighter for tree shaking usability reasons
function is(type, value) {
var _value$constructor;
let options_ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
const options = { ...optionsDefault$2,
...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 (value === null || value === void 0 ? void 0 : (_value$constructor = value.constructor) === null || _value$constructor === void 0 ? void 0 : _value$constructor.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;
}
}
const optionsDefault$1 = {
decode: false,
decodeMethod: decodeURIComponent
};
const castParam = function (value) {
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const options = { ...optionsDefault$1,
...options_
};
let newValue = value;
try {
if (is('string', value) && options.decode && is('function', options.decodeMethod)) newValue = options.decodeMethod(value);
} catch (error) {}
try {
if (is('string', newValue)) {
if ('undefined' === newValue) return undefined;
if ('NaN' === newValue) return NaN;
return JSON.parse(newValue);
}
return newValue;
} catch (error) {}
return newValue;
};
var castParam$1 = castParam;
const resolve = value => {
if (value === undefined) return 'undefined';
if (value instanceof Function || value instanceof Object) return value.toString();
return value;
};
const clean = value => {
if (is('string', value)) return value.replace(/(\s|\r|\n)+/, ' ');
return value;
};
const serializeValue = (value_, method) => {
let value = method(value_); // Ref circular value
if (value === undefined) return ''; // Is object-like make into an object
try {
if (is('object-like', value) && is('not-array-object', value) && value !== null) value = { ...value
};
} catch (error) {}
if (is('object', value)) return "{".concat(Object.keys(value).sort().map(key => "\"".concat(key, "\":").concat(serializeValue(value[key], method))).filter(item => item.slice(-1) !== ':').join(','), "}");
if (is('array', value)) return "[".concat(value.map(value__ => serializeValue(value__, method)).filter(Boolean).join(','), "]");
if (is('string', value)) return "\"".concat(value, "\"");
return clean(JSON.stringify(resolve(value)));
};
const serialize = value => {
const values = new WeakSet();
const getValue = value_ => {
if (typeof value_ === 'object' && value_ !== null) {
if (values.has(value_)) return;
values.add(value_);
}
return value_;
};
return serializeValue(value, getValue);
};
var serialize$1 = serialize;
const optionsDefault = {
serialize: true,
withPrefix: true
};
const hash = function (value_) {
let options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const options = { ...optionsDefault,
...options_
};
let value = value_;
if (options.serialize) value = serialize$1(value);
value = SHA256(value).toString();
return options.withPrefix ? "0x".concat(value) : value;
};
var hash$1 = hash;
// May be TValue or a string as a string value literal
const responses$1 = {};
function string(value_) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
const valueString = value_.reduce((result, item, index) => result += `${item}${args[index] || ''}`, '');
const valueStringMethod = () => {
const rule = {};
valueString.trim().split('\n').filter(Boolean).map(item => item.trim()).forEach(item => {
if (item) {
const items = item.split(':');
let value__ = items[1];
const property = items[0];
value__ = value__ && value__.trim().replace(';', '');
if (property && value__) rule[property] = castParam$1(value__, {
decode: false
});
}
});
return rule;
};
const value = {
a: valueStringMethod()
};
const name = React__default["default"].useMemo(() => hash$1(value.a), [value_]);
if (!responses$1[name]) responses$1[name] = [];
const useStyle = React__default["default"].useState(() => style(value, {
name
}, responses$1[name]))[0];
const values = useStyle();
// Update on value update
React__default["default"].useEffect(() => {
const response = responses$1[name][0];
if (response) response.update(value);
}, [valueString]);
return values.class || '';
}
// May be TValue or a string as a string value literal
const responses = {};
function className(value_) {
let props_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let className_ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
let options_ = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
if (!responses[options_.name]) responses[options_.name] = [];
const useStyle = React__default["default"].useState(() => style(value_, options_, responses[options_.name]))[0];
const values = useStyle(props_);
return values.class && classNames([className_, values.class]) || '';
}
const withStyle = Element => function (value) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// Name
options.name = options.name !== undefined ? options.name : `${Element?.displayName || Element?.type?.displayName || ''}WithStyle`;
// Use styles
const useStyle = style(value, options);
// Element
const element = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
const styles = useStyle(props);
return /*#__PURE__*/React__default["default"].createElement(Element, _extends({
ref: ref,
styles: styles
}, props));
});
return element;
};
var withStyle$1 = withStyle;
const _excluded = ["children", "className"];
const styled = Element => function (value) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// Name
options.name = options.name !== undefined ? options.name : `${Element?.displayName || Element?.type?.displayName || ''}Styled`;
// Use styles
const useStyle = style(value, options);
// Element
const element = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
const {
children,
className: classNameProp
} = props,
other = _objectWithoutProperties(props, _excluded);
const styles = useStyle(props);
return /*#__PURE__*/React__default["default"].createElement(Element, _extends({
ref: ref,
className: classNames([classNameProp, styles.class])
}, other), children);
});
return element;
};
var styled$1 = styled;
exports.OnesyStyle = OnesyStyle$1;
exports.OnesyTheme = OnesyTheme$1;
exports.Style = Style$1;
exports.StyleContext = StyleContext$1;
exports.Theme = Theme$1;
exports.ThemeContext = ThemeContext$1;
exports.c = className;
exports.className = className;
exports.classNames = classNames;
exports.colors = colors$1;
exports.cs = className;
exports.i = inline;
exports.inline = inline;
exports.makeClassName = makeClassName;
exports.p = pure;
exports.prefix = prefix;
exports.pure = pure;
exports.r = reset;
exports.reset = reset;
exports.rtl = rtl;
exports.s = style;
exports.sort = sort;
exports.sr = string;
exports.string = string;
exports.style = style;
exports.styled = styled$1;
exports.sy = styled$1;
exports.unit = unit;
exports.useOnesyStyle = useOnesyStyle;
exports.useOnesyTheme = useOnesyTheme;
exports.valueObject = valueObject;
exports.w = withStyle$1;
exports.withStyle = withStyle$1;
Object.defineProperty(exports, '__esModule', { value: true });
}));