@nocobase/plugin-public-forms 2.1.0-beta.8 → 2.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +1 -0
  3. package/dist/client/192.8517b0a03feac7ee.js +10 -0
  4. package/dist/client/397.b68774708fca6416.js +10 -0
  5. package/dist/client/595.b7c06702cf42a9f1.js +10 -0
  6. package/dist/client/755.54e2c6a5fba42eb6.js +10 -0
  7. package/dist/client/index.js +1 -1
  8. package/dist/client-v2/594.3ec7d41fb076d365.js +10 -0
  9. package/dist/client-v2/599.be4aea35e18fe34f.js +10 -0
  10. package/dist/client-v2/610.5a762348c1d0e93d.js +10 -0
  11. package/dist/client-v2/64.14dd13ceb37723c5.js +10 -0
  12. package/dist/client-v2/965.9ebc606a71f466a5.js +10 -0
  13. package/dist/client-v2/constants.d.ts +20 -0
  14. package/dist/client-v2/index.d.ts +10 -0
  15. package/dist/client-v2/index.js +10 -0
  16. package/dist/client-v2/locale.d.ts +12 -0
  17. package/dist/client-v2/modelTree.d.ts +125 -0
  18. package/dist/client-v2/models/PublicFormLayoutModel.d.ts +32 -0
  19. package/dist/client-v2/models/PublicFormPageModel.d.ts +19 -0
  20. package/dist/client-v2/models/PublicFormSubmitActionModel.d.ts +20 -0
  21. package/dist/client-v2/models/PublicFormsSettingsLayoutModel.d.ts +14 -0
  22. package/dist/client-v2/pages/PublicFormsSettingsPage.d.ts +12 -0
  23. package/dist/client-v2/plugin.d.ts +14 -0
  24. package/dist/client-v2/publicFormFlowModelRepository.d.ts +34 -0
  25. package/dist/client-v2/route.d.ts +17 -0
  26. package/dist/externalVersion.js +8 -4
  27. package/dist/locale/en-US.json +19 -2
  28. package/dist/locale/zh-CN.json +19 -2
  29. package/dist/server/collections/publicForms.js +1 -0
  30. package/dist/server/plugin.d.ts +19 -40
  31. package/dist/server/plugin.js +168 -31
  32. package/package.json +5 -2
  33. package/dist/client/299daa599f56ed18.js +0 -10
  34. package/dist/client/6d049e4a903a70c8.js +0 -10
  35. package/dist/client/9001d28b0af050a8.js +0 -10
  36. package/dist/client/9e93e160b756c6d1.js +0 -10
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ type PublicFormAppLike = {
10
+ router?: {
11
+ getBasename?: () => string | undefined;
12
+ };
13
+ getPublicPath?: () => string;
14
+ getRouteUrl?: (pathname: string) => string;
15
+ };
16
+ export declare function getPublicFormRoutePath(app: PublicFormAppLike | undefined, pathname: string): string;
17
+ export {};
@@ -8,10 +8,12 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.8",
11
+ "@nocobase/client": "2.2.0-alpha.1",
12
12
  "react-i18next": "11.18.6",
13
- "@nocobase/plugin-ui-schema-storage": "2.1.0-beta.8",
14
- "@nocobase/server": "2.1.0-beta.8",
13
+ "@nocobase/flow-engine": "2.2.0-alpha.1",
14
+ "@nocobase/client-v2": "2.2.0-alpha.1",
15
+ "@nocobase/plugin-ui-schema-storage": "2.2.0-alpha.1",
16
+ "@nocobase/server": "2.2.0-alpha.1",
15
17
  "react": "18.2.0",
16
18
  "@ant-design/icons": "5.6.1",
17
19
  "antd": "5.24.2",
@@ -22,6 +24,8 @@ module.exports = {
22
24
  "@formily/react": "2.3.7",
23
25
  "@formily/core": "2.3.7",
24
26
  "@formily/shared": "2.3.7",
25
- "@nocobase/database": "2.1.0-beta.8",
27
+ "@formily/reactive": "2.3.7",
28
+ "ahooks": "3.7.8",
29
+ "@nocobase/database": "2.2.0-alpha.1",
26
30
  "dayjs": "1.11.13"
27
31
  };
@@ -2,17 +2,34 @@
2
2
  "# Submitted successfully!\nThis is a demo text, **supports Markdown syntax**.": "# Submitted successfully!\nThis is a demo text, **supports Markdown syntax**.",
3
3
  "Add New": "Add New",
4
4
  "After successful submission": "After successful submission",
5
+ "Actions": "Actions",
6
+ "Are you sure you want to delete it?": "Are you sure you want to delete it?",
7
+ "Cancel": "Cancel",
8
+ "Collection": "Collection",
9
+ "Configure": "Configure",
10
+ "Configure form": "Configure form",
5
11
  "Copy link": "Copy link",
12
+ "Delete": "Delete",
13
+ "Description": "Description",
14
+ "Edit": "Edit",
6
15
  "Enable form": "Enable form",
7
16
  "Enable password": "Enable password",
17
+ "Enabled": "Enabled",
8
18
  "Form": "Form",
