@verdocs/web-sdk 6.14.0 → 6.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cjs/verdocs-preview_6.cjs.entry.js +2 -2
  2. package/dist/cjs/verdocs-preview_6.cjs.entry.js.map +1 -1
  3. package/dist/cjs/verdocs-template-star.cjs.entry.js +2 -2
  4. package/dist/cjs/verdocs-template-star.cjs.entry.js.map +1 -1
  5. package/dist/collection/components/embeds/verdocs-send/verdocs-send.css +3 -0
  6. package/dist/collection/components/embeds/verdocs-send/verdocs-send.js +1 -1
  7. package/dist/collection/components/embeds/verdocs-send/verdocs-send.js.map +1 -1
  8. package/dist/collection/components/templates/verdocs-template-star/verdocs-template-star.js +2 -2
  9. package/dist/collection/components/templates/verdocs-template-star/verdocs-template-star.js.map +1 -1
  10. package/dist/components/p-Cisooi3V.js +2 -0
  11. package/dist/components/p-Cisooi3V.js.map +1 -0
  12. package/dist/components/{p-DslyN9XL.js → p-ClWqxMkZ.js} +2 -2
  13. package/dist/components/{p-DslyN9XL.js.map → p-ClWqxMkZ.js.map} +1 -1
  14. package/dist/components/verdocs-build.js +1 -1
  15. package/dist/components/verdocs-send.js +1 -1
  16. package/dist/components/verdocs-template-star.js +1 -1
  17. package/dist/components/verdocs-templates-list.js +1 -1
  18. package/dist/custom-elements.json +2523 -0
  19. package/dist/esm/verdocs-preview_6.entry.js +2 -2
  20. package/dist/esm/verdocs-preview_6.entry.js.map +1 -1
  21. package/dist/esm/verdocs-template-star.entry.js +2 -2
  22. package/dist/esm/verdocs-template-star.entry.js.map +1 -1
  23. package/dist/esm-es5/verdocs-preview_6.entry.js +1 -1
  24. package/dist/esm-es5/verdocs-preview_6.entry.js.map +1 -1
  25. package/dist/esm-es5/verdocs-template-star.entry.js +1 -1
  26. package/dist/esm-es5/verdocs-template-star.entry.js.map +1 -1
  27. package/dist/verdocs-web-sdk/{p-5455e818.entry.js → p-442b6b04.entry.js} +2 -2
  28. package/dist/verdocs-web-sdk/{p-5455e818.entry.js.map → p-442b6b04.entry.js.map} +1 -1
  29. package/dist/verdocs-web-sdk/p-BdZ5Ghsa.system.js +1 -1
  30. package/dist/verdocs-web-sdk/{p-bd1bcb9d.system.entry.js → p-ab798e66.system.entry.js} +2 -2
  31. package/dist/verdocs-web-sdk/p-ab798e66.system.entry.js.map +1 -0
  32. package/dist/verdocs-web-sdk/{p-e3f13498.entry.js → p-ad4ae5c3.entry.js} +2 -2
  33. package/dist/verdocs-web-sdk/p-ad4ae5c3.entry.js.map +1 -0
  34. package/dist/verdocs-web-sdk/{p-20bc8055.system.entry.js → p-dea0ae12.system.entry.js} +2 -2
  35. package/dist/verdocs-web-sdk/{p-20bc8055.system.entry.js.map → p-dea0ae12.system.entry.js.map} +1 -1
  36. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  37. package/package.json +2 -2
  38. package/dist/components/p-DPF2i0o5.js +0 -2
  39. package/dist/components/p-DPF2i0o5.js.map +0 -1
  40. package/dist/verdocs-web-sdk/p-bd1bcb9d.system.entry.js.map +0 -1
  41. package/dist/verdocs-web-sdk/p-e3f13498.entry.js.map +0 -1
