@verdocs/web-sdk 6.5.0-beta.32 → 6.5.0-beta.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/dist/cjs/{Types-RUyU-svM.js → Types-YJQtg77a.js} +4 -3
  2. package/dist/{esm/Types-dqxNbm_b.js.map → cjs/Types-YJQtg77a.js.map} +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{utils-otZIKCGM.js → utils-DjHWIYcY.js} +3 -3
  5. package/dist/cjs/{utils-otZIKCGM.js.map → utils-DjHWIYcY.js.map} +1 -1
  6. package/dist/cjs/verdocs-adopt-signature-dialog_8.cjs.entry.js +2 -2
  7. package/dist/cjs/verdocs-contact-picker.cjs.entry.js +2 -2
  8. package/dist/cjs/verdocs-download-dialog_4.cjs.entry.js +2 -2
  9. package/dist/cjs/verdocs-envelope-sidebar.cjs.entry.js +1 -1
  10. package/dist/cjs/verdocs-envelopes-list.cjs.entry.js +2 -2
  11. package/dist/cjs/verdocs-field-attachment_11.cjs.entry.js +86 -12
  12. package/dist/cjs/verdocs-pagination_2.cjs.entry.js +2 -2
  13. package/dist/cjs/verdocs-preview.verdocs-send.verdocs-template-attachments.verdocs-template-build-tabs.verdocs-template-fields.verdocs-template-roles.verdocs-template-settings.entry.cjs.js.map +1 -1
  14. package/dist/cjs/verdocs-preview_7.cjs.entry.js +36 -25
  15. package/dist/cjs/verdocs-sign.cjs.entry.js +2 -2
  16. package/dist/cjs/verdocs-template-document-page.verdocs-toolbar-icon.entry.cjs.js.map +1 -1
  17. package/dist/cjs/verdocs-template-document-page_2.cjs.entry.js +2 -2
  18. package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
  19. package/dist/collection/components/embeds/verdocs-send/verdocs-send.css +8 -0
  20. package/dist/collection/components/embeds/verdocs-send/verdocs-send.js +3 -1
  21. package/dist/collection/components/embeds/verdocs-send/verdocs-send.js.map +1 -1
  22. package/dist/collection/components/fields/verdocs-field-date/verdocs-field-date.css +34 -0
  23. package/dist/collection/components/fields/verdocs-field-date/verdocs-field-date.js +77 -2
  24. package/dist/collection/components/fields/verdocs-field-date/verdocs-field-date.js.map +1 -1
  25. package/dist/collection/components/fields/verdocs-field-textbox/verdocs-field-textbox.css +3 -0
  26. package/dist/collection/components/fields/verdocs-field-textbox/verdocs-field-textbox.js +6 -5
  27. package/dist/collection/components/fields/verdocs-field-textbox/verdocs-field-textbox.js.map +1 -1
  28. package/dist/collection/components/templates/verdocs-template-document-page/verdocs-template-document-page.js +3 -3
  29. package/dist/collection/components/templates/verdocs-template-document-page/verdocs-template-document-page.js.map +1 -1
  30. package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.css +21 -0
  31. package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js +31 -21
  32. package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js.map +1 -1
  33. package/dist/collection/utils/Types.js +2 -1
  34. package/dist/collection/utils/Types.js.map +1 -1
  35. package/dist/components/{p-DLKz8oGD.js → p-1PWpeHpK.js} +3 -3
  36. package/dist/components/{p-DLKz8oGD.js.map → p-1PWpeHpK.js.map} +1 -1
  37. package/dist/components/{p-BSXsWUmY.js → p-BWvUv89M.js} +39 -29
  38. package/dist/components/p-BWvUv89M.js.map +1 -0
  39. package/dist/components/{p-CrKrBZZL.js → p-BcGvNPBh.js} +7 -7
  40. package/dist/components/{p-CrKrBZZL.js.map → p-BcGvNPBh.js.map} +1 -1
  41. package/dist/components/{p-YzC4BSrh.js → p-BttIJYW3.js} +7 -5
  42. package/dist/components/p-BttIJYW3.js.map +1 -0
  43. package/dist/components/{p-88SuPfj4.js → p-C35_YsQk.js} +3 -3
  44. package/dist/components/{p-88SuPfj4.js.map → p-C35_YsQk.js.map} +1 -1
  45. package/dist/components/{p-COtqu2dZ.js → p-CMNmfu0F.js} +3 -3
  46. package/dist/components/{p-COtqu2dZ.js.map → p-CMNmfu0F.js.map} +1 -1
  47. package/dist/components/{p-B7nY_WEM.js → p-CY-c2d8q.js} +9 -9
  48. package/dist/components/p-CY-c2d8q.js.map +1 -0
  49. package/dist/components/{p-DWZamcQd.js → p-CeHrzafI.js} +9 -8
  50. package/dist/components/p-CeHrzafI.js.map +1 -0
  51. package/dist/components/{p-BaFfUg65.js → p-DKO4_Yp9.js} +3 -3
  52. package/dist/components/{p-BaFfUg65.js.map → p-DKO4_Yp9.js.map} +1 -1
  53. package/dist/components/{p-Dl7Xw8F0.js → p-DMMF9yT2.js} +3 -3
  54. package/dist/components/{p-Dl7Xw8F0.js.map → p-DMMF9yT2.js.map} +1 -1
  55. package/dist/components/p-Dh9AjNdu.js +292 -0
  56. package/dist/components/p-Dh9AjNdu.js.map +1 -0
  57. package/dist/components/{p-IUjGbyAi.js → p-Dk8BEvRP.js} +3 -3
  58. package/dist/components/{p-IUjGbyAi.js.map → p-Dk8BEvRP.js.map} +1 -1
  59. package/dist/components/{p-ChDalz5Z.js → p-DyeSZpGe.js} +3 -3
  60. package/dist/components/{p-ChDalz5Z.js.map → p-DyeSZpGe.js.map} +1 -1
  61. package/dist/components/{p-Bu_0SDFO.js → p-Iv65sQlJ.js} +3 -3
  62. package/dist/components/{p-Bu_0SDFO.js.map → p-Iv65sQlJ.js.map} +1 -1
  63. package/dist/components/verdocs-build.js +8 -8
  64. package/dist/components/verdocs-contact-picker.js +1 -1
  65. package/dist/components/verdocs-envelope-document-page.js +1 -1
  66. package/dist/components/verdocs-envelope-sidebar.js +1 -1
  67. package/dist/components/verdocs-envelopes-list.js +2 -2
  68. package/dist/components/verdocs-field-date.js +1 -1
  69. package/dist/components/verdocs-field-textbox.js +1 -1
  70. package/dist/components/verdocs-field-timestamp.js +1 -1
  71. package/dist/components/verdocs-preview.js +1 -1
  72. package/dist/components/verdocs-quick-filter.js +1 -1
  73. package/dist/components/verdocs-send.js +1 -1
  74. package/dist/components/verdocs-sign.js +4 -4
  75. package/dist/components/verdocs-signing-progress.js +1 -1
  76. package/dist/components/verdocs-template-document-page.js +1 -1
  77. package/dist/components/verdocs-template-fields.js +1 -1
  78. package/dist/components/verdocs-templates-list.js +1 -1
  79. package/dist/components/verdocs-view.js +1 -1
  80. package/dist/esm/Types-BqoC0yeA.js +9 -0
  81. package/dist/{cjs/Types-RUyU-svM.js.map → esm/Types-BqoC0yeA.js.map} +1 -1
  82. package/dist/esm/loader.js +1 -1
  83. package/dist/esm/{utils-ivPfUH2E.js → utils-Deu82Q9L.js} +3 -3
  84. package/dist/esm/{utils-ivPfUH2E.js.map → utils-Deu82Q9L.js.map} +1 -1
  85. package/dist/esm/verdocs-adopt-signature-dialog_8.entry.js +2 -2
  86. package/dist/esm/verdocs-contact-picker.entry.js +2 -2
  87. package/dist/esm/verdocs-download-dialog_4.entry.js +2 -2
  88. package/dist/esm/verdocs-envelope-sidebar.entry.js +1 -1
  89. package/dist/esm/verdocs-envelopes-list.entry.js +2 -2
  90. package/dist/esm/verdocs-field-attachment_11.entry.js +86 -12
  91. package/dist/esm/verdocs-pagination_2.entry.js +2 -2
  92. package/dist/esm/verdocs-preview.verdocs-send.verdocs-template-attachments.verdocs-template-build-tabs.verdocs-template-fields.verdocs-template-roles.verdocs-template-settings.entry.js.map +1 -1
  93. package/dist/esm/verdocs-preview_7.entry.js +37 -26
  94. package/dist/esm/verdocs-sign.entry.js +2 -2
  95. package/dist/esm/verdocs-template-document-page.verdocs-toolbar-icon.entry.js.map +1 -1
  96. package/dist/esm/verdocs-template-document-page_2.entry.js +2 -2
  97. package/dist/esm/verdocs-web-sdk.js +1 -1
  98. package/dist/esm-es5/Types-BqoC0yeA.js +2 -0
  99. package/dist/esm-es5/{Types-dqxNbm_b.js.map → Types-BqoC0yeA.js.map} +1 -1
  100. package/dist/esm-es5/loader.js +1 -1
  101. package/dist/esm-es5/{utils-ivPfUH2E.js → utils-Deu82Q9L.js} +2 -2
  102. package/dist/esm-es5/{utils-ivPfUH2E.js.map → utils-Deu82Q9L.js.map} +1 -1
  103. package/dist/esm-es5/verdocs-adopt-signature-dialog_8.entry.js +1 -1
  104. package/dist/esm-es5/verdocs-contact-picker.entry.js +2 -2
  105. package/dist/esm-es5/verdocs-download-dialog_4.entry.js +1 -1
  106. package/dist/esm-es5/verdocs-envelope-sidebar.entry.js +1 -1
  107. package/dist/esm-es5/verdocs-envelopes-list.entry.js +1 -1
  108. package/dist/esm-es5/verdocs-field-attachment_11.entry.js +1 -1
  109. package/dist/esm-es5/verdocs-field-attachment_11.entry.js.map +1 -1
  110. package/dist/esm-es5/verdocs-pagination_2.entry.js +1 -1
  111. package/dist/esm-es5/verdocs-preview.verdocs-send.verdocs-template-attachments.verdocs-template-build-tabs.verdocs-template-fields.verdocs-template-roles.verdocs-template-settings.entry.js.map +1 -1
  112. package/dist/esm-es5/verdocs-preview_7.entry.js +2 -2
  113. package/dist/esm-es5/verdocs-preview_7.entry.js.map +1 -1
  114. package/dist/esm-es5/verdocs-sign.entry.js +1 -1
  115. package/dist/esm-es5/verdocs-template-document-page.verdocs-toolbar-icon.entry.js.map +1 -1
  116. package/dist/esm-es5/verdocs-template-document-page_2.entry.js +1 -1
  117. package/dist/esm-es5/verdocs-web-sdk.js +1 -1
  118. package/dist/types/components/fields/verdocs-field-date/verdocs-field-date.d.ts +6 -1
  119. package/dist/types/components/templates/verdocs-template-fields/verdocs-template-fields.d.ts +3 -3
  120. package/dist/types/utils/Types.d.ts +1 -1
  121. package/dist/verdocs-web-sdk/{p-751501f3.entry.js → p-07a00b97.entry.js} +2 -2
  122. package/dist/verdocs-web-sdk/{p-96c50a15.system.entry.js → p-16e4f438.system.entry.js} +2 -2
  123. package/dist/verdocs-web-sdk/{p-b7a88f34.system.entry.js → p-178d03a6.system.entry.js} +2 -2
  124. package/dist/verdocs-web-sdk/p-1bde2f57.system.entry.js +2 -0
  125. package/dist/verdocs-web-sdk/p-1bde2f57.system.entry.js.map +1 -0
  126. package/dist/verdocs-web-sdk/{p-3c1ca466.entry.js → p-3aebfd86.entry.js} +2 -2
  127. package/dist/verdocs-web-sdk/{p-12a23bdb.entry.js → p-4671fd0b.entry.js} +2 -2
  128. package/dist/verdocs-web-sdk/{p-f615bed5.entry.js → p-5cf0d300.entry.js} +2 -2
  129. package/dist/verdocs-web-sdk/{p-7165eccc.system.entry.js → p-8cb631da.system.entry.js} +2 -2
  130. package/dist/verdocs-web-sdk/p-932934f5.system.entry.js +8 -0
  131. package/dist/verdocs-web-sdk/p-932934f5.system.entry.js.map +1 -0
  132. package/dist/verdocs-web-sdk/{p-cff62722.system.entry.js → p-9ec65cad.system.entry.js} +2 -2
  133. package/dist/verdocs-web-sdk/p-B8zpaHu-.system.js +1 -1
  134. package/dist/verdocs-web-sdk/p-B_NM_Ddi.system.js.map +1 -0
  135. package/dist/verdocs-web-sdk/{p-dY2Fe8ON.system.js.map → p-BaVMqmM6.system.js.map} +1 -1
  136. package/dist/verdocs-web-sdk/{p-D0t6QCh_.system.js → p-BgKRsvh1.system.js} +2 -2
  137. package/dist/verdocs-web-sdk/{p-D0t6QCh_.system.js.map → p-BgKRsvh1.system.js.map} +1 -1
  138. package/dist/verdocs-web-sdk/p-BqoC0yeA.js +2 -0
  139. package/dist/verdocs-web-sdk/{p-dqxNbm_b.js.map → p-BqoC0yeA.js.map} +1 -1
  140. package/dist/verdocs-web-sdk/p-BxZoitZ8.system.js.map +1 -0
  141. package/dist/verdocs-web-sdk/p-C2OP3llY.system.js +2 -0
  142. package/dist/verdocs-web-sdk/{p-CgZsFvRv.system.js.map → p-C2OP3llY.system.js.map} +1 -1
  143. package/dist/verdocs-web-sdk/{p-Baa2Y5Zk.system.js.map → p-C5FCNerT.system.js.map} +1 -1
  144. package/dist/verdocs-web-sdk/{p-DKu4yKnD.system.js.map → p-CwV2z4y9.system.js.map} +1 -1
  145. package/dist/verdocs-web-sdk/{p-BM3jxk1D.system.js.map → p-DAagWDJf.system.js.map} +1 -1
  146. package/dist/verdocs-web-sdk/p-DDdzKvq8.system.js.map +1 -0
  147. package/dist/verdocs-web-sdk/{p-BUDKtx9r.system.js.map → p-DZCgLJyz.system.js.map} +1 -1
  148. package/dist/verdocs-web-sdk/{p-Cz_PSCK3.system.js.map → p-Dxsz-5-P.system.js.map} +1 -1
  149. package/dist/verdocs-web-sdk/{p-BpvxoJa6.system.js.map → p-H1Tf5vYL.system.js.map} +1 -1
  150. package/dist/verdocs-web-sdk/{p-f5d355d5.system.entry.js → p-c0fbae7e.system.entry.js} +2 -2
  151. package/dist/verdocs-web-sdk/{p-6598380f.entry.js → p-c1b0b0a8.entry.js} +2 -2
  152. package/dist/verdocs-web-sdk/{p-3899da33.entry.js → p-c288939e.entry.js} +3 -3
  153. package/dist/verdocs-web-sdk/{p-4cbec34e.system.entry.js → p-c4ca9e20.system.entry.js} +3 -3
  154. package/dist/verdocs-web-sdk/p-d09f0a2c.entry.js +8 -0
  155. package/dist/verdocs-web-sdk/p-d09f0a2c.entry.js.map +1 -0
  156. package/dist/verdocs-web-sdk/{p-363f13cb.system.entry.js → p-dbaaa79f.system.entry.js} +2 -2
  157. package/dist/verdocs-web-sdk/{p-42ad9ea7.entry.js → p-e74f4251.entry.js} +2 -2
  158. package/dist/verdocs-web-sdk/{p-fe97fd80.entry.js → p-ea23d10b.entry.js} +2 -2
  159. package/dist/verdocs-web-sdk/{p-721b3041.system.entry.js → p-ee6623f7.system.entry.js} +2 -2
  160. package/dist/verdocs-web-sdk/p-f986d5dd.entry.js +2 -0
  161. package/dist/verdocs-web-sdk/p-f986d5dd.entry.js.map +1 -0
  162. package/dist/verdocs-web-sdk/{p-CHm_85GB.js → p-oC6bZSel.js} +2 -2
  163. package/dist/verdocs-web-sdk/{p-CHm_85GB.js.map → p-oC6bZSel.js.map} +1 -1
  164. package/dist/verdocs-web-sdk/verdocs-preview.verdocs-send.verdocs-template-attachments.verdocs-template-build-tabs.verdocs-template-fields.verdocs-template-roles.verdocs-template-settings.entry.esm.js.map +1 -1
  165. package/dist/verdocs-web-sdk/verdocs-template-document-page.verdocs-toolbar-icon.entry.esm.js.map +1 -1
  166. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  167. package/package.json +1 -1
  168. package/dist/components/p-B7nY_WEM.js.map +0 -1
  169. package/dist/components/p-BSXsWUmY.js.map +0 -1
  170. package/dist/components/p-DR_BGSby.js +0 -217
  171. package/dist/components/p-DR_BGSby.js.map +0 -1
  172. package/dist/components/p-DWZamcQd.js.map +0 -1
  173. package/dist/components/p-YzC4BSrh.js.map +0 -1
  174. package/dist/esm/Types-dqxNbm_b.js +0 -8
  175. package/dist/esm-es5/Types-dqxNbm_b.js +0 -2
  176. package/dist/verdocs-web-sdk/p-344a99c7.system.entry.js +0 -8
  177. package/dist/verdocs-web-sdk/p-344a99c7.system.entry.js.map +0 -1
  178. package/dist/verdocs-web-sdk/p-8c86b7fd.entry.js +0 -2
  179. package/dist/verdocs-web-sdk/p-8c86b7fd.entry.js.map +0 -1
  180. package/dist/verdocs-web-sdk/p-CgZsFvRv.system.js +0 -2
  181. package/dist/verdocs-web-sdk/p-DNUz9v6d.system.js.map +0 -1
  182. package/dist/verdocs-web-sdk/p-DsA3pbFK.system.js.map +0 -1
  183. package/dist/verdocs-web-sdk/p-DyCZUrdb.system.js.map +0 -1
  184. package/dist/verdocs-web-sdk/p-c3e7b3ce.system.entry.js +0 -2
  185. package/dist/verdocs-web-sdk/p-c3e7b3ce.system.entry.js.map +0 -1
  186. package/dist/verdocs-web-sdk/p-dqxNbm_b.js +0 -2
  187. package/dist/verdocs-web-sdk/p-e23c5042.entry.js +0 -8
  188. package/dist/verdocs-web-sdk/p-e23c5042.entry.js.map +0 -1
  189. /package/dist/verdocs-web-sdk/{p-751501f3.entry.js.map → p-07a00b97.entry.js.map} +0 -0
  190. /package/dist/verdocs-web-sdk/{p-96c50a15.system.entry.js.map → p-16e4f438.system.entry.js.map} +0 -0
  191. /package/dist/verdocs-web-sdk/{p-b7a88f34.system.entry.js.map → p-178d03a6.system.entry.js.map} +0 -0
  192. /package/dist/verdocs-web-sdk/{p-3c1ca466.entry.js.map → p-3aebfd86.entry.js.map} +0 -0
  193. /package/dist/verdocs-web-sdk/{p-12a23bdb.entry.js.map → p-4671fd0b.entry.js.map} +0 -0
  194. /package/dist/verdocs-web-sdk/{p-f615bed5.entry.js.map → p-5cf0d300.entry.js.map} +0 -0
  195. /package/dist/verdocs-web-sdk/{p-7165eccc.system.entry.js.map → p-8cb631da.system.entry.js.map} +0 -0
  196. /package/dist/verdocs-web-sdk/{p-cff62722.system.entry.js.map → p-9ec65cad.system.entry.js.map} +0 -0
  197. /package/dist/verdocs-web-sdk/{p-f5d355d5.system.entry.js.map → p-c0fbae7e.system.entry.js.map} +0 -0
  198. /package/dist/verdocs-web-sdk/{p-6598380f.entry.js.map → p-c1b0b0a8.entry.js.map} +0 -0
  199. /package/dist/verdocs-web-sdk/{p-3899da33.entry.js.map → p-c288939e.entry.js.map} +0 -0
  200. /package/dist/verdocs-web-sdk/{p-4cbec34e.system.entry.js.map → p-c4ca9e20.system.entry.js.map} +0 -0
  201. /package/dist/verdocs-web-sdk/{p-363f13cb.system.entry.js.map → p-dbaaa79f.system.entry.js.map} +0 -0
  202. /package/dist/verdocs-web-sdk/{p-42ad9ea7.entry.js.map → p-e74f4251.entry.js.map} +0 -0
  203. /package/dist/verdocs-web-sdk/{p-fe97fd80.entry.js.map → p-ea23d10b.entry.js.map} +0 -0
  204. /package/dist/verdocs-web-sdk/{p-721b3041.system.entry.js.map → p-ee6623f7.system.entry.js.map} +0 -0
