@verdocs/web-sdk 1.10.6 → 1.10.8

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 (34) hide show
  1. package/dist/cjs/verdocs-quick-functions_3.cjs.entry.js +1 -1
  2. package/dist/cjs/verdocs-template-create_2.cjs.entry.js +37 -7
  3. package/dist/cjs/verdocs-template-recipients.cjs.entry.js +5 -3
  4. package/dist/collection/components/elements/verdocs-search-box/verdocs-search-box.js +2 -2
  5. package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js +37 -7
  6. package/dist/collection/components/templates/verdocs-template-recipients/verdocs-template-recipients.css +11 -0
  7. package/dist/collection/components/templates/verdocs-template-recipients/verdocs-template-recipients.js +18 -2
  8. package/dist/collection/components/templates/verdocs-template-recipients/verdocs-template-recipients.stories.js +5 -4
  9. package/dist/components/verdocs-search-box2.js +1 -1
  10. package/dist/components/verdocs-template-fields2.js +37 -7
  11. package/dist/components/verdocs-template-recipients.js +5 -3
  12. package/dist/custom-elements.json +1361 -0
  13. package/dist/docs.json +11 -2
  14. package/dist/esm/verdocs-quick-functions_3.entry.js +1 -1
  15. package/dist/esm/verdocs-template-create_2.entry.js +37 -7
  16. package/dist/esm/verdocs-template-recipients.entry.js +5 -3
  17. package/dist/esm-es5/verdocs-quick-functions_3.entry.js +1 -1
  18. package/dist/esm-es5/verdocs-template-create_2.entry.js +1 -1
  19. package/dist/esm-es5/verdocs-template-recipients.entry.js +1 -1
  20. package/dist/types/components/templates/verdocs-template-recipients/verdocs-template-recipients.d.ts +4 -0
  21. package/dist/types/components/templates/verdocs-template-recipients/verdocs-template-recipients.stories.d.ts +3 -2
  22. package/dist/types/components.d.ts +4 -0
  23. package/dist/verdocs-web-sdk/p-53198827.entry.js +1 -0
  24. package/dist/verdocs-web-sdk/p-59c4e444.entry.js +1 -0
  25. package/dist/verdocs-web-sdk/p-7bc5fc1e.system.entry.js +1 -0
  26. package/dist/verdocs-web-sdk/{p-3fbe602a.system.entry.js → p-83adc0f7.system.entry.js} +1 -1
  27. package/dist/verdocs-web-sdk/p-c16b6ca4.system.js +1 -1
  28. package/dist/verdocs-web-sdk/{p-205027db.entry.js → p-cf8522b5.entry.js} +1 -1
  29. package/dist/verdocs-web-sdk/{p-cf9883c7.system.entry.js → p-e82bebc9.system.entry.js} +1 -1
  30. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  31. package/package.json +2 -2
  32. package/dist/verdocs-web-sdk/p-8c3d48c1.entry.js +0 -1
  33. package/dist/verdocs-web-sdk/p-e179e3de.system.entry.js +0 -1
  34. package/dist/verdocs-web-sdk/p-f69cdc41.entry.js +0 -1
package/dist/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2023-02-10T13:08:38",
2
+ "timestamp": "2023-02-11T01:05:52",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "2.20.0",
@@ -4283,7 +4283,7 @@
4283
4283
  "reflectToAttr": false,
4284
4284
  "docs": "The placeholder to display in the input field.",
4285
4285
  "docsTags": [],
