/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */

var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var constants_exports = {};
__export(constants_exports, {
  ACTION_MODEL_USES: () => ACTION_MODEL_USES,
  ACTION_TYPE_ALIASES: () => ACTION_TYPE_ALIASES,
  ALLOWED_CTX_ROOTS: () => ALLOWED_CTX_ROOTS,
  API_RESOURCE_METHODS: () => API_RESOURCE_METHODS,
  AST_CTX_METHOD_NAMES: () => AST_CTX_METHOD_NAMES,
  BLOCKED_CTX_CAPABILITIES: () => BLOCKED_CTX_CAPABILITIES,
  CANONICAL_CTX_LIB_MEMBERS: () => CANONICAL_CTX_LIB_MEMBERS,
  CHART_CTX_ROOTS: () => CHART_CTX_ROOTS,
  CONTEXT_FIRST_REPAIR_CLASSES: () => CONTEXT_FIRST_REPAIR_CLASSES,
  CTX_LIB_MEMBER_BY_LOWERCASE: () => CTX_LIB_MEMBER_BY_LOWERCASE,
  FLOW_RESOURCE_BASE_METHODS: () => FLOW_RESOURCE_BASE_METHODS,
  FLOW_RESOURCE_CLASS_NAMES: () => FLOW_RESOURCE_CLASS_NAMES,
  FLOW_RESOURCE_METHODS_BY_TYPE: () => FLOW_RESOURCE_METHODS_BY_TYPE,
  FLOW_RESOURCE_METHOD_SUGGESTIONS: () => FLOW_RESOURCE_METHOD_SUGGESTIONS,
  FORBIDDEN_BARE_GLOBALS: () => FORBIDDEN_BARE_GLOBALS,
  INIT_RESOURCE_CLASS_NAMES: () => INIT_RESOURCE_CLASS_NAMES,
  KNOWN_MODEL_USES: () => KNOWN_MODEL_USES,
  MAX_RUNJS_ERRORS_PER_SOURCE: () => MAX_RUNJS_ERRORS_PER_SOURCE,
  MAX_RUNJS_SOURCES_PER_REQUEST: () => MAX_RUNJS_SOURCES_PER_REQUEST,
  MAX_RUNJS_SOURCE_LENGTH: () => MAX_RUNJS_SOURCE_LENGTH,
  MAX_RUNJS_TOTAL_SOURCE_LENGTH: () => MAX_RUNJS_TOTAL_SOURCE_LENGTH,
  MULTI_RECORD_RESOURCE_METHODS: () => MULTI_RECORD_RESOURCE_METHODS,
  NON_METHOD_CALL_KEYWORDS: () => NON_METHOD_CALL_KEYWORDS,
  PUBLIC_BLOCK_TYPE_BY_MODEL_USE: () => PUBLIC_BLOCK_TYPE_BY_MODEL_USE,
  REACT_HOOK_NAMES: () => REACT_HOOK_NAMES,
  REACT_HOOK_PATTERN: () => REACT_HOOK_PATTERN,
  REACT_NODE_COMPONENT_PROP_NAMES: () => REACT_NODE_COMPONENT_PROP_NAMES,
  RECORD_RESOURCE_METHODS: () => RECORD_RESOURCE_METHODS,
  RENDER_MODEL_USES: () => RENDER_MODEL_USES,
  RUNJS_ALLOWED_BARE_GLOBALS: () => RUNJS_ALLOWED_BARE_GLOBALS,
  RUNJS_ALLOWED_BARE_GLOBALS_BY_MODEL_USE: () => RUNJS_ALLOWED_BARE_GLOBALS_BY_MODEL_USE,
  RUNJS_COLLECTION_RESOURCE_ACTIONS: () => RUNJS_COLLECTION_RESOURCE_ACTIONS,
  RUNJS_COLLECTION_RESOURCE_ACTION_ALIASES: () => RUNJS_COLLECTION_RESOURCE_ACTION_ALIASES,
  RUNJS_CONTEXT_AND_RETRY_INSTRUCTION: () => RUNJS_CONTEXT_AND_RETRY_INSTRUCTION,
  RUNJS_CTX_API_ALLOWED_MEMBERS: () => RUNJS_CTX_API_ALLOWED_MEMBERS,
  RUNJS_CTX_API_AUTH_ALLOWED_MEMBERS: () => RUNJS_CTX_API_AUTH_ALLOWED_MEMBERS,
  RUNJS_CTX_LIB_ALLOWED_MEMBERS_BY_LIBRARY: () => RUNJS_CTX_LIB_ALLOWED_MEMBERS_BY_LIBRARY,
  RUNJS_CTX_LIB_ANTD_ALLOWED_MEMBERS: () => RUNJS_CTX_LIB_ANTD_ALLOWED_MEMBERS,
  RUNJS_CTX_NON_FUNCTION_ROOTS: () => RUNJS_CTX_NON_FUNCTION_ROOTS,
  RUNJS_CTX_NON_FUNCTION_ROOTS_BY_MODEL_USE: () => RUNJS_CTX_NON_FUNCTION_ROOTS_BY_MODEL_USE,
  RUNJS_DATE_FILTER_OPERATORS: () => RUNJS_DATE_FILTER_OPERATORS,
  RUNJS_FIX_AND_RETRY_INSTRUCTION: () => RUNJS_FIX_AND_RETRY_INSTRUCTION,
  RUNJS_RESOURCE_ACTION_PATTERN: () => RUNJS_RESOURCE_ACTION_PATTERN,
  RUNJS_RESOURCE_CHAINABLE_STATE_METHODS: () => RUNJS_RESOURCE_CHAINABLE_STATE_METHODS,
  RUNJS_RESOURCE_ENDPOINT_ACTION_PATTERN: () => RUNJS_RESOURCE_ENDPOINT_ACTION_PATTERN,
  RUNJS_RESOURCE_METHODS: () => RUNJS_RESOURCE_METHODS,
  RUNJS_SUPPORTED_FILTER_OPERATORS: () => RUNJS_SUPPORTED_FILTER_OPERATORS,
  RUNJS_UNSUPPORTED_DATE_RANGE_VALUE_KEYS: () => RUNJS_UNSUPPORTED_DATE_RANGE_VALUE_KEYS,
  SINGLE_RECORD_RESOURCE_METHODS: () => SINGLE_RECORD_RESOURCE_METHODS,
  SQL_RESOURCE_METHODS: () => SQL_RESOURCE_METHODS,
  SURFACE_ALLOWED_MODEL_USES: () => SURFACE_ALLOWED_MODEL_USES,
  SURFACE_STYLE_BY_ID: () => SURFACE_STYLE_BY_ID,
  UNKNOWN_FLOW_RESOURCE_METHODS: () => UNKNOWN_FLOW_RESOURCE_METHODS,
  VALUE_MODEL_USES: () => VALUE_MODEL_USES
});
module.exports = __toCommonJS(constants_exports);
var import_database = require("@nocobase/database");
var _ = __toESM(require("lodash"));
var import_sequelize = require("sequelize");
const RENDER_MODEL_USES = /* @__PURE__ */ new Set([
  "JSBlockModel",
  "JSColumnModel",
  "JSFieldModel",
  "JSItemModel",
  "JSEditableFieldModel",
  "FormJSFieldItemModel",
  "JSItemActionModel"
]);
const ACTION_MODEL_USES = /* @__PURE__ */ new Set([
  "JSActionModel",
  "JSFormActionModel",
  "JSRecordActionModel",
  "JSCollectionActionModel",
  "FilterFormJSActionModel",
  "ChartEventsModel"
]);
const VALUE_MODEL_USES = /* @__PURE__ */ new Set(["ChartOptionModel"]);
const KNOWN_MODEL_USES = /* @__PURE__ */ new Set([...RENDER_MODEL_USES, ...ACTION_MODEL_USES, ...VALUE_MODEL_USES]);
const PUBLIC_BLOCK_TYPE_BY_MODEL_USE = {
  TableBlockModel: "table",
  CalendarBlockModel: "calendar",
  TreeBlockModel: "tree",
  KanbanBlockModel: "kanban",
  FormBlockModel: "editForm",
  CreateFormModel: "createForm",
  EditFormModel: "editForm",
  DetailsBlockModel: "details",
  FilterFormBlockModel: "filterForm",
  ListBlockModel: "list",
  GridCardBlockModel: "gridCard",
  ChartBlockModel: "chart",
  MapBlockModel: "map",
  CommentsBlockModel: "comments",
  RecordHistoryBlockModel: "recordHistory",
  JSBlockModel: "jsBlock",
  MarkdownBlockModel: "markdown",
  IframeBlockModel: "iframe",
  ActionPanelBlockModel: "actionPanel"
};
const SURFACE_STYLE_BY_ID = {
  "event-flow.execute-javascript": "action",
  "linkage.execute-javascript": "action",
  "reaction.value-runjs": "value",
  "custom-variable.runjs": "value",
  "js-model.render": "render",
  "js-model.action": "action"
};
const SURFACE_ALLOWED_MODEL_USES = {
  "event-flow.execute-javascript": /* @__PURE__ */ new Set(["JSActionModel"]),
  "linkage.execute-javascript": /* @__PURE__ */ new Set([
    "JSEditableFieldModel",
    "JSItemModel",
    "JSRecordActionModel",
    "JSCollectionActionModel",
    "JSItemActionModel",
    "FormJSFieldItemModel"
  ]),
  "reaction.value-runjs": /* @__PURE__ */ new Set(["JSEditableFieldModel", "JSItemModel", "FormJSFieldItemModel"]),
  "custom-variable.runjs": /* @__PURE__ */ new Set(["JSEditableFieldModel", "JSItemModel", "FormJSFieldItemModel"]),
  "js-model.render": RENDER_MODEL_USES,
  "js-model.action": ACTION_MODEL_USES
};
const ALLOWED_CTX_ROOTS = /* @__PURE__ */ new Set([
  "acl",
  "antd",
  "antdIcons",
  "api",
  "auth",
  "blockModel",
  "collection",
  "collectionField",
  "console",
  "createResource",
  "dataSourceManager",
  "date",
  "dayjs",
  "element",
  "engine",
  "exit",
  "exitAll",
  "filterManager",
  "form",
  "formValues",
  "getApiInfos",
  "getEnvInfos",
  "getModel",
  "getValue",
  "getVar",
  "getVarInfos",
  "i18n",
  "importAsync",
  "initResource",
  "libs",
  "location",
  "logger",
  "makeResource",
  "message",
  "modal",
  "model",
  "notification",
  "off",
  "on",
  "openView",
  "popup",
  "React",
  "ReactDOM",
  "record",
  "render",
  "request",
  "requireAsync",
  "resolveJsonTemplate",
  "resource",
  "role",
  "route",
  "router",
  "runAction",
  "runjs",
  "setValue",
  "sql",
  "t",
  "user",
  "useResource",
  "value",
  "view",
  "viewer"
]);
const CHART_CTX_ROOTS = /* @__PURE__ */ new Set(["data"]);
const BLOCKED_CTX_CAPABILITIES = {};
const FORBIDDEN_BARE_GLOBALS = /* @__PURE__ */ new Set([
  "fetch",
  "localStorage",
  "sessionStorage",
  "XMLHttpRequest",
  "WebSocket",
  "Worker",
  "SharedWorker",
  "ServiceWorker",
  "BroadcastChannel",
  "EventSource",
  "indexedDB",
  "caches",
  "Function",
  "eval",
  "globalThis",
  "Intl",
  "process",
  "require",
  "module",
  "exports",
  "location"
]);
const RUNJS_ALLOWED_BARE_GLOBALS = /* @__PURE__ */ new Set([
  "ctx",
  "console",
  "window",
  "document",
  "navigator",
  "setTimeout",
  "clearTimeout",
  "setInterval",
  "clearInterval",
  "Array",
  "ArrayBuffer",
  "BigInt",
  "BigInt64Array",
  "BigUint64Array",
  "Boolean",
  "DataView",
  "Date",
  "Error",
  "EvalError",
  "FinalizationRegistry",
  "Float32Array",
  "Float64Array",
  "Int8Array",
  "Int16Array",
  "Int32Array",
  "Map",
  "Math",
  "Number",
  "Object",
  "Promise",
  "Proxy",
  "RangeError",
  "ReferenceError",
  "Reflect",
  "RegExp",
  "Set",
  "String",
  "Symbol",
  "SyntaxError",
  "TypeError",
  "URIError",
  "Uint8Array",
  "Uint8ClampedArray",
  "Uint16Array",
  "Uint32Array",
  "WeakMap",
  "WeakRef",
  "WeakSet",
  "JSON",
  "Blob",
  "URL",
  "decodeURI",
  "decodeURIComponent",
  "encodeURI",
  "encodeURIComponent",
  "isFinite",
  "isNaN",
  "parseFloat",
  "parseInt",
  "undefined",
  "NaN",
  "Infinity"
]);
const RUNJS_ALLOWED_BARE_GLOBALS_BY_MODEL_USE = {
  ChartEventsModel: /* @__PURE__ */ new Set(["chart", "params"])
};
const NON_METHOD_CALL_KEYWORDS = /* @__PURE__ */ new Set(["catch", "do", "for", "function", "if", "switch", "while", "with"]);
const ACTION_TYPE_ALIASES = /* @__PURE__ */ new Map([
  ["jsitem", "jsItem"],
  ["js-item", "jsItem"]
]);
const REACT_HOOK_NAMES = [
  "useActionState",
  "useCallback",
  "useContext",
  "useDebugValue",
  "useDeferredValue",
  "useEffect",
  "useId",
  "useImperativeHandle",
  "useInsertionEffect",
  "useLayoutEffect",
  "useMemo",
  "useOptimistic",
  "useReducer",
  "useRef",
  "useState",
  "useSyncExternalStore",
  "useTransition"
];
const REACT_HOOK_PATTERN = REACT_HOOK_NAMES.map(escapeRegExp).join("|");
const RUNJS_RESOURCE_ACTION_PATTERN = "(?:list|get|create|update|destroy)";
const MAX_RUNJS_SOURCE_LENGTH = 64 * 1024;
const MAX_RUNJS_TOTAL_SOURCE_LENGTH = 256 * 1024;
const MAX_RUNJS_SOURCES_PER_REQUEST = 100;
const MAX_RUNJS_ERRORS_PER_SOURCE = 20;
const RUNJS_SUPPORTED_FILTER_OPERATORS = buildRunJsSupportedFilterOperators();
const RUNJS_DATE_FILTER_OPERATORS = /* @__PURE__ */ new Set([
  "$dateOn",
  "$dateNotOn",
  "$dateBefore",
  "$dateAfter",
  "$dateNotBefore",
  "$dateNotAfter",
  "$dateBetween"
]);
const RUNJS_UNSUPPORTED_DATE_RANGE_VALUE_KEYS = /* @__PURE__ */ new Set(["$dateFrom", "$dateTo"]);
const FLOW_RESOURCE_CLASS_NAMES = /* @__PURE__ */ new Set([
  "FlowResource",
  "APIResource",
  "SingleRecordResource",
  "MultiRecordResource",
  "SQLResource"
]);
const INIT_RESOURCE_CLASS_NAMES = /* @__PURE__ */ new Set([
  "APIResource",
  "SingleRecordResource",
  "MultiRecordResource",
  "SQLResource"
]);
const AST_CTX_METHOD_NAMES = /* @__PURE__ */ new Set(["runjs", "makeResource", "initResource", "render", "request"]);
const RUNJS_CTX_NON_FUNCTION_ROOTS = /* @__PURE__ */ new Set([
  "acl",
  "antd",
  "antdIcons",
  "api",
  "auth",
  "blockModel",
  "collection",
  "collectionField",
  "console",
  "dataSourceManager",
  "date",
  "element",
  "engine",
  "filterManager",
  "form",
  "formValues",
  "i18n",
  "libs",
  "location",
  "logger",
  "message",
  "modal",
  "model",
  "notification",
  "popup",
  "React",
  "ReactDOM",
  "record",
  "resource",
  "role",
  "route",
  "router",
  "sql",
  "user",
  "value",
  "view",
  "viewer"
]);
const RUNJS_CTX_NON_FUNCTION_ROOTS_BY_MODEL_USE = {
  ChartEventsModel: CHART_CTX_ROOTS,
  ChartOptionModel: CHART_CTX_ROOTS
};
const REACT_NODE_COMPONENT_PROP_NAMES = /* @__PURE__ */ new Set(["avatar", "extra", "icon", "prefix", "suffix"]);
const CANONICAL_CTX_LIB_MEMBERS = [
  "React",
  "ReactDOM",
  "antd",
  "dayjs",
  "antdIcons",
  "lodash",
  "formula",
  "math"
];
const CTX_LIB_MEMBER_BY_LOWERCASE = new Map(
  CANONICAL_CTX_LIB_MEMBERS.map((member) => [member.toLowerCase(), member])
);
const RUNJS_CTX_LIB_ANTD_ALLOWED_MEMBERS = /* @__PURE__ */ new Set([
  "Affix",
  "Alert",
  "Anchor",
  "App",
  "AutoComplete",
  "Avatar",
  "BackTop",
  "Badge",
  "Breadcrumb",
  "Button",
  "Calendar",
  "Card",
  "Carousel",
  "Cascader",
  "Checkbox",
  "Col",
  "Collapse",
  "ColorPicker",
  "ConfigProvider",
  "DatePicker",
  "Descriptions",
  "Divider",
  "Drawer",
  "Dropdown",
  "Empty",
  "Flex",
  "FloatButton",
  "Form",
  "Grid",
  "Image",
  "Input",
  "InputNumber",
  "Layout",
  "List",
  "Mentions",
  "Menu",
  "Modal",
  "Pagination",
  "Popconfirm",
  "Popover",
  "Progress",
  "QRCode",
  "Radio",
  "Rate",
  "Result",
  "Row",
  "Segmented",
  "Select",
  "Skeleton",
  "Slider",
  "Space",
  "Spin",
  "Splitter",
  "Statistic",
  "Steps",
  "Switch",
  "Table",
  "Tabs",
  "Tag",
  "TimePicker",
  "Timeline",
  "Tooltip",
  "Tour",
  "Transfer",
  "Tree",
  "TreeSelect",
  "Typography",
  "Upload",
  "Watermark",
  "message",
  "notification",
  "theme",
  "unstableSetRender",
  "version"
]);
const RUNJS_CTX_LIB_ALLOWED_MEMBERS_BY_LIBRARY = /* @__PURE__ */ new Map([
  ["antd", RUNJS_CTX_LIB_ANTD_ALLOWED_MEMBERS]
]);
const RUNJS_CTX_API_ALLOWED_MEMBERS = /* @__PURE__ */ new Set(["auth", "request", "resource"]);
const RUNJS_CTX_API_AUTH_ALLOWED_MEMBERS = /* @__PURE__ */ new Set(["authenticator", "locale", "role", "token"]);
const RUNJS_RESOURCE_METHODS = /* @__PURE__ */ new Set(["list", "get", "create", "update", "destroy"]);
const RUNJS_COLLECTION_RESOURCE_ACTIONS = /* @__PURE__ */ new Set([
  "add",
  "create",
  "destroy",
  "firstOrCreate",
  "get",
  "list",
  "move",
  "query",
  "remove",
  "set",
  "toggle",
  "update",
  "updateOrCreate"
]);
const RUNJS_COLLECTION_RESOURCE_ACTION_ALIASES = /* @__PURE__ */ new Map([
  ["create", ["create", "firstOrCreate", "updateOrCreate"]],
  ["view", ["get", "list", "query"]],
  ["update", ["add", "move", "remove", "set", "toggle", "update"]],
  ["destroy", ["destroy"]]
]);
const RUNJS_RESOURCE_ENDPOINT_ACTION_PATTERN = "[A-Za-z_$][\\w$-]*";
const FLOW_RESOURCE_BASE_METHODS = /* @__PURE__ */ new Set([
  "getData",
  "hasData",
  "setData",
  "getMeta",
  "setMeta",
  "getError",
  "setError",
  "clearError",
  "refresh",
  "on",
  "once",
  "off",
  "emit"
]);
const API_RESOURCE_METHODS = unionMethodSets([
  FLOW_RESOURCE_BASE_METHODS,
  /* @__PURE__ */ new Set([
    "setAPIClient",
    "getURL",
    "setURL",
    "clearRequestParameters",
    "setRequestParameters",
    "setRequestMethod",
    "addRequestHeader",
    "removeRequestHeader",
    "addRequestParameter",
    "getRequestParameter",
    "removeRequestParameter",
    "setRequestBody",
    "setRequestOptions",
    "getRequestOptions",
    "refresh"
  ])
]);
const RECORD_RESOURCE_METHODS = unionMethodSets([
  API_RESOURCE_METHODS,
  /* @__PURE__ */ new Set([
    "setRefreshAction",
    "mergeRequestConfig",
    "setRunActionOptions",
    "runAction",
    "setResourceName",
    "getResourceName",
    "setSourceId",
    "getSourceId",
    "setDataSourceKey",
    "getDataSourceKey",
    "setFilter",
    "getFilter",
    "resetFilter",
    "addFilterGroup",
    "removeFilterGroup",
    "setAppends",
    "getAppends",
    "addAppends",
    "removeAppends",
    "getUpdateAssociationValues",
    "addUpdateAssociationValues",
    "jsonStringify",
    "setFilterByTk",
    "getFilterByTk",
    "setFields",
    "getFields",
    "setSort",
    "getSort",
    "setExcept",
    "getExcept",
    "setWhitelist",
    "getWhitelist",
    "setBlacklist",
    "getBlacklist"
  ])
]);
const RUNJS_RESOURCE_CHAINABLE_STATE_METHODS = /* @__PURE__ */ new Set(["setDataSourceKey", "setResourceName", "setFilter"]);
const MULTI_RECORD_RESOURCE_METHODS = unionMethodSets([
  RECORD_RESOURCE_METHODS,
  /* @__PURE__ */ new Set([
    "setCreateActionOptions",
    "setUpdateActionOptions",
    "setSelectedRows",
    "getSelectedRows",
    "setPage",
    "getPage",
    "setPageSize",
    "getPageSize",
    "getTotalPage",
    "getCell",
    "next",
    "previous",
    "goto",
    "create",
    "get",
    "update",
    "destroySelectedRows",
    "destroy",
    "setItem",
    "refresh"
  ])
]);
const SINGLE_RECORD_RESOURCE_METHODS = unionMethodSets([
  RECORD_RESOURCE_METHODS,
  /* @__PURE__ */ new Set(["setSaveActionOptions", "save", "destroy", "refresh"])
]);
const SQL_RESOURCE_METHODS = unionMethodSets([
  RECORD_RESOURCE_METHODS,
  /* @__PURE__ */ new Set([
    "setDebug",
    "setPage",
    "getPage",
    "setPageSize",
    "getPageSize",
    "next",
    "previous",
    "goto",
    "setDataSourceKey",
    "setSQLType",
    "setSQL",
    "setFilterByTk",
    "setFilter",
    "setBind",
    "setLiquidContext",
    "run",
    "runBySQL",
    "runById",
    "refresh"
  ])
]);
const FLOW_RESOURCE_METHODS_BY_TYPE = {
  FlowResource: FLOW_RESOURCE_BASE_METHODS,
  APIResource: API_RESOURCE_METHODS,
  SingleRecordResource: SINGLE_RECORD_RESOURCE_METHODS,
  MultiRecordResource: MULTI_RECORD_RESOURCE_METHODS,
  SQLResource: SQL_RESOURCE_METHODS
};
const UNKNOWN_FLOW_RESOURCE_METHODS = unionMethodSets(Object.values(FLOW_RESOURCE_METHODS_BY_TYPE));
const FLOW_RESOURCE_METHOD_SUGGESTIONS = /* @__PURE__ */ new Map([
  ["setFilters", "setFilter"],
  ["getCount", "getData"]
]);
const CONTEXT_FIRST_REPAIR_CLASSES = /* @__PURE__ */ new Set([
  "unknown-surface-stop",
  "unknown-model-stop",
  "ctx-root-mismatch-stop",
  "blocked-capability-reroute"
]);
const RUNJS_FIX_AND_RETRY_INSTRUCTION = "Do not skip this JS/RunJS step. Fix the error and retry the same write. If the response contains errors[], fix every listed error in one payload revision before retrying. Do not remove, defer, or replace the JS/RunJS capability to bypass validation.";
const RUNJS_CONTEXT_AND_RETRY_INSTRUCTION = "Do not skip this JS/RunJS step. Resolve the blocking context/problem first, then retry the same write. If the response contains errors[], fix every listed error in one payload revision before retrying. Do not remove, defer, or replace the JS/RunJS capability to bypass validation.";
function unionMethodSets(methodSets) {
  const union = /* @__PURE__ */ new Set();
  methodSets.forEach((methodSet) => {
    methodSet.forEach((method) => union.add(method));
  });
  return union;
}
function buildRunJsSupportedFilterOperators() {
  const supported = new Set(Object.keys(import_database.operators || {}));
  for (const key in import_sequelize.Op) {
    const snakeKey = _.snakeCase(key);
    supported.add(`$${key}`);
    supported.add(`$${snakeKey}`);
    supported.add(`$${snakeKey.replace(/_/g, "")}`);
  }
  return supported;
}
function escapeRegExp(value) {
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ACTION_MODEL_USES,
  ACTION_TYPE_ALIASES,
  ALLOWED_CTX_ROOTS,
  API_RESOURCE_METHODS,
  AST_CTX_METHOD_NAMES,
  BLOCKED_CTX_CAPABILITIES,
  CANONICAL_CTX_LIB_MEMBERS,
  CHART_CTX_ROOTS,
  CONTEXT_FIRST_REPAIR_CLASSES,
  CTX_LIB_MEMBER_BY_LOWERCASE,
  FLOW_RESOURCE_BASE_METHODS,
  FLOW_RESOURCE_CLASS_NAMES,
  FLOW_RESOURCE_METHODS_BY_TYPE,
  FLOW_RESOURCE_METHOD_SUGGESTIONS,
  FORBIDDEN_BARE_GLOBALS,
  INIT_RESOURCE_CLASS_NAMES,
  KNOWN_MODEL_USES,
  MAX_RUNJS_ERRORS_PER_SOURCE,
  MAX_RUNJS_SOURCES_PER_REQUEST,
  MAX_RUNJS_SOURCE_LENGTH,
  MAX_RUNJS_TOTAL_SOURCE_LENGTH,
  MULTI_RECORD_RESOURCE_METHODS,
  NON_METHOD_CALL_KEYWORDS,
  PUBLIC_BLOCK_TYPE_BY_MODEL_USE,
  REACT_HOOK_NAMES,
  REACT_HOOK_PATTERN,
  REACT_NODE_COMPONENT_PROP_NAMES,
  RECORD_RESOURCE_METHODS,
  RENDER_MODEL_USES,
  RUNJS_ALLOWED_BARE_GLOBALS,
  RUNJS_ALLOWED_BARE_GLOBALS_BY_MODEL_USE,
  RUNJS_COLLECTION_RESOURCE_ACTIONS,
  RUNJS_COLLECTION_RESOURCE_ACTION_ALIASES,
  RUNJS_CONTEXT_AND_RETRY_INSTRUCTION,
  RUNJS_CTX_API_ALLOWED_MEMBERS,
  RUNJS_CTX_API_AUTH_ALLOWED_MEMBERS,
  RUNJS_CTX_LIB_ALLOWED_MEMBERS_BY_LIBRARY,
  RUNJS_CTX_LIB_ANTD_ALLOWED_MEMBERS,
  RUNJS_CTX_NON_FUNCTION_ROOTS,
  RUNJS_CTX_NON_FUNCTION_ROOTS_BY_MODEL_USE,
  RUNJS_DATE_FILTER_OPERATORS,
  RUNJS_FIX_AND_RETRY_INSTRUCTION,
  RUNJS_RESOURCE_ACTION_PATTERN,
  RUNJS_RESOURCE_CHAINABLE_STATE_METHODS,
  RUNJS_RESOURCE_ENDPOINT_ACTION_PATTERN,
  RUNJS_RESOURCE_METHODS,
  RUNJS_SUPPORTED_FILTER_OPERATORS,
  RUNJS_UNSUPPORTED_DATE_RANGE_VALUE_KEYS,
  SINGLE_RECORD_RESOURCE_METHODS,
  SQL_RESOURCE_METHODS,
  SURFACE_ALLOWED_MODEL_USES,
  SURFACE_STYLE_BY_ID,
  UNKNOWN_FLOW_RESOURCE_METHODS,
  VALUE_MODEL_USES
});