@@ -1,8 +1,8 @@
1
- var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++){t=arguments[n];for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i))e[i]=t[i]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,n,o){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function l(e){try{a(o["throw"](e))}catch(e){r(e)}}function a(e){e.done?n(e.value):i(e.value).then(s,l)}a((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},o,i,r,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=l(0),s["throw"]=l(1),s["return"]=l(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(e){return function(t){return a([e,t])}}function a(l){if(o)throw new TypeError("Generator is already executing.");while(s&&(s=0,l[0]&&(n=0)),n)try{if(o=1,i&&(r=l[0]&2?i["return"]:l[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;if(i=0,r)l=[l[0]&2,r.value];switch(l[0]){case 0:case 1:r=l;break;case 4:n.label++;return{value:l[1],done:false};case 5:n.label++;i=l[1];l=[0];continue;case 7:l=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){n.label=l[1];break}if(l[0]===6&&n.label<r[1]){n.label=r[1];r=l;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(l);break}if(r[2])n.ops.pop();n.trys.pop();continue}l=t.call(e,n)}catch(e){l=[6,e];i=0}finally{o=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var o=0,i=t.length,r;o<i;o++){if(r||!(o in t)){if(!r)r=Array.prototype.slice.call(t,0,o);r[o]=t[o]}}return e.concat(r||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host,F as Fragment,g as getElement}from"./index-BIRwgFLv.js";import{VerdocsEndpoint,getTemplate,integerSequence,getOrganizationContacts,isValidEmail,createEnvelope,formatFullName,getRGBA,createTemplateDocument,deleteTemplateDocument,updateField,createField,updateTemplateRole,createTemplateRole,updateTemplate}from"@verdocs/js-sdk";import{a as renderDocumentField,g as getFieldId,f as updateCssTransform,h as removeCssTransform,i as setControlStyles,d as defaultHeight,j as defaultWidth}from"./utils-ivPfUH2E.js";import{S as SDKError}from"./errors-C1sRVZWv.js";import{S as Store}from"./Datastore-bS8INhRF.js";import{D as DefaultEndpoint}from"./Environment-C_Xku1v2.js";import{V as VerdocsToast}from"./Toast-CyvDgtoV.js";import{a as DocIcon,P as PngIcon,J as JpgIcon,b as PdfIcon,F as FileIcon,c as PageCountIcon,T as TrashIcon}from"./Icons-COC8ZzcY.js";import{d as dateFnsExports}from"./index-dzBXqXlK.js";import{i as interact}from"./interact.min-BepJAdBZ.js";import"./Types-dqxNbm_b.js";import"./_commonjsHelpers-BFTU3MAI.js";var verdocsPreviewCss='verdocs-preview{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif);display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;position:relative;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-preview div,verdocs-preview canvas{-webkit-box-sizing:border-box;box-sizing:border-box}';var VerdocsPreview=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.templateListenerId=null;this.renderedPages={};this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[PREVIEW] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[PREVIEW] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){console.log("[PREVIEW] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(o){console.log("[PREVIEW] Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.handlePageRendered=function(e){var t;var n=e.detail;this.renderedPages["".concat(n.documentId,":").concat(n.pageNumber)]=n;var o=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).filter((function(e){if(e["document_id"]){return e["document_id"]===n.documentId&&e.page===n.pageNumber}return e.page===n.pageNumber}));o.forEach((function(e){return renderDocumentField("template",e,n,{disabled:true,editable:false,draggable:false})}))};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}return h(Host,null,(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){var n=integerSequence(1,t.pages);return h(Fragment,null,n.map((function(n){var o;var i=((o=t.page_sizes)===null||o===void 0?void 0:o[n])||{width:612,height:792};return h("verdocs-template-document-page",{templateId:t.template_id,documentId:t.id,pageNumber:n,disabled:true,editable:false,done:false,virtualWidth:i.width,virtualHeight:i.height,onPageRendered:function(t){return e.handlePageRendered(t)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))})))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsPreview.style=verdocsPreviewCss;var getRoleNames=function(e){return((e===null||e===void 0?void 0:e.roles)||[]).map((function(e){return e.name}))};var getRoleIndex=function(e,t){return Math.max(getRoleNames(e).findIndex((function(e){return e===t})),0)};var verdocsSendCss='verdocs-send{padding:10px;position:relative;background:#ffffff;-ms-flex-direction:column;flex-direction:column;font-family:var(--verdocs-primary-font, "Inter", "Barlow", 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)}';var editIcon='<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>';var startIcon='<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>';var stepIcon='<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>';var doneIcon='<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>';var VerdocsSend=function(){function e(e){registerInstance(this,e);this.beforeSend=createEvent(this,"beforeSend");this.send=createEvent(this,"send");this.exit=createEvent(this,"exit");this.sdkError=createEvent(this,"sdkError");this.searchContacts=createEvent(this,"searchContacts");this.templateListenerId=null;this.endpoint=DefaultEndpoint;this.templateId=null;this.environment="";this.showCancel=true;this.containerId="verdocs-send-".concat(Math.random().toString(36).substring(2,11));this.showPickerForId="";this.sessionContacts=[];this.sending=false;this.rolesCompleted={};this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[SEND] Loading template",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),true,(function(t){console.log("[SEND] Got new template",t);e.template=t;e.loading=false;e.rolesCompleted={};e.recomputeRolesCompleted()}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.reset=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.rolesCompleted={};return[2]}))}))};e.prototype.onTemplateIdChanged=function(e){console.log("[SEND] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;var o=this;return __generator(this,(function(i){try{this.endpoint.onSessionChanged((function(e,t,n){if(!n){return}var i={id:n.id,first_name:n.first_name,last_name:n.last_name,email:n.email,phone:n.phone};if(n){o.sessionContacts=[i];getOrganizationContacts(o.endpoint).then((function(e){console.log("[SEND] Got contacts",e);o.sessionContacts=__spreadArray(__spreadArray([],e,true),[i],false)})).catch((function(e){console.log("[SEND] Error getting contacts",e)}))}}));this.endpoint.loadSession();if(!this.endpoint.session){console.log("[SEND] Unable to start Send operation, must be authenticated");return[2]}if(!this.templateId){console.log("[SEND] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(o){console.log("[SEND] Error with send session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.recomputeRolesCompleted=function(){var e=this;var t;this.rolesCompleted={};var n={};(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).forEach((function(t){var o=t.sequence;n[o]||(n[o]=[]);var i="r-".concat(o,"-").concat(n[o].length);n[o].push(__assign(__assign({},t),{id:i,role_name:t.name,first_name:t.first_name,last_name:t.last_name}));if(t.first_name&&isValidEmail(t.email)){e.rolesCompleted[i]=__assign(__assign({},t),{id:i,role_name:t.name,first_name:t.first_name,last_name:t.last_name})}}))};e.prototype.getSequenceNumbers=function(){var e;var t={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((function(e){t[e.sequence]=true}));return Object.keys(t).map((function(e){return+e})).sort((function(e,t){return e-t}))};e.prototype.getRolesAtLevel=function(e){var t;var n=(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((function(t){return t.sequence===e})).map((function(t,n){return __assign(__assign({},t),{id:"r-".concat(e,"-").concat(n),role_name:t.name,first_name:t.first_name,last_name:t.last_name})}));return n};e.prototype.getLevelIcon=function(e){if(e==="start"){return h("div",{class:"level-icon",innerHTML:startIcon})}else if(e==="end"){return h("div",{class:"level-icon",innerHTML:doneIcon})}else{return h("div",{class:"level-icon",innerHTML:stepIcon})}};e.prototype.handleSelectContact=function(e,t){e.preventDefault();this.rolesCompleted[t.id]=__assign(__assign({},t),e.detail);this.showPickerForId=""};e.prototype.handleClickRole=function(e,t){e.stopPropagation();this.showPickerForId=t.id};e.prototype.handleSend=function(e){var t=this;var n;if(this.sending){console.log("[SEND] Skipping duplicate send",e);return}console.log("[SEND] Sending",e);e.preventDefault();e.stopPropagation();this.sending=true;var o={template_id:this.templateId,name:((n=this.template)===null||n===void 0?void 0:n.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted)};var i=this.beforeSend.emit(__assign(__assign({},o),{name:o.name,template:this.template}));if(i.defaultPrevented){console.log("[SEND] Send cancelled by parent",o);this.sending=false;return}console.log("[SEND] Creating envelope",o);createEnvelope(this.endpoint,o).then((function(e){var n;console.log("[SEND] Send envelope",e);t.reset().catch((function(e){return console.log("Unknown Error",e)}));t.sending=false;(n=t.send)===null||n===void 0?void 0:n.emit(__assign(__assign({},o),{name:o.name,envelope_id:e.id,envelope:e}))})).catch((function(e){var n,o,i;console.log("[SEND] Send error",e);VerdocsToast(((o=(n=e.response)===null||n===void 0?void 0:n.data)===null||o===void 0?void 0:o.error)||"Error creating envelope, please try again later.");t.sending=false;(i=t.sdkError)===null||i===void 0?void 0:i.emit(e)}))};e.prototype.handleCancel=function(e){var t;e.stopPropagation();(t=this.exit)===null||t===void 0?void 0:t.emit()};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,{style:{display:"flex"}},h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var n=this.getSequenceNumbers();var o=Object.values(this.rolesCompleted).filter((function(e){return isValidEmail(e.email)&&e.first_name&&e.last_name}));var i=o.length>=getRoleNames(this.template).length;return h(Host,{class:{sendable:(t=this.template)===null||t===void 0?void 0:t.is_sendable}},h("div",{class:"recipients"},h("div",{class:"left-line"}),h("div",{class:"level level-start"},this.getLevelIcon("start"),h("div",{class:"complete"},"Send Envelope")),n.map((function(t){return h("div",{class:"level level-".concat(t)},e.getLevelIcon("sequence"),e.getRolesAtLevel(t).map((function(t){var n,i,r;var s=!t.email||!t.first_name||!t.last_name;var l=((n=e.rolesCompleted[t.id])===null||n===void 0?void 0:n.first_name)?formatFullName(e.rolesCompleted[t.id]):s?t.role_name:formatFullName(t);var a="verdocs-send-recipient-".concat(t.role_name);var c=getRoleIndex(e.template,t.role_name);var d=getRGBA(c);var u=o.findIndex((function(e){return e.role_name===t.role_name}))>-1;var f={backgroundColor:d,border:u?"2px solid #55bc81":"2px solid #dddddd"};return s?h("div",{class:"recipient","data-ri":c,"data-rn":t.role_name,style:f,onClick:function(n){return e.handleClickRole(n,t)},id:a},l,h("div",{class:"icon",innerHTML:editIcon}),e.showPickerForId===t.id&&h("verdocs-portal",{anchor:a,onClickAway:function(){return e.showPickerForId=""}},h("verdocs-contact-picker",{onExit:function(){return e.showPickerForId=""},onNext:function(n){return e.handleSelectContact(n,t)},contactSuggestions:e.sessionContacts,templateRole:(i=e.rolesCompleted[t.id])!==null&&i!==void 0?i:t,onSearchContacts:function(t){var n;return(n=e.searchContacts)===null||n===void 0?void 0:n.emit(t.detail)}}))):h("div",{class:"recipient","data-ri":c,"data-rn":t.role_name,style:f,onClick:function(n){return e.handleClickRole(n,t)},id:a},l,h("div",{class:"icon",innerHTML:editIcon}),e.showPickerForId===t.id&&h("verdocs-portal",{anchor:a,onClickAway:function(){return e.showPickerForId=""}},h("verdocs-contact-picker",{onExit:function(){return e.showPickerForId=""},onNext:function(n){return e.handleSelectContact(n,t)},contactSuggestions:e.sessionContacts,templateRole:(r=e.rolesCompleted[t.id])!==null&&r!==void 0?r:t,onSearchContacts:function(t){var n;return(n=e.searchContacts)===null||n===void 0?void 0:n.emit(t.detail)}})))})))})),h("div",{class:"level level-done"},this.getLevelIcon("end"),h("div",{class:"complete"},"Signing Complete"))),h("div",{class:"buttons"},this.showCancel&&h("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:function(t){return e.handleCancel(t)},disabled:this.sending}),h("verdocs-button",{label:"Send",size:"small",disabled:!i||this.sending,onClick:function(t){return e.handleSend(t)}}),this.sending&&h("verdocs-spinner",null)))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsSend.style=verdocsSendCss;var verdocsTemplateAttachmentsCss='verdocs-template-attachments{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-template-attachments h5{font-size:16px;font-weight:bold;margin:0 0 10px 0;color:#46497d}verdocs-template-attachments .attachments{margin:0 0 40px 0}verdocs-template-attachments .attachment{display:-ms-flexbox;display:flex;padding:5px 0;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#33364b}verdocs-template-attachments .attachment:hover .trash-icon{display:-ms-flexbox;display:flex}verdocs-template-attachments .attachment:hover .pages{display:none}verdocs-template-attachments svg{width:28px;height:28px;fill:#5c6575;margin:2px 0 0 0}verdocs-template-attachments .file-icon{-ms-flex:0;flex:0}verdocs-template-attachments .pages{width:24px;height:24px;-ms-flex:0 0 24px;flex:0 0 24px;padding-left:4px;position:relative;margin:-10px 0 0 0}verdocs-template-attachments .pages .pages-icon{top:0;left:0;width:24px;height:24px;position:absolute}verdocs-template-attachments .pages .count{top:11px;left:7px;z-index:1;width:18px;font-size:12px;font-weight:500;position:absolute;text-align:center;letter-spacing:-2px}verdocs-template-attachments .filename{-ms-flex:1;flex:1;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;border-bottom:1px dotted #cccccc}verdocs-template-attachments .trash-icon{-ms-flex:0;flex:0;display:none}verdocs-template-attachments .trash-icon:hover{cursor:pointer}verdocs-template-attachments verdocs-file-chooser{margin:10px 0;border:2px dashed #979797}verdocs-template-attachments .loader-wrapper{background-color:#ffffff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:320px;height:320px;text-align:center;border:2px dashed #979797;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .progress-wrapper{padding:20px}verdocs-template-attachments .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-attachments ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-moz-placeholder{color:#aaaaaa}verdocs-template-attachments :-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::placeholder{color:#aaaaaa}';var VerdocsTemplateAttachments=function(){function e(e){registerInstance(this,e);this.exit=createEvent(this,"exit");this.next=createEvent(this,"next");this.templateUpdated=createEvent(this,"templateUpdated");this.sdkError=createEvent(this,"sdkError");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.uploading=false;this.progressLabel="Uploading...";this.progressPercent=0;this.showDeleteError=false;this.confirmDeleteDocument=null;this.loading=true;this.template=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(o){console.log("[TEMPLATE ATTACHMENTS] Error loading template",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.handleCancel=function(e){e.stopPropagation();this.exit.emit()};e.prototype.handleUploadProgress=function(e){if(e>=99){this.progressPercent=100;this.progressLabel="Processing..."}else{this.progressPercent=e}};e.prototype.handleUpload=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,o,i,r,s,l,a;return __generator(this,(function(c){switch(c.label){case 0:e.stopPropagation();r=e.detail.file;if(!r){return[2]}console.log("[ATTACHMENTS] Uploading...",r);this.uploading=true;this.progressLabel="Uploading...";c.label=1;case 1:c.trys.push([1,4,,5]);return[4,createTemplateDocument(this.endpoint,this.templateId,r,this.handleUploadProgress.bind(this))];case 2:s=c.sent();console.log("[ATTACHMENTS] Created attachment",s);l=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 3:l.template=c.sent();console.log("[ATTACHMENTS] Updated template",this.template);(t=this.templateUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,template:this.template,event:"attachments"});this.uploading=false;this.progressLabel="";this.progressPercent=0;return[3,5];case 4:a=c.sent();console.log("[ATTACHMENTS] Error creating template",a);(n=this.sdkError)===null||n===void 0?void 0:n.emit(new SDKError(a.message,(o=a.response)===null||o===void 0?void 0:o.status,(i=a.response)===null||i===void 0?void 0:i.data));this.uploading=false;return[3,5];case 5:return[2]}}))}))};e.prototype.handleNext=function(e){var t;e.stopPropagation();this.uploading=false;this.progressLabel="";this.progressPercent=0;(t=this.next)===null||t===void 0?void 0:t.emit({template:this.template})};e.prototype.confirmDelete=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,deleteTemplateDocument(this.endpoint,this.confirmDeleteDocument.id)];case 1:t.sent();e=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 2:e.template=t.sent();console.log("[ATTACHMENTS] New template",this.template);this.confirmDeleteDocument=null;return[2]}}))}))};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(n){if((((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>1){this.confirmDeleteDocument=e}else{this.showDeleteError=true}return[2]}))}))};e.prototype.getFileIcon=function(e){switch(e.mime){case"application/pdf":return PdfIcon;case"image/jpeg":return JpgIcon;case"image/png":return PngIcon;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return DocIcon}return FileIcon};e.prototype.render=function(){var e=this;var t,n;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading){return h(Host,{class:"loading"},h("verdocs-loader",null))}if(!this.endpoint.session||!this.template){return h(Host,{class:"empty"})}return h(Host,null,h("h5",null,"Existing Attachments"),h("div",{class:"attachments"},(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){return h("div",{class:"attachment"},h("div",{class:"file-icon",innerHTML:e.getFileIcon(t)}),h("div",{class:"filename",title:t.name},t.name),h("div",{class:"pages"},h("div",{class:"count"},t.pages),h("div",{class:"pages-icon",innerHTML:PageCountIcon})),h("div",{class:"trash-icon",innerHTML:TrashIcon,onClick:function(){return e.handleDelete(t)}}))}))),h("h5",null,"Attach a New Document"),this.uploading?h("div",{class:"loader-wrapper"},h("verdocs-loader",null),this.progressLabel&&h("div",{class:"progress-wrapper"},h("verdocs-progress-bar",{showPercent:true,percent:this.progressPercent,label:this.progressLabel}))):h("verdocs-file-chooser",{onFileSelected:function(t){return e.handleUpload(t)}}),h("div",{class:"buttons"},h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(t){return e.handleCancel(t)},disabled:this.uploading}),h("verdocs-button",{label:"Next",size:"small",onClick:function(t){return e.handleNext(t)},disabled:!(((n=this.template)===null||n===void 0?void 0:n.documents)||[]).length||this.uploading})),this.showDeleteError&&h("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:function(){return e.showDeleteError=false}}),this.confirmDeleteDocument&&h("verdocs-ok-dialog",{heading:"Delete this Attachment?",message:"This operation cannot be undone. All fields placed<br />on the deleted attachment will also be removed.",onNext:function(){return e.confirmDelete()},showCancel:true,onExit:function(){e.confirmDeleteDocument=null}}))};return e}();VerdocsTemplateAttachments.style=verdocsTemplateAttachmentsCss;var verdocsTemplateBuildTabsCss='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:var(--verdocs-primary-font, "Inter", "Barlow", 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}';var HelpIcon='<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>';var CopyIcon='<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>';var STEPS=["attachments","roles","settings","fields","preview"];var VerdocsTemplateBuildTabs=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.stepChanged=createEvent(this,"stepChanged");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.step="preview";this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[BUILD_TABS] Template ID changed",e);this.listenToTemplate()};e.prototype.onStepChanged=function(e){console.log("[BUILD_TABS] Step changed",e)};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){this.step="attachments";console.log("[BUILD_TABS] Missing required template ID, forcing view to attachments");return[2]}this.listenToTemplate()}catch(o){console.log("[BUILD_TABS] Error loading template",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.setStep=function(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)};e.prototype.copyTemplateId=function(){var e=this;navigator.clipboard.writeText(this.templateId).then((function(){VerdocsToast("Template ID copied",{style:"success",duration:3e3})})).catch((function(t){var n;console.warn("[BUILD_TABS] Error copying to clipboard",t);(n=e.sdkError)===null||n===void 0?void 0:n.emit(t)}))};e.prototype.render=function(){var e=this;var t,n,o,i,r,s,l,a,c;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var d=(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>0;var u=d&&(((n=this.template)===null||n===void 0?void 0:n.roles)||[]).length>0;var f=u&&(((o=this.template)===null||o===void 0?void 0:o.fields)||[]).length>0;var v=Math.max(STEPS.indexOf(this.step),0);if(!f&&v>=4){v=3}if(!u&&v>=3){v=1}if(!d&&v>=1){v=0}return h(Host,null,h("verdocs-tabs",{onSelectTab:function(t){return e.setStep(t)},selectedTab:v,tabs:[{id:"attachments",disabled:false,label:"Attachment(s)"},{id:"roles",disabled:!d,label:"Roles"},{id:"settings",disabled:!u,label:"Settings"},{id:"fields",disabled:!u,label:"Fields"},{id:"preview",disabled:!f,label:"Preview/Send"}]}),this.templateId&&h("div",{class:"info"},h("verdocs-button-panel",{icon:HelpIcon},h("div",{class:"template-details-panel"},h("h6",null,"Template Details"),h("div",{class:"row"},h("label",null,"ID:"),h("div",{class:"value"},this.templateId),h("div",{class:"icon-button",innerHTML:CopyIcon,onClick:function(){return e.copyTemplateId()}})),h("div",{class:"row"},h("label",null,"Name:"),h("div",{class:"value"},(i=this.template)===null||i===void 0?void 0:i.name)),h("div",{class:"row"},h("label",null,"Visibility:"),h("div",{class:"value"},((r=this.template)===null||r===void 0?void 0:r.is_public)?"Public":((s=this.template)===null||s===void 0?void 0:s.is_personal)?"Private":"Shared")),h("div",{class:"row"},h("label",null,"Created:"),h("div",{class:"value"},((l=this.template)===null||l===void 0?void 0:l.counter)?dateFnsExports.format(new Date((a=this.template)===null||a===void 0?void 0:a.created_at),"P p"):"")),h("div",{class:"row"},h("label",null,"Used:"),h("div",{class:"value"},(c=this.template)===null||c===void 0?void 0:c.counter," time(s)"))))))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"],step:["onStepChanged"]}},enumerable:false,configurable:true});return e}();VerdocsTemplateBuildTabs.style=verdocsTemplateBuildTabsCss;var verdocsTemplateFieldsCss="verdocs-template-fields{font-family:var(--verdocs-primary-font, \"Inter\", \"Barlow\", 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}";var iconTextbox='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M3.425 16.15V13h11.15v3.15Zm0-5.15V7.85h17.15V11Z"/></svg>';var iconCheck='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z"/></svg>';var iconRadio='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M12 17q2.075 0 3.538-1.463Q17 14.075 17 12t-1.462-3.538Q14.075 7 12 7 9.925 7 8.463 8.462 7 9.925 7 12q0 2.075 1.463 3.537Q9.925 17 12 17Zm0 5.85q-2.275 0-4.25-.85t-3.438-2.312Q2.85 18.225 2 16.25q-.85-1.975-.85-4.25T2 7.75q.85-1.975 2.312-3.438Q5.775 2.85 7.75 2q1.975-.85 4.25-.85t4.25.85q1.975.85 3.438 2.312Q21.15 5.775 22 7.75q.85 1.975.85 4.25T22 16.25q-.85 1.975-2.312 3.438Q18.225 21.15 16.25 22q-1.975.85-4.25.85Zm0-3.15q3.25 0 5.475-2.225Q19.7 15.25 19.7 12q0-3.25-2.225-5.475Q15.25 4.3 12 4.3q-3.25 0-5.475 2.225Q4.3 8.75 4.3 12q0 3.25 2.225 5.475Q8.75 19.7 12 19.7Zm0-7.7Z"/></svg>';var iconDatepicker='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M7.6 13.925q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375ZM5.3 22.85q-1.325 0-2.238-.912-.912-.913-.912-2.238V6.3q0-1.325.912-2.238.913-.912 2.238-.912H6v-2h2.575v2h6.85v-2H18v2h.7q1.325 0 2.238.912.912.913.912 2.238v13.4q0 1.325-.912 2.238-.913.912-2.238.912Zm0-3.15h13.4V10H5.3v9.7ZM5.3 8h13.4V6.3H5.3Zm0 0V6.3 8Z"/></svg>';var iconSignature='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>';var iconInitial='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z"/></svg>';var iconDropdown='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" stroke-width="1.5" stroke="currentColor"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" d="M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25" /></svg>';var iconAttachment='<svg xmlns="http://www.w3.org/2000/svg" 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>';var separator='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.707 14.707"><g><rect x="6.275" y="0" fill="#ffffff7f" width="1" height="15"/></g></svg>';var menuOptions=[{id:"signature",tooltip:"Signature",icon:iconSignature,class:"signature"},{id:"initial",tooltip:"Initials",icon:iconInitial,class:"initial"},{id:"sep1",tooltip:"",icon:separator,class:"separator"},{id:"textbox",tooltip:"Text Box",icon:iconTextbox,class:"textbox"},{id:"checkbox",tooltip:"Check Box",icon:iconCheck,class:"checkbox"},{id:"radio",tooltip:"Radio Button",icon:iconRadio,class:"radio"},{id:"dropdown",tooltip:"Dropdown",icon:iconDropdown,class:"dropdown"},{id:"sep2",tooltip:"",icon:separator,class:"separator"},{id:"date",tooltip:"Date",icon:iconDatepicker,class:"date"},{id:"attachment",tooltip:"Attachment",icon:iconAttachment,class:"attachment"}];var VerdocsTemplateFields=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.templateUpdated=createEvent(this,"templateUpdated");this.fieldsUpdated=createEvent(this,"fieldsUpdated");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.toolbarTargetId=null;this.placing=null;this.showMustSelectRole=false;this.selectedRoleName="";this.loading=true;this.template=null;this.pageHeights={};this.cachedPageInfo={}}e.prototype.onTemplateIdChanged=function(){this.listenToTemplate()};e.prototype.handleKeyDown=function(e){if(e.key==="Escape"){this.placing=null}};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.templateId){console.log("[FIELDS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[FIELDS] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(o){console.log("[FIELDS] Error with fields session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.componentDidRender=function(){interact.dynamicDrop(true);var e=this.toolbarTargetId?document.getElementById(this.toolbarTargetId):null;var t=document.getElementById("verdocs-template-fields-toolbar");if(e&&t){t.remove();e.append(t)}};e.prototype.componentWillUpdate=function(){var e=this;var t,n;var o=((t=this.template)===null||t===void 0?void 0:t.roles)||[];if(!this.selectedRoleName||!o.find((function(t){return t&&t.name===e.selectedRoleName}))){this.selectedRoleName=((n=o[0])===null||n===void 0?void 0:n.name)||"";console.log("[FIELDS] Selected new role",this.selectedRoleName)}};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){var n,o;e.template=t;e.loading=false;if(!e.selectedRoleName){e.selectedRoleName=((o=(n=t.roles)===null||n===void 0?void 0:n[0])===null||o===void 0?void 0:o.name)||""}}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.attachFieldAttributes=function(e,t,n){var o=this;n.addEventListener("settingsChanged",(function(){var e;(e=o.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:o.endpoint,template:o.template,event:"added-field"})}));n.addEventListener("deleted",(function(){var e;n.remove();(e=o.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:o.endpoint,template:o.template,event:"updated-field"})}));n.setAttribute("templateid",this.templateId);n.setAttribute("fieldname",t.name);n.setAttribute("pageNumber",String(e.pageNumber));n.setAttribute("xScale",String(e.xScale));n.setAttribute("yScale",String(e.yScale));n.setAttribute("name",t.name)};e.prototype.handlePageRendered=function(e){var t=this;var n;var o=e.detail;this.cachedPageInfo[o.pageNumber]=o;this.pageHeights[o.pageNumber]=o.naturalHeight;(((n=this.template)===null||n===void 0?void 0:n.fields)||[]).filter((function(e){return e&&e.page===o.pageNumber})).forEach((function(e){var n=getFieldId(e);var o=document.getElementById(n);if(o){o.setAttribute("fieldname",e.name);o.setAttribute("pagenumber",String(e.page));t.makeDraggable(o)}}))};e.prototype.makeDraggable=function(e){interact(e).draggable({listeners:{move:this.handleMoveField.bind(this),end:this.handleMoveEnd.bind(this)}})};e.prototype.handleMoveField=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,o,i,r,s;return __generator(this,(function(l){t=+(e.target.getAttribute("posX")||0);n=+(e.target.getAttribute("posY")||0);o=+(e.target.getAttribute("xScale")||1);i=+(e.target.getAttribute("yScale")||1);r=e.dx/o+t;s=e.dy/i+n;e.target.setAttribute("posX",r);e.target.setAttribute("posy",s);updateCssTransform(e.target,"translate","".concat(r,"px, ").concat(s,"px"));return[2]}))}))};e.prototype.handleMoveEnd=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,o,i,r,s,l,a,c,d,u,h,f,v,p,g,m,b,x,E,w,S,_,y,I,C,T,D,k,q,M,R,A,O,P,H,L,V,z;return __generator(this,(function(Z){switch(Z.label){case 0:c=e.target.getAttribute("fieldname");d=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).find((function(e){return e.name===c}));if(!d){console.log("[FIELDS] Unable to find field",c,e.target);return[2]}u=e.target.getAttribute("pagenumber");h=this.cachedPageInfo[u],f=h.naturalWidth,v=f===void 0?612:f,p=h.naturalHeight,g=p===void 0?792:p,m=h.renderedHeight,b=m===void 0?792:m;x=e.target.getBoundingClientRect();E=e.target.parentElement;w=E.getBoundingClientRect();S=d.width||defaultWidth(d.type);_=d.height||defaultHeight(d.type);y=Math.max(x.left-w.left,0);I=Math.max(b-(w.bottom-x.bottom),0);C=parseInt(u);if(I>b){C=Math.min(C+1,((i=(o=((n=this.template)===null||n===void 0?void 0:n.documents)||[])===null||o===void 0?void 0:o[0])===null||i===void 0?void 0:i.pages)||1);I-=b;b=this.cachedPageInfo[C].renderedHeight;console.log("Next page",{newPageNumber:C,newY:I,renderedHeight:b})}else if(I<0){C=Math.max(C-1,1);b=this.cachedPageInfo[C].renderedHeight;I+=b;console.log("[FIELDS] Next page",{newPageNumber:C,newY:I,renderedHeight:b})}T=this.viewCoordinatesToPageCoordinates(y,I,u,v-S,g-_),D=T.x,k=T.y;Z.label=1;case 1:Z.trys.push([1,3,,4]);q={x:D,y:k,page:C};return[4,updateField(this.endpoint,this.templateId,c,q)];case 2:M=Z.sent();console.log("[FIELDS] Updated",M);R=JSON.parse(JSON.stringify(this.template));A=R.fields.findIndex((function(e){return e.name===c}));if(A>-1){R.fields[A]=M}Store.updateTemplate(this.templateId,R);e.target.removeAttribute("posX");e.target.removeAttribute("posY");removeCssTransform(e.target);O=this.cachedPageInfo[u],P=O.xScale,H=P===void 0?1:P,L=O.yScale,V=L===void 0?1:L;setControlStyles(e.target,M,H,V);(r=this.templateUpdated)===null||r===void 0?void 0:r.emit({endpoint:this.endpoint,template:R,event:"updated-field"});return[3,4];case 3:z=Z.sent();VerdocsToast("Error updating field, please try again later",{style:"error"});console.log("[FIELDS] Error updating field",z);(s=this.sdkError)===null||s===void 0?void 0:s.emit(new SDKError(z.message,(l=z.response)===null||l===void 0?void 0:l.status,(a=z.response)===null||a===void 0?void 0:a.data));e.target.removeAttribute("posX");e.target.removeAttribute("posY");removeCssTransform(e.target);return[3,4];case 4:return[2]}}))}))};e.prototype.generateFieldName=function(e,t){var n;var o=1;var i;do{i="".concat(e,"P").concat(t,"-").concat(o);o++}while((((n=this.template)===null||n===void 0?void 0:n.fields)||[]).some((function(e){return e&&e.name===i})));return i};e.prototype.viewCoordinatesToPageCoordinates=function(e,t,n,o,i){var r=this.cachedPageInfo[n],s=r.xScale,l=s===void 0?1:s,a=r.yScale,c=a===void 0?1:a,d=r.renderedHeight,u=d===void 0?792:d;var h=Math.floor(Math.min(e/l,o));var f=Math.floor(Math.min(Math.max(u-t,0)/c,i));return{x:h,y:f}};e.prototype.handleClickPage=function(e,t){return __awaiter(this,void 0,void 0,(function(){var n,o,i,r,s,l,a,c,d,u,h,f,v,p,g,m;return __generator(this,(function(b){switch(b.label){case 0:if(!this.placing)return[3,2];o=e.offsetX;i=e.offsetY;r=defaultWidth(this.placing);s=defaultHeight(this.placing);l=this.cachedPageInfo[t];a=l.naturalWidth,c=a===void 0?612:a,d=l.naturalHeight,u=d===void 0?792:d;h=this.viewCoordinatesToPageCoordinates(o,i,t,c-r,u-s);f=Math.floor(h.x);v=Math.floor(h.y);p={name:this.generateFieldName(this.placing,t),role_name:this.selectedRoleName,template_id:this.templateId,document_id:l.documentId,type:this.placing,required:this.placing!=="radio"&&this.placing!=="attachment"&&this.placing!=="checkbox",page:t,validator:null,label:null,default:null,placeholder:null,group:null,settings:{},x:f,y:v,width:r,height:s,multiline:false,readonly:false,options:this.placing==="radio"?[{id:"option-1",label:"Option 1"}]:[]};console.log("[FIELDS] Will save new field",p);return[4,createField(this.endpoint,this.templateId,p)];case 1:g=b.sent();console.log("[FIELDS] Saved field",g);m=JSON.parse(JSON.stringify(this.template));m.fields.push(g);Store.updateTemplate(this.templateId,m);(n=this.templateUpdated)===null||n===void 0?void 0:n.emit({endpoint:this.endpoint,template:m,event:"added-field"});this.placing=null;b.label=2;case 2:return[2]}}))}))};e.prototype.render=function(){var e;var t=this;var n,o,i;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var r=(((n=this.template)===null||n===void 0?void 0:n.roles)||[]).map((function(e){return{value:e.name,label:e.full_name?"".concat(e.name,": ").concat(e.full_name):e.name}}));return h(Host,{class:this.placing?(e={},e["placing-".concat(this.placing)]=true,e):{},onSubmit:function(){}},h("div",{id:"verdocs-template-fields-toolbar"},h("div",{class:"add-for"},"Add field:"),h("verdocs-select-input",{value:this.selectedRoleName,options:r,onInput:function(e){return t.selectedRoleName=e.target.value}}),menuOptions.map((function(e){return h("verdocs-toolbar-icon",{text:e.tooltip,icon:e.icon,class:e.class,onClick:function(){if(e.tooltip){if(t.selectedRoleName){t.placing=e.id}else{t.showMustSelectRole=true}}}})}))),h("div",{class:"pages"},(((o=this.template)===null||o===void 0?void 0:o.documents)||[]).map((function(e){var n=integerSequence(1,e.pages);return n.map((function(n){var o=e.page_sizes[n];return h("verdocs-template-document-page",{templateId:t.templateId,documentId:e.id,pageNumber:n,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:function(e){return t.handleClickPage(e,n)},onPageRendered:function(e){return t.handlePageRendered(e)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})}))}))),this.showMustSelectRole&&h("verdocs-ok-dialog",{heading:"Unable to add field",message:(((i=this.template)===null||i===void 0?void 0:i.roles)||[]).length>0?"Please select a role before adding fields.":"Please add at least one role before adding fields.",onNext:function(){return t.showMustSelectRole=false}}))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsTemplateFields.style=verdocsTemplateFieldsCss;
1
+ var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++){t=arguments[n];for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i))e[i]=t[i]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,n,o){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function l(e){try{a(o["throw"](e))}catch(e){r(e)}}function a(e){e.done?n(e.value):i(e.value).then(s,l)}a((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},o,i,r,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=l(0),s["throw"]=l(1),s["return"]=l(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(e){return function(t){return a([e,t])}}function a(l){if(o)throw new TypeError("Generator is already executing.");while(s&&(s=0,l[0]&&(n=0)),n)try{if(o=1,i&&(r=l[0]&2?i["return"]:l[0]?i["throw"]||((r=i["return"])&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;if(i=0,r)l=[l[0]&2,r.value];switch(l[0]){case 0:case 1:r=l;break;case 4:n.label++;return{value:l[1],done:false};case 5:n.label++;i=l[1];l=[0];continue;case 7:l=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){n=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){n.label=l[1];break}if(l[0]===6&&n.label<r[1]){n.label=r[1];r=l;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(l);break}if(r[2])n.ops.pop();n.trys.pop();continue}l=t.call(e,n)}catch(e){l=[6,e];i=0}finally{o=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var o=0,i=t.length,r;o<i;o++){if(r||!(o in t)){if(!r)r=Array.prototype.slice.call(t,0,o);r[o]=t[o]}}return e.concat(r||Array.prototype.slice.call(t))};import{r as registerInstance,c as createEvent,h,H as Host,F as Fragment,g as getElement}from"./index-BIRwgFLv.js";import{VerdocsEndpoint,getTemplate,integerSequence,getOrganizationContacts,isValidEmail,createEnvelope,formatFullName,getRGBA,createTemplateDocument,deleteTemplateDocument,updateField,createField,updateTemplateRole,createTemplateRole,updateTemplate}from"@verdocs/js-sdk";import{a as renderDocumentField,g as getFieldId,f as updateCssTransform,h as removeCssTransform,i as setControlStyles,d as defaultHeight,j as defaultWidth}from"./utils-Deu82Q9L.js";import{S as SDKError}from"./errors-C1sRVZWv.js";import{S as Store}from"./Datastore-bS8INhRF.js";import{D as DefaultEndpoint}from"./Environment-C_Xku1v2.js";import{V as VerdocsToast}from"./Toast-CyvDgtoV.js";import{a as DocIcon,P as PngIcon,J as JpgIcon,b as PdfIcon,F as FileIcon,c as PageCountIcon,T as TrashIcon,D as DocumentPageIcon}from"./Icons-COC8ZzcY.js";import{d as dateFnsExports}from"./index-dzBXqXlK.js";import{i as interact}from"./interact.min-BepJAdBZ.js";import"./Types-BqoC0yeA.js";import"./_commonjsHelpers-BFTU3MAI.js";var verdocsPreviewCss='verdocs-preview{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif);display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;position:relative;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-preview div,verdocs-preview canvas{-webkit-box-sizing:border-box;box-sizing:border-box}';var VerdocsPreview=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.templateListenerId=null;this.renderedPages={};this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[PREVIEW] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[PREVIEW] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){console.log("[PREVIEW] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(o){console.log("[PREVIEW] Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.handlePageRendered=function(e){var t;var n=e.detail;this.renderedPages["".concat(n.documentId,":").concat(n.pageNumber)]=n;var o=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).filter((function(e){if(e["document_id"]){return e["document_id"]===n.documentId&&e.page===n.pageNumber}return e.page===n.pageNumber}));o.forEach((function(e){return renderDocumentField("template",e,n,{disabled:true,editable:false,draggable:false})}))};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}return h(Host,null,(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){var n=integerSequence(1,t.pages);return h(Fragment,null,n.map((function(n){var o;var i=((o=t.page_sizes)===null||o===void 0?void 0:o[n])||{width:612,height:792};return h("verdocs-template-document-page",{templateId:t.template_id,documentId:t.id,pageNumber:n,disabled:true,editable:false,done:false,virtualWidth:i.width,virtualHeight:i.height,onPageRendered:function(t){return e.handlePageRendered(t)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]})})))})))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsPreview.style=verdocsPreviewCss;var getRoleNames=function(e){return((e===null||e===void 0?void 0:e.roles)||[]).map((function(e){return e.name}))};var getRoleIndex=function(e,t){return Math.max(getRoleNames(e).findIndex((function(e){return e===t})),0)};var verdocsSendCss='verdocs-send{padding:10px;position:relative;background:#ffffff;-ms-flex-direction:column;flex-direction:column;font-family:var(--verdocs-primary-font, "Inter", "Barlow", 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-wrap:wrap;flex-wrap:wrap;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}verdocs-send .buttons .error-message{width:100%;color:#cc0000;font-size:13px;margin-bottom:10px}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)}';var editIcon='<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>';var startIcon='<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>';var stepIcon='<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>';var doneIcon='<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>';var VerdocsSend=function(){function e(e){registerInstance(this,e);this.beforeSend=createEvent(this,"beforeSend");this.send=createEvent(this,"send");this.exit=createEvent(this,"exit");this.sdkError=createEvent(this,"sdkError");this.searchContacts=createEvent(this,"searchContacts");this.templateListenerId=null;this.endpoint=DefaultEndpoint;this.templateId=null;this.environment="";this.showCancel=true;this.containerId="verdocs-send-".concat(Math.random().toString(36).substring(2,11));this.showPickerForId="";this.sessionContacts=[];this.sending=false;this.rolesCompleted={};this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[SEND] Loading template",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),true,(function(t){console.log("[SEND] Got new template",t);e.template=t;e.loading=false;e.rolesCompleted={};e.recomputeRolesCompleted()}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.reset=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.rolesCompleted={};return[2]}))}))};e.prototype.onTemplateIdChanged=function(e){console.log("[SEND] Template ID changed",e);this.listenToTemplate()};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;var o=this;return __generator(this,(function(i){try{this.endpoint.onSessionChanged((function(e,t,n){if(!n){return}var i={id:n.id,first_name:n.first_name,last_name:n.last_name,email:n.email,phone:n.phone};if(n){o.sessionContacts=[i];getOrganizationContacts(o.endpoint).then((function(e){console.log("[SEND] Got contacts",e);o.sessionContacts=__spreadArray(__spreadArray([],e,true),[i],false)})).catch((function(e){console.log("[SEND] Error getting contacts",e)}))}}));this.endpoint.loadSession();if(!this.endpoint.session){console.log("[SEND] Unable to start Send operation, must be authenticated");return[2]}if(!this.templateId){console.log("[SEND] Missing required template ID ".concat(this.templateId));return[2]}this.listenToTemplate()}catch(o){console.log("[SEND] Error with send session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.recomputeRolesCompleted=function(){var e=this;var t;this.rolesCompleted={};var n={};(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).forEach((function(t){var o=t.sequence;n[o]||(n[o]=[]);var i="r-".concat(o,"-").concat(n[o].length);n[o].push(__assign(__assign({},t),{id:i,role_name:t.name,first_name:t.first_name,last_name:t.last_name}));if(t.first_name&&isValidEmail(t.email)){e.rolesCompleted[i]=__assign(__assign({},t),{id:i,role_name:t.name,first_name:t.first_name,last_name:t.last_name})}}))};e.prototype.getSequenceNumbers=function(){var e;var t={};(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).forEach((function(e){t[e.sequence]=true}));return Object.keys(t).map((function(e){return+e})).sort((function(e,t){return e-t}))};e.prototype.getRolesAtLevel=function(e){var t;var n=(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((function(t){return t.sequence===e})).map((function(t,n){return __assign(__assign({},t),{id:"r-".concat(e,"-").concat(n),role_name:t.name,first_name:t.first_name,last_name:t.last_name})}));return n};e.prototype.getLevelIcon=function(e){if(e==="start"){return h("div",{class:"level-icon",innerHTML:startIcon})}else if(e==="end"){return h("div",{class:"level-icon",innerHTML:doneIcon})}else{return h("div",{class:"level-icon",innerHTML:stepIcon})}};e.prototype.handleSelectContact=function(e,t){e.preventDefault();this.rolesCompleted[t.id]=__assign(__assign({},t),e.detail);this.showPickerForId=""};e.prototype.handleClickRole=function(e,t){e.stopPropagation();this.showPickerForId=t.id};e.prototype.handleSend=function(e){var t=this;var n;if(this.sending){console.log("[SEND] Skipping duplicate send",e);return}console.log("[SEND] Sending",e);e.preventDefault();e.stopPropagation();this.sending=true;var o={template_id:this.templateId,name:((n=this.template)===null||n===void 0?void 0:n.name)||"New Envelope",environment:this.environment,initial_reminder:0,followup_reminders:0,recipients:Object.values(this.rolesCompleted)};var i=this.beforeSend.emit(__assign(__assign({},o),{name:o.name,template:this.template}));if(i.defaultPrevented){console.log("[SEND] Send cancelled by parent",o);this.sending=false;return}console.log("[SEND] Creating envelope",o);createEnvelope(this.endpoint,o).then((function(e){var n;console.log("[SEND] Send envelope",e);t.reset().catch((function(e){return console.log("Unknown Error",e)}));t.sending=false;(n=t.send)===null||n===void 0?void 0:n.emit(__assign(__assign({},o),{name:o.name,envelope_id:e.id,envelope:e}))})).catch((function(e){var n,o,i;console.log("[SEND] Send error",e);VerdocsToast(((o=(n=e.response)===null||n===void 0?void 0:n.data)===null||o===void 0?void 0:o.error)||"Error creating envelope, please try again later.");t.sending=false;(i=t.sdkError)===null||i===void 0?void 0:i.emit(e)}))};e.prototype.handleCancel=function(e){var t;e.stopPropagation();(t=this.exit)===null||t===void 0?void 0:t.emit()};e.prototype.render=function(){var e=this;var t;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,{style:{display:"flex"}},h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var n=this.getSequenceNumbers();var o=Object.values(this.rolesCompleted).filter((function(e){return isValidEmail(e.email)&&e.first_name&&e.last_name}));var i=o.length>=getRoleNames(this.template).length;var r=o.map((function(e){return e.email.toLowerCase()}));var s=new Set(r).size<r.length;return h(Host,{class:{sendable:(t=this.template)===null||t===void 0?void 0:t.is_sendable}},h("div",{class:"recipients"},h("div",{class:"left-line"}),h("div",{class:"level level-start"},this.getLevelIcon("start"),h("div",{class:"complete"},"Send Envelope")),n.map((function(t){return h("div",{class:"level level-".concat(t)},e.getLevelIcon("sequence"),e.getRolesAtLevel(t).map((function(t){var n,i,r;var s=!t.email||!t.first_name||!t.last_name;var l=((n=e.rolesCompleted[t.id])===null||n===void 0?void 0:n.first_name)?formatFullName(e.rolesCompleted[t.id]):s?t.role_name:formatFullName(t);var a="verdocs-send-recipient-".concat(t.role_name);var c=getRoleIndex(e.template,t.role_name);var d=getRGBA(c);var u=o.findIndex((function(e){return e.role_name===t.role_name}))>-1;var f={backgroundColor:d,border:u?"2px solid #55bc81":"2px solid #dddddd"};return s?h("div",{class:"recipient","data-ri":c,"data-rn":t.role_name,style:f,onClick:function(n){return e.handleClickRole(n,t)},id:a},l,h("div",{class:"icon",innerHTML:editIcon}),e.showPickerForId===t.id&&h("verdocs-portal",{anchor:a,onClickAway:function(){return e.showPickerForId=""}},h("verdocs-contact-picker",{onExit:function(){return e.showPickerForId=""},onNext:function(n){return e.handleSelectContact(n,t)},contactSuggestions:e.sessionContacts,templateRole:(i=e.rolesCompleted[t.id])!==null&&i!==void 0?i:t,onSearchContacts:function(t){var n;return(n=e.searchContacts)===null||n===void 0?void 0:n.emit(t.detail)}}))):h("div",{class:"recipient","data-ri":c,"data-rn":t.role_name,style:f,onClick:function(n){return e.handleClickRole(n,t)},id:a},l,h("div",{class:"icon",innerHTML:editIcon}),e.showPickerForId===t.id&&h("verdocs-portal",{anchor:a,onClickAway:function(){return e.showPickerForId=""}},h("verdocs-contact-picker",{onExit:function(){return e.showPickerForId=""},onNext:function(n){return e.handleSelectContact(n,t)},contactSuggestions:e.sessionContacts,templateRole:(r=e.rolesCompleted[t.id])!==null&&r!==void 0?r:t,onSearchContacts:function(t){var n;return(n=e.searchContacts)===null||n===void 0?void 0:n.emit(t.detail)}})))})))})),h("div",{class:"level level-done"},this.getLevelIcon("end"),h("div",{class:"complete"},"Signing Complete"))),h("div",{class:"buttons"},s&&h("div",{class:"error-message"},"Recipients cannot share the same email."),this.showCancel&&h("verdocs-button",{label:"Cancel",size:"small",variant:"outline",onClick:function(t){return e.handleCancel(t)},disabled:this.sending}),h("verdocs-button",{label:"Send",size:"small",disabled:!i||this.sending||s,onClick:function(t){return e.handleSend(t)}}),this.sending&&h("verdocs-spinner",null)))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsSend.style=verdocsSendCss;var verdocsTemplateAttachmentsCss='verdocs-template-attachments{font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-template-attachments h5{font-size:16px;font-weight:bold;margin:0 0 10px 0;color:#46497d}verdocs-template-attachments .attachments{margin:0 0 40px 0}verdocs-template-attachments .attachment{display:-ms-flexbox;display:flex;padding:5px 0;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#33364b}verdocs-template-attachments .attachment:hover .trash-icon{display:-ms-flexbox;display:flex}verdocs-template-attachments .attachment:hover .pages{display:none}verdocs-template-attachments svg{width:28px;height:28px;fill:#5c6575;margin:2px 0 0 0}verdocs-template-attachments .file-icon{-ms-flex:0;flex:0}verdocs-template-attachments .pages{width:24px;height:24px;-ms-flex:0 0 24px;flex:0 0 24px;padding-left:4px;position:relative;margin:-10px 0 0 0}verdocs-template-attachments .pages .pages-icon{top:0;left:0;width:24px;height:24px;position:absolute}verdocs-template-attachments .pages .count{top:11px;left:7px;z-index:1;width:18px;font-size:12px;font-weight:500;position:absolute;text-align:center;letter-spacing:-2px}verdocs-template-attachments .filename{-ms-flex:1;flex:1;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;border-bottom:1px dotted #cccccc}verdocs-template-attachments .trash-icon{-ms-flex:0;flex:0;display:none}verdocs-template-attachments .trash-icon:hover{cursor:pointer}verdocs-template-attachments verdocs-file-chooser{margin:10px 0;border:2px dashed #979797}verdocs-template-attachments .loader-wrapper{background-color:#ffffff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:320px;height:320px;text-align:center;border:2px dashed #979797;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .progress-wrapper{padding:20px}verdocs-template-attachments .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-attachments ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-moz-placeholder{color:#aaaaaa}verdocs-template-attachments :-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::placeholder{color:#aaaaaa}';var VerdocsTemplateAttachments=function(){function e(e){registerInstance(this,e);this.exit=createEvent(this,"exit");this.next=createEvent(this,"next");this.templateUpdated=createEvent(this,"templateUpdated");this.sdkError=createEvent(this,"sdkError");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.uploading=false;this.progressLabel="Uploading...";this.progressPercent=0;this.showDeleteError=false;this.confirmDeleteDocument=null;this.loading=true;this.template=null}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(o){console.log("[TEMPLATE ATTACHMENTS] Error loading template",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.handleCancel=function(e){e.stopPropagation();this.exit.emit()};e.prototype.handleUploadProgress=function(e){if(e>=99){this.progressPercent=100;this.progressLabel="Processing..."}else{this.progressPercent=e}};e.prototype.handleUpload=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,o,i,r,s,l,a;return __generator(this,(function(c){switch(c.label){case 0:e.stopPropagation();r=e.detail.file;if(!r){return[2]}console.log("[ATTACHMENTS] Uploading...",r);this.uploading=true;this.progressLabel="Uploading...";c.label=1;case 1:c.trys.push([1,4,,5]);return[4,createTemplateDocument(this.endpoint,this.templateId,r,this.handleUploadProgress.bind(this))];case 2:s=c.sent();console.log("[ATTACHMENTS] Created attachment",s);l=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 3:l.template=c.sent();console.log("[ATTACHMENTS] Updated template",this.template);(t=this.templateUpdated)===null||t===void 0?void 0:t.emit({endpoint:this.endpoint,template:this.template,event:"attachments"});this.uploading=false;this.progressLabel="";this.progressPercent=0;return[3,5];case 4:a=c.sent();console.log("[ATTACHMENTS] Error creating template",a);(n=this.sdkError)===null||n===void 0?void 0:n.emit(new SDKError(a.message,(o=a.response)===null||o===void 0?void 0:o.status,(i=a.response)===null||i===void 0?void 0:i.data));this.uploading=false;return[3,5];case 5:return[2]}}))}))};e.prototype.handleNext=function(e){var t;e.stopPropagation();this.uploading=false;this.progressLabel="";this.progressPercent=0;(t=this.next)===null||t===void 0?void 0:t.emit({template:this.template})};e.prototype.confirmDelete=function(){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:return[4,deleteTemplateDocument(this.endpoint,this.confirmDeleteDocument.id)];case 1:t.sent();e=this;return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 2:e.template=t.sent();console.log("[ATTACHMENTS] New template",this.template);this.confirmDeleteDocument=null;return[2]}}))}))};e.prototype.handleDelete=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(n){if((((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>1){this.confirmDeleteDocument=e}else{this.showDeleteError=true}return[2]}))}))};e.prototype.getFileIcon=function(e){switch(e.mime){case"application/pdf":return PdfIcon;case"image/jpeg":return JpgIcon;case"image/png":return PngIcon;case"application/msword":case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return DocIcon}return FileIcon};e.prototype.render=function(){var e=this;var t,n;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading){return h(Host,{class:"loading"},h("verdocs-loader",null))}if(!this.endpoint.session||!this.template){return h(Host,{class:"empty"})}return h(Host,null,h("h5",null,"Existing Attachments"),h("div",{class:"attachments"},(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).map((function(t){return h("div",{class:"attachment"},h("div",{class:"file-icon",innerHTML:e.getFileIcon(t)}),h("div",{class:"filename",title:t.name},t.name),h("div",{class:"pages"},h("div",{class:"count"},t.pages),h("div",{class:"pages-icon",innerHTML:PageCountIcon})),h("div",{class:"trash-icon",innerHTML:TrashIcon,onClick:function(){return e.handleDelete(t)}}))}))),h("h5",null,"Attach a New Document"),this.uploading?h("div",{class:"loader-wrapper"},h("verdocs-loader",null),this.progressLabel&&h("div",{class:"progress-wrapper"},h("verdocs-progress-bar",{showPercent:true,percent:this.progressPercent,label:this.progressLabel}))):h("verdocs-file-chooser",{onFileSelected:function(t){return e.handleUpload(t)}}),h("div",{class:"buttons"},h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(t){return e.handleCancel(t)},disabled:this.uploading}),h("verdocs-button",{label:"Next",size:"small",onClick:function(t){return e.handleNext(t)},disabled:!(((n=this.template)===null||n===void 0?void 0:n.documents)||[]).length||this.uploading})),this.showDeleteError&&h("verdocs-ok-dialog",{heading:"Unable to Delete Attachment",message:"Templates must contain at least one attachment.",onNext:function(){return e.showDeleteError=false}}),this.confirmDeleteDocument&&h("verdocs-ok-dialog",{heading:"Delete this Attachment?",message:"This operation cannot be undone. All fields placed<br />on the deleted attachment will also be removed.",onNext:function(){return e.confirmDelete()},showCancel:true,onExit:function(){e.confirmDeleteDocument=null}}))};return e}();VerdocsTemplateAttachments.style=verdocsTemplateAttachmentsCss;var verdocsTemplateBuildTabsCss='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:var(--verdocs-primary-font, "Inter", "Barlow", 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}';var HelpIcon='<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>';var CopyIcon='<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>';var STEPS=["attachments","roles","settings","fields","preview"];var VerdocsTemplateBuildTabs=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.stepChanged=createEvent(this,"stepChanged");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.step="preview";this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.onTemplateIdChanged=function(e){console.log("[BUILD_TABS] Template ID changed",e);this.listenToTemplate()};e.prototype.onStepChanged=function(e){console.log("[BUILD_TABS] Step changed",e)};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.endpoint.session){console.log("[BUILD_TABS] Unable to start builder session, must be authenticated");return[2]}if(!this.templateId){this.step="attachments";console.log("[BUILD_TABS] Missing required template ID, forcing view to attachments");return[2]}this.listenToTemplate()}catch(o){console.log("[BUILD_TABS] Error loading template",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.setStep=function(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)};e.prototype.copyTemplateId=function(){var e=this;navigator.clipboard.writeText(this.templateId).then((function(){VerdocsToast("Template ID copied",{style:"success",duration:3e3})})).catch((function(t){var n;console.warn("[BUILD_TABS] Error copying to clipboard",t);(n=e.sdkError)===null||n===void 0?void 0:n.emit(t)}))};e.prototype.render=function(){var e=this;var t,n,o,i,r,s,l,a,c;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var d=(((t=this.template)===null||t===void 0?void 0:t.documents)||[]).length>0;var u=d&&(((n=this.template)===null||n===void 0?void 0:n.roles)||[]).length>0;var f=u&&(((o=this.template)===null||o===void 0?void 0:o.fields)||[]).length>0;var v=Math.max(STEPS.indexOf(this.step),0);if(!f&&v>=4){v=3}if(!u&&v>=3){v=1}if(!d&&v>=1){v=0}return h(Host,null,h("verdocs-tabs",{onSelectTab:function(t){return e.setStep(t)},selectedTab:v,tabs:[{id:"attachments",disabled:false,label:"Attachment(s)"},{id:"roles",disabled:!d,label:"Roles"},{id:"settings",disabled:!u,label:"Settings"},{id:"fields",disabled:!u,label:"Fields"},{id:"preview",disabled:!f,label:"Preview/Send"}]}),this.templateId&&h("div",{class:"info"},h("verdocs-button-panel",{icon:HelpIcon},h("div",{class:"template-details-panel"},h("h6",null,"Template Details"),h("div",{class:"row"},h("label",null,"ID:"),h("div",{class:"value"},this.templateId),h("div",{class:"icon-button",innerHTML:CopyIcon,onClick:function(){return e.copyTemplateId()}})),h("div",{class:"row"},h("label",null,"Name:"),h("div",{class:"value"},(i=this.template)===null||i===void 0?void 0:i.name)),h("div",{class:"row"},h("label",null,"Visibility:"),h("div",{class:"value"},((r=this.template)===null||r===void 0?void 0:r.is_public)?"Public":((s=this.template)===null||s===void 0?void 0:s.is_personal)?"Private":"Shared")),h("div",{class:"row"},h("label",null,"Created:"),h("div",{class:"value"},((l=this.template)===null||l===void 0?void 0:l.counter)?dateFnsExports.format(new Date((a=this.template)===null||a===void 0?void 0:a.created_at),"P p"):"")),h("div",{class:"row"},h("label",null,"Used:"),h("div",{class:"value"},(c=this.template)===null||c===void 0?void 0:c.counter," time(s)"))))))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"],step:["onStepChanged"]}},enumerable:false,configurable:true});return e}();VerdocsTemplateBuildTabs.style=verdocsTemplateBuildTabsCss;var verdocsTemplateFieldsCss="verdocs-template-fields{font-family:var(--verdocs-primary-font, \"Inter\", \"Barlow\", 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 .pages .document-separator{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:10px;padding:12px 20px;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:#33364b;color:white;border-radius:6px;font-size:16px;font-weight:500;margin-top:20px;-webkit-box-shadow:0 2px 4px rgba(0, 0, 0, 0.1);box-shadow:0 2px 4px rgba(0, 0, 0, 0.1)}verdocs-template-fields .pages .document-separator svg{-ms-flex-negative:0;flex-shrink:0}verdocs-template-fields .pages .document-separator:first-child{margin-top:0}verdocs-template-fields #verdocs-template-fields-toolbar{width:100%;height:50px;display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;font-weight:700;padding:0 20px 0 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#f5f5fa;-ms-flex-pack:center;justify-content:center;background:#46497d}verdocs-template-fields #verdocs-template-fields-toolbar>verdocs-select-input{margin:0}verdocs-template-fields #verdocs-template-fields-toolbar svg{width:24px;height:24px}verdocs-template-fields #verdocs-template-fields-toolbar .add-for{margin:0;font-weight:500;color:#f5f5fa}verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{margin:0 20px 0 0}@media all and (max-width: 1000px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;padding:0 10px 0 0}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}@media all and (max-width: 600px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:6px;-moz-column-gap:6px;column-gap:6px}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.6);transform:scale(0.6)}verdocs-template-fields #verdocs-template-fields-toolbar .separator,verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}verdocs-template-fields.placing-attachment{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-checkbox{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-date{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath fill='%23000000' d='M7.6 13.925q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375ZM5.3 22.85q-1.325 0-2.238-.912-.912-.913-.912-2.238V6.3q0-1.325.912-2.238.913-.912 2.238-.912H6v-2h2.575v2h6.85v-2H18v2h.7q1.325 0 2.238.912.912.913.912 2.238v13.4q0 1.325-.912 2.238-.913.912-2.238.912Zm0-3.15h13.4V10H5.3v9.7ZM5.3 8h13.4V6.3H5.3Zm0 0V6.3 8Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-dropdown{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24' stroke-width='1.5' stroke='currentColor'%3E%3Cpath stroke='%23000000' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25' /%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-initial{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-payment{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-radio{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M12 17q2.075 0 3.538-1.463Q17 14.075 17 12t-1.462-3.538Q14.075 7 12 7 9.925 7 8.463 8.462 7 9.925 7 12q0 2.075 1.463 3.537Q9.925 17 12 17Zm0 5.85q-2.275 0-4.25-.85t-3.438-2.312Q2.85 18.225 2 16.25q-.85-1.975-.85-4.25T2 7.75q.85-1.975 2.312-3.438Q5.775 2.85 7.75 2q1.975-.85 4.25-.85t4.25.85q1.975.85 3.438 2.312Q21.15 5.775 22 7.75q.85 1.975.85 4.25T22 16.25q-.85 1.975-2.312 3.438Q18.225 21.15 16.25 22q-1.975.85-4.25.85Zm0-3.15q3.25 0 5.475-2.225Q19.7 15.25 19.7 12q0-3.25-2.225-5.475Q15.25 4.3 12 4.3q-3.25 0-5.475 2.225Q4.3 8.75 4.3 12q0 3.25 2.225 5.475Q8.75 19.7 12 19.7Zm0-7.7Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-signature{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-textarea{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M3.225 20.725v-3.15h11.55v3.15Zm0-4.775V12.8h17.55v3.15Zm0-4.75V8.05h17.55v3.15Zm0-4.775v-3.15h17.55v3.15Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-textbox{cursor:url(\"data:image/svg+xml,%3Csvg width='32' height='15' viewBox='0 0 32 15' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cmask id='path-1-inside-1_1401_24' fill='white'%3E%3Cpath d='M0 0H32V15H0V0Z'/%3E%3C/mask%3E%3Cpath d='M0 0H32V15H0V0Z' fill='%234C56CB' fill-opacity='0.1'/%3E%3Cpath d='M0 0V-1H-1V0H0ZM0 15H-1V16H0V15ZM0 1H32V-1H0V1ZM32 14H0V16H32V14ZM1 15V0H-1V15H1Z' fill='%234C56CB' mask='url(%23path-1-inside-1_1401_24)'/%3E%3Cpath d='M3 11.8V8.65H14.15V11.8H3ZM3 6.65V3.5H20.15V6.65H3Z' fill='%234C56CB'/%3E%3Cline x1='31.5' y1='1' x2='31.5' y2='14' stroke='%234C56CB' stroke-opacity='0.32' stroke-dasharray='1 1'/%3E%3C/svg%3E%0A\") 0 14, pointer}verdocs-template-fields.placing-timestamp{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath fill='%23000000' d='M9 1h6v2H9zm10.03 6.39 1.42-1.42c-.43-.51-.9-.99-1.41-1.41l-1.42 1.42C16.07 4.74 14.12 4 12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9 9-4.03 9-9c0-2.12-.74-4.07-1.97-5.61zM13 14h-2V8h2v6z'%3E%3C/path%3E%3C/svg%3E\") 16 16, pointer}";var iconTextbox='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M3.425 16.15V13h11.15v3.15Zm0-5.15V7.85h17.15V11Z"/></svg>';var iconCheck='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z"/></svg>';var iconRadio='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M12 17q2.075 0 3.538-1.463Q17 14.075 17 12t-1.462-3.538Q14.075 7 12 7 9.925 7 8.463 8.462 7 9.925 7 12q0 2.075 1.463 3.537Q9.925 17 12 17Zm0 5.85q-2.275 0-4.25-.85t-3.438-2.312Q2.85 18.225 2 16.25q-.85-1.975-.85-4.25T2 7.75q.85-1.975 2.312-3.438Q5.775 2.85 7.75 2q1.975-.85 4.25-.85t4.25.85q1.975.85 3.438 2.312Q21.15 5.775 22 7.75q.85 1.975.85 4.25T22 16.25q-.85 1.975-2.312 3.438Q18.225 21.15 16.25 22q-1.975.85-4.25.85Zm0-3.15q3.25 0 5.475-2.225Q19.7 15.25 19.7 12q0-3.25-2.225-5.475Q15.25 4.3 12 4.3q-3.25 0-5.475 2.225Q4.3 8.75 4.3 12q0 3.25 2.225 5.475Q8.75 19.7 12 19.7Zm0-7.7Z"/></svg>';var iconDatepicker='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M7.6 13.925q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375ZM5.3 22.85q-1.325 0-2.238-.912-.912-.913-.912-2.238V6.3q0-1.325.912-2.238.913-.912 2.238-.912H6v-2h2.575v2h6.85v-2H18v2h.7q1.325 0 2.238.912.912.913.912 2.238v13.4q0 1.325-.912 2.238-.913.912-2.238.912Zm0-3.15h13.4V10H5.3v9.7ZM5.3 8h13.4V6.3H5.3Zm0 0V6.3 8Z"/></svg>';var iconSignature='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>';var iconInitial='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path fill="#ffffff" d="M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z"/></svg>';var iconDropdown='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" stroke-width="1.5" stroke="currentColor"><path stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" d="M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25" /></svg>';var iconAttachment='<svg xmlns="http://www.w3.org/2000/svg" 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>';var separator='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.707 14.707"><g><rect x="6.275" y="0" fill="#ffffff7f" width="1" height="15"/></g></svg>';var menuOptions=[{id:"signature",tooltip:"Signature",icon:iconSignature,class:"signature"},{id:"initial",tooltip:"Initials",icon:iconInitial,class:"initial"},{id:"sep1",tooltip:"",icon:separator,class:"separator"},{id:"textbox",tooltip:"Text Box",icon:iconTextbox,class:"textbox"},{id:"checkbox",tooltip:"Check Box",icon:iconCheck,class:"checkbox"},{id:"radio",tooltip:"Radio Button",icon:iconRadio,class:"radio"},{id:"dropdown",tooltip:"Dropdown",icon:iconDropdown,class:"dropdown"},{id:"sep2",tooltip:"",icon:separator,class:"separator"},{id:"date",tooltip:"Date",icon:iconDatepicker,class:"date"},{id:"attachment",tooltip:"Attachment",icon:iconAttachment,class:"attachment"}];var VerdocsTemplateFields=function(){function e(e){registerInstance(this,e);this.sdkError=createEvent(this,"sdkError");this.templateUpdated=createEvent(this,"templateUpdated");this.fieldsUpdated=createEvent(this,"fieldsUpdated");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId=null;this.toolbarTargetId=null;this.placing=null;this.showMustSelectRole=false;this.selectedRoleName="";this.loading=true;this.template=null;this.pageHeights={};this.cachedPageInfo={}}e.prototype.onTemplateIdChanged=function(){this.listenToTemplate()};e.prototype.handleKeyDown=function(e){if(e.key==="Escape"){this.placing=null}};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.templateId){console.log("[FIELDS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[FIELDS] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(o){console.log("[FIELDS] Error with fields session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.componentDidRender=function(){interact.dynamicDrop(true);var e=this.toolbarTargetId?document.getElementById(this.toolbarTargetId):null;var t=document.getElementById("verdocs-template-fields-toolbar");if(e&&t){t.remove();e.append(t)}};e.prototype.componentWillUpdate=function(){var e=this;var t,n;var o=__spreadArray([],((t=this.template)===null||t===void 0?void 0:t.roles)||[],true).sort((function(e,t){var n,o;return((n=e.sequence)!==null&&n!==void 0?n:0)-((o=t.sequence)!==null&&o!==void 0?o:0)}));if(!this.selectedRoleName||!o.find((function(t){return t&&t.name===e.selectedRoleName}))){this.selectedRoleName=((n=o[0])===null||n===void 0?void 0:n.name)||"";console.log("[FIELDS] Selected new role",this.selectedRoleName)}};e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){var n;e.template=t;e.loading=false;if(!e.selectedRoleName){var o=__spreadArray([],t.roles||[],true).sort((function(e,t){var n,o;return((n=e.sequence)!==null&&n!==void 0?n:0)-((o=t.sequence)!==null&&o!==void 0?o:0)}));e.selectedRoleName=((n=o[0])===null||n===void 0?void 0:n.name)||""}}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.attachFieldAttributes=function(e,t,n){var o=this;n.addEventListener("settingsChanged",(function(){var e;(e=o.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:o.endpoint,template:o.template,event:"added-field"})}));n.addEventListener("deleted",(function(){var e;n.remove();(e=o.templateUpdated)===null||e===void 0?void 0:e.emit({endpoint:o.endpoint,template:o.template,event:"updated-field"})}));n.setAttribute("templateid",this.templateId);n.setAttribute("fieldname",t.name);n.setAttribute("documentid",String(e.documentId));n.setAttribute("pageNumber",String(e.pageNumber));n.setAttribute("xScale",String(e.xScale));n.setAttribute("yScale",String(e.yScale));n.setAttribute("name",t.name)};e.prototype.handlePageRendered=function(e){var t=this;var n,o;var i,r;var s=e.detail;console.log("[FIELDS] Page rendered",s.documentId,s.pageNumber,s.xScale,s.yScale);(n=(i=this.cachedPageInfo)[r=s.documentId])!==null&&n!==void 0?n:i[r]={};this.cachedPageInfo[s.documentId][s.pageNumber]=s;this.pageHeights[s.pageNumber]=s.naturalHeight;(((o=this.template)===null||o===void 0?void 0:o.fields)||[]).filter((function(e){return e&&e.page===s.pageNumber})).forEach((function(e){var n=getFieldId(e);var o=document.getElementById(n);if(o){o.setAttribute("fieldname",e.name);o.setAttribute("pagenumber",String(e.page));o.setAttribute("documentid",String(e.document_id));t.makeDraggable(o)}}))};e.prototype.makeDraggable=function(e){interact(e).draggable({listeners:{move:this.handleMoveField.bind(this),end:this.handleMoveEnd.bind(this)}})};e.prototype.handleMoveField=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,o,i,r,s;return __generator(this,(function(l){t=+(e.target.getAttribute("posX")||0);n=+(e.target.getAttribute("posY")||0);o=+(e.target.getAttribute("xScale")||1);i=+(e.target.getAttribute("yScale")||1);r=e.dx/o+t;s=e.dy/i+n;e.target.setAttribute("posX",r);e.target.setAttribute("posy",s);updateCssTransform(e.target,"translate","".concat(r,"px, ").concat(s,"px"));return[2]}))}))};e.prototype.handleMoveEnd=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n,o,i,r,s,l,a,c,d,u,h,f,v,p,g,m,x,b,E,w,S,_,y,I,C,T,D,k,q,M,R,A,P,O,H,L,V,z,Z;return __generator(this,(function(N){switch(N.label){case 0:c=e.target.getAttribute("fieldname");d=(((t=this.template)===null||t===void 0?void 0:t.fields)||[]).find((function(e){return e.name===c}));if(!d){console.log("[FIELDS] Unable to find field",c,e.target);return[2]}u=e.target.getAttribute("pagenumber");h=e.target.getAttribute("documentid");f=this.cachedPageInfo[h][u],v=f.naturalWidth,p=v===void 0?612:v,g=f.naturalHeight,m=g===void 0?792:g,x=f.renderedHeight,b=x===void 0?792:x;E=e.target.getBoundingClientRect();w=e.target.parentElement;S=w.getBoundingClientRect();_=d.width||defaultWidth(d.type);y=d.height||defaultHeight(d.type);I=Math.max(E.left-S.left,0);C=Math.max(b-(S.bottom-E.bottom),0);T=parseInt(u);if(C>b){T=Math.min(T+1,((i=(o=((n=this.template)===null||n===void 0?void 0:n.documents)||[])===null||o===void 0?void 0:o[0])===null||i===void 0?void 0:i.pages)||1);C-=b;b=this.cachedPageInfo[h][T].renderedHeight;console.log("Next page",{newPageNumber:T,newY:C,renderedHeight:b})}else if(C<0){T=Math.max(T-1,1);b=this.cachedPageInfo[h][T].renderedHeight;C+=b;console.log("[FIELDS] Next page",{newPageNumber:T,newY:C,renderedHeight:b})}D=this.viewCoordinatesToPageCoordinates(I,C,h,u,p-_,m-y),k=D.x,q=D.y;N.label=1;case 1:N.trys.push([1,3,,4]);M={x:k,y:q,page:T};return[4,updateField(this.endpoint,this.templateId,c,M)];case 2:R=N.sent();console.log("[FIELDS] Updated",R);A=JSON.parse(JSON.stringify(this.template));P=A.fields.findIndex((function(e){return e.name===c}));if(P>-1){A.fields[P]=R}Store.updateTemplate(this.templateId,A);e.target.removeAttribute("posX");e.target.removeAttribute("posY");removeCssTransform(e.target);O=this.cachedPageInfo[h][u],H=O.xScale,L=H===void 0?1:H,V=O.yScale,z=V===void 0?1:V;setControlStyles(e.target,R,L,z);(r=this.templateUpdated)===null||r===void 0?void 0:r.emit({endpoint:this.endpoint,template:A,event:"updated-field"});return[3,4];case 3:Z=N.sent();VerdocsToast("Error updating field, please try again later",{style:"error"});console.log("[FIELDS] Error updating field",Z);(s=this.sdkError)===null||s===void 0?void 0:s.emit(new SDKError(Z.message,(l=Z.response)===null||l===void 0?void 0:l.status,(a=Z.response)===null||a===void 0?void 0:a.data));e.target.removeAttribute("posX");e.target.removeAttribute("posY");removeCssTransform(e.target);return[3,4];case 4:return[2]}}))}))};e.prototype.generateFieldName=function(e,t){var n;var o=1;var i;do{i="".concat(e,"P").concat(t,"-").concat(o);o++}while((((n=this.template)===null||n===void 0?void 0:n.fields)||[]).some((function(e){return e&&e.name===i})));return i};e.prototype.viewCoordinatesToPageCoordinates=function(e,t,n,o,i,r){var s=this.cachedPageInfo[n][o],l=s.xScale,a=l===void 0?1:l,c=s.yScale,d=c===void 0?1:c,u=s.renderedHeight,h=u===void 0?792:u;var f=Math.floor(Math.min(e/a,i));var v=Math.floor(Math.min(Math.max(h-t,0)/d,r));return{x:f,y:v}};e.prototype.handleClickPage=function(e,t,n){return __awaiter(this,void 0,void 0,(function(){var o,i,r,s,l,a,c,d,u,h,f,v,p,g,m,x;return __generator(this,(function(b){switch(b.label){case 0:if(!this.placing)return[3,2];console.log("Placing field",{documentId:t,pageNumber:n});i=e.offsetX;r=e.offsetY;s=defaultWidth(this.placing);l=defaultHeight(this.placing);a=this.cachedPageInfo[t][n];c=a.naturalWidth,d=c===void 0?612:c,u=a.naturalHeight,h=u===void 0?792:u;f=this.viewCoordinatesToPageCoordinates(i,r,t,n,d-s,h-l);v=Math.floor(f.x);p=Math.floor(f.y);g={name:this.generateFieldName(this.placing,n),role_name:this.selectedRoleName,template_id:this.templateId,document_id:a.documentId,type:this.placing,required:this.placing!=="radio"&&this.placing!=="attachment"&&this.placing!=="checkbox",page:n,validator:null,label:null,default:null,placeholder:null,group:null,settings:{},x:v,y:p,width:s,height:l,multiline:false,readonly:false,options:this.placing==="radio"?[{id:"option-1",label:"Option 1"}]:[]};console.log("[FIELDS] Will save new field",g);return[4,createField(this.endpoint,this.templateId,g)];case 1:m=b.sent();console.log("[FIELDS] Saved field",m);x=JSON.parse(JSON.stringify(this.template));x.fields.push(m);Store.updateTemplate(this.templateId,x);(o=this.templateUpdated)===null||o===void 0?void 0:o.emit({endpoint:this.endpoint,template:x,event:"added-field"});this.placing=null;b.label=2;case 2:return[2]}}))}))};e.prototype.render=function(){var e;var t=this;var n,o,i;if(this.loading){return h(Host,null,h("verdocs-loader",null))}if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}var r=__spreadArray([],((n=this.template)===null||n===void 0?void 0:n.roles)||[],true).sort((function(e,t){var n,o;return((n=e.sequence)!==null&&n!==void 0?n:0)-((o=t.sequence)!==null&&o!==void 0?o:0)}));var s=r.map((function(e){return{value:e.name,label:e.full_name?"".concat(e.name,": ").concat(e.full_name):e.name}}));return h(Host,{class:this.placing?(e={},e["placing-".concat(this.placing)]=true,e):{},onSubmit:function(){}},h("div",{id:"verdocs-template-fields-toolbar"},h("div",{class:"add-for"},"Add field:"),h("verdocs-select-input",{value:this.selectedRoleName,options:s,onInput:function(e){return t.selectedRoleName=e.target.value}}),menuOptions.map((function(e){return h("verdocs-toolbar-icon",{text:e.tooltip,icon:e.icon,class:e.class,onClick:function(){if(e.tooltip){if(t.selectedRoleName){t.placing=e.id}else{t.showMustSelectRole=true}}}})}))),h("div",{class:"pages"},(((o=this.template)===null||o===void 0?void 0:o.documents)||[]).map((function(e){var n=integerSequence(1,e.pages);return n.map((function(n){var o;var i=e.page_sizes[n];return h(Fragment,null,((o=t.template)===null||o===void 0?void 0:o.documents.length)>1&&h("div",{class:"document-separator"},h("div",{innerHTML:DocumentPageIcon}),h("span",null,e.name)),h("verdocs-template-document-page",{templateId:t.templateId,documentId:e.id,pageNumber:n,virtualWidth:(i===null||i===void 0?void 0:i.width)||612,virtualHeight:(i===null||i===void 0?void 0:i.height)||792,disabled:true,editable:true,done:false,onClick:function(o){return t.handleClickPage(o,e.id,n)},onPageRendered:function(e){return t.handlePageRendered(e)},layers:[{name:"page",type:"canvas"},{name:"controls",type:"div"}]}))}))}))),this.showMustSelectRole&&h("verdocs-ok-dialog",{heading:"Unable to add field",message:(((i=this.template)===null||i===void 0?void 0:i.roles)||[]).length>0?"Please select a role before adding fields.":"Please add at least one role before adding fields.",onNext:function(){return t.showMustSelectRole=false}}))};Object.defineProperty(e,"watchers",{get:function(){return{templateId:["onTemplateIdChanged"]}},enumerable:false,configurable:true});return e}();VerdocsTemplateFields.style=verdocsTemplateFieldsCss;
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
- */function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);if(t){o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))}n.push.apply(n,o)}return n}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};if(t%2){ownKeys(Object(n),true).forEach((function(t){_defineProperty(e,t,n[t])}))}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}}return e}function _typeof(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function(e){return typeof e}}else{_typeof=function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}function _defineProperty(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function _extends(){_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n){if(Object.prototype.hasOwnProperty.call(n,o)){e[o]=n[o]}}}return e};return _extends.apply(this,arguments)}function _objectWithoutPropertiesLoose(e,t){if(e==null)return{};var n={};var o=Object.keys(e);var i,r;for(r=0;r<o.length;r++){i=o[r];if(t.indexOf(i)>=0)continue;n[i]=e[i]}return n}function _objectWithoutProperties(e,t){if(e==null)return{};var n=_objectWithoutPropertiesLoose(e,t);var o,i;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++){o=r[i];if(t.indexOf(o)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,o))continue;n[o]=e[o]}}return n}var version="1.15.6";function userAgent(e){if(typeof window!=="undefined"&&window.navigator){return!!navigator.userAgent.match(e)}}var IE11OrLess=userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);var Edge=userAgent(/Edge/i);var FireFox=userAgent(/firefox/i);var Safari=userAgent(/safari/i)&&!userAgent(/chrome/i)&&!userAgent(/android/i);var IOS=userAgent(/iP(ad|od|hone)/i);var ChromeForAndroid=userAgent(/chrome/i)&&userAgent(/android/i);var captureMode={capture:false,passive:false};function on(e,t,n){e.addEventListener(t,n,!IE11OrLess&&captureMode)}function off(e,t,n){e.removeEventListener(t,n,!IE11OrLess&&captureMode)}function matches(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 getParentOrHost(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function closest(e,t,n,o){if(e){n=n||document;do{if(t!=null&&(t[0]===">"?e.parentNode===n&&matches(e,t):matches(e,t))||o&&e===n){return e}if(e===n)break}while(e=getParentOrHost(e))}return null}var R_SPACE=/\s+/g;function toggleClass(e,t,n){if(e&&t){if(e.classList){e.classList[n?"add":"remove"](t)}else{var o=(" "+e.className+" ").replace(R_SPACE," ").replace(" "+t+" "," ");e.className=(o+(n?" "+t:"")).replace(R_SPACE," ")}}}function css(e,t,n){var o=e&&e.style;if(o){if(n===void 0){if(document.defaultView&&document.defaultView.getComputedStyle){n=document.defaultView.getComputedStyle(e,"")}else if(e.currentStyle){n=e.currentStyle}return t===void 0?n:n[t]}else{if(!(t in o)&&t.indexOf("webkit")===-1){t="-webkit-"+t}o[t]=n+(typeof n==="string"?"":"px")}}}function matrix(e,t){var n="";if(typeof e==="string"){n=e}else{do{var o=css(e,"transform");if(o&&o!=="none"){n=o+" "+n}}while(!t&&(e=e.parentNode))}var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function find(e,t,n){if(e){var o=e.getElementsByTagName(t),i=0,r=o.length;if(n){for(;i<r;i++){n(o[i],i)}}return o}return[]}function getWindowScrollingElement(){var e=document.scrollingElement;if(e){return e}else{return document.documentElement}}function getRect(e,t,n,o,i){if(!e.getBoundingClientRect&&e!==window)return;var r,s,l,a,c,d,u;if(e!==window&&e.parentNode&&e!==getWindowScrollingElement()){r=e.getBoundingClientRect();s=r.top;l=r.left;a=r.bottom;c=r.right;d=r.height;u=r.width}else{s=0;l=0;a=window.innerHeight;c=window.innerWidth;d=window.innerHeight;u=window.innerWidth}if((t||n)&&e!==window){i=i||e.parentNode;if(!IE11OrLess){do{if(i&&i.getBoundingClientRect&&(css(i,"transform")!=="none"||n&&css(i,"position")!=="static")){var h=i.getBoundingClientRect();s-=h.top+parseInt(css(i,"border-top-width"));l-=h.left+parseInt(css(i,"border-left-width"));a=s+r.height;c=l+r.width;break}}while(i=i.parentNode)}}if(o&&e!==window){var f=matrix(i||e),v=f&&f.a,p=f&&f.d;if(f){s/=p;l/=v;u/=v;d/=p;a=s+d;c=l+u}}return{top:s,left:l,bottom:a,right:c,width:u,height:d}}function isScrolledPast(e,t,n){var o=getParentAutoScrollElement(e,true),i=getRect(e)[t];while(o){var r=getRect(o)[n],s=void 0;{s=i>=r}if(!s)return o;if(o===getWindowScrollingElement())break;o=getParentAutoScrollElement(o,false)}return false}function getChild(e,t,n,o){var i=0,r=0,s=e.children;while(r<s.length){if(s[r].style.display!=="none"&&s[r]!==Sortable.ghost&&(o||s[r]!==Sortable.dragged)&&closest(s[r],n.draggable,e,false)){if(i===t){return s[r]}i++}r++}return null}function lastChild(e,t){var n=e.lastElementChild;while(n&&(n===Sortable.ghost||css(n,"display")==="none"||t&&!matches(n,t))){n=n.previousElementSibling}return n||null}function index(e,t){var n=0;if(!e||!e.parentNode){return-1}while(e=e.previousElementSibling){if(e.nodeName.toUpperCase()!=="TEMPLATE"&&e!==Sortable.clone&&(!t||matches(e,t))){n++}}return n}function getRelativeScrollOffset(e){var t=0,n=0,o=getWindowScrollingElement();if(e){do{var i=matrix(e),r=i.a,s=i.d;t+=e.scrollLeft*r;n+=e.scrollTop*s}while(e!==o&&(e=e.parentNode))}return[t,n]}function indexOfObject(e,t){for(var n in e){if(!e.hasOwnProperty(n))continue;for(var o in t){if(t.hasOwnProperty(o)&&t[o]===e[n][o])return Number(n)}}return-1}function getParentAutoScrollElement(e,t){if(!e||!e.getBoundingClientRect)return getWindowScrollingElement();var n=e;var o=false;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=css(n);if(n.clientWidth<n.scrollWidth&&(i.overflowX=="auto"||i.overflowX=="scroll")||n.clientHeight<n.scrollHeight&&(i.overflowY=="auto"||i.overflowY=="scroll")){if(!n.getBoundingClientRect||n===document.body)return getWindowScrollingElement();if(o||t)return n;o=true}}}while(n=n.parentNode);return getWindowScrollingElement()}function extend(e,t){if(e&&t){for(var n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}}return e}function isRectEqual(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 _throttleTimeout;function throttle(e,t){return function(){if(!_throttleTimeout){var n=arguments,o=this;if(n.length===1){e.call(o,n[0])}else{e.apply(o,n)}_throttleTimeout=setTimeout((function(){_throttleTimeout=void 0}),t)}}}function cancelThrottle(){clearTimeout(_throttleTimeout);_throttleTimeout=void 0}function scrollBy(e,t,n){e.scrollLeft+=t;e.scrollTop+=n}function clone(e){var t=window.Polymer;var n=window.jQuery||window.Zepto;if(t&&t.dom){return t.dom(e).cloneNode(true)}else if(n){return n(e).clone(true)[0]}else{return e.cloneNode(true)}}function getChildContainingRectFromElement(e,t,n){var o={};Array.from(e.children).forEach((function(i){var r,s,l,a;if(!closest(i,t.draggable,e,false)||i.animated||i===n)return;var c=getRect(i);o.left=Math.min((r=o.left)!==null&&r!==void 0?r:Infinity,c.left);o.top=Math.min((s=o.top)!==null&&s!==void 0?s:Infinity,c.top);o.right=Math.max((l=o.right)!==null&&l!==void 0?l:-Infinity,c.right);o.bottom=Math.max((a=o.bottom)!==null&&a!==void 0?a:-Infinity,c.bottom)}));o.width=o.right-o.left;o.height=o.bottom-o.top;o.x=o.left;o.y=o.top;return o}var expando="Sortable"+(new Date).getTime();function AnimationStateManager(){var e=[],t;return{captureAnimationState:function t(){e=[];if(!this.options.animation)return;var n=[].slice.call(this.el.children);n.forEach((function(t){if(css(t,"display")==="none"||t===Sortable.ghost)return;e.push({target:t,rect:getRect(t)});var n=_objectSpread2({},e[e.length-1].rect);if(t.thisAnimationDuration){var o=matrix(t,true);if(o){n.top-=o.f;n.left-=o.e}}t.fromRect=n}))},addAnimationState:function t(n){e.push(n)},removeAnimationState:function t(n){e.splice(indexOfObject(e,{target:n}),1)},animateAll:function n(o){var i=this;if(!this.options.animation){clearTimeout(t);if(typeof o==="function")o();return}var r=false,s=0;e.forEach((function(e){var t=0,n=e.target,o=n.fromRect,l=getRect(n),a=n.prevFromRect,c=n.prevToRect,d=e.rect,u=matrix(n,true);if(u){l.top-=u.f;l.left-=u.e}n.toRect=l;if(n.thisAnimationDuration){if(isRectEqual(a,l)&&!isRectEqual(o,l)&&(d.top-l.top)/(d.left-l.left)===(o.top-l.top)/(o.left-l.left)){t=calculateRealTime(d,a,c,i.options)}}if(!isRectEqual(l,o)){n.prevFromRect=o;n.prevToRect=l;if(!t){t=i.options.animation}i.animate(n,d,l,t)}if(t){r=true;s=Math.max(s,t);clearTimeout(n.animationResetTimer);n.animationResetTimer=setTimeout((function(){n.animationTime=0;n.prevFromRect=null;n.fromRect=null;n.prevToRect=null;n.thisAnimationDuration=null}),t);n.thisAnimationDuration=t}}));clearTimeout(t);if(!r){if(typeof o==="function")o()}else{t=setTimeout((function(){if(typeof o==="function")o()}),s)}e=[]},animate:function e(t,n,o,i){if(i){css(t,"transition","");css(t,"transform","");var r=matrix(this.el),s=r&&r.a,l=r&&r.d,a=(n.left-o.left)/(s||1),c=(n.top-o.top)/(l||1);t.animatingX=!!a;t.animatingY=!!c;css(t,"transform","translate3d("+a+"px,"+c+"px,0)");this.forRepaintDummy=repaint(t);css(t,"transition","transform "+i+"ms"+(this.options.easing?" "+this.options.easing:""));css(t,"transform","translate3d(0,0,0)");typeof t.animated==="number"&&clearTimeout(t.animated);t.animated=setTimeout((function(){css(t,"transition","");css(t,"transform","");t.animated=false;t.animatingX=false;t.animatingY=false}),i)}}}}function repaint(e){return e.offsetWidth}function calculateRealTime(e,t,n,o){return Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))/Math.sqrt(Math.pow(t.top-n.top,2)+Math.pow(t.left-n.left,2))*o.animation}var plugins=[];var defaults={initializeByDefault:true};var PluginManager={mount:function e(t){for(var n in defaults){if(defaults.hasOwnProperty(n)&&!(n in t)){t[n]=defaults[n]}}plugins.forEach((function(e){if(e.pluginName===t.pluginName){throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}}));plugins.push(t)},pluginEvent:function e(t,n,o){var i=this;this.eventCanceled=false;o.cancel=function(){i.eventCanceled=true};var r=t+"Global";plugins.forEach((function(e){if(!n[e.pluginName])return;if(n[e.pluginName][r]){n[e.pluginName][r](_objectSpread2({sortable:n},o))}if(n.options[e.pluginName]&&n[e.pluginName][t]){n[e.pluginName][t](_objectSpread2({sortable:n},o))}}))},initializePlugins:function e(t,n,o,i){plugins.forEach((function(e){var i=e.pluginName;if(!t.options[i]&&!e.initializeByDefault)return;var r=new e(t,n,t.options);r.sortable=t;r.options=t.options;t[i]=r;_extends(o,r.defaults)}));for(var r in t.options){if(!t.options.hasOwnProperty(r))continue;var s=this.modifyOption(t,r,t.options[r]);if(typeof s!=="undefined"){t.options[r]=s}}},getEventProperties:function e(t,n){var o={};plugins.forEach((function(e){if(typeof e.eventProperties!=="function")return;_extends(o,e.eventProperties.call(n[e.pluginName],t))}));return o},modifyOption:function e(t,n,o){var i;plugins.forEach((function(e){if(!t[e.pluginName])return;if(e.optionListeners&&typeof e.optionListeners[n]==="function"){i=e.optionListeners[n].call(t[e.pluginName],o)}}));return i}};function dispatchEvent(e){var t=e.sortable,n=e.rootEl,o=e.name,i=e.targetEl,r=e.cloneEl,s=e.toEl,l=e.fromEl,a=e.oldIndex,c=e.newIndex,d=e.oldDraggableIndex,u=e.newDraggableIndex,h=e.originalEvent,f=e.putSortable,v=e.extraEventProperties;t=t||n&&n[expando];if(!t)return;var p,g=t.options,m="on"+o.charAt(0).toUpperCase()+o.substr(1);if(window.CustomEvent&&!IE11OrLess&&!Edge){p=new CustomEvent(o,{bubbles:true,cancelable:true})}else{p=document.createEvent("Event");p.initEvent(o,true,true)}p.to=s||n;p.from=l||n;p.item=i||n;p.clone=r;p.oldIndex=a;p.newIndex=c;p.oldDraggableIndex=d;p.newDraggableIndex=u;p.originalEvent=h;p.pullMode=f?f.lastPutMode:undefined;var b=_objectSpread2(_objectSpread2({},v),PluginManager.getEventProperties(o,t));for(var x in b){p[x]=b[x]}if(n){n.dispatchEvent(p)}if(g[m]){g[m].call(t,p)}}var _excluded=["evt"];var pluginEvent=function e(t,n){var o=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=o.evt,r=_objectWithoutProperties(o,_excluded);PluginManager.pluginEvent.bind(Sortable)(t,n,_objectSpread2({dragEl:dragEl,parentEl:parentEl,ghostEl:ghostEl,rootEl:rootEl,nextEl:nextEl,lastDownEl:lastDownEl,cloneEl:cloneEl,cloneHidden:cloneHidden,dragStarted:moved,putSortable:putSortable,activeSortable:Sortable.active,originalEvent:i,oldIndex:oldIndex,oldDraggableIndex:oldDraggableIndex,newIndex:newIndex,newDraggableIndex:newDraggableIndex,hideGhostForTarget:_hideGhostForTarget,unhideGhostForTarget:_unhideGhostForTarget,cloneNowHidden:function e(){cloneHidden=true},cloneNowShown:function e(){cloneHidden=false},dispatchSortableEvent:function e(t){_dispatchEvent({sortable:n,name:t,originalEvent:i})}},r))};function _dispatchEvent(e){dispatchEvent(_objectSpread2({putSortable:putSortable,cloneEl:cloneEl,targetEl:dragEl,rootEl:rootEl,oldIndex:oldIndex,oldDraggableIndex:oldDraggableIndex,newIndex:newIndex,newDraggableIndex:newDraggableIndex},e))}var dragEl,parentEl,ghostEl,rootEl,nextEl,lastDownEl,cloneEl,cloneHidden,oldIndex,newIndex,oldDraggableIndex,newDraggableIndex,activeGroup,putSortable,awaitingDragStarted=false,ignoreNextClick=false,sortables=[],tapEvt,touchEvt,lastDx,lastDy,tapDistanceLeft,tapDistanceTop,moved,lastTarget,lastDirection,pastFirstInvertThresh=false,isCircumstantialInvert=false,targetMoveDistance,ghostRelativeParent,ghostRelativeParentInitialScroll=[],_silent=false,savedInputChecked=[];var documentExists=typeof document!=="undefined",PositionGhostAbsolutely=IOS,CSSFloatProperty=Edge||IE11OrLess?"cssFloat":"float",supportDraggable=documentExists&&!ChromeForAndroid&&!IOS&&"draggable"in document.createElement("div"),supportCssPointerEvents=function(){if(!documentExists)return;if(IE11OrLess){return false}var e=document.createElement("x");e.style.cssText="pointer-events:auto";return e.style.pointerEvents==="auto"}(),_detectDirection=function e(t,n){var o=css(t),i=parseInt(o.width)-parseInt(o.paddingLeft)-parseInt(o.paddingRight)-parseInt(o.borderLeftWidth)-parseInt(o.borderRightWidth),r=getChild(t,0,n),s=getChild(t,1,n),l=r&&css(r),a=s&&css(s),c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+getRect(r).width,d=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+getRect(s).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(r&&l["float"]&&l["float"]!=="none"){var u=l["float"]==="left"?"left":"right";return s&&(a.clear==="both"||a.clear===u)?"vertical":"horizontal"}return r&&(l.display==="block"||l.display==="flex"||l.display==="table"||l.display==="grid"||c>=i&&o[CSSFloatProperty]==="none"||s&&o[CSSFloatProperty]==="none"&&c+d>i)?"vertical":"horizontal"},_dragElInRowColumn=function e(t,n,o){var i=o?t.left:t.top,r=o?t.right:t.bottom,s=o?t.width:t.height,l=o?n.left:n.top,a=o?n.right:n.bottom,c=o?n.width:n.height;return i===l||r===a||i+s/2===l+c/2},_detectNearestEmptySortable=function e(t,n){var o;sortables.some((function(e){var i=e[expando].options.emptyInsertThreshold;if(!i||lastChild(e))return;var r=getRect(e),s=t>=r.left-i&&t<=r.right+i,l=n>=r.top-i&&n<=r.bottom+i;if(s&&l){return o=e}}));return o},_prepareGroup=function e(t){function n(e,t){return function(o,i,r,s){var l=o.options.group.name&&i.options.group.name&&o.options.group.name===i.options.group.name;if(e==null&&(t||l)){return true}else if(e==null||e===false){return false}else if(t&&e==="clone"){return e}else if(typeof e==="function"){return n(e(o,i,r,s),t)(o,i,r,s)}else{var a=(t?o:i).options.group.name;return e===true||typeof e==="string"&&e===a||e.join&&e.indexOf(a)>-1}}}var o={};var i=t.group;if(!i||_typeof(i)!="object"){i={name:i}}o.name=i.name;o.checkPull=n(i.pull,true);o.checkPut=n(i.put);o.revertClone=i.revertClone;t.group=o},_hideGhostForTarget=function e(){if(!supportCssPointerEvents&&ghostEl){css(ghostEl,"display","none")}},_unhideGhostForTarget=function e(){if(!supportCssPointerEvents&&ghostEl){css(ghostEl,"display","")}};if(documentExists&&!ChromeForAndroid){document.addEventListener("click",(function(e){if(ignoreNextClick){e.preventDefault();e.stopPropagation&&e.stopPropagation();e.stopImmediatePropagation&&e.stopImmediatePropagation();ignoreNextClick=false;return false}}),true)}var nearestEmptyInsertDetectEvent=function e(t){if(dragEl){t=t.touches?t.touches[0]:t;var n=_detectNearestEmptySortable(t.clientX,t.clientY);if(n){var o={};for(var i in t){if(t.hasOwnProperty(i)){o[i]=t[i]}}o.target=o.rootEl=n;o.preventDefault=void 0;o.stopPropagation=void 0;n[expando]._onDragOver(o)}}};var _checkOutsideTargetEl=function e(t){if(dragEl){dragEl.parentNode[expando]._isOutsideThisEl(t.target)}};function Sortable(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=_extends({},t);e[expando]=this;var n={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 _detectDirection(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,n){t.setData("Text",n.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:Sortable.supportPointer!==false&&"PointerEvent"in window&&(!Safari||IOS),emptyInsertThreshold:5};PluginManager.initializePlugins(this,e,n);for(var o in n){!(o in t)&&(t[o]=n[o])}_prepareGroup(t);for(var i in this){if(i.charAt(0)==="_"&&typeof this[i]==="function"){this[i]=this[i].bind(this)}}this.nativeDraggable=t.forceFallback?false:supportDraggable;if(this.nativeDraggable){this.options.touchStartThreshold=1}if(t.supportPointer){on(e,"pointerdown",this._onTapStart)}else{on(e,"mousedown",this._onTapStart);on(e,"touchstart",this._onTapStart)}if(this.nativeDraggable){on(e,"dragover",this);on(e,"dragenter",this)}sortables.push(this.el);t.store&&t.store.get&&this.sort(t.store.get(this)||[]);_extends(this,AnimationStateManager())}Sortable.prototype={constructor:Sortable,_isOutsideThisEl:function e(t){if(!this.el.contains(t)&&t!==this.el){lastTarget=null}},_getDirection:function e(t,n){return typeof this.options.direction==="function"?this.options.direction.call(this,t,n,dragEl):this.options.direction},_onTapStart:function e(t){if(!t.cancelable)return;var n=this,o=this.el,i=this.options,r=i.preventOnFilter,s=t.type,l=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,a=(l||t).target,c=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||a,d=i.filter;_saveInputCheckedState(o);if(dragEl){return}if(/mousedown|pointerdown/.test(s)&&t.button!==0||i.disabled){return}if(c.isContentEditable){return}if(!this.nativeDraggable&&Safari&&a&&a.tagName.toUpperCase()==="SELECT"){return}a=closest(a,i.draggable,o,false);if(a&&a.animated){return}if(lastDownEl===a){return}oldIndex=index(a);oldDraggableIndex=index(a,i.draggable);if(typeof d==="function"){if(d.call(this,t,a,this)){_dispatchEvent({sortable:n,rootEl:c,name:"filter",targetEl:a,toEl:o,fromEl:o});pluginEvent("filter",n,{evt:t});r&&t.preventDefault();return}}else if(d){d=d.split(",").some((function(e){e=closest(c,e.trim(),o,false);if(e){_dispatchEvent({sortable:n,rootEl:e,name:"filter",targetEl:a,fromEl:o,toEl:o});pluginEvent("filter",n,{evt:t});return true}}));if(d){r&&t.preventDefault();return}}if(i.handle&&!closest(c,i.handle,o,false)){return}this._prepareDragStart(t,l,a)},_prepareDragStart:function e(t,n,o){var i=this,r=i.el,s=i.options,l=r.ownerDocument,a;if(o&&!dragEl&&o.parentNode===r){var c=getRect(o);rootEl=r;dragEl=o;parentEl=dragEl.parentNode;nextEl=dragEl.nextSibling;lastDownEl=o;activeGroup=s.group;Sortable.dragged=dragEl;tapEvt={target:dragEl,clientX:(n||t).clientX,clientY:(n||t).clientY};tapDistanceLeft=tapEvt.clientX-c.left;tapDistanceTop=tapEvt.clientY-c.top;this._lastX=(n||t).clientX;this._lastY=(n||t).clientY;dragEl.style["will-change"]="all";a=function e(){pluginEvent("delayEnded",i,{evt:t});if(Sortable.eventCanceled){i._onDrop();return}i._disableDelayedDragEvents();if(!FireFox&&i.nativeDraggable){dragEl.draggable=true}i._triggerDragStart(t,n);_dispatchEvent({sortable:i,name:"choose",originalEvent:t});toggleClass(dragEl,s.chosenClass,true)};s.ignore.split(",").forEach((function(e){find(dragEl,e.trim(),_disableDraggable)}));on(l,"dragover",nearestEmptyInsertDetectEvent);on(l,"mousemove",nearestEmptyInsertDetectEvent);on(l,"touchmove",nearestEmptyInsertDetectEvent);if(s.supportPointer){on(l,"pointerup",i._onDrop);!this.nativeDraggable&&on(l,"pointercancel",i._onDrop)}else{on(l,"mouseup",i._onDrop);on(l,"touchend",i._onDrop);on(l,"touchcancel",i._onDrop)}if(FireFox&&this.nativeDraggable){this.options.touchStartThreshold=4;dragEl.draggable=true}pluginEvent("delayStart",this,{evt:t});if(s.delay&&(!s.delayOnTouchOnly||n)&&(!this.nativeDraggable||!(Edge||IE11OrLess))){if(Sortable.eventCanceled){this._onDrop();return}if(s.supportPointer){on(l,"pointerup",i._disableDelayedDrag);on(l,"pointercancel",i._disableDelayedDrag)}else{on(l,"mouseup",i._disableDelayedDrag);on(l,"touchend",i._disableDelayedDrag);on(l,"touchcancel",i._disableDelayedDrag)}on(l,"mousemove",i._delayedDragTouchMoveHandler);on(l,"touchmove",i._delayedDragTouchMoveHandler);s.supportPointer&&on(l,"pointermove",i._delayedDragTouchMoveHandler);i._dragStartTimer=setTimeout(a,s.delay)}else{a()}}},_delayedDragTouchMoveHandler:function e(t){var n=t.touches?t.touches[0]:t;if(Math.max(Math.abs(n.clientX-this._lastX),Math.abs(n.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))){this._disableDelayedDrag()}},_disableDelayedDrag:function e(){dragEl&&_disableDraggable(dragEl);clearTimeout(this._dragStartTimer);this._disableDelayedDragEvents()},_disableDelayedDragEvents:function e(){var t=this.el.ownerDocument;off(t,"mouseup",this._disableDelayedDrag);off(t,"touchend",this._disableDelayedDrag);off(t,"touchcancel",this._disableDelayedDrag);off(t,"pointerup",this._disableDelayedDrag);off(t,"pointercancel",this._disableDelayedDrag);off(t,"mousemove",this._delayedDragTouchMoveHandler);off(t,"touchmove",this._delayedDragTouchMoveHandler);off(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function e(t,n){n=n||t.pointerType=="touch"&&t;if(!this.nativeDraggable||n){if(this.options.supportPointer){on(document,"pointermove",this._onTouchMove)}else if(n){on(document,"touchmove",this._onTouchMove)}else{on(document,"mousemove",this._onTouchMove)}}else{on(dragEl,"dragend",this);on(rootEl,"dragstart",this._onDragStart)}try{if(document.selection){_nextTick((function(){document.selection.empty()}))}else{window.getSelection().removeAllRanges()}}catch(e){}},_dragStarted:function e(t,n){awaitingDragStarted=false;if(rootEl&&dragEl){pluginEvent("dragStarted",this,{evt:n});if(this.nativeDraggable){on(document,"dragover",_checkOutsideTargetEl)}var o=this.options;!t&&toggleClass(dragEl,o.dragClass,false);toggleClass(dragEl,o.ghostClass,true);Sortable.active=this;t&&this._appendGhost();_dispatchEvent({sortable:this,name:"start",originalEvent:n})}else{this._nulling()}},_emulateDragOver:function e(){if(touchEvt){this._lastX=touchEvt.clientX;this._lastY=touchEvt.clientY;_hideGhostForTarget();var t=document.elementFromPoint(touchEvt.clientX,touchEvt.clientY);var n=t;while(t&&t.shadowRoot){t=t.shadowRoot.elementFromPoint(touchEvt.clientX,touchEvt.clientY);if(t===n)break;n=t}dragEl.parentNode[expando]._isOutsideThisEl(t);if(n){do{if(n[expando]){var o=void 0;o=n[expando]._onDragOver({clientX:touchEvt.clientX,clientY:touchEvt.clientY,target:t,rootEl:n});if(o&&!this.options.dragoverBubble){break}}t=n}while(n=getParentOrHost(n))}_unhideGhostForTarget()}},_onTouchMove:function e(t){if(tapEvt){var n=this.options,o=n.fallbackTolerance,i=n.fallbackOffset,r=t.touches?t.touches[0]:t,s=ghostEl&&matrix(ghostEl,true),l=ghostEl&&s&&s.a,a=ghostEl&&s&&s.d,c=PositionGhostAbsolutely&&ghostRelativeParent&&getRelativeScrollOffset(ghostRelativeParent),d=(r.clientX-tapEvt.clientX+i.x)/(l||1)+(c?c[0]-ghostRelativeParentInitialScroll[0]:0)/(l||1),u=(r.clientY-tapEvt.clientY+i.y)/(a||1)+(c?c[1]-ghostRelativeParentInitialScroll[1]:0)/(a||1);if(!Sortable.active&&!awaitingDragStarted){if(o&&Math.max(Math.abs(r.clientX-this._lastX),Math.abs(r.clientY-this._lastY))<o){return}this._onDragStart(t,true)}if(ghostEl){if(s){s.e+=d-(lastDx||0);s.f+=u-(lastDy||0)}else{s={a:1,b:0,c:0,d:1,e:d,f:u}}var h="matrix(".concat(s.a,",").concat(s.b,",").concat(s.c,",").concat(s.d,",").concat(s.e,",").concat(s.f,")");css(ghostEl,"webkitTransform",h);css(ghostEl,"mozTransform",h);css(ghostEl,"msTransform",h);css(ghostEl,"transform",h);lastDx=d;lastDy=u;touchEvt=r}t.cancelable&&t.preventDefault()}},_appendGhost:function e(){if(!ghostEl){var t=this.options.fallbackOnBody?document.body:rootEl,n=getRect(dragEl,true,PositionGhostAbsolutely,true,t),o=this.options;if(PositionGhostAbsolutely){ghostRelativeParent=t;while(css(ghostRelativeParent,"position")==="static"&&css(ghostRelativeParent,"transform")==="none"&&ghostRelativeParent!==document){ghostRelativeParent=ghostRelativeParent.parentNode}if(ghostRelativeParent!==document.body&&ghostRelativeParent!==document.documentElement){if(ghostRelativeParent===document)ghostRelativeParent=getWindowScrollingElement();n.top+=ghostRelativeParent.scrollTop;n.left+=ghostRelativeParent.scrollLeft}else{ghostRelativeParent=getWindowScrollingElement()}ghostRelativeParentInitialScroll=getRelativeScrollOffset(ghostRelativeParent)}ghostEl=dragEl.cloneNode(true);toggleClass(ghostEl,o.ghostClass,false);toggleClass(ghostEl,o.fallbackClass,true);toggleClass(ghostEl,o.dragClass,true);css(ghostEl,"transition","");css(ghostEl,"transform","");css(ghostEl,"box-sizing","border-box");css(ghostEl,"margin",0);css(ghostEl,"top",n.top);css(ghostEl,"left",n.left);css(ghostEl,"width",n.width);css(ghostEl,"height",n.height);css(ghostEl,"opacity","0.8");css(ghostEl,"position",PositionGhostAbsolutely?"absolute":"fixed");css(ghostEl,"zIndex","100000");css(ghostEl,"pointerEvents","none");Sortable.ghost=ghostEl;t.appendChild(ghostEl);css(ghostEl,"transform-origin",tapDistanceLeft/parseInt(ghostEl.style.width)*100+"% "+tapDistanceTop/parseInt(ghostEl.style.height)*100+"%")}},_onDragStart:function e(t,n){var o=this;var i=t.dataTransfer;var r=o.options;pluginEvent("dragStart",this,{evt:t});if(Sortable.eventCanceled){this._onDrop();return}pluginEvent("setupClone",this);if(!Sortable.eventCanceled){cloneEl=clone(dragEl);cloneEl.removeAttribute("id");cloneEl.draggable=false;cloneEl.style["will-change"]="";this._hideClone();toggleClass(cloneEl,this.options.chosenClass,false);Sortable.clone=cloneEl}o.cloneId=_nextTick((function(){pluginEvent("clone",o);if(Sortable.eventCanceled)return;if(!o.options.removeCloneOnHide){rootEl.insertBefore(cloneEl,dragEl)}o._hideClone();_dispatchEvent({sortable:o,name:"clone"})}));!n&&toggleClass(dragEl,r.dragClass,true);if(n){ignoreNextClick=true;o._loopId=setInterval(o._emulateDragOver,50)}else{off(document,"mouseup",o._onDrop);off(document,"touchend",o._onDrop);off(document,"touchcancel",o._onDrop);if(i){i.effectAllowed="move";r.setData&&r.setData.call(o,i,dragEl)}on(document,"drop",o);css(dragEl,"transform","translateZ(0)")}awaitingDragStarted=true;o._dragStartId=_nextTick(o._dragStarted.bind(o,n,t));on(document,"selectstart",o);moved=true;window.getSelection().removeAllRanges();if(Safari){css(document.body,"user-select","none")}},_onDragOver:function e(t){var n=this.el,o=t.target,i,r,s,l=this.options,a=l.group,c=Sortable.active,d=activeGroup===a,u=l.sort,h=putSortable||c,f,v=this,p=false;if(_silent)return;function g(e,l){pluginEvent(e,v,_objectSpread2({evt:t,isOwner:d,axis:f?"vertical":"horizontal",revert:s,dragRect:i,targetRect:r,canSort:u,fromSortable:h,target:o,completed:b,onMove:function e(o,r){return _onMove(rootEl,n,dragEl,i,o,getRect(o),t,r)},changed:x},l))}function m(){g("dragOverAnimationCapture");v.captureAnimationState();if(v!==h){h.captureAnimationState()}}function b(e){g("dragOverCompleted",{insertion:e});if(e){if(d){c._hideClone()}else{c._showClone(v)}if(v!==h){toggleClass(dragEl,putSortable?putSortable.options.ghostClass:c.options.ghostClass,false);toggleClass(dragEl,l.ghostClass,true)}if(putSortable!==v&&v!==Sortable.active){putSortable=v}else if(v===Sortable.active&&putSortable){putSortable=null}if(h===v){v._ignoreWhileAnimating=o}v.animateAll((function(){g("dragOverAnimationComplete");v._ignoreWhileAnimating=null}));if(v!==h){h.animateAll();h._ignoreWhileAnimating=null}}if(o===dragEl&&!dragEl.animated||o===n&&!o.animated){lastTarget=null}if(!l.dragoverBubble&&!t.rootEl&&o!==document){dragEl.parentNode[expando]._isOutsideThisEl(t.target);!e&&nearestEmptyInsertDetectEvent(t)}!l.dragoverBubble&&t.stopPropagation&&t.stopPropagation();return p=true}function x(){newIndex=index(dragEl);newDraggableIndex=index(dragEl,l.draggable);_dispatchEvent({sortable:v,name:"change",toEl:n,newIndex:newIndex,newDraggableIndex:newDraggableIndex,originalEvent:t})}if(t.preventDefault!==void 0){t.cancelable&&t.preventDefault()}o=closest(o,l.draggable,n,true);g("dragOver");if(Sortable.eventCanceled)return p;if(dragEl.contains(t.target)||o.animated&&o.animatingX&&o.animatingY||v._ignoreWhileAnimating===o){return b(false)}ignoreNextClick=false;if(c&&!l.disabled&&(d?u||(s=parentEl!==rootEl):putSortable===this||(this.lastPutMode=activeGroup.checkPull(this,c,dragEl,t))&&a.checkPut(this,c,dragEl,t))){f=this._getDirection(t,o)==="vertical";i=getRect(dragEl);g("dragOverValid");if(Sortable.eventCanceled)return p;if(s){parentEl=rootEl;m();this._hideClone();g("revert");if(!Sortable.eventCanceled){if(nextEl){rootEl.insertBefore(dragEl,nextEl)}else{rootEl.appendChild(dragEl)}}return b(true)}var E=lastChild(n,l.draggable);if(!E||_ghostIsLast(t,f,this)&&!E.animated){if(E===dragEl){return b(false)}if(E&&n===t.target){o=E}if(o){r=getRect(o)}if(_onMove(rootEl,n,dragEl,i,o,r,t,!!o)!==false){m();if(E&&E.nextSibling){n.insertBefore(dragEl,E.nextSibling)}else{n.appendChild(dragEl)}parentEl=n;x();return b(true)}}else if(E&&_ghostIsFirst(t,f,this)){var w=getChild(n,0,l,true);if(w===dragEl){return b(false)}o=w;r=getRect(o);if(_onMove(rootEl,n,dragEl,i,o,r,t,false)!==false){m();n.insertBefore(dragEl,w);parentEl=n;x();return b(true)}}else if(o.parentNode===n){r=getRect(o);var S=0,_,y=dragEl.parentNode!==n,I=!_dragElInRowColumn(dragEl.animated&&dragEl.toRect||i,o.animated&&o.toRect||r,f),C=f?"top":"left",T=isScrolledPast(o,"top","top")||isScrolledPast(dragEl,"top","top"),D=T?T.scrollTop:void 0;if(lastTarget!==o){_=r[C];pastFirstInvertThresh=false;isCircumstantialInvert=!I&&l.invertSwap||y}S=_getSwapDirection(t,o,r,f,I?1:l.swapThreshold,l.invertedSwapThreshold==null?l.swapThreshold:l.invertedSwapThreshold,isCircumstantialInvert,lastTarget===o);var k;if(S!==0){var q=index(dragEl);do{q-=S;k=parentEl.children[q]}while(k&&(css(k,"display")==="none"||k===ghostEl))}if(S===0||k===o){return b(false)}lastTarget=o;lastDirection=S;var M=o.nextElementSibling,R=false;R=S===1;var A=_onMove(rootEl,n,dragEl,i,o,r,t,R);if(A!==false){if(A===1||A===-1){R=A===1}_silent=true;setTimeout(_unsilent,30);m();if(R&&!M){n.appendChild(dragEl)}else{o.parentNode.insertBefore(dragEl,R?M:o)}if(T){scrollBy(T,0,D-T.scrollTop)}parentEl=dragEl.parentNode;if(_!==undefined&&!isCircumstantialInvert){targetMoveDistance=Math.abs(_-getRect(o)[C])}x();return b(true)}}if(n.contains(dragEl)){return b(false)}}return false},_ignoreWhileAnimating:null,_offMoveEvents:function e(){off(document,"mousemove",this._onTouchMove);off(document,"touchmove",this._onTouchMove);off(document,"pointermove",this._onTouchMove);off(document,"dragover",nearestEmptyInsertDetectEvent);off(document,"mousemove",nearestEmptyInsertDetectEvent);off(document,"touchmove",nearestEmptyInsertDetectEvent)},_offUpEvents:function e(){var t=this.el.ownerDocument;off(t,"mouseup",this._onDrop);off(t,"touchend",this._onDrop);off(t,"pointerup",this._onDrop);off(t,"pointercancel",this._onDrop);off(t,"touchcancel",this._onDrop);off(document,"selectstart",this)},_onDrop:function e(t){var n=this.el,o=this.options;newIndex=index(dragEl);newDraggableIndex=index(dragEl,o.draggable);pluginEvent("drop",this,{evt:t});parentEl=dragEl&&dragEl.parentNode;newIndex=index(dragEl);newDraggableIndex=index(dragEl,o.draggable);if(Sortable.eventCanceled){this._nulling();return}awaitingDragStarted=false;isCircumstantialInvert=false;pastFirstInvertThresh=false;clearInterval(this._loopId);clearTimeout(this._dragStartTimer);_cancelNextTick(this.cloneId);_cancelNextTick(this._dragStartId);if(this.nativeDraggable){off(document,"drop",this);off(n,"dragstart",this._onDragStart)}this._offMoveEvents();this._offUpEvents();if(Safari){css(document.body,"user-select","")}css(dragEl,"transform","");if(t){if(moved){t.cancelable&&t.preventDefault();!o.dropBubble&&t.stopPropagation()}ghostEl&&ghostEl.parentNode&&ghostEl.parentNode.removeChild(ghostEl);if(rootEl===parentEl||putSortable&&putSortable.lastPutMode!=="clone"){cloneEl&&cloneEl.parentNode&&cloneEl.parentNode.removeChild(cloneEl)}if(dragEl){if(this.nativeDraggable){off(dragEl,"dragend",this)}_disableDraggable(dragEl);dragEl.style["will-change"]="";if(moved&&!awaitingDragStarted){toggleClass(dragEl,putSortable?putSortable.options.ghostClass:this.options.ghostClass,false)}toggleClass(dragEl,this.options.chosenClass,false);_dispatchEvent({sortable:this,name:"unchoose",toEl:parentEl,newIndex:null,newDraggableIndex:null,originalEvent:t});if(rootEl!==parentEl){if(newIndex>=0){_dispatchEvent({rootEl:parentEl,name:"add",toEl:parentEl,fromEl:rootEl,originalEvent:t});_dispatchEvent({sortable:this,name:"remove",toEl:parentEl,originalEvent:t});_dispatchEvent({rootEl:parentEl,name:"sort",toEl:parentEl,fromEl:rootEl,originalEvent:t});_dispatchEvent({sortable:this,name:"sort",toEl:parentEl,originalEvent:t})}putSortable&&putSortable.save()}else{if(newIndex!==oldIndex){if(newIndex>=0){_dispatchEvent({sortable:this,name:"update",toEl:parentEl,originalEvent:t});_dispatchEvent({sortable:this,name:"sort",toEl:parentEl,originalEvent:t})}}}if(Sortable.active){if(newIndex==null||newIndex===-1){newIndex=oldIndex;newDraggableIndex=oldDraggableIndex}_dispatchEvent({sortable:this,name:"end",toEl:parentEl,originalEvent:t});this.save()}}}this._nulling()},_nulling:function e(){pluginEvent("nulling",this);rootEl=dragEl=parentEl=ghostEl=nextEl=cloneEl=lastDownEl=cloneHidden=tapEvt=touchEvt=moved=newIndex=newDraggableIndex=oldIndex=oldDraggableIndex=lastTarget=lastDirection=putSortable=activeGroup=Sortable.dragged=Sortable.ghost=Sortable.clone=Sortable.active=null;savedInputChecked.forEach((function(e){e.checked=true}));savedInputChecked.length=lastDx=lastDy=0},handleEvent:function e(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":if(dragEl){this._onDragOver(t);_globalDragOver(t)}break;case"selectstart":t.preventDefault();break}},toArray:function e(){var t=[],n,o=this.el.children,i=0,r=o.length,s=this.options;for(;i<r;i++){n=o[i];if(closest(n,s.draggable,this.el,false)){t.push(n.getAttribute(s.dataIdAttr)||_generateId(n))}}return t},sort:function e(t,n){var o={},i=this.el;this.toArray().forEach((function(e,t){var n=i.children[t];if(closest(n,this.options.draggable,i,false)){o[e]=n}}),this);n&&this.captureAnimationState();t.forEach((function(e){if(o[e]){i.removeChild(o[e]);i.appendChild(o[e])}}));n&&this.animateAll()},save:function e(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function e(t,n){return closest(t,n||this.options.draggable,this.el,false)},option:function e(t,n){var o=this.options;if(n===void 0){return o[t]}else{var i=PluginManager.modifyOption(this,t,n);if(typeof i!=="undefined"){o[t]=i}else{o[t]=n}if(t==="group"){_prepareGroup(o)}}},destroy:function e(){pluginEvent("destroy",this);var t=this.el;t[expando]=null;off(t,"mousedown",this._onTapStart);off(t,"touchstart",this._onTapStart);off(t,"pointerdown",this._onTapStart);if(this.nativeDraggable){off(t,"dragover",this);off(t,"dragenter",this)}Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),(function(e){e.removeAttribute("draggable")}));this._onDrop();this._disableDelayedDragEvents();sortables.splice(sortables.indexOf(this.el),1);this.el=t=null},_hideClone:function e(){if(!cloneHidden){pluginEvent("hideClone",this);if(Sortable.eventCanceled)return;css(cloneEl,"display","none");if(this.options.removeCloneOnHide&&cloneEl.parentNode){cloneEl.parentNode.removeChild(cloneEl)}cloneHidden=true}},_showClone:function e(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(cloneHidden){pluginEvent("showClone",this);if(Sortable.eventCanceled)return;if(dragEl.parentNode==rootEl&&!this.options.group.revertClone){rootEl.insertBefore(cloneEl,dragEl)}else if(nextEl){rootEl.insertBefore(cloneEl,nextEl)}else{rootEl.appendChild(cloneEl)}if(this.options.group.revertClone){this.animate(dragEl,cloneEl)}css(cloneEl,"display","");cloneHidden=false}}};function _globalDragOver(e){if(e.dataTransfer){e.dataTransfer.dropEffect="move"}e.cancelable&&e.preventDefault()}function _onMove(e,t,n,o,i,r,s,l){var a,c=e[expando],d=c.options.onMove,u;if(window.CustomEvent&&!IE11OrLess&&!Edge){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=n;a.draggedRect=o;a.related=i||t;a.relatedRect=r||getRect(t);a.willInsertAfter=l;a.originalEvent=s;e.dispatchEvent(a);if(d){u=d.call(c,a,s)}return u}function _disableDraggable(e){e.draggable=false}function _unsilent(){_silent=false}function _ghostIsFirst(e,t,n){var o=getRect(getChild(n.el,0,n.options,true));var i=getChildContainingRectFromElement(n.el,n.options,ghostEl);var r=10;return t?e.clientX<i.left-r||e.clientY<o.top&&e.clientX<o.right:e.clientY<i.top-r||e.clientY<o.bottom&&e.clientX<o.left}function _ghostIsLast(e,t,n){var o=getRect(lastChild(n.el,n.options.draggable));var i=getChildContainingRectFromElement(n.el,n.options,ghostEl);var r=10;return t?e.clientX>i.right+r||e.clientY>o.bottom&&e.clientX>o.left:e.clientY>i.bottom+r||e.clientX>o.right&&e.clientY>o.top}function _getSwapDirection(e,t,n,o,i,r,s,l){var a=o?e.clientY:e.clientX,c=o?n.height:n.width,d=o?n.top:n.left,u=o?n.bottom:n.right,h=false;if(!s){if(l&&targetMoveDistance<c*i){if(!pastFirstInvertThresh&&(lastDirection===1?a>d+c*r/2:a<u-c*r/2)){pastFirstInvertThresh=true}if(!pastFirstInvertThresh){if(lastDirection===1?a<d+targetMoveDistance:a>u-targetMoveDistance){return-lastDirection}}else{h=true}}else{if(a>d+c*(1-i)/2&&a<u-c*(1-i)/2){return _getInsertDirection(t)}}}h=h||s;if(h){if(a<d+c*r/2||a>u-c*r/2){return a>d+c/2?1:-1}}return 0}function _getInsertDirection(e){if(index(dragEl)<index(e)){return 1}else{return-1}}function _generateId(e){var t=e.tagName+e.className+e.src+e.href+e.textContent,n=t.length,o=0;while(n--){o+=t.charCodeAt(n)}return o.toString(36)}function _saveInputCheckedState(e){savedInputChecked.length=0;var t=e.getElementsByTagName("input");var n=t.length;while(n--){var o=t[n];o.checked&&savedInputChecked.push(o)}}function _nextTick(e){return setTimeout(e,0)}function _cancelNextTick(e){return clearTimeout(e)}if(documentExists){on(document,"touchmove",(function(e){if((Sortable.active||awaitingDragStarted)&&e.cancelable){e.preventDefault()}}))}Sortable.utils={on:on,off:off,css:css,find:find,is:function e(t,n){return!!closest(t,n,t,false)},extend:extend,throttle:throttle,closest:closest,toggleClass:toggleClass,clone:clone,index:index,nextTick:_nextTick,cancelNextTick:_cancelNextTick,detectDirection:_detectDirection,getChild:getChild,expando:expando};Sortable.get=function(e){return e[expando]};Sortable.mount=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}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)Sortable.utils=_objectSpread2(_objectSpread2({},Sortable.utils),e.utils);PluginManager.mount(e)}))};Sortable.create=function(e,t){return new Sortable(e,t)};Sortable.version=version;var autoScrolls=[],scrollEl,scrollRootEl,scrolling=false,lastAutoScrollX,lastAutoScrollY,touchEvt$1,pointerElemChangedInterval;function AutoScrollPlugin(){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 n=t.originalEvent;if(this.sortable.nativeDraggable){on(document,"dragover",this._handleAutoScroll)}else{if(this.options.supportPointer){on(document,"pointermove",this._handleFallbackAutoScroll)}else if(n.touches){on(document,"touchmove",this._handleFallbackAutoScroll)}else{on(document,"mousemove",this._handleFallbackAutoScroll)}}},dragOverCompleted:function e(t){var n=t.originalEvent;if(!this.options.dragOverBubble&&!n.rootEl){this._handleAutoScroll(n)}},drop:function e(){if(this.sortable.nativeDraggable){off(document,"dragover",this._handleAutoScroll)}else{off(document,"pointermove",this._handleFallbackAutoScroll);off(document,"touchmove",this._handleFallbackAutoScroll);off(document,"mousemove",this._handleFallbackAutoScroll)}clearPointerElemChangedInterval();clearAutoScrolls();cancelThrottle()},nulling:function e(){touchEvt$1=scrollRootEl=scrollEl=scrolling=pointerElemChangedInterval=lastAutoScrollX=lastAutoScrollY=null;autoScrolls.length=0},_handleFallbackAutoScroll:function e(t){this._handleAutoScroll(t,true)},_handleAutoScroll:function e(t,n){var o=this;var i=(t.touches?t.touches[0]:t).clientX,r=(t.touches?t.touches[0]:t).clientY,s=document.elementFromPoint(i,r);touchEvt$1=t;if(n||this.options.forceAutoScrollFallback||Edge||IE11OrLess||Safari){autoScroll(t,this.options,s,n);var l=getParentAutoScrollElement(s,true);if(scrolling&&(!pointerElemChangedInterval||i!==lastAutoScrollX||r!==lastAutoScrollY)){pointerElemChangedInterval&&clearPointerElemChangedInterval();pointerElemChangedInterval=setInterval((function(){var e=getParentAutoScrollElement(document.elementFromPoint(i,r),true);if(e!==l){l=e;clearAutoScrolls()}autoScroll(t,o.options,e,n)}),10);lastAutoScrollX=i;lastAutoScrollY=r}}else{if(!this.options.bubbleScroll||getParentAutoScrollElement(s,true)===getWindowScrollingElement()){clearAutoScrolls();return}autoScroll(t,this.options,getParentAutoScrollElement(s,false),false)}}};return _extends(e,{pluginName:"scroll",initializeByDefault:true})}function clearAutoScrolls(){autoScrolls.forEach((function(e){clearInterval(e.pid)}));autoScrolls=[]}function clearPointerElemChangedInterval(){clearInterval(pointerElemChangedInterval)}var autoScroll=throttle((function(e,t,n,o){if(!t.scroll)return;var i=(e.touches?e.touches[0]:e).clientX,r=(e.touches?e.touches[0]:e).clientY,s=t.scrollSensitivity,l=t.scrollSpeed,a=getWindowScrollingElement();var c=false,d;if(scrollRootEl!==n){scrollRootEl=n;clearAutoScrolls();scrollEl=t.scroll;d=t.scrollFn;if(scrollEl===true){scrollEl=getParentAutoScrollElement(n,true)}}var u=0;var h=scrollEl;do{var f=h,v=getRect(f),p=v.top,g=v.bottom,m=v.left,b=v.right,x=v.width,E=v.height,w=void 0,S=void 0,_=f.scrollWidth,y=f.scrollHeight,I=css(f),C=f.scrollLeft,T=f.scrollTop;if(f===a){w=x<_&&(I.overflowX==="auto"||I.overflowX==="scroll"||I.overflowX==="visible");S=E<y&&(I.overflowY==="auto"||I.overflowY==="scroll"||I.overflowY==="visible")}else{w=x<_&&(I.overflowX==="auto"||I.overflowX==="scroll");S=E<y&&(I.overflowY==="auto"||I.overflowY==="scroll")}var D=w&&(Math.abs(b-i)<=s&&C+x<_)-(Math.abs(m-i)<=s&&!!C);var k=S&&(Math.abs(g-r)<=s&&T+E<y)-(Math.abs(p-r)<=s&&!!T);if(!autoScrolls[u]){for(var q=0;q<=u;q++){if(!autoScrolls[q]){autoScrolls[q]={}}}}if(autoScrolls[u].vx!=D||autoScrolls[u].vy!=k||autoScrolls[u].el!==f){autoScrolls[u].el=f;autoScrolls[u].vx=D;autoScrolls[u].vy=k;clearInterval(autoScrolls[u].pid);if(D!=0||k!=0){c=true;autoScrolls[u].pid=setInterval(function(){if(o&&this.layer===0){Sortable.active._onTouchMove(touchEvt$1)}var t=autoScrolls[this.layer].vy?autoScrolls[this.layer].vy*l:0;var n=autoScrolls[this.layer].vx?autoScrolls[this.layer].vx*l:0;if(typeof d==="function"){if(d.call(Sortable.dragged.parentNode[expando],n,t,e,touchEvt$1,autoScrolls[this.layer].el)!=="continue"){return}}scrollBy(autoScrolls[this.layer].el,n,t)}.bind({layer:u}),24)}}u++}while(t.bubbleScroll&&h!==a&&(h=getParentAutoScrollElement(h,false)));scrolling=c}),30);var drop=function e(t){var n=t.originalEvent,o=t.putSortable,i=t.dragEl,r=t.activeSortable,s=t.dispatchSortableEvent,l=t.hideGhostForTarget,a=t.unhideGhostForTarget;if(!n)return;var c=o||r;l();var d=n.changedTouches&&n.changedTouches.length?n.changedTouches[0]:n;var u=document.elementFromPoint(d.clientX,d.clientY);a();if(c&&!c.el.contains(u)){s("spill");this.onSpill({dragEl:i,putSortable:o})}};function Revert(){}Revert.prototype={startIndex:null,dragStart:function e(t){var n=t.oldDraggableIndex;this.startIndex=n},onSpill:function e(t){var n=t.dragEl,o=t.putSortable;this.sortable.captureAnimationState();if(o){o.captureAnimationState()}var i=getChild(this.sortable.el,this.startIndex,this.options);if(i){this.sortable.el.insertBefore(n,i)}else{this.sortable.el.appendChild(n)}this.sortable.animateAll();if(o){o.animateAll()}},drop:drop};_extends(Revert,{pluginName:"revertOnSpill"});function Remove(){}Remove.prototype={onSpill:function e(t){var n=t.dragEl,o=t.putSortable;var i=o||this.sortable;i.captureAnimationState();n.parentNode&&n.parentNode.removeChild(n);i.animateAll()},drop:drop};_extends(Remove,{pluginName:"removeOnSpill"});Sortable.mount(new AutoScrollPlugin);Sortable.mount(Remove,Revert);var verdocsTemplateRolesCss='verdocs-template-roles{display:block;max-width:600px;font-family:var(--verdocs-primary-font, "Inter", "Barlow", 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}';var settingsIcon='<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20" fill="#00000089"><path d="m8.021 17.917-.313-2.5q-.27-.125-.625-.334-.354-.208-.625-.395l-2.312.979-1.979-3.438 1.979-1.5q-.021-.167-.031-.364-.011-.198-.011-.365 0-.146.011-.344.01-.198.031-.385l-1.979-1.5 1.979-3.417 2.312.958q.271-.187.615-.385t.635-.344l.313-2.5h3.958l.313 2.5q.312.167.625.344.312.177.604.385l2.333-.958 1.979 3.417-1.979 1.521q.021.187.021.364V10q0 .146-.01.333-.011.188-.011.396l1.958 1.5-1.979 3.438-2.312-.979q-.292.208-.615.395-.323.188-.614.334l-.313 2.5Zm1.937-5.355q1.063 0 1.813-.75t.75-1.812q0-1.062-.75-1.812t-1.813-.75q-1.041 0-1.802.75-.76.75-.76 1.812t.76 1.812q.761.75 1.802.75Zm0-1.333q-.5 0-.864-.364-.365-.365-.365-.865t.365-.865q.364-.364.864-.364t.865.364q.365.365.365.865t-.365.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.187q.605-.167 1.136-.49.531-.323 1.031-.802l2.021.875.854-1.375-1.792-1.354q.105-.333.136-.635.031-.303.031-.615 0-.292-.031-.573-.031-.281-.115-.635l1.792-1.396-.834-1.375-2.062.875q-.438-.438-1.021-.781-.583-.344-1.125-.49l-.271-2.208H9.167l-.271 2.208q-.584.146-1.125.458-.542.313-1.042.792l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.479.458 1.021.771.542.312 1.146.479Z"/></svg>';var plusIcon='<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>';var iconSigner='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>';var iconApprover='<svg xmlns="http://www.w3.org/2000/svg" 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>';var iconCC='<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>';var VerdocsTemplateRoles=function(){function e(e){registerInstance(this,e);this.next=createEvent(this,"next");this.exit=createEvent(this,"exit");this.sdkError=createEvent(this,"sdkError");this.rolesUpdated=createEvent(this,"rolesUpdated");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.showingRoleDialog=null;this.sender=null;this.dragging=false;this.loading=true;this.template=null;this.sortableRefs=[]}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate();this.cleanupSortables()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[ROLES] Loading template",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){console.log("[ROLES] Template Updated",t);e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(o){console.log("[ROLES] Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.cleanupSortables=function(){this.sortableRefs.forEach((function(e){return e.destroy()}));this.sortableRefs.length=0};e.prototype.componentDidRender=function(){var e=this;this.cleanupSortables();var t=this.getSequenceNumbers();(t||[]).forEach((function(t){var n=document.getElementById("verdocs-roles-sequence-".concat(t));if(n){var o=new Sortable(n,{group:"roles",animation:150,dragoverBubble:true,filter:".no-drag",onEnd:e.handleMoveEnd.bind(e),onChoose:function(){return e.dragging=true},onUnchoose:function(){return e.dragging=false}});e.sortableRefs.push(o)}}));var n=document.getElementById("verdocs-roles-sequence-add-target");if(n){console.log("[ROLES] Applying sortable to add-sequence slot");var o=new Sortable(n,{group:"roles",animation:150,dragoverBubble:true,filter:".no-drag",onEnd:this.handleMoveEnd.bind(this),onChoose:function(){return e.dragging=true},onUnchoose:function(){return e.dragging=false}});this.sortableRefs.push(o)}};e.prototype.handleMoveEnd=function(e){var t=this;var n=+e.from.dataset.sequence;var o=+e.to.dataset.sequence;var i=+e.oldIndex+1;var r=+e.newIndex+1;console.log("Move from ".concat(n,":").concat(i," to ").concat(o,":").concat(r),e.item);var s={};var l=this.getSequenceNumbers();l.forEach((function(e){var n=t.getRolesAtSequence(e);s[String(e)]=JSON.parse(JSON.stringify(n))}));s[l[l.length-1]+1]=[];var a=s[n].splice(i-1,1)[0];s[o]||(s[o]=[]);s[o].splice(r-1,0,a);var c=[];Object.entries(s).forEach((function(e){var n=e[0],o=e[1];o.forEach((function(e,o){if(!e){return}var i=+o+1;if(e.sequence!==+n||e.order!==i){e.sequence=+n;e.order=i;c.push(updateTemplateRole(t.endpoint,t.templateId,e.name,{sequence:+n,order:i}).then((function(t){return console.log("[ROLES] Updated role",e.name,t)})).catch((function(e){return console.log("[ROLES] Error updating role",e)})))}}))}));return Promise.all(c).then((function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){return[2,console.log("[ROLES] Done renumbering")]}))}))})).catch((function(e){return console.log("[ROLES] Error updating roles",e)}))};e.prototype.handleCancel=function(){var e;(e=this.exit)===null||e===void 0?void 0:e.emit()};e.prototype.handleSubmit=function(){var e;(e=this.next)===null||e===void 0?void 0:e.emit()};e.prototype.getSortedRoles=function(){var e;return(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).sort((function(e,t){return e.sequence===t.sequence?e.order-t.order:e.sequence-t.sequence}))};e.prototype.getSequenceNumbers=function(){var e={};this.getSortedRoles().forEach((function(t){e[t.sequence]=true}));console.log("[ROLES] Sequences",e);return Object.keys(e).map((function(e){return+e})).sort((function(e,t){return e-t}))};e.prototype.getRoleNames=function(){var e=this.getSortedRoles();return e.map((function(e){return e.name}))};e.prototype.getRolesAtSequence=function(e){var t;return(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((function(t){return t&&t.sequence===e}))};e.prototype.renumberTemplateRoles=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n,o;var i=this;return __generator(this,(function(r){switch(r.label){case 0:t={};n=[];o=this.getSequenceNumbers();(o||[]).forEach((function(e){(t[e]||[]).forEach((function(t,o){var r=+o+1;if(t.sequence!==+e||t.order!==r){console.log("[ROLES] Updating role",t.name,"from",t.sequence,t.order,"to",e,r);t.sequence=+e;t.order=r;n.push(updateTemplateRole(i.endpoint,i.templateId,t.name,{sequence:+e,order:r}).then((function(e){return console.log("[ROLES] Updated role",t.name,e)})).catch((function(e){return console.log("[ROLES] Error updating role",e)})))}}))}));console.log("[ROLES] Awaiting ".concat(n.length," renumber requests"));return[4,Promise.all(n).then((function(){return __awaiter(i,void 0,void 0,(function(){var e;return __generator(this,(function(n){e=JSON.parse(JSON.stringify(this.template));e.roles=Object.keys(t).reduce((function(e,n){return e.concat(t[n])}),[]);console.log("[ROLES] Done renumbering",e.roles.map((function(e){return{name:e.name,sequence:e.sequence,order:e.order}})));Store.updateTemplate(this.templateId,e);return[2]}))}))}))];case 1:r.sent();(e=this.rolesUpdated)===null||e===void 0?void 0:e.emit({event:"updated",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()});return[2]}}))}))};e.prototype.getNextRoleName=function(){var e,t;var n="";var o=(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).length;do{o++;n="Recipient ".concat(o)}while(!n||(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).some((function(e){return e&&e.name===n})));return n};e.prototype.callCreateRole=function(e,t,n){var o=this;console.log("[ROLES] Will create role",{name:e,sequence:t,order:n});createTemplateRole(this.endpoint,this.templateId,{template_id:this.templateId,name:e,sequence:t,message:"",order:n,full_name:null,first_name:"",last_name:"",email:"",phone:"",type:"signer",delegator:false}).then((function(e){return __awaiter(o,void 0,void 0,(function(){var t;return __generator(this,(function(n){switch(n.label){case 0:console.log("[ROLES] Created role",e);console.log("Updating template in data store");return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 1:n.sent();(t=this.rolesUpdated)===null||t===void 0?void 0:t.emit({event:"added",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()});return[2]}}))}))})).catch((function(e){console.log("[ROLES] Error creating role",e)}))};e.prototype.handleAddRole=function(e,t){e.stopPropagation();var n=this.getRolesAtSequence(t).length+1;var o=this.getNextRoleName();this.callCreateRole(o,t,n)};e.prototype.handleAddStep=function(e,t){e.stopPropagation();var n=1;var o=this.getNextRoleName();this.callCreateRole(o,t,n)};e.prototype.render=function(){var e=this;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading||!this.template){return h(Host,{class:"loading"},h("verdocs-loader",null))}var t=this.getRoleNames();var n=this.getSequenceNumbers();var o=n&&n.length>0?(n[n.length-1]||0)+1:1;console.log("[ROLES] Rendering",{roleNames:t,sequences:n,nextSequence:o});return h(Host,{class:{dragging:this.dragging}},h("form",{onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off"},h("h5",null,"Roles and Workflow"),h("div",{class:"roles"},n.map((function(t,n){return h("div",{class:"sequence"},h("div",{class:"sequence-label no-drag"},n+1,"."),h("div",{class:"sequence-roles",id:"verdocs-roles-sequence-".concat(t),"data-sequence":t},e.getRolesAtSequence(t).map((function(n){var o=!n.email||!n.first_name||!n.last_name;return o?h("div",{class:"role","data-rolename":n.name,"data-sequence":t,"data-order":n.order},h("div",{class:"role-name"},n.name),h("div",{class:"icons"},h("div",{class:"gear-button",innerHTML:settingsIcon,onClick:function(){return e.showingRoleDialog=n.name},"aria-role":"button"}),h("span",{class:"type-icon",innerHTML:n.type==="signer"?iconSigner:n.type==="cc"?iconCC:iconApprover}))):h("div",{class:"role","data-rolename":n.name,"data-sequence":t,"data-order":n.order},h("div",{class:"role-name"},formatFullName(n)),h("div",{class:"icons"},h("div",{class:"gear-button",innerHTML:settingsIcon,onClick:function(){return e.showingRoleDialog=n.name},"aria-role":"button"}),h("span",{class:"type-icon",innerHTML:n.type==="signer"?iconSigner:n.type==="cc"?iconCC:iconApprover})))}))),h("button",{class:"add-role no-drag",onClick:function(n){return e.handleAddRole(n,t)}},"+ Add Role"))})),h("div",{class:"sequence add-sequence"},h("div",{class:"sequence-label no-drag"},n.length+1,"."),h("div",{class:"sequence-roles",id:"verdocs-roles-sequence-add-target","data-sequence":o}),h("button",{class:"add-role no-drag",onClick:function(t){return e.handleAddRole(t,o)}},"+ Add Role"))),t.length<1&&h("div",{class:"empty"},"You must add at least one Role before proceeding.",h("br",null)," Click the ",h("span",{innerHTML:plusIcon})," Add button above to get started."),h("div",{class:"buttons"},h("div",{class:"flex-fill"}),h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(){return e.handleCancel()}}),h("verdocs-button",{label:"OK",size:"small",onClick:function(){return e.handleSubmit()},disabled:t.length<1}))),this.showingRoleDialog&&h("verdocs-menu-panel",{onClose:function(){return e.showingRoleDialog=null}},h("verdocs-template-role-properties",{endpoint:this.endpoint,templateId:this.templateId,roleName:this.showingRoleDialog,onClose:function(){var t;(t=document.getElementById("verdocs-menu-panel-overlay"))===null||t===void 0?void 0:t.remove();e.showingRoleDialog=null},onDelete:function(){return __awaiter(e,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:this.showingRoleDialog=null;return[4,this.renumberTemplateRoles()];case 1:t.sent();(e=this.rolesUpdated)===null||e===void 0?void 0:e.emit({event:"deleted",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()});return[2]}}))}))}})))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();VerdocsTemplateRoles.style=verdocsTemplateRolesCss;var verdocsTemplateSettingsCss='verdocs-template-settings{display:block;max-width:600px;font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-template-settings>form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;padding:12px}verdocs-template-settings>form h5{font-size:16px;font-weight:bold;color:#46497d;margin:0 0 10px 0}verdocs-template-settings>form label{display:block;font-size:14px;font-weight:500;margin:0 0 4px 0;color:#5c6575}verdocs-template-settings>form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-settings>form input:focus{outline:none}verdocs-template-settings>form .row{margin:20px 0 0 0}verdocs-template-settings .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-settings ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-settings ::-moz-placeholder{color:#aaaaaa}verdocs-template-settings :-ms-input-placeholder{color:#aaaaaa}verdocs-template-settings ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-settings ::placeholder{color:#aaaaaa}';var MS_PER_DAY=24*60*60*1e3;var VerdocsTemplateSettings=function(){function e(e){registerInstance(this,e);this.next=createEvent(this,"next");this.exit=createEvent(this,"exit");this.sdkError=createEvent(this,"sdkError");this.templateUpdated=createEvent(this,"templateUpdated");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.name=null;this.visibility="private";this.sender="envelope_creator";this.sendReminders=false;this.initialReminder=0;this.followupReminders=0;this.dirty=false;this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[SETTINGS] Loading template",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){console.log("[SETTINGS] Template Updated",t);e.template=t;e.name=t.name;e.visibility=t.visibility;e.sender=t.sender;e.sendReminders=t.initial_reminder!==null;e.initialReminder=t.initial_reminder?Math.floor(t.initial_reminder/MS_PER_DAY):null;e.followupReminders=t.followup_reminders?Math.floor(t.followup_reminders/MS_PER_DAY):null;e.dirty=false;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.templateId){console.log("[SETTINGS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[SETTINGS] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(o){console.log("[SETTINGS] Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.handleCancel=function(){var e;(e=this.exit)===null||e===void 0?void 0:e.emit()};e.prototype.handleSubmit=function(){var e=this;updateTemplate(this.endpoint,this.templateId,{name:this.name,visibility:this.visibility,sender:this.sender,initial_reminder:this.sendReminders?this.initialReminder*MS_PER_DAY:null,followup_reminders:this.sendReminders?this.followupReminders*MS_PER_DAY:null}).then((function(t){var n,o;console.log("[SETTINGS] Template Updated",t);e.dirty=false;e.name=t.name;e.visibility=t.visibility;e.sender=t.sender;e.sendReminders=t.initial_reminder!==null;e.initialReminder=t.initial_reminder?Math.floor(t.initial_reminder/MS_PER_DAY):null;e.followupReminders=t.followup_reminders?Math.floor(t.followup_reminders/MS_PER_DAY):null;(n=e.templateUpdated)===null||n===void 0?void 0:n.emit({endpoint:e.endpoint,template:t,event:"update"});(o=e.next)===null||o===void 0?void 0:o.emit()})).catch((function(t){var n,o,i,r,s;console.log("[SETTINGS] Error updating template",t);(n=e.sdkError)===null||n===void 0?void 0:n.emit(new SDKError(t.message,(o=t.response)===null||o===void 0?void 0:o.status,(i=t.response)===null||i===void 0?void 0:i.data));VerdocsToast(((s=(r=t.response)===null||r===void 0?void 0:r.data)===null||s===void 0?void 0:s.error)||"Error updating template, please try again later.")}))};e.prototype.render=function(){var e=this;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading||!this.template){return h(Host,{class:"loading"},h("verdocs-loader",null))}return h(Host,null,h("form",{onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off"},h("h5",null,"Settings"),h("div",{class:"row"},h("verdocs-text-input",{id:"verdocs-field-name",label:"Template Name",value:this.name,autocomplete:"off",placeholder:"Template Name...",onInput:function(t){e.name=t.target.value;e.dirty=true}})),h("div",{class:"row"},h("verdocs-select-input",{label:"Visibility",value:this.visibility,onInput:function(t){e.visibility=t.target.value;e.dirty=true},options:[{value:"private",label:"Private"},{value:"shared",label:"Shared"},{value:"public",label:"Public"}]})),h("div",{class:"row"},h("verdocs-select-input",{label:"Owner for envelopes created from this template",value:this.sender,onInput:function(t){e.sender=t.target.value;e.dirty=true},options:[{value:"envelope_creator",label:"Envelope Creator"},{value:"template_owner",label:"Template Owner"}]})),h("div",{class:"row"},h("label",null,"Send Reminders"),h("verdocs-switch",{checked:this.sendReminders,onCheckedChange:function(t){return e.sendReminders=t.detail}})),this.sendReminders&&h("div",{class:"row"},h("verdocs-text-input",{id:"verdocs-field-name",label:"First Reminder (days)",value:String(this.initialReminder||0),autocomplete:"off",placeholder:"Delay in days...",onInput:function(t){e.initialReminder=+t.target.value;e.dirty=true}})),this.sendReminders&&h("div",{class:"row"},h("verdocs-text-input",{id:"verdocs-field-name",label:"Follow-up Reminders (days)",value:String(this.followupReminders||0),autocomplete:"off",placeholder:"Delay in days...",onInput:function(t){e.followupReminders=+t.target.value;e.dirty=true}})),h("div",{class:"buttons"},h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(){return e.handleCancel()}}),h("verdocs-button",{label:"Save",size:"small",onClick:function(){return e.handleSubmit()},disabled:!this.dirty}))))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();VerdocsTemplateSettings.style=verdocsTemplateSettingsCss;export{VerdocsPreview as verdocs_preview,VerdocsSend as verdocs_send,VerdocsTemplateAttachments as verdocs_template_attachments,VerdocsTemplateBuildTabs as verdocs_template_build_tabs,VerdocsTemplateFields as verdocs_template_fields,VerdocsTemplateRoles as verdocs_template_roles,VerdocsTemplateSettings as verdocs_template_settings};
7
+ */function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);if(t){o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))}n.push.apply(n,o)}return n}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};if(t%2){ownKeys(Object(n),true).forEach((function(t){_defineProperty(e,t,n[t])}))}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}}return e}function _typeof(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function(e){return typeof e}}else{_typeof=function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}function _defineProperty(e,t,n){if(t in e){Object.defineProperty(e,t,{value:n,enumerable:true,configurable:true,writable:true})}else{e[t]=n}return e}function _extends(){_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n){if(Object.prototype.hasOwnProperty.call(n,o)){e[o]=n[o]}}}return e};return _extends.apply(this,arguments)}function _objectWithoutPropertiesLoose(e,t){if(e==null)return{};var n={};var o=Object.keys(e);var i,r;for(r=0;r<o.length;r++){i=o[r];if(t.indexOf(i)>=0)continue;n[i]=e[i]}return n}function _objectWithoutProperties(e,t){if(e==null)return{};var n=_objectWithoutPropertiesLoose(e,t);var o,i;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++){o=r[i];if(t.indexOf(o)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,o))continue;n[o]=e[o]}}return n}var version="1.15.6";function userAgent(e){if(typeof window!=="undefined"&&window.navigator){return!!navigator.userAgent.match(e)}}var IE11OrLess=userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);var Edge=userAgent(/Edge/i);var FireFox=userAgent(/firefox/i);var Safari=userAgent(/safari/i)&&!userAgent(/chrome/i)&&!userAgent(/android/i);var IOS=userAgent(/iP(ad|od|hone)/i);var ChromeForAndroid=userAgent(/chrome/i)&&userAgent(/android/i);var captureMode={capture:false,passive:false};function on(e,t,n){e.addEventListener(t,n,!IE11OrLess&&captureMode)}function off(e,t,n){e.removeEventListener(t,n,!IE11OrLess&&captureMode)}function matches(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 getParentOrHost(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function closest(e,t,n,o){if(e){n=n||document;do{if(t!=null&&(t[0]===">"?e.parentNode===n&&matches(e,t):matches(e,t))||o&&e===n){return e}if(e===n)break}while(e=getParentOrHost(e))}return null}var R_SPACE=/\s+/g;function toggleClass(e,t,n){if(e&&t){if(e.classList){e.classList[n?"add":"remove"](t)}else{var o=(" "+e.className+" ").replace(R_SPACE," ").replace(" "+t+" "," ");e.className=(o+(n?" "+t:"")).replace(R_SPACE," ")}}}function css(e,t,n){var o=e&&e.style;if(o){if(n===void 0){if(document.defaultView&&document.defaultView.getComputedStyle){n=document.defaultView.getComputedStyle(e,"")}else if(e.currentStyle){n=e.currentStyle}return t===void 0?n:n[t]}else{if(!(t in o)&&t.indexOf("webkit")===-1){t="-webkit-"+t}o[t]=n+(typeof n==="string"?"":"px")}}}function matrix(e,t){var n="";if(typeof e==="string"){n=e}else{do{var o=css(e,"transform");if(o&&o!=="none"){n=o+" "+n}}while(!t&&(e=e.parentNode))}var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function find(e,t,n){if(e){var o=e.getElementsByTagName(t),i=0,r=o.length;if(n){for(;i<r;i++){n(o[i],i)}}return o}return[]}function getWindowScrollingElement(){var e=document.scrollingElement;if(e){return e}else{return document.documentElement}}function getRect(e,t,n,o,i){if(!e.getBoundingClientRect&&e!==window)return;var r,s,l,a,c,d,u;if(e!==window&&e.parentNode&&e!==getWindowScrollingElement()){r=e.getBoundingClientRect();s=r.top;l=r.left;a=r.bottom;c=r.right;d=r.height;u=r.width}else{s=0;l=0;a=window.innerHeight;c=window.innerWidth;d=window.innerHeight;u=window.innerWidth}if((t||n)&&e!==window){i=i||e.parentNode;if(!IE11OrLess){do{if(i&&i.getBoundingClientRect&&(css(i,"transform")!=="none"||n&&css(i,"position")!=="static")){var h=i.getBoundingClientRect();s-=h.top+parseInt(css(i,"border-top-width"));l-=h.left+parseInt(css(i,"border-left-width"));a=s+r.height;c=l+r.width;break}}while(i=i.parentNode)}}if(o&&e!==window){var f=matrix(i||e),v=f&&f.a,p=f&&f.d;if(f){s/=p;l/=v;u/=v;d/=p;a=s+d;c=l+u}}return{top:s,left:l,bottom:a,right:c,width:u,height:d}}function isScrolledPast(e,t,n){var o=getParentAutoScrollElement(e,true),i=getRect(e)[t];while(o){var r=getRect(o)[n],s=void 0;{s=i>=r}if(!s)return o;if(o===getWindowScrollingElement())break;o=getParentAutoScrollElement(o,false)}return false}function getChild(e,t,n,o){var i=0,r=0,s=e.children;while(r<s.length){if(s[r].style.display!=="none"&&s[r]!==Sortable.ghost&&(o||s[r]!==Sortable.dragged)&&closest(s[r],n.draggable,e,false)){if(i===t){return s[r]}i++}r++}return null}function lastChild(e,t){var n=e.lastElementChild;while(n&&(n===Sortable.ghost||css(n,"display")==="none"||t&&!matches(n,t))){n=n.previousElementSibling}return n||null}function index(e,t){var n=0;if(!e||!e.parentNode){return-1}while(e=e.previousElementSibling){if(e.nodeName.toUpperCase()!=="TEMPLATE"&&e!==Sortable.clone&&(!t||matches(e,t))){n++}}return n}function getRelativeScrollOffset(e){var t=0,n=0,o=getWindowScrollingElement();if(e){do{var i=matrix(e),r=i.a,s=i.d;t+=e.scrollLeft*r;n+=e.scrollTop*s}while(e!==o&&(e=e.parentNode))}return[t,n]}function indexOfObject(e,t){for(var n in e){if(!e.hasOwnProperty(n))continue;for(var o in t){if(t.hasOwnProperty(o)&&t[o]===e[n][o])return Number(n)}}return-1}function getParentAutoScrollElement(e,t){if(!e||!e.getBoundingClientRect)return getWindowScrollingElement();var n=e;var o=false;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=css(n);if(n.clientWidth<n.scrollWidth&&(i.overflowX=="auto"||i.overflowX=="scroll")||n.clientHeight<n.scrollHeight&&(i.overflowY=="auto"||i.overflowY=="scroll")){if(!n.getBoundingClientRect||n===document.body)return getWindowScrollingElement();if(o||t)return n;o=true}}}while(n=n.parentNode);return getWindowScrollingElement()}function extend(e,t){if(e&&t){for(var n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}}return e}function isRectEqual(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 _throttleTimeout;function throttle(e,t){return function(){if(!_throttleTimeout){var n=arguments,o=this;if(n.length===1){e.call(o,n[0])}else{e.apply(o,n)}_throttleTimeout=setTimeout((function(){_throttleTimeout=void 0}),t)}}}function cancelThrottle(){clearTimeout(_throttleTimeout);_throttleTimeout=void 0}function scrollBy(e,t,n){e.scrollLeft+=t;e.scrollTop+=n}function clone(e){var t=window.Polymer;var n=window.jQuery||window.Zepto;if(t&&t.dom){return t.dom(e).cloneNode(true)}else if(n){return n(e).clone(true)[0]}else{return e.cloneNode(true)}}function getChildContainingRectFromElement(e,t,n){var o={};Array.from(e.children).forEach((function(i){var r,s,l,a;if(!closest(i,t.draggable,e,false)||i.animated||i===n)return;var c=getRect(i);o.left=Math.min((r=o.left)!==null&&r!==void 0?r:Infinity,c.left);o.top=Math.min((s=o.top)!==null&&s!==void 0?s:Infinity,c.top);o.right=Math.max((l=o.right)!==null&&l!==void 0?l:-Infinity,c.right);o.bottom=Math.max((a=o.bottom)!==null&&a!==void 0?a:-Infinity,c.bottom)}));o.width=o.right-o.left;o.height=o.bottom-o.top;o.x=o.left;o.y=o.top;return o}var expando="Sortable"+(new Date).getTime();function AnimationStateManager(){var e=[],t;return{captureAnimationState:function t(){e=[];if(!this.options.animation)return;var n=[].slice.call(this.el.children);n.forEach((function(t){if(css(t,"display")==="none"||t===Sortable.ghost)return;e.push({target:t,rect:getRect(t)});var n=_objectSpread2({},e[e.length-1].rect);if(t.thisAnimationDuration){var o=matrix(t,true);if(o){n.top-=o.f;n.left-=o.e}}t.fromRect=n}))},addAnimationState:function t(n){e.push(n)},removeAnimationState:function t(n){e.splice(indexOfObject(e,{target:n}),1)},animateAll:function n(o){var i=this;if(!this.options.animation){clearTimeout(t);if(typeof o==="function")o();return}var r=false,s=0;e.forEach((function(e){var t=0,n=e.target,o=n.fromRect,l=getRect(n),a=n.prevFromRect,c=n.prevToRect,d=e.rect,u=matrix(n,true);if(u){l.top-=u.f;l.left-=u.e}n.toRect=l;if(n.thisAnimationDuration){if(isRectEqual(a,l)&&!isRectEqual(o,l)&&(d.top-l.top)/(d.left-l.left)===(o.top-l.top)/(o.left-l.left)){t=calculateRealTime(d,a,c,i.options)}}if(!isRectEqual(l,o)){n.prevFromRect=o;n.prevToRect=l;if(!t){t=i.options.animation}i.animate(n,d,l,t)}if(t){r=true;s=Math.max(s,t);clearTimeout(n.animationResetTimer);n.animationResetTimer=setTimeout((function(){n.animationTime=0;n.prevFromRect=null;n.fromRect=null;n.prevToRect=null;n.thisAnimationDuration=null}),t);n.thisAnimationDuration=t}}));clearTimeout(t);if(!r){if(typeof o==="function")o()}else{t=setTimeout((function(){if(typeof o==="function")o()}),s)}e=[]},animate:function e(t,n,o,i){if(i){css(t,"transition","");css(t,"transform","");var r=matrix(this.el),s=r&&r.a,l=r&&r.d,a=(n.left-o.left)/(s||1),c=(n.top-o.top)/(l||1);t.animatingX=!!a;t.animatingY=!!c;css(t,"transform","translate3d("+a+"px,"+c+"px,0)");this.forRepaintDummy=repaint(t);css(t,"transition","transform "+i+"ms"+(this.options.easing?" "+this.options.easing:""));css(t,"transform","translate3d(0,0,0)");typeof t.animated==="number"&&clearTimeout(t.animated);t.animated=setTimeout((function(){css(t,"transition","");css(t,"transform","");t.animated=false;t.animatingX=false;t.animatingY=false}),i)}}}}function repaint(e){return e.offsetWidth}function calculateRealTime(e,t,n,o){return Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))/Math.sqrt(Math.pow(t.top-n.top,2)+Math.pow(t.left-n.left,2))*o.animation}var plugins=[];var defaults={initializeByDefault:true};var PluginManager={mount:function e(t){for(var n in defaults){if(defaults.hasOwnProperty(n)&&!(n in t)){t[n]=defaults[n]}}plugins.forEach((function(e){if(e.pluginName===t.pluginName){throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}}));plugins.push(t)},pluginEvent:function e(t,n,o){var i=this;this.eventCanceled=false;o.cancel=function(){i.eventCanceled=true};var r=t+"Global";plugins.forEach((function(e){if(!n[e.pluginName])return;if(n[e.pluginName][r]){n[e.pluginName][r](_objectSpread2({sortable:n},o))}if(n.options[e.pluginName]&&n[e.pluginName][t]){n[e.pluginName][t](_objectSpread2({sortable:n},o))}}))},initializePlugins:function e(t,n,o,i){plugins.forEach((function(e){var i=e.pluginName;if(!t.options[i]&&!e.initializeByDefault)return;var r=new e(t,n,t.options);r.sortable=t;r.options=t.options;t[i]=r;_extends(o,r.defaults)}));for(var r in t.options){if(!t.options.hasOwnProperty(r))continue;var s=this.modifyOption(t,r,t.options[r]);if(typeof s!=="undefined"){t.options[r]=s}}},getEventProperties:function e(t,n){var o={};plugins.forEach((function(e){if(typeof e.eventProperties!=="function")return;_extends(o,e.eventProperties.call(n[e.pluginName],t))}));return o},modifyOption:function e(t,n,o){var i;plugins.forEach((function(e){if(!t[e.pluginName])return;if(e.optionListeners&&typeof e.optionListeners[n]==="function"){i=e.optionListeners[n].call(t[e.pluginName],o)}}));return i}};function dispatchEvent(e){var t=e.sortable,n=e.rootEl,o=e.name,i=e.targetEl,r=e.cloneEl,s=e.toEl,l=e.fromEl,a=e.oldIndex,c=e.newIndex,d=e.oldDraggableIndex,u=e.newDraggableIndex,h=e.originalEvent,f=e.putSortable,v=e.extraEventProperties;t=t||n&&n[expando];if(!t)return;var p,g=t.options,m="on"+o.charAt(0).toUpperCase()+o.substr(1);if(window.CustomEvent&&!IE11OrLess&&!Edge){p=new CustomEvent(o,{bubbles:true,cancelable:true})}else{p=document.createEvent("Event");p.initEvent(o,true,true)}p.to=s||n;p.from=l||n;p.item=i||n;p.clone=r;p.oldIndex=a;p.newIndex=c;p.oldDraggableIndex=d;p.newDraggableIndex=u;p.originalEvent=h;p.pullMode=f?f.lastPutMode:undefined;var x=_objectSpread2(_objectSpread2({},v),PluginManager.getEventProperties(o,t));for(var b in x){p[b]=x[b]}if(n){n.dispatchEvent(p)}if(g[m]){g[m].call(t,p)}}var _excluded=["evt"];var pluginEvent=function e(t,n){var o=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},i=o.evt,r=_objectWithoutProperties(o,_excluded);PluginManager.pluginEvent.bind(Sortable)(t,n,_objectSpread2({dragEl:dragEl,parentEl:parentEl,ghostEl:ghostEl,rootEl:rootEl,nextEl:nextEl,lastDownEl:lastDownEl,cloneEl:cloneEl,cloneHidden:cloneHidden,dragStarted:moved,putSortable:putSortable,activeSortable:Sortable.active,originalEvent:i,oldIndex:oldIndex,oldDraggableIndex:oldDraggableIndex,newIndex:newIndex,newDraggableIndex:newDraggableIndex,hideGhostForTarget:_hideGhostForTarget,unhideGhostForTarget:_unhideGhostForTarget,cloneNowHidden:function e(){cloneHidden=true},cloneNowShown:function e(){cloneHidden=false},dispatchSortableEvent:function e(t){_dispatchEvent({sortable:n,name:t,originalEvent:i})}},r))};function _dispatchEvent(e){dispatchEvent(_objectSpread2({putSortable:putSortable,cloneEl:cloneEl,targetEl:dragEl,rootEl:rootEl,oldIndex:oldIndex,oldDraggableIndex:oldDraggableIndex,newIndex:newIndex,newDraggableIndex:newDraggableIndex},e))}var dragEl,parentEl,ghostEl,rootEl,nextEl,lastDownEl,cloneEl,cloneHidden,oldIndex,newIndex,oldDraggableIndex,newDraggableIndex,activeGroup,putSortable,awaitingDragStarted=false,ignoreNextClick=false,sortables=[],tapEvt,touchEvt,lastDx,lastDy,tapDistanceLeft,tapDistanceTop,moved,lastTarget,lastDirection,pastFirstInvertThresh=false,isCircumstantialInvert=false,targetMoveDistance,ghostRelativeParent,ghostRelativeParentInitialScroll=[],_silent=false,savedInputChecked=[];var documentExists=typeof document!=="undefined",PositionGhostAbsolutely=IOS,CSSFloatProperty=Edge||IE11OrLess?"cssFloat":"float",supportDraggable=documentExists&&!ChromeForAndroid&&!IOS&&"draggable"in document.createElement("div"),supportCssPointerEvents=function(){if(!documentExists)return;if(IE11OrLess){return false}var e=document.createElement("x");e.style.cssText="pointer-events:auto";return e.style.pointerEvents==="auto"}(),_detectDirection=function e(t,n){var o=css(t),i=parseInt(o.width)-parseInt(o.paddingLeft)-parseInt(o.paddingRight)-parseInt(o.borderLeftWidth)-parseInt(o.borderRightWidth),r=getChild(t,0,n),s=getChild(t,1,n),l=r&&css(r),a=s&&css(s),c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+getRect(r).width,d=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+getRect(s).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(r&&l["float"]&&l["float"]!=="none"){var u=l["float"]==="left"?"left":"right";return s&&(a.clear==="both"||a.clear===u)?"vertical":"horizontal"}return r&&(l.display==="block"||l.display==="flex"||l.display==="table"||l.display==="grid"||c>=i&&o[CSSFloatProperty]==="none"||s&&o[CSSFloatProperty]==="none"&&c+d>i)?"vertical":"horizontal"},_dragElInRowColumn=function e(t,n,o){var i=o?t.left:t.top,r=o?t.right:t.bottom,s=o?t.width:t.height,l=o?n.left:n.top,a=o?n.right:n.bottom,c=o?n.width:n.height;return i===l||r===a||i+s/2===l+c/2},_detectNearestEmptySortable=function e(t,n){var o;sortables.some((function(e){var i=e[expando].options.emptyInsertThreshold;if(!i||lastChild(e))return;var r=getRect(e),s=t>=r.left-i&&t<=r.right+i,l=n>=r.top-i&&n<=r.bottom+i;if(s&&l){return o=e}}));return o},_prepareGroup=function e(t){function n(e,t){return function(o,i,r,s){var l=o.options.group.name&&i.options.group.name&&o.options.group.name===i.options.group.name;if(e==null&&(t||l)){return true}else if(e==null||e===false){return false}else if(t&&e==="clone"){return e}else if(typeof e==="function"){return n(e(o,i,r,s),t)(o,i,r,s)}else{var a=(t?o:i).options.group.name;return e===true||typeof e==="string"&&e===a||e.join&&e.indexOf(a)>-1}}}var o={};var i=t.group;if(!i||_typeof(i)!="object"){i={name:i}}o.name=i.name;o.checkPull=n(i.pull,true);o.checkPut=n(i.put);o.revertClone=i.revertClone;t.group=o},_hideGhostForTarget=function e(){if(!supportCssPointerEvents&&ghostEl){css(ghostEl,"display","none")}},_unhideGhostForTarget=function e(){if(!supportCssPointerEvents&&ghostEl){css(ghostEl,"display","")}};if(documentExists&&!ChromeForAndroid){document.addEventListener("click",(function(e){if(ignoreNextClick){e.preventDefault();e.stopPropagation&&e.stopPropagation();e.stopImmediatePropagation&&e.stopImmediatePropagation();ignoreNextClick=false;return false}}),true)}var nearestEmptyInsertDetectEvent=function e(t){if(dragEl){t=t.touches?t.touches[0]:t;var n=_detectNearestEmptySortable(t.clientX,t.clientY);if(n){var o={};for(var i in t){if(t.hasOwnProperty(i)){o[i]=t[i]}}o.target=o.rootEl=n;o.preventDefault=void 0;o.stopPropagation=void 0;n[expando]._onDragOver(o)}}};var _checkOutsideTargetEl=function e(t){if(dragEl){dragEl.parentNode[expando]._isOutsideThisEl(t.target)}};function Sortable(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=_extends({},t);e[expando]=this;var n={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 _detectDirection(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,n){t.setData("Text",n.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:Sortable.supportPointer!==false&&"PointerEvent"in window&&(!Safari||IOS),emptyInsertThreshold:5};PluginManager.initializePlugins(this,e,n);for(var o in n){!(o in t)&&(t[o]=n[o])}_prepareGroup(t);for(var i in this){if(i.charAt(0)==="_"&&typeof this[i]==="function"){this[i]=this[i].bind(this)}}this.nativeDraggable=t.forceFallback?false:supportDraggable;if(this.nativeDraggable){this.options.touchStartThreshold=1}if(t.supportPointer){on(e,"pointerdown",this._onTapStart)}else{on(e,"mousedown",this._onTapStart);on(e,"touchstart",this._onTapStart)}if(this.nativeDraggable){on(e,"dragover",this);on(e,"dragenter",this)}sortables.push(this.el);t.store&&t.store.get&&this.sort(t.store.get(this)||[]);_extends(this,AnimationStateManager())}Sortable.prototype={constructor:Sortable,_isOutsideThisEl:function e(t){if(!this.el.contains(t)&&t!==this.el){lastTarget=null}},_getDirection:function e(t,n){return typeof this.options.direction==="function"?this.options.direction.call(this,t,n,dragEl):this.options.direction},_onTapStart:function e(t){if(!t.cancelable)return;var n=this,o=this.el,i=this.options,r=i.preventOnFilter,s=t.type,l=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,a=(l||t).target,c=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||a,d=i.filter;_saveInputCheckedState(o);if(dragEl){return}if(/mousedown|pointerdown/.test(s)&&t.button!==0||i.disabled){return}if(c.isContentEditable){return}if(!this.nativeDraggable&&Safari&&a&&a.tagName.toUpperCase()==="SELECT"){return}a=closest(a,i.draggable,o,false);if(a&&a.animated){return}if(lastDownEl===a){return}oldIndex=index(a);oldDraggableIndex=index(a,i.draggable);if(typeof d==="function"){if(d.call(this,t,a,this)){_dispatchEvent({sortable:n,rootEl:c,name:"filter",targetEl:a,toEl:o,fromEl:o});pluginEvent("filter",n,{evt:t});r&&t.preventDefault();return}}else if(d){d=d.split(",").some((function(e){e=closest(c,e.trim(),o,false);if(e){_dispatchEvent({sortable:n,rootEl:e,name:"filter",targetEl:a,fromEl:o,toEl:o});pluginEvent("filter",n,{evt:t});return true}}));if(d){r&&t.preventDefault();return}}if(i.handle&&!closest(c,i.handle,o,false)){return}this._prepareDragStart(t,l,a)},_prepareDragStart:function e(t,n,o){var i=this,r=i.el,s=i.options,l=r.ownerDocument,a;if(o&&!dragEl&&o.parentNode===r){var c=getRect(o);rootEl=r;dragEl=o;parentEl=dragEl.parentNode;nextEl=dragEl.nextSibling;lastDownEl=o;activeGroup=s.group;Sortable.dragged=dragEl;tapEvt={target:dragEl,clientX:(n||t).clientX,clientY:(n||t).clientY};tapDistanceLeft=tapEvt.clientX-c.left;tapDistanceTop=tapEvt.clientY-c.top;this._lastX=(n||t).clientX;this._lastY=(n||t).clientY;dragEl.style["will-change"]="all";a=function e(){pluginEvent("delayEnded",i,{evt:t});if(Sortable.eventCanceled){i._onDrop();return}i._disableDelayedDragEvents();if(!FireFox&&i.nativeDraggable){dragEl.draggable=true}i._triggerDragStart(t,n);_dispatchEvent({sortable:i,name:"choose",originalEvent:t});toggleClass(dragEl,s.chosenClass,true)};s.ignore.split(",").forEach((function(e){find(dragEl,e.trim(),_disableDraggable)}));on(l,"dragover",nearestEmptyInsertDetectEvent);on(l,"mousemove",nearestEmptyInsertDetectEvent);on(l,"touchmove",nearestEmptyInsertDetectEvent);if(s.supportPointer){on(l,"pointerup",i._onDrop);!this.nativeDraggable&&on(l,"pointercancel",i._onDrop)}else{on(l,"mouseup",i._onDrop);on(l,"touchend",i._onDrop);on(l,"touchcancel",i._onDrop)}if(FireFox&&this.nativeDraggable){this.options.touchStartThreshold=4;dragEl.draggable=true}pluginEvent("delayStart",this,{evt:t});if(s.delay&&(!s.delayOnTouchOnly||n)&&(!this.nativeDraggable||!(Edge||IE11OrLess))){if(Sortable.eventCanceled){this._onDrop();return}if(s.supportPointer){on(l,"pointerup",i._disableDelayedDrag);on(l,"pointercancel",i._disableDelayedDrag)}else{on(l,"mouseup",i._disableDelayedDrag);on(l,"touchend",i._disableDelayedDrag);on(l,"touchcancel",i._disableDelayedDrag)}on(l,"mousemove",i._delayedDragTouchMoveHandler);on(l,"touchmove",i._delayedDragTouchMoveHandler);s.supportPointer&&on(l,"pointermove",i._delayedDragTouchMoveHandler);i._dragStartTimer=setTimeout(a,s.delay)}else{a()}}},_delayedDragTouchMoveHandler:function e(t){var n=t.touches?t.touches[0]:t;if(Math.max(Math.abs(n.clientX-this._lastX),Math.abs(n.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))){this._disableDelayedDrag()}},_disableDelayedDrag:function e(){dragEl&&_disableDraggable(dragEl);clearTimeout(this._dragStartTimer);this._disableDelayedDragEvents()},_disableDelayedDragEvents:function e(){var t=this.el.ownerDocument;off(t,"mouseup",this._disableDelayedDrag);off(t,"touchend",this._disableDelayedDrag);off(t,"touchcancel",this._disableDelayedDrag);off(t,"pointerup",this._disableDelayedDrag);off(t,"pointercancel",this._disableDelayedDrag);off(t,"mousemove",this._delayedDragTouchMoveHandler);off(t,"touchmove",this._delayedDragTouchMoveHandler);off(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function e(t,n){n=n||t.pointerType=="touch"&&t;if(!this.nativeDraggable||n){if(this.options.supportPointer){on(document,"pointermove",this._onTouchMove)}else if(n){on(document,"touchmove",this._onTouchMove)}else{on(document,"mousemove",this._onTouchMove)}}else{on(dragEl,"dragend",this);on(rootEl,"dragstart",this._onDragStart)}try{if(document.selection){_nextTick((function(){document.selection.empty()}))}else{window.getSelection().removeAllRanges()}}catch(e){}},_dragStarted:function e(t,n){awaitingDragStarted=false;if(rootEl&&dragEl){pluginEvent("dragStarted",this,{evt:n});if(this.nativeDraggable){on(document,"dragover",_checkOutsideTargetEl)}var o=this.options;!t&&toggleClass(dragEl,o.dragClass,false);toggleClass(dragEl,o.ghostClass,true);Sortable.active=this;t&&this._appendGhost();_dispatchEvent({sortable:this,name:"start",originalEvent:n})}else{this._nulling()}},_emulateDragOver:function e(){if(touchEvt){this._lastX=touchEvt.clientX;this._lastY=touchEvt.clientY;_hideGhostForTarget();var t=document.elementFromPoint(touchEvt.clientX,touchEvt.clientY);var n=t;while(t&&t.shadowRoot){t=t.shadowRoot.elementFromPoint(touchEvt.clientX,touchEvt.clientY);if(t===n)break;n=t}dragEl.parentNode[expando]._isOutsideThisEl(t);if(n){do{if(n[expando]){var o=void 0;o=n[expando]._onDragOver({clientX:touchEvt.clientX,clientY:touchEvt.clientY,target:t,rootEl:n});if(o&&!this.options.dragoverBubble){break}}t=n}while(n=getParentOrHost(n))}_unhideGhostForTarget()}},_onTouchMove:function e(t){if(tapEvt){var n=this.options,o=n.fallbackTolerance,i=n.fallbackOffset,r=t.touches?t.touches[0]:t,s=ghostEl&&matrix(ghostEl,true),l=ghostEl&&s&&s.a,a=ghostEl&&s&&s.d,c=PositionGhostAbsolutely&&ghostRelativeParent&&getRelativeScrollOffset(ghostRelativeParent),d=(r.clientX-tapEvt.clientX+i.x)/(l||1)+(c?c[0]-ghostRelativeParentInitialScroll[0]:0)/(l||1),u=(r.clientY-tapEvt.clientY+i.y)/(a||1)+(c?c[1]-ghostRelativeParentInitialScroll[1]:0)/(a||1);if(!Sortable.active&&!awaitingDragStarted){if(o&&Math.max(Math.abs(r.clientX-this._lastX),Math.abs(r.clientY-this._lastY))<o){return}this._onDragStart(t,true)}if(ghostEl){if(s){s.e+=d-(lastDx||0);s.f+=u-(lastDy||0)}else{s={a:1,b:0,c:0,d:1,e:d,f:u}}var h="matrix(".concat(s.a,",").concat(s.b,",").concat(s.c,",").concat(s.d,",").concat(s.e,",").concat(s.f,")");css(ghostEl,"webkitTransform",h);css(ghostEl,"mozTransform",h);css(ghostEl,"msTransform",h);css(ghostEl,"transform",h);lastDx=d;lastDy=u;touchEvt=r}t.cancelable&&t.preventDefault()}},_appendGhost:function e(){if(!ghostEl){var t=this.options.fallbackOnBody?document.body:rootEl,n=getRect(dragEl,true,PositionGhostAbsolutely,true,t),o=this.options;if(PositionGhostAbsolutely){ghostRelativeParent=t;while(css(ghostRelativeParent,"position")==="static"&&css(ghostRelativeParent,"transform")==="none"&&ghostRelativeParent!==document){ghostRelativeParent=ghostRelativeParent.parentNode}if(ghostRelativeParent!==document.body&&ghostRelativeParent!==document.documentElement){if(ghostRelativeParent===document)ghostRelativeParent=getWindowScrollingElement();n.top+=ghostRelativeParent.scrollTop;n.left+=ghostRelativeParent.scrollLeft}else{ghostRelativeParent=getWindowScrollingElement()}ghostRelativeParentInitialScroll=getRelativeScrollOffset(ghostRelativeParent)}ghostEl=dragEl.cloneNode(true);toggleClass(ghostEl,o.ghostClass,false);toggleClass(ghostEl,o.fallbackClass,true);toggleClass(ghostEl,o.dragClass,true);css(ghostEl,"transition","");css(ghostEl,"transform","");css(ghostEl,"box-sizing","border-box");css(ghostEl,"margin",0);css(ghostEl,"top",n.top);css(ghostEl,"left",n.left);css(ghostEl,"width",n.width);css(ghostEl,"height",n.height);css(ghostEl,"opacity","0.8");css(ghostEl,"position",PositionGhostAbsolutely?"absolute":"fixed");css(ghostEl,"zIndex","100000");css(ghostEl,"pointerEvents","none");Sortable.ghost=ghostEl;t.appendChild(ghostEl);css(ghostEl,"transform-origin",tapDistanceLeft/parseInt(ghostEl.style.width)*100+"% "+tapDistanceTop/parseInt(ghostEl.style.height)*100+"%")}},_onDragStart:function e(t,n){var o=this;var i=t.dataTransfer;var r=o.options;pluginEvent("dragStart",this,{evt:t});if(Sortable.eventCanceled){this._onDrop();return}pluginEvent("setupClone",this);if(!Sortable.eventCanceled){cloneEl=clone(dragEl);cloneEl.removeAttribute("id");cloneEl.draggable=false;cloneEl.style["will-change"]="";this._hideClone();toggleClass(cloneEl,this.options.chosenClass,false);Sortable.clone=cloneEl}o.cloneId=_nextTick((function(){pluginEvent("clone",o);if(Sortable.eventCanceled)return;if(!o.options.removeCloneOnHide){rootEl.insertBefore(cloneEl,dragEl)}o._hideClone();_dispatchEvent({sortable:o,name:"clone"})}));!n&&toggleClass(dragEl,r.dragClass,true);if(n){ignoreNextClick=true;o._loopId=setInterval(o._emulateDragOver,50)}else{off(document,"mouseup",o._onDrop);off(document,"touchend",o._onDrop);off(document,"touchcancel",o._onDrop);if(i){i.effectAllowed="move";r.setData&&r.setData.call(o,i,dragEl)}on(document,"drop",o);css(dragEl,"transform","translateZ(0)")}awaitingDragStarted=true;o._dragStartId=_nextTick(o._dragStarted.bind(o,n,t));on(document,"selectstart",o);moved=true;window.getSelection().removeAllRanges();if(Safari){css(document.body,"user-select","none")}},_onDragOver:function e(t){var n=this.el,o=t.target,i,r,s,l=this.options,a=l.group,c=Sortable.active,d=activeGroup===a,u=l.sort,h=putSortable||c,f,v=this,p=false;if(_silent)return;function g(e,l){pluginEvent(e,v,_objectSpread2({evt:t,isOwner:d,axis:f?"vertical":"horizontal",revert:s,dragRect:i,targetRect:r,canSort:u,fromSortable:h,target:o,completed:x,onMove:function e(o,r){return _onMove(rootEl,n,dragEl,i,o,getRect(o),t,r)},changed:b},l))}function m(){g("dragOverAnimationCapture");v.captureAnimationState();if(v!==h){h.captureAnimationState()}}function x(e){g("dragOverCompleted",{insertion:e});if(e){if(d){c._hideClone()}else{c._showClone(v)}if(v!==h){toggleClass(dragEl,putSortable?putSortable.options.ghostClass:c.options.ghostClass,false);toggleClass(dragEl,l.ghostClass,true)}if(putSortable!==v&&v!==Sortable.active){putSortable=v}else if(v===Sortable.active&&putSortable){putSortable=null}if(h===v){v._ignoreWhileAnimating=o}v.animateAll((function(){g("dragOverAnimationComplete");v._ignoreWhileAnimating=null}));if(v!==h){h.animateAll();h._ignoreWhileAnimating=null}}if(o===dragEl&&!dragEl.animated||o===n&&!o.animated){lastTarget=null}if(!l.dragoverBubble&&!t.rootEl&&o!==document){dragEl.parentNode[expando]._isOutsideThisEl(t.target);!e&&nearestEmptyInsertDetectEvent(t)}!l.dragoverBubble&&t.stopPropagation&&t.stopPropagation();return p=true}function b(){newIndex=index(dragEl);newDraggableIndex=index(dragEl,l.draggable);_dispatchEvent({sortable:v,name:"change",toEl:n,newIndex:newIndex,newDraggableIndex:newDraggableIndex,originalEvent:t})}if(t.preventDefault!==void 0){t.cancelable&&t.preventDefault()}o=closest(o,l.draggable,n,true);g("dragOver");if(Sortable.eventCanceled)return p;if(dragEl.contains(t.target)||o.animated&&o.animatingX&&o.animatingY||v._ignoreWhileAnimating===o){return x(false)}ignoreNextClick=false;if(c&&!l.disabled&&(d?u||(s=parentEl!==rootEl):putSortable===this||(this.lastPutMode=activeGroup.checkPull(this,c,dragEl,t))&&a.checkPut(this,c,dragEl,t))){f=this._getDirection(t,o)==="vertical";i=getRect(dragEl);g("dragOverValid");if(Sortable.eventCanceled)return p;if(s){parentEl=rootEl;m();this._hideClone();g("revert");if(!Sortable.eventCanceled){if(nextEl){rootEl.insertBefore(dragEl,nextEl)}else{rootEl.appendChild(dragEl)}}return x(true)}var E=lastChild(n,l.draggable);if(!E||_ghostIsLast(t,f,this)&&!E.animated){if(E===dragEl){return x(false)}if(E&&n===t.target){o=E}if(o){r=getRect(o)}if(_onMove(rootEl,n,dragEl,i,o,r,t,!!o)!==false){m();if(E&&E.nextSibling){n.insertBefore(dragEl,E.nextSibling)}else{n.appendChild(dragEl)}parentEl=n;b();return x(true)}}else if(E&&_ghostIsFirst(t,f,this)){var w=getChild(n,0,l,true);if(w===dragEl){return x(false)}o=w;r=getRect(o);if(_onMove(rootEl,n,dragEl,i,o,r,t,false)!==false){m();n.insertBefore(dragEl,w);parentEl=n;b();return x(true)}}else if(o.parentNode===n){r=getRect(o);var S=0,_,y=dragEl.parentNode!==n,I=!_dragElInRowColumn(dragEl.animated&&dragEl.toRect||i,o.animated&&o.toRect||r,f),C=f?"top":"left",T=isScrolledPast(o,"top","top")||isScrolledPast(dragEl,"top","top"),D=T?T.scrollTop:void 0;if(lastTarget!==o){_=r[C];pastFirstInvertThresh=false;isCircumstantialInvert=!I&&l.invertSwap||y}S=_getSwapDirection(t,o,r,f,I?1:l.swapThreshold,l.invertedSwapThreshold==null?l.swapThreshold:l.invertedSwapThreshold,isCircumstantialInvert,lastTarget===o);var k;if(S!==0){var q=index(dragEl);do{q-=S;k=parentEl.children[q]}while(k&&(css(k,"display")==="none"||k===ghostEl))}if(S===0||k===o){return x(false)}lastTarget=o;lastDirection=S;var M=o.nextElementSibling,R=false;R=S===1;var A=_onMove(rootEl,n,dragEl,i,o,r,t,R);if(A!==false){if(A===1||A===-1){R=A===1}_silent=true;setTimeout(_unsilent,30);m();if(R&&!M){n.appendChild(dragEl)}else{o.parentNode.insertBefore(dragEl,R?M:o)}if(T){scrollBy(T,0,D-T.scrollTop)}parentEl=dragEl.parentNode;if(_!==undefined&&!isCircumstantialInvert){targetMoveDistance=Math.abs(_-getRect(o)[C])}b();return x(true)}}if(n.contains(dragEl)){return x(false)}}return false},_ignoreWhileAnimating:null,_offMoveEvents:function e(){off(document,"mousemove",this._onTouchMove);off(document,"touchmove",this._onTouchMove);off(document,"pointermove",this._onTouchMove);off(document,"dragover",nearestEmptyInsertDetectEvent);off(document,"mousemove",nearestEmptyInsertDetectEvent);off(document,"touchmove",nearestEmptyInsertDetectEvent)},_offUpEvents:function e(){var t=this.el.ownerDocument;off(t,"mouseup",this._onDrop);off(t,"touchend",this._onDrop);off(t,"pointerup",this._onDrop);off(t,"pointercancel",this._onDrop);off(t,"touchcancel",this._onDrop);off(document,"selectstart",this)},_onDrop:function e(t){var n=this.el,o=this.options;newIndex=index(dragEl);newDraggableIndex=index(dragEl,o.draggable);pluginEvent("drop",this,{evt:t});parentEl=dragEl&&dragEl.parentNode;newIndex=index(dragEl);newDraggableIndex=index(dragEl,o.draggable);if(Sortable.eventCanceled){this._nulling();return}awaitingDragStarted=false;isCircumstantialInvert=false;pastFirstInvertThresh=false;clearInterval(this._loopId);clearTimeout(this._dragStartTimer);_cancelNextTick(this.cloneId);_cancelNextTick(this._dragStartId);if(this.nativeDraggable){off(document,"drop",this);off(n,"dragstart",this._onDragStart)}this._offMoveEvents();this._offUpEvents();if(Safari){css(document.body,"user-select","")}css(dragEl,"transform","");if(t){if(moved){t.cancelable&&t.preventDefault();!o.dropBubble&&t.stopPropagation()}ghostEl&&ghostEl.parentNode&&ghostEl.parentNode.removeChild(ghostEl);if(rootEl===parentEl||putSortable&&putSortable.lastPutMode!=="clone"){cloneEl&&cloneEl.parentNode&&cloneEl.parentNode.removeChild(cloneEl)}if(dragEl){if(this.nativeDraggable){off(dragEl,"dragend",this)}_disableDraggable(dragEl);dragEl.style["will-change"]="";if(moved&&!awaitingDragStarted){toggleClass(dragEl,putSortable?putSortable.options.ghostClass:this.options.ghostClass,false)}toggleClass(dragEl,this.options.chosenClass,false);_dispatchEvent({sortable:this,name:"unchoose",toEl:parentEl,newIndex:null,newDraggableIndex:null,originalEvent:t});if(rootEl!==parentEl){if(newIndex>=0){_dispatchEvent({rootEl:parentEl,name:"add",toEl:parentEl,fromEl:rootEl,originalEvent:t});_dispatchEvent({sortable:this,name:"remove",toEl:parentEl,originalEvent:t});_dispatchEvent({rootEl:parentEl,name:"sort",toEl:parentEl,fromEl:rootEl,originalEvent:t});_dispatchEvent({sortable:this,name:"sort",toEl:parentEl,originalEvent:t})}putSortable&&putSortable.save()}else{if(newIndex!==oldIndex){if(newIndex>=0){_dispatchEvent({sortable:this,name:"update",toEl:parentEl,originalEvent:t});_dispatchEvent({sortable:this,name:"sort",toEl:parentEl,originalEvent:t})}}}if(Sortable.active){if(newIndex==null||newIndex===-1){newIndex=oldIndex;newDraggableIndex=oldDraggableIndex}_dispatchEvent({sortable:this,name:"end",toEl:parentEl,originalEvent:t});this.save()}}}this._nulling()},_nulling:function e(){pluginEvent("nulling",this);rootEl=dragEl=parentEl=ghostEl=nextEl=cloneEl=lastDownEl=cloneHidden=tapEvt=touchEvt=moved=newIndex=newDraggableIndex=oldIndex=oldDraggableIndex=lastTarget=lastDirection=putSortable=activeGroup=Sortable.dragged=Sortable.ghost=Sortable.clone=Sortable.active=null;savedInputChecked.forEach((function(e){e.checked=true}));savedInputChecked.length=lastDx=lastDy=0},handleEvent:function e(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":if(dragEl){this._onDragOver(t);_globalDragOver(t)}break;case"selectstart":t.preventDefault();break}},toArray:function e(){var t=[],n,o=this.el.children,i=0,r=o.length,s=this.options;for(;i<r;i++){n=o[i];if(closest(n,s.draggable,this.el,false)){t.push(n.getAttribute(s.dataIdAttr)||_generateId(n))}}return t},sort:function e(t,n){var o={},i=this.el;this.toArray().forEach((function(e,t){var n=i.children[t];if(closest(n,this.options.draggable,i,false)){o[e]=n}}),this);n&&this.captureAnimationState();t.forEach((function(e){if(o[e]){i.removeChild(o[e]);i.appendChild(o[e])}}));n&&this.animateAll()},save:function e(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function e(t,n){return closest(t,n||this.options.draggable,this.el,false)},option:function e(t,n){var o=this.options;if(n===void 0){return o[t]}else{var i=PluginManager.modifyOption(this,t,n);if(typeof i!=="undefined"){o[t]=i}else{o[t]=n}if(t==="group"){_prepareGroup(o)}}},destroy:function e(){pluginEvent("destroy",this);var t=this.el;t[expando]=null;off(t,"mousedown",this._onTapStart);off(t,"touchstart",this._onTapStart);off(t,"pointerdown",this._onTapStart);if(this.nativeDraggable){off(t,"dragover",this);off(t,"dragenter",this)}Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),(function(e){e.removeAttribute("draggable")}));this._onDrop();this._disableDelayedDragEvents();sortables.splice(sortables.indexOf(this.el),1);this.el=t=null},_hideClone:function e(){if(!cloneHidden){pluginEvent("hideClone",this);if(Sortable.eventCanceled)return;css(cloneEl,"display","none");if(this.options.removeCloneOnHide&&cloneEl.parentNode){cloneEl.parentNode.removeChild(cloneEl)}cloneHidden=true}},_showClone:function e(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(cloneHidden){pluginEvent("showClone",this);if(Sortable.eventCanceled)return;if(dragEl.parentNode==rootEl&&!this.options.group.revertClone){rootEl.insertBefore(cloneEl,dragEl)}else if(nextEl){rootEl.insertBefore(cloneEl,nextEl)}else{rootEl.appendChild(cloneEl)}if(this.options.group.revertClone){this.animate(dragEl,cloneEl)}css(cloneEl,"display","");cloneHidden=false}}};function _globalDragOver(e){if(e.dataTransfer){e.dataTransfer.dropEffect="move"}e.cancelable&&e.preventDefault()}function _onMove(e,t,n,o,i,r,s,l){var a,c=e[expando],d=c.options.onMove,u;if(window.CustomEvent&&!IE11OrLess&&!Edge){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=n;a.draggedRect=o;a.related=i||t;a.relatedRect=r||getRect(t);a.willInsertAfter=l;a.originalEvent=s;e.dispatchEvent(a);if(d){u=d.call(c,a,s)}return u}function _disableDraggable(e){e.draggable=false}function _unsilent(){_silent=false}function _ghostIsFirst(e,t,n){var o=getRect(getChild(n.el,0,n.options,true));var i=getChildContainingRectFromElement(n.el,n.options,ghostEl);var r=10;return t?e.clientX<i.left-r||e.clientY<o.top&&e.clientX<o.right:e.clientY<i.top-r||e.clientY<o.bottom&&e.clientX<o.left}function _ghostIsLast(e,t,n){var o=getRect(lastChild(n.el,n.options.draggable));var i=getChildContainingRectFromElement(n.el,n.options,ghostEl);var r=10;return t?e.clientX>i.right+r||e.clientY>o.bottom&&e.clientX>o.left:e.clientY>i.bottom+r||e.clientX>o.right&&e.clientY>o.top}function _getSwapDirection(e,t,n,o,i,r,s,l){var a=o?e.clientY:e.clientX,c=o?n.height:n.width,d=o?n.top:n.left,u=o?n.bottom:n.right,h=false;if(!s){if(l&&targetMoveDistance<c*i){if(!pastFirstInvertThresh&&(lastDirection===1?a>d+c*r/2:a<u-c*r/2)){pastFirstInvertThresh=true}if(!pastFirstInvertThresh){if(lastDirection===1?a<d+targetMoveDistance:a>u-targetMoveDistance){return-lastDirection}}else{h=true}}else{if(a>d+c*(1-i)/2&&a<u-c*(1-i)/2){return _getInsertDirection(t)}}}h=h||s;if(h){if(a<d+c*r/2||a>u-c*r/2){return a>d+c/2?1:-1}}return 0}function _getInsertDirection(e){if(index(dragEl)<index(e)){return 1}else{return-1}}function _generateId(e){var t=e.tagName+e.className+e.src+e.href+e.textContent,n=t.length,o=0;while(n--){o+=t.charCodeAt(n)}return o.toString(36)}function _saveInputCheckedState(e){savedInputChecked.length=0;var t=e.getElementsByTagName("input");var n=t.length;while(n--){var o=t[n];o.checked&&savedInputChecked.push(o)}}function _nextTick(e){return setTimeout(e,0)}function _cancelNextTick(e){return clearTimeout(e)}if(documentExists){on(document,"touchmove",(function(e){if((Sortable.active||awaitingDragStarted)&&e.cancelable){e.preventDefault()}}))}Sortable.utils={on:on,off:off,css:css,find:find,is:function e(t,n){return!!closest(t,n,t,false)},extend:extend,throttle:throttle,closest:closest,toggleClass:toggleClass,clone:clone,index:index,nextTick:_nextTick,cancelNextTick:_cancelNextTick,detectDirection:_detectDirection,getChild:getChild,expando:expando};Sortable.get=function(e){return e[expando]};Sortable.mount=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++){t[n]=arguments[n]}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)Sortable.utils=_objectSpread2(_objectSpread2({},Sortable.utils),e.utils);PluginManager.mount(e)}))};Sortable.create=function(e,t){return new Sortable(e,t)};Sortable.version=version;var autoScrolls=[],scrollEl,scrollRootEl,scrolling=false,lastAutoScrollX,lastAutoScrollY,touchEvt$1,pointerElemChangedInterval;function AutoScrollPlugin(){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 n=t.originalEvent;if(this.sortable.nativeDraggable){on(document,"dragover",this._handleAutoScroll)}else{if(this.options.supportPointer){on(document,"pointermove",this._handleFallbackAutoScroll)}else if(n.touches){on(document,"touchmove",this._handleFallbackAutoScroll)}else{on(document,"mousemove",this._handleFallbackAutoScroll)}}},dragOverCompleted:function e(t){var n=t.originalEvent;if(!this.options.dragOverBubble&&!n.rootEl){this._handleAutoScroll(n)}},drop:function e(){if(this.sortable.nativeDraggable){off(document,"dragover",this._handleAutoScroll)}else{off(document,"pointermove",this._handleFallbackAutoScroll);off(document,"touchmove",this._handleFallbackAutoScroll);off(document,"mousemove",this._handleFallbackAutoScroll)}clearPointerElemChangedInterval();clearAutoScrolls();cancelThrottle()},nulling:function e(){touchEvt$1=scrollRootEl=scrollEl=scrolling=pointerElemChangedInterval=lastAutoScrollX=lastAutoScrollY=null;autoScrolls.length=0},_handleFallbackAutoScroll:function e(t){this._handleAutoScroll(t,true)},_handleAutoScroll:function e(t,n){var o=this;var i=(t.touches?t.touches[0]:t).clientX,r=(t.touches?t.touches[0]:t).clientY,s=document.elementFromPoint(i,r);touchEvt$1=t;if(n||this.options.forceAutoScrollFallback||Edge||IE11OrLess||Safari){autoScroll(t,this.options,s,n);var l=getParentAutoScrollElement(s,true);if(scrolling&&(!pointerElemChangedInterval||i!==lastAutoScrollX||r!==lastAutoScrollY)){pointerElemChangedInterval&&clearPointerElemChangedInterval();pointerElemChangedInterval=setInterval((function(){var e=getParentAutoScrollElement(document.elementFromPoint(i,r),true);if(e!==l){l=e;clearAutoScrolls()}autoScroll(t,o.options,e,n)}),10);lastAutoScrollX=i;lastAutoScrollY=r}}else{if(!this.options.bubbleScroll||getParentAutoScrollElement(s,true)===getWindowScrollingElement()){clearAutoScrolls();return}autoScroll(t,this.options,getParentAutoScrollElement(s,false),false)}}};return _extends(e,{pluginName:"scroll",initializeByDefault:true})}function clearAutoScrolls(){autoScrolls.forEach((function(e){clearInterval(e.pid)}));autoScrolls=[]}function clearPointerElemChangedInterval(){clearInterval(pointerElemChangedInterval)}var autoScroll=throttle((function(e,t,n,o){if(!t.scroll)return;var i=(e.touches?e.touches[0]:e).clientX,r=(e.touches?e.touches[0]:e).clientY,s=t.scrollSensitivity,l=t.scrollSpeed,a=getWindowScrollingElement();var c=false,d;if(scrollRootEl!==n){scrollRootEl=n;clearAutoScrolls();scrollEl=t.scroll;d=t.scrollFn;if(scrollEl===true){scrollEl=getParentAutoScrollElement(n,true)}}var u=0;var h=scrollEl;do{var f=h,v=getRect(f),p=v.top,g=v.bottom,m=v.left,x=v.right,b=v.width,E=v.height,w=void 0,S=void 0,_=f.scrollWidth,y=f.scrollHeight,I=css(f),C=f.scrollLeft,T=f.scrollTop;if(f===a){w=b<_&&(I.overflowX==="auto"||I.overflowX==="scroll"||I.overflowX==="visible");S=E<y&&(I.overflowY==="auto"||I.overflowY==="scroll"||I.overflowY==="visible")}else{w=b<_&&(I.overflowX==="auto"||I.overflowX==="scroll");S=E<y&&(I.overflowY==="auto"||I.overflowY==="scroll")}var D=w&&(Math.abs(x-i)<=s&&C+b<_)-(Math.abs(m-i)<=s&&!!C);var k=S&&(Math.abs(g-r)<=s&&T+E<y)-(Math.abs(p-r)<=s&&!!T);if(!autoScrolls[u]){for(var q=0;q<=u;q++){if(!autoScrolls[q]){autoScrolls[q]={}}}}if(autoScrolls[u].vx!=D||autoScrolls[u].vy!=k||autoScrolls[u].el!==f){autoScrolls[u].el=f;autoScrolls[u].vx=D;autoScrolls[u].vy=k;clearInterval(autoScrolls[u].pid);if(D!=0||k!=0){c=true;autoScrolls[u].pid=setInterval(function(){if(o&&this.layer===0){Sortable.active._onTouchMove(touchEvt$1)}var t=autoScrolls[this.layer].vy?autoScrolls[this.layer].vy*l:0;var n=autoScrolls[this.layer].vx?autoScrolls[this.layer].vx*l:0;if(typeof d==="function"){if(d.call(Sortable.dragged.parentNode[expando],n,t,e,touchEvt$1,autoScrolls[this.layer].el)!=="continue"){return}}scrollBy(autoScrolls[this.layer].el,n,t)}.bind({layer:u}),24)}}u++}while(t.bubbleScroll&&h!==a&&(h=getParentAutoScrollElement(h,false)));scrolling=c}),30);var drop=function e(t){var n=t.originalEvent,o=t.putSortable,i=t.dragEl,r=t.activeSortable,s=t.dispatchSortableEvent,l=t.hideGhostForTarget,a=t.unhideGhostForTarget;if(!n)return;var c=o||r;l();var d=n.changedTouches&&n.changedTouches.length?n.changedTouches[0]:n;var u=document.elementFromPoint(d.clientX,d.clientY);a();if(c&&!c.el.contains(u)){s("spill");this.onSpill({dragEl:i,putSortable:o})}};function Revert(){}Revert.prototype={startIndex:null,dragStart:function e(t){var n=t.oldDraggableIndex;this.startIndex=n},onSpill:function e(t){var n=t.dragEl,o=t.putSortable;this.sortable.captureAnimationState();if(o){o.captureAnimationState()}var i=getChild(this.sortable.el,this.startIndex,this.options);if(i){this.sortable.el.insertBefore(n,i)}else{this.sortable.el.appendChild(n)}this.sortable.animateAll();if(o){o.animateAll()}},drop:drop};_extends(Revert,{pluginName:"revertOnSpill"});function Remove(){}Remove.prototype={onSpill:function e(t){var n=t.dragEl,o=t.putSortable;var i=o||this.sortable;i.captureAnimationState();n.parentNode&&n.parentNode.removeChild(n);i.animateAll()},drop:drop};_extends(Remove,{pluginName:"removeOnSpill"});Sortable.mount(new AutoScrollPlugin);Sortable.mount(Remove,Revert);var verdocsTemplateRolesCss='verdocs-template-roles{display:block;max-width:600px;font-family:var(--verdocs-primary-font, "Inter", "Barlow", 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}';var settingsIcon='<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20" fill="#00000089"><path d="m8.021 17.917-.313-2.5q-.27-.125-.625-.334-.354-.208-.625-.395l-2.312.979-1.979-3.438 1.979-1.5q-.021-.167-.031-.364-.011-.198-.011-.365 0-.146.011-.344.01-.198.031-.385l-1.979-1.5 1.979-3.417 2.312.958q.271-.187.615-.385t.635-.344l.313-2.5h3.958l.313 2.5q.312.167.625.344.312.177.604.385l2.333-.958 1.979 3.417-1.979 1.521q.021.187.021.364V10q0 .146-.01.333-.011.188-.011.396l1.958 1.5-1.979 3.438-2.312-.979q-.292.208-.615.395-.323.188-.614.334l-.313 2.5Zm1.937-5.355q1.063 0 1.813-.75t.75-1.812q0-1.062-.75-1.812t-1.813-.75q-1.041 0-1.802.75-.76.75-.76 1.812t.76 1.812q.761.75 1.802.75Zm0-1.333q-.5 0-.864-.364-.365-.365-.365-.865t.365-.865q.364-.364.864-.364t.865.364q.365.365.365.865t-.365.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.187q.605-.167 1.136-.49.531-.323 1.031-.802l2.021.875.854-1.375-1.792-1.354q.105-.333.136-.635.031-.303.031-.615 0-.292-.031-.573-.031-.281-.115-.635l1.792-1.396-.834-1.375-2.062.875q-.438-.438-1.021-.781-.583-.344-1.125-.49l-.271-2.208H9.167l-.271 2.208q-.584.146-1.125.458-.542.313-1.042.792l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.479.458 1.021.771.542.312 1.146.479Z"/></svg>';var plusIcon='<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor"><path strokeLinecap="round" strokeLinejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>';var iconSigner='<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24"><path d="m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z"/></svg>';var iconApprover='<svg xmlns="http://www.w3.org/2000/svg" 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>';var iconCC='<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>';var VerdocsTemplateRoles=function(){function e(e){registerInstance(this,e);this.next=createEvent(this,"next");this.exit=createEvent(this,"exit");this.sdkError=createEvent(this,"sdkError");this.rolesUpdated=createEvent(this,"rolesUpdated");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.showingRoleDialog=null;this.sender=null;this.dragging=false;this.loading=true;this.template=null;this.sortableRefs=[]}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate();this.cleanupSortables()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[ROLES] Loading template",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){console.log("[ROLES] Template Updated",t);e.template=t;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.templateId){console.log("[ROLES] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[ROLES] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(o){console.log("[ROLES] Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.cleanupSortables=function(){this.sortableRefs.forEach((function(e){return e.destroy()}));this.sortableRefs.length=0};e.prototype.componentDidRender=function(){var e=this;this.cleanupSortables();var t=this.getSequenceNumbers();(t||[]).forEach((function(t){var n=document.getElementById("verdocs-roles-sequence-".concat(t));if(n){var o=new Sortable(n,{group:"roles",animation:150,dragoverBubble:true,filter:".no-drag",onEnd:e.handleMoveEnd.bind(e),onChoose:function(){return e.dragging=true},onUnchoose:function(){return e.dragging=false}});e.sortableRefs.push(o)}}));var n=document.getElementById("verdocs-roles-sequence-add-target");if(n){console.log("[ROLES] Applying sortable to add-sequence slot");var o=new Sortable(n,{group:"roles",animation:150,dragoverBubble:true,filter:".no-drag",onEnd:this.handleMoveEnd.bind(this),onChoose:function(){return e.dragging=true},onUnchoose:function(){return e.dragging=false}});this.sortableRefs.push(o)}};e.prototype.handleMoveEnd=function(e){var t=this;var n=+e.from.dataset.sequence;var o=+e.to.dataset.sequence;var i=+e.oldIndex+1;var r=+e.newIndex+1;console.log("Move from ".concat(n,":").concat(i," to ").concat(o,":").concat(r),e.item);var s={};var l=this.getSequenceNumbers();l.forEach((function(e){var n=t.getRolesAtSequence(e);s[String(e)]=JSON.parse(JSON.stringify(n))}));s[l[l.length-1]+1]=[];var a=s[n].splice(i-1,1)[0];s[o]||(s[o]=[]);s[o].splice(r-1,0,a);var c=[];Object.entries(s).forEach((function(e){var n=e[0],o=e[1];o.forEach((function(e,o){if(!e){return}var i=+o+1;if(e.sequence!==+n||e.order!==i){e.sequence=+n;e.order=i;c.push(updateTemplateRole(t.endpoint,t.templateId,e.name,{sequence:+n,order:i}).then((function(t){return console.log("[ROLES] Updated role",e.name,t)})).catch((function(e){return console.log("[ROLES] Error updating role",e)})))}}))}));return Promise.all(c).then((function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){return[2,console.log("[ROLES] Done renumbering")]}))}))})).catch((function(e){return console.log("[ROLES] Error updating roles",e)}))};e.prototype.handleCancel=function(){var e;(e=this.exit)===null||e===void 0?void 0:e.emit()};e.prototype.handleSubmit=function(){var e;(e=this.next)===null||e===void 0?void 0:e.emit()};e.prototype.getSortedRoles=function(){var e;return(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).sort((function(e,t){return e.sequence===t.sequence?e.order-t.order:e.sequence-t.sequence}))};e.prototype.getSequenceNumbers=function(){var e={};this.getSortedRoles().forEach((function(t){e[t.sequence]=true}));console.log("[ROLES] Sequences",e);return Object.keys(e).map((function(e){return+e})).sort((function(e,t){return e-t}))};e.prototype.getRoleNames=function(){var e=this.getSortedRoles();return e.map((function(e){return e.name}))};e.prototype.getRolesAtSequence=function(e){var t;return(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).filter((function(t){return t&&t.sequence===e}))};e.prototype.renumberTemplateRoles=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n,o;var i=this;return __generator(this,(function(r){switch(r.label){case 0:t={};n=[];o=this.getSequenceNumbers();(o||[]).forEach((function(e){(t[e]||[]).forEach((function(t,o){var r=+o+1;if(t.sequence!==+e||t.order!==r){console.log("[ROLES] Updating role",t.name,"from",t.sequence,t.order,"to",e,r);t.sequence=+e;t.order=r;n.push(updateTemplateRole(i.endpoint,i.templateId,t.name,{sequence:+e,order:r}).then((function(e){return console.log("[ROLES] Updated role",t.name,e)})).catch((function(e){return console.log("[ROLES] Error updating role",e)})))}}))}));console.log("[ROLES] Awaiting ".concat(n.length," renumber requests"));return[4,Promise.all(n).then((function(){return __awaiter(i,void 0,void 0,(function(){var e;return __generator(this,(function(n){e=JSON.parse(JSON.stringify(this.template));e.roles=Object.keys(t).reduce((function(e,n){return e.concat(t[n])}),[]);console.log("[ROLES] Done renumbering",e.roles.map((function(e){return{name:e.name,sequence:e.sequence,order:e.order}})));Store.updateTemplate(this.templateId,e);return[2]}))}))}))];case 1:r.sent();(e=this.rolesUpdated)===null||e===void 0?void 0:e.emit({event:"updated",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()});return[2]}}))}))};e.prototype.getNextRoleName=function(){var e,t;var n="";var o=(((e=this.template)===null||e===void 0?void 0:e.roles)||[]).length;do{o++;n="Recipient ".concat(o)}while(!n||(((t=this.template)===null||t===void 0?void 0:t.roles)||[]).some((function(e){return e&&e.name===n})));return n};e.prototype.callCreateRole=function(e,t,n){var o=this;console.log("[ROLES] Will create role",{name:e,sequence:t,order:n});createTemplateRole(this.endpoint,this.templateId,{template_id:this.templateId,name:e,sequence:t,message:"",order:n,full_name:null,first_name:"",last_name:"",email:"",phone:"",type:"signer",delegator:false}).then((function(e){return __awaiter(o,void 0,void 0,(function(){var t;return __generator(this,(function(n){switch(n.label){case 0:console.log("[ROLES] Created role",e);console.log("Updating template in data store");return[4,Store.getTemplate(this.endpoint,this.templateId,true)];case 1:n.sent();(t=this.rolesUpdated)===null||t===void 0?void 0:t.emit({event:"added",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()});return[2]}}))}))})).catch((function(e){console.log("[ROLES] Error creating role",e)}))};e.prototype.handleAddRole=function(e,t){e.stopPropagation();var n=this.getRolesAtSequence(t).length+1;var o=this.getNextRoleName();this.callCreateRole(o,t,n)};e.prototype.handleAddStep=function(e,t){e.stopPropagation();var n=1;var o=this.getNextRoleName();this.callCreateRole(o,t,n)};e.prototype.render=function(){var e=this;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading||!this.template){return h(Host,{class:"loading"},h("verdocs-loader",null))}var t=this.getRoleNames();var n=this.getSequenceNumbers();var o=n&&n.length>0?(n[n.length-1]||0)+1:1;console.log("[ROLES] Rendering",{roleNames:t,sequences:n,nextSequence:o});return h(Host,{class:{dragging:this.dragging}},h("form",{onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off"},h("h5",null,"Roles and Workflow"),h("div",{class:"roles"},n.map((function(t,n){return h("div",{class:"sequence"},h("div",{class:"sequence-label no-drag"},n+1,"."),h("div",{class:"sequence-roles",id:"verdocs-roles-sequence-".concat(t),"data-sequence":t},e.getRolesAtSequence(t).map((function(n){var o=!n.email||!n.first_name||!n.last_name;return o?h("div",{class:"role","data-rolename":n.name,"data-sequence":t,"data-order":n.order},h("div",{class:"role-name"},n.name),h("div",{class:"icons"},h("div",{class:"gear-button",innerHTML:settingsIcon,onClick:function(){return e.showingRoleDialog=n.name},"aria-role":"button"}),h("span",{class:"type-icon",innerHTML:n.type==="signer"?iconSigner:n.type==="cc"?iconCC:iconApprover}))):h("div",{class:"role","data-rolename":n.name,"data-sequence":t,"data-order":n.order},h("div",{class:"role-name"},formatFullName(n)),h("div",{class:"icons"},h("div",{class:"gear-button",innerHTML:settingsIcon,onClick:function(){return e.showingRoleDialog=n.name},"aria-role":"button"}),h("span",{class:"type-icon",innerHTML:n.type==="signer"?iconSigner:n.type==="cc"?iconCC:iconApprover})))}))),h("button",{class:"add-role no-drag",onClick:function(n){return e.handleAddRole(n,t)}},"+ Add Role"))})),h("div",{class:"sequence add-sequence"},h("div",{class:"sequence-label no-drag"},n.length+1,"."),h("div",{class:"sequence-roles",id:"verdocs-roles-sequence-add-target","data-sequence":o}),h("button",{class:"add-role no-drag",onClick:function(t){return e.handleAddRole(t,o)}},"+ Add Role"))),t.length<1&&h("div",{class:"empty"},"You must add at least one Role before proceeding.",h("br",null)," Click the ",h("span",{innerHTML:plusIcon})," Add button above to get started."),h("div",{class:"buttons"},h("div",{class:"flex-fill"}),h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(){return e.handleCancel()}}),h("verdocs-button",{label:"OK",size:"small",onClick:function(){return e.handleSubmit()},disabled:t.length<1}))),this.showingRoleDialog&&h("verdocs-menu-panel",{onClose:function(){return e.showingRoleDialog=null}},h("verdocs-template-role-properties",{endpoint:this.endpoint,templateId:this.templateId,roleName:this.showingRoleDialog,onClose:function(){var t;(t=document.getElementById("verdocs-menu-panel-overlay"))===null||t===void 0?void 0:t.remove();e.showingRoleDialog=null},onDelete:function(){return __awaiter(e,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:this.showingRoleDialog=null;return[4,this.renumberTemplateRoles()];case 1:t.sent();(e=this.rolesUpdated)===null||e===void 0?void 0:e.emit({event:"deleted",endpoint:this.endpoint,templateId:this.templateId,roles:this.getSortedRoles()});return[2]}}))}))}})))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();VerdocsTemplateRoles.style=verdocsTemplateRolesCss;var verdocsTemplateSettingsCss='verdocs-template-settings{display:block;max-width:600px;font-family:var(--verdocs-primary-font, "Inter", "Barlow", sans-serif)}verdocs-template-settings>form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;padding:12px}verdocs-template-settings>form h5{font-size:16px;font-weight:bold;color:#46497d;margin:0 0 10px 0}verdocs-template-settings>form label{display:block;font-size:14px;font-weight:500;margin:0 0 4px 0;color:#5c6575}verdocs-template-settings>form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-settings>form input:focus{outline:none}verdocs-template-settings>form .row{margin:20px 0 0 0}verdocs-template-settings .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-settings ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-settings ::-moz-placeholder{color:#aaaaaa}verdocs-template-settings :-ms-input-placeholder{color:#aaaaaa}verdocs-template-settings ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-settings ::placeholder{color:#aaaaaa}';var MS_PER_DAY=24*60*60*1e3;var VerdocsTemplateSettings=function(){function e(e){registerInstance(this,e);this.next=createEvent(this,"next");this.exit=createEvent(this,"exit");this.sdkError=createEvent(this,"sdkError");this.templateUpdated=createEvent(this,"templateUpdated");this.templateListenerId=null;this.endpoint=VerdocsEndpoint.getDefault();this.templateId="";this.name=null;this.visibility="private";this.sender="envelope_creator";this.sendReminders=false;this.initialReminder=0;this.followupReminders=0;this.dirty=false;this.loading=true;this.template=null}e.prototype.disconnectedCallback=function(){this.unlistenToTemplate()};e.prototype.listenToTemplate=function(){return __awaiter(this,void 0,void 0,(function(){var e=this;return __generator(this,(function(t){console.log("[SETTINGS] Loading template",this.templateId);this.unlistenToTemplate();Store.subscribe("templates",this.templateId,(function(){return getTemplate(e.endpoint,e.templateId)}),false,(function(t){console.log("[SETTINGS] Template Updated",t);e.template=t;e.name=t.name;e.visibility=t.visibility;e.sender=t.sender;e.sendReminders=t.initial_reminder!==null;e.initialReminder=t.initial_reminder?Math.floor(t.initial_reminder/MS_PER_DAY):null;e.followupReminders=t.followup_reminders?Math.floor(t.followup_reminders/MS_PER_DAY):null;e.dirty=false;e.loading=false}));return[2]}))}))};e.prototype.unlistenToTemplate=function(){if(this.templateListenerId){Store.store.delListener(this.templateListenerId);this.templateListenerId=null}};e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n;return __generator(this,(function(o){try{this.endpoint.loadSession();if(!this.templateId){console.log("[SETTINGS] Missing required template ID ".concat(this.templateId));return[2]}if(!this.endpoint.session){console.log("[SETTINGS] Unable to start builder session, must be authenticated");return[2]}this.listenToTemplate()}catch(o){console.log("[SETTINGS] Error with preview session",o);(e=this.sdkError)===null||e===void 0?void 0:e.emit(new SDKError(o.message,(t=o.response)===null||t===void 0?void 0:t.status,(n=o.response)===null||n===void 0?void 0:n.data))}return[2]}))}))};e.prototype.handleCancel=function(){var e;(e=this.exit)===null||e===void 0?void 0:e.emit()};e.prototype.handleSubmit=function(){var e=this;updateTemplate(this.endpoint,this.templateId,{name:this.name,visibility:this.visibility,sender:this.sender,initial_reminder:this.sendReminders?this.initialReminder*MS_PER_DAY:null,followup_reminders:this.sendReminders?this.followupReminders*MS_PER_DAY:null}).then((function(t){var n,o;console.log("[SETTINGS] Template Updated",t);e.dirty=false;e.name=t.name;e.visibility=t.visibility;e.sender=t.sender;e.sendReminders=t.initial_reminder!==null;e.initialReminder=t.initial_reminder?Math.floor(t.initial_reminder/MS_PER_DAY):null;e.followupReminders=t.followup_reminders?Math.floor(t.followup_reminders/MS_PER_DAY):null;(n=e.templateUpdated)===null||n===void 0?void 0:n.emit({endpoint:e.endpoint,template:t,event:"update"});(o=e.next)===null||o===void 0?void 0:o.emit()})).catch((function(t){var n,o,i,r,s;console.log("[SETTINGS] Error updating template",t);(n=e.sdkError)===null||n===void 0?void 0:n.emit(new SDKError(t.message,(o=t.response)===null||o===void 0?void 0:o.status,(i=t.response)===null||i===void 0?void 0:i.data));VerdocsToast(((s=(r=t.response)===null||r===void 0?void 0:r.data)===null||s===void 0?void 0:s.error)||"Error updating template, please try again later.")}))};e.prototype.render=function(){var e=this;if(!this.endpoint.session){return h(Host,null,h("verdocs-component-error",{message:"You must be authenticated to use this module."}))}if(this.loading||!this.template){return h(Host,{class:"loading"},h("verdocs-loader",null))}return h(Host,null,h("form",{onSubmit:function(e){return e.preventDefault()},onClick:function(e){return e.stopPropagation()},autocomplete:"off"},h("h5",null,"Settings"),h("div",{class:"row"},h("verdocs-text-input",{id:"verdocs-field-name",label:"Template Name",value:this.name,autocomplete:"off",placeholder:"Template Name...",onInput:function(t){e.name=t.target.value;e.dirty=true}})),h("div",{class:"row"},h("verdocs-select-input",{label:"Visibility",value:this.visibility,onInput:function(t){e.visibility=t.target.value;e.dirty=true},options:[{value:"private",label:"Private"},{value:"shared",label:"Shared"},{value:"public",label:"Public"}]})),h("div",{class:"row"},h("verdocs-select-input",{label:"Owner for envelopes created from this template",value:this.sender,onInput:function(t){e.sender=t.target.value;e.dirty=true},options:[{value:"envelope_creator",label:"Envelope Creator"},{value:"template_owner",label:"Template Owner"}]})),h("div",{class:"row"},h("label",null,"Send Reminders"),h("verdocs-switch",{checked:this.sendReminders,onCheckedChange:function(t){return e.sendReminders=t.detail}})),this.sendReminders&&h("div",{class:"row"},h("verdocs-text-input",{id:"verdocs-field-name",label:"First Reminder (days)",value:String(this.initialReminder||0),autocomplete:"off",placeholder:"Delay in days...",onInput:function(t){e.initialReminder=+t.target.value;e.dirty=true}})),this.sendReminders&&h("div",{class:"row"},h("verdocs-text-input",{id:"verdocs-field-name",label:"Follow-up Reminders (days)",value:String(this.followupReminders||0),autocomplete:"off",placeholder:"Delay in days...",onInput:function(t){e.followupReminders=+t.target.value;e.dirty=true}})),h("div",{class:"buttons"},h("verdocs-button",{variant:"outline",label:"Cancel",size:"small",onClick:function(){return e.handleCancel()}}),h("verdocs-button",{label:"Save",size:"small",onClick:function(){return e.handleSubmit()},disabled:!this.dirty}))))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();VerdocsTemplateSettings.style=verdocsTemplateSettingsCss;export{VerdocsPreview as verdocs_preview,VerdocsSend as verdocs_send,VerdocsTemplateAttachments as verdocs_template_attachments,VerdocsTemplateBuildTabs as verdocs_template_build_tabs,VerdocsTemplateFields as verdocs_template_fields,VerdocsTemplateRoles as verdocs_template_roles,VerdocsTemplateSettings as verdocs_template_settings};
8
8
  //# sourceMappingURL=verdocs-preview_7.entry.js.map