4286
- "default": "'search documents, templates, people...'",
4286
+ "default": "'Search envelopes, templates, organizations...'",
4287
4287
  "values": [
4288
4288
  {
4289
4289
  "type": "string"
@@ -5618,6 +5618,15 @@
5618
5618
  "docs": "Event fired when the user cancels the dialog.",
5619
5619
  "docsTags": []
5620
5620
  },
5621
+ {
5622
+ "event": "next",
5623
+ "detail": "any",
5624
+ "bubbles": true,
5625
+ "cancelable": true,
5626
+ "composed": true,
5627
+ "docs": "Event fired when the user clicks to proceed.",
5628
+ "docsTags": []
5629
+ },
5621
5630
  {
5622
5631
  "event": "sdkError",
5623
5632
  "detail": "SDKError",
@@ -177,7 +177,7 @@ const VerdocsSearchBox = class {
177
177
  this.typeChanged = createEvent(this, "typeChanged", 7);
178
178
  this.queryChanged = createEvent(this, "queryChanged", 7);
179
179
  this.endpoint = VerdocsEndpoint.getDefault();
180
- this.placeholder = 'search documents, templates, people...';
180
+ this.placeholder = 'Search envelopes, templates, organizations...';
181
181
  this.type = 'all';
182
182
  this.query = '';
183
183
  this.grabsFocus = false;
@@ -286,14 +286,44 @@ const VerdocsTemplateFields = class {
286
286
  required: true,
287
287
  page_sequence: pageNumber,
288
288
  validator: null,
289
- setting: {
290
- width,
291
- height,
292
- x,
293
- y,
294
- result: '',
295
- },
289
+ setting: { x, y }, // In the future, this is all we should send, see below
296
290
  };
291
+ // TODO: Fix how the server validates all this. It uses a JSON schema and is very particular about shapes for each field type.
292
+ // That makes it harder for third party developers to create fields via API calls. It would be better to always set X/Y and
293
+ // let the server normalize the rest, discarding properties that are invalid and back-filling defaults as needed.
294
+ switch (field.type) {
295
+ case 'attachment':
296
+ case 'payment':
297
+ field.setting = { x, y };
298
+ break;
299
+ case 'initial':
300
+ case 'signature':
301
+ field.setting = { x, y, result: '' };
302
+ break;
303
+ case 'checkbox_group':
304
+ field.setting = { x, y, minimum_checked: 0, maximum_checked: 1000 };
305
+ break;
306
+ case 'date':
307
+ field.setting = { x, y, width, height, result: '' };
308
+ break;
309
+ // TODO: Remove this everywhere
310
+ // case 'checkbox':break;
311
+ // TODO: What is this?
312
+ // case 'placeholder':break;
313
+ case 'dropdown':
314
+ field.setting = { x, y, width, height, value: '', placeholder: 'Select a value' };
315
+ break;
316
+ case 'radio_button_group':
317
+ field.setting = { x, y };
318
+ break;
319
+ // TODO: What about textareas?
320
+ case 'textbox':
321
+ field.setting = { x, y, width, height, result: '', leading: 0, alignment: 0, upperCase: false };
322
+ break;
323
+ case 'timestamp':
324
+ field.setting = { x, y, width, height };
325
+ break;
326
+ }
297
327
  const saved = await createField(this.endpoint, this.templateId, field);
298
328
  console.log('Saved field', saved);
299
329
  state.fields.push(saved);
@@ -14,7 +14,7 @@ import './Templates-8e4ab976.js';
14
14
  import './Envelopes-130fd6ea.js';
15
15
  import './Files-70a192df.js';
16
16
 
17
- const verdocsTemplateRecipientsCss = "verdocs-template-recipients{display:block;min-width:400px;font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif}verdocs-template-recipients>form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;padding:12px}verdocs-template-recipients>form h5{font-size:16px;font-weight:bold;color:#4c56cb;margin:0 0 10px 0}verdocs-template-recipients>form .participants{position:relative}verdocs-template-recipients>form .left-line{top:32px;left:11px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-template-recipients>form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:0;-moz-column-gap:0;column-gap:0;margin-left:40px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:6px 0 4px 0}verdocs-template-recipients>form .row .row-recipients{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;-ms-flex-direction:row;flex-direction:row}verdocs-template-recipients>form .row .icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-template-recipients>form .row .sender{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 5px 0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;border:1px solid #c6c9cc;background-color:#f5f5fa}verdocs-template-recipients>form .row .complete{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;background-color:#f5f5fa;border:1px solid #aeb4bf}verdocs-template-recipients>form .row .label{font-weight:bold;margin-right:6px;color:#33364b}verdocs-template-recipients>form .row .settings-button{margin:4px 0 0 9px;cursor:pointer}verdocs-template-recipients>form .row .recipient{height:30px;display:-ms-flexbox;display:flex;font-size:14px;line-height:30px;border-radius:30px;-ms-flex-direction:row;flex-direction:row;padding:0 5px 0 6px;white-space:nowrap;border:1px solid #aeb4bf}verdocs-template-recipients>form .row .recipient .type-icon{width:24px;height:24px;-webkit-transform:scale(0.8);transform:scale(0.8);opacity:0.6;margin:4px 12px 0 0}verdocs-template-recipients>form .row .recipient.dragging{position:absolute}verdocs-template-recipients>form .row .recipient.dragging+.dropzone{display:none !important}verdocs-template-recipients>form .row .dropzone{width:14px;height:30px;display:none}verdocs-template-recipients>form .row .dropzone svg{fill:#cccccc}verdocs-template-recipients>form .row .dropzone.visible{margin:0 7px;display:-ms-flexbox;display:flex;-ms-flex:0 0 14px;flex:0 0 14px}verdocs-template-recipients>form .row .dropzone.active{-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;background:#654dcb7f;border:1px dashed #654dcb}verdocs-template-recipients>form label{display:block;font-size:14px;font-weight:500;margin:0 0 4px 0;color:#5c6575}verdocs-template-recipients>form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-recipients>form input:focus{outline:none}verdocs-template-recipients .row.add-sequence{display:none}verdocs-template-recipients .add-role{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-recipients .add-role:hover{opacity:1}verdocs-template-recipients .add-role svg{width:32px;height:32px}verdocs-template-recipients.dragging .add-role{display:none}verdocs-template-recipients.dragging form .row .recipient+.dropzone{display:-ms-flexbox;display:flex}verdocs-template-recipients.dragging .row.add-sequence{display:-ms-flexbox;display:flex}verdocs-template-recipients.dragging .row.add-sequence .dropzone{opacity:0.5;-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;-ms-flex-align:center;align-items:center;background:#654dcb7f;-ms-flex-pack:center;justify-content:center;border:1px dashed #654dcb}verdocs-template-recipients.dragging .row.add-sequence .dropzone.active{opacity:1}verdocs-template-recipients .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-direction:row;flex-direction:row}verdocs-template-recipients ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::-moz-placeholder{color:#aaaaaa}verdocs-template-recipients :-ms-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::placeholder{color:#aaaaaa}";
17
+ const verdocsTemplateRecipientsCss = "verdocs-template-recipients{display:block;min-width:400px;font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif}verdocs-template-recipients>form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;padding:12px}verdocs-template-recipients>form h5{font-size:16px;font-weight:bold;color:#4c56cb;margin:0 0 10px 0}verdocs-template-recipients>form .participants{position:relative}verdocs-template-recipients>form .left-line{top:32px;left:11px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-template-recipients>form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:0;-moz-column-gap:0;column-gap:0;margin-left:40px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:6px 0 4px 0}verdocs-template-recipients>form .row .row-recipients{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;-ms-flex-direction:row;flex-direction:row}verdocs-template-recipients>form .row .icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-template-recipients>form .row .sender{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 5px 0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;border:1px solid #c6c9cc;background-color:#f5f5fa}verdocs-template-recipients>form .row .complete{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;background-color:#f5f5fa;border:1px solid #aeb4bf}verdocs-template-recipients>form .row .label{font-weight:bold;margin-right:6px;color:#33364b}verdocs-template-recipients>form .row .settings-button{margin:4px 0 0 9px;cursor:pointer}verdocs-template-recipients>form .row .recipient{height:30px;display:-ms-flexbox;display:flex;font-size:14px;line-height:30px;border-radius:30px;-ms-flex-direction:row;flex-direction:row;padding:0 5px 0 6px;white-space:nowrap;border:1px solid #aeb4bf}verdocs-template-recipients>form .row .recipient .type-icon{width:24px;height:24px;-webkit-transform:scale(0.8);transform:scale(0.8);opacity:0.6;margin:4px 12px 0 0}verdocs-template-recipients>form .row .recipient.dragging{position:absolute}verdocs-template-recipients>form .row .recipient.dragging+.dropzone{display:none !important}verdocs-template-recipients>form .row .dropzone{width:14px;height:30px;display:none}verdocs-template-recipients>form .row .dropzone svg{fill:#cccccc}verdocs-template-recipients>form .row .dropzone.visible{margin:0 7px;display:-ms-flexbox;display:flex;-ms-flex:0 0 14px;flex:0 0 14px}verdocs-template-recipients>form .row .dropzone.active{-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;background:#654dcb7f;border:1px dashed #654dcb}verdocs-template-recipients>form label{display:block;font-size:14px;font-weight:500;margin:0 0 4px 0;color:#5c6575}verdocs-template-recipients>form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-recipients>form input:focus{outline:none}verdocs-template-recipients .row.add-sequence{display:none}verdocs-template-recipients .add-role{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-recipients .add-role:hover{opacity:1}verdocs-template-recipients .add-role svg{width:32px;height:32px}verdocs-template-recipients.dragging .add-role{display:none}verdocs-template-recipients.dragging form .row .recipient+.dropzone{display:-ms-flexbox;display:flex}verdocs-template-recipients.dragging .row.add-sequence{display:-ms-flexbox;display:flex}verdocs-template-recipients.dragging .row.add-sequence .dropzone{opacity:0.5;-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;-ms-flex-align:center;align-items:center;background:#654dcb7f;-ms-flex-pack:center;justify-content:center;border:1px dashed #654dcb}verdocs-template-recipients.dragging .row.add-sequence .dropzone.active{opacity:1}verdocs-template-recipients .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-direction:row;flex-direction:row}verdocs-template-recipients .empty{font-size:13px;margin-top:15px;margin-bottom:5px}verdocs-template-recipients .empty svg{width:20px;height:20px;stroke:#666666;margin-bottom:-5px}verdocs-template-recipients ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::-moz-placeholder{color:#aaaaaa}verdocs-template-recipients :-ms-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::placeholder{color:#aaaaaa}";
18
18
 
19
19
  const senderLabels = {
20
20
  [TemplateSenderTypes.EVERYONE]: 'Everyone',
@@ -34,6 +34,7 @@ const iconCC = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill
34
34
  const VerdocsTemplateRecipients = class {
35
35
  constructor(hostRef) {
36
36
  registerInstance(this, hostRef);
37
+ this.next = createEvent(this, "next", 7);
37
38
  this.cancel = createEvent(this, "cancel", 7);
38
39
  this.sdkError = createEvent(this, "sdkError", 7);
39
40
  this.sequences = [];
@@ -155,7 +156,9 @@ const VerdocsTemplateRecipients = class {
155
156
  (_a = this.cancel) === null || _a === void 0 ? void 0 : _a.emit();
156
157
  }
157
158
  handleSubmit(e) {
159
+ var _a;
158
160
  e.stopPropagation();
161
+ (_a = this.next) === null || _a === void 0 ? void 0 : _a.emit();
159
162
  }
160
163
  sortTemplateRoles() {
161
164
  state.template.roles.sort((a, b) => {
@@ -225,13 +228,12 @@ const VerdocsTemplateRecipients = class {
225
228
  });
226
229
  }
227
230
  render() {
228
- // console.log('Roles', JSON.parse(JSON.stringify(TemplateStore.template.roles)));
229
231
  const roleNames = state.template.roles.map(role => role.name);
230
232
  return (h(Host, null, h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off", "data-r": this.forceRerender }, h("h5", null, "Recipients"), h("div", { class: "participants" }, h("div", { class: "left-line" }), h("div", { class: "row" }, h("div", { class: "icon", innerHTML: startIcon }), h("div", { class: "row-recipients" }, h("div", { class: "sender" }, h("span", { class: "label" }, "Sender:"), " ", senderLabels[state.template.sender], ' ', h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingSenderDialog = true), "aria-role": "button" })))), h("div", { class: "row add-sequence", "data-sequence": 0 }, h("div", { class: "icon", innerHTML: plusIcon }), h("div", { class: "row-recipients" }, h("div", { class: "dropzone", "data-sequence": 0, "data-order": 1 }, "Add Step"))), this.sequences.map(sequence => (h(Fragment, null, h("div", { class: "row" }, h("div", { class: "icon", innerHTML: stepIcon }), h("div", { class: "row-recipients" }, h("div", { class: "dropzone", "data-order": 0.5, "data-sequence": sequence }), state.template.roles
231
233
  .filter(role => role.sequence === sequence)
232
234
  .map(role => {
233
235
  return (h(Fragment, null, h("div", { class: "recipient", style: { backgroundColor: getRGBA(getRoleIndex(roleNames, role.name)) }, "data-rolename": role.name }, h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.name, " ", h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence })));
234
- }), h("button", { class: "add-role", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) }))), h("div", { class: "row add-sequence", "data-sequence": sequence }, h("div", { class: "row-recipients" }, h("div", { class: "icon", innerHTML: plusIcon }), h("div", { class: "dropzone", "data-sequence": sequence + 1, "data-order": 1 }, "Add Step")))))), h("div", { class: "row" }, h("div", { class: "icon", innerHTML: doneIcon }), h("div", { class: "row-recipients" }, h("div", { class: "complete" }, "Document Complete")))), h("div", { class: "buttons" }, h("div", { class: "flex-fill" }), h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: e => this.handleCancel(e) }), h("verdocs-button", { label: "OK", size: "small", onClick: e => this.handleSubmit(e) }))), this.showingRoleDialog && (h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
236
+ }), h("button", { class: "add-role", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) }))), h("div", { class: "row add-sequence", "data-sequence": sequence }, h("div", { class: "row-recipients" }, h("div", { class: "icon", innerHTML: plusIcon }), h("div", { class: "dropzone", "data-sequence": sequence + 1, "data-order": 1 }, "Add Step")))))), this.sequences.length < 1 && (h(Fragment, null, h("div", { class: "row" }, h("div", { class: "icon", innerHTML: stepIcon }), h("div", { class: "row-recipients" }, h("button", { class: "add-role", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, 1) }))))), h("div", { class: "row" }, h("div", { class: "icon", innerHTML: doneIcon }), h("div", { class: "row-recipients" }, h("div", { class: "complete" }, "Document Complete")))), roleNames.length < 1 && (h("div", { class: "empty" }, "You must add at least one Role before proceeding.", h("br", null), " Click the ", h("span", { innerHTML: plusIcon }), " Add button above to get started.")), h("div", { class: "buttons" }, h("div", { class: "flex-fill" }), h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: e => this.handleCancel(e) }), h("verdocs-button", { label: "OK", size: "small", onClick: e => this.handleSubmit(e), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
235
237
  this.showingRoleDialog = null;
236
238
  this.forceRerender++;
237
239
  }, onDelete: e => {
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function c(e){try{a(r["throw"](e))}catch(e){o(e)}}function a(e){e.done?n(e.value):i(e.value).then(s,c)}a((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(e){return function(t){return a([e,t])}}function a(s){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;i=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1];o=s;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(s);break}if(o[2])n.ops.pop();n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e];i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h}from"./index-f78d163d.js";import{V as VerdocsEndpoint}from"./VerdocsEndpoint-7f17b088.js";import{a as getTemplates}from"./Templates-8e4ab976.js";import"./Token-54690789.js";var __awaiter=undefined&&undefined.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function c(e){try{a(r["throw"](e))}catch(e){o(e)}}function a(e){e.done?n(e.value):i(e.value).then(s,c)}a((r=r.apply(e,t||[])).next())}))};var __generator=undefined&&undefined.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(e){return function(t){return a([e,t])}}function a(c){if(r)throw new TypeError("Generator is already executing.");while(s&&(s=0,c[0]&&(n=0)),n)try{if(r=1,i&&(o=c[0]&2?i["return"]:c[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;if(i=0,o)c=[c[0]&2,o.value];switch(c[0]){case 0:case 1:o=c;break;case 4:n.label++;return{value:c[1],done:false};case 5:n.label++;i=c[1];c=[0];continue;case 7:c=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1];o=c;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(c);break}if(o[2])n.ops.pop();n.trys.pop();continue}c=t.call(e,n)}catch(e){c=[6,e];i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};var getSearchHistory=function(e){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return[2,e.api.get("/search/history").then((function(e){return e.data}))]}))}))};var verdocsQuickFunctionsCss='verdocs-quick-functions{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-quick-functions .container{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;width:240px;background-color:#1e2031;text-transform:uppercase;padding:10px 10px 20px 10px;font-family:sans-serif;color:#ffffff}verdocs-quick-functions .title{font-size:22px;font-weight:700;line-height:30px;margin:1em 0 40px 0}verdocs-quick-functions button{width:140px;height:40px;border:none;display:-ms-flexbox;display:flex;color:#ffffff;cursor:pointer;font-size:14px;font-weight:700;line-height:25px;-ms-flex-align:center;align-items:center;margin-bottom:20px;border-radius:5px;text-transform:uppercase;-ms-flex-pack:space-evenly;justify-content:space-evenly;background-color:#55bc81}verdocs-quick-functions button svg{fill:#ffffff}';var DocumentIcon$1='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"/></svg>';var TemplateIcon='<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/><g><path d="M19,5v14H5V5H19 M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z"/></g><path d="M14,17H7v-2h7V17z M17,13H7v-2h10V13z M17,9H7V7h10V9z"/></g></svg>';var VerdocsQuickFunctions=function(){function e(e){registerInstance(this,e);this.createTemplate=createEvent(this,"createTemplate",7);this.createDocument=createEvent(this,"createDocument",7);this.endpoint=VerdocsEndpoint.getDefault()}e.prototype.handleCreateTemplate=function(){this.createTemplate.emit()};e.prototype.handleCreateDocument=function(){this.createDocument.emit()};e.prototype.render=function(){var e=this;return h("div",{class:"container"},h("p",{class:"title"},"Quick Create"),h("button",{onClick:function(){return e.handleCreateTemplate()},innerHTML:TemplateIcon},"Template"),h("button",{onClick:function(){return e.handleCreateDocument()},innerHTML:DocumentIcon$1},"Document"))};return e}();VerdocsQuickFunctions.style=verdocsQuickFunctionsCss;var verdocsSearchActivityCss='verdocs-search-activity{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-search-activity .container{display:-ms-flexbox;display:flex;width:240px;color:#ffffff;-ms-flex-direction:column;flex-direction:column;text-transform:uppercase;padding:10px 10px 20px 10px;background-color:#1e2031}verdocs-search-activity .title{font-size:22px;font-weight:700;line-height:30px}verdocs-search-activity .items{display:-ms-flexbox;display:flex;margin-top:20px;-ms-flex-direction:column;flex-direction:column}verdocs-search-activity .item{border:none;display:-ms-flexbox;display:flex;text-align:left;margin-bottom:20px;-ms-flex-direction:row;flex-direction:row;background:transparent}verdocs-search-activity .item:hover{cursor:pointer}verdocs-search-activity .icon{-ms-flex:0 0 22px;flex:0 0 22px;margin-right:14px}verdocs-search-activity .icon svg{fill:#707ae5;width:22px;height:22px}verdocs-search-activity .details{display:-ms-flexbox;display:flex;overflow:hidden;-ms-flex-direction:column;flex-direction:column}verdocs-search-activity .item-title{font-size:16px;font-weight:400;color:#ffffff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-search-activity .info{font-size:14px;font-weight:500;line-height:23px;color:#aeb4bf}verdocs-search-activity .empty{text-transform:none;line-height:22px;color:#cccccc}';var DocumentIcon='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"/></svg>';var VerdocsSearchActivity=function(){function e(e){registerInstance(this,e);this.entrySelected=createEvent(this,"entrySelected",7);this.endpoint=VerdocsEndpoint.getDefault();this.type="recent";this.options=undefined;this.emptyMessage="You do not have any starred searches.";this.authFailure=false;this.title="Recent Searches";this.recent=[];this.saved=[];this.starred=[]}e.prototype.componentWillLoad=function(){var e=this;this.endpoint.loadSession();var t=function(t){var n;console.warn("[Verdocs/search-activity] Error getting search data",t);if(((n=t===null||t===void 0?void 0:t.response)===null||n===void 0?void 0:n.status)===401){e.authFailure=true}};switch(this.type){case"recent":this.title="Recent Searches";this.emptyMessage="You do not have any recent searches.";getSearchHistory(this.endpoint).then((function(t){return e.recent=t.recent})).catch(t);break;case"saved":this.title="Saved Searches";this.emptyMessage="You do not have any saved searches.";getSearchHistory(this.endpoint).then((function(t){return e.saved=t.saved})).catch(t);break;case"starred":this.title="My Starred items";this.emptyMessage="You do not have any starred templates.";getTemplates(this.endpoint,{is_starred:true}).then((function(t){return e.starred=t})).catch(t);break}};e.prototype.handleSelectEntry=function(e){this.entrySelected.emit(e)};e.prototype.computePagesText=function(e){if(e<2){return"".concat(e," Page")}else{return"".concat(e," Pages")}};e.prototype.computeRecipientsText=function(e){if(typeof e==="object"){return e.join(", ")}else if(e>1){return"".concat(e," Recipients")}else{return"".concat(e," Recipient")}};e.prototype.render=function(){var e=this;var t=this.recent.length<1&&this.saved.length<1&&this.starred.length<1;return h("div",{class:"container"},h("p",{class:"title"},this.title),h("div",{class:"items"},this.recent.map((function(t){return h("button",{class:"item",onClick:function(){return e.handleSelectEntry(t)}},h("div",{class:"icon",innerHTML:DocumentIcon}),h("div",{class:"details"},h("div",{class:"item-title"},t.params.q),h("div",{class:"info"},"Test")))})),this.saved.map((function(t){return h("button",{class:"item",onClick:function(){return e.handleSelectEntry(t)}},h("div",{class:"icon",innerHTML:DocumentIcon}),h("div",{class:"details"},h("div",{class:"item-title"},t.params.q),h("div",{class:"info"})))})),t&&h("div",{class:"empty"},this.authFailure?"Authentication required":this.emptyMessage)))};return e}();VerdocsSearchActivity.style=verdocsSearchActivityCss;var verdocsSearchBoxCss='verdocs-search-box{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-search-box form{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;height:45px;-webkit-box-sizing:border-box;box-sizing:border-box;margin:5px 0 0;border-radius:5px;-ms-flex-align:center;align-items:center;background-color:#fff;padding:0 8px;border-width:1px;border-style:solid;border-color:#707ae5}verdocs-search-box form input{-webkit-box-sizing:border-box;box-sizing:border-box;height:43px;width:100%;font-size:18px;border:none}verdocs-search-box form input:focus{outline:none}verdocs-search-box form button.search{cursor:pointer;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:4px;border:none;width:100px;height:28px;font-weight:700;font-size:10px;letter-spacing:1px;background-color:#55bc81;text-transform:uppercase;color:#fff}verdocs-search-box form .type{background-color:#707ae5;height:30px;display:-ms-inline-flexbox;display:inline-flex;padding:1px 0 2px 10px;font-size:13px;line-height:16px;border-radius:4px;-ms-flex-pack:center;justify-content:center;text-transform:uppercase;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#fff;margin-right:10px}verdocs-search-box form .type button{border:none;color:#fff;margin:5px 0 0 8px;background:transparent}verdocs-search-box form svg{width:12px;height:12px;margin-right:6px}verdocs-search-box ::-webkit-input-placeholder{color:#aeb4bf}verdocs-search-box ::-moz-placeholder{color:#aeb4bf}verdocs-search-box :-ms-input-placeholder{color:#aeb4bf}verdocs-search-box ::-ms-input-placeholder{color:#aeb4bf}verdocs-search-box ::placeholder{color:#aeb4bf}';var SearchIcon='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23.4809 20.7176L17.9111 15.2536C19.0961 13.6368 19.727 11.6926 19.7128 9.70131C19.7201 7.53345 18.9846 5.42606 17.6244 3.71753C16.2642 2.009 14.3581 0.798456 12.2123 0.280282C10.0665 -0.237892 7.80552 -0.0336342 5.79227 0.86026C3.77902 1.75415 2.13038 3.28582 1.1111 5.20931C0.0918114 7.1328 -0.238985 9.33652 0.171813 11.4666C0.582612 13.5967 1.71117 15.5296 3.37628 16.9548C5.0414 18.3801 7.14646 19.2151 9.35344 19.3257C11.5604 19.4364 13.7413 18.8162 15.5458 17.5649L21.1372 23.05L21.1563 23.0663C21.4841 23.3487 21.9039 23.507 22.3401 23.5128C22.7823 23.5125 23.2063 23.3402 23.5191 23.0337V23.0337C23.6749 22.8812 23.7979 22.6995 23.8804 22.4993C23.963 22.2991 24.0036 22.0847 23.9997 21.8688C23.9959 21.6529 23.9477 21.44 23.858 21.2428C23.7683 21.0456 23.639 20.8682 23.4778 20.7212L23.4809 20.7176ZM14.5167 14.1975C13.4564 15.2349 12.0623 15.8797 10.5719 16.022C9.08145 16.1644 7.58681 15.7955 6.34249 14.9781C5.09816 14.1608 4.18109 12.9456 3.74751 11.5395C3.31393 10.1334 3.39064 8.6233 3.96455 7.26643C4.53846 5.90955 5.57409 4.7898 6.89507 4.09787C8.21606 3.40594 9.74071 3.18461 11.2093 3.4716C12.678 3.75858 13.9998 4.53612 14.9497 5.6718C15.8996 6.80748 16.4188 8.23105 16.4189 9.7001C16.4196 10.5357 16.2519 11.3632 15.9254 12.135C15.599 12.9069 15.1202 13.6078 14.5167 14.1975V14.1975Z" fill="white"/></svg>';var CloseIcon='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.0739 11.7565L19.7127 6.23228C20.0875 5.85692 20.0875 5.25309 19.7127 4.87773L19.0213 4.20046C18.6382 3.82511 18.0219 3.82511 17.6387 4.20046L12 9.72472L6.36127 4.20046C5.97814 3.82511 5.36179 3.82511 4.97866 4.20046L4.28735 4.87773C3.90422 5.25309 3.90422 5.85692 4.28735 6.23228L9.92608 11.7565L4.28735 17.2808C3.90422 17.6561 3.90422 18.26 4.28735 18.6353L4.97866 19.3126C5.36179 19.688 5.97814 19.688 6.36127 19.3126L12 13.7883L17.6387 19.3126C18.0219 19.688 18.6382 19.688 19.0213 19.3126L19.7127 18.6353C20.0958 18.26 20.0958 17.6561 19.7127 17.2808L14.0739 11.7565Z" fill="white"/></svg>';var VerdocsSearchBox=function(){function e(e){registerInstance(this,e);this.searchClicked=createEvent(this,"searchClicked",7);this.typeChanged=createEvent(this,"typeChanged",7);this.queryChanged=createEvent(this,"queryChanged",7);this.endpoint=VerdocsEndpoint.getDefault();this.placeholder="search documents, templates, people...";this.type="all";this.query="";this.grabsFocus=false}e.prototype.focusField=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.inputEl.focus();return[2]}))}))};e.prototype.componentDidRender=function(){if(this.grabsFocus){this.inputEl.focus()}};e.prototype.handleSearch=function(e){this.searchClicked.emit({type:this.type,query:this.query});e.preventDefault();return false};e.prototype.handleChange=function(e){this.queryChanged.emit(e.target.value)};e.prototype.handleClearFilter=function(){this.typeChanged.emit("all")};e.prototype.handleKeyUp=function(e){if(e.key==="Enter"){this.searchClicked.emit({type:this.type,query:this.query})}};e.prototype.render=function(){var e=this;return h("form",{onSubmit:function(t){return e.handleSearch(t)}},this.type!==undefined&&this.type!=="all"&&h("span",{class:"type"},this.type,"s ",h("button",{class:"remove",innerHTML:CloseIcon,onClick:function(){return e.handleClearFilter()}})),h("input",{type:"text",value:this.query,placeholder:this.placeholder,onInput:function(t){return e.handleChange(t)},onKeyUp:function(t){return e.handleKeyUp(t)},ref:function(t){return e.inputEl=t}}),h("button",{onClick:function(t){return e.handleSearch(t)},class:"search"},h("span",{innerHTML:SearchIcon}),"Search"))};return e}();VerdocsSearchBox.style=verdocsSearchBoxCss;export{VerdocsQuickFunctions as verdocs_quick_functions,VerdocsSearchActivity as verdocs_search_activity,VerdocsSearchBox as verdocs_search_box};
1
+ var __awaiter=this&&this.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function c(e){try{a(r["throw"](e))}catch(e){o(e)}}function a(e){e.done?n(e.value):i(e.value).then(s,c)}a((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(e){return function(t){return a([e,t])}}function a(s){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=s[0]&2?i["return"]:s[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;if(i=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;i=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1];o=s;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(s);break}if(o[2])n.ops.pop();n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e];i=0}finally{r=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{r as registerInstance,c as createEvent,h}from"./index-f78d163d.js";import{V as VerdocsEndpoint}from"./VerdocsEndpoint-7f17b088.js";import{a as getTemplates}from"./Templates-8e4ab976.js";import"./Token-54690789.js";var __awaiter=undefined&&undefined.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function c(e){try{a(r["throw"](e))}catch(e){o(e)}}function a(e){e.done?n(e.value):i(e.value).then(s,c)}a((r=r.apply(e,t||[])).next())}))};var __generator=undefined&&undefined.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(e){return function(t){return a([e,t])}}function a(c){if(r)throw new TypeError("Generator is already executing.");while(s&&(s=0,c[0]&&(n=0)),n)try{if(r=1,i&&(o=c[0]&2?i["return"]:c[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;if(i=0,o)c=[c[0]&2,o.value];switch(c[0]){case 0:case 1:o=c;break;case 4:n.label++;return{value:c[1],done:false};case 5:n.label++;i=c[1];c=[0];continue;case 7:c=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1];o=c;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(c);break}if(o[2])n.ops.pop();n.trys.pop();continue}c=t.call(e,n)}catch(e){c=[6,e];i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};var getSearchHistory=function(e){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return[2,e.api.get("/search/history").then((function(e){return e.data}))]}))}))};var verdocsQuickFunctionsCss='verdocs-quick-functions{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-quick-functions .container{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap;width:240px;background-color:#1e2031;text-transform:uppercase;padding:10px 10px 20px 10px;font-family:sans-serif;color:#ffffff}verdocs-quick-functions .title{font-size:22px;font-weight:700;line-height:30px;margin:1em 0 40px 0}verdocs-quick-functions button{width:140px;height:40px;border:none;display:-ms-flexbox;display:flex;color:#ffffff;cursor:pointer;font-size:14px;font-weight:700;line-height:25px;-ms-flex-align:center;align-items:center;margin-bottom:20px;border-radius:5px;text-transform:uppercase;-ms-flex-pack:space-evenly;justify-content:space-evenly;background-color:#55bc81}verdocs-quick-functions button svg{fill:#ffffff}';var DocumentIcon$1='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"/></svg>';var TemplateIcon='<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/><g><path d="M19,5v14H5V5H19 M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3L19,3z"/></g><path d="M14,17H7v-2h7V17z M17,13H7v-2h10V13z M17,9H7V7h10V9z"/></g></svg>';var VerdocsQuickFunctions=function(){function e(e){registerInstance(this,e);this.createTemplate=createEvent(this,"createTemplate",7);this.createDocument=createEvent(this,"createDocument",7);this.endpoint=VerdocsEndpoint.getDefault()}e.prototype.handleCreateTemplate=function(){this.createTemplate.emit()};e.prototype.handleCreateDocument=function(){this.createDocument.emit()};e.prototype.render=function(){var e=this;return h("div",{class:"container"},h("p",{class:"title"},"Quick Create"),h("button",{onClick:function(){return e.handleCreateTemplate()},innerHTML:TemplateIcon},"Template"),h("button",{onClick:function(){return e.handleCreateDocument()},innerHTML:DocumentIcon$1},"Document"))};return e}();VerdocsQuickFunctions.style=verdocsQuickFunctionsCss;var verdocsSearchActivityCss='verdocs-search-activity{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-search-activity .container{display:-ms-flexbox;display:flex;width:240px;color:#ffffff;-ms-flex-direction:column;flex-direction:column;text-transform:uppercase;padding:10px 10px 20px 10px;background-color:#1e2031}verdocs-search-activity .title{font-size:22px;font-weight:700;line-height:30px}verdocs-search-activity .items{display:-ms-flexbox;display:flex;margin-top:20px;-ms-flex-direction:column;flex-direction:column}verdocs-search-activity .item{border:none;display:-ms-flexbox;display:flex;text-align:left;margin-bottom:20px;-ms-flex-direction:row;flex-direction:row;background:transparent}verdocs-search-activity .item:hover{cursor:pointer}verdocs-search-activity .icon{-ms-flex:0 0 22px;flex:0 0 22px;margin-right:14px}verdocs-search-activity .icon svg{fill:#707ae5;width:22px;height:22px}verdocs-search-activity .details{display:-ms-flexbox;display:flex;overflow:hidden;-ms-flex-direction:column;flex-direction:column}verdocs-search-activity .item-title{font-size:16px;font-weight:400;color:#ffffff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-search-activity .info{font-size:14px;font-weight:500;line-height:23px;color:#aeb4bf}verdocs-search-activity .empty{text-transform:none;line-height:22px;color:#cccccc}';var DocumentIcon='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"/></svg>';var VerdocsSearchActivity=function(){function e(e){registerInstance(this,e);this.entrySelected=createEvent(this,"entrySelected",7);this.endpoint=VerdocsEndpoint.getDefault();this.type="recent";this.options=undefined;this.emptyMessage="You do not have any starred searches.";this.authFailure=false;this.title="Recent Searches";this.recent=[];this.saved=[];this.starred=[]}e.prototype.componentWillLoad=function(){var e=this;this.endpoint.loadSession();var t=function(t){var n;console.warn("[Verdocs/search-activity] Error getting search data",t);if(((n=t===null||t===void 0?void 0:t.response)===null||n===void 0?void 0:n.status)===401){e.authFailure=true}};switch(this.type){case"recent":this.title="Recent Searches";this.emptyMessage="You do not have any recent searches.";getSearchHistory(this.endpoint).then((function(t){return e.recent=t.recent})).catch(t);break;case"saved":this.title="Saved Searches";this.emptyMessage="You do not have any saved searches.";getSearchHistory(this.endpoint).then((function(t){return e.saved=t.saved})).catch(t);break;case"starred":this.title="My Starred items";this.emptyMessage="You do not have any starred templates.";getTemplates(this.endpoint,{is_starred:true}).then((function(t){return e.starred=t})).catch(t);break}};e.prototype.handleSelectEntry=function(e){this.entrySelected.emit(e)};e.prototype.computePagesText=function(e){if(e<2){return"".concat(e," Page")}else{return"".concat(e," Pages")}};e.prototype.computeRecipientsText=function(e){if(typeof e==="object"){return e.join(", ")}else if(e>1){return"".concat(e," Recipients")}else{return"".concat(e," Recipient")}};e.prototype.render=function(){var e=this;var t=this.recent.length<1&&this.saved.length<1&&this.starred.length<1;return h("div",{class:"container"},h("p",{class:"title"},this.title),h("div",{class:"items"},this.recent.map((function(t){return h("button",{class:"item",onClick:function(){return e.handleSelectEntry(t)}},h("div",{class:"icon",innerHTML:DocumentIcon}),h("div",{class:"details"},h("div",{class:"item-title"},t.params.q),h("div",{class:"info"},"Test")))})),this.saved.map((function(t){return h("button",{class:"item",onClick:function(){return e.handleSelectEntry(t)}},h("div",{class:"icon",innerHTML:DocumentIcon}),h("div",{class:"details"},h("div",{class:"item-title"},t.params.q),h("div",{class:"info"})))})),t&&h("div",{class:"empty"},this.authFailure?"Authentication required":this.emptyMessage)))};return e}();VerdocsSearchActivity.style=verdocsSearchActivityCss;var verdocsSearchBoxCss='verdocs-search-box{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-search-box form{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;height:45px;-webkit-box-sizing:border-box;box-sizing:border-box;margin:5px 0 0;border-radius:5px;-ms-flex-align:center;align-items:center;background-color:#fff;padding:0 8px;border-width:1px;border-style:solid;border-color:#707ae5}verdocs-search-box form input{-webkit-box-sizing:border-box;box-sizing:border-box;height:43px;width:100%;font-size:18px;border:none}verdocs-search-box form input:focus{outline:none}verdocs-search-box form button.search{cursor:pointer;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:4px;border:none;width:100px;height:28px;font-weight:700;font-size:10px;letter-spacing:1px;background-color:#55bc81;text-transform:uppercase;color:#fff}verdocs-search-box form .type{background-color:#707ae5;height:30px;display:-ms-inline-flexbox;display:inline-flex;padding:1px 0 2px 10px;font-size:13px;line-height:16px;border-radius:4px;-ms-flex-pack:center;justify-content:center;text-transform:uppercase;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#fff;margin-right:10px}verdocs-search-box form .type button{border:none;color:#fff;margin:5px 0 0 8px;background:transparent}verdocs-search-box form svg{width:12px;height:12px;margin-right:6px}verdocs-search-box ::-webkit-input-placeholder{color:#aeb4bf}verdocs-search-box ::-moz-placeholder{color:#aeb4bf}verdocs-search-box :-ms-input-placeholder{color:#aeb4bf}verdocs-search-box ::-ms-input-placeholder{color:#aeb4bf}verdocs-search-box ::placeholder{color:#aeb4bf}';var SearchIcon='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23.4809 20.7176L17.9111 15.2536C19.0961 13.6368 19.727 11.6926 19.7128 9.70131C19.7201 7.53345 18.9846 5.42606 17.6244 3.71753C16.2642 2.009 14.3581 0.798456 12.2123 0.280282C10.0665 -0.237892 7.80552 -0.0336342 5.79227 0.86026C3.77902 1.75415 2.13038 3.28582 1.1111 5.20931C0.0918114 7.1328 -0.238985 9.33652 0.171813 11.4666C0.582612 13.5967 1.71117 15.5296 3.37628 16.9548C5.0414 18.3801 7.14646 19.2151 9.35344 19.3257C11.5604 19.4364 13.7413 18.8162 15.5458 17.5649L21.1372 23.05L21.1563 23.0663C21.4841 23.3487 21.9039 23.507 22.3401 23.5128C22.7823 23.5125 23.2063 23.3402 23.5191 23.0337V23.0337C23.6749 22.8812 23.7979 22.6995 23.8804 22.4993C23.963 22.2991 24.0036 22.0847 23.9997 21.8688C23.9959 21.6529 23.9477 21.44 23.858 21.2428C23.7683 21.0456 23.639 20.8682 23.4778 20.7212L23.4809 20.7176ZM14.5167 14.1975C13.4564 15.2349 12.0623 15.8797 10.5719 16.022C9.08145 16.1644 7.58681 15.7955 6.34249 14.9781C5.09816 14.1608 4.18109 12.9456 3.74751 11.5395C3.31393 10.1334 3.39064 8.6233 3.96455 7.26643C4.53846 5.90955 5.57409 4.7898 6.89507 4.09787C8.21606 3.40594 9.74071 3.18461 11.2093 3.4716C12.678 3.75858 13.9998 4.53612 14.9497 5.6718C15.8996 6.80748 16.4188 8.23105 16.4189 9.7001C16.4196 10.5357 16.2519 11.3632 15.9254 12.135C15.599 12.9069 15.1202 13.6078 14.5167 14.1975V14.1975Z" fill="white"/></svg>';var CloseIcon='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.0739 11.7565L19.7127 6.23228C20.0875 5.85692 20.0875 5.25309 19.7127 4.87773L19.0213 4.20046C18.6382 3.82511 18.0219 3.82511 17.6387 4.20046L12 9.72472L6.36127 4.20046C5.97814 3.82511 5.36179 3.82511 4.97866 4.20046L4.28735 4.87773C3.90422 5.25309 3.90422 5.85692 4.28735 6.23228L9.92608 11.7565L4.28735 17.2808C3.90422 17.6561 3.90422 18.26 4.28735 18.6353L4.97866 19.3126C5.36179 19.688 5.97814 19.688 6.36127 19.3126L12 13.7883L17.6387 19.3126C18.0219 19.688 18.6382 19.688 19.0213 19.3126L19.7127 18.6353C20.0958 18.26 20.0958 17.6561 19.7127 17.2808L14.0739 11.7565Z" fill="white"/></svg>';var VerdocsSearchBox=function(){function e(e){registerInstance(this,e);this.searchClicked=createEvent(this,"searchClicked",7);this.typeChanged=createEvent(this,"typeChanged",7);this.queryChanged=createEvent(this,"queryChanged",7);this.endpoint=VerdocsEndpoint.getDefault();this.placeholder="Search envelopes, templates, organizations...";this.type="all";this.query="";this.grabsFocus=false}e.prototype.focusField=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.inputEl.focus();return[2]}))}))};e.prototype.componentDidRender=function(){if(this.grabsFocus){this.inputEl.focus()}};e.prototype.handleSearch=function(e){this.searchClicked.emit({type:this.type,query:this.query});e.preventDefault();return false};e.prototype.handleChange=function(e){this.queryChanged.emit(e.target.value)};e.prototype.handleClearFilter=function(){this.typeChanged.emit("all")};e.prototype.handleKeyUp=function(e){if(e.key==="Enter"){this.searchClicked.emit({type:this.type,query:this.query})}};e.prototype.render=function(){var e=this;return h("form",{onSubmit:function(t){return e.handleSearch(t)}},this.type!==undefined&&this.type!=="all"&&h("span",{class:"type"},this.type,"s ",h("button",{class:"remove",innerHTML:CloseIcon,onClick:function(){return e.handleClearFilter()}})),h("input",{type:"text",value:this.query,placeholder:this.placeholder,onInput:function(t){return e.handleChange(t)},onKeyUp:function(t){return e.handleKeyUp(t)},ref:function(t){return e.inputEl=t}}),h("button",{onClick:function(t){return e.handleSearch(t)},class:"search"},h("span",{innerHTML:SearchIcon}),"Search"))};return e}();VerdocsSearchBox.style=verdocsSearchBoxCss;export{VerdocsQuickFunctions as verdocs_quick_functions,VerdocsSearchActivity as verdocs_search_activity,VerdocsSearchBox as verdocs_search_box};
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,i,a){function o(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,n){function r(e){try{l(a.next(e))}catch(e){n(e)}}function s(e){try{l(a["throw"](e))}catch(e){n(e)}}function l(e){e.done?i(e.value):o(e.value).then(r,s)}l((a=a.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},a,o,n,r;return r={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function s(e){return function(t){return l([e,t])}}function l(r){if(a)throw new TypeError("Generator is already executing.");while(i)try{if(a=1,o&&(n=r[0]&2?o["return"]:r[0]?o["throw"]||((n=o["return"])&&n.call(o),0):o.next)&&!(n=n.call(o,r[1])).done)return n;if(o=0,n)r=[r[0]&2,n.value];switch(r[0]){case 0:case 1:n=r;break;case 4:i.label++;return{value:r[1],done:false};case 5:i.label++;o=r[1];r=[0];continue;case 7:r=i.ops.pop();i.trys.pop();continue;default:if(!(n=i.trys,n=n.length>0&&n[n.length-1])&&(r[0]===6||r[0]===2)){i=0;continue}if(r[0]===3&&(!n||r[1]>n[0]&&r[1]<n[3])){i.label=r[1];break}if(r[0]===6&&i.label<n[1]){i.label=n[1];n=r;break}if(n&&i.label<n[2]){i.label=n[2];i.ops.push(r);break}if(n[2])i.ops.pop();i.trys.pop();continue}r=t.call(e,i)}catch(e){r=[6,e];o=0}finally{a=n=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,i){if(i||arguments.length===2)for(var a=0,o=t.length,n;a<o;a++){if(n||!(a in t)){if(!n)n=Array.prototype.slice.call(t,0,a);n[a]=t[a]}}return e.concat(n||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host}from"./index-f78d163d.js";import{c as createTemplate,g as getTemplate}from"./Templates-8e4ab976.js";import{V as VerdocsEndpoint}from"./VerdocsEndpoint-7f17b088.js";import{S as SDKError}from"./errors-9b5498c8.js";import{i as interact}from"./interact.min-32c1c1e4.js";import{u as updateField,c as createField}from"./Fields-c82e6df3.js";import{a as getRoleIndex,r as renderDocumentField,c as updateCssTransform,d as defaultWidth,e as defaultHeight}from"./utils-274e2e93.js";import{s as state}from"./templateStore-fd4beaae.js";import{l as loadTemplate}from"./Templates-7595bdbf.js";import"./Token-54690789.js";import"./Envelopes-130fd6ea.js";import"./Files-70a192df.js";import"./index-fd7b8a34.js";import"./Primitives-054bc6e5.js";var createTemplateDocument=function(e,t,i,a){var o=new FormData;o.append("document",i,i.name);return e.api.post("/templates/".concat(t,"/documents"),o,{timeout:1e4,onUploadProgress:function(e){var t=e.total||1;var i=e.loaded||0;a===null||a===void 0?void 0:a(Math.floor(i*100/(t||1)),i,t||1)}}).then((function(e){return e.data}))};var verdocsTemplateCreateCss='verdocs-template-create{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-create form{background-color:#ffffff;padding:12px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;width:340px}verdocs-template-create form .upload-box{max-width:320px;text-align:center;padding:44px 18px 66px;border:2px dashed #979797;color:rgba(0, 0, 0, 0.54)}verdocs-template-create form .upload-box svg{width:64px;fill:#5c6575}verdocs-template-create .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-create .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-create ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-create ::-moz-placeholder{color:#aaaaaa}verdocs-template-create :-ms-input-placeholder{color:#aaaaaa}verdocs-template-create ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-create ::placeholder{color:#aaaaaa}';var unicodeNBSP=" ";var FileIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"><path d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"></path></svg>';var VerdocsTemplateCreate=function(){function e(e){registerInstance(this,e);this.cancel=createEvent(this,"cancel",7);this.next=createEvent(this,"next",7);this.sdkError=createEvent(this,"sdkError",7);this.endpoint=VerdocsEndpoint.getDefault();this.file=undefined;this.creating=false}e.prototype.componentWillLoad=function(){this.endpoint.setTimeout(3e4);this.endpoint.loadSession()};e.prototype.handleFileChanged=function(e){var t;console.log("files",e.target.files);this.file=((t=e.target.files)===null||t===void 0?void 0:t[0])||null;console.log("Selected file",this.file)};e.prototype.handleUpload=function(e){e.stopPropagation();var t=document.getElementById("verdocs-template-create-file");t.click()};e.prototype.handleCancel=function(e){var t;e.stopPropagation();(t=this.cancel)===null||t===void 0?void 0:t.emit()};e.prototype.handleSubmit=function(e){return __awaiter(this,void 0,void 0,(function(){var t,i,a,o,n,r,s,l;return __generator(this,(function(d){switch(d.label){case 0:e.stopPropagation();if(!this.file){return[2]}d.label=1;case 1:d.trys.push([1,5,,6]);return[4,createTemplate(this.endpoint,{name:this.file.name})];case 2:n=d.sent();console.log("created template",n);return[4,createTemplateDocument(this.endpoint,n.id,this.file)];case 3:r=d.sent();console.log("created document",r);return[4,getTemplate(this.endpoint,n.id)];case 4:s=d.sent();console.log("[CREATE] Created template",s);(t=this.next)===null||t===void 0?void 0:t.emit(s);return[3,6];case 5:l=d.sent();console.log("[TEMPLATE-CREATE] Error creating template",l);(i=this.sdkError)===null||i===void 0?void 0:i.emit(new SDKError(l.message,(a=l.response)===null||a===void 0?void 0:a.status,(o=l.response)===null||o===void 0?void 0:o.data));return[3,6];case 6:return[2]}}))}))};e.prototype.render=function(){var e=this;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}return h("form",{onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off"},h("input",{type:"file",id:"verdocs-template-create-file",multiple:true,accept:"application/pdf",style:{display:"none"},onChange:function(t){return e.handleFileChanged(t)}}),h("div",{class:"upload-box"},h("div",null,h("span",{innerHTML:FileIcon})),h("div",{style:{marginTop:"20px",fontSize:"20px",fontWeight:"bold"}},this.file?this.file.name:"Drag a file here"),h("div",{style:{marginTop:"20px",marginBottom:"20px",fontSize:"16px",height:"20px"}},this.file?unicodeNBSP:"Or, if you prefer..."),h("verdocs-button",{label:this.file?"Select a different file":"Select a file from your computer",size:"small",onClick:function(t){return e.handleUpload(t)}})),h("div",{class:"buttons"},h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(t){return e.handleCancel(t)}}),h("verdocs-button",{label:"Next",size:"small",onClick:function(t){return e.handleSubmit(t)},disabled:!this.file})))};return e}();VerdocsTemplateCreate.style=verdocsTemplateCreateCss;var verdocsTemplateFieldsCss="verdocs-template-fields{font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif;position:relative}verdocs-template-fields .page-0{padding:65px 15px 0 15px;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-fields .page-0 .user-placed-fields{height:100px;position:relative;background:#ffffff;-webkit-box-shadow:0 0 10px 5px #0000000f;box-shadow:0 0 10px 5px #0000000f}verdocs-template-fields .page-0 .user-placed-fields .title{top:0;left:0;color:#ffffff;font-size:12px;padding:3px 6px;font-weight:bold;position:absolute;background:#46497d}verdocs-template-fields .pages{display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;position:relative;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-template-fields .pages div,verdocs-template-fields .pages canvas{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-fields.placing-attachment{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-checkbox{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-date{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-dropdown{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-initial{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-payment{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-radio{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M12 17q2.075 0 3.538-1.463Q17 14.075 17 12t-1.462-3.538Q14.075 7 12 7 9.925 7 8.463 8.462 7 9.925 7 12q0 2.075 1.463 3.537Q9.925 17 12 17Zm0 5.85q-2.275 0-4.25-.85t-3.438-2.312Q2.85 18.225 2 16.25q-.85-1.975-.85-4.25T2 7.75q.85-1.975 2.312-3.438Q5.775 2.85 7.75 2q1.975-.85 4.25-.85t4.25.85q1.975.85 3.438 2.312Q21.15 5.775 22 7.75q.85 1.975.85 4.25T22 16.25q-.85 1.975-2.312 3.438Q18.225 21.15 16.25 22q-1.975.85-4.25.85Zm0-3.15q3.25 0 5.475-2.225Q19.7 15.25 19.7 12q0-3.25-2.225-5.475Q15.25 4.3 12 4.3q-3.25 0-5.475 2.225Q4.3 8.75 4.3 12q0 3.25 2.225 5.475Q8.75 19.7 12 19.7Zm0-7.7Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-signature{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-textarea{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M3.225 20.725v-3.15h11.55v3.15Zm0-4.775V12.8h17.55v3.15Zm0-4.75V8.05h17.55v3.15Zm0-4.775v-3.15h17.55v3.15Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-textbox{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M3.425 16.15V13h11.15v3.15Zm0-5.15V7.85h17.15V11Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-timestamp{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}";var iconSingleline='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M3.425 16.15V13h11.15v3.15Zm0-5.15V7.85h17.15V11Z"/></svg>';var iconMultiline='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M3.225 20.725v-3.15h11.55v3.15Zm0-4.775V12.8h17.55v3.15Zm0-4.75V8.05h17.55v3.15Zm0-4.775v-3.15h17.55v3.15Z"/></svg>';var iconCheck='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z"/></svg>';var iconRadio='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M12 17q2.075 0 3.538-1.463Q17 14.075 17 12t-1.462-3.538Q14.075 7 12 7 9.925 7 8.463 8.462 7 9.925 7 12q0 2.075 1.463 3.537Q9.925 17 12 17Zm0 5.85q-2.275 0-4.25-.85t-3.438-2.312Q2.85 18.225 2 16.25q-.85-1.975-.85-4.25T2 7.75q.85-1.975 2.312-3.438Q5.775 2.85 7.75 2q1.975-.85 4.25-.85t4.25.85q1.975.85 3.438 2.312Q21.15 5.775 22 7.75q.85 1.975.85 4.25T22 16.25q-.85 1.975-2.312 3.438Q18.225 21.15 16.25 22q-1.975.85-4.25.85Zm0-3.15q3.25 0 5.475-2.225Q19.7 15.25 19.7 12q0-3.25-2.225-5.475Q15.25 4.3 12 4.3q-3.25 0-5.475 2.225Q4.3 8.75 4.3 12q0 3.25 2.225 5.475Q8.75 19.7 12 19.7Zm0-7.7Z"/></svg>';var iconDatepicker='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M7.6 13.925q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375ZM5.3 22.85q-1.325 0-2.238-.912-.912-.913-.912-2.238V6.3q0-1.325.912-2.238.913-.912 2.238-.912H6v-2h2.575v2h6.85v-2H18v2h.7q1.325 0 2.238.912.912.913.912 2.238v13.4q0 1.325-.912 2.238-.913.912-2.238.912Zm0-3.15h13.4V10H5.3v9.7ZM5.3 8h13.4V6.3H5.3Zm0 0V6.3 8Z"/></svg>';var iconSignature='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>';var iconInitial='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z"/></svg>';var menuOptions=[{id:"attachment",tooltip:"Attachment",icon:"A"},{id:"checkbox",tooltip:"Check Box",icon:iconCheck},{id:"date",tooltip:"Date",icon:iconDatepicker},{id:"dropdown",tooltip:"Dropdown",icon:"O"},{id:"initial",tooltip:"Initials",icon:iconInitial},{id:"payment",tooltip:"Payment",icon:"P"},{id:"radio",tooltip:"Radio Button",icon:iconRadio},{id:"signature",tooltip:"Signature",icon:iconSignature},{id:"textarea",tooltip:"Text Area",icon:iconMultiline},{id:"textbox",tooltip:"Text Box",icon:iconSingleline},{id:"timestamp",tooltip:"Timestamp",icon:"X"}];var VerdocsTemplateFields=function(){function e(e){registerInstance(this,e);this.next=createEvent(this,"next",7);this.cancel=createEvent(this,"cancel",7);this.sdkError=createEvent(this,"sdkError",7);this.pageHeights={};this.cachedPageInfo={};this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.placing=null;this.selectedRoleName=""}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,i,a,o,n,r,s;return __generator(this,(function(l){switch(l.label){case 0:l.trys.push([0,5,,6]);this.endpoint.loadSession();if(!this.templateId){console.log("[FIELDS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[BUILD] Unable to start builder session, must be authenticated");return[2]}l.label=1;case 1:l.trys.push([1,3,,4]);console.log("[FIELDS] Loading template ".concat(this.templateId),this.endpoint.session);return[4,loadTemplate(this.endpoint,this.templateId)];case 2:l.sent();this.selectedRoleName=state.roleNames[0];console.log("Starting with role",this.selectedRoleName);return[3,4];case 3:r=l.sent();console.log("[FIELDS] Error loading template",r);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(r.message,(t=r.response)===null||t===void 0?void 0:t.status,(i=r.response)===null||i===void 0?void 0:i.data));return[3,4];case 4:return[3,6];case 5:s=l.sent();console.log("[FIELDS] Error with preview session",s);(a=this.sdkError)===null||a===void 0?void 0:a.emit(new SDKError(s.message,(o=s.response)===null||o===void 0?void 0:o.status,(n=s.response)===null||n===void 0?void 0:n.data));return[3,6];case 6:return[2]}}))}))};e.prototype.componentDidRender=function(){interact.dynamicDrop(true)};e.prototype.handleFieldChange=function(e,t,i){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(a){console.log("[FIELDS] handleFieldChange",e,t,i);return[2]}))}))};e.prototype.attachFieldAttributes=function(e,t,i,a){var o=this;a.addEventListener("input",(function(e){return o.handleFieldChange(t,e)}));a.addEventListener("settingsChanged",(function(){a.setAttribute("roleindex",getRoleIndex(state.roleNames,t.role_name))}));a.setAttribute("roleindex",i);a.setAttribute("pageNumber",e.pageNumber);a.setAttribute("xScale",e.xScale);a.setAttribute("yScale",e.yScale);a.setAttribute("name",t.name)};e.prototype.handlePageRendered=function(e){var t=this;var i=e.detail;console.log("[FIELDS] Page rendered",i);this.cachedPageInfo[i.pageNumber]=i;this.pageHeights[i.pageNumber]=i.naturalHeight;var a=state.fields.filter((function(e){return e.page_sequence===i.pageNumber}));console.log("[FIELDS] Fields on page",a);a.forEach((function(e){var a=getRoleIndex(state.roleNames,e.role_name);var o=renderDocumentField(e,i,a,{disabled:true,editable:true,draggable:true});if(!o){return}if(Array.isArray(o)){o.map((function(o){return t.attachFieldAttributes(i,e,a,o)}))}else{t.attachFieldAttributes(i,e,a,o)}interact(o).draggable({listeners:{start:function(e){console.log("[FIELDS] Drag started",e.type,e.target)},move:function(e){var t=+(e.target.getAttribute("posX")||0);var i=+(e.target.getAttribute("posY")||0);var a=+(e.target.getAttribute("xScale")||1);var o=+(e.target.getAttribute("yScale")||1);var n=e.dx/a+t;var r=e.dy/o+i;e.target.setAttribute("posX",n);e.target.setAttribute("posy",r);updateCssTransform(e.target,"translate","".concat(n,"px, ").concat(r,"px"))},end:t.handleMoveField.bind(t)}})}))};e.prototype.handleMoveField=function(e){return __awaiter(this,void 0,void 0,(function(){var t,i,a,o,n,r,s,l,d,c,p,h,u,g,m,v,f,x;return __generator(this,(function(w){switch(w.label){case 0:t=e.target.getAttribute("pageNumber");i=this.cachedPageInfo[t],a=i.naturalWidth,o=a===void 0?612:a,n=i.naturalHeight,r=n===void 0?792:n,s=i.renderedHeight,l=s===void 0?792:s;console.log("[FIELDS] Drag ended",t,e.target);d=e.target.getBoundingClientRect();c=e.target.parentElement;p=c.getBoundingClientRect();h=Math.max(d.left-p.left,0);u=Math.max(l-(p.bottom-d.bottom),0);g=this.viewCoordinatesToPageCoordinates(h,u,t,o-e.rect.width,r-e.rect.height),m=g.x,v=g.y;f=e.target.getAttribute("name");x=state.fields.find((function(e){return e.name===f}));if(!x)return[3,2];x.setting.x=m;x.setting.y=v;return[4,updateField(this.endpoint,this.templateId,f,x)];case 1:w.sent();this.handlePageRendered({detail:this.cachedPageInfo[t]});w.label=2;case 2:return[2]}}))}))};e.prototype.generateFieldName=function(e,t){var i;var a=(i=state.template.pages)===null||i===void 0?void 0:i[t-1];var o=(a===null||a===void 0?void 0:a.fields)||[];return"".concat(e,"P").concat(t,"-").concat(o.length)};e.prototype.viewCoordinatesToPageCoordinates=function(e,t,i,a,o){var n=this.cachedPageInfo[i],r=n.xScale,s=r===void 0?1:r,l=n.yScale,d=l===void 0?1:l,c=n.renderedHeight,p=c===void 0?792:c;var h=Math.floor(Math.min(e/s,a));var u=Math.floor(Math.min(Math.max(p-t,0)/d,o));return{x:h,y:u}};e.prototype.handleClickPage=function(e,t){return __awaiter(this,void 0,void 0,(function(){var i,a,o,n,r,s,l,d,c,p,h,u,g,m,v;return __generator(this,(function(f){switch(f.label){case 0:if(!this.placing)return[3,2];i=t.sequence;a=e.offsetX;o=e.offsetY;n=defaultWidth(this.placing);r=defaultHeight(this.placing);s=this.cachedPageInfo[i],l=s.naturalWidth,d=l===void 0?612:l,c=s.naturalHeight,p=c===void 0?792:c;h=this.viewCoordinatesToPageCoordinates(a,o,i,d-n,p-r),u=h.x,g=h.y;m={name:this.generateFieldName(this.placing,i),role_name:this.selectedRoleName,template_id:this.templateId,type:this.placing,required:true,page_sequence:i,validator:null,setting:{width:n,height:r,x:u,y:g,result:""}};return[4,createField(this.endpoint,this.templateId,m)];case 1:v=f.sent();console.log("Saved field",v);state.fields.push(v);this.placing=null;this.handlePageRendered({detail:this.cachedPageInfo[i]});f.label=2;case 2:return[2]}}))}))};e.prototype.render=function(){var e;var t=this;console.log("rendering",state.updateCount);if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(state.loading||!state.template){return h(Host,null,h("verdocs-loader",null))}var i=__spreadArray([],state.template.pages,true);i.sort((function(e,t){return e.sequence-t.sequence}));return h(Host,{class:this.placing?(e={},e["placing-".concat(this.placing)]=true,e):{},"data-updated":state.updateCount,onSubmit:function(){console.log("onSubmit")}},h("div",{class:"pages"},i.map((function(e){return h("verdocs-document-page",{pageImageUri:e.display_uri,virtualWidth:612,virtualHeight:792,onClick:function(i){return t.handleClickPage(i,e)},pageNumber:e.sequence,onPageRendered:function(e){return t.handlePageRendered(e)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})}))),h("verdocs-floating-menu",{options:menuOptions,onOptionSelected:function(e){t.placing=e.detail.id}}))};return e}();VerdocsTemplateFields.style=verdocsTemplateFieldsCss;export{VerdocsTemplateCreate as verdocs_template_create,VerdocsTemplateFields as verdocs_template_fields};
1
+ var __awaiter=this&&this.__awaiter||function(e,t,a,i){function o(e){return e instanceof a?e:new a((function(t){t(e)}))}return new(a||(a=Promise))((function(a,n){function r(e){try{l(i.next(e))}catch(e){n(e)}}function s(e){try{l(i["throw"](e))}catch(e){n(e)}}function l(e){e.done?a(e.value):o(e.value).then(r,s)}l((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var a={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,o,n,r;return r={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function s(e){return function(t){return l([e,t])}}function l(r){if(i)throw new TypeError("Generator is already executing.");while(a)try{if(i=1,o&&(n=r[0]&2?o["return"]:r[0]?o["throw"]||((n=o["return"])&&n.call(o),0):o.next)&&!(n=n.call(o,r[1])).done)return n;if(o=0,n)r=[r[0]&2,n.value];switch(r[0]){case 0:case 1:n=r;break;case 4:a.label++;return{value:r[1],done:false};case 5:a.label++;o=r[1];r=[0];continue;case 7:r=a.ops.pop();a.trys.pop();continue;default:if(!(n=a.trys,n=n.length>0&&n[n.length-1])&&(r[0]===6||r[0]===2)){a=0;continue}if(r[0]===3&&(!n||r[1]>n[0]&&r[1]<n[3])){a.label=r[1];break}if(r[0]===6&&a.label<n[1]){a.label=n[1];n=r;break}if(n&&a.label<n[2]){a.label=n[2];a.ops.push(r);break}if(n[2])a.ops.pop();a.trys.pop();continue}r=t.call(e,a)}catch(e){r=[6,e];o=0}finally{i=n=0}if(r[0]&5)throw r[1];return{value:r[0]?r[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,a){if(a||arguments.length===2)for(var i=0,o=t.length,n;i<o;i++){if(n||!(i in t)){if(!n)n=Array.prototype.slice.call(t,0,i);n[i]=t[i]}}return e.concat(n||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host}from"./index-f78d163d.js";import{c as createTemplate,g as getTemplate}from"./Templates-8e4ab976.js";import{V as VerdocsEndpoint}from"./VerdocsEndpoint-7f17b088.js";import{S as SDKError}from"./errors-9b5498c8.js";import{i as interact}from"./interact.min-32c1c1e4.js";import{u as updateField,c as createField}from"./Fields-c82e6df3.js";import{a as getRoleIndex,r as renderDocumentField,c as updateCssTransform,d as defaultWidth,e as defaultHeight}from"./utils-274e2e93.js";import{s as state}from"./templateStore-fd4beaae.js";import{l as loadTemplate}from"./Templates-7595bdbf.js";import"./Token-54690789.js";import"./Envelopes-130fd6ea.js";import"./Files-70a192df.js";import"./index-fd7b8a34.js";import"./Primitives-054bc6e5.js";var createTemplateDocument=function(e,t,a,i){var o=new FormData;o.append("document",a,a.name);return e.api.post("/templates/".concat(t,"/documents"),o,{timeout:1e4,onUploadProgress:function(e){var t=e.total||1;var a=e.loaded||0;i===null||i===void 0?void 0:i(Math.floor(a*100/(t||1)),a,t||1)}}).then((function(e){return e.data}))};var verdocsTemplateCreateCss='verdocs-template-create{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-create form{background-color:#ffffff;padding:12px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;width:340px}verdocs-template-create form .upload-box{max-width:320px;text-align:center;padding:44px 18px 66px;border:2px dashed #979797;color:rgba(0, 0, 0, 0.54)}verdocs-template-create form .upload-box svg{width:64px;fill:#5c6575}verdocs-template-create .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-create .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-create ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-create ::-moz-placeholder{color:#aaaaaa}verdocs-template-create :-ms-input-placeholder{color:#aaaaaa}verdocs-template-create ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-create ::placeholder{color:#aaaaaa}';var unicodeNBSP=" ";var FileIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"><path d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"></path></svg>';var VerdocsTemplateCreate=function(){function e(e){registerInstance(this,e);this.cancel=createEvent(this,"cancel",7);this.next=createEvent(this,"next",7);this.sdkError=createEvent(this,"sdkError",7);this.endpoint=VerdocsEndpoint.getDefault();this.file=undefined;this.creating=false}e.prototype.componentWillLoad=function(){this.endpoint.setTimeout(3e4);this.endpoint.loadSession()};e.prototype.handleFileChanged=function(e){var t;console.log("files",e.target.files);this.file=((t=e.target.files)===null||t===void 0?void 0:t[0])||null;console.log("Selected file",this.file)};e.prototype.handleUpload=function(e){e.stopPropagation();var t=document.getElementById("verdocs-template-create-file");t.click()};e.prototype.handleCancel=function(e){var t;e.stopPropagation();(t=this.cancel)===null||t===void 0?void 0:t.emit()};e.prototype.handleSubmit=function(e){return __awaiter(this,void 0,void 0,(function(){var t,a,i,o,n,r,s,l;return __generator(this,(function(d){switch(d.label){case 0:e.stopPropagation();if(!this.file){return[2]}d.label=1;case 1:d.trys.push([1,5,,6]);return[4,createTemplate(this.endpoint,{name:this.file.name})];case 2:n=d.sent();console.log("created template",n);return[4,createTemplateDocument(this.endpoint,n.id,this.file)];case 3:r=d.sent();console.log("created document",r);return[4,getTemplate(this.endpoint,n.id)];case 4:s=d.sent();console.log("[CREATE] Created template",s);(t=this.next)===null||t===void 0?void 0:t.emit(s);return[3,6];case 5:l=d.sent();console.log("[TEMPLATE-CREATE] Error creating template",l);(a=this.sdkError)===null||a===void 0?void 0:a.emit(new SDKError(l.message,(i=l.response)===null||i===void 0?void 0:i.status,(o=l.response)===null||o===void 0?void 0:o.data));return[3,6];case 6:return[2]}}))}))};e.prototype.render=function(){var e=this;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}return h("form",{onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off"},h("input",{type:"file",id:"verdocs-template-create-file",multiple:true,accept:"application/pdf",style:{display:"none"},onChange:function(t){return e.handleFileChanged(t)}}),h("div",{class:"upload-box"},h("div",null,h("span",{innerHTML:FileIcon})),h("div",{style:{marginTop:"20px",fontSize:"20px",fontWeight:"bold"}},this.file?this.file.name:"Drag a file here"),h("div",{style:{marginTop:"20px",marginBottom:"20px",fontSize:"16px",height:"20px"}},this.file?unicodeNBSP:"Or, if you prefer..."),h("verdocs-button",{label:this.file?"Select a different file":"Select a file from your computer",size:"small",onClick:function(t){return e.handleUpload(t)}})),h("div",{class:"buttons"},h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(t){return e.handleCancel(t)}}),h("verdocs-button",{label:"Next",size:"small",onClick:function(t){return e.handleSubmit(t)},disabled:!this.file})))};return e}();VerdocsTemplateCreate.style=verdocsTemplateCreateCss;var verdocsTemplateFieldsCss="verdocs-template-fields{font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif;position:relative}verdocs-template-fields .page-0{padding:65px 15px 0 15px;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-fields .page-0 .user-placed-fields{height:100px;position:relative;background:#ffffff;-webkit-box-shadow:0 0 10px 5px #0000000f;box-shadow:0 0 10px 5px #0000000f}verdocs-template-fields .page-0 .user-placed-fields .title{top:0;left:0;color:#ffffff;font-size:12px;padding:3px 6px;font-weight:bold;position:absolute;background:#46497d}verdocs-template-fields .pages{display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;position:relative;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-template-fields .pages div,verdocs-template-fields .pages canvas{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-fields.placing-attachment{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-checkbox{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-date{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-dropdown{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-initial{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-payment{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-radio{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M12 17q2.075 0 3.538-1.463Q17 14.075 17 12t-1.462-3.538Q14.075 7 12 7 9.925 7 8.463 8.462 7 9.925 7 12q0 2.075 1.463 3.537Q9.925 17 12 17Zm0 5.85q-2.275 0-4.25-.85t-3.438-2.312Q2.85 18.225 2 16.25q-.85-1.975-.85-4.25T2 7.75q.85-1.975 2.312-3.438Q5.775 2.85 7.75 2q1.975-.85 4.25-.85t4.25.85q1.975.85 3.438 2.312Q21.15 5.775 22 7.75q.85 1.975.85 4.25T22 16.25q-.85 1.975-2.312 3.438Q18.225 21.15 16.25 22q-1.975.85-4.25.85Zm0-3.15q3.25 0 5.475-2.225Q19.7 15.25 19.7 12q0-3.25-2.225-5.475Q15.25 4.3 12 4.3q-3.25 0-5.475 2.225Q4.3 8.75 4.3 12q0 3.25 2.225 5.475Q8.75 19.7 12 19.7Zm0-7.7Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-signature{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-textarea{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M3.225 20.725v-3.15h11.55v3.15Zm0-4.775V12.8h17.55v3.15Zm0-4.75V8.05h17.55v3.15Zm0-4.775v-3.15h17.55v3.15Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-textbox{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M3.425 16.15V13h11.15v3.15Zm0-5.15V7.85h17.15V11Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-timestamp{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}";var iconSingleline='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M3.425 16.15V13h11.15v3.15Zm0-5.15V7.85h17.15V11Z"/></svg>';var iconMultiline='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M3.225 20.725v-3.15h11.55v3.15Zm0-4.775V12.8h17.55v3.15Zm0-4.75V8.05h17.55v3.15Zm0-4.775v-3.15h17.55v3.15Z"/></svg>';var iconCheck='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z"/></svg>';var iconRadio='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M12 17q2.075 0 3.538-1.463Q17 14.075 17 12t-1.462-3.538Q14.075 7 12 7 9.925 7 8.463 8.462 7 9.925 7 12q0 2.075 1.463 3.537Q9.925 17 12 17Zm0 5.85q-2.275 0-4.25-.85t-3.438-2.312Q2.85 18.225 2 16.25q-.85-1.975-.85-4.25T2 7.75q.85-1.975 2.312-3.438Q5.775 2.85 7.75 2q1.975-.85 4.25-.85t4.25.85q1.975.85 3.438 2.312Q21.15 5.775 22 7.75q.85 1.975.85 4.25T22 16.25q-.85 1.975-2.312 3.438Q18.225 21.15 16.25 22q-1.975.85-4.25.85Zm0-3.15q3.25 0 5.475-2.225Q19.7 15.25 19.7 12q0-3.25-2.225-5.475Q15.25 4.3 12 4.3q-3.25 0-5.475 2.225Q4.3 8.75 4.3 12q0 3.25 2.225 5.475Q8.75 19.7 12 19.7Zm0-7.7Z"/></svg>';var iconDatepicker='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M7.6 13.925q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375ZM5.3 22.85q-1.325 0-2.238-.912-.912-.913-.912-2.238V6.3q0-1.325.912-2.238.913-.912 2.238-.912H6v-2h2.575v2h6.85v-2H18v2h.7q1.325 0 2.238.912.912.913.912 2.238v13.4q0 1.325-.912 2.238-.913.912-2.238.912Zm0-3.15h13.4V10H5.3v9.7ZM5.3 8h13.4V6.3H5.3Zm0 0V6.3 8Z"/></svg>';var iconSignature='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>';var iconInitial='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z"/></svg>';var menuOptions=[{id:"attachment",tooltip:"Attachment",icon:"A"},{id:"checkbox",tooltip:"Check Box",icon:iconCheck},{id:"date",tooltip:"Date",icon:iconDatepicker},{id:"dropdown",tooltip:"Dropdown",icon:"O"},{id:"initial",tooltip:"Initials",icon:iconInitial},{id:"payment",tooltip:"Payment",icon:"P"},{id:"radio",tooltip:"Radio Button",icon:iconRadio},{id:"signature",tooltip:"Signature",icon:iconSignature},{id:"textarea",tooltip:"Text Area",icon:iconMultiline},{id:"textbox",tooltip:"Text Box",icon:iconSingleline},{id:"timestamp",tooltip:"Timestamp",icon:"X"}];var VerdocsTemplateFields=function(){function e(e){registerInstance(this,e);this.next=createEvent(this,"next",7);this.cancel=createEvent(this,"cancel",7);this.sdkError=createEvent(this,"sdkError",7);this.pageHeights={};this.cachedPageInfo={};this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.placing=null;this.selectedRoleName=""}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,a,i,o,n,r,s;return __generator(this,(function(l){switch(l.label){case 0:l.trys.push([0,5,,6]);this.endpoint.loadSession();if(!this.templateId){console.log("[FIELDS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[BUILD] Unable to start builder session, must be authenticated");return[2]}l.label=1;case 1:l.trys.push([1,3,,4]);console.log("[FIELDS] Loading template ".concat(this.templateId),this.endpoint.session);return[4,loadTemplate(this.endpoint,this.templateId)];case 2:l.sent();this.selectedRoleName=state.roleNames[0];console.log("Starting with role",this.selectedRoleName);return[3,4];case 3:r=l.sent();console.log("[FIELDS] Error loading template",r);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(r.message,(t=r.response)===null||t===void 0?void 0:t.status,(a=r.response)===null||a===void 0?void 0:a.data));return[3,4];case 4:return[3,6];case 5:s=l.sent();console.log("[FIELDS] Error with preview session",s);(i=this.sdkError)===null||i===void 0?void 0:i.emit(new SDKError(s.message,(o=s.response)===null||o===void 0?void 0:o.status,(n=s.response)===null||n===void 0?void 0:n.data));return[3,6];case 6:return[2]}}))}))};e.prototype.componentDidRender=function(){interact.dynamicDrop(true)};e.prototype.handleFieldChange=function(e,t,a){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){console.log("[FIELDS] handleFieldChange",e,t,a);return[2]}))}))};e.prototype.attachFieldAttributes=function(e,t,a,i){var o=this;i.addEventListener("input",(function(e){return o.handleFieldChange(t,e)}));i.addEventListener("settingsChanged",(function(){i.setAttribute("roleindex",getRoleIndex(state.roleNames,t.role_name))}));i.setAttribute("roleindex",a);i.setAttribute("pageNumber",e.pageNumber);i.setAttribute("xScale",e.xScale);i.setAttribute("yScale",e.yScale);i.setAttribute("name",t.name)};e.prototype.handlePageRendered=function(e){var t=this;var a=e.detail;console.log("[FIELDS] Page rendered",a);this.cachedPageInfo[a.pageNumber]=a;this.pageHeights[a.pageNumber]=a.naturalHeight;var i=state.fields.filter((function(e){return e.page_sequence===a.pageNumber}));console.log("[FIELDS] Fields on page",i);i.forEach((function(e){var i=getRoleIndex(state.roleNames,e.role_name);var o=renderDocumentField(e,a,i,{disabled:true,editable:true,draggable:true});if(!o){return}if(Array.isArray(o)){o.map((function(o){return t.attachFieldAttributes(a,e,i,o)}))}else{t.attachFieldAttributes(a,e,i,o)}interact(o).draggable({listeners:{start:function(e){console.log("[FIELDS] Drag started",e.type,e.target)},move:function(e){var t=+(e.target.getAttribute("posX")||0);var a=+(e.target.getAttribute("posY")||0);var i=+(e.target.getAttribute("xScale")||1);var o=+(e.target.getAttribute("yScale")||1);var n=e.dx/i+t;var r=e.dy/o+a;e.target.setAttribute("posX",n);e.target.setAttribute("posy",r);updateCssTransform(e.target,"translate","".concat(n,"px, ").concat(r,"px"))},end:t.handleMoveField.bind(t)}})}))};e.prototype.handleMoveField=function(e){return __awaiter(this,void 0,void 0,(function(){var t,a,i,o,n,r,s,l,d,c,p,h,u,g,m,v,f,x;return __generator(this,(function(w){switch(w.label){case 0:t=e.target.getAttribute("pageNumber");a=this.cachedPageInfo[t],i=a.naturalWidth,o=i===void 0?612:i,n=a.naturalHeight,r=n===void 0?792:n,s=a.renderedHeight,l=s===void 0?792:s;console.log("[FIELDS] Drag ended",t,e.target);d=e.target.getBoundingClientRect();c=e.target.parentElement;p=c.getBoundingClientRect();h=Math.max(d.left-p.left,0);u=Math.max(l-(p.bottom-d.bottom),0);g=this.viewCoordinatesToPageCoordinates(h,u,t,o-e.rect.width,r-e.rect.height),m=g.x,v=g.y;f=e.target.getAttribute("name");x=state.fields.find((function(e){return e.name===f}));if(!x)return[3,2];x.setting.x=m;x.setting.y=v;return[4,updateField(this.endpoint,this.templateId,f,x)];case 1:w.sent();this.handlePageRendered({detail:this.cachedPageInfo[t]});w.label=2;case 2:return[2]}}))}))};e.prototype.generateFieldName=function(e,t){var a;var i=(a=state.template.pages)===null||a===void 0?void 0:a[t-1];var o=(i===null||i===void 0?void 0:i.fields)||[];return"".concat(e,"P").concat(t,"-").concat(o.length)};e.prototype.viewCoordinatesToPageCoordinates=function(e,t,a,i,o){var n=this.cachedPageInfo[a],r=n.xScale,s=r===void 0?1:r,l=n.yScale,d=l===void 0?1:l,c=n.renderedHeight,p=c===void 0?792:c;var h=Math.floor(Math.min(e/s,i));var u=Math.floor(Math.min(Math.max(p-t,0)/d,o));return{x:h,y:u}};e.prototype.handleClickPage=function(e,t){return __awaiter(this,void 0,void 0,(function(){var a,i,o,n,r,s,l,d,c,p,h,u,g,m,v;return __generator(this,(function(f){switch(f.label){case 0:if(!this.placing)return[3,2];a=t.sequence;i=e.offsetX;o=e.offsetY;n=defaultWidth(this.placing);r=defaultHeight(this.placing);s=this.cachedPageInfo[a],l=s.naturalWidth,d=l===void 0?612:l,c=s.naturalHeight,p=c===void 0?792:c;h=this.viewCoordinatesToPageCoordinates(i,o,a,d-n,p-r),u=h.x,g=h.y;m={name:this.generateFieldName(this.placing,a),role_name:this.selectedRoleName,template_id:this.templateId,type:this.placing,required:true,page_sequence:a,validator:null,setting:{x:u,y:g}};switch(m.type){case"attachment":case"payment":m.setting={x:u,y:g};break;case"initial":case"signature":m.setting={x:u,y:g,result:""};break;case"checkbox_group":m.setting={x:u,y:g,minimum_checked:0,maximum_checked:1e3};break;case"date":m.setting={x:u,y:g,width:n,height:r,result:""};break;case"dropdown":m.setting={x:u,y:g,width:n,height:r,value:"",placeholder:"Select a value"};break;case"radio_button_group":m.setting={x:u,y:g};break;case"textbox":m.setting={x:u,y:g,width:n,height:r,result:"",leading:0,alignment:0,upperCase:false};break;case"timestamp":m.setting={x:u,y:g,width:n,height:r};break}return[4,createField(this.endpoint,this.templateId,m)];case 1:v=f.sent();console.log("Saved field",v);state.fields.push(v);this.placing=null;this.handlePageRendered({detail:this.cachedPageInfo[a]});f.label=2;case 2:return[2]}}))}))};e.prototype.render=function(){var e;var t=this;console.log("rendering",state.updateCount);if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(state.loading||!state.template){return h(Host,null,h("verdocs-loader",null))}var a=__spreadArray([],state.template.pages,true);a.sort((function(e,t){return e.sequence-t.sequence}));return h(Host,{class:this.placing?(e={},e["placing-".concat(this.placing)]=true,e):{},"data-updated":state.updateCount,onSubmit:function(){console.log("onSubmit")}},h("div",{class:"pages"},a.map((function(e){return h("verdocs-document-page",{pageImageUri:e.display_uri,virtualWidth:612,virtualHeight:792,onClick:function(a){return t.handleClickPage(a,e)},pageNumber:e.sequence,onPageRendered:function(e){return t.handlePageRendered(e)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})}))),h("verdocs-floating-menu",{options:menuOptions,onOptionSelected:function(e){t.placing=e.detail.id}}))};return e}();VerdocsTemplateFields.style=verdocsTemplateFieldsCss;export{VerdocsTemplateCreate as verdocs_template_create,VerdocsTemplateFields as verdocs_template_fields};
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,s){function i(e){try{l(o.next(e))}catch(e){s(e)}}function a(e){try{l(o["throw"](e))}catch(e){s(e)}}function l(e){e.done?r(e.value):n(e.value).then(i,a)}l((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},o,n,s,i;return i={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return l([e,t])}}function l(i){if(o)throw new TypeError("Generator is already executing.");while(r)try{if(o=1,n&&(s=i[0]&2?n["return"]:i[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,i[1])).done)return s;if(n=0,s)i=[i[0]&2,s.value];switch(i[0]){case 0:case 1:s=i;break;case 4:r.label++;return{value:i[1],done:false};case 5:r.label++;n=i[1];i=[0];continue;case 7:i=r.ops.pop();r.trys.pop();continue;default:if(!(s=r.trys,s=s.length>0&&s[s.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!s||i[1]>s[0]&&i[1]<s[3])){r.label=i[1];break}if(i[0]===6&&r.label<s[1]){r.label=s[1];s=i;break}if(s&&r.label<s[2]){r.label=s[2];r.ops.push(i);break}if(s[2])r.ops.pop();r.trys.pop();continue}i=t.call(e,r)}catch(e){i=[6,e];n=0}finally{o=s=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};var _g;import{r as registerInstance,c as createEvent,h,F as Fragment,H as Host,a as getElement}from"./index-f78d163d.js";import{i as interact}from"./interact.min-32c1c1e4.js";import{u as updateRole,c as createRole}from"./Roles-2488d047.js";import{V as VerdocsEndpoint,T as TemplateSenderTypes}from"./VerdocsEndpoint-7f17b088.js";import{g as getRGBA}from"./Colors-1b298092.js";import{s as state}from"./templateStore-fd4beaae.js";import{l as loadTemplate}from"./Templates-7595bdbf.js";import{a as getRoleIndex}from"./utils-274e2e93.js";import{S as SDKError}from"./errors-9b5498c8.js";import"./Token-54690789.js";import"./index-fd7b8a34.js";import"./Primitives-054bc6e5.js";import"./Templates-8e4ab976.js";import"./Envelopes-130fd6ea.js";import"./Files-70a192df.js";var verdocsTemplateRecipientsCss='verdocs-template-recipients{display:block;min-width:400px;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-recipients>form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;padding:12px}verdocs-template-recipients>form h5{font-size:16px;font-weight:bold;color:#4c56cb;margin:0 0 10px 0}verdocs-template-recipients>form .participants{position:relative}verdocs-template-recipients>form .left-line{top:32px;left:11px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-template-recipients>form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:0;-moz-column-gap:0;column-gap:0;margin-left:40px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:6px 0 4px 0}verdocs-template-recipients>form .row .row-recipients{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;-ms-flex-direction:row;flex-direction:row}verdocs-template-recipients>form .row .icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-template-recipients>form .row .sender{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 5px 0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;border:1px solid #c6c9cc;background-color:#f5f5fa}verdocs-template-recipients>form .row .complete{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;background-color:#f5f5fa;border:1px solid #aeb4bf}verdocs-template-recipients>form .row .label{font-weight:bold;margin-right:6px;color:#33364b}verdocs-template-recipients>form .row .settings-button{margin:4px 0 0 9px;cursor:pointer}verdocs-template-recipients>form .row .recipient{height:30px;display:-ms-flexbox;display:flex;font-size:14px;line-height:30px;border-radius:30px;-ms-flex-direction:row;flex-direction:row;padding:0 5px 0 6px;white-space:nowrap;border:1px solid #aeb4bf}verdocs-template-recipients>form .row .recipient .type-icon{width:24px;height:24px;-webkit-transform:scale(0.8);transform:scale(0.8);opacity:0.6;margin:4px 12px 0 0}verdocs-template-recipients>form .row .recipient.dragging{position:absolute}verdocs-template-recipients>form .row .recipient.dragging+.dropzone{display:none !important}verdocs-template-recipients>form .row .dropzone{width:14px;height:30px;display:none}verdocs-template-recipients>form .row .dropzone svg{fill:#cccccc}verdocs-template-recipients>form .row .dropzone.visible{margin:0 7px;display:-ms-flexbox;display:flex;-ms-flex:0 0 14px;flex:0 0 14px}verdocs-template-recipients>form .row .dropzone.active{-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;background:#654dcb7f;border:1px dashed #654dcb}verdocs-template-recipients>form label{display:block;font-size:14px;font-weight:500;margin:0 0 4px 0;color:#5c6575}verdocs-template-recipients>form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-recipients>form input:focus{outline:none}verdocs-template-recipients .row.add-sequence{display:none}verdocs-template-recipients .add-role{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-recipients .add-role:hover{opacity:1}verdocs-template-recipients .add-role svg{width:32px;height:32px}verdocs-template-recipients.dragging .add-role{display:none}verdocs-template-recipients.dragging form .row .recipient+.dropzone{display:-ms-flexbox;display:flex}verdocs-template-recipients.dragging .row.add-sequence{display:-ms-flexbox;display:flex}verdocs-template-recipients.dragging .row.add-sequence .dropzone{opacity:0.5;-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;-ms-flex-align:center;align-items:center;background:#654dcb7f;-ms-flex-pack:center;justify-content:center;border:1px dashed #654dcb}verdocs-template-recipients.dragging .row.add-sequence .dropzone.active{opacity:1}verdocs-template-recipients .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-direction:row;flex-direction:row}verdocs-template-recipients ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::-moz-placeholder{color:#aaaaaa}verdocs-template-recipients :-ms-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::placeholder{color:#aaaaaa}';var senderLabels=(_g={},_g[TemplateSenderTypes.EVERYONE]="Everyone",_g[TemplateSenderTypes.EVERYONE_AS_CREATOR]="Everyone as Me",_g[TemplateSenderTypes.ORGANIZATION_MEMBER]="Organization member",_g[TemplateSenderTypes.ORGANIZATION_MEMBER_AS_CREATOR]="Organization Member as Me",_g[TemplateSenderTypes.CREATOR]="Me",_g);var settingsIcon='<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20" fill="#00000089"><path d="m8.021 17.917-.313-2.5q-.27-.125-.625-.334-.354-.208-.625-.395l-2.312.979-1.979-3.438 1.979-1.5q-.021-.167-.031-.364-.011-.198-.011-.365 0-.146.011-.344.01-.198.031-.385l-1.979-1.5 1.979-3.417 2.312.958q.271-.187.615-.385t.635-.344l.313-2.5h3.958l.313 2.5q.312.167.625.344.312.177.604.385l2.333-.958 1.979 3.417-1.979 1.521q.021.187.021.364V10q0 .146-.01.333-.011.188-.011.396l1.958 1.5-1.979 3.438-2.312-.979q-.292.208-.615.395-.323.188-.614.334l-.313 2.5Zm1.937-5.355q1.063 0 1.813-.75t.75-1.812q0-1.062-.75-1.812t-1.813-.75q-1.041 0-1.802.75-.76.75-.76 1.812t.76 1.812q.761.75 1.802.75Zm0-1.333q-.5 0-.864-.364-.365-.365-.365-.865t.365-.865q.364-.364.864-.364t.865.364q.365.365.365.865t-.365.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.187q.605-.167 1.136-.49.531-.323 1.031-.802l2.021.875.854-1.375-1.792-1.354q.105-.333.136-.635.031-.303.031-.615 0-.292-.031-.573-.031-.281-.115-.635l1.792-1.396-.834-1.375-2.062.875q-.438-.438-1.021-.781-.583-.344-1.125-.49l-.271-2.208H9.167l-.271 2.208q-.584.146-1.125.458-.542.313-1.042.792l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.479.458 1.021.771.542.312 1.146.479Z"/></svg>';var startIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z"></path></svg>';var stepIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></svg>';var doneIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="m18 7-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41 6 19l1.41-1.41L1.83 12 .41 13.41z"></path></svg>';var plusIcon='<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>';var iconSigner='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>';var iconApprover='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z" clip-rule="evenodd" /></svg>';var iconCC='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M1.5 8.67v8.58a3 3 0 003 3h15a3 3 0 003-3V8.67l-8.928 5.493a3 3 0 01-3.144 0L1.5 8.67z" /><path d="M22.5 6.908V6.75a3 3 0 00-3-3h-15a3 3 0 00-3 3v.158l9.714 5.978a1.5 1.5 0 001.572 0L22.5 6.908z" /></svg>';var VerdocsTemplateRecipients=function(){function e(e){registerInstance(this,e);this.cancel=createEvent(this,"cancel",7);this.sdkError=createEvent(this,"sdkError",7);this.sequences=[];this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.showingRoleDialog=null;this.showingSenderDialog=false;this.sender=null;this.forceRerender=1}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,r,o,n,s,i,a;return __generator(this,(function(l){switch(l.label){case 0:l.trys.push([0,5,,6]);this.endpoint.loadSession();if(!this.templateId){console.log("[RECIPIENTS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[RECIPIENTS] Unable to start builder session, must be authenticated");return[2]}l.label=1;case 1:l.trys.push([1,3,,4]);console.log("[RECIPIENTS] Loading template ".concat(this.templateId),this.endpoint.session);return[4,loadTemplate(this.endpoint,this.templateId)];case 2:l.sent();return[3,4];case 3:i=l.sent();console.log("[RECIPIENTS] Error loading template",i);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(i.message,(t=i.response)===null||t===void 0?void 0:t.status,(r=i.response)===null||r===void 0?void 0:r.data));return[3,4];case 4:this.sortTemplateRoles();this.renumberTemplateRoles();return[3,6];case 5:a=l.sent();console.log("[FIELDS] Error with preview session",a);(o=this.sdkError)===null||o===void 0?void 0:o.emit(new SDKError(a.message,(n=a.response)===null||n===void 0?void 0:n.status,(s=a.response)===null||s===void 0?void 0:s.data));return[3,6];case 6:return[2]}}))}))};e.prototype.componentDidRender=function(){interact.dynamicDrop(true);interact(".recipient").draggable({listeners:{start:function e(t){t.target.classList.add("dragging");this.el.classList.add("dragging")}.bind(this),move:function e(t){var r=+(t.target.getAttribute("posX")||0);var o=+(t.target.getAttribute("posY")||0);var n=t.dx+r;var s=t.dy+o;t.target.setAttribute("posX",n);t.target.setAttribute("posy",s);t.target.style.transform="translate(".concat(n+100,"px, ").concat(s-40,"px)")}.bind(this),end:function e(t){t.target.classList.remove("dragging");this.el.classList.remove("dragging");t.target.setAttribute("posX",0);t.target.setAttribute("posy",0);t.target.style.transform="translate(0px, 0px)"}.bind(this)}});interact(".dropzone").dropzone({overlap:.05,ondrop:function e(t){var r=this;t.target.classList.remove("active");var o=t.relatedTarget.dataset.rolename;var n=+t.target.dataset.sequence;var s=+t.target.dataset.order;var i=state.template.roles.find((function(e){return e.name===o}));if(i){i.sequence=n;i.order=s;this.sortTemplateRoles();this.renumberTemplateRoles();this.forceRerender++;Promise.all(state.template.roles.map((function(e){return updateRole(r.endpoint,r.templateId,e.name,{sequence:e.sequence,order:e.order})}))).then((function(){return console.log("[RECIPIENTS] Updated roles")})).catch((function(e){return console.log("[RECIPIENTS] Role updates failed",e)}))}}.bind(this),ondropactivate:function(e){e.target.classList.add("visible")},ondropdeactivate:function(e){e.target.classList.remove("visible")},ondragenter:function(e){e.target.classList.add("active")},ondragleave:function(e){e.target.classList.remove("active")}})};e.prototype.handleCancel=function(e){var t;e.stopPropagation();(t=this.cancel)===null||t===void 0?void 0:t.emit()};e.prototype.handleSubmit=function(e){e.stopPropagation()};e.prototype.sortTemplateRoles=function(){state.template.roles.sort((function(e,t){return e.sequence===t.sequence?e.order-t.order:e.sequence-t.sequence}))};e.prototype.extractSequenceNumbers=function(){var e=this;this.sequences=[];state.template.roles.forEach((function(t){if(!e.sequences.includes(t.sequence)){e.sequences.push(t.sequence)}}))};e.prototype.renumberTemplateRoles=function(){this.extractSequenceNumbers();var e=[];this.sequences.sort((function(e,t){return e-t}));this.sequences.forEach((function(t,r){state.template.roles.filter((function(e){return e.sequence===t})).forEach((function(t,o){if(!e.includes(t.name)){t.sequence=r+1;t.order=o+1;e.push(t.name)}}))}));this.extractSequenceNumbers()};e.prototype.handleAddRole=function(e,t){var r=this;e.stopPropagation();var o=state.template.roles.filter((function(e){return e.sequence===t})).length+1;var n="";var s=state.template.roles.length;do{s++;n="Recipient ".concat(s)}while(!n||state.template.roles.some((function(e){return e.name===n})));console.log("Will create",n,t,o);createRole(this.endpoint,this.templateId,{template_id:this.templateId,name:n,full_name:"",email:"",phone:"",sequence:t,order:o,type:"signer",delegator:false}).then((function(e){console.log("Created role",e);state.template.roles.push(e);r.renumberTemplateRoles();r.forceRerender++})).catch((function(e){console.log("Error creating role",e)}))};e.prototype.render=function(){var e=this;var t=state.template.roles.map((function(e){return e.name}));return h(Host,null,h("form",{onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off","data-r":this.forceRerender},h("h5",null,"Recipients"),h("div",{class:"participants"},h("div",{class:"left-line"}),h("div",{class:"row"},h("div",{class:"icon",innerHTML:startIcon}),h("div",{class:"row-recipients"},h("div",{class:"sender"},h("span",{class:"label"},"Sender:")," ",senderLabels[state.template.sender]," ",h("div",{class:"settings-button",innerHTML:settingsIcon,onClick:function(){return e.showingSenderDialog=true},"aria-role":"button"})))),h("div",{class:"row add-sequence","data-sequence":0},h("div",{class:"icon",innerHTML:plusIcon}),h("div",{class:"row-recipients"},h("div",{class:"dropzone","data-sequence":0,"data-order":1},"Add Step"))),this.sequences.map((function(r){return h(Fragment,null,h("div",{class:"row"},h("div",{class:"icon",innerHTML:stepIcon}),h("div",{class:"row-recipients"},h("div",{class:"dropzone","data-order":.5,"data-sequence":r}),state.template.roles.filter((function(e){return e.sequence===r})).map((function(o){return h(Fragment,null,h("div",{class:"recipient",style:{backgroundColor:getRGBA(getRoleIndex(t,o.name))},"data-rolename":o.name},h("span",{class:"type-icon",innerHTML:o.type==="signer"?iconSigner:o.type==="cc"?iconCC:iconApprover}),o.name," ",h("div",{class:"settings-button",innerHTML:settingsIcon,onClick:function(){return e.showingRoleDialog=o.name},"aria-role":"button"})),h("div",{class:"dropzone","data-order":o.order+.5,"data-sequence":r}))})),h("button",{class:"add-role",innerHTML:plusIcon,onClick:function(t){return e.handleAddRole(t,r)}}))),h("div",{class:"row add-sequence","data-sequence":r},h("div",{class:"row-recipients"},h("div",{class:"icon",innerHTML:plusIcon}),h("div",{class:"dropzone","data-sequence":r+1,"data-order":1},"Add Step"))))})),h("div",{class:"row"},h("div",{class:"icon",innerHTML:doneIcon}),h("div",{class:"row-recipients"},h("div",{class:"complete"},"Document Complete")))),h("div",{class:"buttons"},h("div",{class:"flex-fill"}),h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(t){return e.handleCancel(t)}}),h("verdocs-button",{label:"OK",size:"small",onClick:function(t){return e.handleSubmit(t)}}))),this.showingRoleDialog&&h("verdocs-template-role-properties",{endpoint:this.endpoint,templateId:this.templateId,roleName:this.showingRoleDialog,onClose:function(){e.showingRoleDialog=null;e.forceRerender++},onDelete:function(t){console.log("deleted",t.detail);e.renumberTemplateRoles();e.showingRoleDialog=null;e.forceRerender++}}),this.showingSenderDialog&&h("verdocs-template-sender",{endpoint:this.endpoint,templateId:this.templateId,onClose:function(){return e.showingSenderDialog=false}}))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();VerdocsTemplateRecipients.style=verdocsTemplateRecipientsCss;export{VerdocsTemplateRecipients as verdocs_template_recipients};
1
+ var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,s){function i(e){try{l(o.next(e))}catch(e){s(e)}}function a(e){try{l(o["throw"](e))}catch(e){s(e)}}function l(e){e.done?r(e.value):n(e.value).then(i,a)}l((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},o,n,s,i;return i={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return l([e,t])}}function l(i){if(o)throw new TypeError("Generator is already executing.");while(r)try{if(o=1,n&&(s=i[0]&2?n["return"]:i[0]?n["throw"]||((s=n["return"])&&s.call(n),0):n.next)&&!(s=s.call(n,i[1])).done)return s;if(n=0,s)i=[i[0]&2,s.value];switch(i[0]){case 0:case 1:s=i;break;case 4:r.label++;return{value:i[1],done:false};case 5:r.label++;n=i[1];i=[0];continue;case 7:i=r.ops.pop();r.trys.pop();continue;default:if(!(s=r.trys,s=s.length>0&&s[s.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!s||i[1]>s[0]&&i[1]<s[3])){r.label=i[1];break}if(i[0]===6&&r.label<s[1]){r.label=s[1];s=i;break}if(s&&r.label<s[2]){r.label=s[2];r.ops.push(i);break}if(s[2])r.ops.pop();r.trys.pop();continue}i=t.call(e,r)}catch(e){i=[6,e];n=0}finally{o=s=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};var _g;import{r as registerInstance,c as createEvent,h,F as Fragment,H as Host,a as getElement}from"./index-f78d163d.js";import{i as interact}from"./interact.min-32c1c1e4.js";import{u as updateRole,c as createRole}from"./Roles-2488d047.js";import{V as VerdocsEndpoint,T as TemplateSenderTypes}from"./VerdocsEndpoint-7f17b088.js";import{g as getRGBA}from"./Colors-1b298092.js";import{s as state}from"./templateStore-fd4beaae.js";import{l as loadTemplate}from"./Templates-7595bdbf.js";import{a as getRoleIndex}from"./utils-274e2e93.js";import{S as SDKError}from"./errors-9b5498c8.js";import"./Token-54690789.js";import"./index-fd7b8a34.js";import"./Primitives-054bc6e5.js";import"./Templates-8e4ab976.js";import"./Envelopes-130fd6ea.js";import"./Files-70a192df.js";var verdocsTemplateRecipientsCss='verdocs-template-recipients{display:block;min-width:400px;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-recipients>form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;padding:12px}verdocs-template-recipients>form h5{font-size:16px;font-weight:bold;color:#4c56cb;margin:0 0 10px 0}verdocs-template-recipients>form .participants{position:relative}verdocs-template-recipients>form .left-line{top:32px;left:11px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-template-recipients>form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:0;-moz-column-gap:0;column-gap:0;margin-left:40px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:6px 0 4px 0}verdocs-template-recipients>form .row .row-recipients{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;-ms-flex-direction:row;flex-direction:row}verdocs-template-recipients>form .row .icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-template-recipients>form .row .sender{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 5px 0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;border:1px solid #c6c9cc;background-color:#f5f5fa}verdocs-template-recipients>form .row .complete{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;background-color:#f5f5fa;border:1px solid #aeb4bf}verdocs-template-recipients>form .row .label{font-weight:bold;margin-right:6px;color:#33364b}verdocs-template-recipients>form .row .settings-button{margin:4px 0 0 9px;cursor:pointer}verdocs-template-recipients>form .row .recipient{height:30px;display:-ms-flexbox;display:flex;font-size:14px;line-height:30px;border-radius:30px;-ms-flex-direction:row;flex-direction:row;padding:0 5px 0 6px;white-space:nowrap;border:1px solid #aeb4bf}verdocs-template-recipients>form .row .recipient .type-icon{width:24px;height:24px;-webkit-transform:scale(0.8);transform:scale(0.8);opacity:0.6;margin:4px 12px 0 0}verdocs-template-recipients>form .row .recipient.dragging{position:absolute}verdocs-template-recipients>form .row .recipient.dragging+.dropzone{display:none !important}verdocs-template-recipients>form .row .dropzone{width:14px;height:30px;display:none}verdocs-template-recipients>form .row .dropzone svg{fill:#cccccc}verdocs-template-recipients>form .row .dropzone.visible{margin:0 7px;display:-ms-flexbox;display:flex;-ms-flex:0 0 14px;flex:0 0 14px}verdocs-template-recipients>form .row .dropzone.active{-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;background:#654dcb7f;border:1px dashed #654dcb}verdocs-template-recipients>form label{display:block;font-size:14px;font-weight:500;margin:0 0 4px 0;color:#5c6575}verdocs-template-recipients>form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-recipients>form input:focus{outline:none}verdocs-template-recipients .row.add-sequence{display:none}verdocs-template-recipients .add-role{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-recipients .add-role:hover{opacity:1}verdocs-template-recipients .add-role svg{width:32px;height:32px}verdocs-template-recipients.dragging .add-role{display:none}verdocs-template-recipients.dragging form .row .recipient+.dropzone{display:-ms-flexbox;display:flex}verdocs-template-recipients.dragging .row.add-sequence{display:-ms-flexbox;display:flex}verdocs-template-recipients.dragging .row.add-sequence .dropzone{opacity:0.5;-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;-ms-flex-align:center;align-items:center;background:#654dcb7f;-ms-flex-pack:center;justify-content:center;border:1px dashed #654dcb}verdocs-template-recipients.dragging .row.add-sequence .dropzone.active{opacity:1}verdocs-template-recipients .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-direction:row;flex-direction:row}verdocs-template-recipients .empty{font-size:13px;margin-top:15px;margin-bottom:5px}verdocs-template-recipients .empty svg{width:20px;height:20px;stroke:#666666;margin-bottom:-5px}verdocs-template-recipients ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::-moz-placeholder{color:#aaaaaa}verdocs-template-recipients :-ms-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::placeholder{color:#aaaaaa}';var senderLabels=(_g={},_g[TemplateSenderTypes.EVERYONE]="Everyone",_g[TemplateSenderTypes.EVERYONE_AS_CREATOR]="Everyone as Me",_g[TemplateSenderTypes.ORGANIZATION_MEMBER]="Organization member",_g[TemplateSenderTypes.ORGANIZATION_MEMBER_AS_CREATOR]="Organization Member as Me",_g[TemplateSenderTypes.CREATOR]="Me",_g);var settingsIcon='<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20" fill="#00000089"><path d="m8.021 17.917-.313-2.5q-.27-.125-.625-.334-.354-.208-.625-.395l-2.312.979-1.979-3.438 1.979-1.5q-.021-.167-.031-.364-.011-.198-.011-.365 0-.146.011-.344.01-.198.031-.385l-1.979-1.5 1.979-3.417 2.312.958q.271-.187.615-.385t.635-.344l.313-2.5h3.958l.313 2.5q.312.167.625.344.312.177.604.385l2.333-.958 1.979 3.417-1.979 1.521q.021.187.021.364V10q0 .146-.01.333-.011.188-.011.396l1.958 1.5-1.979 3.438-2.312-.979q-.292.208-.615.395-.323.188-.614.334l-.313 2.5Zm1.937-5.355q1.063 0 1.813-.75t.75-1.812q0-1.062-.75-1.812t-1.813-.75q-1.041 0-1.802.75-.76.75-.76 1.812t.76 1.812q.761.75 1.802.75Zm0-1.333q-.5 0-.864-.364-.365-.365-.365-.865t.365-.865q.364-.364.864-.364t.865.364q.365.365.365.865t-.365.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.187q.605-.167 1.136-.49.531-.323 1.031-.802l2.021.875.854-1.375-1.792-1.354q.105-.333.136-.635.031-.303.031-.615 0-.292-.031-.573-.031-.281-.115-.635l1.792-1.396-.834-1.375-2.062.875q-.438-.438-1.021-.781-.583-.344-1.125-.49l-.271-2.208H9.167l-.271 2.208q-.584.146-1.125.458-.542.313-1.042.792l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.479.458 1.021.771.542.312 1.146.479Z"/></svg>';var startIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z"></path></svg>';var stepIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></svg>';var doneIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="m18 7-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41 6 19l1.41-1.41L1.83 12 .41 13.41z"></path></svg>';var plusIcon='<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>';var iconSigner='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>';var iconApprover='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z" clip-rule="evenodd" /></svg>';var iconCC='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M1.5 8.67v8.58a3 3 0 003 3h15a3 3 0 003-3V8.67l-8.928 5.493a3 3 0 01-3.144 0L1.5 8.67z" /><path d="M22.5 6.908V6.75a3 3 0 00-3-3h-15a3 3 0 00-3 3v.158l9.714 5.978a1.5 1.5 0 001.572 0L22.5 6.908z" /></svg>';var VerdocsTemplateRecipients=function(){function e(e){registerInstance(this,e);this.next=createEvent(this,"next",7);this.cancel=createEvent(this,"cancel",7);this.sdkError=createEvent(this,"sdkError",7);this.sequences=[];this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.showingRoleDialog=null;this.showingSenderDialog=false;this.sender=null;this.forceRerender=1}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,r,o,n,s,i,a;return __generator(this,(function(l){switch(l.label){case 0:l.trys.push([0,5,,6]);this.endpoint.loadSession();if(!this.templateId){console.log("[RECIPIENTS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[RECIPIENTS] Unable to start builder session, must be authenticated");return[2]}l.label=1;case 1:l.trys.push([1,3,,4]);console.log("[RECIPIENTS] Loading template ".concat(this.templateId),this.endpoint.session);return[4,loadTemplate(this.endpoint,this.templateId)];case 2:l.sent();return[3,4];case 3:i=l.sent();console.log("[RECIPIENTS] Error loading template",i);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(i.message,(t=i.response)===null||t===void 0?void 0:t.status,(r=i.response)===null||r===void 0?void 0:r.data));return[3,4];case 4:this.sortTemplateRoles();this.renumberTemplateRoles();return[3,6];case 5:a=l.sent();console.log("[FIELDS] Error with preview session",a);(o=this.sdkError)===null||o===void 0?void 0:o.emit(new SDKError(a.message,(n=a.response)===null||n===void 0?void 0:n.status,(s=a.response)===null||s===void 0?void 0:s.data));return[3,6];case 6:return[2]}}))}))};e.prototype.componentDidRender=function(){interact.dynamicDrop(true);interact(".recipient").draggable({listeners:{start:function e(t){t.target.classList.add("dragging");this.el.classList.add("dragging")}.bind(this),move:function e(t){var r=+(t.target.getAttribute("posX")||0);var o=+(t.target.getAttribute("posY")||0);var n=t.dx+r;var s=t.dy+o;t.target.setAttribute("posX",n);t.target.setAttribute("posy",s);t.target.style.transform="translate(".concat(n+100,"px, ").concat(s-40,"px)")}.bind(this),end:function e(t){t.target.classList.remove("dragging");this.el.classList.remove("dragging");t.target.setAttribute("posX",0);t.target.setAttribute("posy",0);t.target.style.transform="translate(0px, 0px)"}.bind(this)}});interact(".dropzone").dropzone({overlap:.05,ondrop:function e(t){var r=this;t.target.classList.remove("active");var o=t.relatedTarget.dataset.rolename;var n=+t.target.dataset.sequence;var s=+t.target.dataset.order;var i=state.template.roles.find((function(e){return e.name===o}));if(i){i.sequence=n;i.order=s;this.sortTemplateRoles();this.renumberTemplateRoles();this.forceRerender++;Promise.all(state.template.roles.map((function(e){return updateRole(r.endpoint,r.templateId,e.name,{sequence:e.sequence,order:e.order})}))).then((function(){return console.log("[RECIPIENTS] Updated roles")})).catch((function(e){return console.log("[RECIPIENTS] Role updates failed",e)}))}}.bind(this),ondropactivate:function(e){e.target.classList.add("visible")},ondropdeactivate:function(e){e.target.classList.remove("visible")},ondragenter:function(e){e.target.classList.add("active")},ondragleave:function(e){e.target.classList.remove("active")}})};e.prototype.handleCancel=function(e){var t;e.stopPropagation();(t=this.cancel)===null||t===void 0?void 0:t.emit()};e.prototype.handleSubmit=function(e){var t;e.stopPropagation();(t=this.next)===null||t===void 0?void 0:t.emit()};e.prototype.sortTemplateRoles=function(){state.template.roles.sort((function(e,t){return e.sequence===t.sequence?e.order-t.order:e.sequence-t.sequence}))};e.prototype.extractSequenceNumbers=function(){var e=this;this.sequences=[];state.template.roles.forEach((function(t){if(!e.sequences.includes(t.sequence)){e.sequences.push(t.sequence)}}))};e.prototype.renumberTemplateRoles=function(){this.extractSequenceNumbers();var e=[];this.sequences.sort((function(e,t){return e-t}));this.sequences.forEach((function(t,r){state.template.roles.filter((function(e){return e.sequence===t})).forEach((function(t,o){if(!e.includes(t.name)){t.sequence=r+1;t.order=o+1;e.push(t.name)}}))}));this.extractSequenceNumbers()};e.prototype.handleAddRole=function(e,t){var r=this;e.stopPropagation();var o=state.template.roles.filter((function(e){return e.sequence===t})).length+1;var n="";var s=state.template.roles.length;do{s++;n="Recipient ".concat(s)}while(!n||state.template.roles.some((function(e){return e.name===n})));console.log("Will create",n,t,o);createRole(this.endpoint,this.templateId,{template_id:this.templateId,name:n,full_name:"",email:"",phone:"",sequence:t,order:o,type:"signer",delegator:false}).then((function(e){console.log("Created role",e);state.template.roles.push(e);r.renumberTemplateRoles();r.forceRerender++})).catch((function(e){console.log("Error creating role",e)}))};e.prototype.render=function(){var e=this;var t=state.template.roles.map((function(e){return e.name}));return h(Host,null,h("form",{onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off","data-r":this.forceRerender},h("h5",null,"Recipients"),h("div",{class:"participants"},h("div",{class:"left-line"}),h("div",{class:"row"},h("div",{class:"icon",innerHTML:startIcon}),h("div",{class:"row-recipients"},h("div",{class:"sender"},h("span",{class:"label"},"Sender:")," ",senderLabels[state.template.sender]," ",h("div",{class:"settings-button",innerHTML:settingsIcon,onClick:function(){return e.showingSenderDialog=true},"aria-role":"button"})))),h("div",{class:"row add-sequence","data-sequence":0},h("div",{class:"icon",innerHTML:plusIcon}),h("div",{class:"row-recipients"},h("div",{class:"dropzone","data-sequence":0,"data-order":1},"Add Step"))),this.sequences.map((function(r){return h(Fragment,null,h("div",{class:"row"},h("div",{class:"icon",innerHTML:stepIcon}),h("div",{class:"row-recipients"},h("div",{class:"dropzone","data-order":.5,"data-sequence":r}),state.template.roles.filter((function(e){return e.sequence===r})).map((function(o){return h(Fragment,null,h("div",{class:"recipient",style:{backgroundColor:getRGBA(getRoleIndex(t,o.name))},"data-rolename":o.name},h("span",{class:"type-icon",innerHTML:o.type==="signer"?iconSigner:o.type==="cc"?iconCC:iconApprover}),o.name," ",h("div",{class:"settings-button",innerHTML:settingsIcon,onClick:function(){return e.showingRoleDialog=o.name},"aria-role":"button"})),h("div",{class:"dropzone","data-order":o.order+.5,"data-sequence":r}))})),h("button",{class:"add-role",innerHTML:plusIcon,onClick:function(t){return e.handleAddRole(t,r)}}))),h("div",{class:"row add-sequence","data-sequence":r},h("div",{class:"row-recipients"},h("div",{class:"icon",innerHTML:plusIcon}),h("div",{class:"dropzone","data-sequence":r+1,"data-order":1},"Add Step"))))})),this.sequences.length<1&&h(Fragment,null,h("div",{class:"row"},h("div",{class:"icon",innerHTML:stepIcon}),h("div",{class:"row-recipients"},h("button",{class:"add-role",innerHTML:plusIcon,onClick:function(t){return e.handleAddRole(t,1)}})))),h("div",{class:"row"},h("div",{class:"icon",innerHTML:doneIcon}),h("div",{class:"row-recipients"},h("div",{class:"complete"},"Document Complete")))),t.length<1&&h("div",{class:"empty"},"You must add at least one Role before proceeding.",h("br",null)," Click the ",h("span",{innerHTML:plusIcon})," Add button above to get started."),h("div",{class:"buttons"},h("div",{class:"flex-fill"}),h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(t){return e.handleCancel(t)}}),h("verdocs-button",{label:"OK",size:"small",onClick:function(t){return e.handleSubmit(t)},disabled:t.length<1}))),this.showingRoleDialog&&h("verdocs-template-role-properties",{endpoint:this.endpoint,templateId:this.templateId,roleName:this.showingRoleDialog,onClose:function(){e.showingRoleDialog=null;e.forceRerender++},onDelete:function(t){console.log("deleted",t.detail);e.renumberTemplateRoles();e.showingRoleDialog=null;e.forceRerender++}}),this.showingSenderDialog&&h("verdocs-template-sender",{endpoint:this.endpoint,templateId:this.templateId,onClose:function(){return e.showingSenderDialog=false}}))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();VerdocsTemplateRecipients.style=verdocsTemplateRecipientsCss;export{VerdocsTemplateRecipients as verdocs_template_recipients};
@@ -14,6 +14,10 @@ export declare class VerdocsTemplateRecipients {
14
14
  * The template ID to edit.
15
15
  */
16
16
  templateId: string;
17
+ /**
18
+ * Event fired when the user clicks to proceed.
19
+ */
20
+ next: EventEmitter;
17
21
  /**
18
22
  * Event fired when the user cancels the dialog.
19
23
  */
@@ -1,7 +1,8 @@
1
1
  import { Meta } from '@storybook/web-components';
2
2
  declare const _default: Meta<import("@storybook/web-components").Args>;
3
3
  export default _default;
4
- export declare const Recipients: ({ templateId, cancel }: {
4
+ export declare const Recipients: ({ templateId, onCancel, onSave }: {
5
5
  templateId: any;
6
- cancel: any;
6
+ onCancel: any;
7
+ onSave: any;
7
8
  }) => import("lit-html").TemplateResult<1>;
@@ -2473,6 +2473,10 @@ declare namespace LocalJSX {
2473
2473
  * Event fired when the user cancels the dialog.
2474
2474
  */
2475
2475
  "onCancel"?: (event: VerdocsTemplateRecipientsCustomEvent<any>) => void;
2476
+ /**
2477
+ * Event fired when the user clicks to proceed.
2478
+ */
2479
+ "onNext"?: (event: VerdocsTemplateRecipientsCustomEvent<any>) => void;
2476
2480
  /**
2477
2481
  * Event fired if an error occurs. The event details will contain information about the error. Most errors will terminate the process, and the calling application should correct the condition and re-render the component.
2478
2482
  */
@@ -0,0 +1 @@
1
+ import{r as e,c as t,h as i,F as o,H as s,a as r}from"./p-ff1278ed.js";import{i as a}from"./p-4f12a8a7.js";import{u as l,c as n}from"./p-ffe60abd.js";import{V as p,T as d}from"./p-2d4712ea.js";import{g as c}from"./p-6de76553.js";import{s as m}from"./p-3cb8a7f4.js";import{l as f}from"./p-d1393a1a.js";import{a as h}from"./p-d6e07c20.js";import{S as x}from"./p-7a1b2643.js";import"./p-21603661.js";import"./p-5ea05a1d.js";import"./p-7291906c.js";import"./p-b28ef4bb.js";import"./p-880b619d.js";import"./p-aa124212.js";const v={[d.EVERYONE]:"Everyone",[d.EVERYONE_AS_CREATOR]:"Everyone as Me",[d.ORGANIZATION_MEMBER]:"Organization member",[d.ORGANIZATION_MEMBER_AS_CREATOR]:"Organization Member as Me",[d.CREATOR]:"Me"},g='<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20" fill="#00000089"><path d="m8.021 17.917-.313-2.5q-.27-.125-.625-.334-.354-.208-.625-.395l-2.312.979-1.979-3.438 1.979-1.5q-.021-.167-.031-.364-.011-.198-.011-.365 0-.146.011-.344.01-.198.031-.385l-1.979-1.5 1.979-3.417 2.312.958q.271-.187.615-.385t.635-.344l.313-2.5h3.958l.313 2.5q.312.167.625.344.312.177.604.385l2.333-.958 1.979 3.417-1.979 1.521q.021.187.021.364V10q0 .146-.01.333-.011.188-.011.396l1.958 1.5-1.979 3.438-2.312-.979q-.292.208-.615.395-.323.188-.614.334l-.313 2.5Zm1.937-5.355q1.063 0 1.813-.75t.75-1.812q0-1.062-.75-1.812t-1.813-.75q-1.041 0-1.802.75-.76.75-.76 1.812t.76 1.812q.761.75 1.802.75Zm0-1.333q-.5 0-.864-.364-.365-.365-.365-.865t.365-.865q.364-.364.864-.364t.865.364q.365.365.365.865t-.365.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.187q.605-.167 1.136-.49.531-.323 1.031-.802l2.021.875.854-1.375-1.792-1.354q.105-.333.136-.635.031-.303.031-.615 0-.292-.031-.573-.031-.281-.115-.635l1.792-1.396-.834-1.375-2.062.875q-.438-.438-1.021-.781-.583-.344-1.125-.49l-.271-2.208H9.167l-.271 2.208q-.584.146-1.125.458-.542.313-1.042.792l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.479.458 1.021.771.542.312 1.146.479Z"/></svg>',u='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></svg>',b='<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>',w=class{constructor(i){e(this,i),this.next=t(this,"next",7),this.cancel=t(this,"cancel",7),this.sdkError=t(this,"sdkError",7),this.sequences=[],this.endpoint=p.getDefault(),this.templateId="",this.showingRoleDialog=null,this.showingSenderDialog=!1,this.sender=null,this.forceRerender=1}async componentWillLoad(){var e,t,i,o,s,r;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[RECIPIENTS] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[RECIPIENTS] Unable to start builder session, must be authenticated");try{console.log(`[RECIPIENTS] Loading template ${this.templateId}`,this.endpoint.session),await f(this.endpoint,this.templateId)}catch(o){console.log("[RECIPIENTS] Error loading template",o),null===(e=this.sdkError)||void 0===e||e.emit(new x(o.message,null===(t=o.response)||void 0===t?void 0:t.status,null===(i=o.response)||void 0===i?void 0:i.data))}this.sortTemplateRoles(),this.renumberTemplateRoles()}catch(e){console.log("[FIELDS] Error with preview session",e),null===(o=this.sdkError)||void 0===o||o.emit(new x(e.message,null===(s=e.response)||void 0===s?void 0:s.status,null===(r=e.response)||void 0===r?void 0:r.data))}}componentDidRender(){a.dynamicDrop(!0),a(".recipient").draggable({listeners:{start:function(e){e.target.classList.add("dragging"),this.el.classList.add("dragging")}.bind(this),move:function(e){const t=+(e.target.getAttribute("posX")||0),i=+(e.target.getAttribute("posY")||0),o=e.dx+t,s=e.dy+i;e.target.setAttribute("posX",o),e.target.setAttribute("posy",s),e.target.style.transform=`translate(${o+100}px, ${s-40}px)`}.bind(this),end:function(e){e.target.classList.remove("dragging"),this.el.classList.remove("dragging"),e.target.setAttribute("posX",0),e.target.setAttribute("posy",0),e.target.style.transform="translate(0px, 0px)"}.bind(this)}}),a(".dropzone").dropzone({overlap:.05,ondrop:function(e){e.target.classList.remove("active");const t=e.relatedTarget.dataset.rolename,i=+e.target.dataset.sequence,o=+e.target.dataset.order,s=m.template.roles.find((e=>e.name===t));s&&(s.sequence=i,s.order=o,this.sortTemplateRoles(),this.renumberTemplateRoles(),this.forceRerender++,Promise.all(m.template.roles.map((e=>l(this.endpoint,this.templateId,e.name,{sequence:e.sequence,order:e.order})))).then((()=>console.log("[RECIPIENTS] Updated roles"))).catch((e=>console.log("[RECIPIENTS] Role updates failed",e))))}.bind(this),ondropactivate:e=>{e.target.classList.add("visible")},ondropdeactivate:e=>{e.target.classList.remove("visible")},ondragenter:e=>{e.target.classList.add("active")},ondragleave:e=>{e.target.classList.remove("active")}})}handleCancel(e){var t;e.stopPropagation(),null===(t=this.cancel)||void 0===t||t.emit()}handleSubmit(e){var t;e.stopPropagation(),null===(t=this.next)||void 0===t||t.emit()}sortTemplateRoles(){m.template.roles.sort(((e,t)=>e.sequence===t.sequence?e.order-t.order:e.sequence-t.sequence))}extractSequenceNumbers(){this.sequences=[],m.template.roles.forEach((e=>{this.sequences.includes(e.sequence)||this.sequences.push(e.sequence)}))}renumberTemplateRoles(){this.extractSequenceNumbers();const e=[];this.sequences.sort(((e,t)=>e-t)),this.sequences.forEach(((t,i)=>{m.template.roles.filter((e=>e.sequence===t)).forEach(((t,o)=>{e.includes(t.name)||(t.sequence=i+1,t.order=o+1,e.push(t.name))}))})),this.extractSequenceNumbers()}handleAddRole(e,t){e.stopPropagation();const i=m.template.roles.filter((e=>e.sequence===t)).length+1;let o="",s=m.template.roles.length;do{s++,o=`Recipient ${s}`}while(!o||m.template.roles.some((e=>e.name===o)));console.log("Will create",o,t,i),n(this.endpoint,this.templateId,{template_id:this.templateId,name:o,full_name:"",email:"",phone:"",sequence:t,order:i,type:"signer",delegator:!1}).then((e=>{console.log("Created role",e),m.template.roles.push(e),this.renumberTemplateRoles(),this.forceRerender++})).catch((e=>{console.log("Error creating role",e)}))}render(){const e=m.template.roles.map((e=>e.name));return i(s,null,i("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off","data-r":this.forceRerender},i("h5",null,"Recipients"),i("div",{class:"participants"},i("div",{class:"left-line"}),i("div",{class:"row"},i("div",{class:"icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z"></path></svg>'}),i("div",{class:"row-recipients"},i("div",{class:"sender"},i("span",{class:"label"},"Sender:")," ",v[m.template.sender]," ",i("div",{class:"settings-button",innerHTML:g,onClick:()=>this.showingSenderDialog=!0,"aria-role":"button"})))),i("div",{class:"row add-sequence","data-sequence":0},i("div",{class:"icon",innerHTML:b}),i("div",{class:"row-recipients"},i("div",{class:"dropzone","data-sequence":0,"data-order":1},"Add Step"))),this.sequences.map((t=>i(o,null,i("div",{class:"row"},i("div",{class:"icon",innerHTML:u}),i("div",{class:"row-recipients"},i("div",{class:"dropzone","data-order":.5,"data-sequence":t}),m.template.roles.filter((e=>e.sequence===t)).map((s=>i(o,null,i("div",{class:"recipient",style:{backgroundColor:c(h(e,s.name))},"data-rolename":s.name},i("span",{class:"type-icon",innerHTML:"signer"===s.type?'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>':"cc"===s.type?'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M1.5 8.67v8.58a3 3 0 003 3h15a3 3 0 003-3V8.67l-8.928 5.493a3 3 0 01-3.144 0L1.5 8.67z" /><path d="M22.5 6.908V6.75a3 3 0 00-3-3h-15a3 3 0 00-3 3v.158l9.714 5.978a1.5 1.5 0 001.572 0L22.5 6.908z" /></svg>':'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z" clip-rule="evenodd" /></svg>'}),s.name," ",i("div",{class:"settings-button",innerHTML:g,onClick:()=>this.showingRoleDialog=s.name,"aria-role":"button"})),i("div",{class:"dropzone","data-order":s.order+.5,"data-sequence":t})))),i("button",{class:"add-role",innerHTML:b,onClick:e=>this.handleAddRole(e,t)}))),i("div",{class:"row add-sequence","data-sequence":t},i("div",{class:"row-recipients"},i("div",{class:"icon",innerHTML:b}),i("div",{class:"dropzone","data-sequence":t+1,"data-order":1},"Add Step")))))),this.sequences.length<1&&i(o,null,i("div",{class:"row"},i("div",{class:"icon",innerHTML:u}),i("div",{class:"row-recipients"},i("button",{class:"add-role",innerHTML:b,onClick:e=>this.handleAddRole(e,1)})))),i("div",{class:"row"},i("div",{class:"icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="m18 7-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41 6 19l1.41-1.41L1.83 12 .41 13.41z"></path></svg>'}),i("div",{class:"row-recipients"},i("div",{class:"complete"},"Document Complete")))),e.length<1&&i("div",{class:"empty"},"You must add at least one Role before proceeding.",i("br",null)," Click the ",i("span",{innerHTML:b})," Add button above to get started."),i("div",{class:"buttons"},i("div",{class:"flex-fill"}),i("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:e=>this.handleCancel(e)}),i("verdocs-button",{label:"OK",size:"small",onClick:e=>this.handleSubmit(e),disabled:e.length<1}))),this.showingRoleDialog&&i("verdocs-template-role-properties",{endpoint:this.endpoint,templateId:this.templateId,roleName:this.showingRoleDialog,onClose:()=>{this.showingRoleDialog=null,this.forceRerender++},onDelete:e=>{console.log("deleted",e.detail),this.renumberTemplateRoles(),this.showingRoleDialog=null,this.forceRerender++}}),this.showingSenderDialog&&i("verdocs-template-sender",{endpoint:this.endpoint,templateId:this.templateId,onClose:()=>this.showingSenderDialog=!1}))}get el(){return r(this)}};w.style='verdocs-template-recipients{display:block;min-width:400px;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-recipients>form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;padding:12px}verdocs-template-recipients>form h5{font-size:16px;font-weight:bold;color:#4c56cb;margin:0 0 10px 0}verdocs-template-recipients>form .participants{position:relative}verdocs-template-recipients>form .left-line{top:32px;left:11px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-template-recipients>form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:0;-moz-column-gap:0;column-gap:0;margin-left:40px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:6px 0 4px 0}verdocs-template-recipients>form .row .row-recipients{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;-ms-flex-direction:row;flex-direction:row}verdocs-template-recipients>form .row .icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-template-recipients>form .row .sender{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 5px 0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;border:1px solid #c6c9cc;background-color:#f5f5fa}verdocs-template-recipients>form .row .complete{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;background-color:#f5f5fa;border:1px solid #aeb4bf}verdocs-template-recipients>form .row .label{font-weight:bold;margin-right:6px;color:#33364b}verdocs-template-recipients>form .row .settings-button{margin:4px 0 0 9px;cursor:pointer}verdocs-template-recipients>form .row .recipient{height:30px;display:-ms-flexbox;display:flex;font-size:14px;line-height:30px;border-radius:30px;-ms-flex-direction:row;flex-direction:row;padding:0 5px 0 6px;white-space:nowrap;border:1px solid #aeb4bf}verdocs-template-recipients>form .row .recipient .type-icon{width:24px;height:24px;-webkit-transform:scale(0.8);transform:scale(0.8);opacity:0.6;margin:4px 12px 0 0}verdocs-template-recipients>form .row .recipient.dragging{position:absolute}verdocs-template-recipients>form .row .recipient.dragging+.dropzone{display:none !important}verdocs-template-recipients>form .row .dropzone{width:14px;height:30px;display:none}verdocs-template-recipients>form .row .dropzone svg{fill:#cccccc}verdocs-template-recipients>form .row .dropzone.visible{margin:0 7px;display:-ms-flexbox;display:flex;-ms-flex:0 0 14px;flex:0 0 14px}verdocs-template-recipients>form .row .dropzone.active{-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;background:#654dcb7f;border:1px dashed #654dcb}verdocs-template-recipients>form label{display:block;font-size:14px;font-weight:500;margin:0 0 4px 0;color:#5c6575}verdocs-template-recipients>form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-recipients>form input:focus{outline:none}verdocs-template-recipients .row.add-sequence{display:none}verdocs-template-recipients .add-role{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-recipients .add-role:hover{opacity:1}verdocs-template-recipients .add-role svg{width:32px;height:32px}verdocs-template-recipients.dragging .add-role{display:none}verdocs-template-recipients.dragging form .row .recipient+.dropzone{display:-ms-flexbox;display:flex}verdocs-template-recipients.dragging .row.add-sequence{display:-ms-flexbox;display:flex}verdocs-template-recipients.dragging .row.add-sequence .dropzone{opacity:0.5;-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;-ms-flex-align:center;align-items:center;background:#654dcb7f;-ms-flex-pack:center;justify-content:center;border:1px dashed #654dcb}verdocs-template-recipients.dragging .row.add-sequence .dropzone.active{opacity:1}verdocs-template-recipients .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-direction:row;flex-direction:row}verdocs-template-recipients .empty{font-size:13px;margin-top:15px;margin-bottom:5px}verdocs-template-recipients .empty svg{width:20px;height:20px;stroke:#666666;margin-bottom:-5px}verdocs-template-recipients ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::-moz-placeholder{color:#aaaaaa}verdocs-template-recipients :-ms-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-recipients ::placeholder{color:#aaaaaa}';export{w as verdocs_template_recipients}