@verdocs/web-sdk 5.0.0 → 5.0.2
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.
- package/dist/cjs/Icons-9a6f2f7c.js +86 -0
- package/dist/cjs/index-ccac8641.js +6 -10
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/verdocs-field-attachment_13.cjs.entry.js +1 -1
- package/dist/cjs/verdocs-field-payment.cjs.entry.js +1 -1
- package/dist/cjs/{verdocs-file-chooser.cjs.entry.js → verdocs-file-chooser_2.cjs.entry.js} +20 -1
- package/dist/cjs/{verdocs-preview_5.cjs.entry.js → verdocs-preview_6.cjs.entry.js} +155 -0
- package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/templates/verdocs-template-attachments/verdocs-template-attachments.css +120 -0
- package/dist/collection/components/templates/verdocs-template-attachments/verdocs-template-attachments.js +304 -0
- package/dist/components/index.js +2 -0
- package/dist/components/{p-82a3f92e.js → p-0a69031f.js} +1 -1
- package/dist/components/{p-bdc03b91.js → p-1ca705bc.js} +1 -1
- package/dist/{esm/verdocs-file-chooser.entry.js → components/p-22da6d14.js} +31 -8
- package/dist/components/{p-94065def.js → p-22e52874.js} +11 -11
- package/dist/components/{p-4e08dcdd.js → p-49153610.js} +1 -1
- package/dist/components/{p-649a2ae7.js → p-4afcdc84.js} +1 -1
- package/dist/components/{p-1030e0b1.js → p-9c3fd545.js} +1 -1
- package/dist/components/{p-258c3c53.js → p-a22a3b1b.js} +10 -10
- package/dist/components/p-b0766439.js +76 -0
- package/dist/components/{p-642af221.js → p-b0c02eb8.js} +1 -1
- package/dist/components/{p-5d1dec61.js → p-c25e82b9.js} +11 -11
- package/dist/components/{p-b9a18099.js → p-d9704a51.js} +1 -1
- package/dist/components/{p-81794664.js → p-dd701894.js} +1 -1
- package/dist/components/{p-1fc15f94.js → p-ecc818bb.js} +1 -1
- package/dist/components/p-ed88b8d2.js +220 -0
- package/dist/components/{p-caa41754.js → p-fd96322b.js} +1 -1
- package/dist/components/verdocs-build.js +72 -54
- package/dist/components/verdocs-field-attachment.js +1 -1
- package/dist/components/verdocs-field-checkbox.js +1 -1
- package/dist/components/verdocs-field-date.js +1 -1
- package/dist/components/verdocs-field-dropdown.js +1 -1
- package/dist/components/verdocs-field-initial.js +1 -1
- package/dist/components/verdocs-field-payment.js +1 -1
- package/dist/components/verdocs-field-radio.js +1 -1
- package/dist/components/verdocs-field-signature.js +1 -1
- package/dist/components/verdocs-field-textarea.js +1 -1
- package/dist/components/verdocs-field-textbox.js +1 -1
- package/dist/components/verdocs-field-timestamp.js +1 -1
- package/dist/components/verdocs-file-chooser.js +1 -56
- package/dist/components/verdocs-preview.js +1 -1
- package/dist/components/verdocs-template-attachments.d.ts +11 -0
- package/dist/components/verdocs-template-attachments.js +6 -0
- package/dist/components/verdocs-template-document-page.js +1 -1
- package/dist/components/verdocs-template-fields.js +1 -1
- package/dist/custom-elements.json +13 -0
- package/dist/esm/Icons-faf0377f.js +76 -0
- package/dist/esm/index-272d51a4.js +6 -10
- package/dist/esm/loader.js +1 -1
- package/dist/esm/verdocs-field-attachment_13.entry.js +1 -1
- package/dist/esm/verdocs-field-payment.entry.js +1 -1
- package/dist/esm/verdocs-file-chooser_2.entry.js +53 -0
- package/dist/esm/{verdocs-preview_5.entry.js → verdocs-preview_6.entry.js} +156 -2
- package/dist/esm/verdocs-web-sdk.js +1 -1
- package/dist/esm-es5/Icons-faf0377f.js +1 -0
- package/dist/esm-es5/index-272d51a4.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/verdocs-field-attachment_13.entry.js +1 -1
- package/dist/esm-es5/verdocs-field-payment.entry.js +1 -1
- package/dist/esm-es5/verdocs-file-chooser_2.entry.js +1 -0
- package/dist/esm-es5/verdocs-preview_6.entry.js +1 -0
- package/dist/esm-es5/verdocs-web-sdk.js +1 -1
- package/dist/types/components/templates/verdocs-template-attachments/verdocs-template-attachments.d.ts +60 -0
- package/dist/types/components.d.ts +79 -0
- package/dist/verdocs-web-sdk/{p-f7abe6e2.entry.js → p-0e9de098.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-80ce3711.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-81c8663f.entry.js +1 -0
- package/dist/verdocs-web-sdk/{p-e5044463.entry.js → p-8c03fc69.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-b00ef194.system.entry.js → p-8d401072.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/{p-9812e99d.system.entry.js → p-97b00cae.system.entry.js} +1 -1
- package/dist/verdocs-web-sdk/p-b0766439.js +1 -0
- package/dist/verdocs-web-sdk/p-cd546dbe.system.js +1 -0
- package/dist/verdocs-web-sdk/p-df392ef9.entry.js +1 -0
- package/dist/verdocs-web-sdk/p-e2b70dfb.system.js +1 -1
- package/dist/verdocs-web-sdk/p-edfb1951.system.entry.js +1 -0
- package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/Icons-02a47df1.js +0 -7
- package/dist/cjs/verdocs-progress-bar.cjs.entry.js +0 -25
- package/dist/components/p-7e9c499e.js +0 -4
- package/dist/esm/Icons-190fd11d.js +0 -4
- package/dist/esm/verdocs-progress-bar.entry.js +0 -21
- package/dist/esm-es5/Icons-190fd11d.js +0 -1
- package/dist/esm-es5/verdocs-file-chooser.entry.js +0 -1
- package/dist/esm-es5/verdocs-preview_5.entry.js +0 -1
- package/dist/esm-es5/verdocs-progress-bar.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-1efce6e0.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-6a95ce12.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-79f842b4.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-7e9c499e.js +0 -1
- package/dist/verdocs-web-sdk/p-a7db9f1f.system.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-d93c7661.entry.js +0 -1
- package/dist/verdocs-web-sdk/p-efd8149f.system.js +0 -1
- package/dist/verdocs-web-sdk/p-f65a9b03.entry.js +0 -1
@@ -1480,6 +1480,20 @@ export namespace Components {
|
|
1480
1480
|
*/
|
1481
1481
|
"tabs": ITab[];
|
1482
1482
|
}
|
1483
|
+
/**
|
1484
|
+
* Displays an edit form that allows the user to view, add, or remove a template's attachments.
|
1485
|
+
* Note that an active session and valid template ID must be supplied.
|
1486
|
+
*/
|
1487
|
+
interface VerdocsTemplateAttachments {
|
1488
|
+
/**
|
1489
|
+
* The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.
|
1490
|
+
*/
|
1491
|
+
"endpoint": VerdocsEndpoint;
|
1492
|
+
/**
|
1493
|
+
* The template ID to edit.
|
1494
|
+
*/
|
1495
|
+
"templateId": string;
|
1496
|
+
}
|
1483
1497
|
/**
|
1484
1498
|
* Display a set of tabs for the template builder.
|
1485
1499
|
*/
|
@@ -1986,6 +2000,10 @@ export interface VerdocsTabsCustomEvent<T> extends CustomEvent<T> {
|
|
1986
2000
|
detail: T;
|
1987
2001
|
target: HTMLVerdocsTabsElement;
|
1988
2002
|
}
|
2003
|
+
export interface VerdocsTemplateAttachmentsCustomEvent<T> extends CustomEvent<T> {
|
2004
|
+
detail: T;
|
2005
|
+
target: HTMLVerdocsTemplateAttachmentsElement;
|
2006
|
+
}
|
1989
2007
|
export interface VerdocsTemplateBuildTabsCustomEvent<T> extends CustomEvent<T> {
|
1990
2008
|
detail: T;
|
1991
2009
|
target: HTMLVerdocsTemplateBuildTabsElement;
|
@@ -3157,6 +3175,30 @@ declare global {
|
|
3157
3175
|
prototype: HTMLVerdocsTabsElement;
|
3158
3176
|
new (): HTMLVerdocsTabsElement;
|
3159
3177
|
};
|
3178
|
+
interface HTMLVerdocsTemplateAttachmentsElementEventMap {
|
3179
|
+
"exit": any;
|
3180
|
+
"next": {template: ITemplate};
|
3181
|
+
"templateUpdated": {endpoint: VerdocsEndpoint; template: ITemplate; event: string};
|
3182
|
+
"sdkError": SDKError;
|
3183
|
+
}
|
3184
|
+
/**
|
3185
|
+
* Displays an edit form that allows the user to view, add, or remove a template's attachments.
|
3186
|
+
* Note that an active session and valid template ID must be supplied.
|
3187
|
+
*/
|
3188
|
+
interface HTMLVerdocsTemplateAttachmentsElement extends Components.VerdocsTemplateAttachments, HTMLStencilElement {
|
3189
|
+
addEventListener<K extends keyof HTMLVerdocsTemplateAttachmentsElementEventMap>(type: K, listener: (this: HTMLVerdocsTemplateAttachmentsElement, ev: VerdocsTemplateAttachmentsCustomEvent<HTMLVerdocsTemplateAttachmentsElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
3190
|
+
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
3191
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
3192
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
3193
|
+
removeEventListener<K extends keyof HTMLVerdocsTemplateAttachmentsElementEventMap>(type: K, listener: (this: HTMLVerdocsTemplateAttachmentsElement, ev: VerdocsTemplateAttachmentsCustomEvent<HTMLVerdocsTemplateAttachmentsElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
|
3194
|
+
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
3195
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
3196
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
3197
|
+
}
|
3198
|
+
var HTMLVerdocsTemplateAttachmentsElement: {
|
3199
|
+
prototype: HTMLVerdocsTemplateAttachmentsElement;
|
3200
|
+
new (): HTMLVerdocsTemplateAttachmentsElement;
|
3201
|
+
};
|
3160
3202
|
interface HTMLVerdocsTemplateBuildTabsElementEventMap {
|
3161
3203
|
"sdkError": SDKError;
|
3162
3204
|
"stepChanged": TVerdocsBuildStep1;
|
@@ -3551,6 +3593,7 @@ declare global {
|
|
3551
3593
|
"verdocs-switch": HTMLVerdocsSwitchElement;
|
3552
3594
|
"verdocs-table": HTMLVerdocsTableElement;
|
3553
3595
|
"verdocs-tabs": HTMLVerdocsTabsElement;
|
3596
|
+
"verdocs-template-attachments": HTMLVerdocsTemplateAttachmentsElement;
|
3554
3597
|
"verdocs-template-build-tabs": HTMLVerdocsTemplateBuildTabsElement;
|
3555
3598
|
"verdocs-template-card": HTMLVerdocsTemplateCardElement;
|
3556
3599
|
"verdocs-template-create": HTMLVerdocsTemplateCreateElement;
|
@@ -5339,6 +5382,36 @@ declare namespace LocalJSX {
|
|
5339
5382
|
*/
|
5340
5383
|
"tabs"?: ITab[];
|
5341
5384
|
}
|
5385
|
+
/**
|
5386
|
+
* Displays an edit form that allows the user to view, add, or remove a template's attachments.
|
5387
|
+
* Note that an active session and valid template ID must be supplied.
|
5388
|
+
*/
|
5389
|
+
interface VerdocsTemplateAttachments {
|
5390
|
+
/**
|
5391
|
+
* The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.
|
5392
|
+
*/
|
5393
|
+
"endpoint"?: VerdocsEndpoint;
|
5394
|
+
/**
|
5395
|
+
* Event fired when the step is cancelled. This is called exit to avoid conflicts with the JS-reserved "cancel" event name.
|
5396
|
+
*/
|
5397
|
+
"onExit"?: (event: VerdocsTemplateAttachmentsCustomEvent<any>) => void;
|
5398
|
+
/**
|
5399
|
+
* Event fired when the user clicks the next button.
|
5400
|
+
*/
|
5401
|
+
"onNext"?: (event: VerdocsTemplateAttachmentsCustomEvent<{template: ITemplate}>) => void;
|
5402
|
+
/**
|
5403
|
+
* Event fired if an error occurs. The event details will contain information about the error. Most errors will terminate the process, and the calling application should correct the condition and re-render the component.
|
5404
|
+
*/
|
5405
|
+
"onSdkError"?: (event: VerdocsTemplateAttachmentsCustomEvent<SDKError>) => void;
|
5406
|
+
/**
|
5407
|
+
* Event fired when the user updates the template.
|
5408
|
+
*/
|
5409
|
+
"onTemplateUpdated"?: (event: VerdocsTemplateAttachmentsCustomEvent<{endpoint: VerdocsEndpoint; template: ITemplate; event: string}>) => void;
|
5410
|
+
/**
|
5411
|
+
* The template ID to edit.
|
5412
|
+
*/
|
5413
|
+
"templateId"?: string;
|
5414
|
+
}
|
5342
5415
|
/**
|
5343
5416
|
* Display a set of tabs for the template builder.
|
5344
5417
|
*/
|
@@ -5912,6 +5985,7 @@ declare namespace LocalJSX {
|
|
5912
5985
|
"verdocs-switch": VerdocsSwitch;
|
5913
5986
|
"verdocs-table": VerdocsTable;
|
5914
5987
|
"verdocs-tabs": VerdocsTabs;
|
5988
|
+
"verdocs-template-attachments": VerdocsTemplateAttachments;
|
5915
5989
|
"verdocs-template-build-tabs": VerdocsTemplateBuildTabs;
|
5916
5990
|
"verdocs-template-card": VerdocsTemplateCard;
|
5917
5991
|
"verdocs-template-create": VerdocsTemplateCreate;
|
@@ -6344,6 +6418,11 @@ declare module "@stencil/core" {
|
|
6344
6418
|
* ```
|
6345
6419
|
*/
|
6346
6420
|
"verdocs-tabs": LocalJSX.VerdocsTabs & JSXBase.HTMLAttributes<HTMLVerdocsTabsElement>;
|
6421
|
+
/**
|
6422
|
+
* Displays an edit form that allows the user to view, add, or remove a template's attachments.
|
6423
|
+
* Note that an active session and valid template ID must be supplied.
|
6424
|
+
*/
|
6425
|
+
"verdocs-template-attachments": LocalJSX.VerdocsTemplateAttachments & JSXBase.HTMLAttributes<HTMLVerdocsTemplateAttachmentsElement>;
|
6347
6426
|
/**
|
6348
6427
|
* Display a set of tabs for the template builder.
|
6349
6428
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
import{r as e,c as t,h as i,F as s,H as o}from"./p-b9654a5e.js";import{getRGBA as r}from"@verdocs/js-sdk";import{S as n}from"./p-
|
1
|
+
import{r as e,c as t,h as i,F as s,H as o}from"./p-b9654a5e.js";import{getRGBA as r}from"@verdocs/js-sdk";import{S as n}from"./p-b0766439.js";import{S as a}from"./p-da4d4eed.js";const d=class{constructor(i){e(this,i),this.settingsChanged=t(this,"settingsChanged",7),this.deleted=t(this,"deleted",7),this.source="template",this.sourceid="",this.fieldname="",this.disabled=!1,this.done=!1,this.editable=!1,this.moveable=!1,this.xscale=1,this.yscale=1,this.pagenumber=1,this.showingProperties=!1,this.focused=!1,this.fields=void 0,this.pageNum=void 0,this.roleName=void 0,this.fieldId=void 0,this.recipients=void 0,this.selectedRoleName=void 0,this.pdfPages=void 0,this.currentSignature=void 0,this.currentSignatureId=void 0,this.currentInitial=void 0,this.currentInitialId=void 0,this.signed=!1,this.preparedMessage=void 0,this.signatureUrl="",this.roleindex=0}componentWillLoad(){if(this.recipients&&this.recipients.length>0){const e=this.recipients.find((e=>"preparer"===e.type));console.log("Found preparer",e),e&&(this.preparedMessage=`Prepared by ${e.full_name}`)}}async focusField(){this.focused=!0,setTimeout((()=>{this.focused=!1}),500)}async showSettingsPanel(){const e=document.getElementById(`verdocs-settings-panel-${this.fieldname}`);e&&e.showPanel&&e.showPanel()}async hideSettingsPanel(){const e=document.getElementById(`verdocs-settings-panel-${this.fieldname}`);e&&e.hidePanel&&e.hidePanel()}render(){const{source:e,sourceid:t,fieldname:d,editable:l=!1,done:c=!1,disabled:p=!1,focused:h,xscale:g=1,yscale:f=1}=this,{index:b,field:m}=a.getField(e,t,d),u=r(b);return m?c?i(o,{class:{done:c}},"$✓"):i(o,{class:{focused:h,disabled:p},style:{backgroundColor:u}},i("button",{class:{hide:this.signed}},"$"),i("div",this.signed?{class:"frame"}:{style:{display:"none"}}),i("img",{width:"100%",height:"100%",src:this.signatureUrl,alt:"Payment Icon"}),l&&i(s,null,i("div",{id:`verdocs-settings-panel-trigger-${d}`,style:{transform:`scale(${Math.floor(1/g*1e3)/1e3}, ${Math.floor(1/f*1e3)/1e3})`},class:"settings-icon",innerHTML:n,onClick:e=>{e.stopPropagation(),this.showingProperties=!this.showingProperties}}),this.showingProperties&&i("verdocs-portal",{anchor:`verdocs-settings-panel-trigger-${m.name}`,onClickAway:()=>this.showingProperties=!1},i("verdocs-template-field-properties",{templateId:t,fieldName:m.name,onClose:()=>this.showingProperties=!1,onDelete:()=>{var e;return null===(e=this.deleted)||void 0===e||e.emit({fieldName:d}),this.hideSettingsPanel()},onSettingsChanged:e=>{var t;return null===(t=this.settingsChanged)||void 0===t||t.emit(e.detail),this.hideSettingsPanel()},helpText:"Check boxes allow the user to select one or more (non-exclusive) options."})))):i(s,null)}};d.style='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-field-payment{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;width:24px;height:24px;display:block;font-size:11px;position:relative;scroll-margin:20px 0;border:1px solid #cfa;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-payment.disabled{opacity:0.5}verdocs-field-payment button,verdocs-field-payment div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-field-payment button{color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-payment button.hide{display:none}verdocs-field-payment input{float:left;font-family:Arial, sans-serif}verdocs-field-payment select{position:absolute;font-family:Arial, sans-serif;background:linear-gradient(55deg, transparent 50%, #333 50%), linear-gradient(125deg, #333 50%, transparent 50%), linear-gradient(to right, transparent, transparent);background-position:calc(100% - 7px) 4px, calc(100% - 3px) 4px, 100% 0;background-size:5px 5px, 5px 5px, 2.5em 2.5em;background-repeat:no-repeat;-webkit-appearance:none;-moz-appearance:none;appearance:none}verdocs-field-payment .frame{width:100%;height:100%;background-size:contain;text-align:left}verdocs-field-payment .frame img{position:absolute;height:auto;width:100%}verdocs-field-payment.focused{-webkit-animation:verdocs-field-pulse 0.4s 1;animation:verdocs-field-pulse 0.4s 1}verdocs-field-payment .settings-icon{position:absolute;top:-3px;left:-20px;display:inline-block;cursor:pointer;opacity:0.3}verdocs-field-payment .settings-icon svg{fill:#707ae5}verdocs-field-payment .settings-icon:hover{opacity:1}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}';export{d as verdocs_field_payment}
|
@@ -0,0 +1 @@
|
|
1
|
+
System.register(["./p-9186f42e.system.js","@verdocs/js-sdk","./p-cd546dbe.system.js"],(function(e){"use strict";var o,r,s,c,i,l;return{setters:[function(e){o=e.r;r=e.c;s=e.h;c=e.H},function(e){i=e.VerdocsEndpoint},function(e){l=e.u}],execute:function(){var d='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-file-chooser{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-file-chooser .upload-box{text-align:center;-webkit-box-sizing:border-box;box-sizing:border-box;padding:40px 15px;color:rgba(0, 0, 0, 0.54)}verdocs-file-chooser .upload-box svg{width:64px;height:64px;fill:#5c6575}verdocs-file-chooser .selected-filename{font-size:20px;font-weight:bold;overflow-wrap:anywhere}verdocs-file-chooser .or-prefer{height:20px;margin:20px 0;font-size:16px}';var a=d;var f=e("verdocs_file_chooser",function(){function e(e){o(this,e);this.fileSelected=r(this,"fileSelected",7);this.endpoint=i.getDefault();this.file=undefined}e.prototype.handleFileChanged=function(e){var o,r;this.file=((o=e.target.files)===null||o===void 0?void 0:o[0])||null;(r=this.fileSelected)===null||r===void 0?void 0:r.emit({file:this.file});console.debug("[CHOOSER] Selected file",this.file)};e.prototype.handleSelectFile=function(e){var o,r;e.stopPropagation();this.file=null;(o=this.fileSelected)===null||o===void 0?void 0:o.emit({file:null});(r=document.getElementById("verdocs-file-chooser"))===null||r===void 0?void 0:r.click()};e.prototype.render=function(){var e=this;var o=this.file?"Select a different file":"Select a file from your computer";return s(c,{key:"be9ae4e6e32d7c284001b7fea41d96f39b642005"},s("input",{key:"0bc7cd1766b630372ea380300575dfd239bc86e4",type:"file",multiple:true,id:"verdocs-file-chooser",accept:"application/pdf,.pdf,.doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:function(o){return e.handleFileChanged(o)}}),s("div",{key:"dbd3aa4e9d64b4bd427f4c6e198d92b10e94dfff",class:"upload-box"},s("div",{key:"41a10b9ffbe862bedc300cdbb8d2a366dc00414e",class:"selected-filename"},this.file?this.file.name:"Drag a file here"),s("div",{key:"128679d890e1c68ff1c7fb47abd4f638db453b87",class:"or-prefer"},this.file?l:"Or, if you prefer..."),s("verdocs-button",{key:"277c4246513e40dc2bc5e7f0f7d7130d52904813",label:o,size:"small",onClick:function(o){return e.handleSelectFile(o)}})))};return e}());f.style=a;var t='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-progress-bar{font-family:"Inter", "Barlow", sans-serif;width:100%;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-progress-bar .labels{display:-ms-flexbox;display:flex;margin:0 0 8px 0;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between}verdocs-progress-bar .labels .label{display:-ms-flexbox;display:flex;font-size:14px;font-weight:600;margin-right:8px;color:#33364b}verdocs-progress-bar .bar{display:-ms-flexbox;display:flex;-ms-flex:0 0 10px;flex:0 0 10px;border-radius:5px;background-color:#cccccc}verdocs-progress-bar .bar .slider{display:-ms-flexbox;display:flex;border-radius:5px;background-color:#55bc81}';var n=t;var b=e("verdocs_progress_bar",function(){function e(e){o(this,e);this.label="";this.showPercent=false;this.percent=0}e.prototype.render=function(){var e=Math.ceil(100*Math.min(this.percent,100)/100);console.log("Rendering progress bar",{widthPercent:e,label:this.label,showPercent:this.showPercent,percent:this.percent});return s(c,{key:"c57b566587b7fe5f95f7082964dc7d27c46008cb"},s("div",{key:"b44243b4c65cdd5ddb7a47028db07e47e1c9373b",class:"labels"},this.label&&s("div",{key:"58715d2cd0a47260618472ed06d3eeda095ea852",class:"label"},this.label),this.showPercent&&s("div",{key:"38b9fa2f2180eee29cdc6aff0562475c9d6cc943",class:"label"},this.percent,"%")),s("div",{key:"1258f3696cb5852865e7d1af59bf2acb7acfda50",class:"bar"},s("div",{key:"eb1346d2b9f7ccce786c358ef247fd3ec62de67f",class:"slider",style:{width:"".concat(e,"%")}})))};return e}());b.style=n}}}));
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as e,c as t,h as s,H as i,F as o,g as l}from"./p-b9654a5e.js";import{VerdocsEndpoint as a,getTemplate as n,integerSequence as r,getOrganizationContacts as d,isValidEmail as c,createEnvelope as p,getRGBA as h,formatFullName as m,createTemplateDocument as v,deleteTemplateDocument as g,updateField as u,createField as f,updateTemplateRole as x,createTemplateRole as b}from"@verdocs/js-sdk";import{S as w}from"./p-fd97809c.js";import{S as k}from"./p-da4d4eed.js";import{V as y}from"./p-04c07b7b.js";import{D as q,P as C,J as E,a as S,F as M,b as T,T as L}from"./p-b0766439.js";import{f as H}from"./p-12bab948.js";import{i as z}from"./p-a901dff2.js";import{b as Z,c as I,d as V,g as D,e as N,f as _}from"./p-650697bd.js";import"./p-85aa8e05.js";import"./p-c7ee88c7.js";const R=class{constructor(s){e(this,s),this.sdkError=t(this,"sdkError",7),this.templateListenerId=null,this.endpoint=a.getDefault(),this.templateId=null,this.loading=!0,this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate(),k.subscribe("templates",this.templateId,(()=>n(this.endpoint,this.templateId)),!1,(e=>{this.template=e,this.loading=!1}))}unlistenToTemplate(){this.templateListenerId&&(k.store.delListener(this.templateListenerId),this.templateListenerId=null)}onTemplateIdChanged(e){console.log("[PREVIEW] Template ID changed",e),this.listenToTemplate()}async componentWillLoad(){var e,t,s;try{if(this.endpoint.loadSession(),!this.endpoint.session)return void console.log("[PREVIEW] Unable to start builder session, must be authenticated");if(!this.templateId)return void console.log(`[PREVIEW] Missing required template ID ${this.templateId}`);this.listenToTemplate()}catch(i){console.log("[PREVIEW] Error with preview session",i),null===(e=this.sdkError)||void 0===e||e.emit(new w(i.message,null===(t=i.response)||void 0===t?void 0:t.status,null===(s=i.response)||void 0===s?void 0:s.data))}}handlePageRendered(e){}render(){var e;return s(i,null,this.loading?s("verdocs-loader",null):((null===(e=this.template)||void 0===e?void 0:e.documents)||[]).map((e=>{const t=r(1,e.pages);return s(o,null,t.map((t=>{var i;const o=(null===(i=e.page_sizes)||void 0===i?void 0:i[t])||{width:612,height:792};return s("verdocs-template-document-page",{templateId:e.template_id,documentId:e.id,pageNumber:t,disabled:!0,editable:!1,done:!1,virtualWidth:o.width,virtualHeight:o.height,onPageRendered:e=>this.handlePageRendered(e),layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))})))}static get watchers(){return{templateId:["onTemplateIdChanged"]}}};R.style='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-preview{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", 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}';const A=e=>((null==e?void 0:e.roles)||[]).map((e=>e.name)),U=(e,t)=>Math.max(A(e).findIndex((e=>e===t)),0),B='<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path></svg>',Q=class{constructor(s){e(this,s),this.sendingEnvelope=t(this,"sendingEnvelope",7),this.send=t(this,"send",7),this.exit=t(this,"exit",7),this.sdkError=t(this,"sdkError",7),this.searchContacts=t(this,"searchContacts",7),this.templateListenerId=null,this.endpoint=a.getDefault(),this.templateId=null,this.environment="",this.containerId=`verdocs-send-${Math.random().toString(36).substring(2,11)}`,this.showPickerForId="",this.sessionContacts=[],this.sending=!1,this.rolesCompleted={},this.loading=!0,this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){console.log("[SEND] Loading template",this.templateId),this.unlistenToTemplate(),k.subscribe("templates",this.templateId,(()=>n(this.endpoint,this.templateId)),!1,(e=>{this.template=e,this.loading=!1,this.rolesCompleted={}}))}unlistenToTemplate(){this.templateListenerId&&(k.store.delListener(this.templateListenerId),this.templateListenerId=null)}async reset(){this.rolesCompleted={}}onTemplateIdChanged(e){console.log("[SEND] Template ID changed",e),this.listenToTemplate()}async componentWillLoad(){var e,t,s;try{if(this.endpoint.onSessionChanged(((e,t,s)=>{if(!s)return;const i={id:s.id,first_name:s.first_name,last_name:s.last_name,email:s.email,phone:s.phone};s&&(this.sessionContacts=[i],d(this.endpoint).then((e=>{console.log("[SEND] Got contacts",e),this.sessionContacts=[...e,i]})).catch((e=>{console.log("[SEND] Error getting contacts",e)})))})),this.endpoint.loadSession(),!this.endpoint.session)return void console.log("[SEND] Unable to start Send operation, must be authenticated");if(!this.templateId)return void console.log(`[SEND] Missing required template ID ${this.templateId}`);this.listenToTemplate()}catch(i){console.log("[SEND] Error with send session",i),null===(e=this.sdkError)||void 0===e||e.emit(new w(i.message,null===(t=i.response)||void 0===t?void 0:t.status,null===(s=i.response)||void 0===s?void 0:s.data))}}recomputeRolesCompleted(){var e;this.rolesCompleted={};const t={};((null===(e=this.template)||void 0===e?void 0:e.roles)||[]).forEach((e=>{const s=e.sequence-1;t[s]||(t[s]=[]);const i=`r-${s}-${t[s].length}`;t[s].push({...e,id:i,role_name:e.name,first_name:e.first_name,last_name:e.last_name}),e.first_name&&c(e.email)&&(this.rolesCompleted[i]={...e,id:i,role_name:e.name,first_name:e.first_name,last_name:e.last_name})}))}getLevels(){var e;const t=[...new Set(((null===(e=this.template)||void 0===e?void 0:e.roles)||[]).map((e=>e.sequence-1)))];return t.sort(((e,t)=>e-t)),t}getRolesAtLevel(e){var t;return((null===(t=this.template)||void 0===t?void 0:t.roles)||[]).filter((t=>t.sequence-1===e)).map(((t,s)=>({...t,id:`r-${e}-${s}`,role_name:t.name,first_name:"",last_name:""})))}getLevelIcon(e){const t=this.getLevels();return s("div",e<0?{class:"level-icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z"></path></svg>'}:e>=t.length?{class:"level-icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="m18 7-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41 6 19l1.41-1.41L1.83 12 .41 13.41z"></path></svg>'}:{class:"level-icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></svg>'})}handleSelectContact(e,t){e.preventDefault(),this.rolesCompleted[t.id]={...t,...e.detail},this.showPickerForId=""}handleClickRole(e,t){e.stopPropagation(),this.showPickerForId=t.id}handleSend(e){var t,s;if(this.sending)return void console.log("[SEND] Skipping duplicate send",e);console.log("[SEND] Sending",e),e.preventDefault(),e.stopPropagation(),this.sending=!0,null===(t=this.sendingEnvelope)||void 0===t||t.emit({sending:!0});const i={template_id:this.templateId,name:(null===(s=this.template)||void 0===s?void 0:s.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted),fields:[]};console.log("[SEND] Creating envelope",i),p(this.endpoint,i).then((e=>{var t,s;console.log("[SEND] Send envelope",e),this.reset().catch((e=>console.log("Unknown Error",e))),this.sending=!1,null===(t=this.sendingEnvelope)||void 0===t||t.emit({sending:!1}),null===(s=this.send)||void 0===s||s.emit({...i,name:i.name,envelope_id:e.id,envelope:e})})).catch((e=>{var t,s,i;console.log("Send error",e),y((null===(s=null===(t=e.response)||void 0===t?void 0:t.data)||void 0===s?void 0:s.error)||"Error creating envelope, please try again later."),this.sending=!1,null===(i=this.sendingEnvelope)||void 0===i||i.emit({sending:!1})}))}handleCancel(e){var t;e.stopPropagation(),null===(t=this.exit)||void 0===t||t.emit()}render(){var e;if(this.loading)return s(i,null,s("verdocs-loader",null));if(!this.endpoint.session)return s(i,{style:{display:"flex"}},s("verdocs-component-error",{message:"You must be authenticated to use this module."}));const t=this.getLevels(),o=Object.values(this.rolesCompleted).filter((e=>c(e.email))).length>=A(this.template).length;return s(i,{class:{sendable:null===(e=this.template)||void 0===e?void 0:e.is_sendable}},s("div",{class:"recipients"},s("div",{class:"left-line"}),s("div",{class:"level level-start"},this.getLevelIcon(-1),s("div",{class:"complete"},"Send Envelope")),t.map((e=>s("div",{class:`level level-${e}`},this.getLevelIcon(e),this.getRolesAtLevel(e).map((e=>{var t,i,o,l;const a=!e.email,n=`verdocs-send-recipient-${e.role_name}`,r=U(this.template,e.role_name),d=h(r);return a?s("div",{class:"recipient","data-ri":r,"data-rn":e.role_name,style:{backgroundColor:d},onClick:t=>this.handleClickRole(t,e),id:n},(null===(t=this.rolesCompleted[e.id])||void 0===t?void 0:t.first_name)?m(this.rolesCompleted[e.id]):e.role_name,s("div",{class:"icon",innerHTML:B}),this.showPickerForId===e.id&&s("verdocs-portal",{anchor:n,onClickAway:()=>this.showPickerForId=""},s("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:t=>this.handleSelectContact(t,e),contactSuggestions:this.sessionContacts,templateRole:null!==(i=this.rolesCompleted[e.id])&&void 0!==i?i:e,onSearchContacts:e=>{var t;return null===(t=this.searchContacts)||void 0===t?void 0:t.emit(e.detail)}}))):s("div",{class:"recipient",style:{borderColor:d},onClick:t=>this.handleClickRole(t,e),id:n},(null===(o=this.rolesCompleted[e.id])||void 0===o?void 0:o.first_name)?m(this.rolesCompleted[e.id]):e.role_name,s("div",{class:"icon",innerHTML:B}),this.showPickerForId===e.id&&s("verdocs-portal",{anchor:n,onClickAway:()=>this.showPickerForId=""},s("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:t=>this.handleSelectContact(t,e),contactSuggestions:this.sessionContacts,templateRole:null!==(l=this.rolesCompleted[e.id])&&void 0!==l?l:e,onSearchContacts:e=>{var t;return null===(t=this.searchContacts)||void 0===t?void 0:t.emit(e.detail)}})))}))))),s("div",{class:"level level-done"},this.getLevelIcon(t.length),s("div",{class:"complete"},"Signing Complete"))),s("div",{class:"buttons"},s("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:e=>this.handleCancel(e),disabled:this.sending}),s("verdocs-button",{label:"Send",size:"small",disabled:!o||this.sending,onClick:e=>this.handleSend(e)}),this.sending&&s("verdocs-spinner",null)))}static get watchers(){return{templateId:["onTemplateIdChanged"]}}};Q.style='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-send{padding:10px;position:relative;background:#ffffff;-ms-flex-direction:column;flex-direction:column;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-send.sendable{display:-ms-flexbox;display:flex}verdocs-send .recipients{position:relative}verdocs-send .left-line{top:32px;left:20px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-send .level{display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;margin-left:50px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:8px 0 4px 0;border-bottom:1px solid rgba(151, 151, 151, 0.2666666667)}verdocs-send .level .level-icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-send .level .level-icon svg{fill:rgba(0, 0, 0, 0.537254902)}verdocs-send .level .recipient{height:30px;display:-ms-flexbox;display:flex;-ms-flex:0 0 30px;flex:0 0 30px;color:#000000;cursor:pointer;font-size:14px;-ms-flex-align:center;align-items:center;border-radius:30px;-ms-flex-direction:row;flex-direction:row;background:#dddddd;white-space:nowrap;border:2px solid #dddddd;padding:2px 10px 2px 14px}verdocs-send .level .recipient .icon{width:22px;height:22px;-ms-flex:0 0 22px;flex:0 0 22px;margin:0 0 0 10px}verdocs-send .level .recipient .icon svg{width:22px;height:22px;fill:#333333;outline:none}verdocs-send .level .complete{-ms-flex:1;flex:1;height:30px;display:-ms-flexbox;display:flex;color:#000000;font-size:14px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;padding:3px 10px 3px 2px}verdocs-send .buttons{display:-ms-flexbox;display:flex;margin-top:10px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-direction:row;flex-direction:row}verdocs-send verdocs-contact-picker{left:0;top:41px;z-index:10;position:absolute;border:1px solid #dddddd;-webkit-box-shadow:0 0 6px 3px rgba(0, 0, 0, 0.1);box-shadow:0 0 6px 3px rgba(0, 0, 0, 0.1)}';const P=class{constructor(s){e(this,s),this.exit=t(this,"exit",7),this.next=t(this,"next",7),this.templateUpdated=t(this,"templateUpdated",7),this.sdkError=t(this,"sdkError",7),this.templateListenerId=null,this.endpoint=a.getDefault(),this.templateId="",this.uploading=!1,this.progressLabel="Uploading...",this.progressPercent=0,this.showDeleteError=!1,this.confirmDeleteDocument=null,this.loading=!0,this.template=null}async componentWillLoad(){var e,t,s;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[ROLES] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[ROLES] Unable to start builder session, must be authenticated");this.listenToTemplate()}catch(i){console.log("[TEMPLATE ATTACHMENTS] Error loading template",i),null===(e=this.sdkError)||void 0===e||e.emit(new w(i.message,null===(t=i.response)||void 0===t?void 0:t.status,null===(s=i.response)||void 0===s?void 0:s.data))}}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate(),k.subscribe("templates",this.templateId,(()=>n(this.endpoint,this.templateId)),!1,(e=>{this.template=e,this.loading=!1}))}unlistenToTemplate(){this.templateListenerId&&(k.store.delListener(this.templateListenerId),this.templateListenerId=null)}handleCancel(e){e.stopPropagation(),this.exit.emit()}handleUploadProgress(e){e>=99?(this.progressPercent=100,this.progressLabel="Processing..."):this.progressPercent=e}async handleUpload(e){var t,s,i,o;e.stopPropagation();const l=e.detail.file;if(l){console.log("[ATTACHMENTS] Uploading...",l),this.uploading=!0,this.progressLabel="Uploading...";try{const e=await v(this.endpoint,this.templateId,l,this.handleUploadProgress.bind(this));console.log("[ATTACHMENTS] Created attachment",e),this.template=await k.getTemplate(this.endpoint,this.templateId,!0),console.log("[ATTACHMENTS] Updated template",this.template),null===(t=this.templateUpdated)||void 0===t||t.emit({endpoint:this.endpoint,template:this.template,event:"attachments"}),this.uploading=!1,this.progressLabel="",this.progressPercent=0}catch(e){console.log("[ATTACHMENTS] Error creating template",e),null===(s=this.sdkError)||void 0===s||s.emit(new w(e.message,null===(i=e.response)||void 0===i?void 0:i.status,null===(o=e.response)||void 0===o?void 0:o.data)),this.uploading=!1}}}handleNext(e){var t;e.stopPropagation(),this.uploading=!1,this.progressLabel="",this.progressPercent=0,null===(t=this.next)||void 0===t||t.emit({template:this.template})}async confirmDelete(){await g(this.endpoint,this.templateId,this.confirmDeleteDocument.id),this.template=await k.getTemplate(this.endpoint,this.templateId,!0),console.log("[ATTACHMENTS] New template",this.template),this.confirmDeleteDocument=null}async handleDelete(e){var t;((null===(t=this.template)||void 0===t?void 0:t.documents)||[]).length>1?this.confirmDeleteDocument=e:this.showDeleteError=!0}getFileIcon(e){switch(e.mime){case"application/pdf":return S;case"image/jpeg":return E;case"image/png":return C;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return q}return M}render(){var e,t;return this.endpoint.session?this.loading?s(i,{class:"loading"},s("verdocs-loader",null)):this.endpoint.session&&this.template?s(i,null,s("h5",null,"Existing Attachments"),s("div",{class:"attachments"},((null===(e=this.template)||void 0===e?void 0:e.documents)||[]).map((e=>s("div",{class:"attachment"},s("div",{class:"file-icon",innerHTML:this.getFileIcon(e)}),s("div",{class:"filename",title:e.name},e.name),s("div",{class:"pages"},s("div",{class:"count"},e.pages),s("div",{class:"pages-icon",innerHTML:T})),s("div",{class:"trash-icon",innerHTML:L,onClick:()=>this.handleDelete(e)}))))),s("h5",null,"Attach a New Document"),this.uploading?s("div",{class:"loader-wrapper"},s("verdocs-loader",null),this.progressLabel&&s("div",{class:"progress-wrapper"},s("verdocs-progress-bar",{showPercent:!0,percent:this.progressPercent,label:this.progressLabel}))):s("verdocs-file-chooser",{onFileSelected:e=>this.handleUpload(e)}),s("div",{class:"buttons"},s("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:e=>this.handleCancel(e),disabled:this.uploading}),s("verdocs-button",{label:"Next",size:"small",onClick:e=>this.handleNext(e),disabled:!((null===(t=this.template)||void 0===t?void 0:t.documents)||[]).length||this.uploading})),this.showDeleteError&&s("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:()=>this.showDeleteError=!1}),this.confirmDeleteDocument&&s("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:()=>this.confirmDelete(),showCancel:!0,onExit:()=>{this.confirmDeleteDocument=null}})):s(i,{class:"empty"}):s(i,null,s("verdocs-component-error",{message:"You must be authenticated to use this module."}))}};P.style='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-attachments{font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", 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}';const $=["attachments","roles","settings","fields","preview"],j=class{constructor(s){e(this,s),this.sdkError=t(this,"sdkError",7),this.stepChanged=t(this,"stepChanged",7),this.templateListenerId=null,this.endpoint=a.getDefault(),this.templateId=null,this.step="preview",this.loading=!0,this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate(),k.subscribe("templates",this.templateId,(()=>n(this.endpoint,this.templateId)),!1,(e=>{this.template=e,this.loading=!1}))}unlistenToTemplate(){this.templateListenerId&&(k.store.delListener(this.templateListenerId),this.templateListenerId=null)}onTemplateIdChanged(e){console.log("[BUILD_TABS] Template ID changed",e),this.listenToTemplate()}onStepChanged(e){console.log("[BUILD_TABS] Step changed",e)}async componentWillLoad(){var e,t,s;try{if(this.endpoint.loadSession(),!this.endpoint.session)return void console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");if(!this.templateId)return this.step="attachments",void console.log("[BUILD_TABS] Missing required template ID, forcing view to attachments");this.listenToTemplate()}catch(i){console.log("[BUILD_TABS] Error loading template",i),null===(e=this.sdkError)||void 0===e||e.emit(new w(i.message,null===(t=i.response)||void 0===t?void 0:t.status,null===(s=i.response)||void 0===s?void 0:s.data))}}setStep(e){var t;console.log("[BUILD_TABS] Selected step",e.detail.tab.id),e.stopPropagation(),e.preventDefault(),this.step=e.detail.tab.id,null===(t=this.stepChanged)||void 0===t||t.emit(e.detail.tab.id)}copyTemplateId(){navigator.clipboard.writeText(this.templateId).then((()=>{y("Template ID copied",{style:"success",duration:3e3})})).catch((e=>{var t;console.warn("[BUILD_TABS] Error copying to clipboard",e),null===(t=this.sdkError)||void 0===t||t.emit(e)}))}render(){var e,t,o,l,a,n,r,d,c;if(this.loading)return s(i,null,s("verdocs-loader",null));if(!this.endpoint.session)return s(i,null,s("verdocs-component-error",{message:"You must be authenticated to use this module."}));const p=((null===(e=this.template)||void 0===e?void 0:e.documents)||[]).length>0;let h=p&&((null===(t=this.template)||void 0===t?void 0:t.roles)||[]).length>0;const m=h&&((null===(o=this.template)||void 0===o?void 0:o.fields)||[]).length>0;let v=Math.max($.indexOf(this.step),0);return!m&&v>=4&&(v=3),!h&&v>=3&&(v=1),!p&&v>=1&&(v=0),s(i,null,s("verdocs-tabs",{onSelectTab:e=>this.setStep(e),selectedTab:v,tabs:[{id:"attachments",disabled:!1,label:"Attachment(s)"},{id:"roles",disabled:!p,label:"Roles"},{id:"settings",disabled:!h,label:"Settings"},{id:"fields",disabled:!h,label:"Fields"},{id:"preview",disabled:!m,label:"Preview/Send"}]}),this.templateId&&s("div",{class:"info"},s("verdocs-button-panel",{icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" fill="#5c6575"><path d="M11.925 18q.55 0 .938-.387.387-.388.387-.938 0-.55-.387-.925-.388-.375-.938-.375-.55 0-.925.375t-.375.925q0 .55.375.938.375.387.925.387Zm-.95-3.85h1.95q0-.8.2-1.287.2-.488 1.025-1.288.65-.625 1.025-1.213.375-.587.375-1.437 0-1.425-1.025-2.175Q13.5 6 12.1 6q-1.425 0-2.35.775t-1.275 1.85l1.775.7q.125-.45.55-.975.425-.525 1.275-.525.725 0 1.1.412.375.413.375.888 0 .475-.287.9-.288.425-.713.775-1.075.95-1.325 1.475-.25.525-.25 1.875ZM12 22.2q-2.125 0-3.988-.8-1.862-.8-3.237-2.175Q3.4 17.85 2.6 15.988 1.8 14.125 1.8 12t.8-3.988q.8-1.862 2.175-3.237Q6.15 3.4 8.012 2.6 9.875 1.8 12 1.8t3.988.8q1.862.8 3.237 2.175Q20.6 6.15 21.4 8.012q.8 1.863.8 3.988t-.8 3.988q-.8 1.862-2.175 3.237Q17.85 20.6 15.988 21.4q-1.863.8-3.988.8Zm0-2.275q3.325 0 5.625-2.3t2.3-5.625q0-3.325-2.3-5.625T12 4.075q-3.325 0-5.625 2.3T4.075 12q0 3.325 2.3 5.625t5.625 2.3ZM12 12Z"/></svg>'},s("div",{class:"template-details-panel"},s("h6",null,"Template Details"),s("div",{class:"row"},s("label",null,"ID:"),s("div",{class:"value"},this.templateId),s("div",{class:"icon-button",innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75" /></svg>',onClick:()=>this.copyTemplateId()})),s("div",{class:"row"},s("label",null,"Name:"),s("div",{class:"value"},null===(l=this.template)||void 0===l?void 0:l.name)),s("div",{class:"row"},s("label",null,"Visibility:"),s("div",{class:"value"},(null===(a=this.template)||void 0===a?void 0:a.is_public)?"Public":(null===(n=this.template)||void 0===n?void 0:n.is_personal)?"Private":"Shared")),s("div",{class:"row"},s("label",null,"Created:"),s("div",{class:"value"},(null===(r=this.template)||void 0===r?void 0:r.counter)?H(new Date(null===(d=this.template)||void 0===d?void 0:d.created_at),"P p"):"")),s("div",{class:"row"},s("label",null,"Used:"),s("div",{class:"value"},null===(c=this.template)||void 0===c?void 0:c.counter," time(s)"))))))}static get watchers(){return{templateId:["onTemplateIdChanged"],step:["onStepChanged"]}}};j.style='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-build-tabs{-ms-flex:1;flex:1;gap:15px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-build-tabs verdocs-button-panel svg{-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-build-tabs verdocs-template-attachments,verdocs-template-build-tabs verdocs-template-roles{margin:20px}verdocs-template-build-tabs verdocs-template-fields{border-top:1px solid #777777}verdocs-template-build-tabs verdocs-template-attachments{padding:20px;background:#ffffff}verdocs-template-build-tabs verdocs-template-fields{width:100%}verdocs-template-build-tabs verdocs-preview{-ms-flex:1;flex:1}.template-details-panel .row{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:8px;margin:10px 0}.template-details-panel label{-ms-flex:0 0 70px;flex:0 0 70px}.template-details-panel .value{-ms-flex:1;flex:1;font-weight:300;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.template-details-panel .icon-button{cursor:pointer;opacity:0.8;-ms-flex:0;flex:0;width:18px;height:18px}.template-details-panel .icon-button svg{stroke:#000000;width:18px;height:18px}.template-details-panel .icon-button:hover{opacity:1}';const F='<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>',O=[{id:"signature",tooltip:"Signature",icon:'<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>',class:"signature"},{id:"initial",tooltip:"Initials",icon:'<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>',class:"initial"},{id:"sep1",tooltip:"",icon:F,class:"separator"},{id:"textbox",tooltip:"Text Box",icon:'<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>',class:"textbox"},{id:"checkbox",tooltip:"Check Box",icon:'<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>',class:"checkbox"},{id:"radio",tooltip:"Radio Button",icon:'<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>',class:"radio"},{id:"dropdown",tooltip:"Dropdown",icon:'<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>',class:"dropdown"},{id:"sep2",tooltip:"",icon:F,class:"separator"},{id:"date",tooltip:"Date",icon:'<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>',class:"date"},{id:"timestamp",tooltip:"Timestamp",icon:'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" 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"></path></svg>',class:"timestamp"},{id:"attachment",tooltip:"Attachment",icon:'<svg xmlns="http://www.w3.org/2000/svg" fill="none" 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>',class:"attachment"}],W=class{constructor(s){e(this,s),this.sdkError=t(this,"sdkError",7),this.templateUpdated=t(this,"templateUpdated",7),this.fieldsUpdated=t(this,"fieldsUpdated",7),this.templateListenerId=null,this.pageHeights={},this.cachedPageInfo={},this.endpoint=a.getDefault(),this.templateId=null,this.toolbarTargetId=null,this.placing=null,this.showMustSelectRole=!1,this.selectedRoleName="",this.loading=!0,this.template=null}onTemplateIdChanged(){this.listenToTemplate()}handleKeyDown(e){"Escape"===e.key&&(this.placing=null)}async componentWillLoad(){var e,t,s;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[FIELDS] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[FIELDS] Unable to start builder session, must be authenticated");this.listenToTemplate()}catch(i){console.log("[FIELDS] Error with fields session",i),null===(e=this.sdkError)||void 0===e||e.emit(new w(i.message,null===(t=i.response)||void 0===t?void 0:t.status,null===(s=i.response)||void 0===s?void 0:s.data))}}componentDidRender(){z.dynamicDrop(!0);const e=this.toolbarTargetId?document.getElementById(this.toolbarTargetId):null,t=document.getElementById("verdocs-template-fields-toolbar");e&&t&&(console.log("[FIELDS] Moving toolbar"),t.remove(),e.append(t))}componentWillUpdate(){var e,t;const s=(null===(e=this.template)||void 0===e?void 0:e.roles)||[];this.selectedRoleName&&s.find((e=>e&&e.name===this.selectedRoleName))||(this.selectedRoleName=(null===(t=s[0])||void 0===t?void 0:t.name)||"",console.log("[FIELDS] Selected new role",this.selectedRoleName))}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate(),k.subscribe("templates",this.templateId,(()=>n(this.endpoint,this.templateId)),!1,(e=>{var t,s;this.template=e,this.loading=!1,this.selectedRoleName=(null===(s=null===(t=e.roles)||void 0===t?void 0:t[0])||void 0===s?void 0:s.name)||""}))}unlistenToTemplate(){this.templateListenerId&&(k.store.delListener(this.templateListenerId),this.templateListenerId=null)}attachFieldAttributes(e,t,s){s.addEventListener("settingsChanged",(()=>{var e;null===(e=this.templateUpdated)||void 0===e||e.emit({endpoint:this.endpoint,template:this.template,event:"added-field"})})),s.addEventListener("deleted",(()=>{var e;s.remove(),null===(e=this.templateUpdated)||void 0===e||e.emit({endpoint:this.endpoint,template:this.template,event:"updated-field"})})),s.setAttribute("templateid",this.templateId),s.setAttribute("fieldname",t.name),s.setAttribute("pageNumber",String(e.pageNumber)),s.setAttribute("xScale",String(e.xScale)),s.setAttribute("yScale",String(e.yScale)),s.setAttribute("name",t.name)}handlePageRendered(e){var t;const s=e.detail;this.cachedPageInfo[s.pageNumber]=s,this.pageHeights[s.pageNumber]=s.naturalHeight,((null===(t=this.template)||void 0===t?void 0:t.fields)||[]).filter((e=>e&&e.page===s.pageNumber)).forEach((e=>{const t=D(e),s=document.getElementById(t);s&&(s.setAttribute("fieldname",e.name),s.setAttribute("pagenumber",String(e.page)),this.makeDraggable(s))}))}makeDraggable(e){z(e).draggable({listeners:{move:this.handleMoveField.bind(this),end:this.handleMoveEnd.bind(this)}})}async handleMoveField(e){const t=+(e.target.getAttribute("posX")||0),s=+(e.target.getAttribute("posY")||0),i=+(e.target.getAttribute("xScale")||1),o=+(e.target.getAttribute("yScale")||1),l=e.dx/i+t,a=e.dy/o+s;e.target.setAttribute("posX",l),e.target.setAttribute("posy",a),Z(e.target,"translate",`${l}px, ${a}px`)}async handleMoveEnd(e){var t,s,i,o,l,a,n,r;const d=e.target.getAttribute("fieldname"),c=((null===(t=this.template)||void 0===t?void 0:t.fields)||[]).find((e=>e.name===d));if(!c)return void console.log("[FIELDS] Unable to find field",d,e.target);const p=e.target.getAttribute("pagenumber");let{naturalWidth:h=612,naturalHeight:m=792,renderedHeight:v=792}=this.cachedPageInfo[p];const g=e.target.getBoundingClientRect(),f=e.target.parentElement.getBoundingClientRect(),x=c.width||N(c.type),b=c.height||_(c.type),q=Math.max(g.left-f.left,0);let C=Math.max(v-(f.bottom-g.bottom),0),E=parseInt(p);C>v?(E=Math.min(E+1,(null===(o=null===(i=(null===(s=this.template)||void 0===s?void 0:s.documents)||[])||void 0===i?void 0:i[0])||void 0===o?void 0:o.pages)||1),C-=v,v=this.cachedPageInfo[E].renderedHeight,console.log("Next page",{newPageNumber:E,newY:C,renderedHeight:v})):C<0&&(E=Math.max(E-1,1),v=this.cachedPageInfo[E].renderedHeight,C+=v,console.log("[FIELDS] Next page",{newPageNumber:E,newY:C,renderedHeight:v}));const{x:S,y:M}=this.viewCoordinatesToPageCoordinates(q,C,p,h-x,m-b);try{const t={x:S,y:M,page:E},s=await u(this.endpoint,this.templateId,d,t);console.log("[FIELDS] Updated",s);const i=JSON.parse(JSON.stringify(this.template)),o=i.fields.findIndex((e=>e.name===d));o>-1&&(i.fields[o]=s),k.updateTemplate(this.templateId,i),e.target.removeAttribute("posX"),e.target.removeAttribute("posY"),I(e.target);const{xScale:a=1,yScale:n=1}=this.cachedPageInfo[p];V(e.target,s,a,n),null===(l=this.templateUpdated)||void 0===l||l.emit({endpoint:this.endpoint,template:i,event:"updated-field"})}catch(t){y("Error updating field, please try again later",{style:"error"}),console.log("[FIELDS] Error updating field",t),null===(a=this.sdkError)||void 0===a||a.emit(new w(t.message,null===(n=t.response)||void 0===n?void 0:n.status,null===(r=t.response)||void 0===r?void 0:r.data)),e.target.removeAttribute("posX"),e.target.removeAttribute("posY"),I(e.target)}}generateFieldName(e,t){var s;let i,o=1;do{i=`${e}P${t}-${o}`,o++}while(((null===(s=this.template)||void 0===s?void 0:s.fields)||[]).some((e=>e&&e.name===i)));return i}viewCoordinatesToPageCoordinates(e,t,s,i,o){const{xScale:l=1,yScale:a=1,renderedHeight:n=792}=this.cachedPageInfo[s];return{x:Math.floor(Math.min(e/l,i)),y:Math.floor(Math.min(Math.max(n-t,0)/a,o))}}async handleClickPage(e,t){var s;if(this.placing){const i=e.offsetX,o=e.offsetY,l=N(this.placing),a=_(this.placing),n=this.cachedPageInfo[t],{naturalWidth:r=612,naturalHeight:d=792}=n,c=this.viewCoordinatesToPageCoordinates(i,o,t,r-l,d-a),p=Math.floor(c.x),h=Math.floor(c.y),m={name:this.generateFieldName(this.placing,t),role_name:this.selectedRoleName,template_id:this.templateId,document_id:n.documentId,type:this.placing,required:"radio"!==this.placing,page:t,validator:null,label:null,default:null,placeholder:null,group:null,settings:{},x:p,y:h,width:l,height:a,multiline:!1,options:"radio"===this.placing?[{id:"option-1",label:"Option 1"}]:[]};console.log("[FIELDS] Will save new field",m);const v=await f(this.endpoint,this.templateId,m);console.log("[FIELDS] Saved field",v);const g=JSON.parse(JSON.stringify(this.template));g.fields.push(v),k.updateTemplate(this.templateId,g),null===(s=this.templateUpdated)||void 0===s||s.emit({endpoint:this.endpoint,template:g,event:"added-field"}),this.placing=null}}render(){var e,t,o;if(this.loading)return s(i,null,s("verdocs-loader",null));if(!this.endpoint.session)return s(i,null,s("verdocs-component-error",{message:"You must be authenticated to use this module."}));const l=((null===(e=this.template)||void 0===e?void 0:e.roles)||[]).map((e=>({value:e.name,label:e.full_name?`${e.name}: ${e.full_name}`:e.name})));return s(i,{class:this.placing?{[`placing-${this.placing}`]:!0}:{},onSubmit:()=>{}},s("div",{id:"verdocs-template-fields-toolbar"},s("div",{class:"add-for"},"Add field:"),s("verdocs-select-input",{value:this.selectedRoleName,options:l,onInput:e=>this.selectedRoleName=e.target.value}),O.map((e=>s("verdocs-toolbar-icon",{text:e.tooltip,icon:e.icon,class:e.class,onClick:()=>{e.tooltip&&(this.selectedRoleName?this.placing=e.id:this.showMustSelectRole=!0)}})))),s("div",{class:"pages"},((null===(t=this.template)||void 0===t?void 0:t.documents)||[]).map((e=>r(1,e.pages).map((t=>{const i=e.page_sizes[t];return s("verdocs-template-document-page",{templateId:this.templateId,documentId:e.id,pageNumber:t,virtualWidth:(null==i?void 0:i.width)||612,virtualHeight:(null==i?void 0:i.height)||792,disabled:!0,editable:!0,done:!1,onClick:e=>this.handleClickPage(e,t),onPageRendered:e=>this.handlePageRendered(e),layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})}))))),this.showMustSelectRole&&s("verdocs-ok-dialog",{heading:"Unable to add field",message:((null===(o=this.template)||void 0===o?void 0:o.roles)||[]).length>0?"Please select a role before adding fields.":"Please add at least one role before adding fields.",onNext:()=>this.showMustSelectRole=!1}))}static get watchers(){return{templateId:["onTemplateIdChanged"]}}};W.style="@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-fields{font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif;position:relative;display:block;min-height:600px}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 #verdocs-template-fields-toolbar{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}";const Y='<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20" fill="#00000089"><path d="m8.021 17.917-.313-2.5q-.27-.125-.625-.334-.354-.208-.625-.395l-2.312.979-1.979-3.438 1.979-1.5q-.021-.167-.031-.364-.011-.198-.011-.365 0-.146.011-.344.01-.198.031-.385l-1.979-1.5 1.979-3.417 2.312.958q.271-.187.615-.385t.635-.344l.313-2.5h3.958l.313 2.5q.312.167.625.344.312.177.604.385l2.333-.958 1.979 3.417-1.979 1.521q.021.187.021.364V10q0 .146-.01.333-.011.188-.011.396l1.958 1.5-1.979 3.438-2.312-.979q-.292.208-.615.395-.323.188-.614.334l-.313 2.5Zm1.937-5.355q1.063 0 1.813-.75t.75-1.812q0-1.062-.75-1.812t-1.813-.75q-1.041 0-1.802.75-.76.75-.76 1.812t.76 1.812q.761.75 1.802.75Zm0-1.333q-.5 0-.864-.364-.365-.365-.365-.865t.365-.865q.364-.364.864-.364t.865.364q.365.365.365.865t-.365.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.187q.605-.167 1.136-.49.531-.323 1.031-.802l2.021.875.854-1.375-1.792-1.354q.105-.333.136-.635.031-.303.031-.615 0-.292-.031-.573-.031-.281-.115-.635l1.792-1.396-.834-1.375-2.062.875q-.438-.438-1.021-.781-.583-.344-1.125-.49l-.271-2.208H9.167l-.271 2.208q-.584.146-1.125.458-.542.313-1.042.792l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.479.458 1.021.771.542.312 1.146.479Z"/></svg>',J='<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>',X='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>',K='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zm13.36-1.814a.75.75 0 10-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 00-1.06 1.06l2.25 2.25a.75.75 0 001.14-.094l3.75-5.25z" clip-rule="evenodd" /></svg>',G='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M1.5 8.67v8.58a3 3 0 003 3h15a3 3 0 003-3V8.67l-8.928 5.493a3 3 0 01-3.144 0L1.5 8.67z" /><path d="M22.5 6.908V6.75a3 3 0 00-3-3h-15a3 3 0 00-3 3v.158l9.714 5.978a1.5 1.5 0 001.572 0L22.5 6.908z" /></svg>',ee=class{constructor(s){e(this,s),this.next=t(this,"next",7),this.exit=t(this,"exit",7),this.sdkError=t(this,"sdkError",7),this.rolesUpdated=t(this,"rolesUpdated",7),this.templateListenerId=null,this.endpoint=a.getDefault(),this.templateId="",this.showingRoleDialog=null,this.sender=null,this.loading=!0,this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){console.log("[ROLES] Loading template",this.templateId),this.unlistenToTemplate(),k.subscribe("templates",this.templateId,(()=>n(this.endpoint,this.templateId)),!1,(e=>{console.log("[BUILD] Template Updated",e),this.template=e,this.loading=!1}))}unlistenToTemplate(){this.templateListenerId&&(k.store.delListener(this.templateListenerId),this.templateListenerId=null)}async componentWillLoad(){var e,t,s;try{if(this.endpoint.loadSession(),!this.templateId)return void console.log(`[ROLES] Missing required template ID ${this.templateId}`);if(!this.endpoint.session)return void console.log("[ROLES] Unable to start builder session, must be authenticated");this.listenToTemplate()}catch(i){console.log("[FIELDS] Error with preview session",i),null===(e=this.sdkError)||void 0===e||e.emit(new w(i.message,null===(t=i.response)||void 0===t?void 0:t.status,null===(s=i.response)||void 0===s?void 0:s.data))}}componentDidRender(){z.dynamicDrop(!0),z(".recipient").draggable({listeners:{start:function(e){e.target.classList.add("dragging"),this.el.classList.add("dragging")}.bind(this),move:function(e){const t=+(e.target.getAttribute("dX")||0),s=+(e.target.getAttribute("dY")||0),i=+(e.target.dataset.sequence||0),o=+(e.target.dataset.order||0),l=e.dx+t,a=e.dy+s;e.target.setAttribute("dX",l),e.target.setAttribute("dY",a);const n=e.target.getBoundingClientRect();console.log("w",n.width),e.target.style.transform=`translate(${l+n.width-(o+1)}px, ${a-n.height*i}px)`}.bind(this),end:function(e){e.target.classList.remove("dragging"),this.el.classList.remove("dragging"),e.target.removeAttribute("dX"),e.target.removeAttribute("dY"),e.target.style.transform=null}.bind(this)}}),z(".dropzone").dropzone({overlap:.05,ondrop:async function(e){var t;e.target.classList.remove("active"),await this.renumberTemplateRoles(),console.log("[ROLES] Updated roles",this.getSortedRoles()),null===(t=this.rolesUpdated)||void 0===t||t.emit({event:"updated",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()})}.bind(this),ondropactivate:e=>{e.target.classList.add("visible")},ondropdeactivate:e=>{e.target.classList.remove("visible")},ondragenter:e=>{e.target.classList.add("active")},ondragleave:e=>{e.target.classList.remove("active")}})}handleCancel(){var e;null===(e=this.exit)||void 0===e||e.emit()}handleSubmit(){var e;null===(e=this.next)||void 0===e||e.emit()}getSortedRoles(){var e;return((null===(e=this.template)||void 0===e?void 0:e.roles)||[]).sort(((e,t)=>e.sequence===t.sequence?e.order-t.order:e.sequence-t.sequence))}getSequenceNumbers(){const e=[];return this.getSortedRoles().forEach((t=>{e.includes(t.sequence)||e.push(t.sequence)})),e.sort(((e,t)=>e-t))}getRoleNames(){return this.getSortedRoles().map((e=>e.name))}getRolesAtSequence(e){var t;return((null===(t=this.template)||void 0===t?void 0:t.roles)||[]).filter((t=>t&&t.sequence===e))}async renumberTemplateRoles(){const e=[],t=[];return this.getSequenceNumbers().forEach(((s,i)=>{this.getRolesAtSequence(s).forEach(((s,o)=>{e.includes(s.name)||s.sequence===i+1&&s.order===o+1||(s.sequence=i+1,s.order=o+1,e.push(s.name),t.push(x(this.endpoint,this.templateId,s.name,{sequence:s.sequence,order:s.order})))}))})),!(t.length>0)||(console.log(`[ROLES] Submitting ${t.length} renumber requests`),Promise.all(t).then((async()=>{this.template=await k.getTemplate(this.endpoint,this.templateId,!0)})))}getNextRoleName(){var e,t;let s="",i=((null===(e=this.template)||void 0===e?void 0:e.roles)||[]).length;do{i++,s=`Recipient ${i}`}while(!s||((null===(t=this.template)||void 0===t?void 0:t.roles)||[]).some((e=>e&&e.name===s)));return s}callCreateRole(e,t,s){console.log("[ROLES] Will create role",{name:e,sequence:t,order:s}),b(this.endpoint,this.templateId,{template_id:this.templateId,name:e,sequence:t,message:"",order:s,full_name:null,first_name:"",last_name:"",email:"",phone:"",type:"signer",delegator:!1,kba_method:null}).then((async e=>{var t;console.log("[ROLES] Created role",e);const s=JSON.parse(JSON.stringify(this.template));s.roles.push(e),console.log("Updating template in data store"),k.updateTemplate(this.templateId,s),await this.renumberTemplateRoles(),null===(t=this.rolesUpdated)||void 0===t||t.emit({event:"added",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()})})).catch((e=>{console.log("[ROLES] Error creating role",e)}))}handleAddRole(e,t){e.stopPropagation();const s=this.getRolesAtSequence(t).length+1,i=this.getNextRoleName();this.callCreateRole(i,t,s)}handleAddStep(e,t){e.stopPropagation();const s=this.getNextRoleName();this.callCreateRole(s,t,1)}render(){if(!this.endpoint.session)return s(i,null,s("verdocs-component-error",{message:"You must be authenticated to use this module."}));if(this.loading||!this.template)return s(i,{class:"loading"},s("verdocs-loader",null));const e=this.getRoleNames(),t=this.getSequenceNumbers();return s(i,null,s("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},s("h5",null,"Roles and Workflow"),s("div",{class:"participants"},s("div",{class:"left-line"}),s("div",{class:"row"},s("div",{class:"icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z"></path></svg>'}),s("div",{class:"row-roles"},s("div",{class:"sender"},s("span",{class:"label"},"Send Envelope")))),s("div",{class:"row add-sequence","data-sequence":0},s("div",{class:"icon",innerHTML:J}),s("div",{class:"row-roles"},s("div",{class:"dropzone","data-sequence":0,"data-order":1},"Add Step"))),t.map((e=>s(o,null,s("div",{class:"row"},s("div",{class:"icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></svg>'}),s("div",{class:"row-roles"},s("div",{class:"dropzone","data-order":.5,"data-sequence":e}),this.getRolesAtSequence(e).map((t=>s(o,null,t.email?s("div",{class:"recipient",style:{borderColor:h(U(this.template,t.name))},"data-rolename":t.name,"data-sequence":e,"data-order":t.order},s("span",{class:"type-icon",innerHTML:"signer"===t.type?X:"cc"===t.type?G:K}),m(t)," ",s("div",{class:"settings-button",innerHTML:Y,onClick:()=>this.showingRoleDialog=t.name,"aria-role":"button"})):s("div",{class:"recipient",style:{backgroundColor:h(U(this.template,t.name))},"data-rolename":t.name,"data-sequence":e,"data-order":t.order},s("span",{class:"type-icon",innerHTML:"signer"===t.type?X:"cc"===t.type?G:K}),t.name," ",s("div",{class:"settings-button",innerHTML:Y,onClick:()=>this.showingRoleDialog=t.name,"aria-role":"button"})),s("div",{class:"dropzone","data-order":t.order+.5,"data-sequence":e})))),s("button",{class:"add-role",innerHTML:J,onClick:t=>this.handleAddRole(t,e)}))),t.length>0&&s("div",{class:"row add-sequence","data-sequence":e},s("div",{class:"row-roles"},s("div",{class:"icon",innerHTML:J}),s("div",{class:"dropzone","data-sequence":e+1,"data-order":1},"Add Step")))))),s("div",{class:"row","data-sequence":t.length+1},s("div",{class:"row-roles"},s("div",{class:"icon",innerHTML:J}),s("button",{class:"add-step",innerHTML:J,onClick:e=>this.handleAddStep(e,t.length+1)}))),s("div",{class:"row"},s("div",{class:"icon",innerHTML:'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><path d="m18 7-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41 6 19l1.41-1.41L1.83 12 .41 13.41z"></path></svg>'}),s("div",{class:"row-roles"},s("div",{class:"complete"},"Document Complete")))),e.length<1&&s("div",{class:"empty"},"You must add at least one Role before proceeding.",s("br",null)," Click the ",s("span",{innerHTML:J})," Add button above to get started."),s("div",{class:"buttons"},s("div",{class:"flex-fill"}),s("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:()=>this.handleCancel()}),s("verdocs-button",{label:"OK",size:"small",onClick:()=>this.handleSubmit(),disabled:e.length<1}))),this.showingRoleDialog&&s("verdocs-template-role-properties",{endpoint:this.endpoint,templateId:this.templateId,roleName:this.showingRoleDialog,onClose:()=>{this.showingRoleDialog=null},onDelete:async()=>{var e;this.showingRoleDialog=null,await this.renumberTemplateRoles(),null===(e=this.rolesUpdated)||void 0===e||e.emit({event:"deleted",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()})}}))}get el(){return l(this)}};ee.style='@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-roles{display:block;min-width:400px;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-roles>form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;padding:12px}verdocs-template-roles>form h5{font-size:16px;font-weight:bold;color:#46497d;margin:0 0 10px 0}verdocs-template-roles>form .participants{position:relative}verdocs-template-roles>form .left-line{top:32px;left:11px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-template-roles>form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:0;-moz-column-gap:0;column-gap:0;min-height:35px;margin-top:0;margin-left:40px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:6px 0 4px 0}verdocs-template-roles>form .row .row-roles{-ms-flex:1;flex:1;gap:10px;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-direction:row;flex-direction:row}verdocs-template-roles>form .row .icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-template-roles>form .row .sender{height:30px;display:-ms-flexbox;display:flex;font-size:14px;line-height:30px;-ms-flex-align:center;align-items:center;border-radius:30px;-ms-flex-direction:row;flex-direction:row;padding:0 15px 0 15px;border:1px solid #c6c9cc;background-color:#f5f5fa}verdocs-template-roles>form .row .complete{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;background-color:#f5f5fa;border:1px solid #aeb4bf}verdocs-template-roles>form .row .label{font-weight:bold;margin-right:6px;color:#33364b}verdocs-template-roles>form .row .settings-button{display:-ms-flexbox;display:flex;cursor:pointer;margin:0 0 0 9px}verdocs-template-roles>form .row .recipient{height:30px;display:-ms-flexbox;display:flex;font-size:14px;border-radius:30px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;padding:0 5px 0 6px;white-space:nowrap;border:2px solid #aeb4bf}verdocs-template-roles>form .row .recipient .type-icon{width:24px;height:24px;-webkit-transform:scale(0.8);transform:scale(0.8);opacity:0.6;margin:0 12px 0 0}verdocs-template-roles>form .row .recipient.dragging{position:absolute}verdocs-template-roles>form .row .recipient.dragging+.dropzone{display:none !important}verdocs-template-roles>form .row .dropzone{width:14px;height:30px;display:none}verdocs-template-roles>form .row .dropzone svg{fill:#cccccc}verdocs-template-roles>form .row .dropzone.visible{margin:0 7px;display:-ms-flexbox;display:flex;-ms-flex:0 0 14px;flex:0 0 14px}verdocs-template-roles>form .row .dropzone.active{-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;background:rgba(101, 77, 203, 0.4980392157);border:1px dashed #654dcb}verdocs-template-roles>form label{display:block;font-size:14px;font-weight:500;margin:0 0 4px 0;color:#5c6575}verdocs-template-roles>form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-roles>form input:focus{outline:none}verdocs-template-roles .row.add-sequence{display:none}verdocs-template-roles .add-role{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-roles .add-role:hover{opacity:1}verdocs-template-roles .add-role svg{width:32px;height:32px}verdocs-template-roles .add-step{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-roles .add-step:hover{opacity:1}verdocs-template-roles .add-step svg{width:32px;height:32px}verdocs-template-roles.dragging .add-role{display:none}verdocs-template-roles.dragging form .row .recipient+.dropzone{display:-ms-flexbox;display:flex}verdocs-template-roles.dragging .row.add-sequence{display:-ms-flexbox;display:flex}verdocs-template-roles.dragging .row.add-sequence .dropzone{opacity:0.5;-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;-ms-flex-align:center;align-items:center;background:rgba(101, 77, 203, 0.4980392157);-ms-flex-pack:center;justify-content:center;border:1px dashed #654dcb}verdocs-template-roles.dragging .row.add-sequence .dropzone.active{opacity:1}verdocs-template-roles .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-direction:row;flex-direction:row}verdocs-template-roles .empty{font-size:13px;margin-top:15px;margin-bottom:5px}verdocs-template-roles .empty svg{width:16px;height:16px;stroke:#666666;margin-bottom:2px;display:inline-block}verdocs-template-roles ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-roles ::-moz-placeholder{color:#aaaaaa}verdocs-template-roles :-ms-input-placeholder{color:#aaaaaa}verdocs-template-roles ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-roles ::placeholder{color:#aaaaaa}';export{R as verdocs_preview,Q as verdocs_send,P as verdocs_template_attachments,j as verdocs_template_build_tabs,W as verdocs_template_fields,ee as verdocs_template_roles}
|