@verdocs/web-sdk 5.0.29 → 5.0.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/verdocs-envelope-sidebar.cjs.entry.js +16 -0
  3. package/dist/cjs/verdocs-envelope-sidebar.cjs.entry.js.map +1 -1
  4. package/dist/cjs/verdocs-preview_6.cjs.entry.js +13 -3
  5. package/dist/cjs/verdocs-preview_6.cjs.entry.js.map +1 -1
  6. package/dist/cjs/verdocs-sign.cjs.entry.js +9 -2
  7. package/dist/cjs/verdocs-sign.cjs.entry.js.map +1 -1
  8. package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
  9. package/dist/collection/components/embeds/verdocs-send/verdocs-send.js +13 -3
  10. package/dist/collection/components/embeds/verdocs-send/verdocs-send.js.map +1 -1
  11. package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js +9 -2
  12. package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js.map +1 -1
  13. package/dist/collection/components/envelopes/verdocs-envelope-sidebar/verdocs-envelope-sidebar.js +17 -0
  14. package/dist/collection/components/envelopes/verdocs-envelope-sidebar/verdocs-envelope-sidebar.js.map +1 -1
  15. package/dist/components/{p-27a8eef0.js → p-c4368d04.js} +14 -4
  16. package/dist/components/p-c4368d04.js.map +1 -0
  17. package/dist/components/verdocs-build.js +1 -1
  18. package/dist/components/verdocs-envelope-sidebar.js +17 -0
  19. package/dist/components/verdocs-envelope-sidebar.js.map +1 -1
  20. package/dist/components/verdocs-send.js +1 -1
  21. package/dist/components/verdocs-sign.js +9 -2
  22. package/dist/components/verdocs-sign.js.map +1 -1
  23. package/dist/esm/loader.js +1 -1
  24. package/dist/esm/verdocs-envelope-sidebar.entry.js +16 -0
  25. package/dist/esm/verdocs-envelope-sidebar.entry.js.map +1 -1
  26. package/dist/esm/verdocs-preview_6.entry.js +13 -3
  27. package/dist/esm/verdocs-preview_6.entry.js.map +1 -1
  28. package/dist/esm/verdocs-sign.entry.js +9 -2
  29. package/dist/esm/verdocs-sign.entry.js.map +1 -1
  30. package/dist/esm/verdocs-web-sdk.js +1 -1
  31. package/dist/esm-es5/loader.js +1 -1
  32. package/dist/esm-es5/loader.js.map +1 -1
  33. package/dist/esm-es5/verdocs-envelope-sidebar.entry.js +1 -1
  34. package/dist/esm-es5/verdocs-envelope-sidebar.entry.js.map +1 -1
  35. package/dist/esm-es5/verdocs-preview_6.entry.js +1 -1
  36. package/dist/esm-es5/verdocs-preview_6.entry.js.map +1 -1
  37. package/dist/esm-es5/verdocs-sign.entry.js +1 -1
  38. package/dist/esm-es5/verdocs-sign.entry.js.map +1 -1
  39. package/dist/esm-es5/verdocs-web-sdk.js +1 -1
  40. package/dist/esm-es5/verdocs-web-sdk.js.map +1 -1
  41. package/dist/types/components/envelopes/verdocs-envelope-sidebar/verdocs-envelope-sidebar.d.ts +1 -0
  42. package/dist/verdocs-web-sdk/{p-4ae786e9.system.entry.js → p-022110a8.system.entry.js} +3 -3
  43. package/dist/verdocs-web-sdk/p-022110a8.system.entry.js.map +1 -0
  44. package/dist/verdocs-web-sdk/{p-a285560f.entry.js → p-2d0bd50f.entry.js} +2 -2
  45. package/dist/verdocs-web-sdk/{p-a285560f.entry.js.map → p-2d0bd50f.entry.js.map} +1 -1
  46. package/dist/verdocs-web-sdk/{p-1f2c019d.system.entry.js → p-3d7d95b0.system.entry.js} +2 -2
  47. package/dist/verdocs-web-sdk/p-3d7d95b0.system.entry.js.map +1 -0
  48. package/dist/verdocs-web-sdk/{p-b7799ec0.entry.js → p-6ff5cab7.entry.js} +2 -2
  49. package/dist/verdocs-web-sdk/p-6ff5cab7.entry.js.map +1 -0
  50. package/dist/verdocs-web-sdk/{p-70247599.system.entry.js → p-9d538cb1.system.entry.js} +2 -2
  51. package/dist/verdocs-web-sdk/{p-70247599.system.entry.js.map → p-9d538cb1.system.entry.js.map} +1 -1
  52. package/dist/verdocs-web-sdk/p-e2b70dfb.system.js +1 -1
  53. package/dist/verdocs-web-sdk/p-e2b70dfb.system.js.map +1 -1
  54. package/dist/verdocs-web-sdk/{p-6369fc93.entry.js → p-e5470d18.entry.js} +2 -2
  55. package/dist/verdocs-web-sdk/p-e5470d18.entry.js.map +1 -0
  56. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  57. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js.map +1 -1
  58. package/package.json +1 -1
  59. package/dist/components/p-27a8eef0.js.map +0 -1
  60. package/dist/verdocs-web-sdk/p-1f2c019d.system.entry.js.map +0 -1
  61. package/dist/verdocs-web-sdk/p-4ae786e9.system.entry.js.map +0 -1
  62. package/dist/verdocs-web-sdk/p-6369fc93.entry.js.map +0 -1
  63. package/dist/verdocs-web-sdk/p-b7799ec0.entry.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import{r as e,c as t,h as i,H as o,F as s,g as n}from"./p-b9654a5e.js";import{VerdocsEndpoint as l,getTemplate as r,integerSequence as a,getOrganizationContacts as d,isValidEmail as c,createEnvelope as h,formatFullName as u,getRGBA as f,createTemplateDocument as p,deleteTemplateDocument as v,updateField as m,createField as g,updateTemplateRole as b,createTemplateRole as x}from"@verdocs/js-sdk";import{S as w}from"./p-fd97809c.js";import{S as y}from"./p-d4be87ef.js";import{V as k}from"./p-04c07b7b.js";import{D as E,P as S,J as q,a as C,F as M,b as T,T as I}from"./p-b0766439.js";import{f as L}from"./p-12bab948.js";import{i as H}from"./p-a901dff2.js";import{b as D,c as Z,d as z,g as O,e as _,f as N}from"./p-0c45b79c.js";import"./p-85aa8e05.js";import"./p-c7ee88c7.js";const V='@-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 R=V;const A=class{constructor(i){e(this,i);this.sdkError=t(this,"sdkError",7);this.templateListenerId=null;this.endpoint=l.getDefault();this.templateId=null;this.loading=true;this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{this.template=e;this.loading=false}))}unlistenToTemplate(){if(this.templateListenerId){y.store.delListener(this.templateListenerId);this.templateListenerId=null}}onTemplateIdChanged(e){console.log("[PREVIEW] Template ID changed",e);this.listenToTemplate()}async componentWillLoad(){var e,t,i;try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[PREVIEW] Unable to start builder session, must be authenticated");return}if(!this.templateId){console.log(`[PREVIEW] Missing required template ID ${this.templateId}`);return}this.listenToTemplate()}catch(o){console.log("[PREVIEW] Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}}handlePageRendered(e){}render(){var e;if(this.loading){return i(o,null,i("verdocs-loader",null))}return i(o,null,(((e=this.template)===null||e===void 0?void 0:e.documents)||[]).map((e=>{const t=a(1,e.pages);return i(s,null,t.map((t=>{var o;const s=((o=e.page_sizes)===null||o===void 0?void 0:o[t])||{width:612,height:792};return i("verdocs-template-document-page",{templateId:e.template_id,documentId:e.id,pageNumber:t,disabled:true,editable:false,done:false,virtualWidth:s.width,virtualHeight:s.height,onPageRendered:e=>this.handlePageRendered(e),layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))})))}static get watchers(){return{templateId:["onTemplateIdChanged"]}}};A.style=R;const j=e=>((e===null||e===void 0?void 0:e.roles)||[]).map((e=>e.name));const U=(e,t)=>Math.max(j(e).findIndex((e=>e===t)),0);const B='@-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=B;const $='<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>';const Q='<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>';const F='<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>';const W='<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>';const Y=class{constructor(i){e(this,i);this.beforeSend=t(this,"beforeSend",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=l.getDefault();this.templateId=null;this.environment="";this.containerId=`verdocs-send-${Math.random().toString(36).substring(2,11)}`;this.showPickerForId="";this.sessionContacts=[];this.sending=false;this.rolesCompleted={};this.loading=true;this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){console.log("[SEND] Loading template",this.templateId);this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{this.template=e;this.loading=false;this.rolesCompleted={};this.recomputeRolesCompleted()}))}unlistenToTemplate(){if(this.templateListenerId){y.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,i;try{this.endpoint.onSessionChanged(((e,t,i)=>{if(!i){return}const o={id:i.id,first_name:i.first_name,last_name:i.last_name,email:i.email,phone:i.phone};if(i){this.sessionContacts=[o];d(this.endpoint).then((e=>{console.log("[SEND] Got contacts",e);this.sessionContacts=[...e,o]})).catch((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}if(!this.templateId){console.log(`[SEND] Missing required template ID ${this.templateId}`);return}this.listenToTemplate()}catch(o){console.log("[SEND] Error with send session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}}recomputeRolesCompleted(){var e;this.rolesCompleted={};const t={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((e=>{const i=e.sequence-1;t[i]||(t[i]=[]);const o=`r-${i}-${t[i].length}`;t[i].push({...e,id:o,role_name:e.name,first_name:e.first_name,last_name:e.last_name});if(e.first_name&&c(e.email)){this.rolesCompleted[o]={...e,id:o,role_name:e.name,first_name:e.first_name,last_name:e.last_name}}}))}getLevels(){var e;const t=[...new Set((((e=this.template)===null||e===void 0?void 0:e.roles)||[]).map((e=>e.sequence-1)))];t.sort(((e,t)=>e-t));return t}getRolesAtLevel(e){var t;const i=(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((t=>t.sequence-1===e)).map(((t,i)=>({...t,id:`r-${e}-${i}`,role_name:t.name,first_name:t.first_name,last_name:t.last_name})));return i}getLevelIcon(e){const t=this.getLevels();if(e<0){return i("div",{class:"level-icon",innerHTML:Q})}else if(e>=t.length){return i("div",{class:"level-icon",innerHTML:W})}else{return i("div",{class:"level-icon",innerHTML:F})}}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;if(this.sending){console.log("[SEND] Skipping duplicate send",e);return}console.log("[SEND] Sending",e);e.preventDefault();e.stopPropagation();this.sending=true;const i={template_id:this.templateId,name:((t=this.template)===null||t===void 0?void 0:t.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted),fields:[]};const o=this.beforeSend.emit({...i,name:i.name});if(o.defaultPrevented){console.log("[SEND] Send cancelled by parent",i);this.sending=false;return}console.log("[SEND] Creating envelope",i);h(this.endpoint,i).then((e=>{var t;console.log("[SEND] Send envelope",e);this.reset().catch((e=>console.log("Unknown Error",e)));this.sending=false;(t=this.send)===null||t===void 0?void 0:t.emit({...i,name:i.name,envelope_id:e.id,envelope:e})})).catch((e=>{var t,i,o;console.log("[SEND] Send error",e);k(((i=(t=e.response)===null||t===void 0?void 0:t.data)===null||i===void 0?void 0:i.error)||"Error creating envelope, please try again later.");this.sending=false;(o=this.sdkError)===null||o===void 0?void 0:o.emit(e)}))}handleCancel(e){var t;e.stopPropagation();(t=this.exit)===null||t===void 0?void 0:t.emit()}render(){var e;if(this.loading){return i(o,null,i("verdocs-loader",null))}if(!this.endpoint.session){return i(o,{style:{display:"flex"}},i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}const t=this.getLevels();const s=Object.values(this.rolesCompleted).filter((e=>c(e.email)&&e.first_name&&e.last_name));const n=s.length>=j(this.template).length;return i(o,{class:{sendable:(e=this.template)===null||e===void 0?void 0:e.is_sendable}},i("div",{class:"recipients"},i("div",{class:"left-line"}),i("div",{class:`level level-start`},this.getLevelIcon(-1),i("div",{class:"complete"},"Send Envelope")),t.map((e=>i("div",{class:`level level-${e}`},this.getLevelIcon(e),this.getRolesAtLevel(e).map((e=>{var t,o,n;const l=!e.email||!e.first_name||!e.last_name;const r=((t=this.rolesCompleted[e.id])===null||t===void 0?void 0:t.first_name)?u(this.rolesCompleted[e.id]):l?e.role_name:u(e);const a=`verdocs-send-recipient-${e.role_name}`;const d=U(this.template,e.role_name);const c=f(d);const h=s.findIndex((t=>t.role_name===e.role_name))>-1;const p={backgroundColor:c,border:h?"2px solid #55bc81":"2px solid #dddddd"};return l?i("div",{class:"recipient","data-ri":d,"data-rn":e.role_name,style:p,onClick:t=>this.handleClickRole(t,e),id:a},r,i("div",{class:"icon",innerHTML:$}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:a,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:t=>this.handleSelectContact(t,e),contactSuggestions:this.sessionContacts,templateRole:(o=this.rolesCompleted[e.id])!==null&&o!==void 0?o:e,onSearchContacts:e=>{var t;return(t=this.searchContacts)===null||t===void 0?void 0:t.emit(e.detail)}}))):i("div",{class:"recipient","data-ri":d,"data-rn":e.role_name,style:p,onClick:t=>this.handleClickRole(t,e),id:a},r,i("div",{class:"icon",innerHTML:$}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:a,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:t=>this.handleSelectContact(t,e),contactSuggestions:this.sessionContacts,templateRole:(n=this.rolesCompleted[e.id])!==null&&n!==void 0?n:e,onSearchContacts:e=>{var t;return(t=this.searchContacts)===null||t===void 0?void 0:t.emit(e.detail)}})))}))))),i("div",{class:`level level-done`},this.getLevelIcon(t.length),i("div",{class:"complete"},"Signing Complete"))),i("div",{class:"buttons"},i("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:e=>this.handleCancel(e),disabled:this.sending}),i("verdocs-button",{label:"Send",size:"small",disabled:!n||this.sending,onClick:e=>this.handleSend(e)}),this.sending&&i("verdocs-spinner",null)))}static get watchers(){return{templateId:["onTemplateIdChanged"]}}};Y.style=P;const J='@-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 X=J;const G=class{constructor(i){e(this,i);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=l.getDefault();this.templateId="";this.uploading=false;this.progressLabel="Uploading...";this.progressPercent=0;this.showDeleteError=false;this.confirmDeleteDocument=null;this.loading=true;this.template=null}async componentWillLoad(){var e,t,i;try{this.endpoint.loadSession();if(!this.templateId){console.log(`[ROLES] Missing required template ID ${this.templateId}`);return}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return}this.listenToTemplate()}catch(o){console.log("[TEMPLATE ATTACHMENTS] Error loading template",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{this.template=e;this.loading=false}))}unlistenToTemplate(){if(this.templateListenerId){y.store.delListener(this.templateListenerId);this.templateListenerId=null}}handleCancel(e){e.stopPropagation();this.exit.emit()}handleUploadProgress(e){if(e>=99){this.progressPercent=100;this.progressLabel="Processing..."}else{this.progressPercent=e}}async handleUpload(e){var t,i,o,s;e.stopPropagation();const n=e.detail.file;if(!n){return}console.log("[ATTACHMENTS] Uploading...",n);this.uploading=true;this.progressLabel="Uploading...";try{const e=await p(this.endpoint,this.templateId,n,this.handleUploadProgress.bind(this));console.log("[ATTACHMENTS] Created attachment",e);this.template=await y.getTemplate(this.endpoint,this.templateId,true);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}catch(e){console.log("[ATTACHMENTS] Error creating template",e);(i=this.sdkError)===null||i===void 0?void 0:i.emit(new w(e.message,(o=e.response)===null||o===void 0?void 0:o.status,(s=e.response)===null||s===void 0?void 0:s.data));this.uploading=false}}handleNext(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})}async confirmDelete(){await v(this.endpoint,this.templateId,this.confirmDeleteDocument.id);this.template=await y.getTemplate(this.endpoint,this.templateId,true);console.log("[ATTACHMENTS] New template",this.template);this.confirmDeleteDocument=null}async handleDelete(e){var t;if((((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>1){this.confirmDeleteDocument=e}else{this.showDeleteError=true}}getFileIcon(e){switch(e.mime){case"application/pdf":return C;case"image/jpeg":return q;case"image/png":return S;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return E}return M}render(){var e,t;if(!this.endpoint.session){return i(o,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading){return i(o,{class:"loading"},i("verdocs-loader",null))}if(!this.endpoint.session||!this.template){return i(o,{class:"empty"})}return i(o,null,i("h5",null,"Existing Attachments"),i("div",{class:"attachments"},(((e=this.template)===null||e===void 0?void 0:e.documents)||[]).map((e=>i("div",{class:"attachment"},i("div",{class:"file-icon",innerHTML:this.getFileIcon(e)}),i("div",{class:"filename",title:e.name},e.name),i("div",{class:"pages"},i("div",{class:"count"},e.pages),i("div",{class:"pages-icon",innerHTML:T})),i("div",{class:"trash-icon",innerHTML:I,onClick:()=>this.handleDelete(e)}))))),i("h5",null,"Attach a New Document"),this.uploading?i("div",{class:"loader-wrapper"},i("verdocs-loader",null),this.progressLabel&&i("div",{class:"progress-wrapper"},i("verdocs-progress-bar",{showPercent:true,percent:this.progressPercent,label:this.progressLabel}))):i("verdocs-file-chooser",{onFileSelected:e=>this.handleUpload(e)}),i("div",{class:"buttons"},i("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:e=>this.handleCancel(e),disabled:this.uploading}),i("verdocs-button",{label:"Next",size:"small",onClick:e=>this.handleNext(e),disabled:!(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length||this.uploading})),this.showDeleteError&&i("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:()=>this.showDeleteError=false}),this.confirmDeleteDocument&&i("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:true,onExit:()=>{this.confirmDeleteDocument=null}}))}};G.style=X;const K='@-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 ee=K;const te='<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>';const ie=`<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>`;const oe=["attachments","roles","settings","fields","preview"];const se=class{constructor(i){e(this,i);this.sdkError=t(this,"sdkError",7);this.stepChanged=t(this,"stepChanged",7);this.templateListenerId=null;this.endpoint=l.getDefault();this.templateId=null;this.step="preview";this.loading=true;this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{this.template=e;this.loading=false}))}unlistenToTemplate(){if(this.templateListenerId){y.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,i;try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");return}if(!this.templateId){this.step="attachments";console.log("[BUILD_TABS] Missing required template ID, forcing view to attachments");return}this.listenToTemplate()}catch(o){console.log("[BUILD_TABS] Error loading template",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.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;(t=this.stepChanged)===null||t===void 0?void 0:t.emit(e.detail.tab.id)}copyTemplateId(){navigator.clipboard.writeText(this.templateId).then((()=>{k("Template ID copied",{style:"success",duration:3e3})})).catch((e=>{var t;console.warn("[BUILD_TABS] Error copying to clipboard",e);(t=this.sdkError)===null||t===void 0?void 0:t.emit(e)}))}render(){var e,t,s,n,l,r,a,d,c;if(this.loading){return i(o,null,i("verdocs-loader",null))}if(!this.endpoint.session){return i(o,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}const h=(((e=this.template)===null||e===void 0?void 0:e.documents)||[]).length>0;let u=h&&(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).length>0;const f=u&&(((s=this.template)===null||s===void 0?void 0:s.fields)||[]).length>0;let p=Math.max(oe.indexOf(this.step),0);if(!f&&p>=4){p=3}if(!u&&p>=3){p=1}if(!h&&p>=1){p=0}return i(o,null,i("verdocs-tabs",{onSelectTab:e=>this.setStep(e),selectedTab:p,tabs:[{id:"attachments",disabled:false,label:"Attachment(s)"},{id:"roles",disabled:!h,label:"Roles"},{id:"settings",disabled:!u,label:"Settings"},{id:"fields",disabled:!u,label:"Fields"},{id:"preview",disabled:!f,label:"Preview/Send"}]}),this.templateId&&i("div",{class:"info"},i("verdocs-button-panel",{icon:te},i("div",{class:"template-details-panel"},i("h6",null,"Template Details"),i("div",{class:"row"},i("label",null,"ID:"),i("div",{class:"value"},this.templateId),i("div",{class:"icon-button",innerHTML:ie,onClick:()=>this.copyTemplateId()})),i("div",{class:"row"},i("label",null,"Name:"),i("div",{class:"value"},(n=this.template)===null||n===void 0?void 0:n.name)),i("div",{class:"row"},i("label",null,"Visibility:"),i("div",{class:"value"},((l=this.template)===null||l===void 0?void 0:l.is_public)?"Public":((r=this.template)===null||r===void 0?void 0:r.is_personal)?"Private":"Shared")),i("div",{class:"row"},i("label",null,"Created:"),i("div",{class:"value"},((a=this.template)===null||a===void 0?void 0:a.counter)?L(new Date((d=this.template)===null||d===void 0?void 0:d.created_at),"P p"):"")),i("div",{class:"row"},i("label",null,"Used:"),i("div",{class:"value"},(c=this.template)===null||c===void 0?void 0:c.counter," time(s)"))))))}static get watchers(){return{templateId:["onTemplateIdChanged"],step:["onStepChanged"]}}};se.style=ee;const ne="@-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{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}";const le=ne;const re='<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>';const ae='<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>';const de='<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>';const ce='<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>';const he='<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>';const ue='<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>';const fe='<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>';const pe='<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>';const ve='<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>';const me='<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>';const ge=[{id:"signature",tooltip:"Signature",icon:he,class:"signature"},{id:"initial",tooltip:"Initials",icon:ue,class:"initial"},{id:"sep1",tooltip:"",icon:me,class:"separator"},{id:"textbox",tooltip:"Text Box",icon:re,class:"textbox"},{id:"checkbox",tooltip:"Check Box",icon:ae,class:"checkbox"},{id:"radio",tooltip:"Radio Button",icon:de,class:"radio"},{id:"dropdown",tooltip:"Dropdown",icon:pe,class:"dropdown"},{id:"sep2",tooltip:"",icon:me,class:"separator"},{id:"date",tooltip:"Date",icon:ce,class:"date"},{id:"timestamp",tooltip:"Timestamp",icon:fe,class:"timestamp"},{id:"attachment",tooltip:"Attachment",icon:ve,class:"attachment"}];const be=class{constructor(i){e(this,i);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=l.getDefault();this.templateId=null;this.toolbarTargetId=null;this.placing=null;this.showMustSelectRole=false;this.selectedRoleName="";this.loading=true;this.template=null}onTemplateIdChanged(){this.listenToTemplate()}handleKeyDown(e){if(e.key==="Escape"){this.placing=null}}async componentWillLoad(){var e,t,i;try{this.endpoint.loadSession();if(!this.templateId){console.log(`[FIELDS] Missing required template ID ${this.templateId}`);return}if(!this.endpoint.session){console.log("[FIELDS] Unable to start builder session, must be authenticated");return}this.listenToTemplate()}catch(o){console.log("[FIELDS] Error with fields session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}}componentDidRender(){H.dynamicDrop(true);const e=this.toolbarTargetId?document.getElementById(this.toolbarTargetId):null;const t=document.getElementById("verdocs-template-fields-toolbar");if(e&&t){console.log("[FIELDS] Moving toolbar");t.remove();e.append(t)}}componentWillUpdate(){var e,t;const i=((e=this.template)===null||e===void 0?void 0:e.roles)||[];if(!this.selectedRoleName||!i.find((e=>e&&e.name===this.selectedRoleName))){this.selectedRoleName=((t=i[0])===null||t===void 0?void 0:t.name)||"";console.log("[FIELDS] Selected new role",this.selectedRoleName)}}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{var t,i;this.template=e;this.loading=false;if(!this.selectedRoleName){this.selectedRoleName=((i=(t=e.roles)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.name)||""}}))}unlistenToTemplate(){if(this.templateListenerId){y.store.delListener(this.templateListenerId);this.templateListenerId=null}}attachFieldAttributes(e,t,i){i.addEventListener("settingsChanged",(()=>{var e;(e=this.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:this.endpoint,template:this.template,event:"added-field"})}));i.addEventListener("deleted",(()=>{var e;i.remove();(e=this.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:this.endpoint,template:this.template,event:"updated-field"})}));i.setAttribute("templateid",this.templateId);i.setAttribute("fieldname",t.name);i.setAttribute("pageNumber",String(e.pageNumber));i.setAttribute("xScale",String(e.xScale));i.setAttribute("yScale",String(e.yScale));i.setAttribute("name",t.name)}handlePageRendered(e){var t;const i=e.detail;this.cachedPageInfo[i.pageNumber]=i;this.pageHeights[i.pageNumber]=i.naturalHeight;(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).filter((e=>e&&e.page===i.pageNumber)).forEach((e=>{const t=O(e);const i=document.getElementById(t);if(i){i.setAttribute("fieldname",e.name);i.setAttribute("pagenumber",String(e.page));this.makeDraggable(i)}}))}makeDraggable(e){H(e).draggable({listeners:{move:this.handleMoveField.bind(this),end:this.handleMoveEnd.bind(this)}})}async handleMoveField(e){const t=+(e.target.getAttribute("posX")||0);const i=+(e.target.getAttribute("posY")||0);const o=+(e.target.getAttribute("xScale")||1);const s=+(e.target.getAttribute("yScale")||1);const n=e.dx/o+t;const l=e.dy/s+i;e.target.setAttribute("posX",n);e.target.setAttribute("posy",l);D(e.target,"translate",`${n}px, ${l}px`)}async handleMoveEnd(e){var t,i,o,s,n,l,r,a;const d=e.target.getAttribute("fieldname");const c=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).find((e=>e.name===d));if(!c){console.log("[FIELDS] Unable to find field",d,e.target);return}const h=e.target.getAttribute("pagenumber");let{naturalWidth:u=612,naturalHeight:f=792,renderedHeight:p=792}=this.cachedPageInfo[h];const v=e.target.getBoundingClientRect();const g=e.target.parentElement;const b=g.getBoundingClientRect();const x=c.width||_(c.type);const E=c.height||N(c.type);const S=Math.max(v.left-b.left,0);let q=Math.max(p-(b.bottom-v.bottom),0);let C=parseInt(h);if(q>p){C=Math.min(C+1,((s=(o=((i=this.template)===null||i===void 0?void 0:i.documents)||[])===null||o===void 0?void 0:o[0])===null||s===void 0?void 0:s.pages)||1);q-=p;p=this.cachedPageInfo[C].renderedHeight;console.log("Next page",{newPageNumber:C,newY:q,renderedHeight:p})}else if(q<0){C=Math.max(C-1,1);p=this.cachedPageInfo[C].renderedHeight;q+=p;console.log("[FIELDS] Next page",{newPageNumber:C,newY:q,renderedHeight:p})}const{x:M,y:T}=this.viewCoordinatesToPageCoordinates(S,q,h,u-x,f-E);try{const t={x:M,y:T,page:C};const i=await m(this.endpoint,this.templateId,d,t);console.log("[FIELDS] Updated",i);const o=JSON.parse(JSON.stringify(this.template));const s=o.fields.findIndex((e=>e.name===d));if(s>-1){o.fields[s]=i}y.updateTemplate(this.templateId,o);e.target.removeAttribute("posX");e.target.removeAttribute("posY");Z(e.target);const{xScale:l=1,yScale:r=1}=this.cachedPageInfo[h];z(e.target,i,l,r);(n=this.templateUpdated)===null||n===void 0?void 0:n.emit({endpoint:this.endpoint,template:o,event:"updated-field"})}catch(t){k("Error updating field, please try again later",{style:"error"});console.log("[FIELDS] Error updating field",t);(l=this.sdkError)===null||l===void 0?void 0:l.emit(new w(t.message,(r=t.response)===null||r===void 0?void 0:r.status,(a=t.response)===null||a===void 0?void 0:a.data));e.target.removeAttribute("posX");e.target.removeAttribute("posY");Z(e.target)}}generateFieldName(e,t){var i;let o=1;let s;do{s=`${e}P${t}-${o}`;o++}while((((i=this.template)===null||i===void 0?void 0:i.fields)||[]).some((e=>e&&e.name===s)));return s}viewCoordinatesToPageCoordinates(e,t,i,o,s){const{xScale:n=1,yScale:l=1,renderedHeight:r=792}=this.cachedPageInfo[i];const a=Math.floor(Math.min(e/n,o));const d=Math.floor(Math.min(Math.max(r-t,0)/l,s));return{x:a,y:d}}async handleClickPage(e,t){var i;if(this.placing){const o=e.offsetX;const s=e.offsetY;const n=_(this.placing);const l=N(this.placing);const r=this.cachedPageInfo[t];const{naturalWidth:a=612,naturalHeight:d=792}=r;const c=this.viewCoordinatesToPageCoordinates(o,s,t,a-n,d-l);const h=Math.floor(c.x);const u=Math.floor(c.y);const f={name:this.generateFieldName(this.placing,t),role_name:this.selectedRoleName,template_id:this.templateId,document_id:r.documentId,type:this.placing,required:this.placing!=="radio",page:t,validator:null,label:null,default:null,placeholder:null,group:null,settings:{},x:h,y:u,width:n,height:l,multiline:false,readonly:false,options:this.placing==="radio"?[{id:"option-1",label:"Option 1"}]:[]};console.log("[FIELDS] Will save new field",f);const p=await g(this.endpoint,this.templateId,f);console.log("[FIELDS] Saved field",p);const v=JSON.parse(JSON.stringify(this.template));v.fields.push(p);y.updateTemplate(this.templateId,v);(i=this.templateUpdated)===null||i===void 0?void 0:i.emit({endpoint:this.endpoint,template:v,event:"added-field"});this.placing=null}}render(){var e,t,s;if(this.loading){return i(o,null,i("verdocs-loader",null))}if(!this.endpoint.session){return i(o,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}const n=(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).map((e=>({value:e.name,label:e.full_name?`${e.name}: ${e.full_name}`:e.name})));return i(o,{class:this.placing?{[`placing-${this.placing}`]:true}:{},onSubmit:()=>{}},i("div",{id:"verdocs-template-fields-toolbar"},i("div",{class:"add-for"},"Add field:"),i("verdocs-select-input",{value:this.selectedRoleName,options:n,onInput:e=>this.selectedRoleName=e.target.value}),ge.map((e=>i("verdocs-toolbar-icon",{text:e.tooltip,icon:e.icon,class:e.class,onClick:()=>{if(e.tooltip){if(this.selectedRoleName){this.placing=e.id}else{this.showMustSelectRole=true}}}})))),i("div",{class:"pages"},(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((e=>{const t=a(1,e.pages);return t.map((t=>{const o=e.page_sizes[t];return i("verdocs-template-document-page",{templateId:this.templateId,documentId:e.id,pageNumber:t,virtualWidth:(o===null||o===void 0?void 0:o.width)||612,virtualHeight:(o===null||o===void 0?void 0:o.height)||792,disabled:true,editable:true,done:false,onClick:e=>this.handleClickPage(e,t),onPageRendered:e=>this.handlePageRendered(e),layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})}))}))),this.showMustSelectRole&&i("verdocs-ok-dialog",{heading:"Unable to add field",message:(((s=this.template)===null||s===void 0?void 0:s.roles)||[]).length>0?"Please select a role before adding fields.":"Please add at least one role before adding fields.",onNext:()=>this.showMustSelectRole=false}))}static get watchers(){return{templateId:["onTemplateIdChanged"]}}};be.style=le;
1
+ import{r as e,c as t,h as i,H as o,F as s,g as n}from"./p-b9654a5e.js";import{VerdocsEndpoint as l,getTemplate as r,integerSequence as a,getOrganizationContacts as d,isValidEmail as c,createEnvelope as h,formatFullName as u,getRGBA as f,createTemplateDocument as p,deleteTemplateDocument as v,updateField as m,createField as g,updateTemplateRole as b,createTemplateRole as x}from"@verdocs/js-sdk";import{S as w}from"./p-fd97809c.js";import{S as y}from"./p-d4be87ef.js";import{V as k}from"./p-04c07b7b.js";import{D as E,P as S,J as q,a as C,F as M,b as T,T as I}from"./p-b0766439.js";import{f as L}from"./p-12bab948.js";import{i as H}from"./p-a901dff2.js";import{b as D,c as Z,d as z,g as O,e as _,f as N}from"./p-0c45b79c.js";import"./p-85aa8e05.js";import"./p-c7ee88c7.js";const V='@-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 R=V;const A=class{constructor(i){e(this,i);this.sdkError=t(this,"sdkError",7);this.templateListenerId=null;this.endpoint=l.getDefault();this.templateId=null;this.loading=true;this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{this.template=e;this.loading=false}))}unlistenToTemplate(){if(this.templateListenerId){y.store.delListener(this.templateListenerId);this.templateListenerId=null}}onTemplateIdChanged(e){console.log("[PREVIEW] Template ID changed",e);this.listenToTemplate()}async componentWillLoad(){var e,t,i;try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[PREVIEW] Unable to start builder session, must be authenticated");return}if(!this.templateId){console.log(`[PREVIEW] Missing required template ID ${this.templateId}`);return}this.listenToTemplate()}catch(o){console.log("[PREVIEW] Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}}handlePageRendered(e){}render(){var e;if(this.loading){return i(o,null,i("verdocs-loader",null))}return i(o,null,(((e=this.template)===null||e===void 0?void 0:e.documents)||[]).map((e=>{const t=a(1,e.pages);return i(s,null,t.map((t=>{var o;const s=((o=e.page_sizes)===null||o===void 0?void 0:o[t])||{width:612,height:792};return i("verdocs-template-document-page",{templateId:e.template_id,documentId:e.id,pageNumber:t,disabled:true,editable:false,done:false,virtualWidth:s.width,virtualHeight:s.height,onPageRendered:e=>this.handlePageRendered(e),layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))})))}static get watchers(){return{templateId:["onTemplateIdChanged"]}}};A.style=R;const j=e=>((e===null||e===void 0?void 0:e.roles)||[]).map((e=>e.name));const U=(e,t)=>Math.max(j(e).findIndex((e=>e===t)),0);const B='@-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=B;const $='<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>';const Q='<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>';const F='<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>';const W='<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>';const Y=class{constructor(i){e(this,i);this.beforeSend=t(this,"beforeSend",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=l.getDefault();this.templateId=null;this.environment="";this.containerId=`verdocs-send-${Math.random().toString(36).substring(2,11)}`;this.showPickerForId="";this.sessionContacts=[];this.sending=false;this.rolesCompleted={};this.loading=true;this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){console.log("[SEND] Loading template",this.templateId);this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{this.template=e;this.loading=false;this.rolesCompleted={};this.recomputeRolesCompleted()}))}unlistenToTemplate(){if(this.templateListenerId){y.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,i;try{this.endpoint.onSessionChanged(((e,t,i)=>{if(!i){return}const o={id:i.id,first_name:i.first_name,last_name:i.last_name,email:i.email,phone:i.phone};if(i){this.sessionContacts=[o];d(this.endpoint).then((e=>{console.log("[SEND] Got contacts",e);this.sessionContacts=[...e,o]})).catch((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}if(!this.templateId){console.log(`[SEND] Missing required template ID ${this.templateId}`);return}this.listenToTemplate()}catch(o){console.log("[SEND] Error with send session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}}recomputeRolesCompleted(){var e;this.rolesCompleted={};const t={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((e=>{const i=e.sequence-1;t[i]||(t[i]=[]);const o=`r-${i}-${t[i].length}`;t[i].push({...e,id:o,role_name:e.name,first_name:e.first_name,last_name:e.last_name});if(e.first_name&&c(e.email)){this.rolesCompleted[o]={...e,id:o,role_name:e.name,first_name:e.first_name,last_name:e.last_name}}}))}getLevels(){var e;const t={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((e=>{t[e.sequence]=true}));console.log("[SEND] Sequences",t);return Object.keys(t).map((e=>+e)).sort(((e,t)=>e-t))}getRolesAtLevel(e){var t;const i=(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((t=>t.sequence-1===e)).map(((t,i)=>({...t,id:`r-${e}-${i}`,role_name:t.name,first_name:t.first_name,last_name:t.last_name})));return i}getLevelIcon(e){const t=this.getLevels();if(e<0){return i("div",{class:"level-icon",innerHTML:Q})}else if(e>=t.length){return i("div",{class:"level-icon",innerHTML:W})}else{return i("div",{class:"level-icon",innerHTML:F})}}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;if(this.sending){console.log("[SEND] Skipping duplicate send",e);return}console.log("[SEND] Sending",e);e.preventDefault();e.stopPropagation();this.sending=true;const i={template_id:this.templateId,name:((t=this.template)===null||t===void 0?void 0:t.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted),fields:[]};const o=this.beforeSend.emit({...i,name:i.name});if(o.defaultPrevented){console.log("[SEND] Send cancelled by parent",i);this.sending=false;return}console.log("[SEND] Creating envelope",i);h(this.endpoint,i).then((e=>{var t;console.log("[SEND] Send envelope",e);this.reset().catch((e=>console.log("Unknown Error",e)));this.sending=false;(t=this.send)===null||t===void 0?void 0:t.emit({...i,name:i.name,envelope_id:e.id,envelope:e})})).catch((e=>{var t,i,o;console.log("[SEND] Send error",e);k(((i=(t=e.response)===null||t===void 0?void 0:t.data)===null||i===void 0?void 0:i.error)||"Error creating envelope, please try again later.");this.sending=false;(o=this.sdkError)===null||o===void 0?void 0:o.emit(e)}))}handleCancel(e){var t;e.stopPropagation();(t=this.exit)===null||t===void 0?void 0:t.emit()}render(){var e;if(this.loading){return i(o,null,i("verdocs-loader",null))}if(!this.endpoint.session){return i(o,{style:{display:"flex"}},i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}const t=this.getLevels();const s=Object.values(this.rolesCompleted).filter((e=>c(e.email)&&e.first_name&&e.last_name));const n=s.length>=j(this.template).length;return i(o,{class:{sendable:(e=this.template)===null||e===void 0?void 0:e.is_sendable}},i("div",{class:"recipients"},i("div",{class:"left-line"}),i("div",{class:`level level-start`},this.getLevelIcon(-1),i("div",{class:"complete"},"Send Envelope")),t.map((e=>i("div",{class:`level level-${e}`},this.getLevelIcon(e),this.getRolesAtLevel(e).map((e=>{var t,o,n;const l=!e.email||!e.first_name||!e.last_name;const r=((t=this.rolesCompleted[e.id])===null||t===void 0?void 0:t.first_name)?u(this.rolesCompleted[e.id]):l?e.role_name:u(e);const a=`verdocs-send-recipient-${e.role_name}`;const d=U(this.template,e.role_name);const c=f(d);const h=s.findIndex((t=>t.role_name===e.role_name))>-1;const p={backgroundColor:c,border:h?"2px solid #55bc81":"2px solid #dddddd"};return l?i("div",{class:"recipient","data-ri":d,"data-rn":e.role_name,style:p,onClick:t=>this.handleClickRole(t,e),id:a},r,i("div",{class:"icon",innerHTML:$}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:a,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:t=>this.handleSelectContact(t,e),contactSuggestions:this.sessionContacts,templateRole:(o=this.rolesCompleted[e.id])!==null&&o!==void 0?o:e,onSearchContacts:e=>{var t;return(t=this.searchContacts)===null||t===void 0?void 0:t.emit(e.detail)}}))):i("div",{class:"recipient","data-ri":d,"data-rn":e.role_name,style:p,onClick:t=>this.handleClickRole(t,e),id:a},r,i("div",{class:"icon",innerHTML:$}),this.showPickerForId===e.id&&i("verdocs-portal",{anchor:a,onClickAway:()=>this.showPickerForId=""},i("verdocs-contact-picker",{onExit:()=>this.showPickerForId="",onNext:t=>this.handleSelectContact(t,e),contactSuggestions:this.sessionContacts,templateRole:(n=this.rolesCompleted[e.id])!==null&&n!==void 0?n:e,onSearchContacts:e=>{var t;return(t=this.searchContacts)===null||t===void 0?void 0:t.emit(e.detail)}})))}))))),i("div",{class:`level level-done`},this.getLevelIcon(t.length),i("div",{class:"complete"},"Signing Complete"))),i("div",{class:"buttons"},i("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:e=>this.handleCancel(e),disabled:this.sending}),i("verdocs-button",{label:"Send",size:"small",disabled:!n||this.sending,onClick:e=>this.handleSend(e)}),this.sending&&i("verdocs-spinner",null)))}static get watchers(){return{templateId:["onTemplateIdChanged"]}}};Y.style=P;const J='@-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 X=J;const G=class{constructor(i){e(this,i);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=l.getDefault();this.templateId="";this.uploading=false;this.progressLabel="Uploading...";this.progressPercent=0;this.showDeleteError=false;this.confirmDeleteDocument=null;this.loading=true;this.template=null}async componentWillLoad(){var e,t,i;try{this.endpoint.loadSession();if(!this.templateId){console.log(`[ROLES] Missing required template ID ${this.templateId}`);return}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return}this.listenToTemplate()}catch(o){console.log("[TEMPLATE ATTACHMENTS] Error loading template",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{this.template=e;this.loading=false}))}unlistenToTemplate(){if(this.templateListenerId){y.store.delListener(this.templateListenerId);this.templateListenerId=null}}handleCancel(e){e.stopPropagation();this.exit.emit()}handleUploadProgress(e){if(e>=99){this.progressPercent=100;this.progressLabel="Processing..."}else{this.progressPercent=e}}async handleUpload(e){var t,i,o,s;e.stopPropagation();const n=e.detail.file;if(!n){return}console.log("[ATTACHMENTS] Uploading...",n);this.uploading=true;this.progressLabel="Uploading...";try{const e=await p(this.endpoint,this.templateId,n,this.handleUploadProgress.bind(this));console.log("[ATTACHMENTS] Created attachment",e);this.template=await y.getTemplate(this.endpoint,this.templateId,true);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}catch(e){console.log("[ATTACHMENTS] Error creating template",e);(i=this.sdkError)===null||i===void 0?void 0:i.emit(new w(e.message,(o=e.response)===null||o===void 0?void 0:o.status,(s=e.response)===null||s===void 0?void 0:s.data));this.uploading=false}}handleNext(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})}async confirmDelete(){await v(this.endpoint,this.templateId,this.confirmDeleteDocument.id);this.template=await y.getTemplate(this.endpoint,this.templateId,true);console.log("[ATTACHMENTS] New template",this.template);this.confirmDeleteDocument=null}async handleDelete(e){var t;if((((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>1){this.confirmDeleteDocument=e}else{this.showDeleteError=true}}getFileIcon(e){switch(e.mime){case"application/pdf":return C;case"image/jpeg":return q;case"image/png":return S;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return E}return M}render(){var e,t;if(!this.endpoint.session){return i(o,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading){return i(o,{class:"loading"},i("verdocs-loader",null))}if(!this.endpoint.session||!this.template){return i(o,{class:"empty"})}return i(o,null,i("h5",null,"Existing Attachments"),i("div",{class:"attachments"},(((e=this.template)===null||e===void 0?void 0:e.documents)||[]).map((e=>i("div",{class:"attachment"},i("div",{class:"file-icon",innerHTML:this.getFileIcon(e)}),i("div",{class:"filename",title:e.name},e.name),i("div",{class:"pages"},i("div",{class:"count"},e.pages),i("div",{class:"pages-icon",innerHTML:T})),i("div",{class:"trash-icon",innerHTML:I,onClick:()=>this.handleDelete(e)}))))),i("h5",null,"Attach a New Document"),this.uploading?i("div",{class:"loader-wrapper"},i("verdocs-loader",null),this.progressLabel&&i("div",{class:"progress-wrapper"},i("verdocs-progress-bar",{showPercent:true,percent:this.progressPercent,label:this.progressLabel}))):i("verdocs-file-chooser",{onFileSelected:e=>this.handleUpload(e)}),i("div",{class:"buttons"},i("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:e=>this.handleCancel(e),disabled:this.uploading}),i("verdocs-button",{label:"Next",size:"small",onClick:e=>this.handleNext(e),disabled:!(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length||this.uploading})),this.showDeleteError&&i("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:()=>this.showDeleteError=false}),this.confirmDeleteDocument&&i("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:true,onExit:()=>{this.confirmDeleteDocument=null}}))}};G.style=X;const K='@-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 ee=K;const te='<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>';const ie=`<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>`;const oe=["attachments","roles","settings","fields","preview"];const se=class{constructor(i){e(this,i);this.sdkError=t(this,"sdkError",7);this.stepChanged=t(this,"stepChanged",7);this.templateListenerId=null;this.endpoint=l.getDefault();this.templateId=null;this.step="preview";this.loading=true;this.template=null}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{this.template=e;this.loading=false}))}unlistenToTemplate(){if(this.templateListenerId){y.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,i;try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");return}if(!this.templateId){this.step="attachments";console.log("[BUILD_TABS] Missing required template ID, forcing view to attachments");return}this.listenToTemplate()}catch(o){console.log("[BUILD_TABS] Error loading template",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.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;(t=this.stepChanged)===null||t===void 0?void 0:t.emit(e.detail.tab.id)}copyTemplateId(){navigator.clipboard.writeText(this.templateId).then((()=>{k("Template ID copied",{style:"success",duration:3e3})})).catch((e=>{var t;console.warn("[BUILD_TABS] Error copying to clipboard",e);(t=this.sdkError)===null||t===void 0?void 0:t.emit(e)}))}render(){var e,t,s,n,l,r,a,d,c;if(this.loading){return i(o,null,i("verdocs-loader",null))}if(!this.endpoint.session){return i(o,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}const h=(((e=this.template)===null||e===void 0?void 0:e.documents)||[]).length>0;let u=h&&(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).length>0;const f=u&&(((s=this.template)===null||s===void 0?void 0:s.fields)||[]).length>0;let p=Math.max(oe.indexOf(this.step),0);if(!f&&p>=4){p=3}if(!u&&p>=3){p=1}if(!h&&p>=1){p=0}return i(o,null,i("verdocs-tabs",{onSelectTab:e=>this.setStep(e),selectedTab:p,tabs:[{id:"attachments",disabled:false,label:"Attachment(s)"},{id:"roles",disabled:!h,label:"Roles"},{id:"settings",disabled:!u,label:"Settings"},{id:"fields",disabled:!u,label:"Fields"},{id:"preview",disabled:!f,label:"Preview/Send"}]}),this.templateId&&i("div",{class:"info"},i("verdocs-button-panel",{icon:te},i("div",{class:"template-details-panel"},i("h6",null,"Template Details"),i("div",{class:"row"},i("label",null,"ID:"),i("div",{class:"value"},this.templateId),i("div",{class:"icon-button",innerHTML:ie,onClick:()=>this.copyTemplateId()})),i("div",{class:"row"},i("label",null,"Name:"),i("div",{class:"value"},(n=this.template)===null||n===void 0?void 0:n.name)),i("div",{class:"row"},i("label",null,"Visibility:"),i("div",{class:"value"},((l=this.template)===null||l===void 0?void 0:l.is_public)?"Public":((r=this.template)===null||r===void 0?void 0:r.is_personal)?"Private":"Shared")),i("div",{class:"row"},i("label",null,"Created:"),i("div",{class:"value"},((a=this.template)===null||a===void 0?void 0:a.counter)?L(new Date((d=this.template)===null||d===void 0?void 0:d.created_at),"P p"):"")),i("div",{class:"row"},i("label",null,"Used:"),i("div",{class:"value"},(c=this.template)===null||c===void 0?void 0:c.counter," time(s)"))))))}static get watchers(){return{templateId:["onTemplateIdChanged"],step:["onStepChanged"]}}};se.style=ee;const ne="@-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{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}";const le=ne;const re='<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>';const ae='<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>';const de='<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>';const ce='<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>';const he='<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>';const ue='<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>';const fe='<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>';const pe='<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>';const ve='<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>';const me='<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>';const ge=[{id:"signature",tooltip:"Signature",icon:he,class:"signature"},{id:"initial",tooltip:"Initials",icon:ue,class:"initial"},{id:"sep1",tooltip:"",icon:me,class:"separator"},{id:"textbox",tooltip:"Text Box",icon:re,class:"textbox"},{id:"checkbox",tooltip:"Check Box",icon:ae,class:"checkbox"},{id:"radio",tooltip:"Radio Button",icon:de,class:"radio"},{id:"dropdown",tooltip:"Dropdown",icon:pe,class:"dropdown"},{id:"sep2",tooltip:"",icon:me,class:"separator"},{id:"date",tooltip:"Date",icon:ce,class:"date"},{id:"timestamp",tooltip:"Timestamp",icon:fe,class:"timestamp"},{id:"attachment",tooltip:"Attachment",icon:ve,class:"attachment"}];const be=class{constructor(i){e(this,i);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=l.getDefault();this.templateId=null;this.toolbarTargetId=null;this.placing=null;this.showMustSelectRole=false;this.selectedRoleName="";this.loading=true;this.template=null}onTemplateIdChanged(){this.listenToTemplate()}handleKeyDown(e){if(e.key==="Escape"){this.placing=null}}async componentWillLoad(){var e,t,i;try{this.endpoint.loadSession();if(!this.templateId){console.log(`[FIELDS] Missing required template ID ${this.templateId}`);return}if(!this.endpoint.session){console.log("[FIELDS] Unable to start builder session, must be authenticated");return}this.listenToTemplate()}catch(o){console.log("[FIELDS] Error with fields session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}}componentDidRender(){H.dynamicDrop(true);const e=this.toolbarTargetId?document.getElementById(this.toolbarTargetId):null;const t=document.getElementById("verdocs-template-fields-toolbar");if(e&&t){console.log("[FIELDS] Moving toolbar");t.remove();e.append(t)}}componentWillUpdate(){var e,t;const i=((e=this.template)===null||e===void 0?void 0:e.roles)||[];if(!this.selectedRoleName||!i.find((e=>e&&e.name===this.selectedRoleName))){this.selectedRoleName=((t=i[0])===null||t===void 0?void 0:t.name)||"";console.log("[FIELDS] Selected new role",this.selectedRoleName)}}disconnectedCallback(){this.unlistenToTemplate()}async listenToTemplate(){this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{var t,i;this.template=e;this.loading=false;if(!this.selectedRoleName){this.selectedRoleName=((i=(t=e.roles)===null||t===void 0?void 0:t[0])===null||i===void 0?void 0:i.name)||""}}))}unlistenToTemplate(){if(this.templateListenerId){y.store.delListener(this.templateListenerId);this.templateListenerId=null}}attachFieldAttributes(e,t,i){i.addEventListener("settingsChanged",(()=>{var e;(e=this.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:this.endpoint,template:this.template,event:"added-field"})}));i.addEventListener("deleted",(()=>{var e;i.remove();(e=this.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:this.endpoint,template:this.template,event:"updated-field"})}));i.setAttribute("templateid",this.templateId);i.setAttribute("fieldname",t.name);i.setAttribute("pageNumber",String(e.pageNumber));i.setAttribute("xScale",String(e.xScale));i.setAttribute("yScale",String(e.yScale));i.setAttribute("name",t.name)}handlePageRendered(e){var t;const i=e.detail;this.cachedPageInfo[i.pageNumber]=i;this.pageHeights[i.pageNumber]=i.naturalHeight;(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).filter((e=>e&&e.page===i.pageNumber)).forEach((e=>{const t=O(e);const i=document.getElementById(t);if(i){i.setAttribute("fieldname",e.name);i.setAttribute("pagenumber",String(e.page));this.makeDraggable(i)}}))}makeDraggable(e){H(e).draggable({listeners:{move:this.handleMoveField.bind(this),end:this.handleMoveEnd.bind(this)}})}async handleMoveField(e){const t=+(e.target.getAttribute("posX")||0);const i=+(e.target.getAttribute("posY")||0);const o=+(e.target.getAttribute("xScale")||1);const s=+(e.target.getAttribute("yScale")||1);const n=e.dx/o+t;const l=e.dy/s+i;e.target.setAttribute("posX",n);e.target.setAttribute("posy",l);D(e.target,"translate",`${n}px, ${l}px`)}async handleMoveEnd(e){var t,i,o,s,n,l,r,a;const d=e.target.getAttribute("fieldname");const c=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).find((e=>e.name===d));if(!c){console.log("[FIELDS] Unable to find field",d,e.target);return}const h=e.target.getAttribute("pagenumber");let{naturalWidth:u=612,naturalHeight:f=792,renderedHeight:p=792}=this.cachedPageInfo[h];const v=e.target.getBoundingClientRect();const g=e.target.parentElement;const b=g.getBoundingClientRect();const x=c.width||_(c.type);const E=c.height||N(c.type);const S=Math.max(v.left-b.left,0);let q=Math.max(p-(b.bottom-v.bottom),0);let C=parseInt(h);if(q>p){C=Math.min(C+1,((s=(o=((i=this.template)===null||i===void 0?void 0:i.documents)||[])===null||o===void 0?void 0:o[0])===null||s===void 0?void 0:s.pages)||1);q-=p;p=this.cachedPageInfo[C].renderedHeight;console.log("Next page",{newPageNumber:C,newY:q,renderedHeight:p})}else if(q<0){C=Math.max(C-1,1);p=this.cachedPageInfo[C].renderedHeight;q+=p;console.log("[FIELDS] Next page",{newPageNumber:C,newY:q,renderedHeight:p})}const{x:M,y:T}=this.viewCoordinatesToPageCoordinates(S,q,h,u-x,f-E);try{const t={x:M,y:T,page:C};const i=await m(this.endpoint,this.templateId,d,t);console.log("[FIELDS] Updated",i);const o=JSON.parse(JSON.stringify(this.template));const s=o.fields.findIndex((e=>e.name===d));if(s>-1){o.fields[s]=i}y.updateTemplate(this.templateId,o);e.target.removeAttribute("posX");e.target.removeAttribute("posY");Z(e.target);const{xScale:l=1,yScale:r=1}=this.cachedPageInfo[h];z(e.target,i,l,r);(n=this.templateUpdated)===null||n===void 0?void 0:n.emit({endpoint:this.endpoint,template:o,event:"updated-field"})}catch(t){k("Error updating field, please try again later",{style:"error"});console.log("[FIELDS] Error updating field",t);(l=this.sdkError)===null||l===void 0?void 0:l.emit(new w(t.message,(r=t.response)===null||r===void 0?void 0:r.status,(a=t.response)===null||a===void 0?void 0:a.data));e.target.removeAttribute("posX");e.target.removeAttribute("posY");Z(e.target)}}generateFieldName(e,t){var i;let o=1;let s;do{s=`${e}P${t}-${o}`;o++}while((((i=this.template)===null||i===void 0?void 0:i.fields)||[]).some((e=>e&&e.name===s)));return s}viewCoordinatesToPageCoordinates(e,t,i,o,s){const{xScale:n=1,yScale:l=1,renderedHeight:r=792}=this.cachedPageInfo[i];const a=Math.floor(Math.min(e/n,o));const d=Math.floor(Math.min(Math.max(r-t,0)/l,s));return{x:a,y:d}}async handleClickPage(e,t){var i;if(this.placing){const o=e.offsetX;const s=e.offsetY;const n=_(this.placing);const l=N(this.placing);const r=this.cachedPageInfo[t];const{naturalWidth:a=612,naturalHeight:d=792}=r;const c=this.viewCoordinatesToPageCoordinates(o,s,t,a-n,d-l);const h=Math.floor(c.x);const u=Math.floor(c.y);const f={name:this.generateFieldName(this.placing,t),role_name:this.selectedRoleName,template_id:this.templateId,document_id:r.documentId,type:this.placing,required:this.placing!=="radio",page:t,validator:null,label:null,default:null,placeholder:null,group:null,settings:{},x:h,y:u,width:n,height:l,multiline:false,readonly:false,options:this.placing==="radio"?[{id:"option-1",label:"Option 1"}]:[]};console.log("[FIELDS] Will save new field",f);const p=await g(this.endpoint,this.templateId,f);console.log("[FIELDS] Saved field",p);const v=JSON.parse(JSON.stringify(this.template));v.fields.push(p);y.updateTemplate(this.templateId,v);(i=this.templateUpdated)===null||i===void 0?void 0:i.emit({endpoint:this.endpoint,template:v,event:"added-field"});this.placing=null}}render(){var e,t,s;if(this.loading){return i(o,null,i("verdocs-loader",null))}if(!this.endpoint.session){return i(o,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}const n=(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).map((e=>({value:e.name,label:e.full_name?`${e.name}: ${e.full_name}`:e.name})));return i(o,{class:this.placing?{[`placing-${this.placing}`]:true}:{},onSubmit:()=>{}},i("div",{id:"verdocs-template-fields-toolbar"},i("div",{class:"add-for"},"Add field:"),i("verdocs-select-input",{value:this.selectedRoleName,options:n,onInput:e=>this.selectedRoleName=e.target.value}),ge.map((e=>i("verdocs-toolbar-icon",{text:e.tooltip,icon:e.icon,class:e.class,onClick:()=>{if(e.tooltip){if(this.selectedRoleName){this.placing=e.id}else{this.showMustSelectRole=true}}}})))),i("div",{class:"pages"},(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((e=>{const t=a(1,e.pages);return t.map((t=>{const o=e.page_sizes[t];return i("verdocs-template-document-page",{templateId:this.templateId,documentId:e.id,pageNumber:t,virtualWidth:(o===null||o===void 0?void 0:o.width)||612,virtualHeight:(o===null||o===void 0?void 0:o.height)||792,disabled:true,editable:true,done:false,onClick:e=>this.handleClickPage(e,t),onPageRendered:e=>this.handlePageRendered(e),layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})}))}))),this.showMustSelectRole&&i("verdocs-ok-dialog",{heading:"Unable to add field",message:(((s=this.template)===null||s===void 0?void 0:s.roles)||[]).length>0?"Please select a role before adding fields.":"Please add at least one role before adding fields.",onNext:()=>this.showMustSelectRole=false}))}static get watchers(){return{templateId:["onTemplateIdChanged"]}}};be.style=le;
2
2
  /**!
3
3
  * Sortable 1.15.6
4
4
  * @author RubaXa <trash@rubaxa.org>
5
5
  * @author owenm <owen23355@gmail.com>
6
6
  * @license MIT
7
7
  */function xe(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);if(t){o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))}i.push.apply(i,o)}return i}function we(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};if(t%2){xe(Object(i),true).forEach((function(t){ke(e,t,i[t])}))}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(i))}else{xe(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}}return e}function ye(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){ye=function(e){return typeof e}}else{ye=function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return ye(e)}function ke(e,t,i){if(t in e){Object.defineProperty(e,t,{value:i,enumerable:true,configurable:true,writable:true})}else{e[t]=i}return e}function Ee(){Ee=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var o in i){if(Object.prototype.hasOwnProperty.call(i,o)){e[o]=i[o]}}}return e};return Ee.apply(this,arguments)}function Se(e,t){if(e==null)return{};var i={};var o=Object.keys(e);var s,n;for(n=0;n<o.length;n++){s=o[n];if(t.indexOf(s)>=0)continue;i[s]=e[s]}return i}function qe(e,t){if(e==null)return{};var i=Se(e,t);var o,s;if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(s=0;s<n.length;s++){o=n[s];if(t.indexOf(o)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,o))continue;i[o]=e[o]}}return i}var Ce="1.15.6";function Me(e){if(typeof window!=="undefined"&&window.navigator){return!!navigator.userAgent.match(e)}}var Te=Me(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);var Ie=Me(/Edge/i);var Le=Me(/firefox/i);var He=Me(/safari/i)&&!Me(/chrome/i)&&!Me(/android/i);var De=Me(/iP(ad|od|hone)/i);var Ze=Me(/chrome/i)&&Me(/android/i);var ze={capture:false,passive:false};function Oe(e,t,i){e.addEventListener(t,i,!Te&&ze)}function _e(e,t,i){e.removeEventListener(t,i,!Te&&ze)}function Ne(e,t){if(!t)return;t[0]===">"&&(t=t.substring(1));if(e){try{if(e.matches){return e.matches(t)}else if(e.msMatchesSelector){return e.msMatchesSelector(t)}else if(e.webkitMatchesSelector){return e.webkitMatchesSelector(t)}}catch(e){return false}}return false}function Ve(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function Re(e,t,i,o){if(e){i=i||document;do{if(t!=null&&(t[0]===">"?e.parentNode===i&&Ne(e,t):Ne(e,t))||o&&e===i){return e}if(e===i)break}while(e=Ve(e))}return null}var Ae=/\s+/g;function je(e,t,i){if(e&&t){if(e.classList){e.classList[i?"add":"remove"](t)}else{var o=(" "+e.className+" ").replace(Ae," ").replace(" "+t+" "," ");e.className=(o+(i?" "+t:"")).replace(Ae," ")}}}function Ue(e,t,i){var o=e&&e.style;if(o){if(i===void 0){if(document.defaultView&&document.defaultView.getComputedStyle){i=document.defaultView.getComputedStyle(e,"")}else if(e.currentStyle){i=e.currentStyle}return t===void 0?i:i[t]}else{if(!(t in o)&&t.indexOf("webkit")===-1){t="-webkit-"+t}o[t]=i+(typeof i==="string"?"":"px")}}}function Be(e,t){var i="";if(typeof e==="string"){i=e}else{do{var o=Ue(e,"transform");if(o&&o!=="none"){i=o+" "+i}}while(!t&&(e=e.parentNode))}var s=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return s&&new s(i)}function Pe(e,t,i){if(e){var o=e.getElementsByTagName(t),s=0,n=o.length;if(i){for(;s<n;s++){i(o[s],s)}}return o}return[]}function $e(){var e=document.scrollingElement;if(e){return e}else{return document.documentElement}}function Qe(e,t,i,o,s){if(!e.getBoundingClientRect&&e!==window)return;var n,l,r,a,d,c,h;if(e!==window&&e.parentNode&&e!==$e()){n=e.getBoundingClientRect();l=n.top;r=n.left;a=n.bottom;d=n.right;c=n.height;h=n.width}else{l=0;r=0;a=window.innerHeight;d=window.innerWidth;c=window.innerHeight;h=window.innerWidth}if((t||i)&&e!==window){s=s||e.parentNode;if(!Te){do{if(s&&s.getBoundingClientRect&&(Ue(s,"transform")!=="none"||i&&Ue(s,"position")!=="static")){var u=s.getBoundingClientRect();l-=u.top+parseInt(Ue(s,"border-top-width"));r-=u.left+parseInt(Ue(s,"border-left-width"));a=l+n.height;d=r+n.width;break}}while(s=s.parentNode)}}if(o&&e!==window){var f=Be(s||e),p=f&&f.a,v=f&&f.d;if(f){l/=v;r/=p;h/=p;c/=v;a=l+c;d=r+h}}return{top:l,left:r,bottom:a,right:d,width:h,height:c}}function Fe(e,t,i){var o=Ke(e,true),s=Qe(e)[t];while(o){var n=Qe(o)[i],l=void 0;if(i==="top"||i==="left"){l=s>=n}else{l=s<=n}if(!l)return o;if(o===$e())break;o=Ke(o,false)}return false}function We(e,t,i,o){var s=0,n=0,l=e.children;while(n<l.length){if(l[n].style.display!=="none"&&l[n]!==hi.ghost&&(o||l[n]!==hi.dragged)&&Re(l[n],i.draggable,e,false)){if(s===t){return l[n]}s++}n++}return null}function Ye(e,t){var i=e.lastElementChild;while(i&&(i===hi.ghost||Ue(i,"display")==="none"||t&&!Ne(i,t))){i=i.previousElementSibling}return i||null}function Je(e,t){var i=0;if(!e||!e.parentNode){return-1}while(e=e.previousElementSibling){if(e.nodeName.toUpperCase()!=="TEMPLATE"&&e!==hi.clone&&(!t||Ne(e,t))){i++}}return i}function Xe(e){var t=0,i=0,o=$e();if(e){do{var s=Be(e),n=s.a,l=s.d;t+=e.scrollLeft*n;i+=e.scrollTop*l}while(e!==o&&(e=e.parentNode))}return[t,i]}function Ge(e,t){for(var i in e){if(!e.hasOwnProperty(i))continue;for(var o in t){if(t.hasOwnProperty(o)&&t[o]===e[i][o])return Number(i)}}return-1}function Ke(e,t){if(!e||!e.getBoundingClientRect)return $e();var i=e;var o=false;do{if(i.clientWidth<i.scrollWidth||i.clientHeight<i.scrollHeight){var s=Ue(i);if(i.clientWidth<i.scrollWidth&&(s.overflowX=="auto"||s.overflowX=="scroll")||i.clientHeight<i.scrollHeight&&(s.overflowY=="auto"||s.overflowY=="scroll")){if(!i.getBoundingClientRect||i===document.body)return $e();if(o||t)return i;o=true}}}while(i=i.parentNode);return $e()}function et(e,t){if(e&&t){for(var i in t){if(t.hasOwnProperty(i)){e[i]=t[i]}}}return e}function tt(e,t){return Math.round(e.top)===Math.round(t.top)&&Math.round(e.left)===Math.round(t.left)&&Math.round(e.height)===Math.round(t.height)&&Math.round(e.width)===Math.round(t.width)}var it;function ot(e,t){return function(){if(!it){var i=arguments,o=this;if(i.length===1){e.call(o,i[0])}else{e.apply(o,i)}it=setTimeout((function(){it=void 0}),t)}}}function st(){clearTimeout(it);it=void 0}function nt(e,t,i){e.scrollLeft+=t;e.scrollTop+=i}function lt(e){var t=window.Polymer;var i=window.jQuery||window.Zepto;if(t&&t.dom){return t.dom(e).cloneNode(true)}else if(i){return i(e).clone(true)[0]}else{return e.cloneNode(true)}}function rt(e,t,i){var o={};Array.from(e.children).forEach((function(s){var n,l,r,a;if(!Re(s,t.draggable,e,false)||s.animated||s===i)return;var d=Qe(s);o.left=Math.min((n=o.left)!==null&&n!==void 0?n:Infinity,d.left);o.top=Math.min((l=o.top)!==null&&l!==void 0?l:Infinity,d.top);o.right=Math.max((r=o.right)!==null&&r!==void 0?r:-Infinity,d.right);o.bottom=Math.max((a=o.bottom)!==null&&a!==void 0?a:-Infinity,d.bottom)}));o.width=o.right-o.left;o.height=o.bottom-o.top;o.x=o.left;o.y=o.top;return o}var at="Sortable"+(new Date).getTime();function dt(){var e=[],t;return{captureAnimationState:function t(){e=[];if(!this.options.animation)return;var i=[].slice.call(this.el.children);i.forEach((function(t){if(Ue(t,"display")==="none"||t===hi.ghost)return;e.push({target:t,rect:Qe(t)});var i=we({},e[e.length-1].rect);if(t.thisAnimationDuration){var o=Be(t,true);if(o){i.top-=o.f;i.left-=o.e}}t.fromRect=i}))},addAnimationState:function t(i){e.push(i)},removeAnimationState:function t(i){e.splice(Ge(e,{target:i}),1)},animateAll:function i(o){var s=this;if(!this.options.animation){clearTimeout(t);if(typeof o==="function")o();return}var n=false,l=0;e.forEach((function(e){var t=0,i=e.target,o=i.fromRect,r=Qe(i),a=i.prevFromRect,d=i.prevToRect,c=e.rect,h=Be(i,true);if(h){r.top-=h.f;r.left-=h.e}i.toRect=r;if(i.thisAnimationDuration){if(tt(a,r)&&!tt(o,r)&&(c.top-r.top)/(c.left-r.left)===(o.top-r.top)/(o.left-r.left)){t=ht(c,a,d,s.options)}}if(!tt(r,o)){i.prevFromRect=o;i.prevToRect=r;if(!t){t=s.options.animation}s.animate(i,c,r,t)}if(t){n=true;l=Math.max(l,t);clearTimeout(i.animationResetTimer);i.animationResetTimer=setTimeout((function(){i.animationTime=0;i.prevFromRect=null;i.fromRect=null;i.prevToRect=null;i.thisAnimationDuration=null}),t);i.thisAnimationDuration=t}}));clearTimeout(t);if(!n){if(typeof o==="function")o()}else{t=setTimeout((function(){if(typeof o==="function")o()}),l)}e=[]},animate:function e(t,i,o,s){if(s){Ue(t,"transition","");Ue(t,"transform","");var n=Be(this.el),l=n&&n.a,r=n&&n.d,a=(i.left-o.left)/(l||1),d=(i.top-o.top)/(r||1);t.animatingX=!!a;t.animatingY=!!d;Ue(t,"transform","translate3d("+a+"px,"+d+"px,0)");this.forRepaintDummy=ct(t);Ue(t,"transition","transform "+s+"ms"+(this.options.easing?" "+this.options.easing:""));Ue(t,"transform","translate3d(0,0,0)");typeof t.animated==="number"&&clearTimeout(t.animated);t.animated=setTimeout((function(){Ue(t,"transition","");Ue(t,"transform","");t.animated=false;t.animatingX=false;t.animatingY=false}),s)}}}}function ct(e){return e.offsetWidth}function ht(e,t,i,o){return Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))/Math.sqrt(Math.pow(t.top-i.top,2)+Math.pow(t.left-i.left,2))*o.animation}var ut=[];var ft={initializeByDefault:true};var pt={mount:function e(t){for(var i in ft){if(ft.hasOwnProperty(i)&&!(i in t)){t[i]=ft[i]}}ut.forEach((function(e){if(e.pluginName===t.pluginName){throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}}));ut.push(t)},pluginEvent:function e(t,i,o){var s=this;this.eventCanceled=false;o.cancel=function(){s.eventCanceled=true};var n=t+"Global";ut.forEach((function(e){if(!i[e.pluginName])return;if(i[e.pluginName][n]){i[e.pluginName][n](we({sortable:i},o))}if(i.options[e.pluginName]&&i[e.pluginName][t]){i[e.pluginName][t](we({sortable:i},o))}}))},initializePlugins:function e(t,i,o,s){ut.forEach((function(e){var s=e.pluginName;if(!t.options[s]&&!e.initializeByDefault)return;var n=new e(t,i,t.options);n.sortable=t;n.options=t.options;t[s]=n;Ee(o,n.defaults)}));for(var n in t.options){if(!t.options.hasOwnProperty(n))continue;var l=this.modifyOption(t,n,t.options[n]);if(typeof l!=="undefined"){t.options[n]=l}}},getEventProperties:function e(t,i){var o={};ut.forEach((function(e){if(typeof e.eventProperties!=="function")return;Ee(o,e.eventProperties.call(i[e.pluginName],t))}));return o},modifyOption:function e(t,i,o){var s;ut.forEach((function(e){if(!t[e.pluginName])return;if(e.optionListeners&&typeof e.optionListeners[i]==="function"){s=e.optionListeners[i].call(t[e.pluginName],o)}}));return s}};function vt(e){var t=e.sortable,i=e.rootEl,o=e.name,s=e.targetEl,n=e.cloneEl,l=e.toEl,r=e.fromEl,a=e.oldIndex,d=e.newIndex,c=e.oldDraggableIndex,h=e.newDraggableIndex,u=e.originalEvent,f=e.putSortable,p=e.extraEventProperties;t=t||i&&i[at];if(!t)return;var v,m=t.options,g="on"+o.charAt(0).toUpperCase()+o.substr(1);if(window.CustomEvent&&!Te&&!Ie){v=new CustomEvent(o,{bubbles:true,cancelable:true})}else{v=document.createEvent("Event");v.initEvent(o,true,true)}v.to=l||i;v.from=r||i;v.item=s||i;v.clone=n;v.oldIndex=a;v.newIndex=d;v.oldDraggableIndex=c;v.newDraggableIndex=h;v.originalEvent=u;v.pullMode=f?f.lastPutMode:undefined;var b=we(we({},p),pt.getEventProperties(o,t));for(var x in b){v[x]=b[x]}if(i){i.dispatchEvent(v)}if(m[g]){m[g].call(t,v)}}var mt=["evt"];var gt=function e(t,i){var o=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},s=o.evt,n=qe(o,mt);pt.pluginEvent.bind(hi)(t,i,we({dragEl:xt,parentEl:wt,ghostEl:yt,rootEl:kt,nextEl:Et,lastDownEl:St,cloneEl:qt,cloneHidden:Ct,dragStarted:Ut,putSortable:Dt,activeSortable:hi.active,originalEvent:s,oldIndex:Mt,oldDraggableIndex:It,newIndex:Tt,newDraggableIndex:Lt,hideGhostForTarget:ri,unhideGhostForTarget:ai,cloneNowHidden:function e(){Ct=true},cloneNowShown:function e(){Ct=false},dispatchSortableEvent:function e(t){bt({sortable:i,name:t,originalEvent:s})}},n))};function bt(e){vt(we({putSortable:Dt,cloneEl:qt,targetEl:xt,rootEl:kt,oldIndex:Mt,oldDraggableIndex:It,newIndex:Tt,newDraggableIndex:Lt},e))}var xt,wt,yt,kt,Et,St,qt,Ct,Mt,Tt,It,Lt,Ht,Dt,Zt=false,zt=false,Ot=[],_t,Nt,Vt,Rt,At,jt,Ut,Bt,Pt,$t=false,Qt=false,Ft,Wt,Yt=[],Jt=false,Xt=[];var Gt=typeof document!=="undefined",Kt=De,ei=Ie||Te?"cssFloat":"float",ti=Gt&&!Ze&&!De&&"draggable"in document.createElement("div"),ii=function(){if(!Gt)return;if(Te){return false}var e=document.createElement("x");e.style.cssText="pointer-events:auto";return e.style.pointerEvents==="auto"}(),oi=function e(t,i){var o=Ue(t),s=parseInt(o.width)-parseInt(o.paddingLeft)-parseInt(o.paddingRight)-parseInt(o.borderLeftWidth)-parseInt(o.borderRightWidth),n=We(t,0,i),l=We(t,1,i),r=n&&Ue(n),a=l&&Ue(l),d=r&&parseInt(r.marginLeft)+parseInt(r.marginRight)+Qe(n).width,c=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+Qe(l).width;if(o.display==="flex"){return o.flexDirection==="column"||o.flexDirection==="column-reverse"?"vertical":"horizontal"}if(o.display==="grid"){return o.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal"}if(n&&r["float"]&&r["float"]!=="none"){var h=r["float"]==="left"?"left":"right";return l&&(a.clear==="both"||a.clear===h)?"vertical":"horizontal"}return n&&(r.display==="block"||r.display==="flex"||r.display==="table"||r.display==="grid"||d>=s&&o[ei]==="none"||l&&o[ei]==="none"&&d+c>s)?"vertical":"horizontal"},si=function e(t,i,o){var s=o?t.left:t.top,n=o?t.right:t.bottom,l=o?t.width:t.height,r=o?i.left:i.top,a=o?i.right:i.bottom,d=o?i.width:i.height;return s===r||n===a||s+l/2===r+d/2},ni=function e(t,i){var o;Ot.some((function(e){var s=e[at].options.emptyInsertThreshold;if(!s||Ye(e))return;var n=Qe(e),l=t>=n.left-s&&t<=n.right+s,r=i>=n.top-s&&i<=n.bottom+s;if(l&&r){return o=e}}));return o},li=function e(t){function i(e,t){return function(o,s,n,l){var r=o.options.group.name&&s.options.group.name&&o.options.group.name===s.options.group.name;if(e==null&&(t||r)){return true}else if(e==null||e===false){return false}else if(t&&e==="clone"){return e}else if(typeof e==="function"){return i(e(o,s,n,l),t)(o,s,n,l)}else{var a=(t?o:s).options.group.name;return e===true||typeof e==="string"&&e===a||e.join&&e.indexOf(a)>-1}}}var o={};var s=t.group;if(!s||ye(s)!="object"){s={name:s}}o.name=s.name;o.checkPull=i(s.pull,true);o.checkPut=i(s.put);o.revertClone=s.revertClone;t.group=o},ri=function e(){if(!ii&&yt){Ue(yt,"display","none")}},ai=function e(){if(!ii&&yt){Ue(yt,"display","")}};if(Gt&&!Ze){document.addEventListener("click",(function(e){if(zt){e.preventDefault();e.stopPropagation&&e.stopPropagation();e.stopImmediatePropagation&&e.stopImmediatePropagation();zt=false;return false}}),true)}var di=function e(t){if(xt){t=t.touches?t.touches[0]:t;var i=ni(t.clientX,t.clientY);if(i){var o={};for(var s in t){if(t.hasOwnProperty(s)){o[s]=t[s]}}o.target=o.rootEl=i;o.preventDefault=void 0;o.stopPropagation=void 0;i[at]._onDragOver(o)}}};var ci=function e(t){if(xt){xt.parentNode[at]._isOutsideThisEl(t.target)}};function hi(e,t){if(!(e&&e.nodeType&&e.nodeType===1)){throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e))}this.el=e;this.options=t=Ee({},t);e[at]=this;var i={group:null,sort:true,disabled:false,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:false,invertedSwapThreshold:null,removeCloneOnHide:true,direction:function t(){return oi(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:true,animation:0,easing:null,setData:function e(t,i){t.setData("Text",i.textContent)},dropBubble:false,dragoverBubble:false,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:false,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:false,fallbackClass:"sortable-fallback",fallbackOnBody:false,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:hi.supportPointer!==false&&"PointerEvent"in window&&(!He||De),emptyInsertThreshold:5};pt.initializePlugins(this,e,i);for(var o in i){!(o in t)&&(t[o]=i[o])}li(t);for(var s in this){if(s.charAt(0)==="_"&&typeof this[s]==="function"){this[s]=this[s].bind(this)}}this.nativeDraggable=t.forceFallback?false:ti;if(this.nativeDraggable){this.options.touchStartThreshold=1}if(t.supportPointer){Oe(e,"pointerdown",this._onTapStart)}else{Oe(e,"mousedown",this._onTapStart);Oe(e,"touchstart",this._onTapStart)}if(this.nativeDraggable){Oe(e,"dragover",this);Oe(e,"dragenter",this)}Ot.push(this.el);t.store&&t.store.get&&this.sort(t.store.get(this)||[]);Ee(this,dt())}hi.prototype={constructor:hi,_isOutsideThisEl:function e(t){if(!this.el.contains(t)&&t!==this.el){Bt=null}},_getDirection:function e(t,i){return typeof this.options.direction==="function"?this.options.direction.call(this,t,i,xt):this.options.direction},_onTapStart:function e(t){if(!t.cancelable)return;var i=this,o=this.el,s=this.options,n=s.preventOnFilter,l=t.type,r=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,a=(r||t).target,d=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||a,c=s.filter;yi(o);if(xt){return}if(/mousedown|pointerdown/.test(l)&&t.button!==0||s.disabled){return}if(d.isContentEditable){return}if(!this.nativeDraggable&&He&&a&&a.tagName.toUpperCase()==="SELECT"){return}a=Re(a,s.draggable,o,false);if(a&&a.animated){return}if(St===a){return}Mt=Je(a);It=Je(a,s.draggable);if(typeof c==="function"){if(c.call(this,t,a,this)){bt({sortable:i,rootEl:d,name:"filter",targetEl:a,toEl:o,fromEl:o});gt("filter",i,{evt:t});n&&t.preventDefault();return}}else if(c){c=c.split(",").some((function(e){e=Re(d,e.trim(),o,false);if(e){bt({sortable:i,rootEl:e,name:"filter",targetEl:a,fromEl:o,toEl:o});gt("filter",i,{evt:t});return true}}));if(c){n&&t.preventDefault();return}}if(s.handle&&!Re(d,s.handle,o,false)){return}this._prepareDragStart(t,r,a)},_prepareDragStart:function e(t,i,o){var s=this,n=s.el,l=s.options,r=n.ownerDocument,a;if(o&&!xt&&o.parentNode===n){var d=Qe(o);kt=n;xt=o;wt=xt.parentNode;Et=xt.nextSibling;St=o;Ht=l.group;hi.dragged=xt;_t={target:xt,clientX:(i||t).clientX,clientY:(i||t).clientY};At=_t.clientX-d.left;jt=_t.clientY-d.top;this._lastX=(i||t).clientX;this._lastY=(i||t).clientY;xt.style["will-change"]="all";a=function e(){gt("delayEnded",s,{evt:t});if(hi.eventCanceled){s._onDrop();return}s._disableDelayedDragEvents();if(!Le&&s.nativeDraggable){xt.draggable=true}s._triggerDragStart(t,i);bt({sortable:s,name:"choose",originalEvent:t});je(xt,l.chosenClass,true)};l.ignore.split(",").forEach((function(e){Pe(xt,e.trim(),pi)}));Oe(r,"dragover",di);Oe(r,"mousemove",di);Oe(r,"touchmove",di);if(l.supportPointer){Oe(r,"pointerup",s._onDrop);!this.nativeDraggable&&Oe(r,"pointercancel",s._onDrop)}else{Oe(r,"mouseup",s._onDrop);Oe(r,"touchend",s._onDrop);Oe(r,"touchcancel",s._onDrop)}if(Le&&this.nativeDraggable){this.options.touchStartThreshold=4;xt.draggable=true}gt("delayStart",this,{evt:t});if(l.delay&&(!l.delayOnTouchOnly||i)&&(!this.nativeDraggable||!(Ie||Te))){if(hi.eventCanceled){this._onDrop();return}if(l.supportPointer){Oe(r,"pointerup",s._disableDelayedDrag);Oe(r,"pointercancel",s._disableDelayedDrag)}else{Oe(r,"mouseup",s._disableDelayedDrag);Oe(r,"touchend",s._disableDelayedDrag);Oe(r,"touchcancel",s._disableDelayedDrag)}Oe(r,"mousemove",s._delayedDragTouchMoveHandler);Oe(r,"touchmove",s._delayedDragTouchMoveHandler);l.supportPointer&&Oe(r,"pointermove",s._delayedDragTouchMoveHandler);s._dragStartTimer=setTimeout(a,l.delay)}else{a()}}},_delayedDragTouchMoveHandler:function e(t){var i=t.touches?t.touches[0]:t;if(Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))){this._disableDelayedDrag()}},_disableDelayedDrag:function e(){xt&&pi(xt);clearTimeout(this._dragStartTimer);this._disableDelayedDragEvents()},_disableDelayedDragEvents:function e(){var t=this.el.ownerDocument;_e(t,"mouseup",this._disableDelayedDrag);_e(t,"touchend",this._disableDelayedDrag);_e(t,"touchcancel",this._disableDelayedDrag);_e(t,"pointerup",this._disableDelayedDrag);_e(t,"pointercancel",this._disableDelayedDrag);_e(t,"mousemove",this._delayedDragTouchMoveHandler);_e(t,"touchmove",this._delayedDragTouchMoveHandler);_e(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function e(t,i){i=i||t.pointerType=="touch"&&t;if(!this.nativeDraggable||i){if(this.options.supportPointer){Oe(document,"pointermove",this._onTouchMove)}else if(i){Oe(document,"touchmove",this._onTouchMove)}else{Oe(document,"mousemove",this._onTouchMove)}}else{Oe(xt,"dragend",this);Oe(kt,"dragstart",this._onDragStart)}try{if(document.selection){ki((function(){document.selection.empty()}))}else{window.getSelection().removeAllRanges()}}catch(e){}},_dragStarted:function e(t,i){Zt=false;if(kt&&xt){gt("dragStarted",this,{evt:i});if(this.nativeDraggable){Oe(document,"dragover",ci)}var o=this.options;!t&&je(xt,o.dragClass,false);je(xt,o.ghostClass,true);hi.active=this;t&&this._appendGhost();bt({sortable:this,name:"start",originalEvent:i})}else{this._nulling()}},_emulateDragOver:function e(){if(Nt){this._lastX=Nt.clientX;this._lastY=Nt.clientY;ri();var t=document.elementFromPoint(Nt.clientX,Nt.clientY);var i=t;while(t&&t.shadowRoot){t=t.shadowRoot.elementFromPoint(Nt.clientX,Nt.clientY);if(t===i)break;i=t}xt.parentNode[at]._isOutsideThisEl(t);if(i){do{if(i[at]){var o=void 0;o=i[at]._onDragOver({clientX:Nt.clientX,clientY:Nt.clientY,target:t,rootEl:i});if(o&&!this.options.dragoverBubble){break}}t=i}while(i=Ve(i))}ai()}},_onTouchMove:function e(t){if(_t){var i=this.options,o=i.fallbackTolerance,s=i.fallbackOffset,n=t.touches?t.touches[0]:t,l=yt&&Be(yt,true),r=yt&&l&&l.a,a=yt&&l&&l.d,d=Kt&&Wt&&Xe(Wt),c=(n.clientX-_t.clientX+s.x)/(r||1)+(d?d[0]-Yt[0]:0)/(r||1),h=(n.clientY-_t.clientY+s.y)/(a||1)+(d?d[1]-Yt[1]:0)/(a||1);if(!hi.active&&!Zt){if(o&&Math.max(Math.abs(n.clientX-this._lastX),Math.abs(n.clientY-this._lastY))<o){return}this._onDragStart(t,true)}if(yt){if(l){l.e+=c-(Vt||0);l.f+=h-(Rt||0)}else{l={a:1,b:0,c:0,d:1,e:c,f:h}}var u="matrix(".concat(l.a,",").concat(l.b,",").concat(l.c,",").concat(l.d,",").concat(l.e,",").concat(l.f,")");Ue(yt,"webkitTransform",u);Ue(yt,"mozTransform",u);Ue(yt,"msTransform",u);Ue(yt,"transform",u);Vt=c;Rt=h;Nt=n}t.cancelable&&t.preventDefault()}},_appendGhost:function e(){if(!yt){var t=this.options.fallbackOnBody?document.body:kt,i=Qe(xt,true,Kt,true,t),o=this.options;if(Kt){Wt=t;while(Ue(Wt,"position")==="static"&&Ue(Wt,"transform")==="none"&&Wt!==document){Wt=Wt.parentNode}if(Wt!==document.body&&Wt!==document.documentElement){if(Wt===document)Wt=$e();i.top+=Wt.scrollTop;i.left+=Wt.scrollLeft}else{Wt=$e()}Yt=Xe(Wt)}yt=xt.cloneNode(true);je(yt,o.ghostClass,false);je(yt,o.fallbackClass,true);je(yt,o.dragClass,true);Ue(yt,"transition","");Ue(yt,"transform","");Ue(yt,"box-sizing","border-box");Ue(yt,"margin",0);Ue(yt,"top",i.top);Ue(yt,"left",i.left);Ue(yt,"width",i.width);Ue(yt,"height",i.height);Ue(yt,"opacity","0.8");Ue(yt,"position",Kt?"absolute":"fixed");Ue(yt,"zIndex","100000");Ue(yt,"pointerEvents","none");hi.ghost=yt;t.appendChild(yt);Ue(yt,"transform-origin",At/parseInt(yt.style.width)*100+"% "+jt/parseInt(yt.style.height)*100+"%")}},_onDragStart:function e(t,i){var o=this;var s=t.dataTransfer;var n=o.options;gt("dragStart",this,{evt:t});if(hi.eventCanceled){this._onDrop();return}gt("setupClone",this);if(!hi.eventCanceled){qt=lt(xt);qt.removeAttribute("id");qt.draggable=false;qt.style["will-change"]="";this._hideClone();je(qt,this.options.chosenClass,false);hi.clone=qt}o.cloneId=ki((function(){gt("clone",o);if(hi.eventCanceled)return;if(!o.options.removeCloneOnHide){kt.insertBefore(qt,xt)}o._hideClone();bt({sortable:o,name:"clone"})}));!i&&je(xt,n.dragClass,true);if(i){zt=true;o._loopId=setInterval(o._emulateDragOver,50)}else{_e(document,"mouseup",o._onDrop);_e(document,"touchend",o._onDrop);_e(document,"touchcancel",o._onDrop);if(s){s.effectAllowed="move";n.setData&&n.setData.call(o,s,xt)}Oe(document,"drop",o);Ue(xt,"transform","translateZ(0)")}Zt=true;o._dragStartId=ki(o._dragStarted.bind(o,i,t));Oe(document,"selectstart",o);Ut=true;window.getSelection().removeAllRanges();if(He){Ue(document.body,"user-select","none")}},_onDragOver:function e(t){var i=this.el,o=t.target,s,n,l,r=this.options,a=r.group,d=hi.active,c=Ht===a,h=r.sort,u=Dt||d,f,p=this,v=false;if(Jt)return;function m(e,r){gt(e,p,we({evt:t,isOwner:c,axis:f?"vertical":"horizontal",revert:l,dragRect:s,targetRect:n,canSort:h,fromSortable:u,target:o,completed:b,onMove:function e(o,n){return fi(kt,i,xt,s,o,Qe(o),t,n)},changed:x},r))}function g(){m("dragOverAnimationCapture");p.captureAnimationState();if(p!==u){u.captureAnimationState()}}function b(e){m("dragOverCompleted",{insertion:e});if(e){if(c){d._hideClone()}else{d._showClone(p)}if(p!==u){je(xt,Dt?Dt.options.ghostClass:d.options.ghostClass,false);je(xt,r.ghostClass,true)}if(Dt!==p&&p!==hi.active){Dt=p}else if(p===hi.active&&Dt){Dt=null}if(u===p){p._ignoreWhileAnimating=o}p.animateAll((function(){m("dragOverAnimationComplete");p._ignoreWhileAnimating=null}));if(p!==u){u.animateAll();u._ignoreWhileAnimating=null}}if(o===xt&&!xt.animated||o===i&&!o.animated){Bt=null}if(!r.dragoverBubble&&!t.rootEl&&o!==document){xt.parentNode[at]._isOutsideThisEl(t.target);!e&&di(t)}!r.dragoverBubble&&t.stopPropagation&&t.stopPropagation();return v=true}function x(){Tt=Je(xt);Lt=Je(xt,r.draggable);bt({sortable:p,name:"change",toEl:i,newIndex:Tt,newDraggableIndex:Lt,originalEvent:t})}if(t.preventDefault!==void 0){t.cancelable&&t.preventDefault()}o=Re(o,r.draggable,i,true);m("dragOver");if(hi.eventCanceled)return v;if(xt.contains(t.target)||o.animated&&o.animatingX&&o.animatingY||p._ignoreWhileAnimating===o){return b(false)}zt=false;if(d&&!r.disabled&&(c?h||(l=wt!==kt):Dt===this||(this.lastPutMode=Ht.checkPull(this,d,xt,t))&&a.checkPut(this,d,xt,t))){f=this._getDirection(t,o)==="vertical";s=Qe(xt);m("dragOverValid");if(hi.eventCanceled)return v;if(l){wt=kt;g();this._hideClone();m("revert");if(!hi.eventCanceled){if(Et){kt.insertBefore(xt,Et)}else{kt.appendChild(xt)}}return b(true)}var w=Ye(i,r.draggable);if(!w||gi(t,f,this)&&!w.animated){if(w===xt){return b(false)}if(w&&i===t.target){o=w}if(o){n=Qe(o)}if(fi(kt,i,xt,s,o,n,t,!!o)!==false){g();if(w&&w.nextSibling){i.insertBefore(xt,w.nextSibling)}else{i.appendChild(xt)}wt=i;x();return b(true)}}else if(w&&mi(t,f,this)){var y=We(i,0,r,true);if(y===xt){return b(false)}o=y;n=Qe(o);if(fi(kt,i,xt,s,o,n,t,false)!==false){g();i.insertBefore(xt,y);wt=i;x();return b(true)}}else if(o.parentNode===i){n=Qe(o);var k=0,E,S=xt.parentNode!==i,q=!si(xt.animated&&xt.toRect||s,o.animated&&o.toRect||n,f),C=f?"top":"left",M=Fe(o,"top","top")||Fe(xt,"top","top"),T=M?M.scrollTop:void 0;if(Bt!==o){E=n[C];$t=false;Qt=!q&&r.invertSwap||S}k=bi(t,o,n,f,q?1:r.swapThreshold,r.invertedSwapThreshold==null?r.swapThreshold:r.invertedSwapThreshold,Qt,Bt===o);var I;if(k!==0){var L=Je(xt);do{L-=k;I=wt.children[L]}while(I&&(Ue(I,"display")==="none"||I===yt))}if(k===0||I===o){return b(false)}Bt=o;Pt=k;var H=o.nextElementSibling,D=false;D=k===1;var Z=fi(kt,i,xt,s,o,n,t,D);if(Z!==false){if(Z===1||Z===-1){D=Z===1}Jt=true;setTimeout(vi,30);g();if(D&&!H){i.appendChild(xt)}else{o.parentNode.insertBefore(xt,D?H:o)}if(M){nt(M,0,T-M.scrollTop)}wt=xt.parentNode;if(E!==undefined&&!Qt){Ft=Math.abs(E-Qe(o)[C])}x();return b(true)}}if(i.contains(xt)){return b(false)}}return false},_ignoreWhileAnimating:null,_offMoveEvents:function e(){_e(document,"mousemove",this._onTouchMove);_e(document,"touchmove",this._onTouchMove);_e(document,"pointermove",this._onTouchMove);_e(document,"dragover",di);_e(document,"mousemove",di);_e(document,"touchmove",di)},_offUpEvents:function e(){var t=this.el.ownerDocument;_e(t,"mouseup",this._onDrop);_e(t,"touchend",this._onDrop);_e(t,"pointerup",this._onDrop);_e(t,"pointercancel",this._onDrop);_e(t,"touchcancel",this._onDrop);_e(document,"selectstart",this)},_onDrop:function e(t){var i=this.el,o=this.options;Tt=Je(xt);Lt=Je(xt,o.draggable);gt("drop",this,{evt:t});wt=xt&&xt.parentNode;Tt=Je(xt);Lt=Je(xt,o.draggable);if(hi.eventCanceled){this._nulling();return}Zt=false;Qt=false;$t=false;clearInterval(this._loopId);clearTimeout(this._dragStartTimer);Ei(this.cloneId);Ei(this._dragStartId);if(this.nativeDraggable){_e(document,"drop",this);_e(i,"dragstart",this._onDragStart)}this._offMoveEvents();this._offUpEvents();if(He){Ue(document.body,"user-select","")}Ue(xt,"transform","");if(t){if(Ut){t.cancelable&&t.preventDefault();!o.dropBubble&&t.stopPropagation()}yt&&yt.parentNode&&yt.parentNode.removeChild(yt);if(kt===wt||Dt&&Dt.lastPutMode!=="clone"){qt&&qt.parentNode&&qt.parentNode.removeChild(qt)}if(xt){if(this.nativeDraggable){_e(xt,"dragend",this)}pi(xt);xt.style["will-change"]="";if(Ut&&!Zt){je(xt,Dt?Dt.options.ghostClass:this.options.ghostClass,false)}je(xt,this.options.chosenClass,false);bt({sortable:this,name:"unchoose",toEl:wt,newIndex:null,newDraggableIndex:null,originalEvent:t});if(kt!==wt){if(Tt>=0){bt({rootEl:wt,name:"add",toEl:wt,fromEl:kt,originalEvent:t});bt({sortable:this,name:"remove",toEl:wt,originalEvent:t});bt({rootEl:wt,name:"sort",toEl:wt,fromEl:kt,originalEvent:t});bt({sortable:this,name:"sort",toEl:wt,originalEvent:t})}Dt&&Dt.save()}else{if(Tt!==Mt){if(Tt>=0){bt({sortable:this,name:"update",toEl:wt,originalEvent:t});bt({sortable:this,name:"sort",toEl:wt,originalEvent:t})}}}if(hi.active){if(Tt==null||Tt===-1){Tt=Mt;Lt=It}bt({sortable:this,name:"end",toEl:wt,originalEvent:t});this.save()}}}this._nulling()},_nulling:function e(){gt("nulling",this);kt=xt=wt=yt=Et=qt=St=Ct=_t=Nt=Ut=Tt=Lt=Mt=It=Bt=Pt=Dt=Ht=hi.dragged=hi.ghost=hi.clone=hi.active=null;Xt.forEach((function(e){e.checked=true}));Xt.length=Vt=Rt=0},handleEvent:function e(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":if(xt){this._onDragOver(t);ui(t)}break;case"selectstart":t.preventDefault();break}},toArray:function e(){var t=[],i,o=this.el.children,s=0,n=o.length,l=this.options;for(;s<n;s++){i=o[s];if(Re(i,l.draggable,this.el,false)){t.push(i.getAttribute(l.dataIdAttr)||wi(i))}}return t},sort:function e(t,i){var o={},s=this.el;this.toArray().forEach((function(e,t){var i=s.children[t];if(Re(i,this.options.draggable,s,false)){o[e]=i}}),this);i&&this.captureAnimationState();t.forEach((function(e){if(o[e]){s.removeChild(o[e]);s.appendChild(o[e])}}));i&&this.animateAll()},save:function e(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function e(t,i){return Re(t,i||this.options.draggable,this.el,false)},option:function e(t,i){var o=this.options;if(i===void 0){return o[t]}else{var s=pt.modifyOption(this,t,i);if(typeof s!=="undefined"){o[t]=s}else{o[t]=i}if(t==="group"){li(o)}}},destroy:function e(){gt("destroy",this);var t=this.el;t[at]=null;_e(t,"mousedown",this._onTapStart);_e(t,"touchstart",this._onTapStart);_e(t,"pointerdown",this._onTapStart);if(this.nativeDraggable){_e(t,"dragover",this);_e(t,"dragenter",this)}Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),(function(e){e.removeAttribute("draggable")}));this._onDrop();this._disableDelayedDragEvents();Ot.splice(Ot.indexOf(this.el),1);this.el=t=null},_hideClone:function e(){if(!Ct){gt("hideClone",this);if(hi.eventCanceled)return;Ue(qt,"display","none");if(this.options.removeCloneOnHide&&qt.parentNode){qt.parentNode.removeChild(qt)}Ct=true}},_showClone:function e(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(Ct){gt("showClone",this);if(hi.eventCanceled)return;if(xt.parentNode==kt&&!this.options.group.revertClone){kt.insertBefore(qt,xt)}else if(Et){kt.insertBefore(qt,Et)}else{kt.appendChild(qt)}if(this.options.group.revertClone){this.animate(xt,qt)}Ue(qt,"display","");Ct=false}}};function ui(e){if(e.dataTransfer){e.dataTransfer.dropEffect="move"}e.cancelable&&e.preventDefault()}function fi(e,t,i,o,s,n,l,r){var a,d=e[at],c=d.options.onMove,h;if(window.CustomEvent&&!Te&&!Ie){a=new CustomEvent("move",{bubbles:true,cancelable:true})}else{a=document.createEvent("Event");a.initEvent("move",true,true)}a.to=t;a.from=e;a.dragged=i;a.draggedRect=o;a.related=s||t;a.relatedRect=n||Qe(t);a.willInsertAfter=r;a.originalEvent=l;e.dispatchEvent(a);if(c){h=c.call(d,a,l)}return h}function pi(e){e.draggable=false}function vi(){Jt=false}function mi(e,t,i){var o=Qe(We(i.el,0,i.options,true));var s=rt(i.el,i.options,yt);var n=10;return t?e.clientX<s.left-n||e.clientY<o.top&&e.clientX<o.right:e.clientY<s.top-n||e.clientY<o.bottom&&e.clientX<o.left}function gi(e,t,i){var o=Qe(Ye(i.el,i.options.draggable));var s=rt(i.el,i.options,yt);var n=10;return t?e.clientX>s.right+n||e.clientY>o.bottom&&e.clientX>o.left:e.clientY>s.bottom+n||e.clientX>o.right&&e.clientY>o.top}function bi(e,t,i,o,s,n,l,r){var a=o?e.clientY:e.clientX,d=o?i.height:i.width,c=o?i.top:i.left,h=o?i.bottom:i.right,u=false;if(!l){if(r&&Ft<d*s){if(!$t&&(Pt===1?a>c+d*n/2:a<h-d*n/2)){$t=true}if(!$t){if(Pt===1?a<c+Ft:a>h-Ft){return-Pt}}else{u=true}}else{if(a>c+d*(1-s)/2&&a<h-d*(1-s)/2){return xi(t)}}}u=u||l;if(u){if(a<c+d*n/2||a>h-d*n/2){return a>c+d/2?1:-1}}return 0}function xi(e){if(Je(xt)<Je(e)){return 1}else{return-1}}function wi(e){var t=e.tagName+e.className+e.src+e.href+e.textContent,i=t.length,o=0;while(i--){o+=t.charCodeAt(i)}return o.toString(36)}function yi(e){Xt.length=0;var t=e.getElementsByTagName("input");var i=t.length;while(i--){var o=t[i];o.checked&&Xt.push(o)}}function ki(e){return setTimeout(e,0)}function Ei(e){return clearTimeout(e)}if(Gt){Oe(document,"touchmove",(function(e){if((hi.active||Zt)&&e.cancelable){e.preventDefault()}}))}hi.utils={on:Oe,off:_e,css:Ue,find:Pe,is:function e(t,i){return!!Re(t,i,t,false)},extend:et,throttle:ot,closest:Re,toggleClass:je,clone:lt,index:Je,nextTick:ki,cancelNextTick:Ei,detectDirection:oi,getChild:We,expando:at};hi.get=function(e){return e[at]};hi.mount=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++){t[i]=arguments[i]}if(t[0].constructor===Array)t=t[0];t.forEach((function(e){if(!e.prototype||!e.prototype.constructor){throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(e))}if(e.utils)hi.utils=we(we({},hi.utils),e.utils);pt.mount(e)}))};hi.create=function(e,t){return new hi(e,t)};hi.version=Ce;var Si=[],qi,Ci,Mi=false,Ti,Ii,Li,Hi;function Di(){function e(){this.defaults={scroll:true,forceAutoScrollFallback:false,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:true};for(var e in this){if(e.charAt(0)==="_"&&typeof this[e]==="function"){this[e]=this[e].bind(this)}}}e.prototype={dragStarted:function e(t){var i=t.originalEvent;if(this.sortable.nativeDraggable){Oe(document,"dragover",this._handleAutoScroll)}else{if(this.options.supportPointer){Oe(document,"pointermove",this._handleFallbackAutoScroll)}else if(i.touches){Oe(document,"touchmove",this._handleFallbackAutoScroll)}else{Oe(document,"mousemove",this._handleFallbackAutoScroll)}}},dragOverCompleted:function e(t){var i=t.originalEvent;if(!this.options.dragOverBubble&&!i.rootEl){this._handleAutoScroll(i)}},drop:function e(){if(this.sortable.nativeDraggable){_e(document,"dragover",this._handleAutoScroll)}else{_e(document,"pointermove",this._handleFallbackAutoScroll);_e(document,"touchmove",this._handleFallbackAutoScroll);_e(document,"mousemove",this._handleFallbackAutoScroll)}zi();Zi();st()},nulling:function e(){Li=Ci=qi=Mi=Hi=Ti=Ii=null;Si.length=0},_handleFallbackAutoScroll:function e(t){this._handleAutoScroll(t,true)},_handleAutoScroll:function e(t,i){var o=this;var s=(t.touches?t.touches[0]:t).clientX,n=(t.touches?t.touches[0]:t).clientY,l=document.elementFromPoint(s,n);Li=t;if(i||this.options.forceAutoScrollFallback||Ie||Te||He){Oi(t,this.options,l,i);var r=Ke(l,true);if(Mi&&(!Hi||s!==Ti||n!==Ii)){Hi&&zi();Hi=setInterval((function(){var e=Ke(document.elementFromPoint(s,n),true);if(e!==r){r=e;Zi()}Oi(t,o.options,e,i)}),10);Ti=s;Ii=n}}else{if(!this.options.bubbleScroll||Ke(l,true)===$e()){Zi();return}Oi(t,this.options,Ke(l,false),false)}}};return Ee(e,{pluginName:"scroll",initializeByDefault:true})}function Zi(){Si.forEach((function(e){clearInterval(e.pid)}));Si=[]}function zi(){clearInterval(Hi)}var Oi=ot((function(e,t,i,o){if(!t.scroll)return;var s=(e.touches?e.touches[0]:e).clientX,n=(e.touches?e.touches[0]:e).clientY,l=t.scrollSensitivity,r=t.scrollSpeed,a=$e();var d=false,c;if(Ci!==i){Ci=i;Zi();qi=t.scroll;c=t.scrollFn;if(qi===true){qi=Ke(i,true)}}var h=0;var u=qi;do{var f=u,p=Qe(f),v=p.top,m=p.bottom,g=p.left,b=p.right,x=p.width,w=p.height,y=void 0,k=void 0,E=f.scrollWidth,S=f.scrollHeight,q=Ue(f),C=f.scrollLeft,M=f.scrollTop;if(f===a){y=x<E&&(q.overflowX==="auto"||q.overflowX==="scroll"||q.overflowX==="visible");k=w<S&&(q.overflowY==="auto"||q.overflowY==="scroll"||q.overflowY==="visible")}else{y=x<E&&(q.overflowX==="auto"||q.overflowX==="scroll");k=w<S&&(q.overflowY==="auto"||q.overflowY==="scroll")}var T=y&&(Math.abs(b-s)<=l&&C+x<E)-(Math.abs(g-s)<=l&&!!C);var I=k&&(Math.abs(m-n)<=l&&M+w<S)-(Math.abs(v-n)<=l&&!!M);if(!Si[h]){for(var L=0;L<=h;L++){if(!Si[L]){Si[L]={}}}}if(Si[h].vx!=T||Si[h].vy!=I||Si[h].el!==f){Si[h].el=f;Si[h].vx=T;Si[h].vy=I;clearInterval(Si[h].pid);if(T!=0||I!=0){d=true;Si[h].pid=setInterval(function(){if(o&&this.layer===0){hi.active._onTouchMove(Li)}var t=Si[this.layer].vy?Si[this.layer].vy*r:0;var i=Si[this.layer].vx?Si[this.layer].vx*r:0;if(typeof c==="function"){if(c.call(hi.dragged.parentNode[at],i,t,e,Li,Si[this.layer].el)!=="continue"){return}}nt(Si[this.layer].el,i,t)}.bind({layer:h}),24)}}h++}while(t.bubbleScroll&&u!==a&&(u=Ke(u,false)));Mi=d}),30);var _i=function e(t){var i=t.originalEvent,o=t.putSortable,s=t.dragEl,n=t.activeSortable,l=t.dispatchSortableEvent,r=t.hideGhostForTarget,a=t.unhideGhostForTarget;if(!i)return;var d=o||n;r();var c=i.changedTouches&&i.changedTouches.length?i.changedTouches[0]:i;var h=document.elementFromPoint(c.clientX,c.clientY);a();if(d&&!d.el.contains(h)){l("spill");this.onSpill({dragEl:s,putSortable:o})}};function Ni(){}Ni.prototype={startIndex:null,dragStart:function e(t){var i=t.oldDraggableIndex;this.startIndex=i},onSpill:function e(t){var i=t.dragEl,o=t.putSortable;this.sortable.captureAnimationState();if(o){o.captureAnimationState()}var s=We(this.sortable.el,this.startIndex,this.options);if(s){this.sortable.el.insertBefore(i,s)}else{this.sortable.el.appendChild(i)}this.sortable.animateAll();if(o){o.animateAll()}},drop:_i};Ee(Ni,{pluginName:"revertOnSpill"});function Vi(){}Vi.prototype={onSpill:function e(t){var i=t.dragEl,o=t.putSortable;var s=o||this.sortable;s.captureAnimationState();i.parentNode&&i.parentNode.removeChild(i);s.animateAll()},drop:_i};Ee(Vi,{pluginName:"removeOnSpill"});hi.mount(new Di);hi.mount(Vi,Ni);const Ri='@-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;max-width:600px;font-family:"Inter", -apple-system, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif}verdocs-template-roles .roles{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:10px;margin-top:10px}verdocs-template-roles .roles .sequence{gap:10px;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;font-weight:500;padding:0 0 8px 0;-ms-flex-direction:row;flex-direction:row;border-bottom:1px dotted #e3e3e3}verdocs-template-roles .roles .sequence.add-sequence{color:#777777;line-height:34px}verdocs-template-roles .roles .sequence-label{font-size:18px;line-height:32px}verdocs-template-roles .roles .sequence-roles{gap:10px;display:-ms-flexbox;display:flex;position:relative;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-direction:row;flex-direction:row}verdocs-template-roles .roles .role{height:32px;cursor:move;display:-ms-flexbox;display:flex;max-width:200px;position:relative;border-radius:32px;background-color:#eff7fb;-webkit-box-sizing:border-box;box-sizing:border-box;padding:0 14px 0 34px;border:1px solid #ccc;-ms-flex-direction:column;flex-direction:column}verdocs-template-roles .roles .role .role-name{font-size:14px;overflow:hidden;font-weight:400;line-height:30px;white-space:nowrap;text-overflow:ellipsis}verdocs-template-roles .roles .role .icons{position:absolute;left:1px;top:-3px;cursor:pointer;padding:5px;z-index:10}verdocs-template-roles .roles .role .icons .gear-button{display:none;-webkit-transform:scale(1.1);transform:scale(1.1);margin:4px 0 0 1px}verdocs-template-roles .roles .role .icons .type-icon{opacity:0.6;display:block;-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-roles .roles .role .icons:hover .gear-button{display:block}verdocs-template-roles .roles .role .icons:hover .type-icon{display:none}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 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{opacity:0.3;padding:0 10px;cursor:pointer;background:none;height:32px;border:1px solid #cccccc;border-radius:32px}verdocs-template-roles .add-role:hover{opacity:1}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 .row.add-sequence{display:-ms-flexbox;display:flex}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 .sequence-roles{display:-ms-flexbox;display:flex;max-width:400px}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}';const Ai=Ri;const ji='<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>';const Ui=`<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>`;const Bi='<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>';const Pi=`<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><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>`;const $i=`<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><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>`;const Qi=class{constructor(i){e(this,i);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.sortableRefs=[];this.endpoint=l.getDefault();this.templateId="";this.showingRoleDialog=null;this.sender=null;this.dragging=false;this.loading=true;this.template=null}disconnectedCallback(){this.unlistenToTemplate();this.cleanupSortables()}async listenToTemplate(){console.log("[ROLES] Loading template",this.templateId);this.unlistenToTemplate();y.subscribe("templates",this.templateId,(()=>r(this.endpoint,this.templateId)),false,(e=>{console.log("[ROLES] Template Updated",e);this.template=e;this.loading=false}))}unlistenToTemplate(){if(this.templateListenerId){y.store.delListener(this.templateListenerId);this.templateListenerId=null}}async componentWillLoad(){var e,t,i;try{this.endpoint.loadSession();if(!this.templateId){console.log(`[ROLES] Missing required template ID ${this.templateId}`);return}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return}this.listenToTemplate()}catch(o){console.log("[ROLES] Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new w(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(i=o.response)===null||i===void 0?void 0:i.data))}}cleanupSortables(){this.sortableRefs.forEach((e=>e.destroy()));this.sortableRefs.length=0}componentDidRender(){this.cleanupSortables();const e=this.getSequenceNumbers();(e||[]).forEach((e=>{const t=document.getElementById(`verdocs-roles-sequence-${e}`);if(t){const e=new hi(t,{group:"roles",animation:150,dragoverBubble:true,filter:".no-drag",onEnd:this.handleMoveEnd.bind(this),onChoose:()=>this.dragging=true,onUnchoose:()=>this.dragging=false});this.sortableRefs.push(e)}}));const t=document.getElementById(`verdocs-roles-sequence-add-target`);if(t){console.log("[ROLES] Applying sortable to add-sequence slot");const e=new hi(t,{group:"roles",animation:150,dragoverBubble:true,filter:".no-drag",onEnd:this.handleMoveEnd.bind(this),onChoose:()=>this.dragging=true,onUnchoose:()=>this.dragging=false});this.sortableRefs.push(e)}}handleMoveEnd(e){const t=+e.from.dataset.sequence;const i=+e.to.dataset.sequence;const o=+e.oldIndex+1;const s=+e.newIndex+1;console.log(`Move from ${t}:${o} to ${i}:${s}`,e.item);const n={};const l=this.getSequenceNumbers();l.forEach((e=>{const t=this.getRolesAtSequence(e);n[String(e)]=JSON.parse(JSON.stringify(t))}));n[l[l.length-1]+1]=[];const r=n[t].splice(o-1,1)[0];n[i]||(n[i]=[]);n[i].splice(s-1,0,r);const a=[];Object.entries(n).forEach((([e,t])=>{t.forEach(((t,i)=>{if(!t){return}const o=+i+1;if(t.sequence!==+e||t.order!==o){t.sequence=+e;t.order=o;a.push(b(this.endpoint,this.templateId,t.name,{sequence:+e,order:o}).then((e=>console.log("[ROLES] Updated role",t.name,e))).catch((e=>console.log("[ROLES] Error updating role",e))))}}))}));return Promise.all(a).then((async()=>console.log("[ROLES] Done renumbering"))).catch((e=>console.log("[ROLES] Error updating roles",e)))}handleCancel(){var e;(e=this.exit)===null||e===void 0?void 0:e.emit()}handleSubmit(){var e;(e=this.next)===null||e===void 0?void 0:e.emit()}getSortedRoles(){var e;return(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).sort(((e,t)=>e.sequence===t.sequence?e.order-t.order:e.sequence-t.sequence))}getSequenceNumbers(){const e={};this.getSortedRoles().forEach((t=>{e[t.sequence]=true}));console.log("[ROLES] Sequences",e);return Object.keys(e).map((e=>+e)).sort(((e,t)=>e-t))}getRoleNames(){const e=this.getSortedRoles();return e.map((e=>e.name))}getRolesAtSequence(e){var t;return(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((t=>t&&t.sequence===e))}async renumberTemplateRoles(){var e;const t={};const i=[];const o=this.getSequenceNumbers();(o||[]).forEach((e=>{(t[e]||[]).forEach(((t,o)=>{const s=+o+1;if(t.sequence!==+e||t.order!==s){console.log("[ROLES] Updating role",t.name,"from",t.sequence,t.order,"to",e,s);t.sequence=+e;t.order=s;i.push(b(this.endpoint,this.templateId,t.name,{sequence:+e,order:s}).then((e=>console.log("[ROLES] Updated role",t.name,e))).catch((e=>console.log("[ROLES] Error updating role",e))))}}))}));console.log(`[ROLES] Awaiting ${i.length} renumber requests`);await Promise.all(i).then((async()=>{const e=JSON.parse(JSON.stringify(this.template));e.roles=Object.keys(t).reduce(((e,i)=>e.concat(t[i])),[]);console.log("[ROLES] Done renumbering",e.roles.map((e=>({name:e.name,sequence:e.sequence,order:e.order}))));y.updateTemplate(this.templateId,e)}));(e=this.rolesUpdated)===null||e===void 0?void 0:e.emit({event:"updated",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()})}getNextRoleName(){var e,t;let i="";let o=(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).length;do{o++;i=`Recipient ${o}`}while(!i||(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).some((e=>e&&e.name===i)));return i}callCreateRole(e,t,i){console.log("[ROLES] Will create role",{name:e,sequence:t,order:i});x(this.endpoint,this.templateId,{template_id:this.templateId,name:e,sequence:t,message:"",order:i,full_name:null,first_name:"",last_name:"",email:"",phone:"",type:"signer",delegator:false,kba_method:null}).then((async e=>{var t;console.log("[ROLES] Created role",e);console.log("Updating template in data store");await y.getTemplate(this.endpoint,this.templateId,true);(t=this.rolesUpdated)===null||t===void 0?void 0: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 i=this.getRolesAtSequence(t).length+1;const o=this.getNextRoleName();this.callCreateRole(o,t,i)}handleAddStep(e,t){e.stopPropagation();const i=1;const o=this.getNextRoleName();this.callCreateRole(o,t,i)}render(){if(!this.endpoint.session){return i(o,null,i("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading||!this.template){return i(o,{class:"loading"},i("verdocs-loader",null))}const e=this.getRoleNames();const t=this.getSequenceNumbers();const s=t&&t.length>0?(t[t.length-1]||0)+1:1;console.log("[ROLES] Rendering",{roleNames:e,sequences:t,nextSequence:s});return i(o,{class:{dragging:this.dragging}},i("form",{onSubmit:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),autocomplete:"off"},i("h5",null,"Roles and Workflow"),i("div",{class:"roles"},t.map(((e,t)=>i("div",{class:"sequence"},i("div",{class:"sequence-label no-drag"},t+1,"."),i("div",{class:"sequence-roles",id:`verdocs-roles-sequence-${e}`,"data-sequence":e},this.getRolesAtSequence(e).map((t=>{const o=!t.email||!t.first_name||!t.last_name;return o?i("div",{class:"role","data-rolename":t.name,"data-sequence":e,"data-order":t.order},i("div",{class:"role-name"},t.name),i("div",{class:"icons"},i("div",{class:"gear-button",innerHTML:ji,onClick:()=>this.showingRoleDialog=t.name,"aria-role":"button"}),i("span",{class:"type-icon",innerHTML:t.type==="signer"?Bi:t.type==="cc"?$i:Pi}))):i("div",{class:"role","data-rolename":t.name,"data-sequence":e,"data-order":t.order},i("div",{class:"role-name"},u(t)),i("div",{class:"icons"},i("div",{class:"gear-button",innerHTML:ji,onClick:()=>this.showingRoleDialog=t.name,"aria-role":"button"}),i("span",{class:"type-icon",innerHTML:t.type==="signer"?Bi:t.type==="cc"?$i:Pi})))}))),i("button",{class:"add-role no-drag",onClick:t=>this.handleAddRole(t,e)},"+ Add Role")))),i("div",{class:"sequence add-sequence"},i("div",{class:"sequence-label no-drag"},t.length+1,"."),i("div",{class:"sequence-roles",id:`verdocs-roles-sequence-add-target`,"data-sequence":s}),i("button",{class:"add-role no-drag",onClick:e=>this.handleAddRole(e,s)},"+ Add Role"))),e.length<1&&i("div",{class:"empty"},"You must add at least one Role before proceeding.",i("br",null)," Click the ",i("span",{innerHTML:Ui})," Add button above to get started."),i("div",{class:"buttons"},i("div",{class:"flex-fill"}),i("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:()=>this.handleCancel()}),i("verdocs-button",{label:"OK",size:"small",onClick:()=>this.handleSubmit(),disabled:e.length<1}))),this.showingRoleDialog&&i("verdocs-menu-panel",{onClose:()=>this.showingRoleDialog=null},i("verdocs-template-role-properties",{endpoint:this.endpoint,templateId:this.templateId,roleName:this.showingRoleDialog,onClose:()=>{var e;(e=document.getElementById("verdocs-menu-panel-overlay"))===null||e===void 0?void 0:e.remove();this.showingRoleDialog=null},onDelete:async()=>{var e;this.showingRoleDialog=null;await this.renumberTemplateRoles();(e=this.rolesUpdated)===null||e===void 0?void 0:e.emit({event:"deleted",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()})}})))}get el(){return n(this)}};Qi.style=Ai;export{A as verdocs_preview,Y as verdocs_send,G as verdocs_template_attachments,se as verdocs_template_build_tabs,be as verdocs_template_fields,Qi as verdocs_template_roles};
8
- //# sourceMappingURL=p-6369fc93.entry.js.map
8
+ //# sourceMappingURL=p-e5470d18.entry.js.map