// ==UserScript==
// @name 复制html转markDown
// @namespace npm/vite-plugin-monkey
// @version 0.2.1
// @author monkey
// @description 复制html转markDown,只针对https://vue3js.cn/interview
// @icon https://ts1.cn.mm.bing.net/th?id=OIP-C.hpjQBHE4wfYFA1nm4KhTDwAAAA&w=173&h=185&c=8&rs=1&qlt=90&o=6&dpr=1.3&pid=3.1&rm=2
// @match https://vue3js.cn/interview/*
// @require https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.production.min.js
// @require https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.production.min.js
// ==/UserScript==
(function(React2, ReactDOM2) {
"use strict";
const _interopDefaultLegacy = (e2) => e2 && typeof e2 === "object" && "default" in e2 ? e2 : { default: e2 };
function _interopNamespace(e2) {
if (e2 && e2.__esModule)
return e2;
const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
if (e2) {
for (const k2 in e2) {
if (k2 !== "default") {
const d2 = Object.getOwnPropertyDescriptor(e2, k2);
Object.defineProperty(n2, k2, d2.get ? d2 : {
enumerable: true,
get: () => e2[k2]
});
}
}
}
n2.default = e2;
return Object.freeze(n2);
}
const React__default = /* @__PURE__ */ _interopDefaultLegacy(React2);
const React__namespace = /* @__PURE__ */ _interopNamespace(React2);
const ReactDOM__default = /* @__PURE__ */ _interopDefaultLegacy(ReactDOM2);
const ReactDOM__namespace = /* @__PURE__ */ _interopNamespace(ReactDOM2);
var client = {};
var m$2 = ReactDOM__default.default;
{
client.createRoot = m$2.createRoot;
client.hydrateRoot = m$2.hydrateRoot;
}
function extend(destination) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key2 in source) {
if (source.hasOwnProperty(key2))
destination[key2] = source[key2];
}
}
return destination;
}
function repeat(character, count) {
return Array(count + 1).join(character);
}
function trimLeadingNewlines(string2) {
return string2.replace(/^\n*/, "");
}
function trimTrailingNewlines(string2) {
var indexEnd = string2.length;
while (indexEnd > 0 && string2[indexEnd - 1] === "\n")
indexEnd--;
return string2.substring(0, indexEnd);
}
var blockElements = [
"ADDRESS",
"ARTICLE",
"ASIDE",
"AUDIO",
"BLOCKQUOTE",
"BODY",
"CANVAS",
"CENTER",
"DD",
"DIR",
"DIV",
"DL",
"DT",
"FIELDSET",
"FIGCAPTION",
"FIGURE",
"FOOTER",
"FORM",
"FRAMESET",
"H1",
"H2",
"H3",
"H4",
"H5",
"H6",
"HEADER",
"HGROUP",
"HR",
"HTML",
"ISINDEX",
"LI",
"MAIN",
"MENU",
"NAV",
"NOFRAMES",
"NOSCRIPT",
"OL",
"OUTPUT",
"P",
"PRE",
"SECTION",
"TABLE",
"TBODY",
"TD",
"TFOOT",
"TH",
"THEAD",
"TR",
"UL"
];
function isBlock(node) {
return is(node, blockElements);
}
var voidElements = [
"AREA",
"BASE",
"BR",
"COL",
"COMMAND",
"EMBED",
"HR",
"IMG",
"INPUT",
"KEYGEN",
"LINK",
"META",
"PARAM",
"SOURCE",
"TRACK",
"WBR"
];
function isVoid(node) {
return is(node, voidElements);
}
function hasVoid(node) {
return has(node, voidElements);
}
var meaningfulWhenBlankElements = [
"A",
"TABLE",
"THEAD",
"TBODY",
"TFOOT",
"TH",
"TD",
"IFRAME",
"SCRIPT",
"AUDIO",
"VIDEO"
];
function isMeaningfulWhenBlank(node) {
return is(node, meaningfulWhenBlankElements);
}
function hasMeaningfulWhenBlank(node) {
return has(node, meaningfulWhenBlankElements);
}
function is(node, tagNames) {
return tagNames.indexOf(node.nodeName) >= 0;
}
function has(node, tagNames) {
return node.getElementsByTagName && tagNames.some(function(tagName) {
return node.getElementsByTagName(tagName).length;
});
}
var rules$2 = {};
rules$2.paragraph = {
filter: "p",
replacement: function(content) {
return "\n\n" + content + "\n\n";
}
};
rules$2.lineBreak = {
filter: "br",
replacement: function(content, node, options) {
return options.br + "\n";
}
};
rules$2.heading = {
filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
replacement: function(content, node, options) {
var hLevel = Number(node.nodeName.charAt(1));
if (options.headingStyle === "setext" && hLevel < 3) {
var underline = repeat(hLevel === 1 ? "=" : "-", content.length);
return "\n\n" + content + "\n" + underline + "\n\n";
} else {
return "\n\n" + repeat("#", hLevel) + " " + content + "\n\n";
}
}
};
rules$2.blockquote = {
filter: "blockquote",
replacement: function(content) {
content = content.replace(/^\n+|\n+$/g, "");
content = content.replace(/^/gm, "> ");
return "\n\n" + content + "\n\n";
}
};
rules$2.list = {
filter: ["ul", "ol"],
replacement: function(content, node) {
var parent = node.parentNode;
if (parent.nodeName === "LI" && parent.lastElementChild === node) {
return "\n" + content;
} else {
return "\n\n" + content + "\n\n";
}
}
};
rules$2.listItem = {
filter: "li",
replacement: function(content, node, options) {
content = content.replace(/^\n+/, "").replace(/\n+$/, "\n").replace(/\n/gm, "\n ");
var prefix = options.bulletListMarker + " ";
var parent = node.parentNode;
if (parent.nodeName === "OL") {
var start = parent.getAttribute("start");
var index = Array.prototype.indexOf.call(parent.children, node);
prefix = (start ? Number(start) + index : index + 1) + ". ";
}
return prefix + content + (node.nextSibling && !/\n$/.test(content) ? "\n" : "");
}
};
rules$2.indentedCodeBlock = {
filter: function(node, options) {
return options.codeBlockStyle === "indented" && node.nodeName === "PRE" && node.firstChild && node.firstChild.nodeName === "CODE";
},
replacement: function(content, node, options) {
return "\n\n " + node.firstChild.textContent.replace(/\n/g, "\n ") + "\n\n";
}
};
rules$2.fencedCodeBlock = {
filter: function(node, options) {
return options.codeBlockStyle === "fenced" && node.nodeName === "PRE" && node.firstChild && node.firstChild.nodeName === "CODE";
},
replacement: function(content, node, options) {
var className = node.firstChild.getAttribute("class") || "";
var language = (className.match(/language-(\S+)/) || [null, ""])[1];
var code = node.firstChild.textContent;
var fenceChar = options.fence.charAt(0);
var fenceSize = 3;
var fenceInCodeRegex = new RegExp("^" + fenceChar + "{3,}", "gm");
var match;
while (match = fenceInCodeRegex.exec(code)) {
if (match[0].length >= fenceSize) {
fenceSize = match[0].length + 1;
}
}
var fence = repeat(fenceChar, fenceSize);
return "\n\n" + fence + language + "\n" + code.replace(/\n$/, "") + "\n" + fence + "\n\n";
}
};
rules$2.horizontalRule = {
filter: "hr",
replacement: function(content, node, options) {
return "\n\n" + options.hr + "\n\n";
}
};
rules$2.inlineLink = {
filter: function(node, options) {
return options.linkStyle === "inlined" && node.nodeName === "A" && node.getAttribute("href");
},
replacement: function(content, node) {
var href = node.getAttribute("href");
var title = cleanAttribute(node.getAttribute("title"));
if (title)
title = ' "' + title + '"';
return "[" + content + "](" + href + title + ")";
}
};
rules$2.referenceLink = {
filter: function(node, options) {
return options.linkStyle === "referenced" && node.nodeName === "A" && node.getAttribute("href");
},
replacement: function(content, node, options) {
var href = node.getAttribute("href");
var title = cleanAttribute(node.getAttribute("title"));
if (title)
title = ' "' + title + '"';
var replacement;
var reference;
switch (options.linkReferenceStyle) {
case "collapsed":
replacement = "[" + content + "][]";
reference = "[" + content + "]: " + href + title;
break;
case "shortcut":
replacement = "[" + content + "]";
reference = "[" + content + "]: " + href + title;
break;
default:
var id = this.references.length + 1;
replacement = "[" + content + "][" + id + "]";
reference = "[" + id + "]: " + href + title;
}
this.references.push(reference);
return replacement;
},
references: [],
append: function(options) {
var references = "";
if (this.references.length) {
references = "\n\n" + this.references.join("\n") + "\n\n";
this.references = [];
}
return references;
}
};
rules$2.emphasis = {
filter: ["em", "i"],
replacement: function(content, node, options) {
if (!content.trim())
return "";
return options.emDelimiter + content + options.emDelimiter;
}
};
rules$2.strong = {
filter: ["strong", "b"],
replacement: function(content, node, options) {
if (!content.trim())
return "";
return options.strongDelimiter + content + options.strongDelimiter;
}
};
rules$2.code = {
filter: function(node) {
var hasSiblings = node.previousSibling || node.nextSibling;
var isCodeBlock = node.parentNode.nodeName === "PRE" && !hasSiblings;
return node.nodeName === "CODE" && !isCodeBlock;
},
replacement: function(content) {
if (!content)
return "";
content = content.replace(/\r?\n|\r/g, " ");
var extraSpace = /^`|^ .*?[^ ].* $|`$/.test(content) ? " " : "";
var delimiter = "`";
var matches = content.match(/`+/gm) || [];
while (matches.indexOf(delimiter) !== -1)
delimiter = delimiter + "`";
return delimiter + extraSpace + content + extraSpace + delimiter;
}
};
rules$2.image = {
filter: "img",
replacement: function(content, node) {
var alt = cleanAttribute(node.getAttribute("alt"));
var src = node.getAttribute("src") || "";
var title = cleanAttribute(node.getAttribute("title"));
var titlePart = title ? ' "' + title + '"' : "";
return src ? "![" + alt + "](" + src + titlePart + ")" : "";
}
};
function cleanAttribute(attribute) {
return attribute ? attribute.replace(/(\n+\s*)+/g, "\n") : "";
}
function Rules(options) {
this.options = options;
this._keep = [];
this._remove = [];
this.blankRule = {
replacement: options.blankReplacement
};
this.keepReplacement = options.keepReplacement;
this.defaultRule = {
replacement: options.defaultReplacement
};
this.array = [];
for (var key2 in options.rules)
this.array.push(options.rules[key2]);
}
Rules.prototype = {
add: function(key2, rule) {
this.array.unshift(rule);
},
keep: function(filter) {
this._keep.unshift({
filter,
replacement: this.keepReplacement
});
},
remove: function(filter) {
this._remove.unshift({
filter,
replacement: function() {
return "";
}
});
},
forNode: function(node) {
if (node.isBlank)
return this.blankRule;
var rule;
if (rule = findRule(this.array, node, this.options))
return rule;
if (rule = findRule(this._keep, node, this.options))
return rule;
if (rule = findRule(this._remove, node, this.options))
return rule;
return this.defaultRule;
},
forEach: function(fn) {
for (var i = 0; i < this.array.length; i++)
fn(this.array[i], i);
}
};
function findRule(rules2, node, options) {
for (var i = 0; i < rules2.length; i++) {
var rule = rules2[i];
if (filterValue(rule, node, options))
return rule;
}
return void 0;
}
function filterValue(rule, node, options) {
var filter = rule.filter;
if (typeof filter === "string") {
if (filter === node.nodeName.toLowerCase())
return true;
} else if (Array.isArray(filter)) {
if (filter.indexOf(node.nodeName.toLowerCase()) > -1)
return true;
} else if (typeof filter === "function") {
if (filter.call(rule, node, options))
return true;
} else {
throw new TypeError("`filter` needs to be a string, array, or function");
}
}
function collapseWhitespace(options) {
var element = options.element;
var isBlock2 = options.isBlock;
var isVoid2 = options.isVoid;
var isPre = options.isPre || function(node2) {
return node2.nodeName === "PRE";
};
if (!element.firstChild || isPre(element))
return;
var prevText = null;
var keepLeadingWs = false;
var prev = null;
var node = next(prev, element, isPre);
while (node !== element) {
if (node.nodeType === 3 || node.nodeType === 4) {
var text = node.data.replace(/[ \r\n\t]+/g, " ");
if ((!prevText || / $/.test(prevText.data)) && !keepLeadingWs && text[0] === " ") {
text = text.substr(1);
}
if (!text) {
node = remove(node);
continue;
}
node.data = text;
prevText = node;
} else if (node.nodeType === 1) {
if (isBlock2(node) || node.nodeName === "BR") {
if (prevText) {
prevText.data = prevText.data.replace(/ $/, "");
}
prevText = null;
keepLeadingWs = false;
} else if (isVoid2(node) || isPre(node)) {
prevText = null;
keepLeadingWs = true;
} else if (prevText) {
keepLeadingWs = false;
}
} else {
node = remove(node);
continue;
}
var nextNode = next(prev, node, isPre);
prev = node;
node = nextNode;
}
if (prevText) {
prevText.data = prevText.data.replace(/ $/, "");
if (!prevText.data) {
remove(prevText);
}
}
}
function remove(node) {
var next2 = node.nextSibling || node.parentNode;
node.parentNode.removeChild(node);
return next2;
}
function next(prev, current, isPre) {
if (prev && prev.parentNode === current || isPre(current)) {
return current.nextSibling || current.parentNode;
}
return current.firstChild || current.nextSibling || current.parentNode;
}
var root = typeof window !== "undefined" ? window : {};
function canParseHTMLNatively() {
var Parser = root.DOMParser;
var canParse = false;
try {
if (new Parser().parseFromString("", "text/html")) {
canParse = true;
}
} catch (e2) {
}
return canParse;
}
function createHTMLParser() {
var Parser = function() {
};
{
if (shouldUseActiveX()) {
Parser.prototype.parseFromString = function(string2) {
var doc = new window.ActiveXObject("htmlfile");
doc.designMode = "on";
doc.open();
doc.write(string2);
doc.close();
return doc;
};
} else {
Parser.prototype.parseFromString = function(string2) {
var doc = document.implementation.createHTMLDocument("");
doc.open();
doc.write(string2);
doc.close();
return doc;
};
}
}
return Parser;
}
function shouldUseActiveX() {
var useActiveX = false;
try {
document.implementation.createHTMLDocument("").open();
} catch (e2) {
if (window.ActiveXObject)
useActiveX = true;
}
return useActiveX;
}
var HTMLParser = canParseHTMLNatively() ? root.DOMParser : createHTMLParser();
function RootNode(input, options) {
var root2;
if (typeof input === "string") {
var doc = htmlParser().parseFromString(
'' + input + "",
"text/html"
);
root2 = doc.getElementById("turndown-root");
} else {
root2 = input.cloneNode(true);
}
collapseWhitespace({
element: root2,
isBlock,
isVoid,
isPre: options.preformattedCode ? isPreOrCode : null
});
return root2;
}
var _htmlParser;
function htmlParser() {
_htmlParser = _htmlParser || new HTMLParser();
return _htmlParser;
}
function isPreOrCode(node) {
return node.nodeName === "PRE" || node.nodeName === "CODE";
}
function Node(node, options) {
node.isBlock = isBlock(node);
node.isCode = node.nodeName === "CODE" || node.parentNode.isCode;
node.isBlank = isBlank(node);
node.flankingWhitespace = flankingWhitespace(node, options);
return node;
}
function isBlank(node) {
return !isVoid(node) && !isMeaningfulWhenBlank(node) && /^\s*$/i.test(node.textContent) && !hasVoid(node) && !hasMeaningfulWhenBlank(node);
}
function flankingWhitespace(node, options) {
if (node.isBlock || options.preformattedCode && node.isCode) {
return { leading: "", trailing: "" };
}
var edges = edgeWhitespace(node.textContent);
if (edges.leadingAscii && isFlankedByWhitespace("left", node, options)) {
edges.leading = edges.leadingNonAscii;
}
if (edges.trailingAscii && isFlankedByWhitespace("right", node, options)) {
edges.trailing = edges.trailingNonAscii;
}
return { leading: edges.leading, trailing: edges.trailing };
}
function edgeWhitespace(string2) {
var m2 = string2.match(/^(([ \t\r\n]*)(\s*))[\s\S]*?((\s*?)([ \t\r\n]*))$/);
return {
leading: m2[1],
leadingAscii: m2[2],
leadingNonAscii: m2[3],
trailing: m2[4],
trailingNonAscii: m2[5],
trailingAscii: m2[6]
};
}
function isFlankedByWhitespace(side, node, options) {
var sibling;
var regExp;
var isFlanked;
if (side === "left") {
sibling = node.previousSibling;
regExp = / $/;
} else {
sibling = node.nextSibling;
regExp = /^ /;
}
if (sibling) {
if (sibling.nodeType === 3) {
isFlanked = regExp.test(sibling.nodeValue);
} else if (options.preformattedCode && sibling.nodeName === "CODE") {
isFlanked = false;
} else if (sibling.nodeType === 1 && !isBlock(sibling)) {
isFlanked = regExp.test(sibling.textContent);
}
}
return isFlanked;
}
var reduce = Array.prototype.reduce;
var escapes = [
[/\\/g, "\\\\"],
[/\*/g, "\\*"],
[/^-/g, "\\-"],
[/^\+ /g, "\\+ "],
[/^(=+)/g, "\\$1"],
[/^(#{1,6}) /g, "\\$1 "],
[/`/g, "\\`"],
[/^~~~/g, "\\~~~"],
[/\[/g, "\\["],
[/\]/g, "\\]"],
[/^>/g, "\\>"],
[/_/g, "\\_"],
[/^(\d+)\. /g, "$1\\. "]
];
function TurndownService(options) {
if (!(this instanceof TurndownService))
return new TurndownService(options);
var defaults = {
rules: rules$2,
headingStyle: "setext",
hr: "* * *",
bulletListMarker: "*",
codeBlockStyle: "indented",
fence: "```",
emDelimiter: "_",
strongDelimiter: "**",
linkStyle: "inlined",
linkReferenceStyle: "full",
br: " ",
preformattedCode: false,
blankReplacement: function(content, node) {
return node.isBlock ? "\n\n" : "";
},
keepReplacement: function(content, node) {
return node.isBlock ? "\n\n" + node.outerHTML + "\n\n" : node.outerHTML;
},
defaultReplacement: function(content, node) {
return node.isBlock ? "\n\n" + content + "\n\n" : content;
}
};
this.options = extend({}, defaults, options);
this.rules = new Rules(this.options);
}
TurndownService.prototype = {
turndown: function(input) {
if (!canConvert(input)) {
throw new TypeError(
input + " is not a string, or an element/document/fragment node."
);
}
if (input === "")
return "";
var output = process$1.call(this, new RootNode(input, this.options));
return postProcess.call(this, output);
},
use: function(plugin) {
if (Array.isArray(plugin)) {
for (var i = 0; i < plugin.length; i++)
this.use(plugin[i]);
} else if (typeof plugin === "function") {
plugin(this);
} else {
throw new TypeError("plugin must be a Function or an Array of Functions");
}
return this;
},
addRule: function(key2, rule) {
this.rules.add(key2, rule);
return this;
},
keep: function(filter) {
this.rules.keep(filter);
return this;
},
remove: function(filter) {
this.rules.remove(filter);
return this;
},
escape: function(string2) {
return escapes.reduce(function(accumulator, escape) {
return accumulator.replace(escape[0], escape[1]);
}, string2);
}
};
function process$1(parentNode) {
var self = this;
return reduce.call(parentNode.childNodes, function(output, node) {
node = new Node(node, self.options);
var replacement = "";
if (node.nodeType === 3) {
replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);
} else if (node.nodeType === 1) {
replacement = replacementForNode.call(self, node);
}
return join(output, replacement);
}, "");
}
function postProcess(output) {
var self = this;
this.rules.forEach(function(rule) {
if (typeof rule.append === "function") {
output = join(output, rule.append(self.options));
}
});
return output.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
}
function replacementForNode(node) {
var rule = this.rules.forNode(node);
var content = process$1.call(this, node);
var whitespace2 = node.flankingWhitespace;
if (whitespace2.leading || whitespace2.trailing)
content = content.trim();
return whitespace2.leading + rule.replacement(content, node, this.options) + whitespace2.trailing;
}
function join(output, replacement) {
var s1 = trimTrailingNewlines(output);
var s2 = trimLeadingNewlines(replacement);
var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
var separator = "\n\n".substring(0, nls);
return s1 + separator + s2;
}
function canConvert(input) {
return input != null && (typeof input === "string" || input.nodeType && (input.nodeType === 1 || input.nodeType === 9 || input.nodeType === 11));
}
var highlightRegExp = /highlight-(?:text|source)-([a-z0-9]+)/;
function highlightedCodeBlock(turndownService) {
turndownService.addRule("highlightedCodeBlock", {
filter: function(node) {
var firstChild = node.firstChild;
return node.nodeName === "DIV" && highlightRegExp.test(node.className) && firstChild && firstChild.nodeName === "PRE";
},
replacement: function(content, node, options) {
var className = node.className || "";
var language = (className.match(highlightRegExp) || [null, ""])[1];
return "\n\n" + options.fence + language + "\n" + node.firstChild.textContent + "\n" + options.fence + "\n\n";
}
});
}
function strikethrough(turndownService) {
turndownService.addRule("strikethrough", {
filter: ["del", "s", "strike"],
replacement: function(content) {
return "~" + content + "~";
}
});
}
var indexOf = Array.prototype.indexOf;
var every = Array.prototype.every;
var rules$1 = {};
rules$1.tableCell = {
filter: ["th", "td"],
replacement: function(content, node) {
return cell(content, node);
}
};
rules$1.tableRow = {
filter: "tr",
replacement: function(content, node) {
var borderCells = "";
var alignMap = { left: ":--", right: "--:", center: ":-:" };
if (isHeadingRow(node)) {
for (var i = 0; i < node.childNodes.length; i++) {
var border = "---";
var align = (node.childNodes[i].getAttribute("align") || "").toLowerCase();
if (align)
border = alignMap[align] || border;
borderCells += cell(border, node.childNodes[i]);
}
}
return "\n" + content + (borderCells ? "\n" + borderCells : "");
}
};
rules$1.table = {
filter: function(node) {
return node.nodeName === "TABLE" && isHeadingRow(node.rows[0]);
},
replacement: function(content) {
content = content.replace("\n\n", "\n");
return "\n\n" + content + "\n\n";
}
};
rules$1.tableSection = {
filter: ["thead", "tbody", "tfoot"],
replacement: function(content) {
return content;
}
};
function isHeadingRow(tr) {
var parentNode = tr.parentNode;
return parentNode.nodeName === "THEAD" || parentNode.firstChild === tr && (parentNode.nodeName === "TABLE" || isFirstTbody(parentNode)) && every.call(tr.childNodes, function(n2) {
return n2.nodeName === "TH";
});
}
function isFirstTbody(element) {
var previousSibling = element.previousSibling;
return element.nodeName === "TBODY" && (!previousSibling || previousSibling.nodeName === "THEAD" && /^\s*$/i.test(previousSibling.textContent));
}
function cell(content, node) {
var index = indexOf.call(node.parentNode.childNodes, node);
var prefix = " ";
if (index === 0)
prefix = "| ";
return prefix + content + " |";
}
function tables(turndownService) {
turndownService.keep(function(node) {
return node.nodeName === "TABLE" && !isHeadingRow(node.rows[0]);
});
for (var key2 in rules$1)
turndownService.addRule(key2, rules$1[key2]);
}
function taskListItems(turndownService) {
turndownService.addRule("taskListItems", {
filter: function(node) {
return node.type === "checkbox" && node.parentNode.nodeName === "LI";
},
replacement: function(content, node) {
return (node.checked ? "[x]" : "[ ]") + " ";
}
});
}
function gfm(turndownService) {
turndownService.use([
highlightedCodeBlock,
strikethrough,
tables,
taskListItems
]);
}
function _extends$1() {
_extends$1 = Object.assign ? Object.assign.bind() : function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key2 in source) {
if (Object.prototype.hasOwnProperty.call(source, key2)) {
target[key2] = source[key2];
}
}
}
return target;
};
return _extends$1.apply(this, arguments);
}
function _typeof(obj) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
return typeof obj2;
} : function(obj2) {
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
}, _typeof(obj);
}
function _toPrimitive(input, hint) {
if (_typeof(input) !== "object" || input === null)
return input;
var prim = input[Symbol.toPrimitive];
if (prim !== void 0) {
var res = prim.call(input, hint || "default");
if (_typeof(res) !== "object")
return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
var key2 = _toPrimitive(arg, "string");
return _typeof(key2) === "symbol" ? key2 : String(key2);
}
function _defineProperty(obj, key2, value) {
key2 = _toPropertyKey(key2);
if (key2 in obj) {
Object.defineProperty(obj, key2, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key2] = value;
}
return obj;
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor)
descriptor.writable = true;
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps)
_defineProperties(Constructor.prototype, protoProps);
if (staticProps)
_defineProperties(Constructor, staticProps);
Object.defineProperty(Constructor, "prototype", {
writable: false
});
return Constructor;
}
function _setPrototypeOf$1(o, p2) {
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p3) {
o2.__proto__ = p3;
return o2;
};
return _setPrototypeOf$1(o, p2);
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
Object.defineProperty(subClass, "prototype", {
writable: false
});
if (superClass)
_setPrototypeOf$1(subClass, superClass);
}
function _getPrototypeOf$1(o) {
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
return o2.__proto__ || Object.getPrototypeOf(o2);
};
return _getPrototypeOf$1(o);
}
function _isNativeReflectConstruct$1() {
if (typeof Reflect === "undefined" || !Reflect.construct)
return false;
if (Reflect.construct.sham)
return false;
if (typeof Proxy === "function")
return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e2) {
return false;
}
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call2) {
if (call2 && (_typeof(call2) === "object" || typeof call2 === "function")) {
return call2;
} else if (call2 !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
return function _createSuperInternal() {
var Super = _getPrototypeOf$1(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf$1(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var classnames = { exports: {} };
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
(function(module) {
(function() {
var hasOwn = {}.hasOwnProperty;
function classNames2() {
var classes = [];
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (!arg)
continue;
var argType = typeof arg;
if (argType === "string" || argType === "number") {
classes.push(arg);
} else if (Array.isArray(arg)) {
if (arg.length) {
var inner = classNames2.apply(null, arg);
if (inner) {
classes.push(inner);
}
}
} else if (argType === "object") {
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
classes.push(arg.toString());
continue;
}
for (var key2 in arg) {
if (hasOwn.call(arg, key2) && arg[key2]) {
classes.push(key2);
}
}
}
}
return classes.join(" ");
}
if (module.exports) {
classNames2.default = classNames2;
module.exports = classNames2;
} else {
window.classNames = classNames2;
}
})();
})(classnames);
const classNames = classnames.exports;
var reactIs = { exports: {} };
var reactIs_production_min = {};
/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var b = "function" === typeof Symbol && Symbol.for, c = b ? Symbol.for("react.element") : 60103, d = b ? Symbol.for("react.portal") : 60106, e = b ? Symbol.for("react.fragment") : 60107, f$1 = b ? Symbol.for("react.strict_mode") : 60108, g = b ? Symbol.for("react.profiler") : 60114, h = b ? Symbol.for("react.provider") : 60109, k$1 = b ? Symbol.for("react.context") : 60110, l$1 = b ? Symbol.for("react.async_mode") : 60111, m$1 = b ? Symbol.for("react.concurrent_mode") : 60111, n$1 = b ? Symbol.for("react.forward_ref") : 60112, p$1 = b ? Symbol.for("react.suspense") : 60113, q$1 = b ? Symbol.for("react.suspense_list") : 60120, r = b ? Symbol.for("react.memo") : 60115, t = b ? Symbol.for("react.lazy") : 60116, v = b ? Symbol.for("react.block") : 60121, w = b ? Symbol.for("react.fundamental") : 60117, x = b ? Symbol.for("react.responder") : 60118, y = b ? Symbol.for("react.scope") : 60119;
function z(a) {
if ("object" === typeof a && null !== a) {
var u = a.$$typeof;
switch (u) {
case c:
switch (a = a.type, a) {
case l$1:
case m$1:
case e:
case g:
case f$1:
case p$1:
return a;
default:
switch (a = a && a.$$typeof, a) {
case k$1:
case n$1:
case t:
case r:
case h:
return a;
default:
return u;
}
}
case d:
return u;
}
}
}
function A(a) {
return z(a) === m$1;
}
reactIs_production_min.AsyncMode = l$1;
reactIs_production_min.ConcurrentMode = m$1;
reactIs_production_min.ContextConsumer = k$1;
reactIs_production_min.ContextProvider = h;
reactIs_production_min.Element = c;
reactIs_production_min.ForwardRef = n$1;
reactIs_production_min.Fragment = e;
reactIs_production_min.Lazy = t;
reactIs_production_min.Memo = r;
reactIs_production_min.Portal = d;
reactIs_production_min.Profiler = g;
reactIs_production_min.StrictMode = f$1;
reactIs_production_min.Suspense = p$1;
reactIs_production_min.isAsyncMode = function(a) {
return A(a) || z(a) === l$1;
};
reactIs_production_min.isConcurrentMode = A;
reactIs_production_min.isContextConsumer = function(a) {
return z(a) === k$1;
};
reactIs_production_min.isContextProvider = function(a) {
return z(a) === h;
};
reactIs_production_min.isElement = function(a) {
return "object" === typeof a && null !== a && a.$$typeof === c;
};
reactIs_production_min.isForwardRef = function(a) {
return z(a) === n$1;
};
reactIs_production_min.isFragment = function(a) {
return z(a) === e;
};
reactIs_production_min.isLazy = function(a) {
return z(a) === t;
};
reactIs_production_min.isMemo = function(a) {
return z(a) === r;
};
reactIs_production_min.isPortal = function(a) {
return z(a) === d;
};
reactIs_production_min.isProfiler = function(a) {
return z(a) === g;
};
reactIs_production_min.isStrictMode = function(a) {
return z(a) === f$1;
};
reactIs_production_min.isSuspense = function(a) {
return z(a) === p$1;
};
reactIs_production_min.isValidElementType = function(a) {
return "string" === typeof a || "function" === typeof a || a === e || a === m$1 || a === g || a === f$1 || a === p$1 || a === q$1 || "object" === typeof a && null !== a && (a.$$typeof === t || a.$$typeof === r || a.$$typeof === h || a.$$typeof === k$1 || a.$$typeof === n$1 || a.$$typeof === w || a.$$typeof === x || a.$$typeof === y || a.$$typeof === v);
};
reactIs_production_min.typeOf = z;
(function(module) {
{
module.exports = reactIs_production_min;
}
})(reactIs);
function toArray$1(children) {
var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var ret = [];
React__default.default.Children.forEach(children, function(child) {
if ((child === void 0 || child === null) && !option.keepEmpty) {
return;
}
if (Array.isArray(child)) {
ret = ret.concat(toArray$1(child));
} else if (reactIs.exports.isFragment(child) && child.props) {
ret = ret.concat(toArray$1(child.props.children, option));
} else {
ret.push(child);
}
});
return ret;
}
var warned = {};
function warning$2(valid, message2) {
}
function call(method2, valid, message2) {
if (!valid && !warned[message2]) {
method2(false, message2);
warned[message2] = true;
}
}
function warningOnce(valid, message2) {
call(warning$2, valid, message2);
}
function ownKeys(object2, enumerableOnly) {
var keys = Object.keys(object2);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object2);
enumerableOnly && (symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object2, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), true).forEach(function(key2) {
_defineProperty(target, key2, source[key2]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key2) {
Object.defineProperty(target, key2, Object.getOwnPropertyDescriptor(source, key2));
});
}
return target;
}
function useMemo(getValue2, condition, shouldUpdate) {
var cacheRef = React__namespace.useRef({});
if (!("value" in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) {
cacheRef.current.value = getValue2();
cacheRef.current.condition = condition;
}
return cacheRef.current.value;
}
function fillRef(ref, node) {
if (typeof ref === "function") {
ref(node);
} else if (_typeof(ref) === "object" && ref && "current" in ref) {
ref.current = node;
}
}
function supportRef(nodeOrComponent) {
var _type$prototype, _nodeOrComponent$prot;
var type2 = reactIs.exports.isMemo(nodeOrComponent) ? nodeOrComponent.type.type : nodeOrComponent.type;
if (typeof type2 === "function" && !((_type$prototype = type2.prototype) === null || _type$prototype === void 0 ? void 0 : _type$prototype.render)) {
return false;
}
if (typeof nodeOrComponent === "function" && !((_nodeOrComponent$prot = nodeOrComponent.prototype) === null || _nodeOrComponent$prot === void 0 ? void 0 : _nodeOrComponent$prot.render)) {
return false;
}
return true;
}
function findDOMNode(node) {
if (node instanceof HTMLElement) {
return node;
}
return ReactDOM__default.default.findDOMNode(node);
}
var jsxRuntime = { exports: {} };
var reactJsxRuntime_production_min = {};
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var f = React__default.default, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
function q(c2, a, g2) {
var b2, d2 = {}, e2 = null, h2 = null;
void 0 !== g2 && (e2 = "" + g2);
void 0 !== a.key && (e2 = "" + a.key);
void 0 !== a.ref && (h2 = a.ref);
for (b2 in a)
m.call(a, b2) && !p.hasOwnProperty(b2) && (d2[b2] = a[b2]);
if (c2 && c2.defaultProps)
for (b2 in a = c2.defaultProps, a)
void 0 === d2[b2] && (d2[b2] = a[b2]);
return { $$typeof: k, type: c2, key: e2, ref: h2, props: d2, _owner: n.current };
}
reactJsxRuntime_production_min.Fragment = l;
reactJsxRuntime_production_min.jsx = q;
reactJsxRuntime_production_min.jsxs = q;
(function(module) {
{
module.exports = reactJsxRuntime_production_min;
}
})(jsxRuntime);
const Fragment = jsxRuntime.exports.Fragment;
const jsx = jsxRuntime.exports.jsx;
const jsxs = jsxRuntime.exports.jsxs;
var IconContext = /* @__PURE__ */ React2.createContext({});
const IconContext$1 = IconContext;
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null)
return {};
var target = {};
var sourceKeys = Object.keys(source);
var key2, i;
for (i = 0; i < sourceKeys.length; i++) {
key2 = sourceKeys[i];
if (excluded.indexOf(key2) >= 0)
continue;
target[key2] = source[key2];
}
return target;
}
function _objectWithoutProperties(source, excluded) {
if (source == null)
return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key2, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key2 = sourceSymbolKeys[i];
if (excluded.indexOf(key2) >= 0)
continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key2))
continue;
target[key2] = source[key2];
}
}
return target;
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length)
len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++)
arr2[i] = arr[i];
return arr2;
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr))
return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o)
return;
if (typeof o === "string")
return _arrayLikeToArray(o, minLen);
var n2 = Object.prototype.toString.call(o).slice(8, -1);
if (n2 === "Object" && o.constructor)
n2 = o.constructor.name;
if (n2 === "Map" || n2 === "Set")
return Array.from(o);
if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2))
return _arrayLikeToArray(o, minLen);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
var HOOK_MARK = "RC_FORM_INTERNAL_HOOKS";
var warningFunc = function warningFunc2() {
warningOnce(false, "Can not find FormContext. Please make sure you wrap Field under Form.");
};
var Context = /* @__PURE__ */ React__namespace.createContext({
getFieldValue: warningFunc,
getFieldsValue: warningFunc,
getFieldError: warningFunc,
getFieldWarning: warningFunc,
getFieldsError: warningFunc,
isFieldsTouched: warningFunc,
isFieldTouched: warningFunc,
isFieldValidating: warningFunc,
isFieldsValidating: warningFunc,
resetFields: warningFunc,
setFields: warningFunc,
setFieldValue: warningFunc,
setFieldsValue: warningFunc,
validateFields: warningFunc,
submit: warningFunc,
getInternalHooks: function getInternalHooks() {
warningFunc();
return {
dispatch: warningFunc,
initEntityValue: warningFunc,
registerField: warningFunc,
useSubscribe: warningFunc,
setInitialValues: warningFunc,
destroyForm: warningFunc,
setCallbacks: warningFunc,
registerWatch: warningFunc,
getFields: warningFunc,
setValidateMessages: warningFunc,
setPreserve: warningFunc,
getInitialValue: warningFunc
};
}
});
function toArray(value) {
if (value === void 0 || value === null) {
return [];
}
return Array.isArray(value) ? value : [value];
}
function _regeneratorRuntime() {
_regeneratorRuntime = function _regeneratorRuntime2() {
return exports;
};
var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function(obj, key2, desc) {
obj[key2] = desc.value;
}, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key2, value) {
return Object.defineProperty(obj, key2, {
value,
enumerable: true,
configurable: true,
writable: true
}), obj[key2];
}
try {
define({}, "");
} catch (err) {
define = function define2(obj, key2, value) {
return obj[key2] = value;
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context2(tryLocsList || []);
return defineProperty(generator, "_invoke", {
value: makeInvokeMethod(innerFn, self, context)
}), generator;
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {
}
function GeneratorFunction() {
}
function GeneratorFunctionPrototype() {
}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function() {
return this;
});
var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function(method2) {
define(prototype, method2, function(arg) {
return this._invoke(method2, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method2, arg, resolve, reject) {
var record = tryCatch(generator[method2], generator, arg);
if ("throw" !== record.type) {
var result = record.arg, value = result.value;
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function(value2) {
invoke("next", value2, resolve, reject);
}, function(err) {
invoke("throw", err, resolve, reject);
}) : PromiseImpl.resolve(value).then(function(unwrapped) {
result.value = unwrapped, resolve(result);
}, function(error) {
return invoke("throw", error, resolve, reject);
});
}
reject(record.arg);
}
var previousPromise;
defineProperty(this, "_invoke", {
value: function value(method2, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function(resolve, reject) {
invoke(method2, arg, resolve, reject);
});
}
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
}
});
}
function makeInvokeMethod(innerFn, self, context) {
var state = "suspendedStart";
return function(method2, arg) {
if ("executing" === state)
throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method2)
throw arg;
return doneResult();
}
for (context.method = method2, context.arg = arg; ; ) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel)
continue;
return delegateResult;
}
}
if ("next" === context.method)
context.sent = context._sent = context.arg;
else if ("throw" === context.method) {
if ("suspendedStart" === state)
throw state = "completed", context.arg;
context.dispatchException(context.arg);
} else
"return" === context.method && context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel)
continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
}
};
}
function maybeInvokeDelegate(delegate, context) {
var methodName = context.method, method2 = delegate.iterator[methodName];
if (void 0 === method2)
return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = void 0, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
var record = tryCatch(method2, delegate.iterator, context.arg);
if ("throw" === record.type)
return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
var info = record.arg;
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = void 0), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal", delete record.arg, entry.completion = record;
}
function Context2(tryLocsList) {
this.tryEntries = [{
tryLoc: "root"
}], tryLocsList.forEach(pushTryEntry, this), this.reset(true);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod)
return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next)
return iterable;
if (!isNaN(iterable.length)) {
var i = -1, next2 = function next3() {
for (; ++i < iterable.length; )
if (hasOwn.call(iterable, i))
return next3.value = iterable[i], next3.done = false, next3;
return next3.value = void 0, next3.done = true, next3;
};
return next2.next = next2;
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: void 0,
done: true
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
value: GeneratorFunctionPrototype,
configurable: true
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
value: GeneratorFunction,
configurable: true
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function(genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
}, exports.mark = function(genFun) {
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
}, exports.awrap = function(arg) {
return {
__await: arg
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
return this;
}), exports.AsyncIterator = AsyncIterator, exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
return result.done ? result.value : iter.next();
});
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function() {
return this;
}), define(Gp, "toString", function() {
return "[object Generator]";
}), exports.keys = function(val) {
var object2 = Object(val), keys = [];
for (var key2 in object2)
keys.push(key2);
return keys.reverse(), function next2() {
for (; keys.length; ) {
var key3 = keys.pop();
if (key3 in object2)
return next2.value = key3, next2.done = false, next2;
}
return next2.done = true, next2;
};
}, exports.values = values, Context2.prototype = {
constructor: Context2,
reset: function reset(skipTempReset) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = void 0, this.done = false, this.delegate = null, this.method = "next", this.arg = void 0, this.tryEntries.forEach(resetTryEntry), !skipTempReset)
for (var name in this)
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = void 0);
},
stop: function stop() {
this.done = true;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type)
throw rootRecord.arg;
return this.rval;
},
dispatchException: function dispatchException(exception) {
if (this.done)
throw exception;
var context = this;
function handle(loc, caught) {
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = void 0), !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i], record = entry.completion;
if ("root" === entry.tryLoc)
return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc)
return handle(entry.catchLoc, true);
if (this.prev < entry.finallyLoc)
return handle(entry.finallyLoc);
} else if (hasCatch) {
if (this.prev < entry.catchLoc)
return handle(entry.catchLoc, true);
} else {
if (!hasFinally)
throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc)
return handle(entry.finallyLoc);
}
}
}
},
abrupt: function abrupt(type2, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
finallyEntry && ("break" === type2 || "continue" === type2) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return record.type = type2, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
},
complete: function complete(record, afterLoc) {
if ("throw" === record.type)
throw record.arg;
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
},
finish: function finish(finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc)
return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
}
},
"catch": function _catch(tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
return this.delegate = {
iterator: values(iterable),
resultName,
nextLoc
}, "next" === this.method && (this.arg = void 0), ContinueSentinel;
}
}, exports;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key2, arg) {
try {
var info = gen[key2](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function() {
var self = this, args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(void 0);
});
};
}
function _extends() {
_extends = Object.assign ? Object.assign.bind() : function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key2 in source) {
if (Object.prototype.hasOwnProperty.call(source, key2)) {
target[key2] = source[key2];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
_setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o2) {
return o2.__proto__ || Object.getPrototypeOf(o2);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p2) {
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o2, p3) {
o2.__proto__ = p3;
return o2;
};
return _setPrototypeOf(o, p2);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct)
return false;
if (Reflect.construct.sham)
return false;
if (typeof Proxy === "function")
return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e2) {
return false;
}
}
function _construct(Parent, args, Class) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct.bind();
} else {
_construct = function _construct2(Parent2, args2, Class2) {
var a = [null];
a.push.apply(a, args2);
var Constructor = Function.bind.apply(Parent2, a);
var instance = new Constructor();
if (Class2)
_setPrototypeOf(instance, Class2.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
if (Class2 === null || !_isNativeFunction(Class2))
return Class2;
if (typeof Class2 !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class2))
return _cache.get(Class2);
_cache.set(Class2, Wrapper);
}
function Wrapper() {
return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class2.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
});
return _setPrototypeOf(Wrapper, Class2);
};
return _wrapNativeSuper(Class);
}
var formatRegExp = /%[sdj%]/g;
var warning$1 = function warning2() {
};
if (typeof process !== "undefined" && process.env && false) {
warning$1 = function warning2(type2, errors) {
if (typeof console !== "undefined" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING === "undefined") {
if (errors.every(function(e2) {
return typeof e2 === "string";
})) {
console.warn(type2, errors);
}
}
};
}
function convertFieldsError(errors) {
if (!errors || !errors.length)
return null;
var fields = {};
errors.forEach(function(error) {
var field = error.field;
fields[field] = fields[field] || [];
fields[field].push(error);
});
return fields;
}
function format(template) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var i = 0;
var len = args.length;
if (typeof template === "function") {
return template.apply(null, args);
}
if (typeof template === "string") {
var str = template.replace(formatRegExp, function(x2) {
if (x2 === "%%") {
return "%";
}
if (i >= len) {
return x2;
}
switch (x2) {
case "%s":
return String(args[i++]);
case "%d":
return Number(args[i++]);
case "%j":
try {
return JSON.stringify(args[i++]);
} catch (_) {
return "[Circular]";
}
break;
default:
return x2;
}
});
return str;
}
return template;
}
function isNativeStringType(type2) {
return type2 === "string" || type2 === "url" || type2 === "hex" || type2 === "email" || type2 === "date" || type2 === "pattern";
}
function isEmptyValue(value, type2) {
if (value === void 0 || value === null) {
return true;
}
if (type2 === "array" && Array.isArray(value) && !value.length) {
return true;
}
if (isNativeStringType(type2) && typeof value === "string" && !value) {
return true;
}
return false;
}
function asyncParallelArray(arr, func, callback) {
var results = [];
var total = 0;
var arrLength = arr.length;
function count(errors) {
results.push.apply(results, errors || []);
total++;
if (total === arrLength) {
callback(results);
}
}
arr.forEach(function(a) {
func(a, count);
});
}
function asyncSerialArray(arr, func, callback) {
var index = 0;
var arrLength = arr.length;
function next2(errors) {
if (errors && errors.length) {
callback(errors);
return;
}
var original = index;
index = index + 1;
if (original < arrLength) {
func(arr[original], next2);
} else {
callback([]);
}
}
next2([]);
}
function flattenObjArr(objArr) {
var ret = [];
Object.keys(objArr).forEach(function(k2) {
ret.push.apply(ret, objArr[k2] || []);
});
return ret;
}
var AsyncValidationError = /* @__PURE__ */ function(_Error) {
_inheritsLoose(AsyncValidationError2, _Error);
function AsyncValidationError2(errors, fields) {
var _this;
_this = _Error.call(this, "Async Validation Error") || this;
_this.errors = errors;
_this.fields = fields;
return _this;
}
return AsyncValidationError2;
}(/* @__PURE__ */ _wrapNativeSuper(Error));
function asyncMap(objArr, option, func, callback, source) {
if (option.first) {
var _pending = new Promise(function(resolve, reject) {
var next2 = function next3(errors) {
callback(errors);
return errors.length ? reject(new AsyncValidationError(errors, convertFieldsError(errors))) : resolve(source);
};
var flattenArr = flattenObjArr(objArr);
asyncSerialArray(flattenArr, func, next2);
});
_pending["catch"](function(e2) {
return e2;
});
return _pending;
}
var firstFields = option.firstFields === true ? Object.keys(objArr) : option.firstFields || [];
var objArrKeys = Object.keys(objArr);
var objArrLength = objArrKeys.length;
var total = 0;
var results = [];
var pending = new Promise(function(resolve, reject) {
var next2 = function next3(errors) {
results.push.apply(results, errors);
total++;
if (total === objArrLength) {
callback(results);
return results.length ? reject(new AsyncValidationError(results, convertFieldsError(results))) : resolve(source);
}
};
if (!objArrKeys.length) {
callback(results);
resolve(source);
}
objArrKeys.forEach(function(key2) {
var arr = objArr[key2];
if (firstFields.indexOf(key2) !== -1) {
asyncSerialArray(arr, func, next2);
} else {
asyncParallelArray(arr, func, next2);
}
});
});
pending["catch"](function(e2) {
return e2;
});
return pending;
}
function isErrorObj(obj) {
return !!(obj && obj.message !== void 0);
}
function getValue$2(value, path) {
var v2 = value;
for (var i = 0; i < path.length; i++) {
if (v2 == void 0) {
return v2;
}
v2 = v2[path[i]];
}
return v2;
}
function complementError(rule, source) {
return function(oe) {
var fieldValue;
if (rule.fullFields) {
fieldValue = getValue$2(source, rule.fullFields);
} else {
fieldValue = source[oe.field || rule.fullField];
}
if (isErrorObj(oe)) {
oe.field = oe.field || rule.fullField;
oe.fieldValue = fieldValue;
return oe;
}
return {
message: typeof oe === "function" ? oe() : oe,
fieldValue,
field: oe.field || rule.fullField
};
};
}
function deepMerge(target, source) {
if (source) {
for (var s in source) {
if (source.hasOwnProperty(s)) {
var value = source[s];
if (typeof value === "object" && typeof target[s] === "object") {
target[s] = _extends({}, target[s], value);
} else {
target[s] = value;
}
}
}
}
return target;
}
var required$1 = function required2(rule, value, source, errors, options, type2) {
if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type2 || rule.type))) {
errors.push(format(options.messages.required, rule.fullField));
}
};
var whitespace = function whitespace2(rule, value, source, errors, options) {
if (/^\s+$/.test(value) || value === "") {
errors.push(format(options.messages.whitespace, rule.fullField));
}
};
var urlReg;
var getUrlRegex = function() {
if (urlReg) {
return urlReg;
}
var word = "[a-fA-F\\d:]";
var b2 = function b3(options) {
return options && options.includeBoundaries ? "(?:(?<=\\s|^)(?=" + word + ")|(?<=" + word + ")(?=\\s|$))" : "";
};
var v4 = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}";
var v6seg = "[a-fA-F\\d]{1,4}";
var v6 = ("\n(?:\n(?:" + v6seg + ":){7}(?:" + v6seg + "|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:" + v6seg + ":){6}(?:" + v4 + "|:" + v6seg + "|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:" + v6seg + ":){5}(?::" + v4 + "|(?::" + v6seg + "){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:" + v6seg + ":){4}(?:(?::" + v6seg + "){0,1}:" + v4 + "|(?::" + v6seg + "){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:" + v6seg + ":){3}(?:(?::" + v6seg + "){0,2}:" + v4 + "|(?::" + v6seg + "){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:" + v6seg + ":){2}(?:(?::" + v6seg + "){0,3}:" + v4 + "|(?::" + v6seg + "){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:" + v6seg + ":){1}(?:(?::" + v6seg + "){0,4}:" + v4 + "|(?::" + v6seg + "){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::" + v6seg + "){0,5}:" + v4 + "|(?::" + v6seg + "){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim();
var v46Exact = new RegExp("(?:^" + v4 + "$)|(?:^" + v6 + "$)");
var v4exact = new RegExp("^" + v4 + "$");
var v6exact = new RegExp("^" + v6 + "$");
var ip = function ip2(options) {
return options && options.exact ? v46Exact : new RegExp("(?:" + b2(options) + v4 + b2(options) + ")|(?:" + b2(options) + v6 + b2(options) + ")", "g");
};
ip.v4 = function(options) {
return options && options.exact ? v4exact : new RegExp("" + b2(options) + v4 + b2(options), "g");
};
ip.v6 = function(options) {
return options && options.exact ? v6exact : new RegExp("" + b2(options) + v6 + b2(options), "g");
};
var protocol = "(?:(?:[a-z]+:)?//)";
var auth = "(?:\\S+(?::\\S*)?@)?";
var ipv4 = ip.v4().source;
var ipv6 = ip.v6().source;
var host = "(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)";
var domain = "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*";
var tld = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))";
var port = "(?::\\d{2,5})?";
var path = '(?:[/?#][^\\s"]*)?';
var regex = "(?:" + protocol + "|www\\.)" + auth + "(?:localhost|" + ipv4 + "|" + ipv6 + "|" + host + domain + tld + ")" + port + path;
urlReg = new RegExp("(?:^" + regex + "$)", "i");
return urlReg;
};
var pattern$2 = {
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
};
var types = {
integer: function integer2(value) {
return types.number(value) && parseInt(value, 10) === value;
},
"float": function float(value) {
return types.number(value) && !types.integer(value);
},
array: function array2(value) {
return Array.isArray(value);
},
regexp: function regexp2(value) {
if (value instanceof RegExp) {
return true;
}
try {
return !!new RegExp(value);
} catch (e2) {
return false;
}
},
date: function date2(value) {
return typeof value.getTime === "function" && typeof value.getMonth === "function" && typeof value.getYear === "function" && !isNaN(value.getTime());
},
number: function number2(value) {
if (isNaN(value)) {
return false;
}
return typeof value === "number";
},
object: function object2(value) {
return typeof value === "object" && !types.array(value);
},
method: function method2(value) {
return typeof value === "function";
},
email: function email(value) {
return typeof value === "string" && value.length <= 320 && !!value.match(pattern$2.email);
},
url: function url(value) {
return typeof value === "string" && value.length <= 2048 && !!value.match(getUrlRegex());
},
hex: function hex(value) {
return typeof value === "string" && !!value.match(pattern$2.hex);
}
};
var type$1 = function type2(rule, value, source, errors, options) {
if (rule.required && value === void 0) {
required$1(rule, value, source, errors, options);
return;
}
var custom = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"];
var ruleType = rule.type;
if (custom.indexOf(ruleType) > -1) {
if (!types[ruleType](value)) {
errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
}
} else if (ruleType && typeof value !== rule.type) {
errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type));
}
};
var range = function range2(rule, value, source, errors, options) {
var len = typeof rule.len === "number";
var min = typeof rule.min === "number";
var max = typeof rule.max === "number";
var spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
var val = value;
var key2 = null;
var num = typeof value === "number";
var str = typeof value === "string";
var arr = Array.isArray(value);
if (num) {
key2 = "number";
} else if (str) {
key2 = "string";
} else if (arr) {
key2 = "array";
}
if (!key2) {
return false;
}
if (arr) {
val = value.length;
}
if (str) {
val = value.replace(spRegexp, "_").length;
}
if (len) {
if (val !== rule.len) {
errors.push(format(options.messages[key2].len, rule.fullField, rule.len));
}
} else if (min && !max && val < rule.min) {
errors.push(format(options.messages[key2].min, rule.fullField, rule.min));
} else if (max && !min && val > rule.max) {
errors.push(format(options.messages[key2].max, rule.fullField, rule.max));
} else if (min && max && (val < rule.min || val > rule.max)) {
errors.push(format(options.messages[key2].range, rule.fullField, rule.min, rule.max));
}
};
var ENUM$1 = "enum";
var enumerable$1 = function enumerable2(rule, value, source, errors, options) {
rule[ENUM$1] = Array.isArray(rule[ENUM$1]) ? rule[ENUM$1] : [];
if (rule[ENUM$1].indexOf(value) === -1) {
errors.push(format(options.messages[ENUM$1], rule.fullField, rule[ENUM$1].join(", ")));
}
};
var pattern$1 = function pattern2(rule, value, source, errors, options) {
if (rule.pattern) {
if (rule.pattern instanceof RegExp) {
rule.pattern.lastIndex = 0;
if (!rule.pattern.test(value)) {
errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
}
} else if (typeof rule.pattern === "string") {
var _pattern = new RegExp(rule.pattern);
if (!_pattern.test(value)) {
errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern));
}
}
}
};
var rules = {
required: required$1,
whitespace,
type: type$1,
range,
"enum": enumerable$1,
pattern: pattern$1
};
var string = function string2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value, "string") && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options, "string");
if (!isEmptyValue(value, "string")) {
rules.type(rule, value, source, errors, options);
rules.range(rule, value, source, errors, options);
rules.pattern(rule, value, source, errors, options);
if (rule.whitespace === true) {
rules.whitespace(rule, value, source, errors, options);
}
}
}
callback(errors);
};
var method = function method2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
}
}
callback(errors);
};
var number = function number2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (value === "") {
value = void 0;
}
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
rules.range(rule, value, source, errors, options);
}
}
callback(errors);
};
var _boolean = function _boolean2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
}
}
callback(errors);
};
var regexp = function regexp2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (!isEmptyValue(value)) {
rules.type(rule, value, source, errors, options);
}
}
callback(errors);
};
var integer = function integer2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
rules.range(rule, value, source, errors, options);
}
}
callback(errors);
};
var floatFn = function floatFn2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
rules.range(rule, value, source, errors, options);
}
}
callback(errors);
};
var array = function array2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if ((value === void 0 || value === null) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options, "array");
if (value !== void 0 && value !== null) {
rules.type(rule, value, source, errors, options);
rules.range(rule, value, source, errors, options);
}
}
callback(errors);
};
var object = function object2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules.type(rule, value, source, errors, options);
}
}
callback(errors);
};
var ENUM = "enum";
var enumerable = function enumerable2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (value !== void 0) {
rules[ENUM](rule, value, source, errors, options);
}
}
callback(errors);
};
var pattern = function pattern2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value, "string") && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (!isEmptyValue(value, "string")) {
rules.pattern(rule, value, source, errors, options);
}
}
callback(errors);
};
var date = function date2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value, "date") && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
if (!isEmptyValue(value, "date")) {
var dateObject;
if (value instanceof Date) {
dateObject = value;
} else {
dateObject = new Date(value);
}
rules.type(rule, dateObject, source, errors, options);
if (dateObject) {
rules.range(rule, dateObject.getTime(), source, errors, options);
}
}
}
callback(errors);
};
var required = function required2(rule, value, callback, source, options) {
var errors = [];
var type2 = Array.isArray(value) ? "array" : typeof value;
rules.required(rule, value, source, errors, options, type2);
callback(errors);
};
var type = function type2(rule, value, callback, source, options) {
var ruleType = rule.type;
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value, ruleType) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options, ruleType);
if (!isEmptyValue(value, ruleType)) {
rules.type(rule, value, source, errors, options);
}
}
callback(errors);
};
var any = function any2(rule, value, callback, source, options) {
var errors = [];
var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field);
if (validate) {
if (isEmptyValue(value) && !rule.required) {
return callback();
}
rules.required(rule, value, source, errors, options);
}
callback(errors);
};
var validators = {
string,
method,
number,
"boolean": _boolean,
regexp,
integer,
"float": floatFn,
array,
object,
"enum": enumerable,
pattern,
date,
url: type,
hex: type,
email: type,
required,
any
};
function newMessages() {
return {
"default": "Validation error on field %s",
required: "%s is required",
"enum": "%s must be one of %s",
whitespace: "%s cannot be empty",
date: {
format: "%s date %s is invalid for format %s",
parse: "%s date could not be parsed, %s is invalid ",
invalid: "%s date %s is invalid"
},
types: {
string: "%s is not a %s",
method: "%s is not a %s (function)",
array: "%s is not an %s",
object: "%s is not an %s",
number: "%s is not a %s",
date: "%s is not a %s",
"boolean": "%s is not a %s",
integer: "%s is not an %s",
"float": "%s is not a %s",
regexp: "%s is not a valid %s",
email: "%s is not a valid %s",
url: "%s is not a valid %s",
hex: "%s is not a valid %s"
},
string: {
len: "%s must be exactly %s characters",
min: "%s must be at least %s characters",
max: "%s cannot be longer than %s characters",
range: "%s must be between %s and %s characters"
},
number: {
len: "%s must equal %s",
min: "%s cannot be less than %s",
max: "%s cannot be greater than %s",
range: "%s must be between %s and %s"
},
array: {
len: "%s must be exactly %s in length",
min: "%s cannot be less than %s in length",
max: "%s cannot be greater than %s in length",
range: "%s must be between %s and %s in length"
},
pattern: {
mismatch: "%s value %s does not match pattern %s"
},
clone: function clone() {
var cloned = JSON.parse(JSON.stringify(this));
cloned.clone = this.clone;
return cloned;
}
};
}
var messages = newMessages();
var Schema = /* @__PURE__ */ function() {
function Schema2(descriptor) {
this.rules = null;
this._messages = messages;
this.define(descriptor);
}
var _proto = Schema2.prototype;
_proto.define = function define(rules2) {
var _this = this;
if (!rules2) {
throw new Error("Cannot configure a schema with no rules");
}
if (typeof rules2 !== "object" || Array.isArray(rules2)) {
throw new Error("Rules must be an object");
}
this.rules = {};
Object.keys(rules2).forEach(function(name) {
var item = rules2[name];
_this.rules[name] = Array.isArray(item) ? item : [item];
});
};
_proto.messages = function messages2(_messages) {
if (_messages) {
this._messages = deepMerge(newMessages(), _messages);
}
return this._messages;
};
_proto.validate = function validate(source_, o, oc) {
var _this2 = this;
if (o === void 0) {
o = {};
}
if (oc === void 0) {
oc = function oc2() {
};
}
var source = source_;
var options = o;
var callback = oc;
if (typeof options === "function") {
callback = options;
options = {};
}
if (!this.rules || Object.keys(this.rules).length === 0) {
if (callback) {
callback(null, source);
}
return Promise.resolve(source);
}
function complete(results) {
var errors = [];
var fields = {};
function add(e2) {
if (Array.isArray(e2)) {
var _errors;
errors = (_errors = errors).concat.apply(_errors, e2);
} else {
errors.push(e2);
}
}
for (var i = 0; i < results.length; i++) {
add(results[i]);
}
if (!errors.length) {
callback(null, source);
} else {
fields = convertFieldsError(errors);
callback(errors, fields);
}
}
if (options.messages) {
var messages$1 = this.messages();
if (messages$1 === messages) {
messages$1 = newMessages();
}
deepMerge(messages$1, options.messages);
options.messages = messages$1;
} else {
options.messages = this.messages();
}
var series = {};
var keys = options.keys || Object.keys(this.rules);
keys.forEach(function(z2) {
var arr = _this2.rules[z2];
var value = source[z2];
arr.forEach(function(r2) {
var rule = r2;
if (typeof rule.transform === "function") {
if (source === source_) {
source = _extends({}, source);
}
value = source[z2] = rule.transform(value);
}
if (typeof rule === "function") {
rule = {
validator: rule
};
} else {
rule = _extends({}, rule);
}
rule.validator = _this2.getValidationMethod(rule);
if (!rule.validator) {
return;
}
rule.field = z2;
rule.fullField = rule.fullField || z2;
rule.type = _this2.getType(rule);
series[z2] = series[z2] || [];
series[z2].push({
rule,
value,
source,
field: z2
});
});
});
var errorFields = {};
return asyncMap(series, options, function(data, doIt) {
var rule = data.rule;
var deep = (rule.type === "object" || rule.type === "array") && (typeof rule.fields === "object" || typeof rule.defaultField === "object");
deep = deep && (rule.required || !rule.required && data.value);
rule.field = data.field;
function addFullField(key2, schema) {
return _extends({}, schema, {
fullField: rule.fullField + "." + key2,
fullFields: rule.fullFields ? [].concat(rule.fullFields, [key2]) : [key2]
});
}
function cb(e2) {
if (e2 === void 0) {
e2 = [];
}
var errorList = Array.isArray(e2) ? e2 : [e2];
if (!options.suppressWarning && errorList.length) {
Schema2.warning("async-validator:", errorList);
}
if (errorList.length && rule.message !== void 0) {
errorList = [].concat(rule.message);
}
var filledErrors = errorList.map(complementError(rule, source));
if (options.first && filledErrors.length) {
errorFields[rule.field] = 1;
return doIt(filledErrors);
}
if (!deep) {
doIt(filledErrors);
} else {
if (rule.required && !data.value) {
if (rule.message !== void 0) {
filledErrors = [].concat(rule.message).map(complementError(rule, source));
} else if (options.error) {
filledErrors = [options.error(rule, format(options.messages.required, rule.field))];
}
return doIt(filledErrors);
}
var fieldsSchema = {};
if (rule.defaultField) {
Object.keys(data.value).map(function(key2) {
fieldsSchema[key2] = rule.defaultField;
});
}
fieldsSchema = _extends({}, fieldsSchema, data.rule.fields);
var paredFieldsSchema = {};
Object.keys(fieldsSchema).forEach(function(field) {
var fieldSchema = fieldsSchema[field];
var fieldSchemaList = Array.isArray(fieldSchema) ? fieldSchema : [fieldSchema];
paredFieldsSchema[field] = fieldSchemaList.map(addFullField.bind(null, field));
});
var schema = new Schema2(paredFieldsSchema);
schema.messages(options.messages);
if (data.rule.options) {
data.rule.options.messages = options.messages;
data.rule.options.error = options.error;
}
schema.validate(data.value, data.rule.options || options, function(errs) {
var finalErrors = [];
if (filledErrors && filledErrors.length) {
finalErrors.push.apply(finalErrors, filledErrors);
}
if (errs && errs.length) {
finalErrors.push.apply(finalErrors, errs);
}
doIt(finalErrors.length ? finalErrors : null);
});
}
}
var res;
if (rule.asyncValidator) {
res = rule.asyncValidator(rule, data.value, cb, data.source, options);
} else if (rule.validator) {
try {
res = rule.validator(rule, data.value, cb, data.source, options);
} catch (error) {
console.error == null ? void 0 : console.error(error);
if (!options.suppressValidatorError) {
setTimeout(function() {
throw error;
}, 0);
}
cb(error.message);
}
if (res === true) {
cb();
} else if (res === false) {
cb(typeof rule.message === "function" ? rule.message(rule.fullField || rule.field) : rule.message || (rule.fullField || rule.field) + " fails");
} else if (res instanceof Array) {
cb(res);
} else if (res instanceof Error) {
cb(res.message);
}
}
if (res && res.then) {
res.then(function() {
return cb();
}, function(e2) {
return cb(e2);
});
}
}, function(results) {
complete(results);
}, source);
};
_proto.getType = function getType(rule) {
if (rule.type === void 0 && rule.pattern instanceof RegExp) {
rule.type = "pattern";
}
if (typeof rule.validator !== "function" && rule.type && !validators.hasOwnProperty(rule.type)) {
throw new Error(format("Unknown rule type %s", rule.type));
}
return rule.type || "string";
};
_proto.getValidationMethod = function getValidationMethod(rule) {
if (typeof rule.validator === "function") {
return rule.validator;
}
var keys = Object.keys(rule);
var messageIndex = keys.indexOf("message");
if (messageIndex !== -1) {
keys.splice(messageIndex, 1);
}
if (keys.length === 1 && keys[0] === "required") {
return validators.required;
}
return validators[this.getType(rule)] || void 0;
};
return Schema2;
}();
Schema.register = function register(type2, validator) {
if (typeof validator !== "function") {
throw new Error("Cannot register a validator by type, validator is not a function");
}
validators[type2] = validator;
};
Schema.warning = warning$1;
Schema.messages = messages;
Schema.validators = validators;
var typeTemplate$1 = "'${name}' is not a valid ${type}";
var defaultValidateMessages = {
default: "Validation error on field '${name}'",
required: "'${name}' is required",
enum: "'${name}' must be one of [${enum}]",
whitespace: "'${name}' cannot be empty",
date: {
format: "'${name}' is invalid for format date",
parse: "'${name}' could not be parsed as date",
invalid: "'${name}' is invalid date"
},
types: {
string: typeTemplate$1,
method: typeTemplate$1,
array: typeTemplate$1,
object: typeTemplate$1,
number: typeTemplate$1,
date: typeTemplate$1,
boolean: typeTemplate$1,
integer: typeTemplate$1,
float: typeTemplate$1,
regexp: typeTemplate$1,
email: typeTemplate$1,
url: typeTemplate$1,
hex: typeTemplate$1
},
string: {
len: "'${name}' must be exactly ${len} characters",
min: "'${name}' must be at least ${min} characters",
max: "'${name}' cannot be longer than ${max} characters",
range: "'${name}' must be between ${min} and ${max} characters"
},
number: {
len: "'${name}' must equal ${len}",
min: "'${name}' cannot be less than ${min}",
max: "'${name}' cannot be greater than ${max}",
range: "'${name}' must be between ${min} and ${max}"
},
array: {
len: "'${name}' must be exactly ${len} in length",
min: "'${name}' cannot be less than ${min} in length",
max: "'${name}' cannot be greater than ${max} in length",
range: "'${name}' must be between ${min} and ${max} in length"
},
pattern: {
mismatch: "'${name}' does not match pattern ${pattern}"
}
};
function get(entity, path) {
var current = entity;
for (var i = 0; i < path.length; i += 1) {
if (current === null || current === void 0) {
return void 0;
}
current = current[path[i]];
}
return current;
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr))
return arr;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _toArray(arr) {
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
}
function internalSet(entity, paths, value, removeIfUndefined) {
if (!paths.length) {
return value;
}
var _paths = _toArray(paths), path = _paths[0], restPath = _paths.slice(1);
var clone;
if (!entity && typeof path === "number") {
clone = [];
} else if (Array.isArray(entity)) {
clone = _toConsumableArray(entity);
} else {
clone = _objectSpread2({}, entity);
}
if (removeIfUndefined && value === void 0 && restPath.length === 1) {
delete clone[path][restPath[0]];
} else {
clone[path] = internalSet(clone[path], restPath, value, removeIfUndefined);
}
return clone;
}
function set(entity, paths, value) {
var removeIfUndefined = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
if (paths.length && removeIfUndefined && value === void 0 && !get(entity, paths.slice(0, -1))) {
return entity;
}
return internalSet(entity, paths, value, removeIfUndefined);
}
function cloneDeep(val) {
if (Array.isArray(val)) {
return cloneArrayDeep(val);
} else if (_typeof(val) === "object" && val !== null) {
return cloneObjectDeep(val);
}
return val;
}
function cloneObjectDeep(val) {
if (Object.getPrototypeOf(val) === Object.prototype) {
var res = {};
for (var key2 in val) {
res[key2] = cloneDeep(val[key2]);
}
return res;
}
return val;
}
function cloneArrayDeep(val) {
return val.map(function(item) {
return cloneDeep(item);
});
}
function getNamePath(path) {
return toArray(path);
}
function getValue$1(store, namePath) {
var value = get(store, namePath);
return value;
}
function setValue(store, namePath, value) {
var removeIfUndefined = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
var newStore = set(store, namePath, value, removeIfUndefined);
return newStore;
}
function cloneByNamePathList(store, namePathList) {
var newStore = {};
namePathList.forEach(function(namePath) {
var value = getValue$1(store, namePath);
newStore = setValue(newStore, namePath, value);
});
return newStore;
}
function containsNamePath(namePathList, namePath) {
return namePathList && namePathList.some(function(path) {
return matchNamePath(path, namePath);
});
}
function isObject(obj) {
return _typeof(obj) === "object" && obj !== null && Object.getPrototypeOf(obj) === Object.prototype;
}
function internalSetValues(store, values) {
var newStore = Array.isArray(store) ? _toConsumableArray(store) : _objectSpread2({}, store);
if (!values) {
return newStore;
}
Object.keys(values).forEach(function(key2) {
var prevValue = newStore[key2];
var value = values[key2];
var recursive = isObject(prevValue) && isObject(value);
newStore[key2] = recursive ? internalSetValues(prevValue, value || {}) : cloneDeep(value);
});
return newStore;
}
function setValues(store) {
for (var _len = arguments.length, restValues = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
restValues[_key - 1] = arguments[_key];
}
return restValues.reduce(function(current, newStore) {
return internalSetValues(current, newStore);
}, store);
}
function matchNamePath(namePath, changedNamePath) {
if (!namePath || !changedNamePath || namePath.length !== changedNamePath.length) {
return false;
}
return namePath.every(function(nameUnit, i) {
return changedNamePath[i] === nameUnit;
});
}
function isSimilar(source, target) {
if (source === target) {
return true;
}
if (!source && target || source && !target) {
return false;
}
if (!source || !target || _typeof(source) !== "object" || _typeof(target) !== "object") {
return false;
}
var sourceKeys = Object.keys(source);
var targetKeys = Object.keys(target);
var keys = new Set([].concat(sourceKeys, targetKeys));
return _toConsumableArray(keys).every(function(key2) {
var sourceValue = source[key2];
var targetValue = target[key2];
if (typeof sourceValue === "function" && typeof targetValue === "function") {
return true;
}
return sourceValue === targetValue;
});
}
function defaultGetValueFromEvent(valuePropName) {
var event = arguments.length <= 1 ? void 0 : arguments[1];
if (event && event.target && _typeof(event.target) === "object" && valuePropName in event.target) {
return event.target[valuePropName];
}
return event;
}
function move(array2, moveIndex, toIndex) {
var length = array2.length;
if (moveIndex < 0 || moveIndex >= length || toIndex < 0 || toIndex >= length) {
return array2;
}
var item = array2[moveIndex];
var diff = moveIndex - toIndex;
if (diff > 0) {
return [].concat(_toConsumableArray(array2.slice(0, toIndex)), [item], _toConsumableArray(array2.slice(toIndex, moveIndex)), _toConsumableArray(array2.slice(moveIndex + 1, length)));
}
if (diff < 0) {
return [].concat(_toConsumableArray(array2.slice(0, moveIndex)), _toConsumableArray(array2.slice(moveIndex + 1, toIndex + 1)), [item], _toConsumableArray(array2.slice(toIndex + 1, length)));
}
return array2;
}
var AsyncValidator = Schema;
function replaceMessage(template, kv) {
return template.replace(/\$\{\w+\}/g, function(str) {
var key2 = str.slice(2, -1);
return kv[key2];
});
}
var CODE_LOGIC_ERROR = "CODE_LOGIC_ERROR";
function validateRule(_x, _x2, _x3, _x4, _x5) {
return _validateRule.apply(this, arguments);
}
function _validateRule() {
_validateRule = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2(name, value, rule, options, messageVariables) {
var cloneRule, originValidator, subRuleField, validator, messages2, result, subResults, kv, fillVariableResult;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
cloneRule = _objectSpread2({}, rule);
delete cloneRule.ruleIndex;
if (cloneRule.validator) {
originValidator = cloneRule.validator;
cloneRule.validator = function() {
try {
return originValidator.apply(void 0, arguments);
} catch (error) {
console.error(error);
return Promise.reject(CODE_LOGIC_ERROR);
}
};
}
subRuleField = null;
if (cloneRule && cloneRule.type === "array" && cloneRule.defaultField) {
subRuleField = cloneRule.defaultField;
delete cloneRule.defaultField;
}
validator = new AsyncValidator(_defineProperty({}, name, [cloneRule]));
messages2 = setValues({}, defaultValidateMessages, options.validateMessages);
validator.messages(messages2);
result = [];
_context2.prev = 9;
_context2.next = 12;
return Promise.resolve(validator.validate(_defineProperty({}, name, value), _objectSpread2({}, options)));
case 12:
_context2.next = 17;
break;
case 14:
_context2.prev = 14;
_context2.t0 = _context2["catch"](9);
if (_context2.t0.errors) {
result = _context2.t0.errors.map(function(_ref4, index) {
var message2 = _ref4.message;
var mergedMessage = message2 === CODE_LOGIC_ERROR ? messages2.default : message2;
return /* @__PURE__ */ React__namespace.isValidElement(mergedMessage) ? /* @__PURE__ */ React__namespace.cloneElement(mergedMessage, {
key: "error_".concat(index)
}) : mergedMessage;
});
}
case 17:
if (!(!result.length && subRuleField)) {
_context2.next = 22;
break;
}
_context2.next = 20;
return Promise.all(value.map(function(subValue, i) {
return validateRule("".concat(name, ".").concat(i), subValue, subRuleField, options, messageVariables);
}));
case 20:
subResults = _context2.sent;
return _context2.abrupt("return", subResults.reduce(function(prev, errors) {
return [].concat(_toConsumableArray(prev), _toConsumableArray(errors));
}, []));
case 22:
kv = _objectSpread2(_objectSpread2({}, rule), {}, {
name,
enum: (rule.enum || []).join(", ")
}, messageVariables);
fillVariableResult = result.map(function(error) {
if (typeof error === "string") {
return replaceMessage(error, kv);
}
return error;
});
return _context2.abrupt("return", fillVariableResult);
case 25:
case "end":
return _context2.stop();
}
}
}, _callee2, null, [[9, 14]]);
}));
return _validateRule.apply(this, arguments);
}
function validateRules(namePath, value, rules2, options, validateFirst, messageVariables) {
var name = namePath.join(".");
var filledRules = rules2.map(function(currentRule, ruleIndex) {
var originValidatorFunc = currentRule.validator;
var cloneRule = _objectSpread2(_objectSpread2({}, currentRule), {}, {
ruleIndex
});
if (originValidatorFunc) {
cloneRule.validator = function(rule, val, callback) {
var hasPromise = false;
var wrappedCallback = function wrappedCallback2() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
Promise.resolve().then(function() {
warningOnce(!hasPromise, "Your validator function has already return a promise. `callback` will be ignored.");
if (!hasPromise) {
callback.apply(void 0, args);
}
});
};
var promise = originValidatorFunc(rule, val, wrappedCallback);
hasPromise = promise && typeof promise.then === "function" && typeof promise.catch === "function";
warningOnce(hasPromise, "`callback` is deprecated. Please return a promise instead.");
if (hasPromise) {
promise.then(function() {
callback();
}).catch(function(err) {
callback(err || " ");
});
}
};
}
return cloneRule;
}).sort(function(_ref, _ref2) {
var w1 = _ref.warningOnly, i1 = _ref.ruleIndex;
var w2 = _ref2.warningOnly, i2 = _ref2.ruleIndex;
if (!!w1 === !!w2) {
return i1 - i2;
}
if (w1) {
return 1;
}
return -1;
});
var summaryPromise;
if (validateFirst === true) {
summaryPromise = new Promise(/* @__PURE__ */ function() {
var _ref3 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(resolve, reject) {
var i, rule, errors;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
i = 0;
case 1:
if (!(i < filledRules.length)) {
_context.next = 12;
break;
}
rule = filledRules[i];
_context.next = 5;
return validateRule(name, value, rule, options, messageVariables);
case 5:
errors = _context.sent;
if (!errors.length) {
_context.next = 9;
break;
}
reject([{
errors,
rule
}]);
return _context.abrupt("return");
case 9:
i += 1;
_context.next = 1;
break;
case 12:
resolve([]);
case 13:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function(_x6, _x7) {
return _ref3.apply(this, arguments);
};
}());
} else {
var rulePromises = filledRules.map(function(rule) {
return validateRule(name, value, rule, options, messageVariables).then(function(errors) {
return {
errors,
rule
};
});
});
summaryPromise = (validateFirst ? finishOnFirstFailed(rulePromises) : finishOnAllFailed(rulePromises)).then(function(errors) {
return Promise.reject(errors);
});
}
summaryPromise.catch(function(e2) {
return e2;
});
return summaryPromise;
}
function finishOnAllFailed(_x8) {
return _finishOnAllFailed.apply(this, arguments);
}
function _finishOnAllFailed() {
_finishOnAllFailed = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee3(rulePromises) {
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
return _context3.abrupt("return", Promise.all(rulePromises).then(function(errorsList) {
var _ref5;
var errors = (_ref5 = []).concat.apply(_ref5, _toConsumableArray(errorsList));
return errors;
}));
case 1:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
return _finishOnAllFailed.apply(this, arguments);
}
function finishOnFirstFailed(_x9) {
return _finishOnFirstFailed.apply(this, arguments);
}
function _finishOnFirstFailed() {
_finishOnFirstFailed = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee4(rulePromises) {
var count;
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
count = 0;
return _context4.abrupt("return", new Promise(function(resolve) {
rulePromises.forEach(function(promise) {
promise.then(function(ruleError) {
if (ruleError.errors.length) {
resolve([ruleError]);
}
count += 1;
if (count === rulePromises.length) {
resolve([]);
}
});
});
}));
case 2:
case "end":
return _context4.stop();
}
}
}, _callee4);
}));
return _finishOnFirstFailed.apply(this, arguments);
}
var _excluded$6 = ["name"];
var EMPTY_ERRORS = [];
function requireUpdate(shouldUpdate, prev, next2, prevValue, nextValue, info) {
if (typeof shouldUpdate === "function") {
return shouldUpdate(prev, next2, "source" in info ? {
source: info.source
} : {});
}
return prevValue !== nextValue;
}
var Field = /* @__PURE__ */ function(_React$Component) {
_inherits(Field2, _React$Component);
var _super = _createSuper(Field2);
function Field2(props) {
var _this;
_classCallCheck(this, Field2);
_this = _super.call(this, props);
_this.state = {
resetCount: 0
};
_this.cancelRegisterFunc = null;
_this.mounted = false;
_this.touched = false;
_this.dirty = false;
_this.validatePromise = null;
_this.prevValidating = void 0;
_this.errors = EMPTY_ERRORS;
_this.warnings = EMPTY_ERRORS;
_this.cancelRegister = function() {
var _this$props = _this.props, preserve = _this$props.preserve, isListField = _this$props.isListField, name = _this$props.name;
if (_this.cancelRegisterFunc) {
_this.cancelRegisterFunc(isListField, preserve, getNamePath(name));
}
_this.cancelRegisterFunc = null;
};
_this.getNamePath = function() {
var _this$props2 = _this.props, name = _this$props2.name, fieldContext = _this$props2.fieldContext;
var _fieldContext$prefixN = fieldContext.prefixName, prefixName = _fieldContext$prefixN === void 0 ? [] : _fieldContext$prefixN;
return name !== void 0 ? [].concat(_toConsumableArray(prefixName), _toConsumableArray(name)) : [];
};
_this.getRules = function() {
var _this$props3 = _this.props, _this$props3$rules = _this$props3.rules, rules2 = _this$props3$rules === void 0 ? [] : _this$props3$rules, fieldContext = _this$props3.fieldContext;
return rules2.map(function(rule) {
if (typeof rule === "function") {
return rule(fieldContext);
}
return rule;
});
};
_this.refresh = function() {
if (!_this.mounted)
return;
_this.setState(function(_ref) {
var resetCount = _ref.resetCount;
return {
resetCount: resetCount + 1
};
});
};
_this.triggerMetaEvent = function(destroy) {
var onMetaChange = _this.props.onMetaChange;
onMetaChange === null || onMetaChange === void 0 ? void 0 : onMetaChange(_objectSpread2(_objectSpread2({}, _this.getMeta()), {}, {
destroy
}));
};
_this.onStoreChange = function(prevStore, namePathList, info) {
var _this$props4 = _this.props, shouldUpdate = _this$props4.shouldUpdate, _this$props4$dependen = _this$props4.dependencies, dependencies = _this$props4$dependen === void 0 ? [] : _this$props4$dependen, onReset = _this$props4.onReset;
var store = info.store;
var namePath = _this.getNamePath();
var prevValue = _this.getValue(prevStore);
var curValue = _this.getValue(store);
var namePathMatch = namePathList && containsNamePath(namePathList, namePath);
if (info.type === "valueUpdate" && info.source === "external" && prevValue !== curValue) {
_this.touched = true;
_this.dirty = true;
_this.validatePromise = null;
_this.errors = EMPTY_ERRORS;
_this.warnings = EMPTY_ERRORS;
_this.triggerMetaEvent();
}
switch (info.type) {
case "reset":
if (!namePathList || namePathMatch) {
_this.touched = false;
_this.dirty = false;
_this.validatePromise = null;
_this.errors = EMPTY_ERRORS;
_this.warnings = EMPTY_ERRORS;
_this.triggerMetaEvent();
onReset === null || onReset === void 0 ? void 0 : onReset();
_this.refresh();
return;
}
break;
case "remove": {
if (shouldUpdate) {
_this.reRender();
return;
}
break;
}
case "setField": {
if (namePathMatch) {
var data = info.data;
if ("touched" in data) {
_this.touched = data.touched;
}
if ("validating" in data && !("originRCField" in data)) {
_this.validatePromise = data.validating ? Promise.resolve([]) : null;
}
if ("errors" in data) {
_this.errors = data.errors || EMPTY_ERRORS;
}
if ("warnings" in data) {
_this.warnings = data.warnings || EMPTY_ERRORS;
}
_this.dirty = true;
_this.triggerMetaEvent();
_this.reRender();
return;
}
if (shouldUpdate && !namePath.length && requireUpdate(shouldUpdate, prevStore, store, prevValue, curValue, info)) {
_this.reRender();
return;
}
break;
}
case "dependenciesUpdate": {
var dependencyList = dependencies.map(getNamePath);
if (dependencyList.some(function(dependency) {
return containsNamePath(info.relatedFields, dependency);
})) {
_this.reRender();
return;
}
break;
}
default:
if (namePathMatch || (!dependencies.length || namePath.length || shouldUpdate) && requireUpdate(shouldUpdate, prevStore, store, prevValue, curValue, info)) {
_this.reRender();
return;
}
break;
}
if (shouldUpdate === true) {
_this.reRender();
}
};
_this.validateRules = function(options) {
var namePath = _this.getNamePath();
var currentValue = _this.getValue();
var rootPromise = Promise.resolve().then(function() {
if (!_this.mounted) {
return [];
}
var _this$props5 = _this.props, _this$props5$validate = _this$props5.validateFirst, validateFirst = _this$props5$validate === void 0 ? false : _this$props5$validate, messageVariables = _this$props5.messageVariables;
var _ref2 = options || {}, triggerName = _ref2.triggerName;
var filteredRules = _this.getRules();
if (triggerName) {
filteredRules = filteredRules.filter(function(rule) {
return rule;
}).filter(function(rule) {
var validateTrigger = rule.validateTrigger;
if (!validateTrigger) {
return true;
}
var triggerList = toArray(validateTrigger);
return triggerList.includes(triggerName);
});
}
var promise = validateRules(namePath, currentValue, filteredRules, options, validateFirst, messageVariables);
promise.catch(function(e2) {
return e2;
}).then(function() {
var ruleErrors = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : EMPTY_ERRORS;
if (_this.validatePromise === rootPromise) {
var _ruleErrors$forEach;
_this.validatePromise = null;
var nextErrors = [];
var nextWarnings = [];
(_ruleErrors$forEach = ruleErrors.forEach) === null || _ruleErrors$forEach === void 0 ? void 0 : _ruleErrors$forEach.call(ruleErrors, function(_ref3) {
var warningOnly = _ref3.rule.warningOnly, _ref3$errors = _ref3.errors, errors = _ref3$errors === void 0 ? EMPTY_ERRORS : _ref3$errors;
if (warningOnly) {
nextWarnings.push.apply(nextWarnings, _toConsumableArray(errors));
} else {
nextErrors.push.apply(nextErrors, _toConsumableArray(errors));
}
});
_this.errors = nextErrors;
_this.warnings = nextWarnings;
_this.triggerMetaEvent();
_this.reRender();
}
});
return promise;
});
_this.validatePromise = rootPromise;
_this.dirty = true;
_this.errors = EMPTY_ERRORS;
_this.warnings = EMPTY_ERRORS;
_this.triggerMetaEvent();
_this.reRender();
return rootPromise;
};
_this.isFieldValidating = function() {
return !!_this.validatePromise;
};
_this.isFieldTouched = function() {
return _this.touched;
};
_this.isFieldDirty = function() {
if (_this.dirty || _this.props.initialValue !== void 0) {
return true;
}
var fieldContext = _this.props.fieldContext;
var _fieldContext$getInte = fieldContext.getInternalHooks(HOOK_MARK), getInitialValue = _fieldContext$getInte.getInitialValue;
if (getInitialValue(_this.getNamePath()) !== void 0) {
return true;
}
return false;
};
_this.getErrors = function() {
return _this.errors;
};
_this.getWarnings = function() {
return _this.warnings;
};
_this.isListField = function() {
return _this.props.isListField;
};
_this.isList = function() {
return _this.props.isList;
};
_this.isPreserve = function() {
return _this.props.preserve;
};
_this.getMeta = function() {
_this.prevValidating = _this.isFieldValidating();
var meta = {
touched: _this.isFieldTouched(),
validating: _this.prevValidating,
errors: _this.errors,
warnings: _this.warnings,
name: _this.getNamePath()
};
return meta;
};
_this.getOnlyChild = function(children) {
if (typeof children === "function") {
var meta = _this.getMeta();
return _objectSpread2(_objectSpread2({}, _this.getOnlyChild(children(_this.getControlled(), meta, _this.props.fieldContext))), {}, {
isFunction: true
});
}
var childList = toArray$1(children);
if (childList.length !== 1 || !/* @__PURE__ */ React__namespace.isValidElement(childList[0])) {
return {
child: childList,
isFunction: false
};
}
return {
child: childList[0],
isFunction: false
};
};
_this.getValue = function(store) {
var getFieldsValue = _this.props.fieldContext.getFieldsValue;
var namePath = _this.getNamePath();
return getValue$1(store || getFieldsValue(true), namePath);
};
_this.getControlled = function() {
var childProps = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
var _this$props6 = _this.props, trigger = _this$props6.trigger, validateTrigger = _this$props6.validateTrigger, getValueFromEvent = _this$props6.getValueFromEvent, normalize2 = _this$props6.normalize, valuePropName = _this$props6.valuePropName, getValueProps = _this$props6.getValueProps, fieldContext = _this$props6.fieldContext;
var mergedValidateTrigger = validateTrigger !== void 0 ? validateTrigger : fieldContext.validateTrigger;
var namePath = _this.getNamePath();
var getInternalHooks2 = fieldContext.getInternalHooks, getFieldsValue = fieldContext.getFieldsValue;
var _getInternalHooks = getInternalHooks2(HOOK_MARK), dispatch = _getInternalHooks.dispatch;
var value = _this.getValue();
var mergedGetValueProps = getValueProps || function(val) {
return _defineProperty({}, valuePropName, val);
};
var originTriggerFunc = childProps[trigger];
var control = _objectSpread2(_objectSpread2({}, childProps), mergedGetValueProps(value));
control[trigger] = function() {
_this.touched = true;
_this.dirty = true;
_this.triggerMetaEvent();
var newValue;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (getValueFromEvent) {
newValue = getValueFromEvent.apply(void 0, args);
} else {
newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat(args));
}
if (normalize2) {
newValue = normalize2(newValue, value, getFieldsValue(true));
}
dispatch({
type: "updateValue",
namePath,
value: newValue
});
if (originTriggerFunc) {
originTriggerFunc.apply(void 0, args);
}
};
var validateTriggerList = toArray(mergedValidateTrigger || []);
validateTriggerList.forEach(function(triggerName) {
var originTrigger = control[triggerName];
control[triggerName] = function() {
if (originTrigger) {
originTrigger.apply(void 0, arguments);
}
var rules2 = _this.props.rules;
if (rules2 && rules2.length) {
dispatch({
type: "validateField",
namePath,
triggerName
});
}
};
});
return control;
};
if (props.fieldContext) {
var getInternalHooks = props.fieldContext.getInternalHooks;
var _getInternalHooks2 = getInternalHooks(HOOK_MARK), initEntityValue = _getInternalHooks2.initEntityValue;
initEntityValue(_assertThisInitialized(_this));
}
return _this;
}
_createClass(Field2, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this$props7 = this.props, shouldUpdate = _this$props7.shouldUpdate, fieldContext = _this$props7.fieldContext;
this.mounted = true;
if (fieldContext) {
var getInternalHooks = fieldContext.getInternalHooks;
var _getInternalHooks3 = getInternalHooks(HOOK_MARK), registerField = _getInternalHooks3.registerField;
this.cancelRegisterFunc = registerField(this);
}
if (shouldUpdate === true) {
this.reRender();
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.cancelRegister();
this.triggerMetaEvent(true);
this.mounted = false;
}
}, {
key: "reRender",
value: function reRender() {
if (!this.mounted)
return;
this.forceUpdate();
}
}, {
key: "render",
value: function render2() {
this.state.resetCount;
var children = this.props.children;
var _this$getOnlyChild = this.getOnlyChild(children), child = _this$getOnlyChild.child, isFunction = _this$getOnlyChild.isFunction;
var returnChildNode;
if (isFunction) {
returnChildNode = child;
} else if (/* @__PURE__ */ React__namespace.isValidElement(child)) {
returnChildNode = /* @__PURE__ */ React__namespace.cloneElement(child, this.getControlled(child.props));
} else {
warningOnce(!child, "`children` of Field is not validate ReactElement.");
returnChildNode = child;
}
return /* @__PURE__ */ jsx(Fragment, {
children: returnChildNode
});
}
}]);
return Field2;
}(React__namespace.Component);
Field.contextType = Context;
Field.defaultProps = {
trigger: "onChange",
valuePropName: "value"
};
function WrapperField(_ref5) {
var name = _ref5.name, restProps = _objectWithoutProperties(_ref5, _excluded$6);
var fieldContext = React__namespace.useContext(Context);
var namePath = name !== void 0 ? getNamePath(name) : void 0;
var key2 = "keep";
if (!restProps.isListField) {
key2 = "_".concat((namePath || []).join("_"));
}
return /* @__PURE__ */ jsx(Field, {
name: namePath,
...restProps,
fieldContext
}, key2);
}
var ListContext = /* @__PURE__ */ React__namespace.createContext(null);
var List = function List2(_ref) {
var name = _ref.name, initialValue = _ref.initialValue, children = _ref.children, rules2 = _ref.rules, validateTrigger = _ref.validateTrigger;
var context = React__namespace.useContext(Context);
var keyRef = React__namespace.useRef({
keys: [],
id: 0
});
var keyManager = keyRef.current;
var prefixName = React__namespace.useMemo(function() {
var parentPrefixName = getNamePath(context.prefixName) || [];
return [].concat(_toConsumableArray(parentPrefixName), _toConsumableArray(getNamePath(name)));
}, [context.prefixName, name]);
var fieldContext = React__namespace.useMemo(function() {
return _objectSpread2(_objectSpread2({}, context), {}, {
prefixName
});
}, [context, prefixName]);
var listContext = React__namespace.useMemo(function() {
return {
getKey: function getKey(namePath) {
var len = prefixName.length;
var pathName = namePath[len];
return [keyManager.keys[pathName], namePath.slice(len + 1)];
}
};
}, [prefixName]);
if (typeof children !== "function") {
warningOnce(false, "Form.List only accepts function as children.");
return null;
}
var shouldUpdate = function shouldUpdate2(prevValue, nextValue, _ref2) {
var source = _ref2.source;
if (source === "internal") {
return false;
}
return prevValue !== nextValue;
};
return /* @__PURE__ */ jsx(ListContext.Provider, {
value: listContext,
children: /* @__PURE__ */ jsx(Context.Provider, {
value: fieldContext,
children: /* @__PURE__ */ jsx(WrapperField, {
name: [],
shouldUpdate,
rules: rules2,
validateTrigger,
initialValue,
isList: true,
children: function(_ref3, meta) {
var _ref3$value = _ref3.value, value = _ref3$value === void 0 ? [] : _ref3$value, onChange = _ref3.onChange;
var getFieldValue = context.getFieldValue;
var getNewValue = function getNewValue2() {
var values = getFieldValue(prefixName || []);
return values || [];
};
var operations = {
add: function add(defaultValue, index) {
var newValue = getNewValue();
if (index >= 0 && index <= newValue.length) {
keyManager.keys = [].concat(_toConsumableArray(keyManager.keys.slice(0, index)), [keyManager.id], _toConsumableArray(keyManager.keys.slice(index)));
onChange([].concat(_toConsumableArray(newValue.slice(0, index)), [defaultValue], _toConsumableArray(newValue.slice(index))));
} else {
keyManager.keys = [].concat(_toConsumableArray(keyManager.keys), [keyManager.id]);
onChange([].concat(_toConsumableArray(newValue), [defaultValue]));
}
keyManager.id += 1;
},
remove: function remove2(index) {
var newValue = getNewValue();
var indexSet = new Set(Array.isArray(index) ? index : [index]);
if (indexSet.size <= 0) {
return;
}
keyManager.keys = keyManager.keys.filter(function(_, keysIndex) {
return !indexSet.has(keysIndex);
});
onChange(newValue.filter(function(_, valueIndex) {
return !indexSet.has(valueIndex);
}));
},
move: function move$1(from, to) {
if (from === to) {
return;
}
var newValue = getNewValue();
if (from < 0 || from >= newValue.length || to < 0 || to >= newValue.length) {
return;
}
keyManager.keys = move(keyManager.keys, from, to);
onChange(move(newValue, from, to));
}
};
var listValue = value || [];
if (!Array.isArray(listValue)) {
listValue = [];
}
return children(listValue.map(function(__, index) {
var key2 = keyManager.keys[index];
if (key2 === void 0) {
keyManager.keys[index] = keyManager.id;
key2 = keyManager.keys[index];
keyManager.id += 1;
}
return {
name: index,
key: key2,
isListField: true
};
}), operations, meta);
}
})
})
});
};
function _iterableToArrayLimit(arr, i) {
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
if (null != _i) {
var _s, _e, _x, _r, _arr = [], _n = true, _d = false;
try {
if (_x = (_i = _i.call(arr)).next, 0 === i) {
if (Object(_i) !== _i)
return;
_n = false;
} else
for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = true)
;
} catch (err) {
_d = true, _e = err;
} finally {
try {
if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r))
return;
} finally {
if (_d)
throw _e;
}
}
return _arr;
}
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function allPromiseFinish(promiseList) {
var hasError = false;
var count = promiseList.length;
var results = [];
if (!promiseList.length) {
return Promise.resolve([]);
}
return new Promise(function(resolve, reject) {
promiseList.forEach(function(promise, index) {
promise.catch(function(e2) {
hasError = true;
return e2;
}).then(function(result) {
count -= 1;
results[index] = result;
if (count > 0) {
return;
}
if (hasError) {
reject(results);
}
resolve(results);
});
});
});
}
var SPLIT = "__@field_split__";
function normalize(namePath) {
return namePath.map(function(cell2) {
return "".concat(_typeof(cell2), ":").concat(cell2);
}).join(SPLIT);
}
var NameMap = /* @__PURE__ */ function() {
function NameMap2() {
_classCallCheck(this, NameMap2);
this.kvs = /* @__PURE__ */ new Map();
}
_createClass(NameMap2, [{
key: "set",
value: function set2(key2, value) {
this.kvs.set(normalize(key2), value);
}
}, {
key: "get",
value: function get2(key2) {
return this.kvs.get(normalize(key2));
}
}, {
key: "update",
value: function update(key2, updater) {
var origin = this.get(key2);
var next2 = updater(origin);
if (!next2) {
this.delete(key2);
} else {
this.set(key2, next2);
}
}
}, {
key: "delete",
value: function _delete(key2) {
this.kvs.delete(normalize(key2));
}
}, {
key: "map",
value: function map(callback) {
return _toConsumableArray(this.kvs.entries()).map(function(_ref) {
var _ref2 = _slicedToArray(_ref, 2), key2 = _ref2[0], value = _ref2[1];
var cells = key2.split(SPLIT);
return callback({
key: cells.map(function(cell2) {
var _cell$match = cell2.match(/^([^:]*):(.*)$/), _cell$match2 = _slicedToArray(_cell$match, 3), type2 = _cell$match2[1], unit = _cell$match2[2];
return type2 === "number" ? Number(unit) : unit;
}),
value
});
});
}
}, {
key: "toJSON",
value: function toJSON() {
var json = {};
this.map(function(_ref3) {
var key2 = _ref3.key, value = _ref3.value;
json[key2.join(".")] = value;
return null;
});
return json;
}
}]);
return NameMap2;
}();
var _excluded$5 = ["name", "errors"];
var FormStore = /* @__PURE__ */ _createClass(function FormStore2(forceRootUpdate) {
var _this = this;
_classCallCheck(this, FormStore2);
this.formHooked = false;
this.forceRootUpdate = void 0;
this.subscribable = true;
this.store = {};
this.fieldEntities = [];
this.initialValues = {};
this.callbacks = {};
this.validateMessages = null;
this.preserve = null;
this.lastValidatePromise = null;
this.getForm = function() {
return {
getFieldValue: _this.getFieldValue,
getFieldsValue: _this.getFieldsValue,
getFieldError: _this.getFieldError,
getFieldWarning: _this.getFieldWarning,
getFieldsError: _this.getFieldsError,
isFieldsTouched: _this.isFieldsTouched,
isFieldTouched: _this.isFieldTouched,
isFieldValidating: _this.isFieldValidating,
isFieldsValidating: _this.isFieldsValidating,
resetFields: _this.resetFields,
setFields: _this.setFields,
setFieldValue: _this.setFieldValue,
setFieldsValue: _this.setFieldsValue,
validateFields: _this.validateFields,
submit: _this.submit,
_init: true,
getInternalHooks: _this.getInternalHooks
};
};
this.getInternalHooks = function(key2) {
if (key2 === HOOK_MARK) {
_this.formHooked = true;
return {
dispatch: _this.dispatch,
initEntityValue: _this.initEntityValue,
registerField: _this.registerField,
useSubscribe: _this.useSubscribe,
setInitialValues: _this.setInitialValues,
destroyForm: _this.destroyForm,
setCallbacks: _this.setCallbacks,
setValidateMessages: _this.setValidateMessages,
getFields: _this.getFields,
setPreserve: _this.setPreserve,
getInitialValue: _this.getInitialValue,
registerWatch: _this.registerWatch
};
}
warningOnce(false, "`getInternalHooks` is internal usage. Should not call directly.");
return null;
};
this.useSubscribe = function(subscribable) {
_this.subscribable = subscribable;
};
this.prevWithoutPreserves = null;
this.setInitialValues = function(initialValues, init) {
_this.initialValues = initialValues || {};
if (init) {
var _this$prevWithoutPres;
var nextStore = setValues({}, initialValues, _this.store);
(_this$prevWithoutPres = _this.prevWithoutPreserves) === null || _this$prevWithoutPres === void 0 ? void 0 : _this$prevWithoutPres.map(function(_ref) {
var namePath = _ref.key;
nextStore = setValue(nextStore, namePath, getValue$1(initialValues, namePath));
});
_this.prevWithoutPreserves = null;
_this.updateStore(nextStore);
}
};
this.destroyForm = function() {
var prevWithoutPreserves = new NameMap();
_this.getFieldEntities(true).forEach(function(entity) {
if (!_this.isMergedPreserve(entity.isPreserve())) {
prevWithoutPreserves.set(entity.getNamePath(), true);
}
});
_this.prevWithoutPreserves = prevWithoutPreserves;
};
this.getInitialValue = function(namePath) {
var initValue = getValue$1(_this.initialValues, namePath);
return namePath.length ? cloneDeep(initValue) : initValue;
};
this.setCallbacks = function(callbacks) {
_this.callbacks = callbacks;
};
this.setValidateMessages = function(validateMessages) {
_this.validateMessages = validateMessages;
};
this.setPreserve = function(preserve) {
_this.preserve = preserve;
};
this.watchList = [];
this.registerWatch = function(callback) {
_this.watchList.push(callback);
return function() {
_this.watchList = _this.watchList.filter(function(fn) {
return fn !== callback;
});
};
};
this.notifyWatch = function() {
var namePath = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
if (_this.watchList.length) {
var values = _this.getFieldsValue();
_this.watchList.forEach(function(callback) {
callback(values, namePath);
});
}
};
this.timeoutId = null;
this.warningUnhooked = function() {
};
this.updateStore = function(nextStore) {
_this.store = nextStore;
};
this.getFieldEntities = function() {
var pure = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
if (!pure) {
return _this.fieldEntities;
}
return _this.fieldEntities.filter(function(field) {
return field.getNamePath().length;
});
};
this.getFieldsMap = function() {
var pure = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
var cache = new NameMap();
_this.getFieldEntities(pure).forEach(function(field) {
var namePath = field.getNamePath();
cache.set(namePath, field);
});
return cache;
};
this.getFieldEntitiesForNamePathList = function(nameList) {
if (!nameList) {
return _this.getFieldEntities(true);
}
var cache = _this.getFieldsMap(true);
return nameList.map(function(name) {
var namePath = getNamePath(name);
return cache.get(namePath) || {
INVALIDATE_NAME_PATH: getNamePath(name)
};
});
};
this.getFieldsValue = function(nameList, filterFunc) {
_this.warningUnhooked();
if (nameList === true && !filterFunc) {
return _this.store;
}
var fieldEntities = _this.getFieldEntitiesForNamePathList(Array.isArray(nameList) ? nameList : null);
var filteredNameList = [];
fieldEntities.forEach(function(entity) {
var _entity$isListField;
var namePath = "INVALIDATE_NAME_PATH" in entity ? entity.INVALIDATE_NAME_PATH : entity.getNamePath();
if (!nameList && ((_entity$isListField = entity.isListField) === null || _entity$isListField === void 0 ? void 0 : _entity$isListField.call(entity))) {
return;
}
if (!filterFunc) {
filteredNameList.push(namePath);
} else {
var meta = "getMeta" in entity ? entity.getMeta() : null;
if (filterFunc(meta)) {
filteredNameList.push(namePath);
}
}
});
return cloneByNamePathList(_this.store, filteredNameList.map(getNamePath));
};
this.getFieldValue = function(name) {
_this.warningUnhooked();
var namePath = getNamePath(name);
return getValue$1(_this.store, namePath);
};
this.getFieldsError = function(nameList) {
_this.warningUnhooked();
var fieldEntities = _this.getFieldEntitiesForNamePathList(nameList);
return fieldEntities.map(function(entity, index) {
if (entity && !("INVALIDATE_NAME_PATH" in entity)) {
return {
name: entity.getNamePath(),
errors: entity.getErrors(),
warnings: entity.getWarnings()
};
}
return {
name: getNamePath(nameList[index]),
errors: [],
warnings: []
};
});
};
this.getFieldError = function(name) {
_this.warningUnhooked();
var namePath = getNamePath(name);
var fieldError = _this.getFieldsError([namePath])[0];
return fieldError.errors;
};
this.getFieldWarning = function(name) {
_this.warningUnhooked();
var namePath = getNamePath(name);
var fieldError = _this.getFieldsError([namePath])[0];
return fieldError.warnings;
};
this.isFieldsTouched = function() {
_this.warningUnhooked();
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var arg0 = args[0], arg1 = args[1];
var namePathList;
var isAllFieldsTouched = false;
if (args.length === 0) {
namePathList = null;
} else if (args.length === 1) {
if (Array.isArray(arg0)) {
namePathList = arg0.map(getNamePath);
isAllFieldsTouched = false;
} else {
namePathList = null;
isAllFieldsTouched = arg0;
}
} else {
namePathList = arg0.map(getNamePath);
isAllFieldsTouched = arg1;
}
var fieldEntities = _this.getFieldEntities(true);
var isFieldTouched = function isFieldTouched2(field) {
return field.isFieldTouched();
};
if (!namePathList) {
return isAllFieldsTouched ? fieldEntities.every(isFieldTouched) : fieldEntities.some(isFieldTouched);
}
var map = new NameMap();
namePathList.forEach(function(shortNamePath) {
map.set(shortNamePath, []);
});
fieldEntities.forEach(function(field) {
var fieldNamePath = field.getNamePath();
namePathList.forEach(function(shortNamePath) {
if (shortNamePath.every(function(nameUnit, i) {
return fieldNamePath[i] === nameUnit;
})) {
map.update(shortNamePath, function(list) {
return [].concat(_toConsumableArray(list), [field]);
});
}
});
});
var isNamePathListTouched = function isNamePathListTouched2(entities) {
return entities.some(isFieldTouched);
};
var namePathListEntities = map.map(function(_ref2) {
var value = _ref2.value;
return value;
});
return isAllFieldsTouched ? namePathListEntities.every(isNamePathListTouched) : namePathListEntities.some(isNamePathListTouched);
};
this.isFieldTouched = function(name) {
_this.warningUnhooked();
return _this.isFieldsTouched([name]);
};
this.isFieldsValidating = function(nameList) {
_this.warningUnhooked();
var fieldEntities = _this.getFieldEntities();
if (!nameList) {
return fieldEntities.some(function(testField) {
return testField.isFieldValidating();
});
}
var namePathList = nameList.map(getNamePath);
return fieldEntities.some(function(testField) {
var fieldNamePath = testField.getNamePath();
return containsNamePath(namePathList, fieldNamePath) && testField.isFieldValidating();
});
};
this.isFieldValidating = function(name) {
_this.warningUnhooked();
return _this.isFieldsValidating([name]);
};
this.resetWithFieldInitialValue = function() {
var info = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
var cache = new NameMap();
var fieldEntities = _this.getFieldEntities(true);
fieldEntities.forEach(function(field) {
var initialValue = field.props.initialValue;
var namePath = field.getNamePath();
if (initialValue !== void 0) {
var records = cache.get(namePath) || /* @__PURE__ */ new Set();
records.add({
entity: field,
value: initialValue
});
cache.set(namePath, records);
}
});
var resetWithFields = function resetWithFields2(entities) {
entities.forEach(function(field) {
var initialValue = field.props.initialValue;
if (initialValue !== void 0) {
var namePath = field.getNamePath();
var formInitialValue = _this.getInitialValue(namePath);
if (formInitialValue !== void 0) {
warningOnce(false, "Form already set 'initialValues' with path '".concat(namePath.join("."), "'. Field can not overwrite it."));
} else {
var records = cache.get(namePath);
if (records && records.size > 1) {
warningOnce(false, "Multiple Field with path '".concat(namePath.join("."), "' set 'initialValue'. Can not decide which one to pick."));
} else if (records) {
var originValue = _this.getFieldValue(namePath);
if (!info.skipExist || originValue === void 0) {
_this.updateStore(setValue(_this.store, namePath, _toConsumableArray(records)[0].value));
}
}
}
}
});
};
var requiredFieldEntities;
if (info.entities) {
requiredFieldEntities = info.entities;
} else if (info.namePathList) {
requiredFieldEntities = [];
info.namePathList.forEach(function(namePath) {
var records = cache.get(namePath);
if (records) {
var _requiredFieldEntitie;
(_requiredFieldEntitie = requiredFieldEntities).push.apply(_requiredFieldEntitie, _toConsumableArray(_toConsumableArray(records).map(function(r2) {
return r2.entity;
})));
}
});
} else {
requiredFieldEntities = fieldEntities;
}
resetWithFields(requiredFieldEntities);
};
this.resetFields = function(nameList) {
_this.warningUnhooked();
var prevStore = _this.store;
if (!nameList) {
_this.updateStore(setValues({}, _this.initialValues));
_this.resetWithFieldInitialValue();
_this.notifyObservers(prevStore, null, {
type: "reset"
});
_this.notifyWatch();
return;
}
var namePathList = nameList.map(getNamePath);
namePathList.forEach(function(namePath) {
var initialValue = _this.getInitialValue(namePath);
_this.updateStore(setValue(_this.store, namePath, initialValue));
});
_this.resetWithFieldInitialValue({
namePathList
});
_this.notifyObservers(prevStore, namePathList, {
type: "reset"
});
_this.notifyWatch(namePathList);
};
this.setFields = function(fields) {
_this.warningUnhooked();
var prevStore = _this.store;
var namePathList = [];
fields.forEach(function(fieldData) {
var name = fieldData.name;
fieldData.errors;
var data = _objectWithoutProperties(fieldData, _excluded$5);
var namePath = getNamePath(name);
namePathList.push(namePath);
if ("value" in data) {
_this.updateStore(setValue(_this.store, namePath, data.value));
}
_this.notifyObservers(prevStore, [namePath], {
type: "setField",
data: fieldData
});
});
_this.notifyWatch(namePathList);
};
this.getFields = function() {
var entities = _this.getFieldEntities(true);
var fields = entities.map(function(field) {
var namePath = field.getNamePath();
var meta = field.getMeta();
var fieldData = _objectSpread2(_objectSpread2({}, meta), {}, {
name: namePath,
value: _this.getFieldValue(namePath)
});
Object.defineProperty(fieldData, "originRCField", {
value: true
});
return fieldData;
});
return fields;
};
this.initEntityValue = function(entity) {
var initialValue = entity.props.initialValue;
if (initialValue !== void 0) {
var namePath = entity.getNamePath();
var prevValue = getValue$1(_this.store, namePath);
if (prevValue === void 0) {
_this.updateStore(setValue(_this.store, namePath, initialValue));
}
}
};
this.isMergedPreserve = function(fieldPreserve) {
var mergedPreserve = fieldPreserve !== void 0 ? fieldPreserve : _this.preserve;
return mergedPreserve !== null && mergedPreserve !== void 0 ? mergedPreserve : true;
};
this.registerField = function(entity) {
_this.fieldEntities.push(entity);
var namePath = entity.getNamePath();
_this.notifyWatch([namePath]);
if (entity.props.initialValue !== void 0) {
var prevStore = _this.store;
_this.resetWithFieldInitialValue({
entities: [entity],
skipExist: true
});
_this.notifyObservers(prevStore, [entity.getNamePath()], {
type: "valueUpdate",
source: "internal"
});
}
return function(isListField, preserve) {
var subNamePath = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
_this.fieldEntities = _this.fieldEntities.filter(function(item) {
return item !== entity;
});
if (!_this.isMergedPreserve(preserve) && (!isListField || subNamePath.length > 1)) {
var defaultValue = isListField ? void 0 : _this.getInitialValue(namePath);
if (namePath.length && _this.getFieldValue(namePath) !== defaultValue && _this.fieldEntities.every(function(field) {
return !matchNamePath(field.getNamePath(), namePath);
})) {
var _prevStore = _this.store;
_this.updateStore(setValue(_prevStore, namePath, defaultValue, true));
_this.notifyObservers(_prevStore, [namePath], {
type: "remove"
});
_this.triggerDependenciesUpdate(_prevStore, namePath);
}
}
_this.notifyWatch([namePath]);
};
};
this.dispatch = function(action) {
switch (action.type) {
case "updateValue": {
var namePath = action.namePath, value = action.value;
_this.updateValue(namePath, value);
break;
}
case "validateField": {
var _namePath = action.namePath, triggerName = action.triggerName;
_this.validateFields([_namePath], {
triggerName
});
break;
}
}
};
this.notifyObservers = function(prevStore, namePathList, info) {
if (_this.subscribable) {
var mergedInfo = _objectSpread2(_objectSpread2({}, info), {}, {
store: _this.getFieldsValue(true)
});
_this.getFieldEntities().forEach(function(_ref3) {
var onStoreChange = _ref3.onStoreChange;
onStoreChange(prevStore, namePathList, mergedInfo);
});
} else {
_this.forceRootUpdate();
}
};
this.triggerDependenciesUpdate = function(prevStore, namePath) {
var childrenFields = _this.getDependencyChildrenFields(namePath);
if (childrenFields.length) {
_this.validateFields(childrenFields);
}
_this.notifyObservers(prevStore, childrenFields, {
type: "dependenciesUpdate",
relatedFields: [namePath].concat(_toConsumableArray(childrenFields))
});
return childrenFields;
};
this.updateValue = function(name, value) {
var namePath = getNamePath(name);
var prevStore = _this.store;
_this.updateStore(setValue(_this.store, namePath, value));
_this.notifyObservers(prevStore, [namePath], {
type: "valueUpdate",
source: "internal"
});
_this.notifyWatch([namePath]);
var childrenFields = _this.triggerDependenciesUpdate(prevStore, namePath);
var onValuesChange = _this.callbacks.onValuesChange;
if (onValuesChange) {
var changedValues = cloneByNamePathList(_this.store, [namePath]);
onValuesChange(changedValues, _this.getFieldsValue());
}
_this.triggerOnFieldsChange([namePath].concat(_toConsumableArray(childrenFields)));
};
this.setFieldsValue = function(store) {
_this.warningUnhooked();
var prevStore = _this.store;
if (store) {
var nextStore = setValues(_this.store, store);
_this.updateStore(nextStore);
}
_this.notifyObservers(prevStore, null, {
type: "valueUpdate",
source: "external"
});
_this.notifyWatch();
};
this.setFieldValue = function(name, value) {
_this.setFields([{
name,
value
}]);
};
this.getDependencyChildrenFields = function(rootNamePath) {
var children = /* @__PURE__ */ new Set();
var childrenFields = [];
var dependencies2fields = new NameMap();
_this.getFieldEntities().forEach(function(field) {
var dependencies = field.props.dependencies;
(dependencies || []).forEach(function(dependency) {
var dependencyNamePath = getNamePath(dependency);
dependencies2fields.update(dependencyNamePath, function() {
var fields = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : /* @__PURE__ */ new Set();
fields.add(field);
return fields;
});
});
});
var fillChildren = function fillChildren2(namePath) {
var fields = dependencies2fields.get(namePath) || /* @__PURE__ */ new Set();
fields.forEach(function(field) {
if (!children.has(field)) {
children.add(field);
var fieldNamePath = field.getNamePath();
if (field.isFieldDirty() && fieldNamePath.length) {
childrenFields.push(fieldNamePath);
fillChildren2(fieldNamePath);
}
}
});
};
fillChildren(rootNamePath);
return childrenFields;
};
this.triggerOnFieldsChange = function(namePathList, filedErrors) {
var onFieldsChange = _this.callbacks.onFieldsChange;
if (onFieldsChange) {
var fields = _this.getFields();
if (filedErrors) {
var cache = new NameMap();
filedErrors.forEach(function(_ref4) {
var name = _ref4.name, errors = _ref4.errors;
cache.set(name, errors);
});
fields.forEach(function(field) {
field.errors = cache.get(field.name) || field.errors;
});
}
var changedFields = fields.filter(function(_ref5) {
var fieldName = _ref5.name;
return containsNamePath(namePathList, fieldName);
});
onFieldsChange(changedFields, fields);
}
};
this.validateFields = function(nameList, options) {
_this.warningUnhooked();
var provideNameList = !!nameList;
var namePathList = provideNameList ? nameList.map(getNamePath) : [];
var promiseList = [];
_this.getFieldEntities(true).forEach(function(field) {
if (!provideNameList) {
namePathList.push(field.getNamePath());
}
if ((options === null || options === void 0 ? void 0 : options.recursive) && provideNameList) {
var namePath = field.getNamePath();
if (namePath.every(function(nameUnit, i) {
return nameList[i] === nameUnit || nameList[i] === void 0;
})) {
namePathList.push(namePath);
}
}
if (!field.props.rules || !field.props.rules.length) {
return;
}
var fieldNamePath = field.getNamePath();
if (!provideNameList || containsNamePath(namePathList, fieldNamePath)) {
var promise = field.validateRules(_objectSpread2({
validateMessages: _objectSpread2(_objectSpread2({}, defaultValidateMessages), _this.validateMessages)
}, options));
promiseList.push(promise.then(function() {
return {
name: fieldNamePath,
errors: [],
warnings: []
};
}).catch(function(ruleErrors) {
var _ruleErrors$forEach;
var mergedErrors = [];
var mergedWarnings = [];
(_ruleErrors$forEach = ruleErrors.forEach) === null || _ruleErrors$forEach === void 0 ? void 0 : _ruleErrors$forEach.call(ruleErrors, function(_ref6) {
var warningOnly = _ref6.rule.warningOnly, errors = _ref6.errors;
if (warningOnly) {
mergedWarnings.push.apply(mergedWarnings, _toConsumableArray(errors));
} else {
mergedErrors.push.apply(mergedErrors, _toConsumableArray(errors));
}
});
if (mergedErrors.length) {
return Promise.reject({
name: fieldNamePath,
errors: mergedErrors,
warnings: mergedWarnings
});
}
return {
name: fieldNamePath,
errors: mergedErrors,
warnings: mergedWarnings
};
}));
}
});
var summaryPromise = allPromiseFinish(promiseList);
_this.lastValidatePromise = summaryPromise;
summaryPromise.catch(function(results) {
return results;
}).then(function(results) {
var resultNamePathList = results.map(function(_ref7) {
var name = _ref7.name;
return name;
});
_this.notifyObservers(_this.store, resultNamePathList, {
type: "validateFinish"
});
_this.triggerOnFieldsChange(resultNamePathList, results);
});
var returnPromise = summaryPromise.then(function() {
if (_this.lastValidatePromise === summaryPromise) {
return Promise.resolve(_this.getFieldsValue(namePathList));
}
return Promise.reject([]);
}).catch(function(results) {
var errorList = results.filter(function(result) {
return result && result.errors.length;
});
return Promise.reject({
values: _this.getFieldsValue(namePathList),
errorFields: errorList,
outOfDate: _this.lastValidatePromise !== summaryPromise
});
});
returnPromise.catch(function(e2) {
return e2;
});
return returnPromise;
};
this.submit = function() {
_this.warningUnhooked();
_this.validateFields().then(function(values) {
var onFinish = _this.callbacks.onFinish;
if (onFinish) {
try {
onFinish(values);
} catch (err) {
console.error(err);
}
}
}).catch(function(e2) {
var onFinishFailed = _this.callbacks.onFinishFailed;
if (onFinishFailed) {
onFinishFailed(e2);
}
});
};
this.forceRootUpdate = forceRootUpdate;
});
function useForm(form) {
var formRef = React__namespace.useRef();
var _React$useState = React__namespace.useState({}), _React$useState2 = _slicedToArray(_React$useState, 2), forceUpdate = _React$useState2[1];
if (!formRef.current) {
if (form) {
formRef.current = form;
} else {
var forceReRender = function forceReRender2() {
forceUpdate({});
};
var formStore = new FormStore(forceReRender);
formRef.current = formStore.getForm();
}
}
return [formRef.current];
}
var FormContext = /* @__PURE__ */ React__namespace.createContext({
triggerFormChange: function triggerFormChange() {
},
triggerFormFinish: function triggerFormFinish() {
},
registerForm: function registerForm() {
},
unregisterForm: function unregisterForm() {
}
});
var FormProvider = function FormProvider2(_ref) {
var validateMessages = _ref.validateMessages, onFormChange = _ref.onFormChange, onFormFinish = _ref.onFormFinish, children = _ref.children;
var formContext = React__namespace.useContext(FormContext);
var formsRef = React__namespace.useRef({});
return /* @__PURE__ */ jsx(FormContext.Provider, {
value: _objectSpread2(_objectSpread2({}, formContext), {}, {
validateMessages: _objectSpread2(_objectSpread2({}, formContext.validateMessages), validateMessages),
triggerFormChange: function triggerFormChange(name, changedFields) {
if (onFormChange) {
onFormChange(name, {
changedFields,
forms: formsRef.current
});
}
formContext.triggerFormChange(name, changedFields);
},
triggerFormFinish: function triggerFormFinish(name, values) {
if (onFormFinish) {
onFormFinish(name, {
values,
forms: formsRef.current
});
}
formContext.triggerFormFinish(name, values);
},
registerForm: function registerForm(name, form) {
if (name) {
formsRef.current = _objectSpread2(_objectSpread2({}, formsRef.current), {}, _defineProperty({}, name, form));
}
formContext.registerForm(name, form);
},
unregisterForm: function unregisterForm(name) {
var newForms = _objectSpread2({}, formsRef.current);
delete newForms[name];
formsRef.current = newForms;
formContext.unregisterForm(name);
}
}),
children
});
};
var _excluded$4 = ["name", "initialValues", "fields", "form", "preserve", "children", "component", "validateMessages", "validateTrigger", "onValuesChange", "onFieldsChange", "onFinish", "onFinishFailed"];
var Form = function Form2(_ref, ref) {
var name = _ref.name, initialValues = _ref.initialValues, fields = _ref.fields, form = _ref.form, preserve = _ref.preserve, children = _ref.children, _ref$component = _ref.component, Component = _ref$component === void 0 ? "form" : _ref$component, validateMessages = _ref.validateMessages, _ref$validateTrigger = _ref.validateTrigger, validateTrigger = _ref$validateTrigger === void 0 ? "onChange" : _ref$validateTrigger, onValuesChange = _ref.onValuesChange, _onFieldsChange = _ref.onFieldsChange, _onFinish = _ref.onFinish, onFinishFailed = _ref.onFinishFailed, restProps = _objectWithoutProperties(_ref, _excluded$4);
var formContext = React__namespace.useContext(FormContext);
var _useForm = useForm(form), _useForm2 = _slicedToArray(_useForm, 1), formInstance = _useForm2[0];
var _formInstance$getInte = formInstance.getInternalHooks(HOOK_MARK), useSubscribe = _formInstance$getInte.useSubscribe, setInitialValues = _formInstance$getInte.setInitialValues, setCallbacks = _formInstance$getInte.setCallbacks, setValidateMessages = _formInstance$getInte.setValidateMessages, setPreserve = _formInstance$getInte.setPreserve, destroyForm = _formInstance$getInte.destroyForm;
React__namespace.useImperativeHandle(ref, function() {
return formInstance;
});
React__namespace.useEffect(function() {
formContext.registerForm(name, formInstance);
return function() {
formContext.unregisterForm(name);
};
}, [formContext, formInstance, name]);
setValidateMessages(_objectSpread2(_objectSpread2({}, formContext.validateMessages), validateMessages));
setCallbacks({
onValuesChange,
onFieldsChange: function onFieldsChange(changedFields) {
formContext.triggerFormChange(name, changedFields);
if (_onFieldsChange) {
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
rest[_key - 1] = arguments[_key];
}
_onFieldsChange.apply(void 0, [changedFields].concat(rest));
}
},
onFinish: function onFinish(values2) {
formContext.triggerFormFinish(name, values2);
if (_onFinish) {
_onFinish(values2);
}
},
onFinishFailed
});
setPreserve(preserve);
var mountRef = React__namespace.useRef(null);
setInitialValues(initialValues, !mountRef.current);
if (!mountRef.current) {
mountRef.current = true;
}
React__namespace.useEffect(
function() {
return destroyForm;
},
[]
);
var childrenNode;
var childrenRenderProps = typeof children === "function";
if (childrenRenderProps) {
var values = formInstance.getFieldsValue(true);
childrenNode = children(values, formInstance);
} else {
childrenNode = children;
}
useSubscribe(!childrenRenderProps);
var prevFieldsRef = React__namespace.useRef();
React__namespace.useEffect(function() {
if (!isSimilar(prevFieldsRef.current || [], fields || [])) {
formInstance.setFields(fields || []);
}
prevFieldsRef.current = fields;
}, [fields, formInstance]);
var formContextValue = React__namespace.useMemo(function() {
return _objectSpread2(_objectSpread2({}, formInstance), {}, {
validateTrigger
});
}, [formInstance, validateTrigger]);
var wrapperNode = /* @__PURE__ */ jsx(Context.Provider, {
value: formContextValue,
children: childrenNode
});
if (Component === false) {
return wrapperNode;
}
return /* @__PURE__ */ jsx(Component, {
...restProps,
onSubmit: function onSubmit(event) {
event.preventDefault();
event.stopPropagation();
formInstance.submit();
},
onReset: function onReset(event) {
var _restProps$onReset;
event.preventDefault();
formInstance.resetFields();
(_restProps$onReset = restProps.onReset) === null || _restProps$onReset === void 0 ? void 0 : _restProps$onReset.call(restProps, event);
},
children: wrapperNode
});
};
function stringify(value) {
try {
return JSON.stringify(value);
} catch (err) {
return Math.random();
}
}
function useWatch() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var _args$ = args[0], dependencies = _args$ === void 0 ? [] : _args$, form = args[1];
var _useState = React2.useState(), _useState2 = _slicedToArray(_useState, 2), value = _useState2[0], setValue2 = _useState2[1];
var valueStr = React2.useMemo(function() {
return stringify(value);
}, [value]);
var valueStrRef = React2.useRef(valueStr);
valueStrRef.current = valueStr;
var fieldContext = React2.useContext(Context);
var formInstance = form || fieldContext;
var isValidForm = formInstance && formInstance._init;
var namePath = getNamePath(dependencies);
var namePathRef = React2.useRef(namePath);
namePathRef.current = namePath;
React2.useEffect(
function() {
if (!isValidForm) {
return;
}
var getFieldsValue = formInstance.getFieldsValue, getInternalHooks = formInstance.getInternalHooks;
var _getInternalHooks = getInternalHooks(HOOK_MARK), registerWatch = _getInternalHooks.registerWatch;
var cancelRegister = registerWatch(function(store) {
var newValue = getValue$1(store, namePathRef.current);
var nextValueStr = stringify(newValue);
if (valueStrRef.current !== nextValueStr) {
valueStrRef.current = nextValueStr;
setValue2(newValue);
}
});
var initialValue = getValue$1(getFieldsValue(), namePathRef.current);
setValue2(initialValue);
return cancelRegister;
},
[isValidForm]
);
return value;
}
var InternalForm = /* @__PURE__ */ React__namespace.forwardRef(Form);
var RefForm = InternalForm;
RefForm.FormProvider = FormProvider;
RefForm.Field = WrapperField;
RefForm.List = List;
RefForm.useForm = useForm;
RefForm.useWatch = useWatch;
const enUS$1 = {
items_per_page: "/ page",
jump_to: "Go to",
jump_to_confirm: "confirm",
page: "Page",
prev_page: "Previous Page",
next_page: "Next Page",
prev_5: "Previous 5 Pages",
next_5: "Next 5 Pages",
prev_3: "Previous 3 Pages",
next_3: "Next 3 Pages",
page_size: "Page Size"
};
var locale$2 = {
locale: "en_US",
today: "Today",
now: "Now",
backToToday: "Back to today",
ok: "OK",
clear: "Clear",
month: "Month",
year: "Year",
timeSelect: "select time",
dateSelect: "select date",
weekSelect: "Choose a week",
monthSelect: "Choose a month",
yearSelect: "Choose a year",
decadeSelect: "Choose a decade",
yearFormat: "YYYY",
dateFormat: "M/D/YYYY",
dayFormat: "D",
dateTimeFormat: "M/D/YYYY HH:mm:ss",
monthBeforeYear: true,
previousMonth: "Previous month (PageUp)",
nextMonth: "Next month (PageDown)",
previousYear: "Last year (Control + left)",
nextYear: "Next year (Control + right)",
previousDecade: "Last decade",
nextDecade: "Next decade",
previousCentury: "Last century",
nextCentury: "Next century"
};
var locale$1 = {
placeholder: "Select time",
rangePlaceholder: ["Start time", "End time"]
};
const TimePicker = locale$1;
var locale = {
lang: _extends$1({
placeholder: "Select date",
yearPlaceholder: "Select year",
quarterPlaceholder: "Select quarter",
monthPlaceholder: "Select month",
weekPlaceholder: "Select week",
rangePlaceholder: ["Start date", "End date"],
rangeYearPlaceholder: ["Start year", "End year"],
rangeQuarterPlaceholder: ["Start quarter", "End quarter"],
rangeMonthPlaceholder: ["Start month", "End month"],
rangeWeekPlaceholder: ["Start week", "End week"]
}, locale$2),
timePickerLocale: _extends$1({}, TimePicker)
};
const enUS = locale;
var typeTemplate = "${label} is not a valid ${type}";
var localeValues = {
locale: "en",
Pagination: enUS$1,
DatePicker: enUS,
TimePicker,
Calendar: enUS,
global: {
placeholder: "Please select"
},
Table: {
filterTitle: "Filter menu",
filterConfirm: "OK",
filterReset: "Reset",
filterEmptyText: "No filters",
filterCheckall: "Select all items",
filterSearchPlaceholder: "Search in filters",
emptyText: "No data",
selectAll: "Select current page",
selectInvert: "Invert current page",
selectNone: "Clear all data",
selectionAll: "Select all data",
sortTitle: "Sort",
expand: "Expand row",
collapse: "Collapse row",
triggerDesc: "Click to sort descending",
triggerAsc: "Click to sort ascending",
cancelSort: "Click to cancel sorting"
},
Modal: {
okText: "OK",
cancelText: "Cancel",
justOkText: "OK"
},
Popconfirm: {
okText: "OK",
cancelText: "Cancel"
},
Transfer: {
titles: ["", ""],
searchPlaceholder: "Search here",
itemUnit: "item",
itemsUnit: "items",
remove: "Remove",
selectCurrent: "Select current page",
removeCurrent: "Remove current page",
selectAll: "Select all data",
removeAll: "Remove all data",
selectInvert: "Invert current page"
},
Upload: {
uploading: "Uploading...",
removeFile: "Remove file",
uploadError: "Upload error",
previewFile: "Preview file",
downloadFile: "Download file"
},
Empty: {
description: "No data"
},
Icon: {
icon: "icon"
},
Text: {
edit: "Edit",
copy: "Copy",
copied: "Copied",
expand: "Expand"
},
PageHeader: {
back: "Back"
},
Form: {
optional: "(optional)",
defaultValidateMessages: {
"default": "Field validation error for ${label}",
required: "Please enter ${label}",
"enum": "${label} must be one of [${enum}]",
whitespace: "${label} cannot be a blank character",
date: {
format: "${label} date format is invalid",
parse: "${label} cannot be converted to a date",
invalid: "${label} is an invalid date"
},
types: {
string: typeTemplate,
method: typeTemplate,
array: typeTemplate,
object: typeTemplate,
number: typeTemplate,
date: typeTemplate,
"boolean": typeTemplate,
integer: typeTemplate,
"float": typeTemplate,
regexp: typeTemplate,
email: typeTemplate,
url: typeTemplate,
hex: typeTemplate
},
string: {
len: "${label} must be ${len} characters",
min: "${label} must be at least ${min} characters",
max: "${label} must be up to ${max} characters",
range: "${label} must be between ${min}-${max} characters"
},
number: {
len: "${label} must be equal to ${len}",
min: "${label} must be minimum ${min}",
max: "${label} must be maximum ${max}",
range: "${label} must be between ${min}-${max}"
},
array: {
len: "Must be ${len} ${label}",
min: "At least ${min} ${label}",
max: "At most ${max} ${label}",
range: "The amount of ${label} must be between ${min}-${max}"
},
pattern: {
mismatch: "${label} does not match the pattern ${pattern}"
}
}
},
Image: {
preview: "Preview"
}
};
const defaultLocale = localeValues;
var runtimeLocale = _extends$1({}, defaultLocale.Modal);
function changeConfirmLocale(newLocale) {
if (newLocale) {
runtimeLocale = _extends$1(_extends$1({}, runtimeLocale), newLocale);
} else {
runtimeLocale = _extends$1({}, defaultLocale.Modal);
}
}
var LocaleContext = /* @__PURE__ */ React2.createContext(void 0);
const LocaleContext$1 = LocaleContext;
var ANT_MARK = "internalMark";
var LocaleProvider = function LocaleProvider2(props) {
var _props$locale = props.locale, locale2 = _props$locale === void 0 ? {} : _props$locale, children = props.children;
props._ANT_MARK__;
React__namespace.useEffect(function() {
changeConfirmLocale(locale2 && locale2.Modal);
return function() {
changeConfirmLocale();
};
}, [locale2]);
var getMemoizedContextValue = React__namespace.useMemo(function() {
return _extends$1(_extends$1({}, locale2), {
exist: true
});
}, [locale2]);
return /* @__PURE__ */ jsx(LocaleContext$1.Provider, {
value: getMemoizedContextValue,
children
});
};
const LocaleProvider$1 = LocaleProvider;
var LocaleReceiver = function LocaleReceiver2(props) {
var _props$componentName = props.componentName, componentName = _props$componentName === void 0 ? "global" : _props$componentName, defaultLocale$1 = props.defaultLocale, children = props.children;
var antLocale = React__namespace.useContext(LocaleContext$1);
var getLocale = React__namespace.useMemo(function() {
var _a;
var locale2 = defaultLocale$1 || defaultLocale[componentName];
var localeFromContext = (_a = antLocale === null || antLocale === void 0 ? void 0 : antLocale[componentName]) !== null && _a !== void 0 ? _a : {};
return _extends$1(_extends$1({}, locale2 instanceof Function ? locale2() : locale2), localeFromContext || {});
}, [componentName, defaultLocale$1, antLocale]);
var getLocaleCode = React__namespace.useMemo(function() {
var localeCode = antLocale && antLocale.locale;
if (antLocale && antLocale.exist && !localeCode) {
return defaultLocale.locale;
}
return localeCode;
}, [antLocale]);
return children(getLocale, getLocaleCode, antLocale);
};
const LocaleReceiver$1 = LocaleReceiver;
var CheckCircleFilled$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z" } }] }, "name": "check-circle", "theme": "filled" };
const CheckCircleFilledSvg = CheckCircleFilled$2;
function bound01(n2, max) {
if (isOnePointZero(n2)) {
n2 = "100%";
}
var isPercent = isPercentage(n2);
n2 = max === 360 ? n2 : Math.min(max, Math.max(0, parseFloat(n2)));
if (isPercent) {
n2 = parseInt(String(n2 * max), 10) / 100;
}
if (Math.abs(n2 - max) < 1e-6) {
return 1;
}
if (max === 360) {
n2 = (n2 < 0 ? n2 % max + max : n2 % max) / parseFloat(String(max));
} else {
n2 = n2 % max / parseFloat(String(max));
}
return n2;
}
function clamp01(val) {
return Math.min(1, Math.max(0, val));
}
function isOnePointZero(n2) {
return typeof n2 === "string" && n2.indexOf(".") !== -1 && parseFloat(n2) === 1;
}
function isPercentage(n2) {
return typeof n2 === "string" && n2.indexOf("%") !== -1;
}
function boundAlpha(a) {
a = parseFloat(a);
if (isNaN(a) || a < 0 || a > 1) {
a = 1;
}
return a;
}
function convertToPercentage(n2) {
if (n2 <= 1) {
return "".concat(Number(n2) * 100, "%");
}
return n2;
}
function pad2(c2) {
return c2.length === 1 ? "0" + c2 : String(c2);
}
function rgbToRgb(r2, g2, b2) {
return {
r: bound01(r2, 255) * 255,
g: bound01(g2, 255) * 255,
b: bound01(b2, 255) * 255
};
}
function rgbToHsl(r2, g2, b2) {
r2 = bound01(r2, 255);
g2 = bound01(g2, 255);
b2 = bound01(b2, 255);
var max = Math.max(r2, g2, b2);
var min = Math.min(r2, g2, b2);
var h2 = 0;
var s = 0;
var l2 = (max + min) / 2;
if (max === min) {
s = 0;
h2 = 0;
} else {
var d2 = max - min;
s = l2 > 0.5 ? d2 / (2 - max - min) : d2 / (max + min);
switch (max) {
case r2:
h2 = (g2 - b2) / d2 + (g2 < b2 ? 6 : 0);
break;
case g2:
h2 = (b2 - r2) / d2 + 2;
break;
case b2:
h2 = (r2 - g2) / d2 + 4;
break;
}
h2 /= 6;
}
return { h: h2, s, l: l2 };
}
function hue2rgb(p2, q2, t2) {
if (t2 < 0) {
t2 += 1;
}
if (t2 > 1) {
t2 -= 1;
}
if (t2 < 1 / 6) {
return p2 + (q2 - p2) * (6 * t2);
}
if (t2 < 1 / 2) {
return q2;
}
if (t2 < 2 / 3) {
return p2 + (q2 - p2) * (2 / 3 - t2) * 6;
}
return p2;
}
function hslToRgb(h2, s, l2) {
var r2;
var g2;
var b2;
h2 = bound01(h2, 360);
s = bound01(s, 100);
l2 = bound01(l2, 100);
if (s === 0) {
g2 = l2;
b2 = l2;
r2 = l2;
} else {
var q2 = l2 < 0.5 ? l2 * (1 + s) : l2 + s - l2 * s;
var p2 = 2 * l2 - q2;
r2 = hue2rgb(p2, q2, h2 + 1 / 3);
g2 = hue2rgb(p2, q2, h2);
b2 = hue2rgb(p2, q2, h2 - 1 / 3);
}
return { r: r2 * 255, g: g2 * 255, b: b2 * 255 };
}
function rgbToHsv(r2, g2, b2) {
r2 = bound01(r2, 255);
g2 = bound01(g2, 255);
b2 = bound01(b2, 255);
var max = Math.max(r2, g2, b2);
var min = Math.min(r2, g2, b2);
var h2 = 0;
var v2 = max;
var d2 = max - min;
var s = max === 0 ? 0 : d2 / max;
if (max === min) {
h2 = 0;
} else {
switch (max) {
case r2:
h2 = (g2 - b2) / d2 + (g2 < b2 ? 6 : 0);
break;
case g2:
h2 = (b2 - r2) / d2 + 2;
break;
case b2:
h2 = (r2 - g2) / d2 + 4;
break;
}
h2 /= 6;
}
return { h: h2, s, v: v2 };
}
function hsvToRgb(h2, s, v2) {
h2 = bound01(h2, 360) * 6;
s = bound01(s, 100);
v2 = bound01(v2, 100);
var i = Math.floor(h2);
var f2 = h2 - i;
var p2 = v2 * (1 - s);
var q2 = v2 * (1 - f2 * s);
var t2 = v2 * (1 - (1 - f2) * s);
var mod = i % 6;
var r2 = [v2, q2, p2, p2, t2, v2][mod];
var g2 = [t2, v2, v2, q2, p2, p2][mod];
var b2 = [p2, p2, t2, v2, v2, q2][mod];
return { r: r2 * 255, g: g2 * 255, b: b2 * 255 };
}
function rgbToHex(r2, g2, b2, allow3Char) {
var hex = [
pad2(Math.round(r2).toString(16)),
pad2(Math.round(g2).toString(16)),
pad2(Math.round(b2).toString(16))
];
if (allow3Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1))) {
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
}
return hex.join("");
}
function rgbaToHex(r2, g2, b2, a, allow4Char) {
var hex = [
pad2(Math.round(r2).toString(16)),
pad2(Math.round(g2).toString(16)),
pad2(Math.round(b2).toString(16)),
pad2(convertDecimalToHex(a))
];
if (allow4Char && hex[0].startsWith(hex[0].charAt(1)) && hex[1].startsWith(hex[1].charAt(1)) && hex[2].startsWith(hex[2].charAt(1)) && hex[3].startsWith(hex[3].charAt(1))) {
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
}
return hex.join("");
}
function convertDecimalToHex(d2) {
return Math.round(parseFloat(d2) * 255).toString(16);
}
function convertHexToDecimal(h2) {
return parseIntFromHex(h2) / 255;
}
function parseIntFromHex(val) {
return parseInt(val, 16);
}
function numberInputToObject(color) {
return {
r: color >> 16,
g: (color & 65280) >> 8,
b: color & 255
};
}
var names = {
aliceblue: "#f0f8ff",
antiquewhite: "#faebd7",
aqua: "#00ffff",
aquamarine: "#7fffd4",
azure: "#f0ffff",
beige: "#f5f5dc",
bisque: "#ffe4c4",
black: "#000000",
blanchedalmond: "#ffebcd",
blue: "#0000ff",
blueviolet: "#8a2be2",
brown: "#a52a2a",
burlywood: "#deb887",
cadetblue: "#5f9ea0",
chartreuse: "#7fff00",
chocolate: "#d2691e",
coral: "#ff7f50",
cornflowerblue: "#6495ed",
cornsilk: "#fff8dc",
crimson: "#dc143c",
cyan: "#00ffff",
darkblue: "#00008b",
darkcyan: "#008b8b",
darkgoldenrod: "#b8860b",
darkgray: "#a9a9a9",
darkgreen: "#006400",
darkgrey: "#a9a9a9",
darkkhaki: "#bdb76b",
darkmagenta: "#8b008b",
darkolivegreen: "#556b2f",
darkorange: "#ff8c00",
darkorchid: "#9932cc",
darkred: "#8b0000",
darksalmon: "#e9967a",
darkseagreen: "#8fbc8f",
darkslateblue: "#483d8b",
darkslategray: "#2f4f4f",
darkslategrey: "#2f4f4f",
darkturquoise: "#00ced1",
darkviolet: "#9400d3",
deeppink: "#ff1493",
deepskyblue: "#00bfff",
dimgray: "#696969",
dimgrey: "#696969",
dodgerblue: "#1e90ff",
firebrick: "#b22222",
floralwhite: "#fffaf0",
forestgreen: "#228b22",
fuchsia: "#ff00ff",
gainsboro: "#dcdcdc",
ghostwhite: "#f8f8ff",
goldenrod: "#daa520",
gold: "#ffd700",
gray: "#808080",
green: "#008000",
greenyellow: "#adff2f",
grey: "#808080",
honeydew: "#f0fff0",
hotpink: "#ff69b4",
indianred: "#cd5c5c",
indigo: "#4b0082",
ivory: "#fffff0",
khaki: "#f0e68c",
lavenderblush: "#fff0f5",
lavender: "#e6e6fa",
lawngreen: "#7cfc00",
lemonchiffon: "#fffacd",
lightblue: "#add8e6",
lightcoral: "#f08080",
lightcyan: "#e0ffff",
lightgoldenrodyellow: "#fafad2",
lightgray: "#d3d3d3",
lightgreen: "#90ee90",
lightgrey: "#d3d3d3",
lightpink: "#ffb6c1",
lightsalmon: "#ffa07a",
lightseagreen: "#20b2aa",
lightskyblue: "#87cefa",
lightslategray: "#778899",
lightslategrey: "#778899",
lightsteelblue: "#b0c4de",
lightyellow: "#ffffe0",
lime: "#00ff00",
limegreen: "#32cd32",
linen: "#faf0e6",
magenta: "#ff00ff",
maroon: "#800000",
mediumaquamarine: "#66cdaa",
mediumblue: "#0000cd",
mediumorchid: "#ba55d3",
mediumpurple: "#9370db",
mediumseagreen: "#3cb371",
mediumslateblue: "#7b68ee",
mediumspringgreen: "#00fa9a",
mediumturquoise: "#48d1cc",
mediumvioletred: "#c71585",
midnightblue: "#191970",
mintcream: "#f5fffa",
mistyrose: "#ffe4e1",
moccasin: "#ffe4b5",
navajowhite: "#ffdead",
navy: "#000080",
oldlace: "#fdf5e6",
olive: "#808000",
olivedrab: "#6b8e23",
orange: "#ffa500",
orangered: "#ff4500",
orchid: "#da70d6",
palegoldenrod: "#eee8aa",
palegreen: "#98fb98",
paleturquoise: "#afeeee",
palevioletred: "#db7093",
papayawhip: "#ffefd5",
peachpuff: "#ffdab9",
peru: "#cd853f",
pink: "#ffc0cb",
plum: "#dda0dd",
powderblue: "#b0e0e6",
purple: "#800080",
rebeccapurple: "#663399",
red: "#ff0000",
rosybrown: "#bc8f8f",
royalblue: "#4169e1",
saddlebrown: "#8b4513",
salmon: "#fa8072",
sandybrown: "#f4a460",
seagreen: "#2e8b57",
seashell: "#fff5ee",
sienna: "#a0522d",
silver: "#c0c0c0",
skyblue: "#87ceeb",
slateblue: "#6a5acd",
slategray: "#708090",
slategrey: "#708090",
snow: "#fffafa",
springgreen: "#00ff7f",
steelblue: "#4682b4",
tan: "#d2b48c",
teal: "#008080",
thistle: "#d8bfd8",
tomato: "#ff6347",
turquoise: "#40e0d0",
violet: "#ee82ee",
wheat: "#f5deb3",
white: "#ffffff",
whitesmoke: "#f5f5f5",
yellow: "#ffff00",
yellowgreen: "#9acd32"
};
function inputToRGB(color) {
var rgb = { r: 0, g: 0, b: 0 };
var a = 1;
var s = null;
var v2 = null;
var l2 = null;
var ok = false;
var format2 = false;
if (typeof color === "string") {
color = stringInputToObject(color);
}
if (typeof color === "object") {
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
rgb = rgbToRgb(color.r, color.g, color.b);
ok = true;
format2 = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
s = convertToPercentage(color.s);
v2 = convertToPercentage(color.v);
rgb = hsvToRgb(color.h, s, v2);
ok = true;
format2 = "hsv";
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
s = convertToPercentage(color.s);
l2 = convertToPercentage(color.l);
rgb = hslToRgb(color.h, s, l2);
ok = true;
format2 = "hsl";
}
if (Object.prototype.hasOwnProperty.call(color, "a")) {
a = color.a;
}
}
a = boundAlpha(a);
return {
ok,
format: color.format || format2,
r: Math.min(255, Math.max(rgb.r, 0)),
g: Math.min(255, Math.max(rgb.g, 0)),
b: Math.min(255, Math.max(rgb.b, 0)),
a
};
}
var CSS_INTEGER = "[-\\+]?\\d+%?";
var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")");
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
var matchers = {
CSS_UNIT: new RegExp(CSS_UNIT),
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
};
function stringInputToObject(color) {
color = color.trim().toLowerCase();
if (color.length === 0) {
return false;
}
var named = false;
if (names[color]) {
color = names[color];
named = true;
} else if (color === "transparent") {
return { r: 0, g: 0, b: 0, a: 0, format: "name" };
}
var match = matchers.rgb.exec(color);
if (match) {
return { r: match[1], g: match[2], b: match[3] };
}
match = matchers.rgba.exec(color);
if (match) {
return { r: match[1], g: match[2], b: match[3], a: match[4] };
}
match = matchers.hsl.exec(color);
if (match) {
return { h: match[1], s: match[2], l: match[3] };
}
match = matchers.hsla.exec(color);
if (match) {
return { h: match[1], s: match[2], l: match[3], a: match[4] };
}
match = matchers.hsv.exec(color);
if (match) {
return { h: match[1], s: match[2], v: match[3] };
}
match = matchers.hsva.exec(color);
if (match) {
return { h: match[1], s: match[2], v: match[3], a: match[4] };
}
match = matchers.hex8.exec(color);
if (match) {
return {
r: parseIntFromHex(match[1]),
g: parseIntFromHex(match[2]),
b: parseIntFromHex(match[3]),
a: convertHexToDecimal(match[4]),
format: named ? "name" : "hex8"
};
}
match = matchers.hex6.exec(color);
if (match) {
return {
r: parseIntFromHex(match[1]),
g: parseIntFromHex(match[2]),
b: parseIntFromHex(match[3]),
format: named ? "name" : "hex"
};
}
match = matchers.hex4.exec(color);
if (match) {
return {
r: parseIntFromHex(match[1] + match[1]),
g: parseIntFromHex(match[2] + match[2]),
b: parseIntFromHex(match[3] + match[3]),
a: convertHexToDecimal(match[4] + match[4]),
format: named ? "name" : "hex8"
};
}
match = matchers.hex3.exec(color);
if (match) {
return {
r: parseIntFromHex(match[1] + match[1]),
g: parseIntFromHex(match[2] + match[2]),
b: parseIntFromHex(match[3] + match[3]),
format: named ? "name" : "hex"
};
}
return false;
}
function isValidCSSUnit(color) {
return Boolean(matchers.CSS_UNIT.exec(String(color)));
}
var TinyColor = function() {
function TinyColor2(color, opts) {
if (color === void 0) {
color = "";
}
if (opts === void 0) {
opts = {};
}
var _a;
if (color instanceof TinyColor2) {
return color;
}
if (typeof color === "number") {
color = numberInputToObject(color);
}
this.originalInput = color;
var rgb = inputToRGB(color);
this.originalInput = color;
this.r = rgb.r;
this.g = rgb.g;
this.b = rgb.b;
this.a = rgb.a;
this.roundA = Math.round(100 * this.a) / 100;
this.format = (_a = opts.format) !== null && _a !== void 0 ? _a : rgb.format;
this.gradientType = opts.gradientType;
if (this.r < 1) {
this.r = Math.round(this.r);
}
if (this.g < 1) {
this.g = Math.round(this.g);
}
if (this.b < 1) {
this.b = Math.round(this.b);
}
this.isValid = rgb.ok;
}
TinyColor2.prototype.isDark = function() {
return this.getBrightness() < 128;
};
TinyColor2.prototype.isLight = function() {
return !this.isDark();
};
TinyColor2.prototype.getBrightness = function() {
var rgb = this.toRgb();
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1e3;
};
TinyColor2.prototype.getLuminance = function() {
var rgb = this.toRgb();
var R;
var G;
var B;
var RsRGB = rgb.r / 255;
var GsRGB = rgb.g / 255;
var BsRGB = rgb.b / 255;
if (RsRGB <= 0.03928) {
R = RsRGB / 12.92;
} else {
R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
}
if (GsRGB <= 0.03928) {
G = GsRGB / 12.92;
} else {
G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
}
if (BsRGB <= 0.03928) {
B = BsRGB / 12.92;
} else {
B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
}
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
};
TinyColor2.prototype.getAlpha = function() {
return this.a;
};
TinyColor2.prototype.setAlpha = function(alpha) {
this.a = boundAlpha(alpha);
this.roundA = Math.round(100 * this.a) / 100;
return this;
};
TinyColor2.prototype.isMonochrome = function() {
var s = this.toHsl().s;
return s === 0;
};
TinyColor2.prototype.toHsv = function() {
var hsv = rgbToHsv(this.r, this.g, this.b);
return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };
};
TinyColor2.prototype.toHsvString = function() {
var hsv = rgbToHsv(this.r, this.g, this.b);
var h2 = Math.round(hsv.h * 360);
var s = Math.round(hsv.s * 100);
var v2 = Math.round(hsv.v * 100);
return this.a === 1 ? "hsv(".concat(h2, ", ").concat(s, "%, ").concat(v2, "%)") : "hsva(".concat(h2, ", ").concat(s, "%, ").concat(v2, "%, ").concat(this.roundA, ")");
};
TinyColor2.prototype.toHsl = function() {
var hsl = rgbToHsl(this.r, this.g, this.b);
return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };
};
TinyColor2.prototype.toHslString = function() {
var hsl = rgbToHsl(this.r, this.g, this.b);
var h2 = Math.round(hsl.h * 360);
var s = Math.round(hsl.s * 100);
var l2 = Math.round(hsl.l * 100);
return this.a === 1 ? "hsl(".concat(h2, ", ").concat(s, "%, ").concat(l2, "%)") : "hsla(".concat(h2, ", ").concat(s, "%, ").concat(l2, "%, ").concat(this.roundA, ")");
};
TinyColor2.prototype.toHex = function(allow3Char) {
if (allow3Char === void 0) {
allow3Char = false;
}
return rgbToHex(this.r, this.g, this.b, allow3Char);
};
TinyColor2.prototype.toHexString = function(allow3Char) {
if (allow3Char === void 0) {
allow3Char = false;
}
return "#" + this.toHex(allow3Char);
};
TinyColor2.prototype.toHex8 = function(allow4Char) {
if (allow4Char === void 0) {
allow4Char = false;
}
return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
};
TinyColor2.prototype.toHex8String = function(allow4Char) {
if (allow4Char === void 0) {
allow4Char = false;
}
return "#" + this.toHex8(allow4Char);
};
TinyColor2.prototype.toRgb = function() {
return {
r: Math.round(this.r),
g: Math.round(this.g),
b: Math.round(this.b),
a: this.a
};
};
TinyColor2.prototype.toRgbString = function() {
var r2 = Math.round(this.r);
var g2 = Math.round(this.g);
var b2 = Math.round(this.b);
return this.a === 1 ? "rgb(".concat(r2, ", ").concat(g2, ", ").concat(b2, ")") : "rgba(".concat(r2, ", ").concat(g2, ", ").concat(b2, ", ").concat(this.roundA, ")");
};
TinyColor2.prototype.toPercentageRgb = function() {
var fmt = function(x2) {
return "".concat(Math.round(bound01(x2, 255) * 100), "%");
};
return {
r: fmt(this.r),
g: fmt(this.g),
b: fmt(this.b),
a: this.a
};
};
TinyColor2.prototype.toPercentageRgbString = function() {
var rnd = function(x2) {
return Math.round(bound01(x2, 255) * 100);
};
return this.a === 1 ? "rgb(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%)") : "rgba(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%, ").concat(this.roundA, ")");
};
TinyColor2.prototype.toName = function() {
if (this.a === 0) {
return "transparent";
}
if (this.a < 1) {
return false;
}
var hex = "#" + rgbToHex(this.r, this.g, this.b, false);
for (var _i = 0, _a = Object.entries(names); _i < _a.length; _i++) {
var _b = _a[_i], key2 = _b[0], value = _b[1];
if (hex === value) {
return key2;
}
}
return false;
};
TinyColor2.prototype.toString = function(format2) {
var formatSet = Boolean(format2);
format2 = format2 !== null && format2 !== void 0 ? format2 : this.format;
var formattedString = false;
var hasAlpha = this.a < 1 && this.a >= 0;
var needsAlphaFormat = !formatSet && hasAlpha && (format2.startsWith("hex") || format2 === "name");
if (needsAlphaFormat) {
if (format2 === "name" && this.a === 0) {
return this.toName();
}
return this.toRgbString();
}
if (format2 === "rgb") {
formattedString = this.toRgbString();
}
if (format2 === "prgb") {
formattedString = this.toPercentageRgbString();
}
if (format2 === "hex" || format2 === "hex6") {
formattedString = this.toHexString();
}
if (format2 === "hex3") {
formattedString = this.toHexString(true);
}
if (format2 === "hex4") {
formattedString = this.toHex8String(true);
}
if (format2 === "hex8") {
formattedString = this.toHex8String();
}
if (format2 === "name") {
formattedString = this.toName();
}
if (format2 === "hsl") {
formattedString = this.toHslString();
}
if (format2 === "hsv") {
formattedString = this.toHsvString();
}
return formattedString || this.toHexString();
};
TinyColor2.prototype.toNumber = function() {
return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
};
TinyColor2.prototype.clone = function() {
return new TinyColor2(this.toString());
};
TinyColor2.prototype.lighten = function(amount) {
if (amount === void 0) {
amount = 10;
}
var hsl = this.toHsl();
hsl.l += amount / 100;
hsl.l = clamp01(hsl.l);
return new TinyColor2(hsl);
};
TinyColor2.prototype.brighten = function(amount) {
if (amount === void 0) {
amount = 10;
}
var rgb = this.toRgb();
rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
return new TinyColor2(rgb);
};
TinyColor2.prototype.darken = function(amount) {
if (amount === void 0) {
amount = 10;
}
var hsl = this.toHsl();
hsl.l -= amount / 100;
hsl.l = clamp01(hsl.l);
return new TinyColor2(hsl);
};
TinyColor2.prototype.tint = function(amount) {
if (amount === void 0) {
amount = 10;
}
return this.mix("white", amount);
};
TinyColor2.prototype.shade = function(amount) {
if (amount === void 0) {
amount = 10;
}
return this.mix("black", amount);
};
TinyColor2.prototype.desaturate = function(amount) {
if (amount === void 0) {
amount = 10;
}
var hsl = this.toHsl();
hsl.s -= amount / 100;
hsl.s = clamp01(hsl.s);
return new TinyColor2(hsl);
};
TinyColor2.prototype.saturate = function(amount) {
if (amount === void 0) {
amount = 10;
}
var hsl = this.toHsl();
hsl.s += amount / 100;
hsl.s = clamp01(hsl.s);
return new TinyColor2(hsl);
};
TinyColor2.prototype.greyscale = function() {
return this.desaturate(100);
};
TinyColor2.prototype.spin = function(amount) {
var hsl = this.toHsl();
var hue = (hsl.h + amount) % 360;
hsl.h = hue < 0 ? 360 + hue : hue;
return new TinyColor2(hsl);
};
TinyColor2.prototype.mix = function(color, amount) {
if (amount === void 0) {
amount = 50;
}
var rgb1 = this.toRgb();
var rgb2 = new TinyColor2(color).toRgb();
var p2 = amount / 100;
var rgba = {
r: (rgb2.r - rgb1.r) * p2 + rgb1.r,
g: (rgb2.g - rgb1.g) * p2 + rgb1.g,
b: (rgb2.b - rgb1.b) * p2 + rgb1.b,
a: (rgb2.a - rgb1.a) * p2 + rgb1.a
};
return new TinyColor2(rgba);
};
TinyColor2.prototype.analogous = function(results, slices) {
if (results === void 0) {
results = 6;
}
if (slices === void 0) {
slices = 30;
}
var hsl = this.toHsl();
var part = 360 / slices;
var ret = [this];
for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results; ) {
hsl.h = (hsl.h + part) % 360;
ret.push(new TinyColor2(hsl));
}
return ret;
};
TinyColor2.prototype.complement = function() {
var hsl = this.toHsl();
hsl.h = (hsl.h + 180) % 360;
return new TinyColor2(hsl);
};
TinyColor2.prototype.monochromatic = function(results) {
if (results === void 0) {
results = 6;
}
var hsv = this.toHsv();
var h2 = hsv.h;
var s = hsv.s;
var v2 = hsv.v;
var res = [];
var modification = 1 / results;
while (results--) {
res.push(new TinyColor2({ h: h2, s, v: v2 }));
v2 = (v2 + modification) % 1;
}
return res;
};
TinyColor2.prototype.splitcomplement = function() {
var hsl = this.toHsl();
var h2 = hsl.h;
return [
this,
new TinyColor2({ h: (h2 + 72) % 360, s: hsl.s, l: hsl.l }),
new TinyColor2({ h: (h2 + 216) % 360, s: hsl.s, l: hsl.l })
];
};
TinyColor2.prototype.onBackground = function(background) {
var fg = this.toRgb();
var bg = new TinyColor2(background).toRgb();
return new TinyColor2({
r: bg.r + (fg.r - bg.r) * fg.a,
g: bg.g + (fg.g - bg.g) * fg.a,
b: bg.b + (fg.b - bg.b) * fg.a
});
};
TinyColor2.prototype.triad = function() {
return this.polyad(3);
};
TinyColor2.prototype.tetrad = function() {
return this.polyad(4);
};
TinyColor2.prototype.polyad = function(n2) {
var hsl = this.toHsl();
var h2 = hsl.h;
var result = [this];
var increment = 360 / n2;
for (var i = 1; i < n2; i++) {
result.push(new TinyColor2({ h: (h2 + i * increment) % 360, s: hsl.s, l: hsl.l }));
}
return result;
};
TinyColor2.prototype.equals = function(color) {
return this.toRgbString() === new TinyColor2(color).toRgbString();
};
return TinyColor2;
}();
var hueStep = 2;
var saturationStep = 0.16;
var saturationStep2 = 0.05;
var brightnessStep1 = 0.05;
var brightnessStep2 = 0.15;
var lightColorCount = 5;
var darkColorCount = 4;
var darkColorMap = [{
index: 7,
opacity: 0.15
}, {
index: 6,
opacity: 0.25
}, {
index: 5,
opacity: 0.3
}, {
index: 5,
opacity: 0.45
}, {
index: 5,
opacity: 0.65
}, {
index: 5,
opacity: 0.85
}, {
index: 4,
opacity: 0.9
}, {
index: 3,
opacity: 0.95
}, {
index: 2,
opacity: 0.97
}, {
index: 1,
opacity: 0.98
}];
function toHsv(_ref) {
var r2 = _ref.r, g2 = _ref.g, b2 = _ref.b;
var hsv = rgbToHsv(r2, g2, b2);
return {
h: hsv.h * 360,
s: hsv.s,
v: hsv.v
};
}
function toHex(_ref2) {
var r2 = _ref2.r, g2 = _ref2.g, b2 = _ref2.b;
return "#".concat(rgbToHex(r2, g2, b2, false));
}
function mix(rgb1, rgb2, amount) {
var p2 = amount / 100;
var rgb = {
r: (rgb2.r - rgb1.r) * p2 + rgb1.r,
g: (rgb2.g - rgb1.g) * p2 + rgb1.g,
b: (rgb2.b - rgb1.b) * p2 + rgb1.b
};
return rgb;
}
function getHue(hsv, i, light) {
var hue;
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
} else {
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
}
if (hue < 0) {
hue += 360;
} else if (hue >= 360) {
hue -= 360;
}
return hue;
}
function getSaturation(hsv, i, light) {
if (hsv.h === 0 && hsv.s === 0) {
return hsv.s;
}
var saturation;
if (light) {
saturation = hsv.s - saturationStep * i;
} else if (i === darkColorCount) {
saturation = hsv.s + saturationStep;
} else {
saturation = hsv.s + saturationStep2 * i;
}
if (saturation > 1) {
saturation = 1;
}
if (light && i === lightColorCount && saturation > 0.1) {
saturation = 0.1;
}
if (saturation < 0.06) {
saturation = 0.06;
}
return Number(saturation.toFixed(2));
}
function getValue(hsv, i, light) {
var value;
if (light) {
value = hsv.v + brightnessStep1 * i;
} else {
value = hsv.v - brightnessStep2 * i;
}
if (value > 1) {
value = 1;
}
return Number(value.toFixed(2));
}
function generate$1(color) {
var opts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var patterns = [];
var pColor = inputToRGB(color);
for (var i = lightColorCount; i > 0; i -= 1) {
var hsv = toHsv(pColor);
var colorString = toHex(inputToRGB({
h: getHue(hsv, i, true),
s: getSaturation(hsv, i, true),
v: getValue(hsv, i, true)
}));
patterns.push(colorString);
}
patterns.push(toHex(pColor));
for (var _i = 1; _i <= darkColorCount; _i += 1) {
var _hsv = toHsv(pColor);
var _colorString = toHex(inputToRGB({
h: getHue(_hsv, _i),
s: getSaturation(_hsv, _i),
v: getValue(_hsv, _i)
}));
patterns.push(_colorString);
}
if (opts.theme === "dark") {
return darkColorMap.map(function(_ref3) {
var index = _ref3.index, opacity = _ref3.opacity;
var darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || "#141414"), inputToRGB(patterns[index]), opacity * 100));
return darkColorString;
});
}
return patterns;
}
var presetPrimaryColors = {
red: "#F5222D",
volcano: "#FA541C",
orange: "#FA8C16",
gold: "#FAAD14",
yellow: "#FADB14",
lime: "#A0D911",
green: "#52C41A",
cyan: "#13C2C2",
blue: "#1890FF",
geekblue: "#2F54EB",
purple: "#722ED1",
magenta: "#EB2F96",
grey: "#666666"
};
var presetPalettes = {};
var presetDarkPalettes = {};
Object.keys(presetPrimaryColors).forEach(function(key2) {
presetPalettes[key2] = generate$1(presetPrimaryColors[key2]);
presetPalettes[key2].primary = presetPalettes[key2][5];
presetDarkPalettes[key2] = generate$1(presetPrimaryColors[key2], {
theme: "dark",
backgroundColor: "#141414"
});
presetDarkPalettes[key2].primary = presetDarkPalettes[key2][5];
});
function canUseDom() {
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
}
function contains(root2, n2) {
if (!root2) {
return false;
}
if (root2.contains) {
return root2.contains(n2);
}
var node = n2;
while (node) {
if (node === root2) {
return true;
}
node = node.parentNode;
}
return false;
}
var APPEND_ORDER = "data-rc-order";
var MARK_KEY = "rc-util-key";
var containerCache = /* @__PURE__ */ new Map();
function getMark() {
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, mark = _ref.mark;
if (mark) {
return mark.startsWith("data-") ? mark : "data-".concat(mark);
}
return MARK_KEY;
}
function getContainer$1(option) {
if (option.attachTo) {
return option.attachTo;
}
var head = document.querySelector("head");
return head || document.body;
}
function getOrder(prepend) {
if (prepend === "queue") {
return "prependQueue";
}
return prepend ? "prepend" : "append";
}
function findStyles(container) {
return Array.from((containerCache.get(container) || container).children).filter(function(node) {
return node.tagName === "STYLE";
});
}
function injectCSS(css) {
var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
if (!canUseDom()) {
return null;
}
var csp = option.csp, prepend = option.prepend;
var styleNode = document.createElement("style");
styleNode.setAttribute(APPEND_ORDER, getOrder(prepend));
if (csp === null || csp === void 0 ? void 0 : csp.nonce) {
styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;
}
styleNode.innerHTML = css;
var container = getContainer$1(option);
var firstChild = container.firstChild;
if (prepend) {
if (prepend === "queue") {
var existStyle = findStyles(container).filter(function(node) {
return ["prepend", "prependQueue"].includes(node.getAttribute(APPEND_ORDER));
});
if (existStyle.length) {
container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
return styleNode;
}
}
container.insertBefore(styleNode, firstChild);
} else {
container.appendChild(styleNode);
}
return styleNode;
}
function findExistNode(key2) {
var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
var container = getContainer$1(option);
return findStyles(container).find(function(node) {
return node.getAttribute(getMark(option)) === key2;
});
}
function syncRealContainer(container, option) {
var cachedRealContainer = containerCache.get(container);
if (!cachedRealContainer || !contains(document, cachedRealContainer)) {
var placeholderStyle = injectCSS("", option);
var parentNode = placeholderStyle.parentNode;
containerCache.set(container, parentNode);
container.removeChild(placeholderStyle);
}
}
function updateCSS(css, key2) {
var option = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
var container = getContainer$1(option);
syncRealContainer(container, option);
var existNode = findExistNode(key2, option);
if (existNode) {
var _option$csp, _option$csp2;
if (((_option$csp = option.csp) === null || _option$csp === void 0 ? void 0 : _option$csp.nonce) && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) {
var _option$csp3;
existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce;
}
if (existNode.innerHTML !== css) {
existNode.innerHTML = css;
}
return existNode;
}
var newNode = injectCSS(css, option);
newNode.setAttribute(getMark(option), key2);
return newNode;
}
function warning(valid, message2) {
warningOnce(valid, "[@ant-design/icons] ".concat(message2));
}
function isIconDefinition(target) {
return _typeof(target) === "object" && typeof target.name === "string" && typeof target.theme === "string" && (_typeof(target.icon) === "object" || typeof target.icon === "function");
}
function normalizeAttrs() {
var attrs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
return Object.keys(attrs).reduce(function(acc, key2) {
var val = attrs[key2];
switch (key2) {
case "class":
acc.className = val;
delete acc.class;
break;
default:
acc[key2] = val;
}
return acc;
}, {});
}
function generate(node, key2, rootProps) {
if (!rootProps) {
return /* @__PURE__ */ React__default.default.createElement(node.tag, _objectSpread2({
key: key2
}, normalizeAttrs(node.attrs)), (node.children || []).map(function(child, index) {
return generate(child, "".concat(key2, "-").concat(node.tag, "-").concat(index));
}));
}
return /* @__PURE__ */ React__default.default.createElement(node.tag, _objectSpread2(_objectSpread2({
key: key2
}, normalizeAttrs(node.attrs)), rootProps), (node.children || []).map(function(child, index) {
return generate(child, "".concat(key2, "-").concat(node.tag, "-").concat(index));
}));
}
function getSecondaryColor(primaryColor) {
return generate$1(primaryColor)[0];
}
function normalizeTwoToneColors(twoToneColor) {
if (!twoToneColor) {
return [];
}
return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor];
}
var iconStyles = "\n.anticon {\n display: inline-block;\n color: inherit;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -0.125em;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.anticon > * {\n line-height: 1;\n}\n\n.anticon svg {\n display: inline-block;\n}\n\n.anticon::before {\n display: none;\n}\n\n.anticon .anticon-icon {\n display: block;\n}\n\n.anticon[tabindex] {\n cursor: pointer;\n}\n\n.anticon-spin::before,\n.anticon-spin {\n display: inline-block;\n -webkit-animation: loadingCircle 1s infinite linear;\n animation: loadingCircle 1s infinite linear;\n}\n\n@-webkit-keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n";
var useInsertStyles = function useInsertStyles2() {
var styleStr = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : iconStyles;
var _useContext = React2.useContext(IconContext$1), csp = _useContext.csp;
React2.useEffect(function() {
updateCSS(styleStr, "@ant-design-icons", {
prepend: true,
csp
});
}, []);
};
var _excluded$3 = ["icon", "className", "onClick", "style", "primaryColor", "secondaryColor"];
var twoToneColorPalette = {
primaryColor: "#333",
secondaryColor: "#E6E6E6",
calculated: false
};
function setTwoToneColors(_ref) {
var primaryColor = _ref.primaryColor, secondaryColor = _ref.secondaryColor;
twoToneColorPalette.primaryColor = primaryColor;
twoToneColorPalette.secondaryColor = secondaryColor || getSecondaryColor(primaryColor);
twoToneColorPalette.calculated = !!secondaryColor;
}
function getTwoToneColors() {
return _objectSpread2({}, twoToneColorPalette);
}
var IconBase = function IconBase2(props) {
var icon = props.icon, className = props.className, onClick = props.onClick, style2 = props.style, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, restProps = _objectWithoutProperties(props, _excluded$3);
var colors = twoToneColorPalette;
if (primaryColor) {
colors = {
primaryColor,
secondaryColor: secondaryColor || getSecondaryColor(primaryColor)
};
}
useInsertStyles();
warning(isIconDefinition(icon), "icon should be icon definiton, but got ".concat(icon));
if (!isIconDefinition(icon)) {
return null;
}
var target = icon;
if (target && typeof target.icon === "function") {
target = _objectSpread2(_objectSpread2({}, target), {}, {
icon: target.icon(colors.primaryColor, colors.secondaryColor)
});
}
return generate(target.icon, "svg-".concat(target.name), _objectSpread2({
className,
onClick,
style: style2,
"data-icon": target.name,
width: "1em",
height: "1em",
fill: "currentColor",
"aria-hidden": "true"
}, restProps));
};
IconBase.displayName = "IconReact";
IconBase.getTwoToneColors = getTwoToneColors;
IconBase.setTwoToneColors = setTwoToneColors;
const ReactIcon = IconBase;
function setTwoToneColor(twoToneColor) {
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor), _normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2), primaryColor = _normalizeTwoToneColo2[0], secondaryColor = _normalizeTwoToneColo2[1];
return ReactIcon.setTwoToneColors({
primaryColor,
secondaryColor
});
}
function getTwoToneColor() {
var colors = ReactIcon.getTwoToneColors();
if (!colors.calculated) {
return colors.primaryColor;
}
return [colors.primaryColor, colors.secondaryColor];
}
var _excluded$2 = ["className", "icon", "spin", "rotate", "tabIndex", "onClick", "twoToneColor"];
setTwoToneColor("#1890ff");
var Icon = /* @__PURE__ */ React__namespace.forwardRef(function(props, ref) {
var _classNames;
var className = props.className, icon = props.icon, spin = props.spin, rotate = props.rotate, tabIndex = props.tabIndex, onClick = props.onClick, twoToneColor = props.twoToneColor, restProps = _objectWithoutProperties(props, _excluded$2);
var _React$useContext = React__namespace.useContext(IconContext$1), _React$useContext$pre = _React$useContext.prefixCls, prefixCls = _React$useContext$pre === void 0 ? "anticon" : _React$useContext$pre, rootClassName = _React$useContext.rootClassName;
var classString = classNames(rootClassName, prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(icon.name), !!icon.name), _defineProperty(_classNames, "".concat(prefixCls, "-spin"), !!spin || icon.name === "loading"), _classNames), className);
var iconTabIndex = tabIndex;
if (iconTabIndex === void 0 && onClick) {
iconTabIndex = -1;
}
var svgStyle = rotate ? {
msTransform: "rotate(".concat(rotate, "deg)"),
transform: "rotate(".concat(rotate, "deg)")
} : void 0;
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor), _normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2), primaryColor = _normalizeTwoToneColo2[0], secondaryColor = _normalizeTwoToneColo2[1];
return /* @__PURE__ */ jsx("span", {
..._objectSpread2(_objectSpread2({
role: "img",
"aria-label": icon.name
}, restProps), {}, {
ref,
tabIndex: iconTabIndex,
onClick,
className: classString
}),
children: /* @__PURE__ */ jsx(ReactIcon, {
icon,
primaryColor,
secondaryColor,
style: svgStyle
})
});
});
Icon.displayName = "AntdIcon";
Icon.getTwoToneColor = getTwoToneColor;
Icon.setTwoToneColor = setTwoToneColor;
const AntdIcon = Icon;
var CheckCircleFilled = function CheckCircleFilled2(props, ref) {
return /* @__PURE__ */ jsx(AntdIcon, {
..._objectSpread2(_objectSpread2({}, props), {}, {
ref,
icon: CheckCircleFilledSvg
})
});
};
CheckCircleFilled.displayName = "CheckCircleFilled";
const CheckCircleFilled$1 = /* @__PURE__ */ React__namespace.forwardRef(CheckCircleFilled);
var CloseCircleFilled$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z" } }] }, "name": "close-circle", "theme": "filled" };
const CloseCircleFilledSvg = CloseCircleFilled$2;
var CloseCircleFilled = function CloseCircleFilled2(props, ref) {
return /* @__PURE__ */ jsx(AntdIcon, {
..._objectSpread2(_objectSpread2({}, props), {}, {
ref,
icon: CloseCircleFilledSvg
})
});
};
CloseCircleFilled.displayName = "CloseCircleFilled";
const CloseCircleFilled$1 = /* @__PURE__ */ React__namespace.forwardRef(CloseCircleFilled);
var ExclamationCircleFilled$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" } }] }, "name": "exclamation-circle", "theme": "filled" };
const ExclamationCircleFilledSvg = ExclamationCircleFilled$2;
var ExclamationCircleFilled = function ExclamationCircleFilled2(props, ref) {
return /* @__PURE__ */ jsx(AntdIcon, {
..._objectSpread2(_objectSpread2({}, props), {}, {
ref,
icon: ExclamationCircleFilledSvg
})
});
};
ExclamationCircleFilled.displayName = "ExclamationCircleFilled";
const ExclamationCircleFilled$1 = /* @__PURE__ */ React__namespace.forwardRef(ExclamationCircleFilled);
var InfoCircleFilled$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" } }] }, "name": "info-circle", "theme": "filled" };
const InfoCircleFilledSvg = InfoCircleFilled$2;
var InfoCircleFilled = function InfoCircleFilled2(props, ref) {
return /* @__PURE__ */ jsx(AntdIcon, {
..._objectSpread2(_objectSpread2({}, props), {}, {
ref,
icon: InfoCircleFilledSvg
})
});
};
InfoCircleFilled.displayName = "InfoCircleFilled";
const InfoCircleFilled$1 = /* @__PURE__ */ React__namespace.forwardRef(InfoCircleFilled);
var LoadingOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "0 0 1024 1024", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z" } }] }, "name": "loading", "theme": "outlined" };
const LoadingOutlinedSvg = LoadingOutlined$2;
var LoadingOutlined = function LoadingOutlined2(props, ref) {
return /* @__PURE__ */ jsx(AntdIcon, {
..._objectSpread2(_objectSpread2({}, props), {}, {
ref,
icon: LoadingOutlinedSvg
})
});
};
LoadingOutlined.displayName = "LoadingOutlined";
const LoadingOutlined$1 = /* @__PURE__ */ React__namespace.forwardRef(LoadingOutlined);
var fullClone = _objectSpread2({}, ReactDOM__namespace);
var version = fullClone.version, reactRender = fullClone.render, unmountComponentAtNode = fullClone.unmountComponentAtNode;
var createRoot;
try {
var mainVersion = Number((version || "").split(".")[0]);
if (mainVersion >= 18) {
createRoot = fullClone.createRoot;
}
} catch (e2) {
}
function toggleWarning(skip) {
var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = fullClone.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && _typeof(__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === "object") {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
}
}
var MARK = "__rc_react_root__";
function modernRender(node, container) {
toggleWarning(true);
var root2 = container[MARK] || createRoot(container);
toggleWarning(false);
root2.render(node);
container[MARK] = root2;
}
function legacyRender(node, container) {
reactRender(node, container);
}
function render(node, container) {
if (createRoot) {
modernRender(node, container);
return;
}
legacyRender(node, container);
}
function modernUnmount(_x) {
return _modernUnmount.apply(this, arguments);
}
function _modernUnmount() {
_modernUnmount = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(container) {
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", Promise.resolve().then(function() {
var _container$MARK;
(_container$MARK = container[MARK]) === null || _container$MARK === void 0 ? void 0 : _container$MARK.unmount();
delete container[MARK];
}));
case 1:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _modernUnmount.apply(this, arguments);
}
function legacyUnmount(container) {
unmountComponentAtNode(container);
}
function unmount(_x2) {
return _unmount.apply(this, arguments);
}
function _unmount() {
_unmount = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2(container) {
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
if (!(createRoot !== void 0)) {
_context2.next = 2;
break;
}
return _context2.abrupt("return", modernUnmount(container));
case 2:
legacyUnmount(container);
case 3:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return _unmount.apply(this, arguments);
}
function makePrefixMap(styleProp, eventName) {
var prefixes = {};
prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
prefixes["Webkit".concat(styleProp)] = "webkit".concat(eventName);
prefixes["Moz".concat(styleProp)] = "moz".concat(eventName);
prefixes["ms".concat(styleProp)] = "MS".concat(eventName);
prefixes["O".concat(styleProp)] = "o".concat(eventName.toLowerCase());
return prefixes;
}
function getVendorPrefixes(domSupport, win) {
var prefixes = {
animationend: makePrefixMap("Animation", "AnimationEnd"),
transitionend: makePrefixMap("Transition", "TransitionEnd")
};
if (domSupport) {
if (!("AnimationEvent" in win)) {
delete prefixes.animationend.animation;
}
if (!("TransitionEvent" in win)) {
delete prefixes.transitionend.transition;
}
}
return prefixes;
}
var vendorPrefixes = getVendorPrefixes(canUseDom(), typeof window !== "undefined" ? window : {});
var style = {};
if (canUseDom()) {
var _document$createEleme = document.createElement("div");
style = _document$createEleme.style;
}
var prefixedEventNames = {};
function getVendorPrefixedEventName(eventName) {
if (prefixedEventNames[eventName]) {
return prefixedEventNames[eventName];
}
var prefixMap = vendorPrefixes[eventName];
if (prefixMap) {
var stylePropList = Object.keys(prefixMap);
var len = stylePropList.length;
for (var i = 0; i < len; i += 1) {
var styleProp = stylePropList[i];
if (Object.prototype.hasOwnProperty.call(prefixMap, styleProp) && styleProp in style) {
prefixedEventNames[eventName] = prefixMap[styleProp];
return prefixedEventNames[eventName];
}
}
}
return "";
}
var internalAnimationEndName = getVendorPrefixedEventName("animationend");
var internalTransitionEndName = getVendorPrefixedEventName("transitionend");
var supportTransition = !!(internalAnimationEndName && internalTransitionEndName);
var animationEndName = internalAnimationEndName || "animationend";
var transitionEndName = internalTransitionEndName || "transitionend";
function getTransitionName(transitionName2, transitionType) {
if (!transitionName2)
return null;
if (_typeof(transitionName2) === "object") {
var type2 = transitionType.replace(/-\w/g, function(match) {
return match[1].toUpperCase();
});
return transitionName2[type2];
}
return "".concat(transitionName2, "-").concat(transitionType);
}
var STATUS_NONE = "none";
var STATUS_APPEAR = "appear";
var STATUS_ENTER = "enter";
var STATUS_LEAVE = "leave";
var STEP_NONE = "none";
var STEP_PREPARE = "prepare";
var STEP_START = "start";
var STEP_ACTIVE = "active";
var STEP_ACTIVATED = "end";
function useSafeState(defaultValue) {
var destroyRef = React__namespace.useRef(false);
var _React$useState = React__namespace.useState(defaultValue), _React$useState2 = _slicedToArray(_React$useState, 2), value = _React$useState2[0], setValue2 = _React$useState2[1];
React__namespace.useEffect(function() {
destroyRef.current = false;
return function() {
destroyRef.current = true;
};
}, []);
function safeSetState(updater, ignoreDestroy) {
if (ignoreDestroy && destroyRef.current) {
return;
}
setValue2(updater);
}
return [value, safeSetState];
}
var raf = function raf2(callback) {
return +setTimeout(callback, 16);
};
var caf = function caf2(num) {
return clearTimeout(num);
};
if (typeof window !== "undefined" && "requestAnimationFrame" in window) {
raf = function raf2(callback) {
return window.requestAnimationFrame(callback);
};
caf = function caf2(handle) {
return window.cancelAnimationFrame(handle);
};
}
var rafUUID = 0;
var rafIds = /* @__PURE__ */ new Map();
function cleanup(id) {
rafIds.delete(id);
}
var wrapperRaf = function wrapperRaf2(callback) {
var times = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
rafUUID += 1;
var id = rafUUID;
function callRef(leftTimes) {
if (leftTimes === 0) {
cleanup(id);
callback();
} else {
var realId = raf(function() {
callRef(leftTimes - 1);
});
rafIds.set(id, realId);
}
}
callRef(times);
return id;
};
wrapperRaf.cancel = function(id) {
var realId = rafIds.get(id);
cleanup(realId);
return caf(realId);
};
const useNextFrame = function() {
var nextFrameRef = React__namespace.useRef(null);
function cancelNextFrame() {
wrapperRaf.cancel(nextFrameRef.current);
}
function nextFrame(callback) {
var delay = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2;
cancelNextFrame();
var nextFrameId = wrapperRaf(function() {
if (delay <= 1) {
callback({
isCanceled: function isCanceled() {
return nextFrameId !== nextFrameRef.current;
}
});
} else {
nextFrame(callback, delay - 1);
}
});
nextFrameRef.current = nextFrameId;
}
React__namespace.useEffect(function() {
return function() {
cancelNextFrame();
};
}, []);
return [nextFrame, cancelNextFrame];
};
var useIsomorphicLayoutEffect = canUseDom() ? React2.useLayoutEffect : React2.useEffect;
var STEP_QUEUE = [STEP_PREPARE, STEP_START, STEP_ACTIVE, STEP_ACTIVATED];
var SkipStep = false;
var DoStep = true;
function isActive(step) {
return step === STEP_ACTIVE || step === STEP_ACTIVATED;
}
const useStepQueue = function(status, callback) {
var _useState = useSafeState(STEP_NONE), _useState2 = _slicedToArray(_useState, 2), step = _useState2[0], setStep = _useState2[1];
var _useNextFrame = useNextFrame(), _useNextFrame2 = _slicedToArray(_useNextFrame, 2), nextFrame = _useNextFrame2[0], cancelNextFrame = _useNextFrame2[1];
function startQueue() {
setStep(STEP_PREPARE, true);
}
useIsomorphicLayoutEffect(function() {
if (step !== STEP_NONE && step !== STEP_ACTIVATED) {
var index = STEP_QUEUE.indexOf(step);
var nextStep = STEP_QUEUE[index + 1];
var result = callback(step);
if (result === SkipStep) {
setStep(nextStep, true);
} else {
nextFrame(function(info) {
function doNext() {
if (info.isCanceled())
return;
setStep(nextStep, true);
}
if (result === true) {
doNext();
} else {
Promise.resolve(result).then(doNext);
}
});
}
}
}, [status, step]);
React__namespace.useEffect(function() {
return function() {
cancelNextFrame();
};
}, []);
return [startQueue, step];
};
const useDomMotionEvents = function(callback) {
var cacheElementRef = React2.useRef();
var callbackRef = React2.useRef(callback);
callbackRef.current = callback;
var onInternalMotionEnd = React__namespace.useCallback(function(event) {
callbackRef.current(event);
}, []);
function removeMotionEvents(element) {
if (element) {
element.removeEventListener(transitionEndName, onInternalMotionEnd);
element.removeEventListener(animationEndName, onInternalMotionEnd);
}
}
function patchMotionEvents(element) {
if (cacheElementRef.current && cacheElementRef.current !== element) {
removeMotionEvents(cacheElementRef.current);
}
if (element && element !== cacheElementRef.current) {
element.addEventListener(transitionEndName, onInternalMotionEnd);
element.addEventListener(animationEndName, onInternalMotionEnd);
cacheElementRef.current = element;
}
}
React__namespace.useEffect(function() {
return function() {
removeMotionEvents(cacheElementRef.current);
};
}, []);
return [patchMotionEvents, removeMotionEvents];
};
function useStatus(supportMotion, visible, getElement, _ref) {
var _ref$motionEnter = _ref.motionEnter, motionEnter = _ref$motionEnter === void 0 ? true : _ref$motionEnter, _ref$motionAppear = _ref.motionAppear, motionAppear = _ref$motionAppear === void 0 ? true : _ref$motionAppear, _ref$motionLeave = _ref.motionLeave, motionLeave = _ref$motionLeave === void 0 ? true : _ref$motionLeave, motionDeadline = _ref.motionDeadline, motionLeaveImmediately = _ref.motionLeaveImmediately, onAppearPrepare = _ref.onAppearPrepare, onEnterPrepare = _ref.onEnterPrepare, onLeavePrepare = _ref.onLeavePrepare, onAppearStart = _ref.onAppearStart, onEnterStart = _ref.onEnterStart, onLeaveStart = _ref.onLeaveStart, onAppearActive = _ref.onAppearActive, onEnterActive = _ref.onEnterActive, onLeaveActive = _ref.onLeaveActive, onAppearEnd = _ref.onAppearEnd, onEnterEnd = _ref.onEnterEnd, onLeaveEnd = _ref.onLeaveEnd, onVisibleChanged = _ref.onVisibleChanged;
var _useState = useSafeState(), _useState2 = _slicedToArray(_useState, 2), asyncVisible = _useState2[0], setAsyncVisible = _useState2[1];
var _useState3 = useSafeState(STATUS_NONE), _useState4 = _slicedToArray(_useState3, 2), status = _useState4[0], setStatus = _useState4[1];
var _useState5 = useSafeState(null), _useState6 = _slicedToArray(_useState5, 2), style2 = _useState6[0], setStyle = _useState6[1];
var mountedRef = React2.useRef(false);
var deadlineRef = React2.useRef(null);
function getDomElement() {
return getElement();
}
var activeRef = React2.useRef(false);
function onInternalMotionEnd(event) {
var element = getDomElement();
if (event && !event.deadline && event.target !== element) {
return;
}
var currentActive = activeRef.current;
var canEnd;
if (status === STATUS_APPEAR && currentActive) {
canEnd = onAppearEnd === null || onAppearEnd === void 0 ? void 0 : onAppearEnd(element, event);
} else if (status === STATUS_ENTER && currentActive) {
canEnd = onEnterEnd === null || onEnterEnd === void 0 ? void 0 : onEnterEnd(element, event);
} else if (status === STATUS_LEAVE && currentActive) {
canEnd = onLeaveEnd === null || onLeaveEnd === void 0 ? void 0 : onLeaveEnd(element, event);
}
if (status !== STATUS_NONE && currentActive && canEnd !== false) {
setStatus(STATUS_NONE, true);
setStyle(null, true);
}
}
var _useDomMotionEvents = useDomMotionEvents(onInternalMotionEnd), _useDomMotionEvents2 = _slicedToArray(_useDomMotionEvents, 1), patchMotionEvents = _useDomMotionEvents2[0];
var eventHandlers = React__namespace.useMemo(function() {
var _ref2, _ref3, _ref4;
switch (status) {
case STATUS_APPEAR:
return _ref2 = {}, _defineProperty(_ref2, STEP_PREPARE, onAppearPrepare), _defineProperty(_ref2, STEP_START, onAppearStart), _defineProperty(_ref2, STEP_ACTIVE, onAppearActive), _ref2;
case STATUS_ENTER:
return _ref3 = {}, _defineProperty(_ref3, STEP_PREPARE, onEnterPrepare), _defineProperty(_ref3, STEP_START, onEnterStart), _defineProperty(_ref3, STEP_ACTIVE, onEnterActive), _ref3;
case STATUS_LEAVE:
return _ref4 = {}, _defineProperty(_ref4, STEP_PREPARE, onLeavePrepare), _defineProperty(_ref4, STEP_START, onLeaveStart), _defineProperty(_ref4, STEP_ACTIVE, onLeaveActive), _ref4;
default:
return {};
}
}, [status]);
var _useStepQueue = useStepQueue(status, function(newStep) {
if (newStep === STEP_PREPARE) {
var onPrepare = eventHandlers[STEP_PREPARE];
if (!onPrepare) {
return SkipStep;
}
return onPrepare(getDomElement());
}
if (step in eventHandlers) {
var _eventHandlers$step;
setStyle(((_eventHandlers$step = eventHandlers[step]) === null || _eventHandlers$step === void 0 ? void 0 : _eventHandlers$step.call(eventHandlers, getDomElement(), null)) || null);
}
if (step === STEP_ACTIVE) {
patchMotionEvents(getDomElement());
if (motionDeadline > 0) {
clearTimeout(deadlineRef.current);
deadlineRef.current = setTimeout(function() {
onInternalMotionEnd({
deadline: true
});
}, motionDeadline);
}
}
return DoStep;
}), _useStepQueue2 = _slicedToArray(_useStepQueue, 2), startStep = _useStepQueue2[0], step = _useStepQueue2[1];
var active = isActive(step);
activeRef.current = active;
useIsomorphicLayoutEffect(function() {
setAsyncVisible(visible);
var isMounted = mountedRef.current;
mountedRef.current = true;
if (!supportMotion) {
return;
}
var nextStatus;
if (!isMounted && visible && motionAppear) {
nextStatus = STATUS_APPEAR;
}
if (isMounted && visible && motionEnter) {
nextStatus = STATUS_ENTER;
}
if (isMounted && !visible && motionLeave || !isMounted && motionLeaveImmediately && !visible && motionLeave) {
nextStatus = STATUS_LEAVE;
}
if (nextStatus) {
setStatus(nextStatus);
startStep();
}
}, [visible]);
React2.useEffect(function() {
if (status === STATUS_APPEAR && !motionAppear || status === STATUS_ENTER && !motionEnter || status === STATUS_LEAVE && !motionLeave) {
setStatus(STATUS_NONE);
}
}, [motionAppear, motionEnter, motionLeave]);
React2.useEffect(function() {
return function() {
mountedRef.current = false;
clearTimeout(deadlineRef.current);
};
}, []);
var firstMountChangeRef = React__namespace.useRef(false);
React2.useEffect(function() {
if (asyncVisible) {
firstMountChangeRef.current = true;
}
if (asyncVisible !== void 0 && status === STATUS_NONE) {
if (firstMountChangeRef.current || asyncVisible) {
onVisibleChanged === null || onVisibleChanged === void 0 ? void 0 : onVisibleChanged(asyncVisible);
}
firstMountChangeRef.current = true;
}
}, [asyncVisible, status]);
var mergedStyle = style2;
if (eventHandlers[STEP_PREPARE] && step === STEP_START) {
mergedStyle = _objectSpread2({
transition: "none"
}, mergedStyle);
}
return [status, step, mergedStyle, asyncVisible !== null && asyncVisible !== void 0 ? asyncVisible : visible];
}
var DomWrapper = /* @__PURE__ */ function(_React$Component) {
_inherits(DomWrapper2, _React$Component);
var _super = _createSuper(DomWrapper2);
function DomWrapper2() {
_classCallCheck(this, DomWrapper2);
return _super.apply(this, arguments);
}
_createClass(DomWrapper2, [{
key: "render",
value: function render2() {
return this.props.children;
}
}]);
return DomWrapper2;
}(React__namespace.Component);
function genCSSMotion(config) {
var transitionSupport = config;
if (_typeof(config) === "object") {
transitionSupport = config.transitionSupport;
}
function isSupportTransition(props) {
return !!(props.motionName && transitionSupport);
}
var CSSMotion2 = /* @__PURE__ */ React__namespace.forwardRef(function(props, ref) {
var _props$visible = props.visible, visible = _props$visible === void 0 ? true : _props$visible, _props$removeOnLeave = props.removeOnLeave, removeOnLeave = _props$removeOnLeave === void 0 ? true : _props$removeOnLeave, forceRender = props.forceRender, children = props.children, motionName = props.motionName, leavedClassName = props.leavedClassName, eventProps = props.eventProps;
var supportMotion = isSupportTransition(props);
var nodeRef = React2.useRef();
var wrapperNodeRef = React2.useRef();
function getDomElement() {
try {
return nodeRef.current instanceof HTMLElement ? nodeRef.current : findDOMNode(wrapperNodeRef.current);
} catch (e2) {
return null;
}
}
var _useStatus = useStatus(supportMotion, visible, getDomElement, props), _useStatus2 = _slicedToArray(_useStatus, 4), status = _useStatus2[0], statusStep = _useStatus2[1], statusStyle = _useStatus2[2], mergedVisible = _useStatus2[3];
var renderedRef = React__namespace.useRef(mergedVisible);
if (mergedVisible) {
renderedRef.current = true;
}
var setNodeRef = React__namespace.useCallback(function(node) {
nodeRef.current = node;
fillRef(ref, node);
}, [ref]);
var motionChildren;
var mergedProps = _objectSpread2(_objectSpread2({}, eventProps), {}, {
visible
});
if (!children) {
motionChildren = null;
} else if (status === STATUS_NONE || !isSupportTransition(props)) {
if (mergedVisible) {
motionChildren = children(_objectSpread2({}, mergedProps), setNodeRef);
} else if (!removeOnLeave && renderedRef.current && leavedClassName) {
motionChildren = children(_objectSpread2(_objectSpread2({}, mergedProps), {}, {
className: leavedClassName
}), setNodeRef);
} else if (forceRender || !removeOnLeave && !leavedClassName) {
motionChildren = children(_objectSpread2(_objectSpread2({}, mergedProps), {}, {
style: {
display: "none"
}
}), setNodeRef);
} else {
motionChildren = null;
}
} else {
var _classNames;
var statusSuffix;
if (statusStep === STEP_PREPARE) {
statusSuffix = "prepare";
} else if (isActive(statusStep)) {
statusSuffix = "active";
} else if (statusStep === STEP_START) {
statusSuffix = "start";
}
motionChildren = children(_objectSpread2(_objectSpread2({}, mergedProps), {}, {
className: classNames(getTransitionName(motionName, status), (_classNames = {}, _defineProperty(_classNames, getTransitionName(motionName, "".concat(status, "-").concat(statusSuffix)), statusSuffix), _defineProperty(_classNames, motionName, typeof motionName === "string"), _classNames)),
style: statusStyle
}), setNodeRef);
}
if (/* @__PURE__ */ React__namespace.isValidElement(motionChildren) && supportRef(motionChildren)) {
var _ref = motionChildren, originNodeRef = _ref.ref;
if (!originNodeRef) {
motionChildren = /* @__PURE__ */ React__namespace.cloneElement(motionChildren, {
ref: setNodeRef
});
}
}
return /* @__PURE__ */ jsx(DomWrapper, {
ref: wrapperNodeRef,
children: motionChildren
});
});
CSSMotion2.displayName = "CSSMotion";
return CSSMotion2;
}
const CSSMotion = genCSSMotion(supportTransition);
var STATUS_ADD = "add";
var STATUS_KEEP = "keep";
var STATUS_REMOVE = "remove";
var STATUS_REMOVED = "removed";
function wrapKeyToObject(key2) {
var keyObj;
if (key2 && _typeof(key2) === "object" && "key" in key2) {
keyObj = key2;
} else {
keyObj = {
key: key2
};
}
return _objectSpread2(_objectSpread2({}, keyObj), {}, {
key: String(keyObj.key)
});
}
function parseKeys() {
var keys = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
return keys.map(wrapKeyToObject);
}
function diffKeys() {
var prevKeys = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
var currentKeys = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
var list = [];
var currentIndex = 0;
var currentLen = currentKeys.length;
var prevKeyObjects = parseKeys(prevKeys);
var currentKeyObjects = parseKeys(currentKeys);
prevKeyObjects.forEach(function(keyObj) {
var hit = false;
for (var i = currentIndex; i < currentLen; i += 1) {
var currentKeyObj = currentKeyObjects[i];
if (currentKeyObj.key === keyObj.key) {
if (currentIndex < i) {
list = list.concat(currentKeyObjects.slice(currentIndex, i).map(function(obj) {
return _objectSpread2(_objectSpread2({}, obj), {}, {
status: STATUS_ADD
});
}));
currentIndex = i;
}
list.push(_objectSpread2(_objectSpread2({}, currentKeyObj), {}, {
status: STATUS_KEEP
}));
currentIndex += 1;
hit = true;
break;
}
}
if (!hit) {
list.push(_objectSpread2(_objectSpread2({}, keyObj), {}, {
status: STATUS_REMOVE
}));
}
});
if (currentIndex < currentLen) {
list = list.concat(currentKeyObjects.slice(currentIndex).map(function(obj) {
return _objectSpread2(_objectSpread2({}, obj), {}, {
status: STATUS_ADD
});
}));
}
var keys = {};
list.forEach(function(_ref) {
var key2 = _ref.key;
keys[key2] = (keys[key2] || 0) + 1;
});
var duplicatedKeys = Object.keys(keys).filter(function(key2) {
return keys[key2] > 1;
});
duplicatedKeys.forEach(function(matchKey) {
list = list.filter(function(_ref2) {
var key2 = _ref2.key, status = _ref2.status;
return key2 !== matchKey || status !== STATUS_REMOVE;
});
list.forEach(function(node) {
if (node.key === matchKey) {
node.status = STATUS_KEEP;
}
});
});
return list;
}
var _excluded$1 = ["component", "children", "onVisibleChanged", "onAllRemoved"], _excluded2 = ["status"];
var MOTION_PROP_NAMES = ["eventProps", "visible", "children", "motionName", "motionAppear", "motionEnter", "motionLeave", "motionLeaveImmediately", "motionDeadline", "removeOnLeave", "leavedClassName", "onAppearStart", "onAppearActive", "onAppearEnd", "onEnterStart", "onEnterActive", "onEnterEnd", "onLeaveStart", "onLeaveActive", "onLeaveEnd"];
function genCSSMotionList(transitionSupport) {
var CSSMotion$1 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : CSSMotion;
var CSSMotionList2 = /* @__PURE__ */ function(_React$Component) {
_inherits(CSSMotionList3, _React$Component);
var _super = _createSuper(CSSMotionList3);
function CSSMotionList3() {
var _this;
_classCallCheck(this, CSSMotionList3);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "state", {
keyEntities: []
});
_defineProperty(_assertThisInitialized(_this), "removeKey", function(removeKey) {
var keyEntities = _this.state.keyEntities;
var nextKeyEntities = keyEntities.map(function(entity) {
if (entity.key !== removeKey)
return entity;
return _objectSpread2(_objectSpread2({}, entity), {}, {
status: STATUS_REMOVED
});
});
_this.setState({
keyEntities: nextKeyEntities
});
return nextKeyEntities.filter(function(_ref) {
var status = _ref.status;
return status !== STATUS_REMOVED;
}).length;
});
return _this;
}
_createClass(CSSMotionList3, [{
key: "render",
value: function render2() {
var _this2 = this;
var keyEntities = this.state.keyEntities;
var _this$props = this.props, component = _this$props.component, children = _this$props.children, _onVisibleChanged = _this$props.onVisibleChanged, onAllRemoved = _this$props.onAllRemoved, restProps = _objectWithoutProperties(_this$props, _excluded$1);
var Component = component || React__namespace.Fragment;
var motionProps = {};
MOTION_PROP_NAMES.forEach(function(prop) {
motionProps[prop] = restProps[prop];
delete restProps[prop];
});
delete restProps.keys;
return /* @__PURE__ */ jsx(Component, {
...restProps,
children: keyEntities.map(function(_ref2) {
var status = _ref2.status, eventProps = _objectWithoutProperties(_ref2, _excluded2);
var visible = status === STATUS_ADD || status === STATUS_KEEP;
return /* @__PURE__ */ React2.createElement(CSSMotion$1, {
...motionProps,
key: eventProps.key,
visible,
eventProps,
onVisibleChanged: function onVisibleChanged(changedVisible) {
_onVisibleChanged === null || _onVisibleChanged === void 0 ? void 0 : _onVisibleChanged(changedVisible, {
key: eventProps.key
});
if (!changedVisible) {
var restKeysCount = _this2.removeKey(eventProps.key);
if (restKeysCount === 0 && onAllRemoved) {
onAllRemoved();
}
}
}
}, children);
})
});
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(_ref3, _ref4) {
var keys = _ref3.keys;
var keyEntities = _ref4.keyEntities;
var parsedKeyObjects = parseKeys(keys);
var mixedKeyEntities = diffKeys(keyEntities, parsedKeyObjects);
return {
keyEntities: mixedKeyEntities.filter(function(entity) {
var prevEntity = keyEntities.find(function(_ref5) {
var key2 = _ref5.key;
return entity.key === key2;
});
if (prevEntity && prevEntity.status === STATUS_REMOVED && entity.status === STATUS_REMOVE) {
return false;
}
return true;
})
};
}
}]);
return CSSMotionList3;
}(React__namespace.Component);
_defineProperty(CSSMotionList2, "defaultProps", {
component: "div"
});
return CSSMotionList2;
}
const CSSMotionList = genCSSMotionList(supportTransition);
var Notice = /* @__PURE__ */ function(_Component) {
_inherits(Notice2, _Component);
var _super = _createSuper(Notice2);
function Notice2() {
var _this;
_classCallCheck(this, Notice2);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_this.closeTimer = null;
_this.close = function(e2) {
if (e2) {
e2.stopPropagation();
}
_this.clearCloseTimer();
var _this$props = _this.props, onClose = _this$props.onClose, noticeKey = _this$props.noticeKey;
if (onClose) {
onClose(noticeKey);
}
};
_this.startCloseTimer = function() {
if (_this.props.duration) {
_this.closeTimer = window.setTimeout(function() {
_this.close();
}, _this.props.duration * 1e3);
}
};
_this.clearCloseTimer = function() {
if (_this.closeTimer) {
clearTimeout(_this.closeTimer);
_this.closeTimer = null;
}
};
return _this;
}
_createClass(Notice2, [{
key: "componentDidMount",
value: function componentDidMount() {
this.startCloseTimer();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (this.props.duration !== prevProps.duration || this.props.updateMark !== prevProps.updateMark || this.props.visible !== prevProps.visible && this.props.visible) {
this.restartCloseTimer();
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.clearCloseTimer();
}
}, {
key: "restartCloseTimer",
value: function restartCloseTimer() {
this.clearCloseTimer();
this.startCloseTimer();
}
}, {
key: "render",
value: function render2() {
var _this2 = this;
var _this$props2 = this.props, prefixCls = _this$props2.prefixCls, className = _this$props2.className, closable = _this$props2.closable, closeIcon = _this$props2.closeIcon, style2 = _this$props2.style, onClick = _this$props2.onClick, children = _this$props2.children, holder = _this$props2.holder;
var componentClass = "".concat(prefixCls, "-notice");
var dataOrAriaAttributeProps = Object.keys(this.props).reduce(function(acc, key2) {
if (key2.substr(0, 5) === "data-" || key2.substr(0, 5) === "aria-" || key2 === "role") {
acc[key2] = _this2.props[key2];
}
return acc;
}, {});
var node = /* @__PURE__ */ jsxs("div", {
className: classNames(componentClass, className, _defineProperty({}, "".concat(componentClass, "-closable"), closable)),
style: style2,
onMouseEnter: this.clearCloseTimer,
onMouseLeave: this.startCloseTimer,
onClick,
...dataOrAriaAttributeProps,
children: [/* @__PURE__ */ jsx("div", {
className: "".concat(componentClass, "-content"),
children
}), closable ? /* @__PURE__ */ jsx("a", {
tabIndex: 0,
onClick: this.close,
className: "".concat(componentClass, "-close"),
children: closeIcon || /* @__PURE__ */ jsx("span", {
className: "".concat(componentClass, "-close-x")
})
}) : null]
});
if (holder) {
return /* @__PURE__ */ ReactDOM__default.default.createPortal(node, holder);
}
return node;
}
}]);
return Notice2;
}(React2.Component);
Notice.defaultProps = {
onClose: function onClose() {
},
duration: 1.5
};
function useNotification(notificationInstance2) {
var createdRef = React__namespace.useRef({});
var _React$useState = React__namespace.useState([]), _React$useState2 = _slicedToArray(_React$useState, 2), elements = _React$useState2[0], setElements = _React$useState2[1];
function notify(noticeProps) {
var firstMount = true;
notificationInstance2.add(noticeProps, function(div, props) {
var key2 = props.key;
if (div && (!createdRef.current[key2] || firstMount)) {
var noticeEle = /* @__PURE__ */ jsx(Notice, {
...props,
holder: div
});
createdRef.current[key2] = noticeEle;
setElements(function(originElements) {
var index = originElements.findIndex(function(ele) {
return ele.key === props.key;
});
if (index === -1) {
return [].concat(_toConsumableArray(originElements), [noticeEle]);
}
var cloneList = _toConsumableArray(originElements);
cloneList[index] = noticeEle;
return cloneList;
});
}
firstMount = false;
});
}
return [
notify,
/* @__PURE__ */ jsx(Fragment, {
children: elements
})
];
}
var _excluded = ["getContainer"];
var seed = 0;
var now = Date.now();
function getUuid() {
var id = seed;
seed += 1;
return "rcNotification_".concat(now, "_").concat(id);
}
var Notification = /* @__PURE__ */ function(_Component) {
_inherits(Notification2, _Component);
var _super = _createSuper(Notification2);
function Notification2() {
var _this;
_classCallCheck(this, Notification2);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_this.state = {
notices: []
};
_this.hookRefs = /* @__PURE__ */ new Map();
_this.add = function(originNotice, holderCallback) {
var _originNotice$key;
var key2 = (_originNotice$key = originNotice.key) !== null && _originNotice$key !== void 0 ? _originNotice$key : getUuid();
var notice2 = _objectSpread2(_objectSpread2({}, originNotice), {}, {
key: key2
});
var maxCount2 = _this.props.maxCount;
_this.setState(function(previousState) {
var notices = previousState.notices;
var noticeIndex = notices.map(function(v2) {
return v2.notice.key;
}).indexOf(key2);
var updatedNotices = notices.concat();
if (noticeIndex !== -1) {
updatedNotices.splice(noticeIndex, 1, {
notice: notice2,
holderCallback
});
} else {
if (maxCount2 && notices.length >= maxCount2) {
notice2.key = updatedNotices[0].notice.key;
notice2.updateMark = getUuid();
notice2.userPassKey = key2;
updatedNotices.shift();
}
updatedNotices.push({
notice: notice2,
holderCallback
});
}
return {
notices: updatedNotices
};
});
};
_this.remove = function(removeKey) {
_this.setState(function(_ref) {
var notices = _ref.notices;
return {
notices: notices.filter(function(_ref2) {
var _ref2$notice = _ref2.notice, key2 = _ref2$notice.key, userPassKey = _ref2$notice.userPassKey;
var mergedKey = userPassKey !== null && userPassKey !== void 0 ? userPassKey : key2;
return mergedKey !== removeKey;
})
};
});
};
_this.noticePropsMap = {};
return _this;
}
_createClass(Notification2, [{
key: "getTransitionName",
value: function getTransitionName2() {
var _this$props = this.props, prefixCls = _this$props.prefixCls, animation = _this$props.animation;
var transitionName2 = this.props.transitionName;
if (!transitionName2 && animation) {
transitionName2 = "".concat(prefixCls, "-").concat(animation);
}
return transitionName2;
}
}, {
key: "render",
value: function render2() {
var _this2 = this;
var notices = this.state.notices;
var _this$props2 = this.props, prefixCls = _this$props2.prefixCls, className = _this$props2.className, closeIcon = _this$props2.closeIcon, style2 = _this$props2.style;
var noticeKeys = [];
notices.forEach(function(_ref3, index) {
var notice2 = _ref3.notice, holderCallback = _ref3.holderCallback;
var updateMark = index === notices.length - 1 ? notice2.updateMark : void 0;
var key2 = notice2.key, userPassKey = notice2.userPassKey;
var noticeProps = _objectSpread2(_objectSpread2(_objectSpread2({
prefixCls,
closeIcon
}, notice2), notice2.props), {}, {
key: key2,
noticeKey: userPassKey || key2,
updateMark,
onClose: function onClose(noticeKey) {
var _notice$onClose;
_this2.remove(noticeKey);
(_notice$onClose = notice2.onClose) === null || _notice$onClose === void 0 ? void 0 : _notice$onClose.call(notice2);
},
onClick: notice2.onClick,
children: notice2.content
});
noticeKeys.push(key2);
_this2.noticePropsMap[key2] = {
props: noticeProps,
holderCallback
};
});
return /* @__PURE__ */ jsx("div", {
className: classNames(prefixCls, className),
style: style2,
children: /* @__PURE__ */ jsx(CSSMotionList, {
keys: noticeKeys,
motionName: this.getTransitionName(),
onVisibleChanged: function onVisibleChanged(changedVisible, _ref4) {
var key2 = _ref4.key;
if (!changedVisible) {
delete _this2.noticePropsMap[key2];
}
},
children: function(_ref5) {
var key2 = _ref5.key, motionClassName = _ref5.className, motionStyle = _ref5.style, visible = _ref5.visible;
var _this2$noticePropsMap = _this2.noticePropsMap[key2], noticeProps = _this2$noticePropsMap.props, holderCallback = _this2$noticePropsMap.holderCallback;
if (holderCallback) {
return /* @__PURE__ */ jsx("div", {
className: classNames(motionClassName, "".concat(prefixCls, "-hook-holder")),
style: _objectSpread2({}, motionStyle),
ref: function ref(div) {
if (typeof key2 === "undefined") {
return;
}
if (div) {
_this2.hookRefs.set(key2, div);
holderCallback(div, noticeProps);
} else {
_this2.hookRefs.delete(key2);
}
}
}, key2);
}
return /* @__PURE__ */ jsx(Notice, {
...noticeProps,
className: classNames(motionClassName, noticeProps === null || noticeProps === void 0 ? void 0 : noticeProps.className),
style: _objectSpread2(_objectSpread2({}, motionStyle), noticeProps === null || noticeProps === void 0 ? void 0 : noticeProps.style),
visible
});
}
})
});
}
}]);
return Notification2;
}(React2.Component);
Notification.newInstance = void 0;
Notification.defaultProps = {
prefixCls: "rc-notification",
animation: "fade",
style: {
top: 65,
left: "50%"
}
};
Notification.newInstance = function newNotificationInstance(properties, callback) {
var _ref6 = properties || {}, getContainer2 = _ref6.getContainer, props = _objectWithoutProperties(_ref6, _excluded);
var div = document.createElement("div");
if (getContainer2) {
var root2 = getContainer2();
root2.appendChild(div);
} else {
document.body.appendChild(div);
}
var called = false;
function ref(notification2) {
if (called) {
return;
}
called = true;
callback({
notice: function notice2(noticeProps) {
notification2.add(noticeProps);
},
removeNotice: function removeNotice(key2) {
notification2.remove(key2);
},
component: notification2,
destroy: function destroy() {
unmount(div);
if (div.parentNode) {
div.parentNode.removeChild(div);
}
},
useNotification: function useNotification$1() {
return useNotification(notification2);
}
});
}
render(
/* @__PURE__ */ jsx(Notification, {
...props,
ref
}),
div
);
};
function createUseMessage(getRcNotificationInstance, getRCNoticeProps2) {
var useMessage = function useMessage2() {
var getPrefixCls;
var getPopupContainer;
var innerInstance = null;
var proxy = {
add: function add(noticeProps, holderCallback) {
innerInstance === null || innerInstance === void 0 ? void 0 : innerInstance.component.add(noticeProps, holderCallback);
}
};
var _useRCNotification = useNotification(proxy), _useRCNotification2 = _slicedToArray(_useRCNotification, 2), hookNotify = _useRCNotification2[0], holder = _useRCNotification2[1];
function notify(args) {
var customizePrefixCls = args.prefixCls;
var mergedPrefixCls = getPrefixCls("message", customizePrefixCls);
var rootPrefixCls = getPrefixCls();
var target = args.key || getKeyThenIncreaseKey();
var closePromise = new Promise(function(resolve) {
var callback = function callback2() {
if (typeof args.onClose === "function") {
args.onClose();
}
return resolve(true);
};
getRcNotificationInstance(_extends$1(_extends$1({}, args), {
prefixCls: mergedPrefixCls,
rootPrefixCls,
getPopupContainer
}), function(_ref) {
var prefixCls = _ref.prefixCls, instance = _ref.instance;
innerInstance = instance;
hookNotify(getRCNoticeProps2(_extends$1(_extends$1({}, args), {
key: target,
onClose: callback
}), prefixCls));
});
});
var result = function result2() {
if (innerInstance) {
innerInstance.removeNotice(target);
}
};
result.then = function(filled, rejected) {
return closePromise.then(filled, rejected);
};
result.promise = closePromise;
return result;
}
var hookApiRef = React__namespace.useRef({});
hookApiRef.current.open = notify;
typeList.forEach(function(type2) {
return attachTypeApi(hookApiRef.current, type2);
});
return [
hookApiRef.current,
/* @__PURE__ */ jsx(ConfigConsumer, {
children: function(context) {
getPrefixCls = context.getPrefixCls;
getPopupContainer = context.getPopupContainer;
return holder;
}
}, "holder")
];
};
return useMessage;
}
var messageInstance;
var defaultDuration$1 = 3;
var defaultTop$1;
var key = 1;
var localPrefixCls = "";
var transitionName = "move-up";
var hasTransitionName = false;
var getContainer;
var maxCount$1;
var rtl$1 = false;
function getKeyThenIncreaseKey() {
return key++;
}
function setMessageConfig(options) {
if (options.top !== void 0) {
defaultTop$1 = options.top;
messageInstance = null;
}
if (options.duration !== void 0) {
defaultDuration$1 = options.duration;
}
if (options.prefixCls !== void 0) {
localPrefixCls = options.prefixCls;
}
if (options.getContainer !== void 0) {
getContainer = options.getContainer;
messageInstance = null;
}
if (options.transitionName !== void 0) {
transitionName = options.transitionName;
messageInstance = null;
hasTransitionName = true;
}
if (options.maxCount !== void 0) {
maxCount$1 = options.maxCount;
messageInstance = null;
}
if (options.rtl !== void 0) {
rtl$1 = options.rtl;
}
}
function getRCNotificationInstance(args, callback) {
var customizePrefixCls = args.prefixCls, getContextPopupContainer = args.getPopupContainer;
var _globalConfig = globalConfig(), getPrefixCls = _globalConfig.getPrefixCls, getRootPrefixCls = _globalConfig.getRootPrefixCls, getIconPrefixCls = _globalConfig.getIconPrefixCls;
var prefixCls = getPrefixCls("message", customizePrefixCls || localPrefixCls);
var rootPrefixCls = getRootPrefixCls(args.rootPrefixCls, prefixCls);
var iconPrefixCls = getIconPrefixCls();
if (messageInstance) {
callback({
prefixCls,
rootPrefixCls,
iconPrefixCls,
instance: messageInstance
});
return;
}
var instanceConfig = {
prefixCls,
transitionName: hasTransitionName ? transitionName : "".concat(rootPrefixCls, "-").concat(transitionName),
style: {
top: defaultTop$1
},
getContainer: getContainer || getContextPopupContainer,
maxCount: maxCount$1
};
Notification.newInstance(instanceConfig, function(instance) {
if (messageInstance) {
callback({
prefixCls,
rootPrefixCls,
iconPrefixCls,
instance: messageInstance
});
return;
}
messageInstance = instance;
callback({
prefixCls,
rootPrefixCls,
iconPrefixCls,
instance
});
});
}
var typeToIcon$1 = {
info: InfoCircleFilled$1,
success: CheckCircleFilled$1,
error: CloseCircleFilled$1,
warning: ExclamationCircleFilled$1,
loading: LoadingOutlined$1
};
var typeList = Object.keys(typeToIcon$1);
function getRCNoticeProps$1(args, prefixCls, iconPrefixCls) {
var _classNames;
var duration = args.duration !== void 0 ? args.duration : defaultDuration$1;
var IconComponent = typeToIcon$1[args.type];
var messageClass = classNames("".concat(prefixCls, "-custom-content"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(args.type), args.type), _defineProperty(_classNames, "".concat(prefixCls, "-rtl"), rtl$1 === true), _classNames));
return {
key: args.key,
duration,
style: args.style || {},
className: args.className,
content: /* @__PURE__ */ jsx(ConfigProvider, {
iconPrefixCls,
children: /* @__PURE__ */ jsxs("div", {
className: messageClass,
children: [args.icon || IconComponent && /* @__PURE__ */ jsx(IconComponent, {}), /* @__PURE__ */ jsx("span", {
children: args.content
})]
})
}),
onClose: args.onClose,
onClick: args.onClick
};
}
function notice$1(args) {
var target = args.key || getKeyThenIncreaseKey();
var closePromise = new Promise(function(resolve) {
var callback = function callback2() {
if (typeof args.onClose === "function") {
args.onClose();
}
return resolve(true);
};
getRCNotificationInstance(args, function(_ref) {
var prefixCls = _ref.prefixCls, iconPrefixCls = _ref.iconPrefixCls, instance = _ref.instance;
instance.notice(getRCNoticeProps$1(_extends$1(_extends$1({}, args), {
key: target,
onClose: callback
}), prefixCls, iconPrefixCls));
});
});
var result = function result2() {
var _a;
if (messageInstance) {
messageInstance.removeNotice(target);
(_a = args.onClose) === null || _a === void 0 ? void 0 : _a.call(args);
}
};
result.then = function(filled, rejected) {
return closePromise.then(filled, rejected);
};
result.promise = closePromise;
return result;
}
function isArgsProps(content) {
return Object.prototype.toString.call(content) === "[object Object]" && !!content.content;
}
var api$1 = {
open: notice$1,
config: setMessageConfig,
destroy: function destroy(messageKey) {
if (messageInstance) {
if (messageKey) {
var _messageInstance = messageInstance, removeNotice = _messageInstance.removeNotice;
removeNotice(messageKey);
} else {
var _messageInstance2 = messageInstance, destroy2 = _messageInstance2.destroy;
destroy2();
messageInstance = null;
}
}
}
};
function attachTypeApi(originalApi, type2) {
originalApi[type2] = function(content, duration, onClose) {
if (isArgsProps(content)) {
return originalApi.open(_extends$1(_extends$1({}, content), {
type: type2
}));
}
if (typeof duration === "function") {
onClose = duration;
duration = void 0;
}
return originalApi.open({
content,
duration,
type: type2,
onClose
});
};
}
typeList.forEach(function(type2) {
return attachTypeApi(api$1, type2);
});
api$1.warn = api$1.warning;
api$1.useMessage = createUseMessage(getRCNotificationInstance, getRCNoticeProps$1);
const message = api$1;
var CheckCircleOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M699 353h-46.9c-10.2 0-19.9 4.9-25.9 13.3L469 584.3l-71.2-98.8c-6-8.3-15.6-13.3-25.9-13.3H325c-6.5 0-10.3 7.4-6.5 12.7l124.6 172.8a31.8 31.8 0 0051.7 0l210.6-292c3.9-5.3.1-12.7-6.4-12.7z" } }, { "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" } }] }, "name": "check-circle", "theme": "outlined" };
const CheckCircleOutlinedSvg = CheckCircleOutlined$2;
var CheckCircleOutlined = function CheckCircleOutlined2(props, ref) {
return /* @__PURE__ */ jsx(AntdIcon, {
..._objectSpread2(_objectSpread2({}, props), {}, {
ref,
icon: CheckCircleOutlinedSvg
})
});
};
CheckCircleOutlined.displayName = "CheckCircleOutlined";
const CheckCircleOutlined$1 = /* @__PURE__ */ React__namespace.forwardRef(CheckCircleOutlined);
var CloseCircleOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M685.4 354.8c0-4.4-3.6-8-8-8l-66 .3L512 465.6l-99.3-118.4-66.1-.3c-4.4 0-8 3.5-8 8 0 1.9.7 3.7 1.9 5.2l130.1 155L340.5 670a8.32 8.32 0 00-1.9 5.2c0 4.4 3.6 8 8 8l66.1-.3L512 564.4l99.3 118.4 66 .3c4.4 0 8-3.5 8-8 0-1.9-.7-3.7-1.9-5.2L553.5 515l130.1-155c1.2-1.4 1.8-3.3 1.8-5.2z" } }, { "tag": "path", "attrs": { "d": "M512 65C264.6 65 64 265.6 64 513s200.6 448 448 448 448-200.6 448-448S759.4 65 512 65zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" } }] }, "name": "close-circle", "theme": "outlined" };
const CloseCircleOutlinedSvg = CloseCircleOutlined$2;
var CloseCircleOutlined = function CloseCircleOutlined2(props, ref) {
return /* @__PURE__ */ jsx(AntdIcon, {
..._objectSpread2(_objectSpread2({}, props), {}, {
ref,
icon: CloseCircleOutlinedSvg
})
});
};
CloseCircleOutlined.displayName = "CloseCircleOutlined";
const CloseCircleOutlined$1 = /* @__PURE__ */ React__namespace.forwardRef(CloseCircleOutlined);
var CloseOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z" } }] }, "name": "close", "theme": "outlined" };
const CloseOutlinedSvg = CloseOutlined$2;
var CloseOutlined = function CloseOutlined2(props, ref) {
return /* @__PURE__ */ jsx(AntdIcon, {
..._objectSpread2(_objectSpread2({}, props), {}, {
ref,
icon: CloseOutlinedSvg
})
});
};
CloseOutlined.displayName = "CloseOutlined";
const CloseOutlined$1 = /* @__PURE__ */ React__namespace.forwardRef(CloseOutlined);
var ExclamationCircleOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" } }, { "tag": "path", "attrs": { "d": "M464 688a48 48 0 1096 0 48 48 0 10-96 0zm24-112h48c4.4 0 8-3.6 8-8V296c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8z" } }] }, "name": "exclamation-circle", "theme": "outlined" };
const ExclamationCircleOutlinedSvg = ExclamationCircleOutlined$2;
var ExclamationCircleOutlined = function ExclamationCircleOutlined2(props, ref) {
return /* @__PURE__ */ jsx(AntdIcon, {
..._objectSpread2(_objectSpread2({}, props), {}, {
ref,
icon: ExclamationCircleOutlinedSvg
})
});
};
ExclamationCircleOutlined.displayName = "ExclamationCircleOutlined";
const ExclamationCircleOutlined$1 = /* @__PURE__ */ React__namespace.forwardRef(ExclamationCircleOutlined);
var InfoCircleOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" } }, { "tag": "path", "attrs": { "d": "M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z" } }] }, "name": "info-circle", "theme": "outlined" };
const InfoCircleOutlinedSvg = InfoCircleOutlined$2;
var InfoCircleOutlined = function InfoCircleOutlined2(props, ref) {
return /* @__PURE__ */ jsx(AntdIcon, {
..._objectSpread2(_objectSpread2({}, props), {}, {
ref,
icon: InfoCircleOutlinedSvg
})
});
};
InfoCircleOutlined.displayName = "InfoCircleOutlined";
const InfoCircleOutlined$1 = /* @__PURE__ */ React__namespace.forwardRef(InfoCircleOutlined);
function createUseNotification(getNotificationInstance2, getRCNoticeProps2) {
var useNotification$1 = function useNotification$12() {
var getPrefixCls;
var innerInstance = null;
var proxy = {
add: function add(noticeProps, holderCallback) {
innerInstance === null || innerInstance === void 0 ? void 0 : innerInstance.component.add(noticeProps, holderCallback);
}
};
var _useRCNotification = useNotification(proxy), _useRCNotification2 = _slicedToArray(_useRCNotification, 2), hookNotify = _useRCNotification2[0], holder = _useRCNotification2[1];
function notify(args) {
var customizePrefixCls = args.prefixCls;
var mergedPrefixCls = getPrefixCls("notification", customizePrefixCls);
getNotificationInstance2(_extends$1(_extends$1({}, args), {
prefixCls: mergedPrefixCls
}), function(_ref) {
var prefixCls = _ref.prefixCls, instance = _ref.instance;
innerInstance = instance;
hookNotify(getRCNoticeProps2(args, prefixCls));
});
}
var hookApiRef = React__namespace.useRef({});
hookApiRef.current.open = notify;
["success", "info", "warning", "error"].forEach(function(type2) {
hookApiRef.current[type2] = function(args) {
return hookApiRef.current.open(_extends$1(_extends$1({}, args), {
type: type2
}));
};
});
return [
hookApiRef.current,
/* @__PURE__ */ jsx(ConfigConsumer, {
children: function(context) {
getPrefixCls = context.getPrefixCls;
return holder;
}
}, "holder")
];
};
return useNotification$1;
}
globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e2) {
reject(e2);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e2) {
reject(e2);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var notificationInstance = {};
var defaultDuration = 4.5;
var defaultTop = 24;
var defaultBottom = 24;
var defaultPrefixCls$1 = "";
var defaultPlacement = "topRight";
var defaultGetContainer;
var defaultCloseIcon;
var rtl = false;
var maxCount;
function setNotificationConfig(options) {
var duration = options.duration, placement = options.placement, bottom = options.bottom, top = options.top, getContainer2 = options.getContainer, closeIcon = options.closeIcon, prefixCls = options.prefixCls;
if (prefixCls !== void 0) {
defaultPrefixCls$1 = prefixCls;
}
if (duration !== void 0) {
defaultDuration = duration;
}
if (placement !== void 0) {
defaultPlacement = placement;
} else if (options.rtl) {
defaultPlacement = "topLeft";
}
if (bottom !== void 0) {
defaultBottom = bottom;
}
if (top !== void 0) {
defaultTop = top;
}
if (getContainer2 !== void 0) {
defaultGetContainer = getContainer2;
}
if (closeIcon !== void 0) {
defaultCloseIcon = closeIcon;
}
if (options.rtl !== void 0) {
rtl = options.rtl;
}
if (options.maxCount !== void 0) {
maxCount = options.maxCount;
}
}
function getPlacementStyle(placement) {
var top = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultTop;
var bottom = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : defaultBottom;
var style2;
switch (placement) {
case "top":
style2 = {
left: "50%",
transform: "translateX(-50%)",
right: "auto",
top,
bottom: "auto"
};
break;
case "topLeft":
style2 = {
left: 0,
top,
bottom: "auto"
};
break;
case "topRight":
style2 = {
right: 0,
top,
bottom: "auto"
};
break;
case "bottom":
style2 = {
left: "50%",
transform: "translateX(-50%)",
right: "auto",
top: "auto",
bottom
};
break;
case "bottomLeft":
style2 = {
left: 0,
top: "auto",
bottom
};
break;
default:
style2 = {
right: 0,
top: "auto",
bottom
};
break;
}
return style2;
}
function getNotificationInstance(args, callback) {
var _args$placement = args.placement, placement = _args$placement === void 0 ? defaultPlacement : _args$placement, top = args.top, bottom = args.bottom, _args$getContainer = args.getContainer, getContainer2 = _args$getContainer === void 0 ? defaultGetContainer : _args$getContainer, customizePrefixCls = args.prefixCls;
var _globalConfig = globalConfig(), getPrefixCls = _globalConfig.getPrefixCls, getIconPrefixCls = _globalConfig.getIconPrefixCls;
var prefixCls = getPrefixCls("notification", customizePrefixCls || defaultPrefixCls$1);
var iconPrefixCls = getIconPrefixCls();
var cacheKey = "".concat(prefixCls, "-").concat(placement);
var cacheInstance = notificationInstance[cacheKey];
if (cacheInstance) {
Promise.resolve(cacheInstance).then(function(instance) {
callback({
prefixCls: "".concat(prefixCls, "-notice"),
iconPrefixCls,
instance
});
});
return;
}
var notificationClass = classNames("".concat(prefixCls, "-").concat(placement), _defineProperty({}, "".concat(prefixCls, "-rtl"), rtl === true));
notificationInstance[cacheKey] = new Promise(function(resolve) {
Notification.newInstance({
prefixCls,
className: notificationClass,
style: getPlacementStyle(placement, top, bottom),
getContainer: getContainer2,
maxCount
}, function(notification2) {
resolve(notification2);
callback({
prefixCls: "".concat(prefixCls, "-notice"),
iconPrefixCls,
instance: notification2
});
});
});
}
var typeToIcon = {
success: CheckCircleOutlined$1,
info: InfoCircleOutlined$1,
error: CloseCircleOutlined$1,
warning: ExclamationCircleOutlined$1
};
function getRCNoticeProps(args, prefixCls, iconPrefixCls) {
var durationArg = args.duration, icon = args.icon, type2 = args.type, description = args.description, message2 = args.message, btn = args.btn, onClose = args.onClose, onClick = args.onClick, key2 = args.key, style2 = args.style, className = args.className, _args$closeIcon = args.closeIcon, closeIcon = _args$closeIcon === void 0 ? defaultCloseIcon : _args$closeIcon, props = args.props;
var duration = durationArg === void 0 ? defaultDuration : durationArg;
var iconNode = null;
if (icon) {
iconNode = /* @__PURE__ */ jsx("span", {
className: "".concat(prefixCls, "-icon"),
children: args.icon
});
} else if (type2) {
iconNode = /* @__PURE__ */ React__namespace.createElement(typeToIcon[type2] || null, {
className: "".concat(prefixCls, "-icon ").concat(prefixCls, "-icon-").concat(type2)
});
}
var closeIconToRender = /* @__PURE__ */ jsx("span", {
className: "".concat(prefixCls, "-close-x"),
children: closeIcon || /* @__PURE__ */ jsx(CloseOutlined$1, {
className: "".concat(prefixCls, "-close-icon")
})
});
var autoMarginTag = !description && iconNode ? /* @__PURE__ */ jsx("span", {
className: "".concat(prefixCls, "-message-single-line-auto-margin")
}) : null;
return {
content: /* @__PURE__ */ jsx(ConfigProvider, {
iconPrefixCls,
children: /* @__PURE__ */ jsxs("div", {
className: iconNode ? "".concat(prefixCls, "-with-icon") : "",
role: "alert",
children: [iconNode, /* @__PURE__ */ jsxs("div", {
className: "".concat(prefixCls, "-message"),
children: [autoMarginTag, message2]
}), /* @__PURE__ */ jsx("div", {
className: "".concat(prefixCls, "-description"),
children: description
}), btn ? /* @__PURE__ */ jsx("span", {
className: "".concat(prefixCls, "-btn"),
children: btn
}) : null]
})
}),
duration,
closable: true,
closeIcon: closeIconToRender,
onClose,
onClick,
key: key2,
style: style2 || {},
className: classNames(className, _defineProperty({}, "".concat(prefixCls, "-").concat(type2), !!type2)),
props
};
}
function notice(args) {
getNotificationInstance(args, function(_ref) {
var prefixCls = _ref.prefixCls, iconPrefixCls = _ref.iconPrefixCls, instance = _ref.instance;
instance.notice(getRCNoticeProps(args, prefixCls, iconPrefixCls));
});
}
var api = {
open: notice,
close: function close(key2) {
Object.keys(notificationInstance).forEach(function(cacheKey) {
return Promise.resolve(notificationInstance[cacheKey]).then(function(instance) {
instance.removeNotice(key2);
});
});
},
config: setNotificationConfig,
destroy: function destroy() {
Object.keys(notificationInstance).forEach(function(cacheKey) {
Promise.resolve(notificationInstance[cacheKey]).then(function(instance) {
instance.destroy();
});
delete notificationInstance[cacheKey];
});
}
};
["success", "info", "warning", "error"].forEach(function(type2) {
api[type2] = function(args) {
return api.open(_extends$1(_extends$1({}, args), {
type: type2
}));
};
});
api.warn = api.warning;
api.useNotification = createUseNotification(getNotificationInstance, getRCNoticeProps);
const notification = api;
var defaultGetPrefixCls = function defaultGetPrefixCls2(suffixCls, customizePrefixCls) {
if (customizePrefixCls)
return customizePrefixCls;
return suffixCls ? "ant-".concat(suffixCls) : "ant";
};
var ConfigContext = /* @__PURE__ */ React__namespace.createContext({
getPrefixCls: defaultGetPrefixCls
});
var ConfigConsumer = ConfigContext.Consumer;
var dynamicStyleMark = "-ant-".concat(Date.now(), "-").concat(Math.random());
function getStyle(globalPrefixCls2, theme) {
var variables = {};
var formatColor = function formatColor2(color, updater) {
var clone = color.clone();
clone = (updater === null || updater === void 0 ? void 0 : updater(clone)) || clone;
return clone.toRgbString();
};
var fillColor = function fillColor2(colorVal, type2) {
var baseColor = new TinyColor(colorVal);
var colorPalettes = generate$1(baseColor.toRgbString());
variables["".concat(type2, "-color")] = formatColor(baseColor);
variables["".concat(type2, "-color-disabled")] = colorPalettes[1];
variables["".concat(type2, "-color-hover")] = colorPalettes[4];
variables["".concat(type2, "-color-active")] = colorPalettes[6];
variables["".concat(type2, "-color-outline")] = baseColor.clone().setAlpha(0.2).toRgbString();
variables["".concat(type2, "-color-deprecated-bg")] = colorPalettes[0];
variables["".concat(type2, "-color-deprecated-border")] = colorPalettes[2];
};
if (theme.primaryColor) {
fillColor(theme.primaryColor, "primary");
var primaryColor = new TinyColor(theme.primaryColor);
var primaryColors = generate$1(primaryColor.toRgbString());
primaryColors.forEach(function(color, index) {
variables["primary-".concat(index + 1)] = color;
});
variables["primary-color-deprecated-l-35"] = formatColor(primaryColor, function(c2) {
return c2.lighten(35);
});
variables["primary-color-deprecated-l-20"] = formatColor(primaryColor, function(c2) {
return c2.lighten(20);
});
variables["primary-color-deprecated-t-20"] = formatColor(primaryColor, function(c2) {
return c2.tint(20);
});
variables["primary-color-deprecated-t-50"] = formatColor(primaryColor, function(c2) {
return c2.tint(50);
});
variables["primary-color-deprecated-f-12"] = formatColor(primaryColor, function(c2) {
return c2.setAlpha(c2.getAlpha() * 0.12);
});
var primaryActiveColor = new TinyColor(primaryColors[0]);
variables["primary-color-active-deprecated-f-30"] = formatColor(primaryActiveColor, function(c2) {
return c2.setAlpha(c2.getAlpha() * 0.3);
});
variables["primary-color-active-deprecated-d-02"] = formatColor(primaryActiveColor, function(c2) {
return c2.darken(2);
});
}
if (theme.successColor) {
fillColor(theme.successColor, "success");
}
if (theme.warningColor) {
fillColor(theme.warningColor, "warning");
}
if (theme.errorColor) {
fillColor(theme.errorColor, "error");
}
if (theme.infoColor) {
fillColor(theme.infoColor, "info");
}
var cssList = Object.keys(variables).map(function(key2) {
return "--".concat(globalPrefixCls2, "-").concat(key2, ": ").concat(variables[key2], ";");
});
return "\n :root {\n ".concat(cssList.join("\n"), "\n }\n ").trim();
}
function registerTheme(globalPrefixCls2, theme) {
var style2 = getStyle(globalPrefixCls2, theme);
if (canUseDom()) {
updateCSS(style2, "".concat(dynamicStyleMark, "-dynamic-theme"));
}
}
var DisabledContext = /* @__PURE__ */ React__namespace.createContext(false);
var DisabledContextProvider = function DisabledContextProvider2(_ref) {
var children = _ref.children, disabled = _ref.disabled;
var originDisabled = React__namespace.useContext(DisabledContext);
return /* @__PURE__ */ jsx(DisabledContext.Provider, {
value: disabled !== null && disabled !== void 0 ? disabled : originDisabled,
children
});
};
var SizeContext = /* @__PURE__ */ React__namespace.createContext(void 0);
var SizeContextProvider = function SizeContextProvider2(_ref) {
var children = _ref.children, size = _ref.size;
return /* @__PURE__ */ jsx(SizeContext.Consumer, {
children: function(originSize) {
return /* @__PURE__ */ jsx(SizeContext.Provider, {
value: size || originSize,
children
});
}
});
};
const SizeContext$1 = SizeContext;
var PASSED_PROPS = ["getTargetContainer", "getPopupContainer", "renderEmpty", "pageHeader", "input", "pagination", "form"];
var defaultPrefixCls = "ant";
var defaultIconPrefixCls = "anticon";
var globalPrefixCls;
var globalIconPrefixCls;
function getGlobalPrefixCls() {
return globalPrefixCls || defaultPrefixCls;
}
function getGlobalIconPrefixCls() {
return globalIconPrefixCls || defaultIconPrefixCls;
}
var setGlobalConfig = function setGlobalConfig2(_ref) {
var prefixCls = _ref.prefixCls, iconPrefixCls = _ref.iconPrefixCls, theme = _ref.theme;
if (prefixCls !== void 0) {
globalPrefixCls = prefixCls;
}
if (iconPrefixCls !== void 0) {
globalIconPrefixCls = iconPrefixCls;
}
if (theme) {
registerTheme(getGlobalPrefixCls(), theme);
}
};
var globalConfig = function globalConfig2() {
return {
getPrefixCls: function getPrefixCls(suffixCls, customizePrefixCls) {
if (customizePrefixCls)
return customizePrefixCls;
return suffixCls ? "".concat(getGlobalPrefixCls(), "-").concat(suffixCls) : getGlobalPrefixCls();
},
getIconPrefixCls: getGlobalIconPrefixCls,
getRootPrefixCls: function getRootPrefixCls(rootPrefixCls, customizePrefixCls) {
if (rootPrefixCls) {
return rootPrefixCls;
}
if (globalPrefixCls) {
return globalPrefixCls;
}
if (customizePrefixCls && customizePrefixCls.includes("-")) {
return customizePrefixCls.replace(/^(.*)-[^-]*$/, "$1");
}
return getGlobalPrefixCls();
}
};
};
var ProviderChildren = function ProviderChildren2(props) {
var _a, _b;
var children = props.children, csp = props.csp, autoInsertSpaceInButton = props.autoInsertSpaceInButton, form = props.form, locale2 = props.locale, componentSize = props.componentSize, direction = props.direction, space = props.space, virtual = props.virtual, dropdownMatchSelectWidth = props.dropdownMatchSelectWidth, legacyLocale = props.legacyLocale, parentContext = props.parentContext, iconPrefixCls = props.iconPrefixCls, componentDisabled = props.componentDisabled;
var getPrefixCls = React__namespace.useCallback(function(suffixCls, customizePrefixCls) {
var prefixCls = props.prefixCls;
if (customizePrefixCls)
return customizePrefixCls;
var mergedPrefixCls = prefixCls || parentContext.getPrefixCls("");
return suffixCls ? "".concat(mergedPrefixCls, "-").concat(suffixCls) : mergedPrefixCls;
}, [parentContext.getPrefixCls, props.prefixCls]);
var config = _extends$1(_extends$1({}, parentContext), {
csp,
autoInsertSpaceInButton,
locale: locale2 || legacyLocale,
direction,
space,
virtual,
dropdownMatchSelectWidth,
getPrefixCls
});
PASSED_PROPS.forEach(function(propName) {
var propValue = props[propName];
if (propValue) {
config[propName] = propValue;
}
});
var memoedConfig = useMemo(function() {
return config;
}, config, function(prevConfig, currentConfig) {
var prevKeys = Object.keys(prevConfig);
var currentKeys = Object.keys(currentConfig);
return prevKeys.length !== currentKeys.length || prevKeys.some(function(key2) {
return prevConfig[key2] !== currentConfig[key2];
});
});
var memoIconContextValue = React__namespace.useMemo(function() {
return {
prefixCls: iconPrefixCls,
csp
};
}, [iconPrefixCls, csp]);
var childNode = children;
var validateMessages = {};
if (locale2) {
validateMessages = ((_a = locale2.Form) === null || _a === void 0 ? void 0 : _a.defaultValidateMessages) || ((_b = defaultLocale.Form) === null || _b === void 0 ? void 0 : _b.defaultValidateMessages) || {};
}
if (form && form.validateMessages) {
validateMessages = _extends$1(_extends$1({}, validateMessages), form.validateMessages);
}
if (Object.keys(validateMessages).length > 0) {
childNode = /* @__PURE__ */ jsx(FormProvider, {
validateMessages,
children
});
}
if (locale2) {
childNode = /* @__PURE__ */ jsx(LocaleProvider$1, {
locale: locale2,
_ANT_MARK__: ANT_MARK,
children: childNode
});
}
if (iconPrefixCls || csp) {
childNode = /* @__PURE__ */ jsx(IconContext$1.Provider, {
value: memoIconContextValue,
children: childNode
});
}
if (componentSize) {
childNode = /* @__PURE__ */ jsx(SizeContextProvider, {
size: componentSize,
children: childNode
});
}
if (componentDisabled !== void 0) {
childNode = /* @__PURE__ */ jsx(DisabledContextProvider, {
disabled: componentDisabled,
children: childNode
});
}
return /* @__PURE__ */ jsx(ConfigContext.Provider, {
value: memoedConfig,
children: childNode
});
};
var ConfigProvider = function ConfigProvider2(props) {
React__namespace.useEffect(function() {
if (props.direction) {
message.config({
rtl: props.direction === "rtl"
});
notification.config({
rtl: props.direction === "rtl"
});
}
}, [props.direction]);
return /* @__PURE__ */ jsx(LocaleReceiver$1, {
children: function(_, __, legacyLocale) {
return /* @__PURE__ */ jsx(ConfigConsumer, {
children: function(context) {
return /* @__PURE__ */ jsx(ProviderChildren, {
parentContext: context,
legacyLocale,
...props
});
}
});
}
});
};
ConfigProvider.ConfigContext = ConfigContext;
ConfigProvider.SizeContext = SizeContext$1;
ConfigProvider.config = setGlobalConfig;
const App$1 = "";
function App() {
const [copyContent, setCopyContent] = React2.useState("");
React2.useEffect(() => {
document.querySelectorAll("pre");
let jsCodeDivList = document.querySelectorAll(".line-numbers-mode");
jsCodeDivList.forEach((item, index) => {
item.onclick = function() {
let turndownService = new TurndownService();
turndownService.use(gfm);
turndownService.use([tables, strikethrough]);
let markdown = turndownService.turndown(item.children[0]);
console.log(markdown);
setCopyContent(markdown);
};
});
}, []);
React2.useEffect(() => {
console.log("jinru");
onCopy(copyContent);
}, [copyContent]);
const onCopy = (copyContent2) => {
if (copyContent2) {
let oInput = document.createElement("textarea");
oInput.value = copyContent2;
document.body.appendChild(oInput);
oInput.select();
document.execCommand("Copy");
message.success("\u590D\u5236\u6210\u529F!");
oInput.remove();
}
};
return /* @__PURE__ */ jsx("div", {
children: "\u4F60\u597D"
});
}
client.createRoot((() => {
const app = document.createElement("div");
document.body.append(app);
return app;
})()).render(/* @__PURE__ */ jsx(React__default.default.Fragment, {
children: /* @__PURE__ */ jsx(App, {})
}));
})(React, ReactDOM);