@@ -26,7 +26,7 @@ const VerdocsTemplateStar = class {
26
26
  toggle(e) {
27
27
  e.stopPropagation();
28
28
  this.updating = true;
29
- toggleTemplateStar(VerdocsEndpoint.getDefault(), this.template.id)
29
+ toggleTemplateStar(this.endpoint, this.template.id)
30
30
  .then(r => {
31
31
  this.updating = false;
32
32
  this.template.star_counter = r.star_counter;
@@ -43,7 +43,7 @@ const VerdocsTemplateStar = class {
43
43
  });
44
44
  }
45
45
  render() {
46
- return (h(Host, { key: '3008017b75bf678075828ff02a73f032a7a146cb' }, h("div", { key: '770caa1d2ea53efc45d0857f2202e2c871e5d960', class: `star ${this.updating ? 'updating' : ''}`, innerHTML: this.template.star_counter ? SolidStarIcon : OutlineStarIcon, onClick: e => this.toggle(e) }), h("div", { key: '157ab322269c33f8214acd2e6e7267fd2db0f560', class: "count" }, this.template.star_counter || '--')));
46
+ return (h(Host, { key: '3ad893e322e75e91b50bb0e88a52351a3ae08b12' }, h("div", { key: 'abcc59607ae57838800e568d43c75488b0a5528d', class: `star ${this.updating ? 'updating' : ''}`, innerHTML: this.template.star_counter ? SolidStarIcon : OutlineStarIcon, onClick: e => this.toggle(e) }), h("div", { key: '2a369be78c9f89ae8cad98286b33f1e6e8b182a9', class: "count" }, this.template.star_counter || '--')));
47
47
  }
48
48
  };
49
49
  VerdocsTemplateStar.style = verdocsTemplateStarCss();
@@ -1 +1 @@
1
- {"version":3,"file":"verdocs-template-star.entry.js","sources":["src/components/templates/verdocs-template-star/verdocs-template-star.scss?tag=verdocs-template-star","src/components/templates/verdocs-template-star/verdocs-template-star.tsx"],"sourcesContent":["@import '../../../theme.scss';\n\nverdocs-template-star {\n display: flex;\n flex: 0 0 60px;\n align-items: center;\n flex-direction: row;\n font-family: $primary-font;\n\n .star {\n line-height: 10px;\n\n &.updating {\n animation: spinningStar 2s infinite linear;\n }\n\n svg {\n width: 24px;\n height: 24px;\n }\n }\n\n .count {\n color: #595c5d;\n font-size: 14px;\n margin-left: 10px;\n }\n}\n\n@keyframes spinningStar {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(359deg);\n }\n}\n","import {VerdocsEndpoint, toggleTemplateStar, ITemplate} from '@verdocs/js-sdk';\nimport {Component, Prop, h, Host, Event, EventEmitter, State} from '@stencil/core';\nimport {SDKError} from '../../../utils/errors';\n\nconst OutlineStarIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z\" /></svg>`;\n\nconst SolidStarIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z\" clip-rule=\"evenodd\" /></svg>`;\n\n/**\n * Displays a clickable star that allows users to mark frequently-used templates.\n */\n@Component({\n tag: 'verdocs-template-star',\n styleUrl: 'verdocs-template-star.scss',\n})\nexport class VerdocsTemplateStar {\n /**\n * The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.\n */\n @Prop() endpoint: VerdocsEndpoint = VerdocsEndpoint.getDefault();\n\n /**\n * The template to display the star for.\n */\n @Prop({mutable: true}) template: ITemplate;\n\n /**\n * Event fired when the user toggles the star on or off. The event detail will contain\n * the new \"starred\" status and count.\n */\n @Event({composed: true}) starChange: EventEmitter<{templateId: string; starred: boolean; count: number}>;\n\n /**\n * Event fired if an error occurs. The event details will contain information about the error. Most errors will\n * terminate the process, and the calling application should correct the condition and re-render the component.\n */\n @Event({composed: true}) sdkError: EventEmitter<SDKError>;\n\n @State() updating = false;\n\n async componentWillLoad() {\n this.endpoint.loadSession();\n\n if (!this.endpoint.session) {\n console.log('[TEMPLATES] Must be authenticated');\n return;\n }\n }\n\n toggle(e: any) {\n e.stopPropagation();\n this.updating = true;\n toggleTemplateStar(VerdocsEndpoint.getDefault(), this.template.id)\n .then(r => {\n this.updating = false;\n this.template.star_counter = r.star_counter;\n this.starChange.emit({\n templateId: this.template.id,\n starred: r.star_counter > 0,\n count: r.star_counter,\n });\n })\n .catch(e => {\n this.updating = false;\n console.log('[STAR] Error toggling template star', e.message);\n this.sdkError.emit(e);\n });\n }\n\n render() {\n return (\n <Host>\n <div class={`star ${this.updating ? 'updating' : ''}`} innerHTML={this.template.star_counter ? SolidStarIcon : OutlineStarIcon} onClick={e => this.toggle(e)} />\n <div class=\"count\">{this.template.star_counter || '--'}</div>\n </Host>\n );\n }\n}\n"],"names":[],"mappings":";;;AAAA,MAAM,sBAAsB,GAAG,MAAM,CAAC,8yBAA8yB,CAAC;;ACIr1B,MAAM,eAAe,GAAG,CAAA,qhBAAA,CAAuhB;AAE/iB,MAAM,aAAa,GAAG,CAAA,0aAAA,CAA4a;MASrb,mBAAmB,GAAA,MAAA;AAJhC,IAAA,WAAA,CAAA,OAAA,EAAA;;;;AAKE;;AAEG;AACK,QAAA,IAAA,CAAA,QAAQ,GAAoB,eAAe,CAAC,UAAU,EAAE;AAmBvD,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK;AAuC1B;AArCC,IAAA,MAAM,iBAAiB,GAAA;AACrB,QAAA,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;AAE3B,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AAC1B,YAAA,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC;YAChD;;;AAIJ,IAAA,MAAM,CAAC,CAAM,EAAA;QACX,CAAC,CAAC,eAAe,EAAE;AACnB,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;QACpB,kBAAkB,CAAC,eAAe,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;aAC9D,IAAI,CAAC,CAAC,IAAG;AACR,YAAA,IAAI,CAAC,QAAQ,GAAG,KAAK;YACrB,IAAI,CAAC,QAAQ,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY;AAC3C,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;AACnB,gBAAA,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;AAC5B,gBAAA,OAAO,EAAE,CAAC,CAAC,YAAY,GAAG,CAAC;gBAC3B,KAAK,EAAE,CAAC,CAAC,YAAY;AACtB,aAAA,CAAC;AACJ,SAAC;aACA,KAAK,CAAC,CAAC,IAAG;AACT,YAAA,IAAI,CAAC,QAAQ,GAAG,KAAK;YACrB,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,CAAC,CAAC,OAAO,CAAC;AAC7D,YAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACvB,SAAC,CAAC;;IAGN,MAAM,GAAA;AACJ,QAAA,QACE,EAAC,IAAI,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,EACH,CAAA,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAK,KAAK,EAAE,CAAA,KAAA,EAAQ,IAAI,CAAC,QAAQ,GAAG,UAAU,GAAG,EAAE,CAAA,CAAE,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,GAAG,aAAa,GAAG,eAAe,EAAE,OAAO,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAA,CAAI,EAChK,CAAA,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAK,KAAK,EAAC,OAAO,EAAA,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI,CAAO,CACxD;;;;;;;"}
1
+ {"version":3,"file":"verdocs-template-star.entry.js","sources":["src/components/templates/verdocs-template-star/verdocs-template-star.scss?tag=verdocs-template-star","src/components/templates/verdocs-template-star/verdocs-template-star.tsx"],"sourcesContent":["@import '../../../theme.scss';\n\nverdocs-template-star {\n display: flex;\n flex: 0 0 60px;\n align-items: center;\n flex-direction: row;\n font-family: $primary-font;\n\n .star {\n line-height: 10px;\n\n &.updating {\n animation: spinningStar 2s infinite linear;\n }\n\n svg {\n width: 24px;\n height: 24px;\n }\n }\n\n .count {\n color: #595c5d;\n font-size: 14px;\n margin-left: 10px;\n }\n}\n\n@keyframes spinningStar {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(359deg);\n }\n}\n","import {VerdocsEndpoint, toggleTemplateStar, ITemplate} from '@verdocs/js-sdk';\nimport {Component, Prop, h, Host, Event, EventEmitter, State} from '@stencil/core';\nimport {SDKError} from '../../../utils/errors';\n\nconst OutlineStarIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z\" /></svg>`;\n\nconst SolidStarIcon = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z\" clip-rule=\"evenodd\" /></svg>`;\n\n/**\n * Displays a clickable star that allows users to mark frequently-used templates.\n */\n@Component({\n tag: 'verdocs-template-star',\n styleUrl: 'verdocs-template-star.scss',\n})\nexport class VerdocsTemplateStar {\n /**\n * The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.\n */\n @Prop() endpoint: VerdocsEndpoint = VerdocsEndpoint.getDefault();\n\n /**\n * The template to display the star for.\n */\n @Prop({mutable: true}) template: ITemplate;\n\n /**\n * Event fired when the user toggles the star on or off. The event detail will contain\n * the new \"starred\" status and count.\n */\n @Event({composed: true}) starChange: EventEmitter<{templateId: string; starred: boolean; count: number}>;\n\n /**\n * Event fired if an error occurs. The event details will contain information about the error. Most errors will\n * terminate the process, and the calling application should correct the condition and re-render the component.\n */\n @Event({composed: true}) sdkError: EventEmitter<SDKError>;\n\n @State() updating = false;\n\n async componentWillLoad() {\n this.endpoint.loadSession();\n\n if (!this.endpoint.session) {\n console.log('[TEMPLATES] Must be authenticated');\n return;\n }\n }\n\n toggle(e: any) {\n e.stopPropagation();\n this.updating = true;\n toggleTemplateStar(this.endpoint, this.template.id)\n .then(r => {\n this.updating = false;\n this.template.star_counter = r.star_counter;\n this.starChange.emit({\n templateId: this.template.id,\n starred: r.star_counter > 0,\n count: r.star_counter,\n });\n })\n .catch(e => {\n this.updating = false;\n console.log('[STAR] Error toggling template star', e.message);\n this.sdkError.emit(e);\n });\n }\n\n render() {\n return (\n <Host>\n <div class={`star ${this.updating ? 'updating' : ''}`} innerHTML={this.template.star_counter ? SolidStarIcon : OutlineStarIcon} onClick={e => this.toggle(e)} />\n <div class=\"count\">{this.template.star_counter || '--'}</div>\n </Host>\n );\n }\n}\n"],"names":[],"mappings":";;;AAAA,MAAM,sBAAsB,GAAG,MAAM,CAAC,8yBAA8yB,CAAC;;ACIr1B,MAAM,eAAe,GAAG,CAAA,qhBAAA,CAAuhB;AAE/iB,MAAM,aAAa,GAAG,CAAA,0aAAA,CAA4a;MASrb,mBAAmB,GAAA,MAAA;AAJhC,IAAA,WAAA,CAAA,OAAA,EAAA;;;;AAKE;;AAEG;AACK,QAAA,IAAA,CAAA,QAAQ,GAAoB,eAAe,CAAC,UAAU,EAAE;AAmBvD,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK;AAuC1B;AArCC,IAAA,MAAM,iBAAiB,GAAA;AACrB,QAAA,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE;AAE3B,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AAC1B,YAAA,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC;YAChD;;;AAIJ,IAAA,MAAM,CAAC,CAAM,EAAA;QACX,CAAC,CAAC,eAAe,EAAE;AACnB,QAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;QACpB,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;aAC/C,IAAI,CAAC,CAAC,IAAG;AACR,YAAA,IAAI,CAAC,QAAQ,GAAG,KAAK;YACrB,IAAI,CAAC,QAAQ,CAAC,YAAY,GAAG,CAAC,CAAC,YAAY;AAC3C,YAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;AACnB,gBAAA,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;AAC5B,gBAAA,OAAO,EAAE,CAAC,CAAC,YAAY,GAAG,CAAC;gBAC3B,KAAK,EAAE,CAAC,CAAC,YAAY;AACtB,aAAA,CAAC;AACJ,SAAC;aACA,KAAK,CAAC,CAAC,IAAG;AACT,YAAA,IAAI,CAAC,QAAQ,GAAG,KAAK;YACrB,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,CAAC,CAAC,OAAO,CAAC;AAC7D,YAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACvB,SAAC,CAAC;;IAGN,MAAM,GAAA;AACJ,QAAA,QACE,EAAC,IAAI,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAA,EACH,CAAA,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAK,KAAK,EAAE,CAAA,KAAA,EAAQ,IAAI,CAAC,QAAQ,GAAG,UAAU,GAAG,EAAE,CAAA,CAAE,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,GAAG,aAAa,GAAG,eAAe,EAAE,OAAO,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAA,CAAI,EAChK,CAAA,CAAA,KAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EAAK,KAAK,EAAC,OAAO,EAAA,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI,CAAO,CACxD;;;;;;;"}
@@ -1,4 +1,4 @@
1
- var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,n,i){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i["throw"](e))}catch(e){o(e)}}function l(e){e.done?n(e.value):r(e.value).then(s,a)}l((i=i.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:[]},i,r,o,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=a(0),s["throw"]=a(1),s["return"]=a(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(e){return function(t){return l([e,t])}}function l(a){if(i)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(n=0)),n)try{if(i=1,r&&(o=a[0]&2?r["return"]:a[0]?r["throw"]||((o=r["return"])&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;if(r=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;r=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];r=0}finally{i=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var i=0,r=t.length,o;i<r;i++){if(o||!(i in t)){if(!o)o=Array.prototype.slice.call(t,0,i);o[i]=t[i]}}return e.concat(o||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host,F as Fragment,g as getElement}from"./index-CjTHbolG.js";import{i as interact}from"./interact.min-Bf1WXbdg.js";import{VerdocsEndpoint,getTemplate,integerSequence,getBrands,getOrganization,formatFullName,getOrganizationContacts,isValidEmail,createEnvelope,getRGBA,createTemplateDocument,deleteTemplateDocument,updateField,createField,updateTemplateRole,createTemplateRole}from"@verdocs/js-sdk";import{a as renderDocumentField,g as getFieldId,h as setControlStyles,i as updateCssTransform,j as removeCssTransform,d as defaultHeight,k as defaultWidth}from"./utils-T8dqWH7y.js";import{S as SDKError}from"./errors-C1sRVZWv.js";import{S as Store}from"./Datastore-C7hFgM52.js";import{D as DefaultEndpoint,g as getWebAppUrl}from"./Environment-Cq60Emo_.js";import{u as updateScrollFade}from"./ScrollFade-7UEjZarN.js";import{V as VerdocsToast}from"./Toast-D97GxsI-.js";import{a as DocIcon,P as PngIcon,J as JpgIcon,b as PdfIcon,F as FileIcon,c as PageCountIcon,T as TrashIcon,D as DocumentPageIcon}from"./Icons-DobS6Y7w.js";import"./_commonjsHelpers-B85MJLTf.js";import"./index-BglCURB-.js";import"./Types-CIxfEdV7.js";var verdocsPreviewCss=function(){return'verdocs-preview{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif);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-preview div,verdocs-preview canvas{-webkit-box-sizing:border-box;box-sizing:border-box}'};var VerdocsPreview=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.templateListenerId=null;this.renderedPages={};this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[PREVIEW] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(i){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[PREVIEW] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){console.log("[PREVIEW] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(i){console.log("[PREVIEW] Error with preview session",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,(n=i.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.componentDidRender=function(){var e;(e=this.hostEl)===null||e===void 0?void 0:e.querySelectorAll(".verdocs-field").forEach((function(e){interact(e).unset()}))};e.prototype.handlePageRendered=function(e){var t;var n=e.detail;this.renderedPages["".concat(n.documentId,":").concat(n.pageNumber)]=n;var i=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).filter((function(e){if(e["document_id"]){return e["document_id"]===n.documentId&&e.page===n.pageNumber}return e.page===n.pageNumber}));i.forEach((function(e){return renderDocumentField("template",e,n,{disabled:true,editable:false,draggable:false})}))};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}return h(Host,null,(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){var n=integerSequence(1,t.pages);return h(Fragment,null,n.map((function(n){var i;var r=((i=t.page_sizes)===null||i===void 0?void 0:i[n])||{width:612,height:792};return h("verdocs-template-document-page",{templateId:t.template_id,documentId:t.id,pageNumber:n,disabled:true,editable:false,done:false,virtualWidth:r.width,virtualHeight:r.height,onPageRendered:function(t){return e.handlePageRendered(t)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))})))};Object.defineProperty(e.prototype,"hostEl",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{templateId:[{onTemplateIdChanged:0}]}},enumerable:false,configurable:true});return e}();VerdocsPreview.style=verdocsPreviewCss();var getRoleNames=function(e){return((e===null||e===void 0?void 0:e.roles)||[]).map((function(e){return e.name}))};var getRoleIndex=function(e,t){return Math.max(getRoleNames(e).findIndex((function(e){return e===t})),0)};var verdocsSendCss=function(){return'verdocs-send{--send-ink:var(--verdocs-body-color, #111827);--send-ink-2:#374151;--send-muted:#6b7280;--send-faint:#9ca3af;--send-rule:#e5e7eb;--send-control-border:#d1d5db;--send-accent:var(--verdocs-link-color, #4c56cb);--send-accent-tint:#f4f5fc;--send-accent-tint-2:#e6e7f8;--send-warning-bg:#fffbeb;--send-warning-border:#fde68a;--send-warning-icon:#d97706;--send-warning-text:#78350f;--send-radius:var(--verdocs-dialog-radius, 8px);--send-min-height:480px;--send-max-width:480px;display:none;position:relative;overflow:hidden;width:100%;min-width:0;max-width:var(--verdocs-send-max-width, var(--send-max-width));-webkit-box-sizing:border-box;box-sizing:border-box;background:#ffffff;color:var(--send-ink);font-size:14px;border-radius:var(--send-radius);border:1px solid var(--send-rule);font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-send *{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-send.sendable{display:block}verdocs-send .track{position:relative;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;min-height:var(--send-min-height);-webkit-transition:-webkit-transform 220ms ease-out;transition:-webkit-transform 220ms ease-out;transition:transform 220ms ease-out;transition:transform 220ms ease-out, -webkit-transform 220ms ease-out}verdocs-send.detail-open .track{-webkit-transform:translateX(-100%);transform:translateX(-100%)}@media (prefers-reduced-motion: reduce){verdocs-send .track{-webkit-transition:none;transition:none}}verdocs-send .pane{padding:16px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .main-pane{-ms-flex:1;flex:1}verdocs-send .detail-pane{position:absolute;top:0;left:100%;bottom:0;width:100%;overflow:hidden}verdocs-send .detail{-ms-flex:1;flex:1;min-height:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .detail-body-wrap{position:relative;-ms-flex:1;flex:1;min-height:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .detail-body{-ms-flex:1;flex:1;min-height:0;overflow-y:auto}verdocs-send .scroll-fade{position:absolute;left:0;right:0;bottom:0;height:36px;opacity:0;pointer-events:none;-webkit-transition:opacity 150ms ease-out;transition:opacity 150ms ease-out;background:-webkit-gradient(linear, left top, left bottom, from(rgba(255, 255, 255, 0)), to(#ffffff));background:linear-gradient(rgba(255, 255, 255, 0), #ffffff)}verdocs-send .scrollable:not(.at-end)>.scroll-fade{opacity:1}verdocs-send .recipient-detail verdocs-contact-picker{-ms-flex:1;flex:1;min-height:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .section-title{font-size:12px;font-weight:600;color:var(--send-ink-2);margin:0 0 6px 0}verdocs-send .delivery-title{margin-top:16px}verdocs-send .step{font-size:11px;color:var(--send-muted);padding:10px 0 4px 0}verdocs-send .recipient,verdocs-send .kv{all:unset;display:-ms-flexbox;display:flex;width:100%;min-width:0;max-width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;cursor:pointer;-ms-flex-align:center;align-items:center;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;border-top:1px solid var(--send-rule);color:var(--send-ink);font-family:inherit}verdocs-send .recipient:focus-visible,verdocs-send .kv:focus-visible{outline:2px solid var(--send-accent);outline-offset:-2px;border-radius:4px}verdocs-send .recipient .chevron,verdocs-send .kv .chevron{-ms-flex:0 0 16px;flex:0 0 16px;width:16px;height:16px;color:var(--send-faint)}verdocs-send .recipient .chevron svg,verdocs-send .kv .chevron svg{width:16px;height:16px;display:block}verdocs-send .recipient{padding:8px 6px 8px 0}verdocs-send .recipient:last-child{border-bottom:1px solid var(--send-rule)}verdocs-send .recipient .who{-ms-flex:1;flex:1;width:0;min-width:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .recipient .role-name{font-size:13px;font-weight:600}verdocs-send .recipient .who-detail{font-size:12px;color:var(--send-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-send .recipient .who-detail.configure{color:var(--send-accent);font-weight:500}verdocs-send .recipient .options{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:4px;margin-top:3px}verdocs-send .recipient .pill{height:18px;padding:0 6px;border-radius:999px;font-size:10px;font-weight:500;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;background:var(--send-accent-tint);color:var(--send-ink-2)}verdocs-send .role-dot{-ms-flex:0 0 10px;flex:0 0 10px;width:10px;height:10px;border-radius:50%;border:1px solid rgba(0, 0, 0, 0.1)}verdocs-send .kv{height:40px;padding:0 6px 0 0;font-size:13px}verdocs-send .kv:last-child{border-bottom:1px solid var(--send-rule)}verdocs-send .kv:disabled{cursor:default;color:var(--send-muted)}verdocs-send .kv .key{-ms-flex:0 0 84px;flex:0 0 84px;color:var(--send-muted)}verdocs-send .kv .value{-ms-flex:1;flex:1;width:0;min-width:0;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-send .kv .value small{font-size:inherit;font-weight:400;color:var(--send-muted)}verdocs-send .kv .value.stacked{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;row-gap:1px;white-space:normal}verdocs-send .kv .value.stacked .line{display:block;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-send .kv .value.stacked small.line{font-size:12px}verdocs-send .kv .value.off{color:var(--send-warning-icon)}verdocs-send .kv:has(.value.stacked){height:auto;min-height:40px;padding-top:6px;padding-bottom:6px}verdocs-send .main-spacer,verdocs-send .detail-spacer{-ms-flex:1;flex:1}verdocs-send .buttons{display:-ms-flexbox;display:flex;margin-top:14px;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center;-ms-flex-pack:end;justify-content:flex-end}verdocs-send .buttons .error-message{width:100%;color:#cc0000;font-size:13px;margin-bottom:10px}verdocs-send .detail-header{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin:-2px 0 14px 0}verdocs-send .detail-header .back{all:unset;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;cursor:pointer;font-size:13px;font-weight:500;color:var(--send-accent);font-family:inherit;-ms-flex:0 0 52px;flex:0 0 52px}verdocs-send .detail-header .back .icon,verdocs-send .detail-header .back .icon svg{width:16px;height:16px;display:block}verdocs-send .detail-header .back:focus-visible{outline:2px solid var(--send-accent);outline-offset:2px;border-radius:4px}verdocs-send .detail-header .detail-title{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;font-size:14px;font-weight:600;text-align:center}verdocs-send .detail-header .detail-header-spacer{-ms-flex:0 0 52px;flex:0 0 52px}verdocs-send .detail-footer{margin-top:10px;padding-top:12px;border-top:1px solid var(--send-rule)}verdocs-send .detail-footer verdocs-button,verdocs-send .detail-footer verdocs-button button{width:100%}verdocs-send .hint{font-size:12px;line-height:1.5;color:var(--send-muted);margin:10px 0 0 0}verdocs-send .option-list{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .option{all:unset;display:-ms-flexbox;display:flex;width:100%;cursor:pointer;-ms-flex-align:center;align-items:center;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;padding:10px 0;font-size:13px;font-family:inherit;color:var(--send-ink);border-top:1px solid var(--send-rule)}verdocs-send .option:first-child{border-top:0}verdocs-send .option:focus-visible{outline:2px solid var(--send-accent);outline-offset:-2px;border-radius:4px}verdocs-send .option .radio{-ms-flex:0 0 16px;flex:0 0 16px;width:16px;height:16px;border-radius:50%;border:1px solid var(--send-control-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}verdocs-send .option.selected .radio{border-color:var(--send-accent)}verdocs-send .option.selected .radio::after{content:"";width:8px;height:8px;border-radius:50%;background:var(--send-accent)}verdocs-send .option .swatch{-ms-flex:0 0 22px;flex:0 0 22px;width:22px;height:22px;border-radius:5px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;font-size:9px;font-weight:700;color:#ffffff;overflow:hidden}verdocs-send .option .swatch.logo{background:#ffffff;border:1px solid var(--send-rule)}verdocs-send .option .swatch img{width:100%;height:100%;-o-object-fit:contain;object-fit:contain;display:block}verdocs-send .option .option-label{-ms-flex:1;flex:1;width:0;min-width:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .option .option-label small{font-size:11px;color:var(--send-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-send .option-divider{height:0;margin:2px 0;border-top:1px solid var(--send-control-border)}verdocs-send .option-divider+.option{border-top:0}verdocs-send .hint a{color:var(--send-accent);font-weight:500;text-decoration:none;border-bottom:1px solid var(--send-accent-tint-2)}verdocs-send .hint a .icon,verdocs-send .hint a .icon svg{width:11px;height:11px;display:inline-block;vertical-align:-1px;margin-left:2px}verdocs-send .expires-field{position:relative}verdocs-send .expires-field input{width:100%;height:36px;padding:0 52px 0 10px;font-size:14px;font-family:inherit;color:var(--send-ink);background:#ffffff;border:1px solid var(--send-control-border);border-radius:6px;outline:none}verdocs-send .expires-field input:focus{border-color:var(--send-accent);-webkit-box-shadow:0 0 0 2px var(--send-accent-tint-2);box-shadow:0 0 0 2px var(--send-accent-tint-2)}verdocs-send .expires-field input::-webkit-input-placeholder{color:var(--send-faint)}verdocs-send .expires-field input::-moz-placeholder{color:var(--send-faint)}verdocs-send .expires-field input:-ms-input-placeholder{color:var(--send-faint)}verdocs-send .expires-field input::-ms-input-placeholder{color:var(--send-faint)}verdocs-send .expires-field input::placeholder{color:var(--send-faint)}verdocs-send .expires-field .suffix{position:absolute;right:10px;top:0;height:36px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;font-size:13px;color:var(--send-muted);pointer-events:none}verdocs-send .sender-field{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;row-gap:4px;margin:0 0 10px 0}verdocs-send .sender-field label{font-size:12px;font-weight:500;color:var(--send-ink-2)}verdocs-send .sender-field input{width:100%;height:36px;padding:0 10px;font-size:14px;font-family:inherit;color:var(--send-ink);background:#ffffff;border:1px solid var(--send-control-border);border-radius:6px;outline:none}verdocs-send .sender-field input:focus{border-color:var(--send-accent);-webkit-box-shadow:0 0 0 2px var(--send-accent-tint-2);box-shadow:0 0 0 2px var(--send-accent-tint-2)}verdocs-send .sender-field .field-error{font-size:12px;color:#cc0000}verdocs-send .notice{display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;margin-top:4px;padding:10px 12px;font-size:12px;line-height:1.5;border-radius:6px;color:var(--send-ink-2);background:var(--send-accent-tint);border:1px solid var(--send-accent-tint-2)}verdocs-send .notice>.icon{-ms-flex:0 0 18px;flex:0 0 18px;width:18px;height:18px;margin-top:1px;color:var(--send-accent)}verdocs-send .notice>.icon svg{width:18px;height:18px;display:block}verdocs-send .warning{display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;margin-top:12px;padding:10px 12px;font-size:12px;line-height:1.5;border-radius:6px;color:var(--send-warning-text);background:var(--send-warning-bg);border:1px solid var(--send-warning-border)}verdocs-send .warning>.icon{-ms-flex:0 0 18px;flex:0 0 18px;width:18px;height:18px;margin-top:1px;color:var(--send-warning-icon)}verdocs-send .warning>.icon svg{width:18px;height:18px;display:block}verdocs-send .warning a{color:var(--send-accent);font-weight:500;text-decoration:none;border-bottom:1px solid var(--send-accent-tint-2)}verdocs-send .warning a .icon,verdocs-send .warning a .icon svg{width:11px;height:11px;display:inline-block;vertical-align:-1px;margin-left:2px}verdocs-send verdocs-checkbox{display:block;padding:4px 0;font-size:13px}'};var chevronRightIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 6 6 6-6 6"/></svg>';var chevronLeftIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m15 18-6-6 6-6"/></svg>';var warningIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><path d="M12 9v4M12 17h.01"/></svg>';var infoIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/></svg>';var externalLinkIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6M10 14 21 3M21 14v7H3V3h7"/></svg>';var VERDOCS_LOGO_URL="https://app.verdocs.com/assets/blue-logo.svg";var SWIPE_START_FRACTION=.25;var SWIPE_MIN_DISTANCE=60;var SWIPE_MAX_DURATION=500;var MIN_EXPIRY_DAYS=1;var MAX_EXPIRY_DAYS=120;var DEFAULT_EXPIRY_DAYS=120;var AUTH_METHOD_LABELS={email:"Email",passcode:"Passcode",sms:"SMS",kba:"KBA",id:"ID check"};var VerdocsSend=function(){function e(e){registerInstance(this,e);this.beforeSend=createEvent(this,"beforeSend");this.send=createEvent(this,"send");this.exit=createEvent(this,"exit");this.sdkError=createEvent(this,"sdkError");this.searchContacts=createEvent(this,"searchContacts");this.templateListenerId=null;this.endpoint=DefaultEndpoint;this.templateId=null;this.environment="";this.showCancel=true;this.brandKey="";this.swipeStart=null;this.swallowNextClick=false;this.loadedOrganizationId="";this.containerId="verdocs-send-".concat(Math.random().toString(36).substring(2,11));this.view="main";this.editingRoleId="";this.sessionContacts=[];this.sending=false;this.brands=[];this.organization=null;this.expiresInDays="";this.noContact=false;this.senderDefaults={name:"",email:""};this.senderName="";this.senderEmail="";this.rolesCompleted={};this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.componentDidLoad=function(){var e=this;this.el.addEventListener("click",(function(t){if(e.swallowNextClick){e.swallowNextClick=false;t.stopPropagation();t.preventDefault()}}),true)};e.prototype.componentDidRender=function(){var e,t;updateScrollFade(this.el.querySelector(".detail-body"));(e=this.el.querySelector(".main-pane"))===null||e===void 0?void 0:e.toggleAttribute("inert",this.view!=="main");(t=this.el.querySelector(".detail-pane"))===null||t===void 0?void 0:t.toggleAttribute("inert",this.view==="main")};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[SEND] Loading template",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),true,(function(t){console.log("[SEND] Got new template",t);e.template=t;e.loading=false;e.rolesCompleted={};e.view="main";e.editingRoleId="";e.recomputeRolesCompleted();e.loadBrands()}));return[2]}))}))};e.prototype.loadBrands=function(){var e=this;var t;var n=(t=this.template)===null||t===void 0?void 0:t.organization_id;if(!n||n===this.loadedOrganizationId){return}var i=!!this.loadedOrganizationId;this.loadedOrganizationId=n;this.brands=[];this.organization=null;if(i){this.brandKey=""}var r=function(){var t;return((t=e.template)===null||t===void 0?void 0:t.organization_id)===n};getBrands(this.endpoint,n).then((function(t){if(r()){e.brands=t||[]}})).catch((function(e){return console.log("[SEND] Unable to load brands",e)}));getOrganization(this.endpoint,n).then((function(t){if(r()){e.organization=t}})).catch((function(e){return console.log("[SEND] Unable to load organization",e)}))};e.prototype.handleExpiryInput=function(e){var t=(e.target.value||"").replace(/[^0-9]/g,"");this.expiresInDays=t?String(Math.min(Math.max(Number(t),MIN_EXPIRY_DAYS),MAX_EXPIRY_DAYS)):"";e.target.value=this.expiresInDays};e.prototype.effectiveExpiryDays=function(){var e=Number(this.expiresInDays);return e>=MIN_EXPIRY_DAYS?e:DEFAULT_EXPIRY_DAYS};e.prototype.expiresAt=function(){return new Date(Date.now()+this.effectiveExpiryDays()*24*60*60*1e3)};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.reset=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.rolesCompleted={};this.view="main";this.editingRoleId="";this.brandKey="";this.expiresInDays="";this.noContact=false;this.senderName="";this.senderEmail="";return[2]}))}))};e.prototype.effectiveSenderName=function(){return this.senderName||this.senderDefaults.name};e.prototype.effectiveSenderEmail=function(){return this.senderEmail||this.senderDefaults.email};e.prototype.senderOverrides=function(){var e=this.senderName.trim();var t=this.senderEmail.trim();return{sender_name:e&&e!==this.senderDefaults.name?e:undefined,sender_email:t&&t!==this.senderDefaults.email?t:undefined}};e.prototype.onTemplateIdChanged=function(e){console.log("[SEND] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;var i=this;return __generator(this,(function(r){try{this.endpoint.onSessionChanged((function(e,t,n){if(!n){return}var r={id:n.id,first_name:n.first_name,last_name:n.last_name,email:n.email,phone:n.phone};if(n){i.senderDefaults={name:formatFullName(n),email:n.email||""};i.sessionContacts=[r];getOrganizationContacts(i.endpoint).then((function(e){console.log("[SEND] Got contacts",e);i.sessionContacts=__spreadArray(__spreadArray([],e,true),[r],false)})).catch((function(e){console.log("[SEND] Error getting contacts",e)}))}}));this.endpoint.loadSession();if(!this.endpoint.session){console.log("[SEND] Unable to start Send operation, must be authenticated");return[2]}if(!this.templateId){console.log("[SEND] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(i){console.log("[SEND] Error with send session",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,(n=i.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.recomputeRolesCompleted=function(){var e=this;var t;this.rolesCompleted={};var n={};(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).forEach((function(t){var i=t.sequence;n[i]||(n[i]=[]);var r="r-".concat(i,"-").concat(n[i].length);n[i].push(__assign(__assign({},t),{id:r,role_name:t.name,first_name:t.first_name,last_name:t.last_name}));if(t.first_name&&isValidEmail(t.email)){e.rolesCompleted[r]=__assign(__assign({},t),{id:r,role_name:t.name,first_name:t.first_name,last_name:t.last_name})}}))};e.prototype.getSequenceNumbers=function(){var e;var t={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((function(e){t[e.sequence]=true}));return Object.keys(t).map((function(e){return+e})).sort((function(e,t){return e-t}))};e.prototype.getRolesAtLevel=function(e){var t;var n=(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((function(t){return t.sequence===e})).map((function(t,n){return __assign(__assign({},t),{id:"r-".concat(e,"-").concat(n),role_name:t.name,first_name:t.first_name,last_name:t.last_name})}));return n};e.prototype.getRoleById=function(e){for(var t=0,n=this.getSequenceNumbers();t<n.length;t++){var i=n[t];var r=this.getRolesAtLevel(i).find((function(t){return t.id===e}));if(r){return r}}return null};e.prototype.getRecipientOptionLabels=function(e){if(!e){return[]}var t=(e.auth_methods||[]).filter((function(e){return e!=="email"})).map((function(e){return AUTH_METHOD_LABELS[e]||e}));if(e.delegator){t.push("May delegate")}if(e.name_locked){t.push("Name locked")}return t};e.prototype.getDefaultBrand=function(){var e;var t=(e=this.organization)===null||e===void 0?void 0:e.default_brand_id;return t&&this.brands.find((function(e){return e.id===t}))||null};e.prototype.getDefaultBrandLabel=function(){var e;var t=(e=this.getDefaultBrand())===null||e===void 0?void 0:e.name;return"Default (".concat(t||"Verdocs",")")};e.prototype.getSelectedBrandLabel=function(){var e=this;if(!this.brandKey){return this.getDefaultBrandLabel()}var t=this.brands.find((function(t){return t.key===e.brandKey}));return(t===null||t===void 0?void 0:t.name)||(t===null||t===void 0?void 0:t.key)||this.brandKey};e.prototype.showView=function(e){this.view=e};e.prototype.handleSelectContact=function(e,t){var n;e.preventDefault();this.rolesCompleted=__assign(__assign({},this.rolesCompleted),(n={},n[t.id]=__assign(__assign({},t),e.detail),n));this.editingRoleId="";this.view="main"};e.prototype.handleClickRole=function(e,t){e.stopPropagation();this.editingRoleId=t.id;this.view="recipient"};e.prototype.handleSend=function(e){var t=this;var n;if(this.sending){console.log("[SEND] Skipping duplicate send",e);return}console.log("[SEND] Sending",e);e.preventDefault();e.stopPropagation();this.sending=true;var i=Intl.DateTimeFormat().resolvedOptions();var r={template_id:this.templateId,name:((n=this.template)===null||n===void 0?void 0:n.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted),timezone:i.timeZone,locale:i.locale,expires_at:this.expiresAt().toISOString()};r.no_contact=this.noContact;var o=this.senderOverrides(),s=o.sender_name,a=o.sender_email;if(s){r.sender_name=s}if(a){r.sender_email=a}if(this.brandKey){r.brand_key=this.brandKey}var l=this.beforeSend.emit(__assign(__assign({},r),{name:r.name,template:this.template}));if(l.defaultPrevented){console.log("[SEND] Send cancelled by parent",r);this.sending=false;return}console.log("[SEND] Creating envelope",r);createEnvelope(this.endpoint,r).then((function(e){var n;console.log("[SEND] Send envelope",e);t.reset().catch((function(e){return console.log("Unknown Error",e)}));t.sending=false;(n=t.send)===null||n===void 0?void 0:n.emit(__assign(__assign({},r),{name:r.name,envelope_id:e.id,envelope:e}))})).catch((function(e){var n,i,r;console.log("[SEND] Send error",e);VerdocsToast(((i=(n=e.response)===null||n===void 0?void 0:n.data)===null||i===void 0?void 0:i.error)||"Error creating envelope, please try again later.");t.sending=false;(r=t.sdkError)===null||r===void 0?void 0:r.emit(e)}))};e.prototype.handleCancel=function(e){var t;e.stopPropagation();(t=this.exit)===null||t===void 0?void 0:t.emit()};e.prototype.handleSwipeStart=function(e){var t,n;this.swallowNextClick=false;var i=e.currentTarget;var r=i.getBoundingClientRect();var o=!!((n=(t=e.target)===null||t===void 0?void 0:t.closest)===null||n===void 0?void 0:n.call(t,"input, textarea, select, [contenteditable]"));if(this.view==="main"||o||e.clientX-r.left>r.width*SWIPE_START_FRACTION){this.swipeStart=null;return}this.swipeStart={x:e.clientX,y:e.clientY,time:Date.now()}};e.prototype.handleSwipeEnd=function(e){var t=this.swipeStart;this.swipeStart=null;if(!t){return}var n=e.clientX-t.x;var i=Math.abs(e.clientY-t.y);if(n>=SWIPE_MIN_DISTANCE&&n>i&&Date.now()-t.time<=SWIPE_MAX_DURATION){this.swallowNextClick=true;this.showView("main")}};e.prototype.renderDetailHeader=function(e){var t=this;return h("div",{class:"detail-header"},h("button",{type:"button",class:"back",onClick:function(){return t.showView("main")}},h("span",{class:"icon",innerHTML:chevronLeftIcon}),"Back"),h("div",{class:"detail-title"},e),h("div",{class:"detail-header-spacer"}))};e.prototype.renderDetailBody=function(e){return h("div",{class:"detail-body-wrap"},h("div",{class:"detail-body",onScroll:function(e){return updateScrollFade(e.target)}},e),h("div",{class:"scroll-fade"}))};e.prototype.renderDoneButton=function(){var e=this;return h("div",{class:"detail-footer"},h("verdocs-button",{label:"Done",size:"small",onClick:function(){return e.showView("main")}}))};e.prototype.renderRecipientView=function(){var e=this;var t;var n=this.getRoleById(this.editingRoleId);if(!n){return h("div",{class:"detail recipient-detail"},this.renderDetailHeader("Recipient"))}var i=getRoleIndex(this.template,n.role_name);return h("div",{class:"detail recipient-detail"},this.renderDetailHeader([h("span",{class:"role-dot",style:{backgroundColor:getRGBA(i)}}),n.role_name]),h("verdocs-contact-picker",{key:n.id,showCancel:false,onExit:function(){return e.showView("main")},onNext:function(t){return e.handleSelectContact(t,n)},contactSuggestions:this.sessionContacts,templateRole:(t=this.rolesCompleted[n.id])!==null&&t!==void 0?t:n,onSearchContacts:function(t){var n;return(n=e.searchContacts)===null||n===void 0?void 0:n.emit(t.detail)}}))};e.prototype.renderBrandSwatch=function(e,t){var n=(e===null||e===void 0?void 0:e.favicon_url)||(e===null||e===void 0?void 0:e.thumbnail_url)||(e?null:VERDOCS_LOGO_URL);if(n){return h("span",{class:"swatch logo"},h("img",{src:n,alt:""}))}return h("span",{class:"swatch",style:{backgroundColor:(e===null||e===void 0?void 0:e.primary_color)||"#4c56cb"}},t.substring(0,2).toUpperCase())};e.prototype.renderBrandOption=function(e,t,n,i){var r=this;return h("button",{type:"button",class:{option:true,selected:this.brandKey===e},onClick:function(){return r.brandKey=e}},h("span",{class:"radio"}),i,h("span",{class:"option-label"},t,h("small",null,n)))};e.prototype.renderBrandView=function(){var e=this;var t=this.getDefaultBrand();var n=this.brands.filter((function(e){return e.id!==(t===null||t===void 0?void 0:t.id)})).sort((function(e,t){return(e.name||e.key).localeCompare(t.name||t.key)}));var i=this.brands.length>0;return h("div",{class:"detail"},this.renderDetailHeader("Brand"),this.renderDetailBody([h("div",{class:"option-list"},this.renderBrandOption("",this.getDefaultBrandLabel(),"Organization default",this.renderBrandSwatch(t,(t===null||t===void 0?void 0:t.name)||"V")),n.length>0&&h("div",{class:"option-divider"}),n.map((function(t){return e.renderBrandOption(t.key,t.name||t.key,t.key,e.renderBrandSwatch(t,t.name||t.key))}))),!i&&h("p",{class:"hint"},"Configure the look and feel of the signing experience by"," ",h("a",{href:"".concat(getWebAppUrl(this.endpoint),"/settings/branding"),target:"_blank",rel:"noopener"},"Creating a Brand",h("span",{class:"icon",innerHTML:externalLinkIcon})),".")]),this.renderDoneButton())};e.prototype.renderExpiresView=function(){var e=this;var t=this.expiresAt();var n="".concat(t.toLocaleDateString(undefined,{month:"short",day:"numeric",year:"numeric"})," at ").concat(t.toLocaleTimeString(undefined,{hour:"numeric",minute:"2-digit"}));return h("div",{class:"detail"},this.renderDetailHeader("Expiration"),this.renderDetailBody([h("div",{class:"expires-field"},h("input",{type:"text",inputMode:"numeric","aria-label":"Expires in (days)",placeholder:String(DEFAULT_EXPIRY_DAYS),value:this.expiresInDays,disabled:this.sending,onInput:function(t){return e.handleExpiryInput(t)}}),h("span",{class:"suffix"},"days")),h("p",{class:"hint"},"This envelope will expire on ",n,". Expirations may be set from ",MIN_EXPIRY_DAYS,"-",MAX_EXPIRY_DAYS," days. If left blank, this will default to ",DEFAULT_EXPIRY_DAYS,".")]),this.renderDoneButton())};e.prototype.renderSenderView=function(){var e=this;var t=!this.senderEmail.trim()||isValidEmail(this.senderEmail.trim());return h("div",{class:"detail"},this.renderDetailHeader("Sender"),this.renderDetailBody([h("div",{class:"sender-field"},h("label",{htmlFor:"".concat(this.containerId,"-sender-name")},"Name"),h("input",{id:"".concat(this.containerId,"-sender-name"),type:"text",value:this.effectiveSenderName(),disabled:this.sending,onInput:function(t){return e.senderName=t.target.value}})),h("div",{class:"sender-field"},h("label",{htmlFor:"".concat(this.containerId,"-sender-email")},"Email"),h("input",{id:"".concat(this.containerId,"-sender-email"),type:"email",value:this.effectiveSenderEmail(),disabled:this.sending,onInput:function(t){return e.senderEmail=t.target.value}}),!t&&h("div",{class:"field-error"},"Enter a valid email address.")),h("div",{class:"notice"},h("span",{class:"icon",innerHTML:infoIcon}),h("div",null,'Specify where envelope-completed email notifications and "Ask a Question" submissions are delivered. To customize the "From" address for email notifications, please configure those in'," ",h("a",{href:"".concat(getWebAppUrl(this.endpoint),"/settings/brands"),target:"_blank",rel:"noopener"},"Brands",h("span",{class:"icon",innerHTML:externalLinkIcon}))," ","."))]),this.renderDoneButton())};e.prototype.renderNotificationsView=function(){var e=this;return h("div",{class:"detail"},this.renderDetailHeader("Notifications"),this.renderDetailBody([h("verdocs-checkbox",{size:"small",label:"Disable notifications",checked:this.noContact,onInput:function(t){return e.noContact=!!t.target.checked}}),this.noContact&&h("div",{class:"warning"},h("span",{class:"icon",innerHTML:warningIcon}),h("div",null,"Disabling notifications turns off invitations and reminders to recipients as well as status updates to you. You may obtain invite links in the recipient summary or via an API call. We strongly recommend enabling"," ",h("a",{href:"".concat(getWebAppUrl(this.endpoint),"/settings/webhooks"),target:"_blank",rel:"noopener"},"Webhooks",h("span",{class:"icon",innerHTML:externalLinkIcon}))," ","to help automate this process."))]),this.renderDoneButton())};e.prototype.renderDetail=function(){switch(this.view){case"recipient":return this.renderRecipientView();case"brand":return this.renderBrandView();case"expires":return this.renderExpiresView();case"notifications":return this.renderNotificationsView();case"sender":return this.renderSenderView();default:return null}};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,{style:{display:"flex"}},h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var n=this.getSequenceNumbers();var i=Object.values(this.rolesCompleted).filter((function(e){return isValidEmail(e.email)&&e.first_name&&e.last_name}));var r=i.length>=getRoleNames(this.template).length;var o=i.map((function(e){return e.email.toLowerCase()}));var s=new Set(o).size<o.length;var a=this.expiresAt();var l=a.toLocaleDateString(undefined,{month:"short",day:"numeric"});return h(Host,{class:{sendable:(t=this.template)===null||t===void 0?void 0:t.is_sendable,"detail-open":this.view!=="main"}},h("div",{class:"track"},h("div",{class:"pane main-pane","aria-hidden":this.view!=="main"?"true":"false"},h("div",{class:"section-title"},"Recipients"),h("div",{class:"recipients"},n.map((function(t){return[n.length>1&&h("div",{class:"step"},"Step ",t),e.getRolesAtLevel(t).map((function(t){var n=getRoleIndex(e.template,t.role_name);var r=e.rolesCompleted[t.id];var o=r&&i.findIndex((function(e){return e.role_name===t.role_name}))>-1;var s=e.getRecipientOptionLabels(r);return h("button",{type:"button",class:"recipient","data-ri":n,"data-rn":t.role_name,onClick:function(n){return e.handleClickRole(n,t)}},h("span",{class:"role-dot",style:{backgroundColor:getRGBA(n)}}),h("span",{class:"who"},h("span",{class:"role-name"},t.role_name),o?h("span",{class:"who-detail"},formatFullName(r)," · ",r.email):h("span",{class:"who-detail configure"},"Configure recipient"),s.length>0&&h("span",{class:"options"},s.map((function(e){return h("span",{class:"pill"},e)})))),h("span",{class:"chevron",innerHTML:chevronRightIcon}))}))]}))),h("div",{class:"section-title delivery-title"},"Delivery"),h("div",{class:"delivery"},h("button",{type:"button",class:"kv",onClick:function(){return e.showView("brand")},disabled:this.sending},h("span",{class:"key"},"Brand"),h("span",{class:"value"},this.getSelectedBrandLabel()),h("span",{class:"chevron",innerHTML:chevronRightIcon})),h("button",{type:"button",class:"kv",onClick:function(){return e.showView("expires")},disabled:this.sending},h("span",{class:"key"},"Expires"),h("span",{class:"value"},this.effectiveExpiryDays()," days ",h("small",null,"· ",l)),h("span",{class:"chevron",innerHTML:chevronRightIcon})),h("button",{type:"button",class:"kv",onClick:function(){return e.showView("sender")},disabled:this.sending},h("span",{class:"key"},"Sender"),h("span",{class:"value stacked"},h("span",{class:"line"},this.effectiveSenderName()||this.effectiveSenderEmail()),this.effectiveSenderName()&&this.effectiveSenderEmail()?h("small",{class:"line"},this.effectiveSenderEmail()):null),h("span",{class:"chevron",innerHTML:chevronRightIcon})),h("button",{type:"button",class:"kv",onClick:function(){return e.showView("notifications")},disabled:this.sending},h("span",{class:"key"},"Notifications"),h("span",{class:{value:true,off:this.noContact}},this.noContact?"Off":"On"),h("span",{class:"chevron",innerHTML:chevronRightIcon}))),h("div",{class:"main-spacer"}),h("div",{class:"buttons"},s&&h("div",{class:"error-message"},"Recipients cannot share the same email."),this.sending&&h("verdocs-spinner",null),this.showCancel&&h("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:function(t){return e.handleCancel(t)},disabled:this.sending}),h("verdocs-button",{label:"Send",size:"small",disabled:!r||this.sending||s,onClick:function(t){return e.handleSend(t)}}))),h("div",{class:"pane detail-pane","aria-hidden":this.view==="main"?"true":"false",onPointerDown:function(t){return e.handleSwipeStart(t)},onPointerUp:function(t){return e.handleSwipeEnd(t)},onPointerCancel:function(){return e.swipeStart=null}},this.renderDetail())))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{templateId:[{onTemplateIdChanged:0}]}},enumerable:false,configurable:true});return e}();VerdocsSend.style=verdocsSendCss();var verdocsTemplateAttachmentsCss=function(){return'verdocs-template-attachments{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-template-attachments h5{font-size:16px;font-weight:bold;margin:0 0 10px 0;color:#46497d}verdocs-template-attachments .attachments{margin:0 0 40px 0}verdocs-template-attachments .attachment{display:-ms-flexbox;display:flex;padding:5px 0;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#33364b}verdocs-template-attachments .attachment:hover .trash-icon{display:-ms-flexbox;display:flex}verdocs-template-attachments .attachment:hover .pages{display:none}verdocs-template-attachments svg{width:28px;height:28px;fill:#5c6575;margin:2px 0 0 0}verdocs-template-attachments .file-icon{-ms-flex:0;flex:0}verdocs-template-attachments .pages{width:24px;height:24px;-ms-flex:0 0 24px;flex:0 0 24px;padding-left:4px;position:relative;margin:-10px 0 0 0}verdocs-template-attachments .pages .pages-icon{top:0;left:0;width:24px;height:24px;position:absolute}verdocs-template-attachments .pages .count{top:11px;left:7px;z-index:1;width:18px;font-size:12px;font-weight:500;position:absolute;text-align:center;letter-spacing:-2px}verdocs-template-attachments .filename{-ms-flex:1;flex:1;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;border-bottom:1px dotted #cccccc}verdocs-template-attachments .trash-icon{-ms-flex:0;flex:0;display:none}verdocs-template-attachments .trash-icon:hover{cursor:pointer}verdocs-template-attachments verdocs-file-chooser{margin:10px 0;border:2px dashed #979797}verdocs-template-attachments .loader-wrapper{background-color:#ffffff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:320px;height:320px;text-align:center;border:2px dashed #979797;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .progress-wrapper{padding:20px}verdocs-template-attachments .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-attachments .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-attachments ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-moz-placeholder{color:#aaaaaa}verdocs-template-attachments :-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::placeholder{color:#aaaaaa}'};var VerdocsTemplateAttachments=function(){function e(e){registerInstance(this,e);this.exit=createEvent(this,"exit");this.next=createEvent(this,"next");this.templateUpdated=createEvent(this,"templateUpdated");this.sdkError=createEvent(this,"sdkError");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.uploading=false;this.progressLabel="Uploading...";this.progressPercent=0;this.showDeleteError=false;this.confirmDeleteDocument=null;this.loading=true;this.template=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(i){try{this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(i){console.log("[TEMPLATE ATTACHMENTS] 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,(n=i.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.handleCancel=function(e){e.stopPropagation();this.exit.emit()};e.prototype.handleUploadProgress=function(e){if(e>=99){this.progressPercent=100;this.progressLabel="Processing..."}else{this.progressPercent=e}};e.prototype.handleUpload=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,i,r,o,s,a,l;return __generator(this,(function(d){switch(d.label){case 0:e.stopPropagation();o=e.detail.file;if(!o){return[2]}console.log("[ATTACHMENTS] Uploading...",o);this.uploading=true;this.progressLabel="Uploading...";d.label=1;case 1:d.trys.push([1,4,,5]);return[4,createTemplateDocument(this.endpoint,this.templateId,o,this.handleUploadProgress.bind(this))];case 2:s=d.sent();console.log("[ATTACHMENTS] Created attachment",s);a=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 3:a.template=d.sent();console.log("[ATTACHMENTS] Updated template",this.template);(t=this.templateUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,template:this.template,event:"attachments"});this.uploading=false;this.progressLabel="";this.progressPercent=0;return[3,5];case 4:l=d.sent();console.log("[ATTACHMENTS] Error creating template",l);(n=this.sdkError)===null||n===void 0?void 0:n.emit(new SDKError(l.message,(i=l.response)===null||i===void 0?void 0:i.status,(r=l.response)===null||r===void 0?void 0:r.data));this.uploading=false;return[3,5];case 5:return[2]}}))}))};e.prototype.handleNext=function(e){var t;e.stopPropagation();this.uploading=false;this.progressLabel="";this.progressPercent=0;(t=this.next)===null||t===void 0?void 0:t.emit({template:this.template})};e.prototype.confirmDelete=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,deleteTemplateDocument(this.endpoint,this.confirmDeleteDocument.id)];case 1:t.sent();e=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 2:e.template=t.sent();console.log("[ATTACHMENTS] New template",this.template);this.confirmDeleteDocument=null;return[2]}}))}))};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(n){if((((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>1){this.confirmDeleteDocument=e}else{this.showDeleteError=true}return[2]}))}))};e.prototype.getFileIcon=function(e){switch(e.mime){case"application/pdf":return PdfIcon;case"image/jpeg":return JpgIcon;case"image/png":return PngIcon;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return DocIcon}return FileIcon};e.prototype.render=function(){var e=this;var t,n;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading){return h(Host,{class:"loading"},h("verdocs-loader",null))}if(!this.endpoint.session||!this.template){return h(Host,{class:"empty"})}return h(Host,null,h("h5",null,"Existing Attachments"),h("div",{class:"attachments"},(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){return h("div",{class:"attachment"},h("div",{class:"file-icon",innerHTML:e.getFileIcon(t)}),h("div",{class:"filename",title:t.name},t.name),h("div",{class:"pages"},h("div",{class:"count"},t.pages),h("div",{class:"pages-icon",innerHTML:PageCountIcon})),h("div",{class:"trash-icon",innerHTML:TrashIcon,onClick:function(){return e.handleDelete(t)}}))}))),h("h5",null,"Attach a New Document"),this.uploading?h("div",{class:"loader-wrapper"},h("verdocs-loader",null),this.progressLabel&&h("div",{class:"progress-wrapper"},h("verdocs-progress-bar",{showPercent:true,percent:this.progressPercent,label:this.progressLabel}))):h("verdocs-file-chooser",{onFileSelected: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)},disabled:this.uploading}),h("verdocs-button",{label:"Next",size:"small",onClick:function(t){return e.handleNext(t)},disabled:!(((n=this.template)===null||n===void 0?void 0:n.documents)||[]).length||this.uploading})),this.showDeleteError&&h("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:function(){return e.showDeleteError=false}}),this.confirmDeleteDocument&&h("verdocs-ok-dialog",{heading:"Delete this Attachment?",message:"This operation cannot be undone. All fields placed<br />on the deleted attachment will also be removed.",onNext:function(){return e.confirmDelete()},showCancel:true,onExit:function(){e.confirmDeleteDocument=null}}))};return e}();VerdocsTemplateAttachments.style=verdocsTemplateAttachmentsCss();var verdocsTemplateBuildTabsCss=function(){return'verdocs-template-build-tabs{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:end;align-items:flex-end;-ms-flex:0 0 50px;flex:0 0 50px;width:100%;background:#ffffff;color:#72757d;border-bottom:1px solid #dddddd;-webkit-filter:drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));filter:drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-template-build-tabs .tab{position:relative;display:-ms-flexbox;display:flex;-ms-flex:1;flex:1;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;height:50px;padding:0 4px;background:#e7e7e7;font-weight:700;font-size:12px;cursor:pointer}@media (min-width: 768px){verdocs-template-build-tabs .tab{padding:0 8px 0 24px;font-size:14px}}verdocs-template-build-tabs .tab svg{position:absolute;top:0;right:-19px;z-index:10;pointer-events:none;display:none}@media (min-width: 768px){verdocs-template-build-tabs .tab svg{display:block}}verdocs-template-build-tabs .tab.active{background:#ffffff;color:#707ae5}verdocs-template-build-tabs .tab.disabled{cursor:default;color:#d1d5db}'};var VerdocsTemplateBuildTabs=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.stepChanged=createEvent(this,"stepChanged");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.step="preview";this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[BUILD_TABS] Template ID changed",e);this.listenToTemplate()};e.prototype.onStepChanged=function(e){console.log("[BUILD_TABS] Step changed",e)};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(i){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){this.step="attachments";console.log("[BUILD_TABS] Missing required template ID, forcing view to attachments");return[2]}this.listenToTemplate()}catch(i){console.log("[BUILD_TABS] 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,(n=i.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.handleSelect=function(e){var t;if(e.disabled||e.id===this.step){return}this.step=e.id;(t=this.stepChanged)===null||t===void 0?void 0:t.emit(e.id)};e.prototype.render=function(){var e=this;var t,n,i;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var r=(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>0;var o=r&&(((n=this.template)===null||n===void 0?void 0:n.roles)||[]).length>0;var s=o&&(((i=this.template)===null||i===void 0?void 0:i.fields)||[]).length>0;var a=[{id:"attachments",label:"Attachments",disabled:false},{id:"roles",label:"Workflow",disabled:!r},{id:"fields",label:"Fields",disabled:!o},{id:"preview",label:"Preview & Send",disabled:!s}];return h(Host,null,a.map((function(t){var n=t.id===e.step;var i=["tab"];if(n)i.push("active");if(t.disabled)i.push("disabled");return h("div",{class:i.join(" "),onClick:function(){return e.handleSelect(t)}},h("span",null,t.label),h("svg",{"aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"19",height:"50",viewBox:"0 0 19 50"},h("polygon",{points:"0,0 19,25 0,50",fill:n?"#ffffff":"#e7e7e7"})))})))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:[{onTemplateIdChanged:0}],step:[{onStepChanged:0}]}},enumerable:false,configurable:true});return e}();VerdocsTemplateBuildTabs.style=verdocsTemplateBuildTabsCss();var verdocsTemplateFieldsCss=function(){return"verdocs-template-fields{font-family:var(--verdocs-primary-font, \"Inter\", \"Barlow\", sans-serif);position:relative;display:block;min-height:600px}verdocs-template-fields .verdocs-field-selected{outline:2px solid rgba(101, 77, 203, 0.75);outline-offset:1px}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 rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294)}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 .pages .document-separator{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:10px;padding:12px 20px;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:#33364b;color:white;border-radius:6px;font-size:16px;font-weight:500;margin-top:20px;-webkit-box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);box-shadow:0 2px 4px rgba(0, 0, 0, 0.1)}verdocs-template-fields .pages .document-separator svg{-ms-flex-negative:0;flex-shrink:0}verdocs-template-fields .pages .document-separator:first-child{margin-top:0}verdocs-template-fields #verdocs-template-fields-toolbar{width:100%;height:50px;display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;font-weight:700;padding:0 20px 0 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#f5f5fa;-ms-flex-pack:center;justify-content:center;background:#46497d}verdocs-template-fields #verdocs-template-fields-toolbar>verdocs-select-input{margin:0}verdocs-template-fields #verdocs-template-fields-toolbar svg{width:24px;height:24px}verdocs-template-fields #verdocs-template-fields-toolbar .add-for{margin:0;font-weight:500;color:#f5f5fa}verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{margin:0 20px 0 0}@media all and (max-width: 1000px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;padding:0 10px 0 0}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}@media all and (max-width: 600px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:6px;-moz-column-gap:6px;column-gap:6px}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.6);transform:scale(0.6)}verdocs-template-fields #verdocs-template-fields-toolbar .separator,verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}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 fill='%23000000' 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'/%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' stroke-width='1.5' stroke='currentColor'%3E%3Cpath stroke='%23000000' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25' /%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 width='32' height='15' viewBox='0 0 32 15' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cmask id='path-1-inside-1_1401_24' fill='white'%3E%3Cpath d='M0 0H32V15H0V0Z'/%3E%3C/mask%3E%3Cpath d='M0 0H32V15H0V0Z' fill='%234C56CB' fill-opacity='0.1'/%3E%3Cpath d='M0 0V-1H-1V0H0ZM0 15H-1V16H0V15ZM0 1H32V-1H0V1ZM32 14H0V16H32V14ZM1 15V0H-1V15H1Z' fill='%234C56CB' mask='url(%23path-1-inside-1_1401_24)'/%3E%3Cpath d='M3 11.8V8.65H14.15V11.8H3ZM3 6.65V3.5H20.15V6.65H3Z' fill='%234C56CB'/%3E%3Cline x1='31.5' y1='1' x2='31.5' y2='14' stroke='%234C56CB' stroke-opacity='0.32' stroke-dasharray='1 1'/%3E%3C/svg%3E%0A\") 0 14, 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 fill='%23000000' d='M9 1h6v2H9zm10.03 6.39 1.42-1.42c-.43-.51-.9-.99-1.41-1.41l-1.42 1.42C16.07 4.74 14.12 4 12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9 9-4.03 9-9c0-2.12-.74-4.07-1.97-5.61zM13 14h-2V8h2v6z'%3E%3C/path%3E%3C/svg%3E\") 16 16, pointer}"};var iconTextbox='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M3.425 16.15V13h11.15v3.15Zm0-5.15V7.85h17.15V11Z"/></svg>';var iconCheck='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" 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 fill="#ffffff" 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 fill="#ffffff" 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 fill="#ffffff" 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 fill="#ffffff" d="M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z"/></svg>';var iconDropdown='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" stroke-width="1.5" stroke="currentColor"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" d="M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25" /></svg>';var iconAttachment='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"><path stroke-linecap="round" stroke-linejoin="round" d="m18.375 12.739-7.693 7.693a4.5 4.5 0 0 1-6.364-6.364l10.94-10.94A3 3 0 1 1 19.5 7.372L8.552 18.32m.009-.01-.01.01m5.699-9.941-7.81 7.81a1.5 1.5 0 0 0 2.112 2.13" /></svg>';var separator='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.707 14.707"><g><rect x="6.275" y="0" fill="#ffffff7f" width="1" height="15"/></g></svg>';var GEOMETRY_KEYS=["x","y","width","height","page","multiline"];var NUDGE_SAVE_DELAY_MS=400;var MAX_UNDO=50;var isTypingTarget=function(e){return!!e&&(["INPUT","TEXTAREA","SELECT"].includes(e.tagName)||e.isContentEditable)};var menuOptions=[{id:"signature",tooltip:"Signature",icon:iconSignature,class:"signature"},{id:"initial",tooltip:"Initials",icon:iconInitial,class:"initial"},{id:"sep1",tooltip:"",icon:separator,class:"separator"},{id:"textbox",tooltip:"Text Box",icon:iconTextbox,class:"textbox"},{id:"checkbox",tooltip:"Check Box",icon:iconCheck,class:"checkbox"},{id:"radio",tooltip:"Radio Button",icon:iconRadio,class:"radio"},{id:"dropdown",tooltip:"Dropdown",icon:iconDropdown,class:"dropdown"},{id:"sep2",tooltip:"",icon:separator,class:"separator"},{id:"date",tooltip:"Date",icon:iconDatepicker,class:"date"},{id:"attachment",tooltip:"Attachment",icon:iconAttachment,class:"attachment"}];var VerdocsTemplateFields=function(){function e(e){var t=this;registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.templateUpdated=createEvent(this,"templateUpdated");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.toolbarTargetId=null;this.placing=null;this.showMustSelectRole=false;this.selectedRoleName="";this.loading=true;this.template=null;this.pageHeights={};this.selectedFieldName=null;this.undoStack=[];this.pendingNudge=null;this.nudgeTimer=null;this.dragBefore=null;this.optimistic=new Map;this.inFlight=new Set;this.pendingResizes=new Map;this.handleFieldTap=function(e){var n,i;return t.selectField(((i=(n=e.currentTarget)===null||n===void 0?void 0:n.getAttribute)===null||i===void 0?void 0:i.call(n,"fieldname"))||null)};this.handleFieldResizeStart=function(e){var n,i;var r=((i=(n=e.target)===null||n===void 0?void 0:n.getAttribute)===null||i===void 0?void 0:i.call(n,"fieldname"))||null;t.flushNudge();t.selectField(r);t.startResize(r)};this.cachedPageInfo={}}e.prototype.onTemplateIdChanged=function(){this.listenToTemplate()};e.prototype.handleKeyDown=function(e){var t,n;if(e.key==="Escape"){this.placing=null;this.selectField(null);return}var i=((t=e.composedPath)===null||t===void 0?void 0:t.call(e)[0])||e.target;if(e.defaultPrevented||isTypingTarget(i)){return}if(i!==document.body&&i!==document.documentElement&&!this.el.contains(i)){return}if((e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="z"){if(this.pendingNudge||this.undoStack.length>0||this.inFlight.size>0||this.pendingResizes.size>0){e.preventDefault();this.undo()}return}var r=e.shiftKey?10:1;var o={ArrowLeft:[-r,0],ArrowRight:[r,0],ArrowUp:[0,r],ArrowDown:[0,-r]}[e.key];if(!o||!this.selectedFieldName||e.metaKey||e.ctrlKey||e.altKey){return}var s=this.findField(this.selectedFieldName);var a=s?(n=document.getElementById(getFieldId(s)))===null||n===void 0?void 0:n.getBoundingClientRect():null;if(!a||a.bottom<0||a.top>window.innerHeight||a.right<0||a.left>window.innerWidth){this.selectField(null);return}e.preventDefault();this.nudge(o[0],o[1])};e.prototype.handleFieldSettingsChanged=function(e){var t;var n=e.detail||{},i=n.fieldName,r=n.field;if(r&&i&&r.name!==i){this.renameFieldState(i,r.name)}var o=r?this.pendingResizes.get(r.name):null;if(o){this.recordUndo(r.name,o.before,r);o.settle()}(t=this.templateUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,template:this.template,event:"updated-field"})};e.prototype.handleFieldDeleted=function(e){var t,n;var i=(t=e.detail)===null||t===void 0?void 0:t.fieldName;if(i){this.forgetField(i)}(n=this.templateUpdated)===null||n===void 0?void 0:n.emit({endpoint:this.endpoint,template:this.template,event:"deleted-field"})};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(i){try{this.endpoint.loadSession();if(!this.templateId){console.log("[FIELDS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[FIELDS] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(i){console.log("[FIELDS] Error with fields session",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,(n=i.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.componentDidRender=function(){var e=this;interact.dynamicDrop(true);document.querySelectorAll(".verdocs-field").forEach((function(t){e.makeDraggable(t)}));var t=this.toolbarTargetId?document.getElementById(this.toolbarTargetId):null;var n=document.getElementById("verdocs-template-fields-toolbar");if(t&&n){n.remove();t.append(n)}this.applySelection()};e.prototype.componentWillUpdate=function(){var e=this;var t,n;var i=__spreadArray([],((t=this.template)===null||t===void 0?void 0:t.roles)||[],true).sort((function(e,t){var n,i;return((n=e.sequence)!==null&&n!==void 0?n:0)-((i=t.sequence)!==null&&i!==void 0?i:0)}));if(!this.selectedRoleName||!i.find((function(t){return t&&t.name===e.selectedRoleName}))){this.selectedRoleName=((n=i[0])===null||n===void 0?void 0:n.name)||"";console.log("[FIELDS] Selected new role",this.selectedRoleName)}};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate();this.flushNudge();this.selectField(null)};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){var n;console.log("Template updated");e.template=t;e.loading=false;if(!e.selectedRoleName){var i=__spreadArray([],t.roles||[],true).sort((function(e,t){var n,i;return((n=e.sequence)!==null&&n!==void 0?n:0)-((i=t.sequence)!==null&&i!==void 0?i:0)}));e.selectedRoleName=((n=i[0])===null||n===void 0?void 0:n.name)||""}}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.handlePageRendered=function(e){var t=this;var n,i;var r,o;var s=e.detail;console.log("[FIELDS] Page rendered",s.documentId,s.pageNumber,s.xScale,s.yScale);(n=(r=this.cachedPageInfo)[o=s.documentId])!==null&&n!==void 0?n:r[o]={};this.cachedPageInfo[s.documentId][s.pageNumber]=s;this.pageHeights[s.pageNumber]=s.naturalHeight;(((i=this.template)===null||i===void 0?void 0:i.fields)||[]).filter((function(e){return e&&e.page===s.pageNumber})).forEach((function(e){var n=getFieldId(e);var i=document.getElementById(n);if(i){i.setAttribute("templateid",t.templateId);i.setAttribute("fieldname",e.name);i.setAttribute("documentid",String(e.document_id));i.setAttribute("pagenumber",String(e.page));i.setAttribute("xScale",String(s.xScale));i.setAttribute("yScale",String(s.yScale));t.makeDraggable(i)}}))};e.prototype.makeDraggable=function(e){interact(e).draggable({listeners:{start:this.handleMoveStart.bind(this),move:this.handleMoveField.bind(this),end:this.handleMoveEnd.bind(this)}}).off("tap",this.handleFieldTap).on("tap",this.handleFieldTap).off("resizestart",this.handleFieldResizeStart).on("resizestart",this.handleFieldResizeStart)};e.prototype.findField=function(e){var t;return e?(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).find((function(t){return t.name===e})):undefined};e.prototype.currentGeometry=function(e){var t=__assign(__assign({},e),this.optimistic.get(e.name)),n=t.x,i=t.y,r=t.width,o=t.height,s=t.page,a=t.multiline;return{x:n,y:i,width:r,height:o,page:s,multiline:a}};e.prototype.selectField=function(e){if(this.pendingNudge&&this.pendingNudge.name!==e){this.flushNudge()}this.selectedFieldName=e;this.applySelection()};e.prototype.applySelection=function(){var e;document.querySelectorAll(".verdocs-field-selected").forEach((function(e){return e.classList.remove("verdocs-field-selected")}));var t=this.findField(this.selectedFieldName);if(t){(e=document.getElementById(getFieldId(t)))===null||e===void 0?void 0:e.classList.add("verdocs-field-selected")}};e.prototype.recordUndo=function(e,t,n){if(GEOMETRY_KEYS.some((function(e){return n[e]!==undefined&&n[e]!==t[e]}))){this.undoStack.push({name:e,before:t});this.undoStack.splice(0,Math.max(0,this.undoStack.length-MAX_UNDO))}};e.prototype.startResize=function(e){var t=this;var n;var i=this.findField(e);if(!i){return}(n=this.pendingResizes.get(i.name))===null||n===void 0?void 0:n.settle();var r;var o=new Promise((function(e){return r=e}));var s={before:this.currentGeometry(i),settle:function(){return r()},done:o};this.pendingResizes.set(i.name,s);var a=setTimeout((function(){return s.settle()}),5e3);o.then((function(){clearTimeout(a);if(t.pendingResizes.get(i.name)===s){t.pendingResizes.delete(i.name)}}))};e.prototype.renameFieldState=function(e,t){this.undoStack.forEach((function(n){return n.name===e&&(n.name=t)}));if(this.selectedFieldName===e){this.selectedFieldName=t}};e.prototype.forgetField=function(e){var t,n;this.undoStack=this.undoStack.filter((function(t){return t.name!==e}));this.optimistic.delete(e);(t=this.pendingResizes.get(e))===null||t===void 0?void 0:t.settle();if(((n=this.pendingNudge)===null||n===void 0?void 0:n.name)===e){clearTimeout(this.nudgeTimer);this.nudgeTimer=null;this.pendingNudge=null}if(this.selectedFieldName===e){this.selectField(null)}};e.prototype.drawField=function(e,t){if(t===void 0){t={}}var n,i;var r=(n=this.cachedPageInfo[e.document_id])===null||n===void 0?void 0:n[(i=t.page)!==null&&i!==void 0?i:e.page];var o=document.getElementById(getFieldId(e));if(o&&r){setControlStyles(o,__assign(__assign({},e),t),r.xScale,r.yScale)}};e.prototype.nudge=function(e,t){var n=this;var i,r,o,s,a;var l=this.findField(this.selectedFieldName);if(!l||!document.getElementById(getFieldId(l))||!((i=this.cachedPageInfo[l.document_id])===null||i===void 0?void 0:i[l.page])){return}if(((r=this.pendingNudge)===null||r===void 0?void 0:r.name)!==l.name){this.flushNudge();var d=this.currentGeometry(l);this.pendingNudge={name:l.name,before:d,x:d.x,y:d.y}}var c=(a=(s=(((o=this.template)===null||o===void 0?void 0:o.documents)||[]).find((function(e){return e.id===l.document_id})))===null||s===void 0?void 0:s.page_sizes)===null||a===void 0?void 0:a[l.page];var u=((c===null||c===void 0?void 0:c.width)||612)-(l.width||defaultWidth(l.type));var h=((c===null||c===void 0?void 0:c.height)||792)-(l.height||defaultHeight(l.type));this.pendingNudge.x=Math.min(Math.max(this.pendingNudge.x+e,0),u);this.pendingNudge.y=Math.min(Math.max(this.pendingNudge.y+t,0),h);this.drawField(l,{x:this.pendingNudge.x,y:this.pendingNudge.y});if(this.nudgeTimer){clearTimeout(this.nudgeTimer)}this.nudgeTimer=setTimeout((function(){return n.flushNudge()}),NUDGE_SAVE_DELAY_MS)};e.prototype.flushNudge=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:if(this.nudgeTimer){clearTimeout(this.nudgeTimer);this.nudgeTimer=null}e=this.pendingNudge;this.pendingNudge=null;if(!e)return[3,2];return[4,this.saveGeometry(e.name,{x:e.x,y:e.y},e.before)];case 1:t.sent();t.label=2;case 2:return[2]}}))}))};e.prototype.undo=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(i){switch(i.label){case 0:return[4,this.flushNudge()];case 1:i.sent();return[4,Promise.all(__spreadArray(__spreadArray([],this.inFlight,true),__spreadArray([],this.pendingResizes.values(),true).map((function(e){return e.done})),true))];case 2:i.sent();e=function(){var e,n,i,r;return __generator(this,(function(o){switch(o.label){case 0:e=t.undoStack.pop(),n=e.name,i=e.before;r=t.findField(n);if(!(r&&GEOMETRY_KEYS.some((function(e){return r[e]!==i[e]}))))return[3,2];t.selectField(n);return[4,t.saveGeometry(n,i)];case 1:o.sent();return[2,{value:void 0}];case 2:return[2]}}))};t=this;i.label=3;case 3:if(!(this.undoStack.length>0))return[3,5];return[5,e()];case 4:n=i.sent();if(typeof n==="object")return[2,n.value];return[3,3];case 5:return[2]}}))}))};e.prototype.saveGeometry=function(e,t,n){var i=this;var r=this.findField(e);if(!r){return Promise.resolve()}var o=__assign({},t);this.optimistic.set(e,o);this.drawField(r,t);var s=function(){return __awaiter(i,void 0,void 0,(function(){var i,r,s,a,l,d,c,u,h,f,v;return __generator(this,(function(p){switch(p.label){case 0:p.trys.push([0,2,3,4]);return[4,updateField(this.endpoint,this.templateId,e,t)];case 1:c=p.sent();u=JSON.parse(JSON.stringify(this.template));h=u.fields.findIndex((function(t){return t.name===e}));if(h>-1){u.fields[h]=c}Store.updateTemplate(this.templateId,u);this.drawField(c);if(n){this.recordUndo(e,n,c)}(i=this.templateUpdated)===null||i===void 0?void 0:i.emit({endpoint:this.endpoint,template:u,event:"updated-field"});return[3,4];case 2:f=p.sent();console.log("[FIELDS] Error saving field position",f);VerdocsToast(((s=(r=f.response)===null||r===void 0?void 0:r.data)===null||s===void 0?void 0:s.error)||"Unable to move the field. Please try again.",{style:"error"});(a=this.sdkError)===null||a===void 0?void 0:a.emit(new SDKError(f.message,(l=f.response)===null||l===void 0?void 0:l.status,(d=f.response)===null||d===void 0?void 0:d.data));v=this.findField(e);if(v){this.drawField(v)}return[3,4];case 3:if(this.optimistic.get(e)===o){this.optimistic.delete(e)}return[7];case 4:return[2]}}))}))}();this.inFlight.add(s);s.finally((function(){return i.inFlight.delete(s)}));return s};e.prototype.handleMoveStart=function(e){var t=e.target.getAttribute("fieldname");this.flushNudge();this.selectField(t);var n=this.findField(t);this.dragBefore=n?{name:t,before:this.currentGeometry(n)}:null};e.prototype.handleMoveField=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,i,r,o,s;return __generator(this,(function(a){t=+(e.target.getAttribute("posX")||0);n=+(e.target.getAttribute("posY")||0);i=+(e.target.getAttribute("xScale")||1);r=+(e.target.getAttribute("yScale")||1);o=e.dx/i+t;s=e.dy/r+n;e.target.setAttribute("posX",o);e.target.setAttribute("posy",s);updateCssTransform(e.target,"translate","".concat(o,"px, ").concat(s,"px"));return[2]}))}))};e.prototype.handleMoveEnd=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,i,r,o,s,a,l,d,c,u,h,f,v,p,g,m,x,b,w,E,_,S,y,k,I,C,T;return __generator(this,(function(D){switch(D.label){case 0:s=e.target.getAttribute("fieldname");a=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).find((function(e){return e.name===s}));if(!a){console.log("[FIELDS] Unable to find field",s,e.target);return[2]}l=e.target.getAttribute("pagenumber");d=e.target.getAttribute("documentid");c=this.cachedPageInfo[d][l],u=c.naturalWidth,h=u===void 0?612:u,f=c.naturalHeight,v=f===void 0?792:f,p=c.renderedHeight,g=p===void 0?792:p;m=e.target.getBoundingClientRect();x=e.target.parentElement;b=x.getBoundingClientRect();w=a.width||defaultWidth(a.type);E=a.height||defaultHeight(a.type);_=Math.max(m.left-b.left,0);S=Math.max(g-(b.bottom-m.bottom),0);y=parseInt(l);if(S>g){y=Math.min(y+1,((r=(i=((n=this.template)===null||n===void 0?void 0:n.documents)||[])===null||i===void 0?void 0:i[0])===null||r===void 0?void 0:r.pages)||1);S-=g;g=this.cachedPageInfo[d][y].renderedHeight;console.log("Next page",{newPageNumber:y,newY:S,renderedHeight:g})}else if(S<0){y=Math.max(y-1,1);g=this.cachedPageInfo[d][y].renderedHeight;S+=g;console.log("[FIELDS] Next page",{newPageNumber:y,newY:S,renderedHeight:g})}k=this.viewCoordinatesToPageCoordinates(_,S,d,l,h-w,v-E),I=k.x,C=k.y;e.target.removeAttribute("posX");e.target.removeAttribute("posY");removeCssTransform(e.target);T=((o=this.dragBefore)===null||o===void 0?void 0:o.name)===s?this.dragBefore.before:undefined;this.dragBefore=null;return[4,this.saveGeometry(s,{x:I,y:C,page:y},T)];case 1:D.sent();return[2]}}))}))};e.prototype.generateFieldName=function(e,t){var n;var i=1;var r;do{r="".concat(e,"P").concat(t,"-").concat(i);i++}while((((n=this.template)===null||n===void 0?void 0:n.fields)||[]).some((function(e){return e&&e.name===r})));return r};e.prototype.viewCoordinatesToPageCoordinates=function(e,t,n,i,r,o){var s=this.cachedPageInfo[n][i],a=s.xScale,l=a===void 0?1:a,d=s.yScale,c=d===void 0?1:d,u=s.renderedHeight,h=u===void 0?792:u;var f=Math.round(Math.min(e/l,r));var v=Math.round(Math.min(Math.max(h-t,0)/c,o));return{x:f,y:v}};e.prototype.handleClickPage=function(e,t,n){return __awaiter(this,void 0,void 0,(function(){var i,r,o,s,a,l,d,c,u,h,f,v,p,g,m,x,b,w;return __generator(this,(function(E){switch(E.label){case 0:if(!this.placing&&!((r=(i=e.target)===null||i===void 0?void 0:i.closest)===null||r===void 0?void 0:r.call(i,".verdocs-field"))){this.selectField(null)}if(!this.placing)return[3,2];s=e.offsetX;a=e.offsetY;l=defaultWidth(this.placing);d=defaultHeight(this.placing);c=this.cachedPageInfo[t][n];u=c.naturalWidth,h=u===void 0?612:u,f=c.naturalHeight,v=f===void 0?792:f;p=this.viewCoordinatesToPageCoordinates(s,a,t,n,h-l,v-d);g=Math.floor(p.x);m=Math.floor(p.y);x={name:this.generateFieldName(this.placing,n),role_name:this.selectedRoleName,template_id:this.templateId,document_id:c.documentId,type:this.placing,required:this.placing!=="radio"&&this.placing!=="attachment"&&this.placing!=="checkbox",page:n,validator:null,label:null,default:null,placeholder:null,group:null,settings:{},x:g,y:m,width:l,height:d,multiline:false,readonly:false,options:this.placing==="radio"?[{id:"option-1",label:"Option 1"}]:[]};return[4,createField(this.endpoint,this.templateId,x)];case 1:b=E.sent();console.log("[FIELDS] Created field",b);w=JSON.parse(JSON.stringify(this.template));w.fields.push(b);Store.updateTemplate(this.templateId,w);(o=this.templateUpdated)===null||o===void 0?void 0:o.emit({endpoint:this.endpoint,template:w,event:"added-field"});this.placing=null;E.label=2;case 2:return[2]}}))}))};e.prototype.render=function(){var e;var t=this;var n,i,r;console.log("Rendering");if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var o=__spreadArray([],((n=this.template)===null||n===void 0?void 0:n.roles)||[],true).sort((function(e,t){var n,i;return((n=e.sequence)!==null&&n!==void 0?n:0)-((i=t.sequence)!==null&&i!==void 0?i:0)}));var s=o.map((function(e){return{value:e.name,label:e.full_name?"".concat(e.name,": ").concat(e.full_name):e.name}}));return h(Host,{class:this.placing?(e={},e["placing-".concat(this.placing)]=true,e):{},onSubmit:function(){}},h("div",{id:"verdocs-template-fields-toolbar"},h("div",{class:"add-for"},"Add field:"),h("verdocs-select-input",{value:this.selectedRoleName,options:s,onInput:function(e){return t.selectedRoleName=e.target.value}}),menuOptions.map((function(e){return h("verdocs-toolbar-icon",{text:e.tooltip,icon:e.icon,class:e.class,onClick:function(){if(e.tooltip){if(t.selectedRoleName){t.placing=e.id}else{t.showMustSelectRole=true}}}})}))),h("div",{class:"pages"},(((i=this.template)===null||i===void 0?void 0:i.documents)||[]).map((function(e){var n=integerSequence(1,e.pages);return n.map((function(n){var i;var r=e.page_sizes[n];return h(Fragment,null,((i=t.template)===null||i===void 0?void 0:i.documents.length)>1&&h("div",{class:"document-separator"},h("div",{innerHTML:DocumentPageIcon}),h("span",null,e.name)),h("verdocs-template-document-page",{templateId:t.templateId,documentId:e.id,pageNumber:n,virtualWidth:(r===null||r===void 0?void 0:r.width)||612,virtualHeight:(r===null||r===void 0?void 0:r.height)||792,disabled:true,editable:true,done:false,onClick:function(i){return t.handleClickPage(i,e.id,n)},onPageRendered:function(e){return t.handlePageRendered(e)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]}))}))}))),this.showMustSelectRole&&h("verdocs-ok-dialog",{heading:"Unable to add field",message:(((r=this.template)===null||r===void 0?void 0:r.roles)||[]).length>0?"Please select a role before adding fields.":"Please add at least one role before adding fields.",onNext:function(){return t.showMustSelectRole=false}}))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{templateId:[{onTemplateIdChanged:0}]}},enumerable:false,configurable:true});return e}();VerdocsTemplateFields.style=verdocsTemplateFieldsCss();
1
+ var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,n,i){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i["throw"](e))}catch(e){o(e)}}function l(e){e.done?n(e.value):r(e.value).then(s,a)}l((i=i.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:[]},i,r,o,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=a(0),s["throw"]=a(1),s["return"]=a(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(e){return function(t){return l([e,t])}}function l(a){if(i)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(n=0)),n)try{if(i=1,r&&(o=a[0]&2?r["return"]:a[0]?r["throw"]||((o=r["return"])&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;if(r=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;r=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];r=0}finally{i=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var i=0,r=t.length,o;i<r;i++){if(o||!(i in t)){if(!o)o=Array.prototype.slice.call(t,0,i);o[i]=t[i]}}return e.concat(o||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host,F as Fragment,g as getElement}from"./index-CjTHbolG.js";import{i as interact}from"./interact.min-Bf1WXbdg.js";import{VerdocsEndpoint,getTemplate,integerSequence,getBrands,getOrganization,formatFullName,getOrganizationContacts,isValidEmail,createEnvelope,getRGBA,createTemplateDocument,deleteTemplateDocument,updateField,createField,updateTemplateRole,createTemplateRole}from"@verdocs/js-sdk";import{a as renderDocumentField,g as getFieldId,h as setControlStyles,i as updateCssTransform,j as removeCssTransform,d as defaultHeight,k as defaultWidth}from"./utils-T8dqWH7y.js";import{S as SDKError}from"./errors-C1sRVZWv.js";import{S as Store}from"./Datastore-C7hFgM52.js";import{D as DefaultEndpoint,g as getWebAppUrl}from"./Environment-Cq60Emo_.js";import{u as updateScrollFade}from"./ScrollFade-7UEjZarN.js";import{V as VerdocsToast}from"./Toast-D97GxsI-.js";import{a as DocIcon,P as PngIcon,J as JpgIcon,b as PdfIcon,F as FileIcon,c as PageCountIcon,T as TrashIcon,D as DocumentPageIcon}from"./Icons-DobS6Y7w.js";import"./_commonjsHelpers-B85MJLTf.js";import"./index-BglCURB-.js";import"./Types-CIxfEdV7.js";var verdocsPreviewCss=function(){return'verdocs-preview{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif);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-preview div,verdocs-preview canvas{-webkit-box-sizing:border-box;box-sizing:border-box}'};var VerdocsPreview=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.templateListenerId=null;this.renderedPages={};this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[PREVIEW] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(i){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[PREVIEW] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){console.log("[PREVIEW] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(i){console.log("[PREVIEW] Error with preview session",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,(n=i.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.componentDidRender=function(){var e;(e=this.hostEl)===null||e===void 0?void 0:e.querySelectorAll(".verdocs-field").forEach((function(e){interact(e).unset()}))};e.prototype.handlePageRendered=function(e){var t;var n=e.detail;this.renderedPages["".concat(n.documentId,":").concat(n.pageNumber)]=n;var i=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).filter((function(e){if(e["document_id"]){return e["document_id"]===n.documentId&&e.page===n.pageNumber}return e.page===n.pageNumber}));i.forEach((function(e){return renderDocumentField("template",e,n,{disabled:true,editable:false,draggable:false})}))};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}return h(Host,null,(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){var n=integerSequence(1,t.pages);return h(Fragment,null,n.map((function(n){var i;var r=((i=t.page_sizes)===null||i===void 0?void 0:i[n])||{width:612,height:792};return h("verdocs-template-document-page",{templateId:t.template_id,documentId:t.id,pageNumber:n,disabled:true,editable:false,done:false,virtualWidth:r.width,virtualHeight:r.height,onPageRendered:function(t){return e.handlePageRendered(t)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))})))};Object.defineProperty(e.prototype,"hostEl",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{templateId:[{onTemplateIdChanged:0}]}},enumerable:false,configurable:true});return e}();VerdocsPreview.style=verdocsPreviewCss();var getRoleNames=function(e){return((e===null||e===void 0?void 0:e.roles)||[]).map((function(e){return e.name}))};var getRoleIndex=function(e,t){return Math.max(getRoleNames(e).findIndex((function(e){return e===t})),0)};var verdocsSendCss=function(){return'verdocs-send{--send-ink:var(--verdocs-body-color, #111827);--send-ink-2:#374151;--send-muted:#6b7280;--send-faint:#9ca3af;--send-rule:#e5e7eb;--send-control-border:#d1d5db;--send-accent:var(--verdocs-link-color, #4c56cb);--send-accent-tint:#f4f5fc;--send-accent-tint-2:#e6e7f8;--send-warning-bg:#fffbeb;--send-warning-border:#fde68a;--send-warning-icon:#d97706;--send-warning-text:#78350f;--send-radius:var(--verdocs-dialog-radius, 8px);--send-min-height:480px;--send-max-width:480px;display:none;position:relative;overflow:hidden;width:100%;min-width:0;max-width:var(--verdocs-send-max-width, var(--send-max-width));-webkit-box-sizing:border-box;box-sizing:border-box;background:#ffffff;color:var(--send-ink);font-size:14px;border-radius:var(--send-radius);border:1px solid var(--send-rule);font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-send *{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-send.sendable{display:block}verdocs-send .track{position:relative;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;min-height:var(--send-min-height);-webkit-transition:-webkit-transform 220ms ease-out;transition:-webkit-transform 220ms ease-out;transition:transform 220ms ease-out;transition:transform 220ms ease-out, -webkit-transform 220ms ease-out}verdocs-send.detail-open .track{-webkit-transform:translateX(-100%);transform:translateX(-100%)}@media (prefers-reduced-motion: reduce){verdocs-send .track{-webkit-transition:none;transition:none}}verdocs-send .pane{padding:16px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .main-pane{-ms-flex:1;flex:1}verdocs-send .detail-pane{position:absolute;top:0;left:100%;bottom:0;width:100%;overflow:hidden}verdocs-send .detail{-ms-flex:1;flex:1;min-height:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .detail-body-wrap{position:relative;-ms-flex:1;flex:1;min-height:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .detail-body{-ms-flex:1;flex:1;min-height:0;overflow-y:auto}verdocs-send .scroll-fade{position:absolute;left:0;right:0;bottom:0;height:36px;opacity:0;pointer-events:none;-webkit-transition:opacity 150ms ease-out;transition:opacity 150ms ease-out;background:-webkit-gradient(linear, left top, left bottom, from(rgba(255, 255, 255, 0)), to(#ffffff));background:linear-gradient(rgba(255, 255, 255, 0), #ffffff)}verdocs-send .scrollable:not(.at-end)>.scroll-fade{opacity:1}verdocs-send .recipient-detail verdocs-contact-picker{-ms-flex:1;flex:1;min-height:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .section-title{font-size:12px;font-weight:600;color:var(--send-ink-2);margin:0 0 6px 0}verdocs-send .delivery-title{margin-top:16px}verdocs-send .step{font-size:11px;color:var(--send-muted);padding:10px 0 4px 0}verdocs-send .recipient,verdocs-send .kv{all:unset;display:-ms-flexbox;display:flex;width:100%;min-width:0;max-width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;cursor:pointer;-ms-flex-align:center;align-items:center;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;border-top:1px solid var(--send-rule);color:var(--send-ink);font-family:inherit}verdocs-send .recipient:focus-visible,verdocs-send .kv:focus-visible{outline:2px solid var(--send-accent);outline-offset:-2px;border-radius:4px}verdocs-send .recipient .chevron,verdocs-send .kv .chevron{-ms-flex:0 0 16px;flex:0 0 16px;width:16px;height:16px;color:var(--send-faint)}verdocs-send .recipient .chevron svg,verdocs-send .kv .chevron svg{width:16px;height:16px;display:block}verdocs-send .recipient{padding:8px 6px 8px 0}verdocs-send .recipient:last-child{border-bottom:1px solid var(--send-rule)}verdocs-send .recipient .who{-ms-flex:1;flex:1;width:0;min-width:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .recipient .role-name{font-size:13px;font-weight:600}verdocs-send .recipient .who-detail{font-size:12px;color:var(--send-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-send .recipient .who-detail.configure{color:var(--send-accent);font-weight:500}verdocs-send .recipient .options{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;gap:4px;margin-top:3px}verdocs-send .recipient .pill{height:18px;padding:0 6px;border-radius:999px;font-size:10px;font-weight:500;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;background:var(--send-accent-tint);color:var(--send-ink-2)}verdocs-send .role-dot{-ms-flex:0 0 10px;flex:0 0 10px;width:10px;height:10px;border-radius:50%;border:1px solid rgba(0, 0, 0, 0.1)}verdocs-send .kv{height:40px;padding:0 6px 0 0;font-size:13px}verdocs-send .kv:last-child{border-bottom:1px solid var(--send-rule)}verdocs-send .kv:disabled{cursor:default;color:var(--send-muted)}verdocs-send .kv .key{-ms-flex:0 0 84px;flex:0 0 84px;color:var(--send-muted)}verdocs-send .kv .value{-ms-flex:1;flex:1;width:0;min-width:0;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-send .kv .value small{font-size:inherit;font-weight:400;color:var(--send-muted)}verdocs-send .kv .value.stacked{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;row-gap:1px;white-space:normal}verdocs-send .kv .value.stacked .line{display:block;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-send .kv .value.stacked small.line{font-size:12px}verdocs-send .kv .value.off{color:var(--send-warning-icon)}verdocs-send .kv:has(.value.stacked){height:auto;min-height:40px;padding-top:6px;padding-bottom:6px}verdocs-send .main-spacer,verdocs-send .detail-spacer{-ms-flex:1;flex:1}verdocs-send .buttons{display:-ms-flexbox;display:flex;margin-top:14px;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center;-ms-flex-pack:end;justify-content:flex-end}verdocs-send .buttons .error-message{width:100%;color:#cc0000;font-size:13px;margin-bottom:10px}verdocs-send .detail-header{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin:-2px 0 14px 0}verdocs-send .detail-header .back{all:unset;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;cursor:pointer;font-size:13px;font-weight:500;color:var(--send-accent);font-family:inherit;-ms-flex:0 0 52px;flex:0 0 52px}verdocs-send .detail-header .back .icon,verdocs-send .detail-header .back .icon svg{width:16px;height:16px;display:block}verdocs-send .detail-header .back:focus-visible{outline:2px solid var(--send-accent);outline-offset:2px;border-radius:4px}verdocs-send .detail-header .detail-title{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;font-size:14px;font-weight:600;text-align:center}verdocs-send .detail-header .detail-header-spacer{-ms-flex:0 0 52px;flex:0 0 52px}verdocs-send .detail-footer{margin-top:10px;padding-top:12px;border-top:1px solid var(--send-rule)}verdocs-send .detail-footer verdocs-button,verdocs-send .detail-footer verdocs-button button{width:100%}verdocs-send .hint{font-size:12px;line-height:1.5;color:var(--send-muted);margin:10px 0 0 0}verdocs-send .option-list{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .option{all:unset;display:-ms-flexbox;display:flex;width:100%;cursor:pointer;-ms-flex-align:center;align-items:center;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;padding:10px 0;font-size:13px;font-family:inherit;color:var(--send-ink);border-top:1px solid var(--send-rule)}verdocs-send .option:first-child{border-top:0}verdocs-send .option:focus-visible{outline:2px solid var(--send-accent);outline-offset:-2px;border-radius:4px}verdocs-send .option .radio{-ms-flex:0 0 16px;flex:0 0 16px;width:16px;height:16px;border-radius:50%;border:1px solid var(--send-control-border);display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}verdocs-send .option.selected .radio{border-color:var(--send-accent)}verdocs-send .option.selected .radio::after{content:"";width:8px;height:8px;border-radius:50%;background:var(--send-accent)}verdocs-send .option .swatch{-ms-flex:0 0 22px;flex:0 0 22px;width:22px;height:22px;border-radius:5px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;font-size:9px;font-weight:700;color:#ffffff;overflow:hidden}verdocs-send .option .swatch.logo{background:#ffffff;border:1px solid var(--send-rule)}verdocs-send .option .swatch img{width:100%;height:100%;-o-object-fit:contain;object-fit:contain;display:block}verdocs-send .option .option-label{-ms-flex:1;flex:1;width:0;min-width:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-send .option .option-label small{font-size:11px;color:var(--send-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}verdocs-send .option-divider{height:0;margin:2px 0;border-top:1px solid var(--send-control-border)}verdocs-send .option-divider+.option{border-top:0}verdocs-send .hint a{color:var(--send-accent);font-weight:500;text-decoration:none;border-bottom:1px solid var(--send-accent-tint-2)}verdocs-send .hint a .icon,verdocs-send .hint a .icon svg{width:11px;height:11px;display:inline-block;vertical-align:-1px;margin-left:2px}verdocs-send .expires-field{position:relative}verdocs-send .expires-field input{width:100%;height:36px;padding:0 52px 0 10px;font-size:14px;font-family:inherit;color:var(--send-ink);background:#ffffff;border:1px solid var(--send-control-border);border-radius:6px;outline:none}verdocs-send .expires-field input:focus{border-color:var(--send-accent);-webkit-box-shadow:0 0 0 2px var(--send-accent-tint-2);box-shadow:0 0 0 2px var(--send-accent-tint-2)}verdocs-send .expires-field input::-webkit-input-placeholder{color:var(--send-faint)}verdocs-send .expires-field input::-moz-placeholder{color:var(--send-faint)}verdocs-send .expires-field input:-ms-input-placeholder{color:var(--send-faint)}verdocs-send .expires-field input::-ms-input-placeholder{color:var(--send-faint)}verdocs-send .expires-field input::placeholder{color:var(--send-faint)}verdocs-send .expires-field .suffix{position:absolute;right:10px;top:0;height:36px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;font-size:13px;color:var(--send-muted);pointer-events:none}verdocs-send .sender-field{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;row-gap:4px;margin:0 0 10px 0}verdocs-send .sender-field label{font-size:12px;font-weight:500;color:var(--send-ink-2)}verdocs-send .sender-field input{width:100%;height:36px;padding:0 10px;font-size:14px;font-family:inherit;color:var(--send-ink);background:#ffffff;border:1px solid var(--send-control-border);border-radius:6px;outline:none}verdocs-send .sender-field input:focus{border-color:var(--send-accent);-webkit-box-shadow:0 0 0 2px var(--send-accent-tint-2);box-shadow:0 0 0 2px var(--send-accent-tint-2)}verdocs-send .sender-field .field-error{font-size:12px;color:#cc0000}verdocs-send .notice{display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;margin-top:4px;padding:10px 12px;font-size:12px;line-height:1.5;border-radius:6px;color:var(--send-ink-2);background:var(--send-accent-tint);border:1px solid var(--send-accent-tint-2)}verdocs-send .notice>.icon{-ms-flex:0 0 18px;flex:0 0 18px;width:18px;height:18px;margin-top:1px;color:var(--send-accent)}verdocs-send .notice>.icon svg{width:18px;height:18px;display:block}verdocs-send .warning{display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;margin-top:12px;padding:10px 12px;font-size:12px;line-height:1.5;border-radius:6px;color:var(--send-warning-text);background:var(--send-warning-bg);border:1px solid var(--send-warning-border)}verdocs-send .warning>.icon{-ms-flex:0 0 18px;flex:0 0 18px;width:18px;height:18px;margin-top:1px;color:var(--send-warning-icon)}verdocs-send .warning>.icon svg{width:18px;height:18px;display:block}verdocs-send .notice a,verdocs-send .warning a{color:var(--send-accent);font-weight:500;text-decoration:none;border-bottom:1px solid var(--send-accent-tint-2)}verdocs-send .notice a .icon,verdocs-send .notice a .icon svg,verdocs-send .warning a .icon,verdocs-send .warning a .icon svg{width:11px;height:11px;display:inline-block;vertical-align:-1px;margin-left:2px}verdocs-send verdocs-checkbox{display:block;padding:4px 0;font-size:13px}'};var chevronRightIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 6 6 6-6 6"/></svg>';var chevronLeftIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m15 18-6-6 6-6"/></svg>';var warningIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><path d="M12 9v4M12 17h.01"/></svg>';var infoIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/></svg>';var externalLinkIcon='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h6v6M10 14 21 3M21 14v7H3V3h7"/></svg>';var VERDOCS_LOGO_URL="https://app.verdocs.com/assets/blue-logo.svg";var SWIPE_START_FRACTION=.25;var SWIPE_MIN_DISTANCE=60;var SWIPE_MAX_DURATION=500;var MIN_EXPIRY_DAYS=1;var MAX_EXPIRY_DAYS=120;var DEFAULT_EXPIRY_DAYS=120;var AUTH_METHOD_LABELS={email:"Email",passcode:"Passcode",sms:"SMS",kba:"KBA",id:"ID check"};var VerdocsSend=function(){function e(e){registerInstance(this,e);this.beforeSend=createEvent(this,"beforeSend");this.send=createEvent(this,"send");this.exit=createEvent(this,"exit");this.sdkError=createEvent(this,"sdkError");this.searchContacts=createEvent(this,"searchContacts");this.templateListenerId=null;this.endpoint=DefaultEndpoint;this.templateId=null;this.environment="";this.showCancel=true;this.brandKey="";this.swipeStart=null;this.swallowNextClick=false;this.loadedOrganizationId="";this.containerId="verdocs-send-".concat(Math.random().toString(36).substring(2,11));this.view="main";this.editingRoleId="";this.sessionContacts=[];this.sending=false;this.brands=[];this.organization=null;this.expiresInDays="";this.noContact=false;this.senderDefaults={name:"",email:""};this.senderName="";this.senderEmail="";this.rolesCompleted={};this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.componentDidLoad=function(){var e=this;this.el.addEventListener("click",(function(t){if(e.swallowNextClick){e.swallowNextClick=false;t.stopPropagation();t.preventDefault()}}),true)};e.prototype.componentDidRender=function(){var e,t;updateScrollFade(this.el.querySelector(".detail-body"));(e=this.el.querySelector(".main-pane"))===null||e===void 0?void 0:e.toggleAttribute("inert",this.view!=="main");(t=this.el.querySelector(".detail-pane"))===null||t===void 0?void 0:t.toggleAttribute("inert",this.view==="main")};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[SEND] Loading template",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),true,(function(t){console.log("[SEND] Got new template",t);e.template=t;e.loading=false;e.rolesCompleted={};e.view="main";e.editingRoleId="";e.recomputeRolesCompleted();e.loadBrands()}));return[2]}))}))};e.prototype.loadBrands=function(){var e=this;var t;var n=(t=this.template)===null||t===void 0?void 0:t.organization_id;if(!n||n===this.loadedOrganizationId){return}var i=!!this.loadedOrganizationId;this.loadedOrganizationId=n;this.brands=[];this.organization=null;if(i){this.brandKey=""}var r=function(){var t;return((t=e.template)===null||t===void 0?void 0:t.organization_id)===n};getBrands(this.endpoint,n).then((function(t){if(r()){e.brands=t||[]}})).catch((function(e){return console.log("[SEND] Unable to load brands",e)}));getOrganization(this.endpoint,n).then((function(t){if(r()){e.organization=t}})).catch((function(e){return console.log("[SEND] Unable to load organization",e)}))};e.prototype.handleExpiryInput=function(e){var t=(e.target.value||"").replace(/[^0-9]/g,"");this.expiresInDays=t?String(Math.min(Math.max(Number(t),MIN_EXPIRY_DAYS),MAX_EXPIRY_DAYS)):"";e.target.value=this.expiresInDays};e.prototype.effectiveExpiryDays=function(){var e=Number(this.expiresInDays);return e>=MIN_EXPIRY_DAYS?e:DEFAULT_EXPIRY_DAYS};e.prototype.expiresAt=function(){return new Date(Date.now()+this.effectiveExpiryDays()*24*60*60*1e3)};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.reset=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.rolesCompleted={};this.view="main";this.editingRoleId="";this.brandKey="";this.expiresInDays="";this.noContact=false;this.senderName="";this.senderEmail="";return[2]}))}))};e.prototype.effectiveSenderName=function(){return this.senderName||this.senderDefaults.name};e.prototype.effectiveSenderEmail=function(){return this.senderEmail||this.senderDefaults.email};e.prototype.senderOverrides=function(){var e=this.senderName.trim();var t=this.senderEmail.trim();return{sender_name:e&&e!==this.senderDefaults.name?e:undefined,sender_email:t&&t!==this.senderDefaults.email?t:undefined}};e.prototype.onTemplateIdChanged=function(e){console.log("[SEND] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;var i=this;return __generator(this,(function(r){try{this.endpoint.onSessionChanged((function(e,t,n){if(!n){return}var r={id:n.id,first_name:n.first_name,last_name:n.last_name,email:n.email,phone:n.phone};if(n){i.senderDefaults={name:formatFullName(n),email:n.email||""};i.sessionContacts=[r];getOrganizationContacts(i.endpoint).then((function(e){console.log("[SEND] Got contacts",e);i.sessionContacts=__spreadArray(__spreadArray([],e,true),[r],false)})).catch((function(e){console.log("[SEND] Error getting contacts",e)}))}}));this.endpoint.loadSession();if(!this.endpoint.session){console.log("[SEND] Unable to start Send operation, must be authenticated");return[2]}if(!this.templateId){console.log("[SEND] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(i){console.log("[SEND] Error with send session",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,(n=i.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.recomputeRolesCompleted=function(){var e=this;var t;this.rolesCompleted={};var n={};(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).forEach((function(t){var i=t.sequence;n[i]||(n[i]=[]);var r="r-".concat(i,"-").concat(n[i].length);n[i].push(__assign(__assign({},t),{id:r,role_name:t.name,first_name:t.first_name,last_name:t.last_name}));if(t.first_name&&isValidEmail(t.email)){e.rolesCompleted[r]=__assign(__assign({},t),{id:r,role_name:t.name,first_name:t.first_name,last_name:t.last_name})}}))};e.prototype.getSequenceNumbers=function(){var e;var t={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((function(e){t[e.sequence]=true}));return Object.keys(t).map((function(e){return+e})).sort((function(e,t){return e-t}))};e.prototype.getRolesAtLevel=function(e){var t;var n=(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((function(t){return t.sequence===e})).map((function(t,n){return __assign(__assign({},t),{id:"r-".concat(e,"-").concat(n),role_name:t.name,first_name:t.first_name,last_name:t.last_name})}));return n};e.prototype.getRoleById=function(e){for(var t=0,n=this.getSequenceNumbers();t<n.length;t++){var i=n[t];var r=this.getRolesAtLevel(i).find((function(t){return t.id===e}));if(r){return r}}return null};e.prototype.getRecipientOptionLabels=function(e){if(!e){return[]}var t=(e.auth_methods||[]).filter((function(e){return e!=="email"})).map((function(e){return AUTH_METHOD_LABELS[e]||e}));if(e.delegator){t.push("May delegate")}if(e.name_locked){t.push("Name locked")}return t};e.prototype.getDefaultBrand=function(){var e;var t=(e=this.organization)===null||e===void 0?void 0:e.default_brand_id;return t&&this.brands.find((function(e){return e.id===t}))||null};e.prototype.getDefaultBrandLabel=function(){var e;var t=(e=this.getDefaultBrand())===null||e===void 0?void 0:e.name;return"Default (".concat(t||"Verdocs",")")};e.prototype.getSelectedBrandLabel=function(){var e=this;if(!this.brandKey){return this.getDefaultBrandLabel()}var t=this.brands.find((function(t){return t.key===e.brandKey}));return(t===null||t===void 0?void 0:t.name)||(t===null||t===void 0?void 0:t.key)||this.brandKey};e.prototype.showView=function(e){this.view=e};e.prototype.handleSelectContact=function(e,t){var n;e.preventDefault();this.rolesCompleted=__assign(__assign({},this.rolesCompleted),(n={},n[t.id]=__assign(__assign({},t),e.detail),n));this.editingRoleId="";this.view="main"};e.prototype.handleClickRole=function(e,t){e.stopPropagation();this.editingRoleId=t.id;this.view="recipient"};e.prototype.handleSend=function(e){var t=this;var n;if(this.sending){console.log("[SEND] Skipping duplicate send",e);return}console.log("[SEND] Sending",e);e.preventDefault();e.stopPropagation();this.sending=true;var i=Intl.DateTimeFormat().resolvedOptions();var r={template_id:this.templateId,name:((n=this.template)===null||n===void 0?void 0:n.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted),timezone:i.timeZone,locale:i.locale,expires_at:this.expiresAt().toISOString()};r.no_contact=this.noContact;var o=this.senderOverrides(),s=o.sender_name,a=o.sender_email;if(s){r.sender_name=s}if(a){r.sender_email=a}if(this.brandKey){r.brand_key=this.brandKey}var l=this.beforeSend.emit(__assign(__assign({},r),{name:r.name,template:this.template}));if(l.defaultPrevented){console.log("[SEND] Send cancelled by parent",r);this.sending=false;return}console.log("[SEND] Creating envelope",r);createEnvelope(this.endpoint,r).then((function(e){var n;console.log("[SEND] Send envelope",e);t.reset().catch((function(e){return console.log("Unknown Error",e)}));t.sending=false;(n=t.send)===null||n===void 0?void 0:n.emit(__assign(__assign({},r),{name:r.name,envelope_id:e.id,envelope:e}))})).catch((function(e){var n,i,r;console.log("[SEND] Send error",e);VerdocsToast(((i=(n=e.response)===null||n===void 0?void 0:n.data)===null||i===void 0?void 0:i.error)||"Error creating envelope, please try again later.");t.sending=false;(r=t.sdkError)===null||r===void 0?void 0:r.emit(e)}))};e.prototype.handleCancel=function(e){var t;e.stopPropagation();(t=this.exit)===null||t===void 0?void 0:t.emit()};e.prototype.handleSwipeStart=function(e){var t,n;this.swallowNextClick=false;var i=e.currentTarget;var r=i.getBoundingClientRect();var o=!!((n=(t=e.target)===null||t===void 0?void 0:t.closest)===null||n===void 0?void 0:n.call(t,"input, textarea, select, [contenteditable]"));if(this.view==="main"||o||e.clientX-r.left>r.width*SWIPE_START_FRACTION){this.swipeStart=null;return}this.swipeStart={x:e.clientX,y:e.clientY,time:Date.now()}};e.prototype.handleSwipeEnd=function(e){var t=this.swipeStart;this.swipeStart=null;if(!t){return}var n=e.clientX-t.x;var i=Math.abs(e.clientY-t.y);if(n>=SWIPE_MIN_DISTANCE&&n>i&&Date.now()-t.time<=SWIPE_MAX_DURATION){this.swallowNextClick=true;this.showView("main")}};e.prototype.renderDetailHeader=function(e){var t=this;return h("div",{class:"detail-header"},h("button",{type:"button",class:"back",onClick:function(){return t.showView("main")}},h("span",{class:"icon",innerHTML:chevronLeftIcon}),"Back"),h("div",{class:"detail-title"},e),h("div",{class:"detail-header-spacer"}))};e.prototype.renderDetailBody=function(e){return h("div",{class:"detail-body-wrap"},h("div",{class:"detail-body",onScroll:function(e){return updateScrollFade(e.target)}},e),h("div",{class:"scroll-fade"}))};e.prototype.renderDoneButton=function(){var e=this;return h("div",{class:"detail-footer"},h("verdocs-button",{label:"Done",size:"small",onClick:function(){return e.showView("main")}}))};e.prototype.renderRecipientView=function(){var e=this;var t;var n=this.getRoleById(this.editingRoleId);if(!n){return h("div",{class:"detail recipient-detail"},this.renderDetailHeader("Recipient"))}var i=getRoleIndex(this.template,n.role_name);return h("div",{class:"detail recipient-detail"},this.renderDetailHeader([h("span",{class:"role-dot",style:{backgroundColor:getRGBA(i)}}),n.role_name]),h("verdocs-contact-picker",{key:n.id,showCancel:false,onExit:function(){return e.showView("main")},onNext:function(t){return e.handleSelectContact(t,n)},contactSuggestions:this.sessionContacts,templateRole:(t=this.rolesCompleted[n.id])!==null&&t!==void 0?t:n,onSearchContacts:function(t){var n;return(n=e.searchContacts)===null||n===void 0?void 0:n.emit(t.detail)}}))};e.prototype.renderBrandSwatch=function(e,t){var n=(e===null||e===void 0?void 0:e.favicon_url)||(e===null||e===void 0?void 0:e.thumbnail_url)||(e?null:VERDOCS_LOGO_URL);if(n){return h("span",{class:"swatch logo"},h("img",{src:n,alt:""}))}return h("span",{class:"swatch",style:{backgroundColor:(e===null||e===void 0?void 0:e.primary_color)||"#4c56cb"}},t.substring(0,2).toUpperCase())};e.prototype.renderBrandOption=function(e,t,n,i){var r=this;return h("button",{type:"button",class:{option:true,selected:this.brandKey===e},onClick:function(){return r.brandKey=e}},h("span",{class:"radio"}),i,h("span",{class:"option-label"},t,h("small",null,n)))};e.prototype.renderBrandView=function(){var e=this;var t=this.getDefaultBrand();var n=this.brands.filter((function(e){return e.id!==(t===null||t===void 0?void 0:t.id)})).sort((function(e,t){return(e.name||e.key).localeCompare(t.name||t.key)}));var i=this.brands.length>0;return h("div",{class:"detail"},this.renderDetailHeader("Brand"),this.renderDetailBody([h("div",{class:"option-list"},this.renderBrandOption("",this.getDefaultBrandLabel(),"Organization default",this.renderBrandSwatch(t,(t===null||t===void 0?void 0:t.name)||"V")),n.length>0&&h("div",{class:"option-divider"}),n.map((function(t){return e.renderBrandOption(t.key,t.name||t.key,t.key,e.renderBrandSwatch(t,t.name||t.key))}))),!i&&h("p",{class:"hint"},"Configure the look and feel of the signing experience by"," ",h("a",{href:"".concat(getWebAppUrl(this.endpoint),"/settings/branding"),target:"_blank",rel:"noopener"},"Creating a Brand",h("span",{class:"icon",innerHTML:externalLinkIcon})),".")]),this.renderDoneButton())};e.prototype.renderExpiresView=function(){var e=this;var t=this.expiresAt();var n="".concat(t.toLocaleDateString(undefined,{month:"short",day:"numeric",year:"numeric"})," at ").concat(t.toLocaleTimeString(undefined,{hour:"numeric",minute:"2-digit"}));return h("div",{class:"detail"},this.renderDetailHeader("Expiration"),this.renderDetailBody([h("div",{class:"expires-field"},h("input",{type:"text",inputMode:"numeric","aria-label":"Expires in (days)",placeholder:String(DEFAULT_EXPIRY_DAYS),value:this.expiresInDays,disabled:this.sending,onInput:function(t){return e.handleExpiryInput(t)}}),h("span",{class:"suffix"},"days")),h("p",{class:"hint"},"This envelope will expire on ",n,". Expirations may be set from ",MIN_EXPIRY_DAYS,"-",MAX_EXPIRY_DAYS," days. If left blank, this will default to ",DEFAULT_EXPIRY_DAYS,".")]),this.renderDoneButton())};e.prototype.renderSenderView=function(){var e=this;var t=!this.senderEmail.trim()||isValidEmail(this.senderEmail.trim());return h("div",{class:"detail"},this.renderDetailHeader("Sender"),this.renderDetailBody([h("div",{class:"sender-field"},h("label",{htmlFor:"".concat(this.containerId,"-sender-name")},"Name"),h("input",{id:"".concat(this.containerId,"-sender-name"),type:"text",value:this.effectiveSenderName(),disabled:this.sending,onInput:function(t){return e.senderName=t.target.value}})),h("div",{class:"sender-field"},h("label",{htmlFor:"".concat(this.containerId,"-sender-email")},"Email"),h("input",{id:"".concat(this.containerId,"-sender-email"),type:"email",value:this.effectiveSenderEmail(),disabled:this.sending,onInput:function(t){return e.senderEmail=t.target.value}}),!t&&h("div",{class:"field-error"},"Enter a valid email address.")),h("div",{class:"notice"},h("span",{class:"icon",innerHTML:infoIcon}),h("div",null,'Specify where envelope-completed email notifications and "Ask a Question" submissions are delivered. To customize the "From" address for email notifications, please configure those in'," ",h("a",{href:"".concat(getWebAppUrl(this.endpoint),"/settings/branding"),target:"_blank",rel:"noopener"},"Brands",h("span",{class:"icon",innerHTML:externalLinkIcon})),"."))]),this.renderDoneButton())};e.prototype.renderNotificationsView=function(){var e=this;return h("div",{class:"detail"},this.renderDetailHeader("Notifications"),this.renderDetailBody([h("verdocs-checkbox",{size:"small",label:"Disable notifications",checked:this.noContact,onInput:function(t){return e.noContact=!!t.target.checked}}),this.noContact&&h("div",{class:"warning"},h("span",{class:"icon",innerHTML:warningIcon}),h("div",null,"Disabling notifications turns off invitations and reminders to recipients as well as status updates to you. You may obtain invite links in the recipient summary or via an API call. We strongly recommend enabling"," ",h("a",{href:"".concat(getWebAppUrl(this.endpoint),"/settings/webhooks"),target:"_blank",rel:"noopener"},"Webhooks",h("span",{class:"icon",innerHTML:externalLinkIcon}))," ","to help automate this process."))]),this.renderDoneButton())};e.prototype.renderDetail=function(){switch(this.view){case"recipient":return this.renderRecipientView();case"brand":return this.renderBrandView();case"expires":return this.renderExpiresView();case"notifications":return this.renderNotificationsView();case"sender":return this.renderSenderView();default:return null}};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,{style:{display:"flex"}},h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var n=this.getSequenceNumbers();var i=Object.values(this.rolesCompleted).filter((function(e){return isValidEmail(e.email)&&e.first_name&&e.last_name}));var r=i.length>=getRoleNames(this.template).length;var o=i.map((function(e){return e.email.toLowerCase()}));var s=new Set(o).size<o.length;var a=this.expiresAt();var l=a.toLocaleDateString(undefined,{month:"short",day:"numeric"});return h(Host,{class:{sendable:(t=this.template)===null||t===void 0?void 0:t.is_sendable,"detail-open":this.view!=="main"}},h("div",{class:"track"},h("div",{class:"pane main-pane","aria-hidden":this.view!=="main"?"true":"false"},h("div",{class:"section-title"},"Recipients"),h("div",{class:"recipients"},n.map((function(t){return[n.length>1&&h("div",{class:"step"},"Step ",t),e.getRolesAtLevel(t).map((function(t){var n=getRoleIndex(e.template,t.role_name);var r=e.rolesCompleted[t.id];var o=r&&i.findIndex((function(e){return e.role_name===t.role_name}))>-1;var s=e.getRecipientOptionLabels(r);return h("button",{type:"button",class:"recipient","data-ri":n,"data-rn":t.role_name,onClick:function(n){return e.handleClickRole(n,t)}},h("span",{class:"role-dot",style:{backgroundColor:getRGBA(n)}}),h("span",{class:"who"},h("span",{class:"role-name"},t.role_name),o?h("span",{class:"who-detail"},formatFullName(r)," · ",r.email):h("span",{class:"who-detail configure"},"Configure recipient"),s.length>0&&h("span",{class:"options"},s.map((function(e){return h("span",{class:"pill"},e)})))),h("span",{class:"chevron",innerHTML:chevronRightIcon}))}))]}))),h("div",{class:"section-title delivery-title"},"Delivery"),h("div",{class:"delivery"},h("button",{type:"button",class:"kv",onClick:function(){return e.showView("brand")},disabled:this.sending},h("span",{class:"key"},"Brand"),h("span",{class:"value"},this.getSelectedBrandLabel()),h("span",{class:"chevron",innerHTML:chevronRightIcon})),h("button",{type:"button",class:"kv",onClick:function(){return e.showView("expires")},disabled:this.sending},h("span",{class:"key"},"Expires"),h("span",{class:"value"},this.effectiveExpiryDays()," days ",h("small",null,"· ",l)),h("span",{class:"chevron",innerHTML:chevronRightIcon})),h("button",{type:"button",class:"kv",onClick:function(){return e.showView("sender")},disabled:this.sending},h("span",{class:"key"},"Sender"),h("span",{class:"value stacked"},h("span",{class:"line"},this.effectiveSenderName()||this.effectiveSenderEmail()),this.effectiveSenderName()&&this.effectiveSenderEmail()?h("small",{class:"line"},this.effectiveSenderEmail()):null),h("span",{class:"chevron",innerHTML:chevronRightIcon})),h("button",{type:"button",class:"kv",onClick:function(){return e.showView("notifications")},disabled:this.sending},h("span",{class:"key"},"Notifications"),h("span",{class:{value:true,off:this.noContact}},this.noContact?"Off":"On"),h("span",{class:"chevron",innerHTML:chevronRightIcon}))),h("div",{class:"main-spacer"}),h("div",{class:"buttons"},s&&h("div",{class:"error-message"},"Recipients cannot share the same email."),this.sending&&h("verdocs-spinner",null),this.showCancel&&h("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:function(t){return e.handleCancel(t)},disabled:this.sending}),h("verdocs-button",{label:"Send",size:"small",disabled:!r||this.sending||s,onClick:function(t){return e.handleSend(t)}}))),h("div",{class:"pane detail-pane","aria-hidden":this.view==="main"?"true":"false",onPointerDown:function(t){return e.handleSwipeStart(t)},onPointerUp:function(t){return e.handleSwipeEnd(t)},onPointerCancel:function(){return e.swipeStart=null}},this.renderDetail())))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{templateId:[{onTemplateIdChanged:0}]}},enumerable:false,configurable:true});return e}();VerdocsSend.style=verdocsSendCss();var verdocsTemplateAttachmentsCss=function(){return'verdocs-template-attachments{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-template-attachments h5{font-size:16px;font-weight:bold;margin:0 0 10px 0;color:#46497d}verdocs-template-attachments .attachments{margin:0 0 40px 0}verdocs-template-attachments .attachment{display:-ms-flexbox;display:flex;padding:5px 0;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#33364b}verdocs-template-attachments .attachment:hover .trash-icon{display:-ms-flexbox;display:flex}verdocs-template-attachments .attachment:hover .pages{display:none}verdocs-template-attachments svg{width:28px;height:28px;fill:#5c6575;margin:2px 0 0 0}verdocs-template-attachments .file-icon{-ms-flex:0;flex:0}verdocs-template-attachments .pages{width:24px;height:24px;-ms-flex:0 0 24px;flex:0 0 24px;padding-left:4px;position:relative;margin:-10px 0 0 0}verdocs-template-attachments .pages .pages-icon{top:0;left:0;width:24px;height:24px;position:absolute}verdocs-template-attachments .pages .count{top:11px;left:7px;z-index:1;width:18px;font-size:12px;font-weight:500;position:absolute;text-align:center;letter-spacing:-2px}verdocs-template-attachments .filename{-ms-flex:1;flex:1;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;border-bottom:1px dotted #cccccc}verdocs-template-attachments .trash-icon{-ms-flex:0;flex:0;display:none}verdocs-template-attachments .trash-icon:hover{cursor:pointer}verdocs-template-attachments verdocs-file-chooser{margin:10px 0;border:2px dashed #979797}verdocs-template-attachments .loader-wrapper{background-color:#ffffff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:320px;height:320px;text-align:center;border:2px dashed #979797;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .progress-wrapper{padding:20px}verdocs-template-attachments .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-attachments .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-attachments ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-moz-placeholder{color:#aaaaaa}verdocs-template-attachments :-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::placeholder{color:#aaaaaa}'};var VerdocsTemplateAttachments=function(){function e(e){registerInstance(this,e);this.exit=createEvent(this,"exit");this.next=createEvent(this,"next");this.templateUpdated=createEvent(this,"templateUpdated");this.sdkError=createEvent(this,"sdkError");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.uploading=false;this.progressLabel="Uploading...";this.progressPercent=0;this.showDeleteError=false;this.confirmDeleteDocument=null;this.loading=true;this.template=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(i){try{this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(i){console.log("[TEMPLATE ATTACHMENTS] 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,(n=i.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.handleCancel=function(e){e.stopPropagation();this.exit.emit()};e.prototype.handleUploadProgress=function(e){if(e>=99){this.progressPercent=100;this.progressLabel="Processing..."}else{this.progressPercent=e}};e.prototype.handleUpload=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,i,r,o,s,a,l;return __generator(this,(function(d){switch(d.label){case 0:e.stopPropagation();o=e.detail.file;if(!o){return[2]}console.log("[ATTACHMENTS] Uploading...",o);this.uploading=true;this.progressLabel="Uploading...";d.label=1;case 1:d.trys.push([1,4,,5]);return[4,createTemplateDocument(this.endpoint,this.templateId,o,this.handleUploadProgress.bind(this))];case 2:s=d.sent();console.log("[ATTACHMENTS] Created attachment",s);a=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 3:a.template=d.sent();console.log("[ATTACHMENTS] Updated template",this.template);(t=this.templateUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,template:this.template,event:"attachments"});this.uploading=false;this.progressLabel="";this.progressPercent=0;return[3,5];case 4:l=d.sent();console.log("[ATTACHMENTS] Error creating template",l);(n=this.sdkError)===null||n===void 0?void 0:n.emit(new SDKError(l.message,(i=l.response)===null||i===void 0?void 0:i.status,(r=l.response)===null||r===void 0?void 0:r.data));this.uploading=false;return[3,5];case 5:return[2]}}))}))};e.prototype.handleNext=function(e){var t;e.stopPropagation();this.uploading=false;this.progressLabel="";this.progressPercent=0;(t=this.next)===null||t===void 0?void 0:t.emit({template:this.template})};e.prototype.confirmDelete=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,deleteTemplateDocument(this.endpoint,this.confirmDeleteDocument.id)];case 1:t.sent();e=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 2:e.template=t.sent();console.log("[ATTACHMENTS] New template",this.template);this.confirmDeleteDocument=null;return[2]}}))}))};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(n){if((((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>1){this.confirmDeleteDocument=e}else{this.showDeleteError=true}return[2]}))}))};e.prototype.getFileIcon=function(e){switch(e.mime){case"application/pdf":return PdfIcon;case"image/jpeg":return JpgIcon;case"image/png":return PngIcon;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return DocIcon}return FileIcon};e.prototype.render=function(){var e=this;var t,n;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading){return h(Host,{class:"loading"},h("verdocs-loader",null))}if(!this.endpoint.session||!this.template){return h(Host,{class:"empty"})}return h(Host,null,h("h5",null,"Existing Attachments"),h("div",{class:"attachments"},(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){return h("div",{class:"attachment"},h("div",{class:"file-icon",innerHTML:e.getFileIcon(t)}),h("div",{class:"filename",title:t.name},t.name),h("div",{class:"pages"},h("div",{class:"count"},t.pages),h("div",{class:"pages-icon",innerHTML:PageCountIcon})),h("div",{class:"trash-icon",innerHTML:TrashIcon,onClick:function(){return e.handleDelete(t)}}))}))),h("h5",null,"Attach a New Document"),this.uploading?h("div",{class:"loader-wrapper"},h("verdocs-loader",null),this.progressLabel&&h("div",{class:"progress-wrapper"},h("verdocs-progress-bar",{showPercent:true,percent:this.progressPercent,label:this.progressLabel}))):h("verdocs-file-chooser",{onFileSelected: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)},disabled:this.uploading}),h("verdocs-button",{label:"Next",size:"small",onClick:function(t){return e.handleNext(t)},disabled:!(((n=this.template)===null||n===void 0?void 0:n.documents)||[]).length||this.uploading})),this.showDeleteError&&h("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:function(){return e.showDeleteError=false}}),this.confirmDeleteDocument&&h("verdocs-ok-dialog",{heading:"Delete this Attachment?",message:"This operation cannot be undone. All fields placed<br />on the deleted attachment will also be removed.",onNext:function(){return e.confirmDelete()},showCancel:true,onExit:function(){e.confirmDeleteDocument=null}}))};return e}();VerdocsTemplateAttachments.style=verdocsTemplateAttachmentsCss();var verdocsTemplateBuildTabsCss=function(){return'verdocs-template-build-tabs{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:end;align-items:flex-end;-ms-flex:0 0 50px;flex:0 0 50px;width:100%;background:#ffffff;color:#72757d;border-bottom:1px solid #dddddd;-webkit-filter:drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));filter:drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-template-build-tabs .tab{position:relative;display:-ms-flexbox;display:flex;-ms-flex:1;flex:1;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;height:50px;padding:0 4px;background:#e7e7e7;font-weight:700;font-size:12px;cursor:pointer}@media (min-width: 768px){verdocs-template-build-tabs .tab{padding:0 8px 0 24px;font-size:14px}}verdocs-template-build-tabs .tab svg{position:absolute;top:0;right:-19px;z-index:10;pointer-events:none;display:none}@media (min-width: 768px){verdocs-template-build-tabs .tab svg{display:block}}verdocs-template-build-tabs .tab.active{background:#ffffff;color:#707ae5}verdocs-template-build-tabs .tab.disabled{cursor:default;color:#d1d5db}'};var VerdocsTemplateBuildTabs=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.stepChanged=createEvent(this,"stepChanged");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.step="preview";this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[BUILD_TABS] Template ID changed",e);this.listenToTemplate()};e.prototype.onStepChanged=function(e){console.log("[BUILD_TABS] Step changed",e)};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(i){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){this.step="attachments";console.log("[BUILD_TABS] Missing required template ID, forcing view to attachments");return[2]}this.listenToTemplate()}catch(i){console.log("[BUILD_TABS] 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,(n=i.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.handleSelect=function(e){var t;if(e.disabled||e.id===this.step){return}this.step=e.id;(t=this.stepChanged)===null||t===void 0?void 0:t.emit(e.id)};e.prototype.render=function(){var e=this;var t,n,i;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var r=(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>0;var o=r&&(((n=this.template)===null||n===void 0?void 0:n.roles)||[]).length>0;var s=o&&(((i=this.template)===null||i===void 0?void 0:i.fields)||[]).length>0;var a=[{id:"attachments",label:"Attachments",disabled:false},{id:"roles",label:"Workflow",disabled:!r},{id:"fields",label:"Fields",disabled:!o},{id:"preview",label:"Preview & Send",disabled:!s}];return h(Host,null,a.map((function(t){var n=t.id===e.step;var i=["tab"];if(n)i.push("active");if(t.disabled)i.push("disabled");return h("div",{class:i.join(" "),onClick:function(){return e.handleSelect(t)}},h("span",null,t.label),h("svg",{"aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"19",height:"50",viewBox:"0 0 19 50"},h("polygon",{points:"0,0 19,25 0,50",fill:n?"#ffffff":"#e7e7e7"})))})))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:[{onTemplateIdChanged:0}],step:[{onStepChanged:0}]}},enumerable:false,configurable:true});return e}();VerdocsTemplateBuildTabs.style=verdocsTemplateBuildTabsCss();var verdocsTemplateFieldsCss=function(){return"verdocs-template-fields{font-family:var(--verdocs-primary-font, \"Inter\", \"Barlow\", sans-serif);position:relative;display:block;min-height:600px}verdocs-template-fields .verdocs-field-selected{outline:2px solid rgba(101, 77, 203, 0.75);outline-offset:1px}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 rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294)}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 .pages .document-separator{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:10px;padding:12px 20px;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:#33364b;color:white;border-radius:6px;font-size:16px;font-weight:500;margin-top:20px;-webkit-box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);box-shadow:0 2px 4px rgba(0, 0, 0, 0.1)}verdocs-template-fields .pages .document-separator svg{-ms-flex-negative:0;flex-shrink:0}verdocs-template-fields .pages .document-separator:first-child{margin-top:0}verdocs-template-fields #verdocs-template-fields-toolbar{width:100%;height:50px;display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;font-weight:700;padding:0 20px 0 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#f5f5fa;-ms-flex-pack:center;justify-content:center;background:#46497d}verdocs-template-fields #verdocs-template-fields-toolbar>verdocs-select-input{margin:0}verdocs-template-fields #verdocs-template-fields-toolbar svg{width:24px;height:24px}verdocs-template-fields #verdocs-template-fields-toolbar .add-for{margin:0;font-weight:500;color:#f5f5fa}verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{margin:0 20px 0 0}@media all and (max-width: 1000px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;padding:0 10px 0 0}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}@media all and (max-width: 600px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:6px;-moz-column-gap:6px;column-gap:6px}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.6);transform:scale(0.6)}verdocs-template-fields #verdocs-template-fields-toolbar .separator,verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}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 fill='%23000000' 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'/%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' stroke-width='1.5' stroke='currentColor'%3E%3Cpath stroke='%23000000' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25' /%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 width='32' height='15' viewBox='0 0 32 15' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cmask id='path-1-inside-1_1401_24' fill='white'%3E%3Cpath d='M0 0H32V15H0V0Z'/%3E%3C/mask%3E%3Cpath d='M0 0H32V15H0V0Z' fill='%234C56CB' fill-opacity='0.1'/%3E%3Cpath d='M0 0V-1H-1V0H0ZM0 15H-1V16H0V15ZM0 1H32V-1H0V1ZM32 14H0V16H32V14ZM1 15V0H-1V15H1Z' fill='%234C56CB' mask='url(%23path-1-inside-1_1401_24)'/%3E%3Cpath d='M3 11.8V8.65H14.15V11.8H3ZM3 6.65V3.5H20.15V6.65H3Z' fill='%234C56CB'/%3E%3Cline x1='31.5' y1='1' x2='31.5' y2='14' stroke='%234C56CB' stroke-opacity='0.32' stroke-dasharray='1 1'/%3E%3C/svg%3E%0A\") 0 14, 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 fill='%23000000' d='M9 1h6v2H9zm10.03 6.39 1.42-1.42c-.43-.51-.9-.99-1.41-1.41l-1.42 1.42C16.07 4.74 14.12 4 12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9 9-4.03 9-9c0-2.12-.74-4.07-1.97-5.61zM13 14h-2V8h2v6z'%3E%3C/path%3E%3C/svg%3E\") 16 16, pointer}"};var iconTextbox='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M3.425 16.15V13h11.15v3.15Zm0-5.15V7.85h17.15V11Z"/></svg>';var iconCheck='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" 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 fill="#ffffff" 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 fill="#ffffff" 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 fill="#ffffff" 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 fill="#ffffff" d="M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z"/></svg>';var iconDropdown='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" stroke-width="1.5" stroke="currentColor"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" d="M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25" /></svg>';var iconAttachment='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6"><path stroke-linecap="round" stroke-linejoin="round" d="m18.375 12.739-7.693 7.693a4.5 4.5 0 0 1-6.364-6.364l10.94-10.94A3 3 0 1 1 19.5 7.372L8.552 18.32m.009-.01-.01.01m5.699-9.941-7.81 7.81a1.5 1.5 0 0 0 2.112 2.13" /></svg>';var separator='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.707 14.707"><g><rect x="6.275" y="0" fill="#ffffff7f" width="1" height="15"/></g></svg>';var GEOMETRY_KEYS=["x","y","width","height","page","multiline"];var NUDGE_SAVE_DELAY_MS=400;var MAX_UNDO=50;var isTypingTarget=function(e){return!!e&&(["INPUT","TEXTAREA","SELECT"].includes(e.tagName)||e.isContentEditable)};var menuOptions=[{id:"signature",tooltip:"Signature",icon:iconSignature,class:"signature"},{id:"initial",tooltip:"Initials",icon:iconInitial,class:"initial"},{id:"sep1",tooltip:"",icon:separator,class:"separator"},{id:"textbox",tooltip:"Text Box",icon:iconTextbox,class:"textbox"},{id:"checkbox",tooltip:"Check Box",icon:iconCheck,class:"checkbox"},{id:"radio",tooltip:"Radio Button",icon:iconRadio,class:"radio"},{id:"dropdown",tooltip:"Dropdown",icon:iconDropdown,class:"dropdown"},{id:"sep2",tooltip:"",icon:separator,class:"separator"},{id:"date",tooltip:"Date",icon:iconDatepicker,class:"date"},{id:"attachment",tooltip:"Attachment",icon:iconAttachment,class:"attachment"}];var VerdocsTemplateFields=function(){function e(e){var t=this;registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.templateUpdated=createEvent(this,"templateUpdated");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.toolbarTargetId=null;this.placing=null;this.showMustSelectRole=false;this.selectedRoleName="";this.loading=true;this.template=null;this.pageHeights={};this.selectedFieldName=null;this.undoStack=[];this.pendingNudge=null;this.nudgeTimer=null;this.dragBefore=null;this.optimistic=new Map;this.inFlight=new Set;this.pendingResizes=new Map;this.handleFieldTap=function(e){var n,i;return t.selectField(((i=(n=e.currentTarget)===null||n===void 0?void 0:n.getAttribute)===null||i===void 0?void 0:i.call(n,"fieldname"))||null)};this.handleFieldResizeStart=function(e){var n,i;var r=((i=(n=e.target)===null||n===void 0?void 0:n.getAttribute)===null||i===void 0?void 0:i.call(n,"fieldname"))||null;t.flushNudge();t.selectField(r);t.startResize(r)};this.cachedPageInfo={}}e.prototype.onTemplateIdChanged=function(){this.listenToTemplate()};e.prototype.handleKeyDown=function(e){var t,n;if(e.key==="Escape"){this.placing=null;this.selectField(null);return}var i=((t=e.composedPath)===null||t===void 0?void 0:t.call(e)[0])||e.target;if(e.defaultPrevented||isTypingTarget(i)){return}if(i!==document.body&&i!==document.documentElement&&!this.el.contains(i)){return}if((e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="z"){if(this.pendingNudge||this.undoStack.length>0||this.inFlight.size>0||this.pendingResizes.size>0){e.preventDefault();this.undo()}return}var r=e.shiftKey?10:1;var o={ArrowLeft:[-r,0],ArrowRight:[r,0],ArrowUp:[0,r],ArrowDown:[0,-r]}[e.key];if(!o||!this.selectedFieldName||e.metaKey||e.ctrlKey||e.altKey){return}var s=this.findField(this.selectedFieldName);var a=s?(n=document.getElementById(getFieldId(s)))===null||n===void 0?void 0:n.getBoundingClientRect():null;if(!a||a.bottom<0||a.top>window.innerHeight||a.right<0||a.left>window.innerWidth){this.selectField(null);return}e.preventDefault();this.nudge(o[0],o[1])};e.prototype.handleFieldSettingsChanged=function(e){var t;var n=e.detail||{},i=n.fieldName,r=n.field;if(r&&i&&r.name!==i){this.renameFieldState(i,r.name)}var o=r?this.pendingResizes.get(r.name):null;if(o){this.recordUndo(r.name,o.before,r);o.settle()}(t=this.templateUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,template:this.template,event:"updated-field"})};e.prototype.handleFieldDeleted=function(e){var t,n;var i=(t=e.detail)===null||t===void 0?void 0:t.fieldName;if(i){this.forgetField(i)}(n=this.templateUpdated)===null||n===void 0?void 0:n.emit({endpoint:this.endpoint,template:this.template,event:"deleted-field"})};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(i){try{this.endpoint.loadSession();if(!this.templateId){console.log("[FIELDS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[FIELDS] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(i){console.log("[FIELDS] Error with fields session",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,(n=i.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.componentDidRender=function(){var e=this;interact.dynamicDrop(true);document.querySelectorAll(".verdocs-field").forEach((function(t){e.makeDraggable(t)}));var t=this.toolbarTargetId?document.getElementById(this.toolbarTargetId):null;var n=document.getElementById("verdocs-template-fields-toolbar");if(t&&n){n.remove();t.append(n)}this.applySelection()};e.prototype.componentWillUpdate=function(){var e=this;var t,n;var i=__spreadArray([],((t=this.template)===null||t===void 0?void 0:t.roles)||[],true).sort((function(e,t){var n,i;return((n=e.sequence)!==null&&n!==void 0?n:0)-((i=t.sequence)!==null&&i!==void 0?i:0)}));if(!this.selectedRoleName||!i.find((function(t){return t&&t.name===e.selectedRoleName}))){this.selectedRoleName=((n=i[0])===null||n===void 0?void 0:n.name)||"";console.log("[FIELDS] Selected new role",this.selectedRoleName)}};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate();this.flushNudge();this.selectField(null)};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){var n;console.log("Template updated");e.template=t;e.loading=false;if(!e.selectedRoleName){var i=__spreadArray([],t.roles||[],true).sort((function(e,t){var n,i;return((n=e.sequence)!==null&&n!==void 0?n:0)-((i=t.sequence)!==null&&i!==void 0?i:0)}));e.selectedRoleName=((n=i[0])===null||n===void 0?void 0:n.name)||""}}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.handlePageRendered=function(e){var t=this;var n,i;var r,o;var s=e.detail;console.log("[FIELDS] Page rendered",s.documentId,s.pageNumber,s.xScale,s.yScale);(n=(r=this.cachedPageInfo)[o=s.documentId])!==null&&n!==void 0?n:r[o]={};this.cachedPageInfo[s.documentId][s.pageNumber]=s;this.pageHeights[s.pageNumber]=s.naturalHeight;(((i=this.template)===null||i===void 0?void 0:i.fields)||[]).filter((function(e){return e&&e.page===s.pageNumber})).forEach((function(e){var n=getFieldId(e);var i=document.getElementById(n);if(i){i.setAttribute("templateid",t.templateId);i.setAttribute("fieldname",e.name);i.setAttribute("documentid",String(e.document_id));i.setAttribute("pagenumber",String(e.page));i.setAttribute("xScale",String(s.xScale));i.setAttribute("yScale",String(s.yScale));t.makeDraggable(i)}}))};e.prototype.makeDraggable=function(e){interact(e).draggable({listeners:{start:this.handleMoveStart.bind(this),move:this.handleMoveField.bind(this),end:this.handleMoveEnd.bind(this)}}).off("tap",this.handleFieldTap).on("tap",this.handleFieldTap).off("resizestart",this.handleFieldResizeStart).on("resizestart",this.handleFieldResizeStart)};e.prototype.findField=function(e){var t;return e?(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).find((function(t){return t.name===e})):undefined};e.prototype.currentGeometry=function(e){var t=__assign(__assign({},e),this.optimistic.get(e.name)),n=t.x,i=t.y,r=t.width,o=t.height,s=t.page,a=t.multiline;return{x:n,y:i,width:r,height:o,page:s,multiline:a}};e.prototype.selectField=function(e){if(this.pendingNudge&&this.pendingNudge.name!==e){this.flushNudge()}this.selectedFieldName=e;this.applySelection()};e.prototype.applySelection=function(){var e;document.querySelectorAll(".verdocs-field-selected").forEach((function(e){return e.classList.remove("verdocs-field-selected")}));var t=this.findField(this.selectedFieldName);if(t){(e=document.getElementById(getFieldId(t)))===null||e===void 0?void 0:e.classList.add("verdocs-field-selected")}};e.prototype.recordUndo=function(e,t,n){if(GEOMETRY_KEYS.some((function(e){return n[e]!==undefined&&n[e]!==t[e]}))){this.undoStack.push({name:e,before:t});this.undoStack.splice(0,Math.max(0,this.undoStack.length-MAX_UNDO))}};e.prototype.startResize=function(e){var t=this;var n;var i=this.findField(e);if(!i){return}(n=this.pendingResizes.get(i.name))===null||n===void 0?void 0:n.settle();var r;var o=new Promise((function(e){return r=e}));var s={before:this.currentGeometry(i),settle:function(){return r()},done:o};this.pendingResizes.set(i.name,s);var a=setTimeout((function(){return s.settle()}),5e3);o.then((function(){clearTimeout(a);if(t.pendingResizes.get(i.name)===s){t.pendingResizes.delete(i.name)}}))};e.prototype.renameFieldState=function(e,t){this.undoStack.forEach((function(n){return n.name===e&&(n.name=t)}));if(this.selectedFieldName===e){this.selectedFieldName=t}};e.prototype.forgetField=function(e){var t,n;this.undoStack=this.undoStack.filter((function(t){return t.name!==e}));this.optimistic.delete(e);(t=this.pendingResizes.get(e))===null||t===void 0?void 0:t.settle();if(((n=this.pendingNudge)===null||n===void 0?void 0:n.name)===e){clearTimeout(this.nudgeTimer);this.nudgeTimer=null;this.pendingNudge=null}if(this.selectedFieldName===e){this.selectField(null)}};e.prototype.drawField=function(e,t){if(t===void 0){t={}}var n,i;var r=(n=this.cachedPageInfo[e.document_id])===null||n===void 0?void 0:n[(i=t.page)!==null&&i!==void 0?i:e.page];var o=document.getElementById(getFieldId(e));if(o&&r){setControlStyles(o,__assign(__assign({},e),t),r.xScale,r.yScale)}};e.prototype.nudge=function(e,t){var n=this;var i,r,o,s,a;var l=this.findField(this.selectedFieldName);if(!l||!document.getElementById(getFieldId(l))||!((i=this.cachedPageInfo[l.document_id])===null||i===void 0?void 0:i[l.page])){return}if(((r=this.pendingNudge)===null||r===void 0?void 0:r.name)!==l.name){this.flushNudge();var d=this.currentGeometry(l);this.pendingNudge={name:l.name,before:d,x:d.x,y:d.y}}var c=(a=(s=(((o=this.template)===null||o===void 0?void 0:o.documents)||[]).find((function(e){return e.id===l.document_id})))===null||s===void 0?void 0:s.page_sizes)===null||a===void 0?void 0:a[l.page];var u=((c===null||c===void 0?void 0:c.width)||612)-(l.width||defaultWidth(l.type));var h=((c===null||c===void 0?void 0:c.height)||792)-(l.height||defaultHeight(l.type));this.pendingNudge.x=Math.min(Math.max(this.pendingNudge.x+e,0),u);this.pendingNudge.y=Math.min(Math.max(this.pendingNudge.y+t,0),h);this.drawField(l,{x:this.pendingNudge.x,y:this.pendingNudge.y});if(this.nudgeTimer){clearTimeout(this.nudgeTimer)}this.nudgeTimer=setTimeout((function(){return n.flushNudge()}),NUDGE_SAVE_DELAY_MS)};e.prototype.flushNudge=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:if(this.nudgeTimer){clearTimeout(this.nudgeTimer);this.nudgeTimer=null}e=this.pendingNudge;this.pendingNudge=null;if(!e)return[3,2];return[4,this.saveGeometry(e.name,{x:e.x,y:e.y},e.before)];case 1:t.sent();t.label=2;case 2:return[2]}}))}))};e.prototype.undo=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(i){switch(i.label){case 0:return[4,this.flushNudge()];case 1:i.sent();return[4,Promise.all(__spreadArray(__spreadArray([],this.inFlight,true),__spreadArray([],this.pendingResizes.values(),true).map((function(e){return e.done})),true))];case 2:i.sent();e=function(){var e,n,i,r;return __generator(this,(function(o){switch(o.label){case 0:e=t.undoStack.pop(),n=e.name,i=e.before;r=t.findField(n);if(!(r&&GEOMETRY_KEYS.some((function(e){return r[e]!==i[e]}))))return[3,2];t.selectField(n);return[4,t.saveGeometry(n,i)];case 1:o.sent();return[2,{value:void 0}];case 2:return[2]}}))};t=this;i.label=3;case 3:if(!(this.undoStack.length>0))return[3,5];return[5,e()];case 4:n=i.sent();if(typeof n==="object")return[2,n.value];return[3,3];case 5:return[2]}}))}))};e.prototype.saveGeometry=function(e,t,n){var i=this;var r=this.findField(e);if(!r){return Promise.resolve()}var o=__assign({},t);this.optimistic.set(e,o);this.drawField(r,t);var s=function(){return __awaiter(i,void 0,void 0,(function(){var i,r,s,a,l,d,c,u,h,f,v;return __generator(this,(function(p){switch(p.label){case 0:p.trys.push([0,2,3,4]);return[4,updateField(this.endpoint,this.templateId,e,t)];case 1:c=p.sent();u=JSON.parse(JSON.stringify(this.template));h=u.fields.findIndex((function(t){return t.name===e}));if(h>-1){u.fields[h]=c}Store.updateTemplate(this.templateId,u);this.drawField(c);if(n){this.recordUndo(e,n,c)}(i=this.templateUpdated)===null||i===void 0?void 0:i.emit({endpoint:this.endpoint,template:u,event:"updated-field"});return[3,4];case 2:f=p.sent();console.log("[FIELDS] Error saving field position",f);VerdocsToast(((s=(r=f.response)===null||r===void 0?void 0:r.data)===null||s===void 0?void 0:s.error)||"Unable to move the field. Please try again.",{style:"error"});(a=this.sdkError)===null||a===void 0?void 0:a.emit(new SDKError(f.message,(l=f.response)===null||l===void 0?void 0:l.status,(d=f.response)===null||d===void 0?void 0:d.data));v=this.findField(e);if(v){this.drawField(v)}return[3,4];case 3:if(this.optimistic.get(e)===o){this.optimistic.delete(e)}return[7];case 4:return[2]}}))}))}();this.inFlight.add(s);s.finally((function(){return i.inFlight.delete(s)}));return s};e.prototype.handleMoveStart=function(e){var t=e.target.getAttribute("fieldname");this.flushNudge();this.selectField(t);var n=this.findField(t);this.dragBefore=n?{name:t,before:this.currentGeometry(n)}:null};e.prototype.handleMoveField=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,i,r,o,s;return __generator(this,(function(a){t=+(e.target.getAttribute("posX")||0);n=+(e.target.getAttribute("posY")||0);i=+(e.target.getAttribute("xScale")||1);r=+(e.target.getAttribute("yScale")||1);o=e.dx/i+t;s=e.dy/r+n;e.target.setAttribute("posX",o);e.target.setAttribute("posy",s);updateCssTransform(e.target,"translate","".concat(o,"px, ").concat(s,"px"));return[2]}))}))};e.prototype.handleMoveEnd=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,i,r,o,s,a,l,d,c,u,h,f,v,p,g,m,x,b,w,E,_,S,y,k,I,C,T;return __generator(this,(function(D){switch(D.label){case 0:s=e.target.getAttribute("fieldname");a=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).find((function(e){return e.name===s}));if(!a){console.log("[FIELDS] Unable to find field",s,e.target);return[2]}l=e.target.getAttribute("pagenumber");d=e.target.getAttribute("documentid");c=this.cachedPageInfo[d][l],u=c.naturalWidth,h=u===void 0?612:u,f=c.naturalHeight,v=f===void 0?792:f,p=c.renderedHeight,g=p===void 0?792:p;m=e.target.getBoundingClientRect();x=e.target.parentElement;b=x.getBoundingClientRect();w=a.width||defaultWidth(a.type);E=a.height||defaultHeight(a.type);_=Math.max(m.left-b.left,0);S=Math.max(g-(b.bottom-m.bottom),0);y=parseInt(l);if(S>g){y=Math.min(y+1,((r=(i=((n=this.template)===null||n===void 0?void 0:n.documents)||[])===null||i===void 0?void 0:i[0])===null||r===void 0?void 0:r.pages)||1);S-=g;g=this.cachedPageInfo[d][y].renderedHeight;console.log("Next page",{newPageNumber:y,newY:S,renderedHeight:g})}else if(S<0){y=Math.max(y-1,1);g=this.cachedPageInfo[d][y].renderedHeight;S+=g;console.log("[FIELDS] Next page",{newPageNumber:y,newY:S,renderedHeight:g})}k=this.viewCoordinatesToPageCoordinates(_,S,d,l,h-w,v-E),I=k.x,C=k.y;e.target.removeAttribute("posX");e.target.removeAttribute("posY");removeCssTransform(e.target);T=((o=this.dragBefore)===null||o===void 0?void 0:o.name)===s?this.dragBefore.before:undefined;this.dragBefore=null;return[4,this.saveGeometry(s,{x:I,y:C,page:y},T)];case 1:D.sent();return[2]}}))}))};e.prototype.generateFieldName=function(e,t){var n;var i=1;var r;do{r="".concat(e,"P").concat(t,"-").concat(i);i++}while((((n=this.template)===null||n===void 0?void 0:n.fields)||[]).some((function(e){return e&&e.name===r})));return r};e.prototype.viewCoordinatesToPageCoordinates=function(e,t,n,i,r,o){var s=this.cachedPageInfo[n][i],a=s.xScale,l=a===void 0?1:a,d=s.yScale,c=d===void 0?1:d,u=s.renderedHeight,h=u===void 0?792:u;var f=Math.round(Math.min(e/l,r));var v=Math.round(Math.min(Math.max(h-t,0)/c,o));return{x:f,y:v}};e.prototype.handleClickPage=function(e,t,n){return __awaiter(this,void 0,void 0,(function(){var i,r,o,s,a,l,d,c,u,h,f,v,p,g,m,x,b,w;return __generator(this,(function(E){switch(E.label){case 0:if(!this.placing&&!((r=(i=e.target)===null||i===void 0?void 0:i.closest)===null||r===void 0?void 0:r.call(i,".verdocs-field"))){this.selectField(null)}if(!this.placing)return[3,2];s=e.offsetX;a=e.offsetY;l=defaultWidth(this.placing);d=defaultHeight(this.placing);c=this.cachedPageInfo[t][n];u=c.naturalWidth,h=u===void 0?612:u,f=c.naturalHeight,v=f===void 0?792:f;p=this.viewCoordinatesToPageCoordinates(s,a,t,n,h-l,v-d);g=Math.floor(p.x);m=Math.floor(p.y);x={name:this.generateFieldName(this.placing,n),role_name:this.selectedRoleName,template_id:this.templateId,document_id:c.documentId,type:this.placing,required:this.placing!=="radio"&&this.placing!=="attachment"&&this.placing!=="checkbox",page:n,validator:null,label:null,default:null,placeholder:null,group:null,settings:{},x:g,y:m,width:l,height:d,multiline:false,readonly:false,options:this.placing==="radio"?[{id:"option-1",label:"Option 1"}]:[]};return[4,createField(this.endpoint,this.templateId,x)];case 1:b=E.sent();console.log("[FIELDS] Created field",b);w=JSON.parse(JSON.stringify(this.template));w.fields.push(b);Store.updateTemplate(this.templateId,w);(o=this.templateUpdated)===null||o===void 0?void 0:o.emit({endpoint:this.endpoint,template:w,event:"added-field"});this.placing=null;E.label=2;case 2:return[2]}}))}))};e.prototype.render=function(){var e;var t=this;var n,i,r;console.log("Rendering");if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var o=__spreadArray([],((n=this.template)===null||n===void 0?void 0:n.roles)||[],true).sort((function(e,t){var n,i;return((n=e.sequence)!==null&&n!==void 0?n:0)-((i=t.sequence)!==null&&i!==void 0?i:0)}));var s=o.map((function(e){return{value:e.name,label:e.full_name?"".concat(e.name,": ").concat(e.full_name):e.name}}));return h(Host,{class:this.placing?(e={},e["placing-".concat(this.placing)]=true,e):{},onSubmit:function(){}},h("div",{id:"verdocs-template-fields-toolbar"},h("div",{class:"add-for"},"Add field:"),h("verdocs-select-input",{value:this.selectedRoleName,options:s,onInput:function(e){return t.selectedRoleName=e.target.value}}),menuOptions.map((function(e){return h("verdocs-toolbar-icon",{text:e.tooltip,icon:e.icon,class:e.class,onClick:function(){if(e.tooltip){if(t.selectedRoleName){t.placing=e.id}else{t.showMustSelectRole=true}}}})}))),h("div",{class:"pages"},(((i=this.template)===null||i===void 0?void 0:i.documents)||[]).map((function(e){var n=integerSequence(1,e.pages);return n.map((function(n){var i;var r=e.page_sizes[n];return h(Fragment,null,((i=t.template)===null||i===void 0?void 0:i.documents.length)>1&&h("div",{class:"document-separator"},h("div",{innerHTML:DocumentPageIcon}),h("span",null,e.name)),h("verdocs-template-document-page",{templateId:t.templateId,documentId:e.id,pageNumber:n,virtualWidth:(r===null||r===void 0?void 0:r.width)||612,virtualHeight:(r===null||r===void 0?void 0:r.height)||792,disabled:true,editable:true,done:false,onClick:function(i){return t.handleClickPage(i,e.id,n)},onPageRendered:function(e){return t.handlePageRendered(e)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]}))}))}))),this.showMustSelectRole&&h("verdocs-ok-dialog",{heading:"Unable to add field",message:(((r=this.template)===null||r===void 0?void 0:r.roles)||[]).length>0?"Please select a role before adding fields.":"Please add at least one role before adding fields.",onNext:function(){return t.showMustSelectRole=false}}))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{templateId:[{onTemplateIdChanged:0}]}},enumerable:false,configurable:true});return e}();VerdocsTemplateFields.style=verdocsTemplateFieldsCss();
2
2
  /**!
3
3
  * Sortable 1.15.7
4
4
  * @author RubaXa <trash@rubaxa.org>