stream-chat-react
Version:
React components to create chat conversations or livestream style chat
1,674 lines (1,628 loc) • 377 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all2) => {
for (var name2 in all2)
__defProp(target, name2, { get: all2[name2], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// node_modules/inline-style-parser/index.js
var require_inline_style_parser = __commonJS({
"node_modules/inline-style-parser/index.js"(exports, module2) {
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
var NEWLINE_REGEX = /\n/g;
var WHITESPACE_REGEX = /^\s*/;
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
var COLON_REGEX = /^:\s*/;
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
var SEMICOLON_REGEX = /^[;\s]*/;
var TRIM_REGEX = /^\s+|\s+$/g;
var NEWLINE = "\n";
var FORWARD_SLASH = "/";
var ASTERISK = "*";
var EMPTY_STRING = "";
var TYPE_COMMENT = "comment";
var TYPE_DECLARATION = "declaration";
module2.exports = function(style, options) {
if (typeof style !== "string") {
throw new TypeError("First argument must be a string");
}
if (!style) return [];
options = options || {};
var lineno = 1;
var column = 1;
function updatePosition(str) {
var lines = str.match(NEWLINE_REGEX);
if (lines) lineno += lines.length;
var i = str.lastIndexOf(NEWLINE);
column = ~i ? str.length - i : column + str.length;
}
function position4() {
var start2 = { line: lineno, column };
return function(node2) {
node2.position = new Position(start2);
whitespace2();
return node2;
};
}
function Position(start2) {
this.start = start2;
this.end = { line: lineno, column };
this.source = options.source;
}
Position.prototype.content = style;
var errorsList = [];
function error(msg) {
var err = new Error(
options.source + ":" + lineno + ":" + column + ": " + msg
);
err.reason = msg;
err.filename = options.source;
err.line = lineno;
err.column = column;
err.source = style;
if (options.silent) {
errorsList.push(err);
} else {
throw err;
}
}
function match(re2) {
var m = re2.exec(style);
if (!m) return;
var str = m[0];
updatePosition(str);
style = style.slice(str.length);
return m;
}
function whitespace2() {
match(WHITESPACE_REGEX);
}
function comments(rules) {
var c;
rules = rules || [];
while (c = comment()) {
if (c !== false) {
rules.push(c);
}
}
return rules;
}
function comment() {
var pos = position4();
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
var i = 2;
while (EMPTY_STRING != style.charAt(i) && (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))) {
++i;
}
i += 2;
if (EMPTY_STRING === style.charAt(i - 1)) {
return error("End of comment missing");
}
var str = style.slice(2, i - 2);
column += 2;
updatePosition(str);
style = style.slice(i);
column += 2;
return pos({
type: TYPE_COMMENT,
comment: str
});
}
function declaration() {
var pos = position4();
var prop = match(PROPERTY_REGEX);
if (!prop) return;
comment();
if (!match(COLON_REGEX)) return error("property missing ':'");
var val = match(VALUE_REGEX);
var ret = pos({
type: TYPE_DECLARATION,
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
value: val ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) : EMPTY_STRING
});
match(SEMICOLON_REGEX);
return ret;
}
function declarations() {
var decls = [];
comments(decls);
var decl;
while (decl = declaration()) {
if (decl !== false) {
decls.push(decl);
comments(decls);
}
}
return decls;
}
whitespace2();
return declarations();
};
function trim(str) {
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
}
}
});
// node_modules/style-to-object/cjs/index.js
var require_cjs = __commonJS({
"node_modules/style-to-object/cjs/index.js"(exports) {
"use strict";
var __importDefault = exports && exports.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = StyleToObject2;
var inline_style_parser_1 = __importDefault(require_inline_style_parser());
function StyleToObject2(style, iterator) {
var styleObject = null;
if (!style || typeof style !== "string") {
return styleObject;
}
var declarations = (0, inline_style_parser_1.default)(style);
var hasIterator = typeof iterator === "function";
declarations.forEach(function(declaration) {
if (declaration.type !== "declaration") {
return;
}
var property = declaration.property, value = declaration.value;
if (hasIterator) {
iterator(property, value, declaration);
} else if (value) {
styleObject = styleObject || {};
styleObject[property] = value;
}
});
return styleObject;
}
}
});
// node_modules/extend/index.js
var require_extend = __commonJS({
"node_modules/extend/index.js"(exports, module2) {
"use strict";
var hasOwn = Object.prototype.hasOwnProperty;
var toStr = Object.prototype.toString;
var defineProperty = Object.defineProperty;
var gOPD = Object.getOwnPropertyDescriptor;
var isArray = function isArray2(arr) {
if (typeof Array.isArray === "function") {
return Array.isArray(arr);
}
return toStr.call(arr) === "[object Array]";
};
var isPlainObject2 = function isPlainObject3(obj) {
if (!obj || toStr.call(obj) !== "[object Object]") {
return false;
}
var hasOwnConstructor = hasOwn.call(obj, "constructor");
var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, "isPrototypeOf");
if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
return false;
}
var key;
for (key in obj) {
}
return typeof key === "undefined" || hasOwn.call(obj, key);
};
var setProperty = function setProperty2(target, options) {
if (defineProperty && options.name === "__proto__") {
defineProperty(target, options.name, {
enumerable: true,
configurable: true,
value: options.newValue,
writable: true
});
} else {
target[options.name] = options.newValue;
}
};
var getProperty = function getProperty2(obj, name2) {
if (name2 === "__proto__") {
if (!hasOwn.call(obj, name2)) {
return void 0;
} else if (gOPD) {
return gOPD(obj, name2).value;
}
}
return obj[name2];
};
module2.exports = function extend2() {
var options, name2, src, copy, copyIsArray, clone;
var target = arguments[0];
var i = 1;
var length = arguments.length;
var deep = false;
if (typeof target === "boolean") {
deep = target;
target = arguments[1] || {};
i = 2;
}
if (target == null || typeof target !== "object" && typeof target !== "function") {
target = {};
}
for (; i < length; ++i) {
options = arguments[i];
if (options != null) {
for (name2 in options) {
src = getProperty(target, name2);
copy = getProperty(options, name2);
if (target !== copy) {
if (deep && copy && (isPlainObject2(copy) || (copyIsArray = isArray(copy)))) {
if (copyIsArray) {
copyIsArray = false;
clone = src && isArray(src) ? src : [];
} else {
clone = src && isPlainObject2(src) ? src : {};
}
setProperty(target, { name: name2, newValue: extend2(deep, clone, copy) });
} else if (typeof copy !== "undefined") {
setProperty(target, { name: name2, newValue: copy });
}
}
}
}
}
return target;
};
}
});
// src/experimental/index.ts
var experimental_exports = {};
__export(experimental_exports, {
ChannelSearchResultItem: () => ChannelSearchResultItem,
DefaultDropdownActionButton: () => DefaultDropdownActionButton,
DefaultSearchResultItems: () => DefaultSearchResultItems,
MessageActions: () => MessageActions,
MessageSearchResultItem: () => MessageSearchResultItem,
Search: () => Search,
SearchBar: () => SearchBar,
SearchContext: () => SearchContext,
SearchContextProvider: () => SearchContextProvider,
SearchResults: () => SearchResults,
SearchResultsHeader: () => SearchResultsHeader,
SearchResultsPresearch: () => SearchResultsPresearch,
SearchSourceResultList: () => SearchSourceResultList,
SearchSourceResultListFooter: () => SearchSourceResultListFooter,
SearchSourceResults: () => SearchSourceResults,
SearchSourceResultsContext: () => SearchSourceResultsContext,
SearchSourceResultsContextProvider: () => SearchSourceResultsContextProvider,
SearchSourceResultsEmpty: () => SearchSourceResultsEmpty,
SearchSourceResultsLoadingIndicator: () => SearchSourceResultsLoadingIndicator,
UserSearchResultItem: () => UserSearchResultItem,
defaultMessageActionSet: () => defaultMessageActionSet,
useBaseMessageActionSetFilter: () => useBaseMessageActionSetFilter,
useSearchContext: () => useSearchContext,
useSearchSourceResultsContext: () => useSearchSourceResultsContext,
useSplitMessageActionSet: () => useSplitMessageActionSet
});
module.exports = __toCommonJS(experimental_exports);
// src/experimental/MessageActions/MessageActions.tsx
var import_clsx8 = __toESM(require("clsx"));
var import_react37 = __toESM(require("react"));
// src/context/ChannelActionContext.tsx
var import_react = __toESM(require("react"));
var ChannelActionContext = import_react.default.createContext(void 0);
var useChannelActionContext = (componentName) => {
const contextValue = (0, import_react.useContext)(ChannelActionContext);
if (!contextValue) {
console.warn(
`The useChannelActionContext hook was called outside of the ChannelActionContext provider. Make sure this hook is called within a child of the Channel component. The errored call is located in the ${componentName} component.`
);
return {};
}
return contextValue;
};
// src/context/ChannelListContext.tsx
var import_react2 = __toESM(require("react"));
var ChannelListContext = (0, import_react2.createContext)(
void 0
);
var useChannelListContext = (componentName) => {
const contextValue = (0, import_react2.useContext)(ChannelListContext);
if (!contextValue) {
console.warn(
`The useChannelListContext hook was called outside of the ChannelListContext provider. Make sure this hook is called within the ChannelList component. The errored call is located in the ${componentName} component.`
);
return {};
}
return contextValue;
};
// src/context/ChannelStateContext.tsx
var import_react3 = __toESM(require("react"));
var ChannelStateContext = import_react3.default.createContext(void 0);
var useChannelStateContext = (componentName) => {
const contextValue = (0, import_react3.useContext)(ChannelStateContext);
if (!contextValue) {
console.warn(
`The useChannelStateContext hook was called outside of the ChannelStateContext provider. Make sure this hook is called within a child of the Channel component. The errored call is located in the ${componentName} component.`
);
return {};
}
return contextValue;
};
// src/context/ChatContext.tsx
var import_react4 = __toESM(require("react"));
var ChatContext = import_react4.default.createContext(void 0);
var useChatContext = (componentName) => {
const contextValue = (0, import_react4.useContext)(ChatContext);
if (!contextValue) {
console.warn(
`The useChatContext hook was called outside of the ChatContext provider. Make sure this hook is called within a child of the Chat component. The errored call is located in the ${componentName} component.`
);
return {};
}
return contextValue;
};
// src/context/ComponentContext.tsx
var import_react5 = __toESM(require("react"));
var ComponentContext = import_react5.default.createContext({});
var useComponentContext = (_componentName) => (0, import_react5.useContext)(ComponentContext);
// src/context/DialogManagerContext.tsx
var import_react10 = __toESM(require("react"));
// src/components/Dialog/DialogPortal.tsx
var import_react9 = __toESM(require("react"));
// src/components/Dialog/hooks/useDialog.ts
var import_react7 = require("react");
// src/store/hooks/useStateStore.ts
var import_react6 = require("react");
var import_shim = require("use-sync-external-store/shim");
var noop = () => {
};
function useStateStore(store, selector2) {
const wrappedSubscription = (0, import_react6.useCallback)(
(onStoreChange) => {
const unsubscribe = store?.subscribeWithSelector(selector2, onStoreChange);
return unsubscribe ?? noop;
},
[store, selector2]
);
const wrappedSnapshot = (0, import_react6.useMemo)(() => {
let cachedTuple;
return () => {
const currentValue = store?.getLatestValue();
if (!currentValue) return void 0;
if (cachedTuple && cachedTuple[0] === currentValue) {
return cachedTuple[1];
}
const newlySelected = selector2(currentValue);
if (cachedTuple) {
let selectededAreEqualToCached = true;
for (const key in cachedTuple[1]) {
if (cachedTuple[1][key] === newlySelected[key]) continue;
selectededAreEqualToCached = false;
break;
}
if (selectededAreEqualToCached) return cachedTuple[1];
}
cachedTuple = [currentValue, newlySelected];
return cachedTuple[1];
};
}, [store, selector2]);
const state = (0, import_shim.useSyncExternalStore)(wrappedSubscription, wrappedSnapshot);
return state;
}
// src/components/Dialog/hooks/useDialog.ts
var useDialog = ({ id }) => {
const { dialogManager } = useDialogManager();
(0, import_react7.useEffect)(
() => () => {
dialogManager.markForRemoval(id);
},
[dialogManager, id]
);
return dialogManager.getOrCreate({ id });
};
var useDialogIsOpen = (id) => {
const { dialogManager } = useDialogManager();
const dialogIsOpenSelector = (0, import_react7.useCallback)(
({ dialogsById }) => ({ isOpen: !!dialogsById[id]?.isOpen }),
[id]
);
return useStateStore(dialogManager.state, dialogIsOpenSelector).isOpen;
};
// src/components/Portal/Portal.ts
var import_react8 = require("react");
var import_react_dom = require("react-dom");
var Portal = ({
children,
getPortalDestination,
isOpen
}) => {
const [portalDestination, setPortalDestination] = (0, import_react8.useState)(null);
(0, import_react8.useLayoutEffect)(() => {
const destination = getPortalDestination();
if (!destination || !isOpen) return;
setPortalDestination(destination);
}, [getPortalDestination, isOpen]);
if (!portalDestination) return null;
return (0, import_react_dom.createPortal)(children, portalDestination);
};
// src/components/Dialog/DialogPortal.tsx
var DialogPortalEntry = ({
children,
dialogId
}) => {
const { dialogManager } = useDialogManager();
const dialogIsOpen = useDialogIsOpen(dialogId);
const getPortalDestination = (0, import_react9.useCallback)(
() => document.querySelector(`div[data-str-chat__portal-id="${dialogManager.id}"]`),
[dialogManager.id]
);
return /* @__PURE__ */ import_react9.default.createElement(Portal, { getPortalDestination, isOpen: dialogIsOpen }, children);
};
// src/context/DialogManagerContext.tsx
var DialogManagerProviderContext = import_react10.default.createContext(void 0);
var useDialogManager = () => {
const value = (0, import_react10.useContext)(DialogManagerProviderContext);
return value;
};
// src/context/MessageContext.tsx
var import_react11 = __toESM(require("react"));
var MessageContext = import_react11.default.createContext(
void 0
);
var useMessageContext = (_componentName) => {
const contextValue = (0, import_react11.useContext)(MessageContext);
if (!contextValue) {
return {};
}
return contextValue;
};
// src/constants/limits.ts
var DEFAULT_JUMP_TO_PAGE_SIZE = 100;
var DEFAULT_LOAD_PAGE_SCROLL_THRESHOLD = 250;
var DEFAULT_UPLOAD_SIZE_LIMIT_BYTES = 100 * 1024 * 1024;
// src/context/TranslationContext.tsx
var import_react12 = __toESM(require("react"));
var import_dayjs2 = __toESM(require("dayjs"));
var import_calendar = __toESM(require("dayjs/plugin/calendar"));
var import_localizedFormat = __toESM(require("dayjs/plugin/localizedFormat"));
// src/i18n/utils.ts
var import_dayjs = __toESM(require("dayjs"));
var defaultTranslatorFunction = (key) => key;
var defaultDateTimeParser = (input) => (0, import_dayjs.default)(input);
// src/context/TranslationContext.tsx
import_dayjs2.default.extend(import_calendar.default);
import_dayjs2.default.extend(import_localizedFormat.default);
var TranslationContext = import_react12.default.createContext({
t: defaultTranslatorFunction,
tDateTimeParser: defaultDateTimeParser,
userLanguage: "en"
});
var useTranslationContext = (componentName) => {
const contextValue = (0, import_react12.useContext)(TranslationContext);
if (!contextValue) {
console.warn(
`The useTranslationContext hook was called outside of the TranslationContext provider. Make sure this hook is called within a child of the Chat component. The errored call is located in the ${componentName} component.`
);
return {};
}
return contextValue;
};
// node_modules/unist-util-is/lib/index.js
var convert = (
// Note: overloads in JSDoc can’t yet use different `@template`s.
/**
* @type {(
* (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
* (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
* (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
* ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
* ((test?: Test) => Check)
* )}
*/
/**
* @param {Test} [test]
* @returns {Check}
*/
function(test) {
if (test === null || test === void 0) {
return ok;
}
if (typeof test === "function") {
return castFactory(test);
}
if (typeof test === "object") {
return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
}
if (typeof test === "string") {
return typeFactory(test);
}
throw new Error("Expected function, string, or object as test");
}
);
function anyFactory(tests) {
const checks2 = [];
let index3 = -1;
while (++index3 < tests.length) {
checks2[index3] = convert(tests[index3]);
}
return castFactory(any);
function any(...parameters) {
let index4 = -1;
while (++index4 < checks2.length) {
if (checks2[index4].apply(this, parameters)) return true;
}
return false;
}
}
function propsFactory(check) {
const checkAsRecord = (
/** @type {Record<string, unknown>} */
check
);
return castFactory(all2);
function all2(node2) {
const nodeAsRecord = (
/** @type {Record<string, unknown>} */
/** @type {unknown} */
node2
);
let key;
for (key in check) {
if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
}
return true;
}
}
function typeFactory(check) {
return castFactory(type);
function type(node2) {
return node2 && node2.type === check;
}
}
function castFactory(testFunction) {
return check;
function check(value, index3, parent) {
return Boolean(
looksLikeANode(value) && testFunction.call(
this,
value,
typeof index3 === "number" ? index3 : void 0,
parent || void 0
)
);
}
}
function ok() {
return true;
}
function looksLikeANode(value) {
return value !== null && typeof value === "object" && "type" in value;
}
// node_modules/unist-util-visit-parents/lib/color.js
function color(d) {
return d;
}
// node_modules/unist-util-visit-parents/lib/index.js
var empty = [];
var CONTINUE = true;
var EXIT = false;
var SKIP = "skip";
function visitParents(tree, test, visitor, reverse) {
let check;
if (typeof test === "function" && typeof visitor !== "function") {
reverse = visitor;
visitor = test;
} else {
check = test;
}
const is2 = convert(check);
const step = reverse ? -1 : 1;
factory(tree, void 0, [])();
function factory(node2, index3, parents) {
const value = (
/** @type {Record<string, unknown>} */
node2 && typeof node2 === "object" ? node2 : {}
);
if (typeof value.type === "string") {
const name2 = (
// `hast`
typeof value.tagName === "string" ? value.tagName : (
// `xast`
typeof value.name === "string" ? value.name : void 0
)
);
Object.defineProperty(visit2, "name", {
value: "node (" + color(node2.type + (name2 ? "<" + name2 + ">" : "")) + ")"
});
}
return visit2;
function visit2() {
let result = empty;
let subresult;
let offset;
let grandparents;
if (!test || is2(node2, index3, parents[parents.length - 1] || void 0)) {
result = toResult(visitor(node2, parents));
if (result[0] === EXIT) {
return result;
}
}
if ("children" in node2 && node2.children) {
const nodeAsParent = (
/** @type {UnistParent} */
node2
);
if (nodeAsParent.children && result[0] !== SKIP) {
offset = (reverse ? nodeAsParent.children.length : -1) + step;
grandparents = parents.concat(nodeAsParent);
while (offset > -1 && offset < nodeAsParent.children.length) {
const child = nodeAsParent.children[offset];
subresult = factory(child, offset, grandparents)();
if (subresult[0] === EXIT) {
return subresult;
}
offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
}
}
}
return result;
}
}
}
function toResult(value) {
if (Array.isArray(value)) {
return value;
}
if (typeof value === "number") {
return [CONTINUE, value];
}
return value === null || value === void 0 ? empty : [value];
}
// node_modules/unist-util-visit/lib/index.js
function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
let reverse;
let test;
let visitor;
if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
test = void 0;
visitor = testOrVisitor;
reverse = visitorOrReverse;
} else {
test = testOrVisitor;
visitor = visitorOrReverse;
reverse = maybeReverse;
}
visitParents(tree, test, overload, reverse);
function overload(node2, parents) {
const parent = parents[parents.length - 1];
const index3 = parent ? parent.children.indexOf(node2) : void 0;
return visitor(node2, index3, parent);
}
}
// node_modules/devlop/lib/default.js
function ok2() {
}
function unreachable() {
}
// node_modules/comma-separated-tokens/index.js
function stringify(values, options) {
const settings = options || {};
const input = values[values.length - 1] === "" ? [...values, ""] : values;
return input.join(
(settings.padRight ? " " : "") + "," + (settings.padLeft === false ? "" : " ")
).trim();
}
// node_modules/estree-util-is-identifier-name/lib/index.js
var nameRe = /^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u;
var nameReJsx = /^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u;
var emptyOptions = {};
function name(name2, options) {
const settings = options || emptyOptions;
const re2 = settings.jsx ? nameReJsx : nameRe;
return re2.test(name2);
}
// node_modules/hast-util-whitespace/lib/index.js
var re = /[ \t\n\f\r]/g;
function whitespace(thing) {
return typeof thing === "object" ? thing.type === "text" ? empty2(thing.value) : false : empty2(thing);
}
function empty2(value) {
return value.replace(re, "") === "";
}
// node_modules/property-information/lib/util/schema.js
var Schema = class {
/**
* @constructor
* @param {Properties} property
* @param {Normal} normal
* @param {string} [space]
*/
constructor(property, normal, space2) {
this.property = property;
this.normal = normal;
if (space2) {
this.space = space2;
}
}
};
Schema.prototype.property = {};
Schema.prototype.normal = {};
Schema.prototype.space = null;
// node_modules/property-information/lib/util/merge.js
function merge(definitions, space2) {
const property = {};
const normal = {};
let index3 = -1;
while (++index3 < definitions.length) {
Object.assign(property, definitions[index3].property);
Object.assign(normal, definitions[index3].normal);
}
return new Schema(property, normal, space2);
}
// node_modules/property-information/lib/normalize.js
function normalize(value) {
return value.toLowerCase();
}
// node_modules/property-information/lib/util/info.js
var Info = class {
/**
* @constructor
* @param {string} property
* @param {string} attribute
*/
constructor(property, attribute) {
this.property = property;
this.attribute = attribute;
}
};
Info.prototype.space = null;
Info.prototype.boolean = false;
Info.prototype.booleanish = false;
Info.prototype.overloadedBoolean = false;
Info.prototype.number = false;
Info.prototype.commaSeparated = false;
Info.prototype.spaceSeparated = false;
Info.prototype.commaOrSpaceSeparated = false;
Info.prototype.mustUseProperty = false;
Info.prototype.defined = false;
// node_modules/property-information/lib/util/types.js
var types_exports = {};
__export(types_exports, {
boolean: () => boolean,
booleanish: () => booleanish,
commaOrSpaceSeparated: () => commaOrSpaceSeparated,
commaSeparated: () => commaSeparated,
number: () => number,
overloadedBoolean: () => overloadedBoolean,
spaceSeparated: () => spaceSeparated
});
var powers = 0;
var boolean = increment();
var booleanish = increment();
var overloadedBoolean = increment();
var number = increment();
var spaceSeparated = increment();
var commaSeparated = increment();
var commaOrSpaceSeparated = increment();
function increment() {
return 2 ** ++powers;
}
// node_modules/property-information/lib/util/defined-info.js
var checks = Object.keys(types_exports);
var DefinedInfo = class extends Info {
/**
* @constructor
* @param {string} property
* @param {string} attribute
* @param {number|null} [mask]
* @param {string} [space]
*/
constructor(property, attribute, mask, space2) {
let index3 = -1;
super(property, attribute);
mark(this, "space", space2);
if (typeof mask === "number") {
while (++index3 < checks.length) {
const check = checks[index3];
mark(this, checks[index3], (mask & types_exports[check]) === types_exports[check]);
}
}
}
};
DefinedInfo.prototype.defined = true;
function mark(values, key, value) {
if (value) {
values[key] = value;
}
}
// node_modules/property-information/lib/util/create.js
var own = {}.hasOwnProperty;
function create(definition2) {
const property = {};
const normal = {};
let prop;
for (prop in definition2.properties) {
if (own.call(definition2.properties, prop)) {
const value = definition2.properties[prop];
const info = new DefinedInfo(
prop,
definition2.transform(definition2.attributes || {}, prop),
value,
definition2.space
);
if (definition2.mustUseProperty && definition2.mustUseProperty.includes(prop)) {
info.mustUseProperty = true;
}
property[prop] = info;
normal[normalize(prop)] = prop;
normal[normalize(info.attribute)] = prop;
}
}
return new Schema(property, normal, definition2.space);
}
// node_modules/property-information/lib/xlink.js
var xlink = create({
space: "xlink",
transform(_, prop) {
return "xlink:" + prop.slice(5).toLowerCase();
},
properties: {
xLinkActuate: null,
xLinkArcRole: null,
xLinkHref: null,
xLinkRole: null,
xLinkShow: null,
xLinkTitle: null,
xLinkType: null
}
});
// node_modules/property-information/lib/xml.js
var xml = create({
space: "xml",
transform(_, prop) {
return "xml:" + prop.slice(3).toLowerCase();
},
properties: { xmlLang: null, xmlBase: null, xmlSpace: null }
});
// node_modules/property-information/lib/util/case-sensitive-transform.js
function caseSensitiveTransform(attributes, attribute) {
return attribute in attributes ? attributes[attribute] : attribute;
}
// node_modules/property-information/lib/util/case-insensitive-transform.js
function caseInsensitiveTransform(attributes, property) {
return caseSensitiveTransform(attributes, property.toLowerCase());
}
// node_modules/property-information/lib/xmlns.js
var xmlns = create({
space: "xmlns",
attributes: { xmlnsxlink: "xmlns:xlink" },
transform: caseInsensitiveTransform,
properties: { xmlns: null, xmlnsXLink: null }
});
// node_modules/property-information/lib/aria.js
var aria = create({
transform(_, prop) {
return prop === "role" ? prop : "aria-" + prop.slice(4).toLowerCase();
},
properties: {
ariaActiveDescendant: null,
ariaAtomic: booleanish,
ariaAutoComplete: null,
ariaBusy: booleanish,
ariaChecked: booleanish,
ariaColCount: number,
ariaColIndex: number,
ariaColSpan: number,
ariaControls: spaceSeparated,
ariaCurrent: null,
ariaDescribedBy: spaceSeparated,
ariaDetails: null,
ariaDisabled: booleanish,
ariaDropEffect: spaceSeparated,
ariaErrorMessage: null,
ariaExpanded: booleanish,
ariaFlowTo: spaceSeparated,
ariaGrabbed: booleanish,
ariaHasPopup: null,
ariaHidden: booleanish,
ariaInvalid: null,
ariaKeyShortcuts: null,
ariaLabel: null,
ariaLabelledBy: spaceSeparated,
ariaLevel: number,
ariaLive: null,
ariaModal: booleanish,
ariaMultiLine: booleanish,
ariaMultiSelectable: booleanish,
ariaOrientation: null,
ariaOwns: spaceSeparated,
ariaPlaceholder: null,
ariaPosInSet: number,
ariaPressed: booleanish,
ariaReadOnly: booleanish,
ariaRelevant: null,
ariaRequired: booleanish,
ariaRoleDescription: spaceSeparated,
ariaRowCount: number,
ariaRowIndex: number,
ariaRowSpan: number,
ariaSelected: booleanish,
ariaSetSize: number,
ariaSort: null,
ariaValueMax: number,
ariaValueMin: number,
ariaValueNow: number,
ariaValueText: null,
role: null
}
});
// node_modules/property-information/lib/html.js
var html = create({
space: "html",
attributes: {
acceptcharset: "accept-charset",
classname: "class",
htmlfor: "for",
httpequiv: "http-equiv"
},
transform: caseInsensitiveTransform,
mustUseProperty: ["checked", "multiple", "muted", "selected"],
properties: {
// Standard Properties.
abbr: null,
accept: commaSeparated,
acceptCharset: spaceSeparated,
accessKey: spaceSeparated,
action: null,
allow: null,
allowFullScreen: boolean,
allowPaymentRequest: boolean,
allowUserMedia: boolean,
alt: null,
as: null,
async: boolean,
autoCapitalize: null,
autoComplete: spaceSeparated,
autoFocus: boolean,
autoPlay: boolean,
blocking: spaceSeparated,
capture: boolean,
charSet: null,
checked: boolean,
cite: null,
className: spaceSeparated,
cols: number,
colSpan: null,
content: null,
contentEditable: booleanish,
controls: boolean,
controlsList: spaceSeparated,
coords: number | commaSeparated,
crossOrigin: null,
data: null,
dateTime: null,
decoding: null,
default: boolean,
defer: boolean,
dir: null,
dirName: null,
disabled: boolean,
download: overloadedBoolean,
draggable: booleanish,
encType: null,
enterKeyHint: null,
fetchPriority: null,
form: null,
formAction: null,
formEncType: null,
formMethod: null,
formNoValidate: boolean,
formTarget: null,
headers: spaceSeparated,
height: number,
hidden: boolean,
high: number,
href: null,
hrefLang: null,
htmlFor: spaceSeparated,
httpEquiv: spaceSeparated,
id: null,
imageSizes: null,
imageSrcSet: null,
inert: boolean,
inputMode: null,
integrity: null,
is: null,
isMap: boolean,
itemId: null,
itemProp: spaceSeparated,
itemRef: spaceSeparated,
itemScope: boolean,
itemType: spaceSeparated,
kind: null,
label: null,
lang: null,
language: null,
list: null,
loading: null,
loop: boolean,
low: number,
manifest: null,
max: null,
maxLength: number,
media: null,
method: null,
min: null,
minLength: number,
multiple: boolean,
muted: boolean,
name: null,
nonce: null,
noModule: boolean,
noValidate: boolean,
onAbort: null,
onAfterPrint: null,
onAuxClick: null,
onBeforeMatch: null,
onBeforePrint: null,
onBeforeToggle: null,
onBeforeUnload: null,
onBlur: null,
onCancel: null,
onCanPlay: null,
onCanPlayThrough: null,
onChange: null,
onClick: null,
onClose: null,
onContextLost: null,
onContextMenu: null,
onContextRestored: null,
onCopy: null,
onCueChange: null,
onCut: null,
onDblClick: null,
onDrag: null,
onDragEnd: null,
onDragEnter: null,
onDragExit: null,
onDragLeave: null,
onDragOver: null,
onDragStart: null,
onDrop: null,
onDurationChange: null,
onEmptied: null,
onEnded: null,
onError: null,
onFocus: null,
onFormData: null,
onHashChange: null,
onInput: null,
onInvalid: null,
onKeyDown: null,
onKeyPress: null,
onKeyUp: null,
onLanguageChange: null,
onLoad: null,
onLoadedData: null,
onLoadedMetadata: null,
onLoadEnd: null,
onLoadStart: null,
onMessage: null,
onMessageError: null,
onMouseDown: null,
onMouseEnter: null,
onMouseLeave: null,
onMouseMove: null,
onMouseOut: null,
onMouseOver: null,
onMouseUp: null,
onOffline: null,
onOnline: null,
onPageHide: null,
onPageShow: null,
onPaste: null,
onPause: null,
onPlay: null,
onPlaying: null,
onPopState: null,
onProgress: null,
onRateChange: null,
onRejectionHandled: null,
onReset: null,
onResize: null,
onScroll: null,
onScrollEnd: null,
onSecurityPolicyViolation: null,
onSeeked: null,
onSeeking: null,
onSelect: null,
onSlotChange: null,
onStalled: null,
onStorage: null,
onSubmit: null,
onSuspend: null,
onTimeUpdate: null,
onToggle: null,
onUnhandledRejection: null,
onUnload: null,
onVolumeChange: null,
onWaiting: null,
onWheel: null,
open: boolean,
optimum: number,
pattern: null,
ping: spaceSeparated,
placeholder: null,
playsInline: boolean,
popover: null,
popoverTarget: null,
popoverTargetAction: null,
poster: null,
preload: null,
readOnly: boolean,
referrerPolicy: null,
rel: spaceSeparated,
required: boolean,
reversed: boolean,
rows: number,
rowSpan: number,
sandbox: spaceSeparated,
scope: null,
scoped: boolean,
seamless: boolean,
selected: boolean,
shadowRootDelegatesFocus: boolean,
shadowRootMode: null,
shape: null,
size: number,
sizes: null,
slot: null,
span: number,
spellCheck: booleanish,
src: null,
srcDoc: null,
srcLang: null,
srcSet: null,
start: number,
step: null,
style: null,
tabIndex: number,
target: null,
title: null,
translate: null,
type: null,
typeMustMatch: boolean,
useMap: null,
value: booleanish,
width: number,
wrap: null,
// Legacy.
// See: https://html.spec.whatwg.org/#other-elements,-attributes-and-apis
align: null,
// Several. Use CSS `text-align` instead,
aLink: null,
// `<body>`. Use CSS `a:active {color}` instead
archive: spaceSeparated,
// `<object>`. List of URIs to archives
axis: null,
// `<td>` and `<th>`. Use `scope` on `<th>`
background: null,
// `<body>`. Use CSS `background-image` instead
bgColor: null,
// `<body>` and table elements. Use CSS `background-color` instead
border: number,
// `<table>`. Use CSS `border-width` instead,
borderColor: null,
// `<table>`. Use CSS `border-color` instead,
bottomMargin: number,
// `<body>`
cellPadding: null,
// `<table>`
cellSpacing: null,
// `<table>`
char: null,
// Several table elements. When `align=char`, sets the character to align on
charOff: null,
// Several table elements. When `char`, offsets the alignment
classId: null,
// `<object>`
clear: null,
// `<br>`. Use CSS `clear` instead
code: null,
// `<object>`
codeBase: null,
// `<object>`
codeType: null,
// `<object>`
color: null,
// `<font>` and `<hr>`. Use CSS instead
compact: boolean,
// Lists. Use CSS to reduce space between items instead
declare: boolean,
// `<object>`
event: null,
// `<script>`
face: null,
// `<font>`. Use CSS instead
frame: null,
// `<table>`
frameBorder: null,
// `<iframe>`. Use CSS `border` instead
hSpace: number,
// `<img>` and `<object>`
leftMargin: number,
// `<body>`
link: null,
// `<body>`. Use CSS `a:link {color: *}` instead
longDesc: null,
// `<frame>`, `<iframe>`, and `<img>`. Use an `<a>`
lowSrc: null,
// `<img>`. Use a `<picture>`
marginHeight: number,
// `<body>`
marginWidth: number,
// `<body>`
noResize: boolean,
// `<frame>`
noHref: boolean,
// `<area>`. Use no href instead of an explicit `nohref`
noShade: boolean,
// `<hr>`. Use background-color and height instead of borders
noWrap: boolean,
// `<td>` and `<th>`
object: null,
// `<applet>`
profile: null,
// `<head>`
prompt: null,
// `<isindex>`
rev: null,
// `<link>`
rightMargin: number,
// `<body>`
rules: null,
// `<table>`
scheme: null,
// `<meta>`
scrolling: booleanish,
// `<frame>`. Use overflow in the child context
standby: null,
// `<object>`
summary: null,
// `<table>`
text: null,
// `<body>`. Use CSS `color` instead
topMargin: number,
// `<body>`
valueType: null,
// `<param>`
version: null,
// `<html>`. Use a doctype.
vAlign: null,
// Several. Use CSS `vertical-align` instead
vLink: null,
// `<body>`. Use CSS `a:visited {color}` instead
vSpace: number,
// `<img>` and `<object>`
// Non-standard Properties.
allowTransparency: null,
autoCorrect: null,
autoSave: null,
disablePictureInPicture: boolean,
disableRemotePlayback: boolean,
prefix: null,
property: null,
results: number,
security: null,
unselectable: null
}
});
// node_modules/property-information/lib/svg.js
var svg = create({
space: "svg",
attributes: {
accentHeight: "accent-height",
alignmentBaseline: "alignment-baseline",
arabicForm: "arabic-form",
baselineShift: "baseline-shift",
capHeight: "cap-height",
className: "class",
clipPath: "clip-path",
clipRule: "clip-rule",
colorInterpolation: "color-interpolation",
colorInterpolationFilters: "color-interpolation-filters",
colorProfile: "color-profile",
colorRendering: "color-rendering",
crossOrigin: "crossorigin",
dataType: "datatype",
dominantBaseline: "dominant-baseline",
enableBackground: "enable-background",
fillOpacity: "fill-opacity",
fillRule: "fill-rule",
floodColor: "flood-color",
floodOpacity: "flood-opacity",
fontFamily: "font-family",
fontSize: "font-size",
fontSizeAdjust: "font-size-adjust",
fontStretch: "font-stretch",
fontStyle: "font-style",
fontVariant: "font-variant",
fontWeight: "font-weight",
glyphName: "glyph-name",
glyphOrientationHorizontal: "glyph-orientation-horizontal",
glyphOrientationVertical: "glyph-orientation-vertical",
hrefLang: "hreflang",
horizAdvX: "horiz-adv-x",
horizOriginX: "horiz-origin-x",
horizOriginY: "horiz-origin-y",
imageRendering: "image-rendering",
letterSpacing: "letter-spacing",
lightingColor: "lighting-color",
markerEnd: "marker-end",
markerMid: "marker-mid",
markerStart: "marker-start",
navDown: "nav-down",
navDownLeft: "nav-down-left",
navDownRight: "nav-down-right",
navLeft: "nav-left",
navNext: "nav-next",
navPrev: "nav-prev",
navRight: "nav-right",
navUp: "nav-up",
navUpLeft: "nav-up-left",
navUpRight: "nav-up-right",
onAbort: "onabort",
onActivate: "onactivate",
onAfterPrint: "onafterprint",
onBeforePrint: "onbeforeprint",
onBegin: "onbegin",
onCancel: "oncancel",
onCanPlay: "oncanplay",
onCanPlayThrough: "oncanplaythrough",
onChange: "onchange",
onClick: "onclick",
onClose: "onclose",
onCopy: "oncopy",
onCueChange: "oncuechange",
onCut: "oncut",
onDblClick: "ondblclick",
onDrag: "ondrag",
onDragEnd: "ondragend",
onDragEnter: "ondragenter",
onDragExit: "ondragexit",
onDragLeave: "ondragleave",
onDragOver: "ondragover",
onDragStart: "ondragstart",
onDrop: "ondrop",
onDurationChange: "ondurationchange",
onEmptied: "onemptied",
onEnd: "onend",
onEnded: "onended",
onError: "onerror",
onFocus: "onfocus",
onFocusIn: "onfocusin",
onFocusOut: "onfocusout",
onHashChange: "onhashchange",
onInput: "oninput",
onInvalid: "oninvalid",
onKeyDown: "onkeydown",
onKeyPress: "onkeypress",
onKeyUp: "onkeyup",
onLoad: "onload",
onLoadedData: "onloadeddata",
onLoadedMetadata: "onloadedmetadata",
onLoadStart: "onloadstart",
onMessage: "onmessage",
onMouseDown: "onmousedown",
onMouseEnter: "onmouseenter",
onMouseLeave: "onmouseleave",
onMouseMove: "onmousemove",
onMouseOut: "onmouseout",
onMouseOver: "onmouseover",
onMouseUp: "onmouseup",
onMouseWheel: "onmousewheel",
onOffline: "onoffline",
onOnline: "ononline",
onPageHide: "onpagehide",
onPageShow: "onpageshow",
onPaste: "onpaste",
onPause: "onpause",
onPlay: "onplay",
onPlaying: "onplaying",
onPopState: "onpopstate",
onProgress: "onprogress",
onRateChange: "onratechange",
onRepeat: "onrepeat",
onReset: "onreset",
onResize: "onresize",
onScroll: "onscroll",
onSeeked: "onseeked",
onSeeking: "onseeking",
onSelect: "onselect",
onShow: "onshow",
onStalled: "onstalled",
onStorage: "onstorage",
onSubmit: "onsubmit",
onSuspend: "onsuspend",
onTimeUpdate: "ontimeupdate",
onToggle: "ontoggle",
onUnload: "onunload",
onVolumeChange: "onvolumechange",
onWaiting: "onwaiting",
onZoom: "onzoom",
overlinePosition: "overline-position",
overlineThickness: "overline-thickness",
paintOrder: "paint-order",
panose1: "panose-1",
pointerEvents: "pointer-events",
referrerPolicy: "referrerpolicy",
renderingIntent: "rendering-intent",
shapeRendering: "shape-rendering",
stopColor: "stop-color",
stopOpacity: "stop-opacity",
strikethroughPosition: "strikethrough-position",
strikethroughThickness: "strikethrough-thickness",
strokeDashArray: "stroke-dasharray",
strokeDashOffset: "stroke-dashoffset",
strokeLineCap: "stroke-linecap",
strokeLineJoin: "stroke-linejoin",
strokeMiterLimit: "stroke-miterlimit",
strokeOpacity: "stroke-opacity",
strokeWidth: "stroke-width",
tabIndex: "tabindex",
textAnchor: "text-anchor",
textDecoration: "text-decoration",
textRendering: "text-rendering",
transformOrigin: "transform-origin",
typeOf: "typeof",
underlinePosition: "underline-position",
underlineThickness: "underline-thickness",
unicodeBidi: "unicode-bidi",
unicodeRange: "unicode-range",
unitsPerEm: "units-per-em",
vAlphabetic: "v-alphabetic",
vHanging: "v-hanging",
vIdeographic: "v-ideographic",
vMathematical: "v-mathematical",
vectorEffect: "vector-effect",
vertAdvY: "vert-adv-y",
vertOriginX: "vert-origin-x",
vertOriginY: "vert-origin-y",
wordSpacing: "word-spacing",
writingMode: "writing-mode",
xHeight: "x-height",
// These were camelcased in Tiny. Now lowercased in SVG 2
playbackOrder: "playbackorder",
timelineBegin: "timelinebegin"
},
transform: caseSensitiveTransform,
properties: {
about: commaOrSpaceSeparated,
accentHeight: number,
accumulate: null,
additive: null,
alignmentBaseline: null,
alphabetic: number,
amplitude: number,
arabicForm: null,
ascent: number,
attributeName: null,
attributeType: null,
azimuth: number,
bandwidth: null,
baselineShift: null,
baseFrequency: null,
baseProfile: null,
bbox: null,
begin: null,
bias: number,
by: null,
calcMode: null,
capHeight: number,
className: spaceSeparated,
clip: null,
clipPath: null,
clipPathUnits: null,
clipRule: null,
color: null,
colorInterpolation: null,
colorInterpolationFilters: null,
colorProfile: null,
colorRendering: null,
content: null,
contentScriptType: null,
contentStyleType: null,
crossOrigin: null,
cursor: null,
cx: null,
cy: null,
d: null,
dataType: null,
defaultAction: null,
descent: number,
diffuseConstant: number,
direction: null,
display: null,
dur: null,
divisor: number,
dominantBaseline: null,
download: boolean,
dx: null,
dy: null,
edgeMode: null,
editable: null,
elevation: number,
enableBackground: null,
end: null,
event: null,
exponent: number,
externalResourcesRequired: null,
fill: null,
fillOpacity: number,
fillRule: null,
filter: null,
filterRes: null,
filterUnits: null,
floodColor: null,
floodOpacity: null,
focusable: null,
focusHighlight: null,
fontFamily: null,
fontSize: null,
fontSizeAdjust: null,
fontStretch: null,
fontStyle: null,
fontVariant: null,
fontWeight: null,
format: null,
fr: null,
from: null,
fx: null,
fy: null,
g1: commaSeparated,
g2: commaSeparated,
glyphName: commaSeparated,
glyphOrientationHorizontal: null,
glyphOrientationVertical: null,
glyphRef: null,
gradientTransform: null,
gradientUnits: null,
handler: null,
hanging: number,
hatchContentUnits: null,
hatchUnits: null,
height: null,
href: null,
hrefLang: null,
horizAdvX: number,
horizOriginX: number,
horizOriginY: number,
id: null,
ideographic: number,
imageRendering: null,
initialVisibility: null,
in: null,
in2: null,
intercept: number,
k: number,
k1: number,
k2: number,
k3: number,
k4: number,
kernelMatrix: commaOr