19
+ "Incorrect password": "Incorrect password",
9
20
  "Link copied successfully": "Link copied successfully",
21
+ "No": "No",
10
22
  "Open form": "Open form",
23
+ "Password": "Password",
11
24
  "Prompt after successful submission": "Prompt after successful submission",
12
25
  "Public forms": "Public forms",
13
26
  "QR code": "QR code",
14
27
  "Set password": "Set password",
28
+ "Settings": "Settings",
29
+ "Submit": "Submit",
15
30
  "The form is not enabled and cannot be accessed": "The form is not enabled and cannot be accessed",
16
31
  "The form is not found": "The form is not found",
17
- "Type": "Type"
18
- }
32
+ "Title": "Title",
33
+ "Type": "Type",
34
+ "Yes": "Yes"
35
+ }
@@ -2,17 +2,34 @@
2
2
  "# Submitted successfully!\nThis is a demo text, **supports Markdown syntax**.": "# 提交成功!\n这是一段演示文本,**支持 Markdown 语法**。",
3
3
  "Add New": "添加",
4
4
  "After successful submission": "提交成功后",
5
+ "Actions": "操作",
6
+ "Are you sure you want to delete it?": "确定删除吗?",
7
+ "Cancel": "取消",
8
+ "Collection": "数据表",
9
+ "Configure": "配置",
10
+ "Configure form": "配置表单",
5
11
  "Copy link": "复制链接",
12
+ "Delete": "删除",
13
+ "Description": "描述",
14
+ "Edit": "编辑",
6
15
  "Enable form": "启用表单",
7
16
  "Enable password": "启用密码",
17
+ "Enabled": "是否启用",
8
18
  "Form": "普通表单",
19
+ "Incorrect password": "密码错误",
9
20
  "Link copied successfully": "复制地址成功",
21
+ "No": "否",
10
22
  "Open form": "查看公开表单",
23
+ "Password": "密码",
11
24
  "Prompt after successful submission": "提交成功后的信息提示",
12
25
  "Public forms": "公开表单",
13
26
  "QR code": "二维码",
14
27
  "Set password": "设置密码",
28
+ "Settings": "设置",
29
+ "Submit": "提交",
15
30
  "The form is not enabled and cannot be accessed": "该表单未启用,无法访问",
16
31
  "The form is not found": "未找到该表单",
17
- "Type": "类型"
18
- }
32
+ "Title": "标题",
33
+ "Type": "类型",
34
+ "Yes": "是"
35
+ }
@@ -32,6 +32,7 @@ module.exports = __toCommonJS(publicForms_exports);
32
32
  var import_database = require("@nocobase/database");
33
33
  var publicForms_default = (0, import_database.defineCollection)({
34
34
  name: "publicForms",
35
+ dataCategory: "system",
35
36
  filterTargetKey: "key",
36
37
  migrationRules: ["overwrite", "schema-only"],
37
38
  createdBy: true,
@@ -8,26 +8,21 @@
8
8
  */
9
9
  import { Plugin } from '@nocobase/server';
10
10
  export declare class PluginPublicFormsServer extends Plugin {
11
- parseCollectionData(dataSourceKey: any, formCollection: any, appends: any): Promise<{
12
- name: any;
13
- fields: {
14
- [x: string]: any;
15
- name: string;
16
- field: string;
17
- rawType: string;
18
- type: string;
19
- description?: string;
20
- interface?: string;
21
- uiSchema?: any;
22
- possibleTypes?: string[];
23
- defaultValue?: any;
24
- primaryKey?: boolean;
25
- unique?: boolean;
26
- allowNull?: boolean;
27
- autoIncrement?: boolean;
28
- }[];
29
- template: any;
30
- }[]>;
11
+ protected associationFieldTypes: string[];
12
+ parseCollectionData(dataSourceKey: any, formCollection: any, appends: any): Promise<any[]>;
13
+ getFlowModelTree(uid: string, options?: {
14
+ includeAsyncNode?: boolean;
15
+ }): Promise<any>;
16
+ isFlowModelDescendant(rootUid: string, uid: string): Promise<boolean>;
17
+ validatePublicFormToken(filterByTk: string, token?: string): Promise<import("jsonwebtoken").JwtPayload>;
18
+ getFlowModelByTk(filterByTk: string, options: {
19
+ uid?: string;
20
+ parentId?: string;
21
+ subKey?: string;
22
+ token?: string;
23
+ }): Promise<any>;
24
+ getSchemaAssociationAppends(dataSourceKey: string, collectionName: string, schema: any): any[];
25
+ getFlowModelAssociationAppends(dataSourceKey: string, collectionName: string, flowModel: any): string[];
31
26
  getMetaByTk(filterByTk: string, options: {
32
27
  password?: string;
33
28
  token?: string;
@@ -36,38 +31,22 @@ export declare class PluginPublicFormsServer extends Plugin {
36
31
  dataSource?: undefined;
37
32
  token?: undefined;
38
33
  schema?: undefined;
34
+ flowModel?: undefined;
39
35
  title?: undefined;
40
36
  } | {
41
37
  dataSource: {
42
38
  key: any;
43
39
  displayName: any;
44
- collections: {
45
- name: any;
46
- fields: {
47
- [x: string]: any;
48
- name: string;
49
- field: string;
50
- rawType: string;
51
- type: string;
52
- description?: string;
53
- interface?: string;
54
- uiSchema?: any;
55
- possibleTypes?: string[];
56
- defaultValue?: any;
57
- primaryKey?: boolean;
58
- unique?: boolean;
59
- allowNull?: boolean;
60
- autoIncrement?: boolean;
61
- }[];
62
- template: any;
63
- }[];
40
+ collections: any[];
64
41
  };
65
42
  token: string;
66
43
  schema: any;
44
+ flowModel: any;
67
45
  title: any;
68
46
  passwordRequired?: undefined;
69
47
  }>;
70
48
  getPublicFormsMeta: (ctx: any, next: any) => Promise<void>;
49
+ getPublicFormFlowModel: (ctx: any, next: any) => Promise<void>;
71
50
  parseToken: (ctx: any, next: any) => Promise<any>;
72
51
  parseACL: (ctx: any, next: any) => Promise<any>;
73
52
  load(): Promise<void>;
@@ -35,34 +35,144 @@ var import_hook = require("./hook");
35
35
  class PasswordError extends Error {
36
36
  }
37
37
  class PluginPublicFormsServer extends import_server.Plugin {
38
+ associationFieldTypes = ["hasOne", "hasMany", "belongsTo", "belongsToMany", "belongsToArray"];
38
39
  async parseCollectionData(dataSourceKey, formCollection, appends) {
39
40
  const dataSource = this.app.dataSourceManager.dataSources.get(dataSourceKey);
41
+ const serializeCollection = (collection2) => ({
42
+ ...collection2.options,
43
+ name: collection2.name,
44
+ filterTargetKey: collection2.filterTargetKey,
45
+ titleField: collection2.titleField,
46
+ fields: collection2.getFields().map((v) => {
47
+ return {
48
+ ...v.options
49
+ };
50
+ })
51
+ });
40
52
  const collection = dataSource.collectionManager.getCollection(formCollection);
41
- const collections = [
42
- {
43
- name: collection.name,
44
- fields: collection.getFields().map((v) => {
45
- return {
46
- ...v.options
47
- };
48
- }),
49
- template: collection.options.template
50
- }
51
- ];
53
+ const collections = [serializeCollection(collection)];
52
54
  return collections.concat(
53
55
  appends.map((v) => {
54
- const targetCollection = this.db.getCollection(v);
55
- return {
56
- ...targetCollection.options,
57
- fields: targetCollection.getFields().map((v2) => {
58
- return {
59
- ...v2.options
60
- };
61
- })
62
- };
56
+ const targetCollection = dataSource.collectionManager.getCollection(v);
57
+ return serializeCollection(targetCollection);
63
58
  })
64
59
  );
65
60
  }
61
+ async getFlowModelTree(uid, options = {}) {
62
+ var _a;
63
+ const repository = (_a = this.db.getCollection("flowModels")) == null ? void 0 : _a.repository;
64
+ if (!(repository == null ? void 0 : repository.findModelById)) {
65
+ return null;
66
+ }
67
+ return repository.findModelById(uid, { includeAsyncNode: !!options.includeAsyncNode }).catch(() => null);
68
+ }
69
+ async isFlowModelDescendant(rootUid, uid) {
70
+ var _a, _b;
71
+ if (!rootUid || !uid) {
72
+ return false;
73
+ }
74
+ if (rootUid === uid) {
75
+ return true;
76
+ }
77
+ const repository = this.db.getRepository("flowModelTreePath");
78
+ const node = await ((_b = (_a = repository == null ? void 0 : repository.model) == null ? void 0 : _a.findOne) == null ? void 0 : _b.call(_a, {
79
+ where: {
80
+ ancestor: rootUid,
81
+ descendant: uid
82
+ }
83
+ }));
84
+ return !!node;
85
+ }
86
+ async validatePublicFormToken(filterByTk, token) {
87
+ if (!token) {
88
+ throw new Error("Public form token is required");
89
+ }
90
+ const tokenData = await this.app.authManager.jwt.decode(token);
91
+ if ((tokenData == null ? void 0 : tokenData.formKey) !== filterByTk) {
92
+ throw new Error("Invalid public form token");
93
+ }
94
+ const publicForms = this.db.getRepository("publicForms");
95
+ const instance = await publicForms.findOne({
96
+ filter: {
97
+ key: tokenData.formKey
98
+ }
99
+ });
100
+ if (!instance) {
101
+ throw new Error("The form is not found");
102
+ }
103
+ if (!instance.get("enabled")) {
104
+ throw new Error("The form is not enabled");
105
+ }
106
+ return tokenData;
107
+ }
108
+ async getFlowModelByTk(filterByTk, options) {
109
+ var _a;
110
+ await this.validatePublicFormToken(filterByTk, options.token);
111
+ const repository = (_a = this.db.getCollection("flowModels")) == null ? void 0 : _a.repository;
112
+ if (!repository) {
113
+ return null;
114
+ }
115
+ if (options.uid) {
116
+ if (!await this.isFlowModelDescendant(filterByTk, options.uid)) {
117
+ throw new Error("The flow model is not in this public form");
118
+ }
119
+ return repository.findModelById(options.uid, { includeAsyncNode: true }).catch(() => null);
120
+ }
121
+ if (!options.parentId) {
122
+ throw new Error("parentId is required");
123
+ }
124
+ if (!await this.isFlowModelDescendant(filterByTk, options.parentId)) {
125
+ throw new Error("The flow model parent is not in this public form");
126
+ }
127
+ const flowModel = await repository.findModelByParentId(options.parentId, {
128
+ subKey: options.subKey,
129
+ includeAsyncNode: true
130
+ }).catch(() => null);
131
+ if ((flowModel == null ? void 0 : flowModel.uid) && !await this.isFlowModelDescendant(filterByTk, flowModel.uid)) {
132
+ throw new Error("The flow model is not in this public form");
133
+ }
134
+ return flowModel;
135
+ }
136
+ getSchemaAssociationAppends(dataSourceKey, collectionName, schema) {
137
+ var _a;
138
+ if (!((_a = schema == null ? void 0 : schema.properties) == null ? void 0 : _a.form)) {
139
+ return [];
140
+ }
141
+ const { getAssociationAppends } = (0, import_hook.parseAssociationNames)(dataSourceKey, collectionName, this.app, schema);
142
+ return getAssociationAppends().appends || [];
143
+ }
144
+ getFlowModelAssociationAppends(dataSourceKey, collectionName, flowModel) {
145
+ const dataSource = this.app.dataSourceManager.dataSources.get(dataSourceKey);
146
+ const appends = /* @__PURE__ */ new Set();
147
+ const traverse = (node) => {
148
+ var _a, _b;
149
+ if (!node || typeof node !== "object") {
150
+ return;
151
+ }
152
+ const init = (_b = (_a = node.stepParams) == null ? void 0 : _a.fieldSettings) == null ? void 0 : _b.init;
153
+ const fieldDataSourceKey = (init == null ? void 0 : init.dataSourceKey) || dataSourceKey;
154
+ const fieldCollectionName = (init == null ? void 0 : init.collectionName) || collectionName;
155
+ const fieldPath = init == null ? void 0 : init.fieldPath;
156
+ if (fieldDataSourceKey === dataSourceKey && fieldCollectionName && fieldPath) {
157
+ const collection = dataSource.collectionManager.getCollection(fieldCollectionName);
158
+ const fieldName = String(fieldPath).split(".")[0];
159
+ const collectionField = collection == null ? void 0 : collection.getField(fieldName);
160
+ const collectionFieldOptions = collectionField == null ? void 0 : collectionField.options;
161
+ if (collectionFieldOptions && this.associationFieldTypes.includes(collectionFieldOptions.type) && collectionFieldOptions.target) {
162
+ appends.add(collectionFieldOptions.target);
163
+ }
164
+ }
165
+ Object.values(node.subModels || {}).forEach((subModel) => {
166
+ if (Array.isArray(subModel)) {
167
+ subModel.forEach(traverse);
168
+ return;
169
+ }
170
+ traverse(subModel);
171
+ });
172
+ };
173
+ traverse(flowModel);
174
+ return [...(0, import_hook.fillParentFields)(appends)];
175
+ }
66
176
  async getMetaByTk(filterByTk, options) {
67
177
  const { token, password } = options;
68
178
  const publicForms = this.db.getRepository("publicForms");
@@ -78,25 +188,40 @@ class PluginPublicFormsServer extends import_server.Plugin {
78
188
  if (!instance.get("enabled")) {
79
189
  return null;
80
190
  }
81
- if (!token) {
82
- if (instance.get("password")) {
83
- if (password === void 0) {
191
+ if (instance.get("password")) {
192
+ if (password !== void 0) {
193
+ if (this.app.environment.renderJsonTemplate(instance.get("password")) !== password) {
194
+ throw new PasswordError("Please enter your password");
195
+ }
196
+ } else if (token) {
197
+ try {
198
+ await this.validatePublicFormToken(filterByTk, token);
199
+ } catch (error) {
84
200
  return {
85
201
  passwordRequired: true
86
202
  };
87
203
  }
88
- if (this.app.environment.renderJsonTemplate(instance.get("password")) !== password) {
89
- throw new PasswordError("Please enter your password");
90
- }
204
+ } else {
205
+ return {
206
+ passwordRequired: true
207
+ };
91
208
  }
92
209
  }
93
210
  const keys = instance.collection.split(":");
94
211
  const collectionName = keys.pop();
95
212
  const dataSourceKey = keys.pop() || "main";
96
213
  const title = instance.get("title");
97
- const schema = await uiSchema.getJsonSchema(filterByTk);
98
- const { getAssociationAppends } = (0, import_hook.parseAssociationNames)(dataSourceKey, collectionName, this.app, schema);
99
- const { appends } = getAssociationAppends();
214
+ const [schema, flowModel, completeFlowModel] = await Promise.all([
215
+ uiSchema.getJsonSchema(filterByTk).catch(() => null),
216
+ this.getFlowModelTree(filterByTk),
217
+ this.getFlowModelTree(filterByTk, { includeAsyncNode: true })
218
+ ]);
219
+ const appends = [
220
+ .../* @__PURE__ */ new Set([
221
+ ...this.getSchemaAssociationAppends(dataSourceKey, collectionName, schema),
222
+ ...this.getFlowModelAssociationAppends(dataSourceKey, collectionName, completeFlowModel || flowModel)
223
+ ])
224
+ ];
100
225
  const collections = await this.parseCollectionData(dataSourceKey, collectionName, appends);
101
226
  return {
102
227
  dataSource: {
@@ -115,6 +240,7 @@ class PluginPublicFormsServer extends import_server.Plugin {
115
240
  }
116
241
  ),
117
242
  schema,
243
+ flowModel,
118
244
  title
119
245
  };
120
246
  }
@@ -133,6 +259,16 @@ class PluginPublicFormsServer extends import_server.Plugin {
133
259
  }
134
260
  await next();
135
261
  };
262
+ getPublicFormFlowModel = async (ctx, next) => {
263
+ const token = ctx.get("X-Form-Token");
264
+ const { filterByTk, uid, parentId, subKey } = ctx.action.params;
265
+ try {
266
+ ctx.body = await this.getFlowModelByTk(filterByTk, { uid, parentId, subKey, token });
267
+ } catch (error) {
268
+ ctx.throw(401, error.message);
269
+ }
270
+ await next();
271
+ };
136
272
  parseToken = async (ctx, next) => {
137
273
  if (!ctx.action) {
138
274
  return next();
@@ -196,9 +332,10 @@ class PluginPublicFormsServer extends import_server.Plugin {
196
332
  name: `pm.${this.name}`,
197
333
  actions: ["publicForms:*"]
198
334
  });
199
- this.app.acl.allow("publicForms", "getMeta", "public");
335
+ this.app.acl.allow("publicForms", ["getMeta", "getFlowModel"], "public");
200
336
  this.app.resourceManager.registerActionHandlers({
201
- "publicForms:getMeta": this.getPublicFormsMeta
337
+ "publicForms:getMeta": this.getPublicFormsMeta,
338
+ "publicForms:getFlowModel": this.getPublicFormFlowModel
202
339
  });
203
340
  this.app.dataSourceManager.afterAddDataSource((dataSource) => {
204
341
  dataSource.resourceManager.use(this.parseToken, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-public-forms",
3
- "version": "2.1.0-beta.8",
3
+ "version": "2.2.0-alpha.1",
4
4
  "main": "dist/server/index.js",
5
5
  "displayName": "Public forms",
6
6
  "displayName.ru-RU": "Публичные формы",
@@ -14,7 +14,10 @@
14
14
  "homepage.zh-CN": "https://docs-cn.nocobase.com/public-form",
15
15
  "peerDependencies": {
16
16
  "@nocobase/client": "2.x",
17
+ "@nocobase/client-v2": "2.x",
18
+ "@nocobase/flow-engine": "2.x",
17
19
  "@nocobase/plugin-client": "2.x",
20
+ "@nocobase/plugin-flow-engine": "2.x",
18
21
  "@nocobase/plugin-ui-schema-storage": "2.x",
19
22
  "@nocobase/server": "2.x",
20
23
  "@nocobase/test": "2.x"
@@ -22,5 +25,5 @@
22
25
  "devDependencies": {
23
26
  "react-device-detect": "2.2.3"
24
27
  },
25
- "gitHead": "5099d561c5467292414c1e77ad6bad3730d97344"
28
+ "gitHead": "303663aba6c6eefa27e6a6435b4c0352074ec40f"
26
29
  }
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_public_forms=self.webpackChunk_nocobase_plugin_public_forms||[]).push([["309"],{8975:function(e,t,r){r.r(t),r.d(t,{PublicFormMessageContext:function(){return R},PageBackgroundColor:function(){return _},PublicFormPage:function(){return K}});var n=r(4964),o=r(3505),a=r(3772),i=r(2721),l=r(2992),u=r(8156),c=r.n(u),s=r(3135),f=r(5432),p=r(9173),d=r(5760),m=r.n(d),b=r(3238);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var v=(0,o.connect)(function(e){var t,r,n,o=(0,b.useTranslation)().t,i=e.value,s=e.onChange,f=(e.dateFormat,e.timeFormat),p=e.showTime,d=void 0!==p&&p,v=e.picker,h=e.disabled,g=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(e,["value","onChange","dateFormat","timeFormat","showTime","picker","disabled"]),w=(t=(0,u.useState)(!1),function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(t,2)||function(e,t){if(e){if("string"==typeof e)return y(e,2);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return y(e,t)}}(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),O=w[0],S=w[1],k=(0,u.useCallback)(function(t){S(!1);var r=new Date(t);e.dateOnly?s(m()(t)):s(r)},[d,s]),P=(0,u.useCallback)(function(){S(!1),s(null)},[s]),C=(0,u.useCallback)(function(e,t){return t},[]);return c().createElement(c().Fragment,null,c().createElement("div",{onClick:function(){return!h&&S(!0)}},c().createElement(a.DatePicker,(r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({onClick:function(){return S(!0)},value:i,picker:v,disabled:h},g),n=n={popupStyle:{display:"none"},style:{pointerEvents:"none",width:"100%"}},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}),r))),c().createElement(l.Mt,{cancelText:o("Cancel"),confirmText:o("Confirm"),visible:O,title:c().createElement("a",{onClick:P},o("Clear")),onClose:function(){S(!1)},precision:d?function(e){var t=e.toLowerCase();if(/\bss?\b/.test(t))return"second";if(/\bmm?\b/.test(t))return"minute";if(/\bhh?\b/.test(t))return"hour";throw Error("Invalid time format")}(void 0===f?"HH:mm":f):"date"===v?"day":v,renderLabel:C,min:new Date(1950,0,1),max:new Date(2050,11,31),onConfirm:function(e){k(e)}}))},(0,o.mapProps)((0,a.mapDatePicker)()),(0,o.mapReadPretty)(a.DatePicker.ReadPretty));function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var w=(0,o.connect)(function(e){var t=e.value,r=e.onChange,n=e.options,o=void 0===n?[]:n,i=e.mode,s=e.disabled,f=(0,b.useTranslation)().t,p=g((0,u.useState)(!1),2),d=p[0],m=p[1],y=g((0,u.useState)(t||[]),2),v=y[0],h=y[1],w=g((0,u.useState)(null),2),O=w[0],S=w[1],k=(0,u.useMemo)(function(){return O?o.filter(function(e){return e.label.toLowerCase().includes(O.toLowerCase())}):o},[o,O]);return(0,u.useEffect)(function(){d||S(null)},[d]),c().createElement(c().Fragment,null,c().createElement("div",{onClick:function(){return!s&&m(!0)}},c().createElement(a.Select,{placeholder:f("Select"),value:t,dropdownStyle:{display:"none"},multiple:"multiple"===i,disabled:s,onClear:function(){m(!1),r(null),h(null)},onFocus:function(e){return e.preventDefault()},style:{pointerEvents:"none"}})),c().createElement(l.GI,{visible:d,onMaskClick:function(){m(!1),t&&(null==t?void 0:t.length)!==0||h([])},destroyOnClose:!0},c().createElement("div",{style:{margin:"10px"}},c().createElement(l.E1,{placeholder:f("search"),value:O,onChange:function(e){return S(e)},showCancelButton:!0})),c().createElement("div",{style:{maxHeight:"60vh",overflowY:"auto"}},c().createElement(l.Su,{multiple:"multiple"===i,value:Array.isArray(v)?v:[v],onChange:function(e){"multiple"===i?h(e):(h(e[0]),r(e[0]),m(!1))}},k.map(function(e){return c().createElement(l.Su.Item,{key:e.value,value:e.value},e.label)}))),"multiple"===i&&c().createElement(l.zx,{block:!0,color:"primary",onClick:function(){r(v),m(!1)},style:{marginTop:"16px"}},f("Confirm"))))},(0,o.mapProps)({dataSource:"options"})),O=r(7641),S=function(){var e=(0,O.NY)().t;return c().createElement(a.BlockItemCard,{style:{boxShadow:"unset"}},c().createElement(i.Result,{status:"403",subTitle:e("The form is not enabled and cannot be accessed",{ns:O.A7})}))},k=function(){return(0,O.NY)().t,c().createElement(a.BlockItemCard,{style:{boxShadow:"unset"}},c().createElement(i.Result,{status:"404"}))};function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function C(e,t,r,n,o,a,i){try{var l=e[a](i),u=l.value}catch(e){r(e);return}l.done?t(u):Promise.resolve(u).then(n,o)}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function j(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function A(e,t){return(A=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function D(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,l=!1;try{for(o=o.call(e);!(i=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){l=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(l)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return P(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return P(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(F=function(){return!!e})()}function T(){var e,t,r=(e=["\n @media (min-width: 1025px) {\n padding-top: 10vh;\n }\n padding-top: 0px;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return T=function(){return r},r}var M=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=E(e),function(e,t){var r;if(t&&("object"==((r=t)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,F()?Reflect.construct(e,t||[],E(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&A(r,e),t=[{key:"getDataSource",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var u=[a,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return[2,{}]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){C(a,n,o,i,l,"next",e)}function l(e){C(a,n,o,i,l,"throw",e)}i(void 0)})})()}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,t),r}(a.DataSource);function B(e){var t=e.dataSource,r=(0,a.useApp)(),n=D((0,u.useMemo)(function(){var e=new a.DataSourceManager({},r),n=e.addDataSource(M,t);return[e,new a.CollectionManager([],n)]},[r,t]),2),o=n[0],i=n[1];return c().createElement("div",null,c().createElement(a.DataSourceApplicationProvider,{dataSource:t.key,dataSourceManager:o,instance:i},e.children))}function I(e){var t=e.children,r=(0,a.useApp)();return(0,u.useEffect)(function(){var e=r.apiClient.axios.interceptors.request.use(function(e){return e.headers&&(e.headers["X-Form-Token"]=localStorage.getItem("NOCOBASE_FORM_TOKEN")||""),e});return function(){r.apiClient.axios.interceptors.request.eject(e)}},[r.apiClient.axios.interceptors.request]),c().createElement(a.APIClientProvider,{apiClient:r.apiClient},t)}var R=(0,u.createContext)({}),_="#f5f5f5",q=function(e){var t=e.children,r=D((0,u.useState)(!1),2),n=r[0],a=r[1],i=(0,o.useField)(),l=function(e,t){i.form.query(e).take(function(e){e&&(e.visible=t,e.hidden=!t)})};return(0,u.useEffect)(function(){l("success",n),l("form",!n),n||i.form.query("promptMessage").take(function(e){e&&(e.visible=!1,e.hidden=!0)})},[n]),c().createElement(R.Provider,{value:{showMessage:n,setShowMessage:a}},t)},V=function(e){return c().createElement(a.AssociationField,j(x({},e),{popupMatchSelectWidth:!0}))};V.SubTable=a.AssociationField.SubTable,V.Nester=a.AssociationField.Nester,V.AddNewer=a.Action.Container,V.Selector=a.Action.Container,V.Viewer=a.Action.Container,V.InternalSelect=a.AssociationField.InternalSelect,V.ReadPretty=a.AssociationField.ReadPretty,V.FileSelector=a.AssociationField.FileSelector;var N=function(e){return c().createElement(v,e)};N.FilterWithPicker=a.DatePicker.FilterWithPicker,N.RangePicker=a.DatePicker.RangePicker;var G={Button:l.zx,Select:function(e){return c().createElement(w,e)},DatePicker:N,UnixTimestamp:v,Modal:l.Vq,AssociationField:V};function z(){var e,t,r,o,l,d,m=(0,f.useParams)(),b=(0,a.useRequest)({url:"publicForms:getMeta/".concat(m.name),skipAuth:!0},{onSuccess:function(e){var t;localStorage.setItem("NOCOBASE_FORM_TOKEN",null==e||null==(t=e.data)?void 0:t.token)}}),y=b.error,v=b.data,h=b.loading,g=b.run,w=D((0,u.useState)(""),2),O=w[0],P=w[1],C=(0,u.useContext)(a.SchemaComponentContext);if(e=(0,a.useCompile)(),(0,u.useEffect)(function(){var t;v&&(document.title=e(null==v||null==(t=v.data)?void 0:t.title))},[v]),(0,u.useEffect)(function(){if(!s.isDesktop){var e=document.querySelector('meta[name="viewport"]');e||((e=document.createElement("meta")).setAttribute("name","viewport"),document.head.appendChild(e)),e.setAttribute("content","width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"),document.body.style.backgroundColor=_,document.body.style.overflow="hidden";var t=document.createElement("div");document.body.appendChild(t),document.body.removeChild(t)}},[]),(null==y||null==(t=y.response)?void 0:t.status)===401||(null==v||null==(r=v.data)?void 0:r.passwordRequired))return c().createElement("div",null,c().createElement(i.Modal,{centered:!0,title:"Password",open:!0,cancelButtonProps:{hidden:!0},onOk:function(){g({password:O})}},c().createElement(i.Input.Password,{onChange:function(e){P(e.target.value)}})));if((null==y||null==(o=y.response)?void 0:o.status)===500)return c().createElement(k,null);if(h)return c().createElement(i.Spin,null);if(!(null==v?void 0:v.data))return c().createElement(S,null);var E=s.isMobile?G:{};return c().createElement(a.ACLCustomContext.Provider,{value:{allowAll:!0}},c().createElement(I,null,c().createElement("div",{style:{minHeight:"100vh",background:_,height:"100%",overflow:"auto"}},c().createElement("div",{style:{maxWidth:800,margin:"0 auto",position:"relative",zIndex:0},className:(0,n.css)(T())},c().createElement(B,{dataSource:null==v||null==(l=v.data)?void 0:l.dataSource},c().createElement(a.SchemaComponentContext.Provider,{value:j(x({},C),{designable:!1})},c().createElement(a.SchemaComponent,{schema:null==v||null==(d=v.data)?void 0:d.schema,scope:{useCreateActionProps:p.hG},components:x({PublicFormMessageProvider:q},E)}))),c().createElement("div",{style:{marginBottom:"20px"}},c().createElement(a.PoweredBy,null))))))}function K(){return c().createElement(a.GlobalThemeProvider,{theme:{token:{marginBlock:18,borderRadiusBlock:0,boxShadowTertiary:"none",fontSize:14}}},c().createElement(a.VariablesProvider,{filterVariables:function(e){return!["$user","$nRole","$nToken"].includes(e.key)}},c().createElement(z,null)))}},9173:function(e,t,r){r.d(t,{Dq:function(){return i},j1:function(){return v},fC:function(){return c},hG:function(){return d}});var n=r(3772),o=r(2721);function a(e,t,r,n,o,a,i){try{var l=e[a](i),u=l.value}catch(e){r(e);return}l.done?t(u):Promise.resolve(u).then(n,o)}function i(){var e=o.App.useApp().message,t=(0,n.useCollectionRecordData)(),r=(0,n.useDataBlockResource)(),i=(0,n.useBlockRequestContext)().service,l=(0,n.useCollection)();return{confirm:{title:"Delete",content:"Are you sure you want to delete it?"},onClick:function(){var n;return(n=function(){return function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var u=[a,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:if(!l)throw Error("collection does not exist");return[4,r.destroy({filterByTk:t[l.filterTargetKey]})];case 1:return n.sent(),[4,i.refresh()];case 2:return n.sent(),e.success("Deleted!"),[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var i=n.apply(e,t);function l(e){a(i,r,o,l,u,"next",e)}function u(e){a(i,r,o,l,u,"throw",e)}l(void 0)})})()}}}var l=r(8563),u=r(8156),c=function(){var e=(0,n.useCollectionRecordData)();return{form:(0,u.useMemo)(function(){return(0,l.createForm)({initialValues:e})},[e])}},s=r(3505),f=r(8975);function p(e,t,r,n,o,a,i){try{var l=e[a](i),u=l.value}catch(e){r(e);return}l.done?t(u):Promise.resolve(u).then(n,o)}var d=function(){var e=(0,s.useForm)(),t=(0,n.useDataBlockResource)(),r=(0,s.useField)(),o=(0,n.useCollectValuesToSubmit)(),a=(0,s.useFieldSchema)(),i=(0,n.useFormBlockContext)().updateAssociationValues,l=(0,u.useContext)(f.PublicFormMessageContext).setShowMessage;return{type:"primary",onClick:function(){var n;return(n=function(){var n,u,c,s,f;return function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var u=[a,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(p){switch(p.label){case 0:if(c=(u=null!=(n=null==a?void 0:a["x-action-settings"])?n:{}).skipValidator,s=u.triggerWorkflows,c)return[3,2];return[4,e.submit()];case 1:p.sent(),p.label=2;case 2:return[4,o()];case 3:f=p.sent(),r.data=r.data||{},r.data.loading=!0,p.label=4;case 4:return p.trys.push([4,8,,9]),[4,e.submit()];case 5:return p.sent(),[4,t.publicSubmit({values:f,triggerWorkflows:(null==s?void 0:s.length)?s.map(function(e){return[e.workflowKey,e.context].filter(Boolean).join("!")}).join(","):void 0,updateAssociationValues:i})];case 6:return p.sent(),[4,e.reset()];case 7:return p.sent(),r.data.loading=!1,l(!0),[3,9];case 8:return p.sent(),r.data.loading=!1,[3,9];case 9:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var a=n.apply(e,t);function i(e){p(a,r,o,i,l,"next",e)}function l(e){p(a,r,o,i,l,"throw",e)}i(void 0)})})()}}},m=r(8875),b=r(5018);function y(e,t,r,n,o,a,i){try{var l=e[a](i),u=l.value}catch(e){r(e);return}l.done?t(u):Promise.resolve(u).then(n,o)}var v=function(){var e=(0,n.useActionContext)().setVisible,t=o.App.useApp().message,r=(0,s.useForm)(),a=(0,n.useDataBlockResource)(),i=(0,n.useCollection)(),l=(0,n.useAPIClient)(),u=(0,n.usePlugin)(b.default),c=(0,n.useBlockRequestContext)().service;return{type:"primary",onClick:function(){var n;return(n=function(){var n,o,s,f,p,d;return function(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function l(a){return function(l){var u=[a,l];if(r)throw TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(b){switch(b.label){case 0:return[4,r.submit()];case 1:if(b.sent(),!(n=r.values)[i.filterTargetKey])return[3,3];return[4,a.update({values:n,filterByTk:n[i.filterTargetKey]})];case 2:return b.sent(),[3,6];case 3:var y,v,h,g;return o=(0,m.uid)(),s=u.getFormSchemaByType(n.type),p=(f=n.collection.split(":")).pop(),y=s({collection:p,dataSource:f.pop()||"main"}),v=u.t.bind(u),(d={type:"void",name:(0,m.uid)(),"x-decorator":"PublicFormMessageProvider",properties:{form:y,promptMessage:{type:"void","x-component":"h3","x-component-props":{style:{margin:"10px 0px 10px"},children:'{{ t("Prompt after successful submission",{ns:"public-forms"})}}'}},success:{type:"void","x-editable":!1,"x-toolbar-props":{draggable:!1},"x-settings":"blockSettings:publicMarkdown","x-component":"Markdown.Void","x-decorator":"CardItem","x-component-props":{content:v("# Submitted successfully!\nThis is a demo text, **supports Markdown syntax**.")},"x-decorator-props":{name:"markdown",engine:"handlebars"}}}})["x-uid"]=o,[4,a.create({values:(h=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},n),g=g={key:o},Object.getOwnPropertyDescriptors?Object.defineProperties(h,Object.getOwnPropertyDescriptors(g)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(g)).forEach(function(e){Object.defineProperty(h,e,Object.getOwnPropertyDescriptor(g,e))}),h)})];case 4:return b.sent(),[4,l.resource("uiSchemas").insert({values:d})];case 5:b.sent(),b.label=6;case 6:return r.reset(),[4,c.refresh()];case 7:return b.sent(),t.success("Saved successfully!"),e(!1),[2]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var a=n.apply(e,t);function i(e){y(a,r,o,i,l,"next",e)}function l(e){y(a,r,o,i,l,"throw",e)}i(void 0)})})()}}}}}]);