@verdocs/web-sdk 5.0.2 → 5.0.4

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 (325) hide show
  1. package/dist/cjs/{Datastore-b1742da2.js → Datastore-5b860927.js} +2 -2
  2. package/dist/cjs/index-ccac8641.js +4 -4
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{utils-ba1e95e0.js → utils-30de2530.js} +2 -4
  5. package/dist/cjs/verdocs-build.cjs.entry.js +1 -1
  6. package/dist/cjs/verdocs-button_2.cjs.entry.js +2 -2
  7. package/dist/cjs/verdocs-checkbox_6.cjs.entry.js +8 -8
  8. package/dist/cjs/verdocs-contact-picker_2.cjs.entry.js +2 -2
  9. package/dist/cjs/verdocs-dialog.cjs.entry.js +1 -1
  10. package/dist/cjs/verdocs-envelope-document-page.cjs.entry.js +2 -2
  11. package/dist/cjs/verdocs-envelope-recipient-link_2.cjs.entry.js +3 -3
  12. package/dist/cjs/verdocs-envelope-recipient-summary.cjs.entry.js +1 -1
  13. package/dist/cjs/verdocs-envelope-sidebar.cjs.entry.js +1 -1
  14. package/dist/cjs/verdocs-envelopes-list.cjs.entry.js +7 -7
  15. package/dist/cjs/verdocs-field-attachment_13.cjs.entry.js +4 -4
  16. package/dist/cjs/verdocs-field-payment.cjs.entry.js +1 -1
  17. package/dist/cjs/verdocs-file-chooser_2.cjs.entry.js +1 -1
  18. package/dist/cjs/verdocs-kba-dialog_2.cjs.entry.js +2 -2
  19. package/dist/cjs/verdocs-menu-panel_2.cjs.entry.js +241 -0
  20. package/dist/cjs/verdocs-ok-dialog.cjs.entry.js +1 -1
  21. package/dist/cjs/verdocs-organization-card_2.cjs.entry.js +2 -2
  22. package/dist/cjs/verdocs-pagination_2.cjs.entry.js +2 -2
  23. package/dist/cjs/verdocs-preview_6.cjs.entry.js +2865 -158
  24. package/dist/cjs/verdocs-quick-functions.cjs.entry.js +1 -1
  25. package/dist/cjs/verdocs-radio-button.cjs.entry.js +1 -1
  26. package/dist/cjs/verdocs-search-tabs.cjs.entry.js +1 -1
  27. package/dist/cjs/verdocs-sign.cjs.entry.js +1 -1
  28. package/dist/cjs/verdocs-spinner.cjs.entry.js +1 -1
  29. package/dist/cjs/verdocs-status-indicator.cjs.entry.js +2 -2
  30. package/dist/cjs/verdocs-template-card.cjs.entry.js +1 -1
  31. package/dist/cjs/verdocs-template-document-page_2.cjs.entry.js +3 -3
  32. package/dist/cjs/verdocs-template-star.cjs.entry.js +1 -1
  33. package/dist/cjs/verdocs-template-tags.cjs.entry.js +1 -1
  34. package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
  35. package/dist/collection/collection-manifest.json +1 -0
  36. package/dist/collection/components/controls/verdocs-help-icon/verdocs-help-icon.css +1 -1
  37. package/dist/collection/components/controls/verdocs-help-icon/verdocs-help-icon.js +1 -1
  38. package/dist/collection/components/controls/verdocs-menu-panel/verdocs-menu-panel.css +42 -0
  39. package/dist/collection/components/controls/verdocs-menu-panel/verdocs-menu-panel.js +159 -0
  40. package/dist/collection/components/controls/verdocs-organization-card/verdocs-organization-card.js +1 -1
  41. package/dist/collection/components/controls/verdocs-pagination/verdocs-pagination.js +1 -1
  42. package/dist/collection/components/controls/verdocs-portal/verdocs-portal.js +1 -1
  43. package/dist/collection/components/controls/verdocs-progress-bar/verdocs-progress-bar.js +1 -1
  44. package/dist/collection/components/controls/verdocs-radio-button/verdocs-radio-button.js +1 -1
  45. package/dist/collection/components/controls/verdocs-select-input/verdocs-select-input.css +2 -2
  46. package/dist/collection/components/controls/verdocs-select-input/verdocs-select-input.js +1 -1
  47. package/dist/collection/components/controls/verdocs-spinner/verdocs-spinner.js +1 -1
  48. package/dist/collection/components/controls/verdocs-switch/verdocs-switch.js +2 -2
  49. package/dist/collection/components/controls/verdocs-text-input/verdocs-text-input.css +2 -2
  50. package/dist/collection/components/controls/verdocs-text-input/verdocs-text-input.js +4 -4
  51. package/dist/collection/components/controls/verdocs-toggle-button/verdocs-toggle-button.js +1 -1
  52. package/dist/collection/components/controls/verdocs-toolbar-icon/verdocs-toolbar-icon.js +1 -1
  53. package/dist/collection/components/dialogs/verdocs-dialog/verdocs-dialog.js +1 -1
  54. package/dist/collection/components/dialogs/verdocs-initial-dialog/verdocs-initial-dialog.js +1 -1
  55. package/dist/collection/components/dialogs/verdocs-ok-dialog/verdocs-ok-dialog.js +1 -1
  56. package/dist/collection/components/dialogs/verdocs-signature-dialog/verdocs-signature-dialog.js +1 -1
  57. package/dist/collection/components/dialogs/verdocs-upload-dialog/verdocs-upload-dialog.js +1 -1
  58. package/dist/collection/components/elements/verdocs-quick-functions/verdocs-quick-functions.js +1 -1
  59. package/dist/collection/components/elements/verdocs-search-tabs/verdocs-search-tabs.js +1 -1
  60. package/dist/collection/components/envelopes/verdocs-envelope-document-page/verdocs-envelope-document-page.js +1 -1
  61. package/dist/collection/components/envelopes/verdocs-envelopes-list/verdocs-envelopes-list.js +6 -6
  62. package/dist/collection/components/envelopes/verdocs-status-indicator/verdocs-status-indicator.js +2 -2
  63. package/dist/collection/components/templates/verdocs-template-card/verdocs-template-card.js +1 -1
  64. package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.css +1 -0
  65. package/dist/collection/components/templates/verdocs-template-role-properties/verdocs-template-role-properties.css +27 -42
  66. package/dist/collection/components/templates/verdocs-template-role-properties/verdocs-template-role-properties.js +12 -14
  67. package/dist/collection/components/templates/verdocs-template-roles/verdocs-template-roles.css +74 -120
  68. package/dist/collection/components/templates/verdocs-template-roles/verdocs-template-roles.js +145 -101
  69. package/dist/collection/components/templates/verdocs-template-star/verdocs-template-star.js +1 -1
  70. package/dist/collection/components/templates/verdocs-template-tags/verdocs-template-tags.js +1 -1
  71. package/dist/collection/utils/Datastore.js +2 -2
  72. package/dist/collection/utils/utils.js +2 -4
  73. package/dist/components/index.js +2 -0
  74. package/dist/components/{p-ed88b8d2.js → p-005c3387.js} +3 -3
  75. package/dist/components/{p-0d063bf9.js → p-052fcdac.js} +4 -4
  76. package/dist/components/{p-0a69031f.js → p-053a0408.js} +6 -6
  77. package/dist/components/{p-4bc5ac82.js → p-093d51c8.js} +2 -4
  78. package/dist/components/{p-5d82a9f3.js → p-15b1e7a0.js} +10 -8
  79. package/dist/components/{p-6400f542.js → p-1a77c51b.js} +6 -6
  80. package/dist/components/{p-f990140a.js → p-2ef2d490.js} +2 -2
  81. package/dist/components/{p-c8fedb4e.js → p-325b3828.js} +6 -6
  82. package/dist/components/{p-8d3c0b4c.js → p-332a97b3.js} +2 -2
  83. package/dist/components/{p-b0c02eb8.js → p-3a621e5d.js} +7 -7
  84. package/dist/components/{p-18999830.js → p-41a75ad6.js} +1 -1
  85. package/dist/components/{p-5eb45a4f.js → p-44ae3c75.js} +1 -1
  86. package/dist/components/{p-1e2e8b1c.js → p-4d3b9ee9.js} +1 -1
  87. package/dist/components/{p-1e67ebdf.js → p-53585e13.js} +18 -26
  88. package/dist/components/{p-c7b00ce6.js → p-5654568d.js} +1 -1
  89. package/dist/components/{p-ecc818bb.js → p-5df09a0d.js} +6 -6
  90. package/dist/components/{p-315d6592.js → p-62743fd3.js} +2 -2
  91. package/dist/components/{p-dd701894.js → p-6506ddb4.js} +6 -6
  92. package/dist/components/{p-5d4bbcd0.js → p-6719b0d7.js} +1 -1
  93. package/dist/components/{p-d9704a51.js → p-6c18617e.js} +6 -6
  94. package/dist/components/{p-fd96322b.js → p-7246d2ee.js} +6 -6
  95. package/dist/components/{p-0ca7012b.js → p-7f32e087.js} +2 -2
  96. package/dist/components/{p-22e52874.js → p-987a8392.js} +24 -24
  97. package/dist/components/{p-b9034018.js → p-9c0b30f8.js} +3 -3
  98. package/dist/components/{p-b16c202a.js → p-9cfd8022.js} +1 -1
  99. package/dist/components/{p-a3e12c74.js → p-9fb98ea2.js} +1 -1
  100. package/dist/components/p-a06a0184.js +3055 -0
  101. package/dist/components/{p-f72b9c45.js → p-a2f6d2c6.js} +1 -1
  102. package/dist/components/{p-1ca705bc.js → p-b36c979b.js} +6 -6
  103. package/dist/components/{p-da4d4eed.js → p-b712e729.js} +2 -2
  104. package/dist/components/{p-cf6ea837.js → p-b7d080eb.js} +1 -1
  105. package/dist/components/p-be261487.js +79 -0
  106. package/dist/components/{p-9bb47a5a.js → p-c00770e6.js} +1 -1
  107. package/dist/components/{p-4afcdc84.js → p-c9a4ef35.js} +6 -6
  108. package/dist/components/{p-9c3fd545.js → p-ca8e3721.js} +8 -8
  109. package/dist/components/{p-5a9cea40.js → p-cce871bf.js} +3 -3
  110. package/dist/components/{p-a22a3b1b.js → p-cef9df4b.js} +21 -21
  111. package/dist/components/{p-15d530b8.js → p-d9074622.js} +4 -4
  112. package/dist/components/{p-ec894daf.js → p-ed4f91be.js} +1 -1
  113. package/dist/components/{p-c25e82b9.js → p-f0f1ed82.js} +21 -21
  114. package/dist/components/{p-58c2bd5d.js → p-f0f6e862.js} +2 -2
  115. package/dist/components/{p-49153610.js → p-f21ef4fb.js} +7 -7
  116. package/dist/components/{p-fcad60f5.js → p-f4e068a9.js} +2 -2
  117. package/dist/components/{p-2548f3f0.js → p-f7462b26.js} +1 -1
  118. package/dist/components/verdocs-auth.js +2 -2
  119. package/dist/components/verdocs-build.js +64 -58
  120. package/dist/components/verdocs-contact-picker.js +1 -1
  121. package/dist/components/verdocs-dialog.js +1 -1
  122. package/dist/components/verdocs-dropdown.js +1 -1
  123. package/dist/components/verdocs-envelope-document-page.js +1 -1
  124. package/dist/components/verdocs-envelope-recipient-link.js +1 -1
  125. package/dist/components/verdocs-envelope-recipient-summary.js +1 -1
  126. package/dist/components/verdocs-envelope-sidebar.js +8 -8
  127. package/dist/components/verdocs-envelopes-list.js +15 -15
  128. package/dist/components/verdocs-field-attachment.js +1 -1
  129. package/dist/components/verdocs-field-checkbox.js +1 -1
  130. package/dist/components/verdocs-field-date.js +1 -1
  131. package/dist/components/verdocs-field-dropdown.js +1 -1
  132. package/dist/components/verdocs-field-initial.js +1 -1
  133. package/dist/components/verdocs-field-payment.js +6 -6
  134. package/dist/components/verdocs-field-radio.js +1 -1
  135. package/dist/components/verdocs-field-signature.js +1 -1
  136. package/dist/components/verdocs-field-textarea.js +1 -1
  137. package/dist/components/verdocs-field-textbox.js +1 -1
  138. package/dist/components/verdocs-field-timestamp.js +1 -1
  139. package/dist/components/verdocs-help-icon.js +1 -1
  140. package/dist/components/verdocs-initial-dialog.js +1 -1
  141. package/dist/components/verdocs-menu-panel.d.ts +11 -0
  142. package/dist/components/verdocs-menu-panel.js +6 -0
  143. package/dist/components/verdocs-ok-dialog.js +1 -1
  144. package/dist/components/verdocs-organization-card.js +2 -2
  145. package/dist/components/verdocs-pagination.js +1 -1
  146. package/dist/components/verdocs-portal.js +1 -1
  147. package/dist/components/verdocs-preview.js +1 -1
  148. package/dist/components/verdocs-progress-bar.js +1 -1
  149. package/dist/components/verdocs-quick-filter.js +1 -1
  150. package/dist/components/verdocs-quick-functions.js +1 -1
  151. package/dist/components/verdocs-radio-button.js +1 -1
  152. package/dist/components/verdocs-search-tabs.js +1 -1
  153. package/dist/components/verdocs-select-input.js +1 -1
  154. package/dist/components/verdocs-send.js +1 -1
  155. package/dist/components/verdocs-sign.js +7 -7
  156. package/dist/components/verdocs-signature-dialog.js +1 -1
  157. package/dist/components/verdocs-spinner.js +1 -1
  158. package/dist/components/verdocs-status-indicator.js +1 -1
  159. package/dist/components/verdocs-switch.js +1 -1
  160. package/dist/components/verdocs-template-attachments.js +1 -1
  161. package/dist/components/verdocs-template-build-tabs.js +1 -1
  162. package/dist/components/verdocs-template-card.js +1 -1
  163. package/dist/components/verdocs-template-create.js +1 -1
  164. package/dist/components/verdocs-template-document-page.js +1 -1
  165. package/dist/components/verdocs-template-field-properties.js +1 -1
  166. package/dist/components/verdocs-template-fields.js +1 -1
  167. package/dist/components/verdocs-template-role-properties.js +1 -1
  168. package/dist/components/verdocs-template-roles.js +1 -1
  169. package/dist/components/verdocs-template-star.js +1 -1
  170. package/dist/components/verdocs-template-tags.js +1 -1
  171. package/dist/components/verdocs-templates-list.js +9 -9
  172. package/dist/components/verdocs-text-input.js +1 -1
  173. package/dist/components/verdocs-toggle-button.js +1 -1
  174. package/dist/components/verdocs-toolbar-icon.js +1 -1
  175. package/dist/components/verdocs-upload-dialog.js +1 -1
  176. package/dist/components/verdocs-view.js +1 -1
  177. package/dist/custom-elements.json +31 -2
  178. package/dist/esm/{Datastore-52fcbac6.js → Datastore-d29d4aeb.js} +2 -2
  179. package/dist/esm/index-272d51a4.js +4 -4
  180. package/dist/esm/loader.js +1 -1
  181. package/dist/esm/{utils-47de6f79.js → utils-a5f5c427.js} +2 -4
  182. package/dist/esm/verdocs-build.entry.js +1 -1
  183. package/dist/esm/verdocs-button_2.entry.js +2 -2
  184. package/dist/esm/verdocs-checkbox_6.entry.js +8 -8
  185. package/dist/esm/verdocs-contact-picker_2.entry.js +2 -2
  186. package/dist/esm/verdocs-dialog.entry.js +1 -1
  187. package/dist/esm/verdocs-envelope-document-page.entry.js +2 -2
  188. package/dist/esm/verdocs-envelope-recipient-link_2.entry.js +3 -3
  189. package/dist/esm/verdocs-envelope-recipient-summary.entry.js +1 -1
  190. package/dist/esm/verdocs-envelope-sidebar.entry.js +1 -1
  191. package/dist/esm/verdocs-envelopes-list.entry.js +7 -7
  192. package/dist/esm/verdocs-field-attachment_13.entry.js +4 -4
  193. package/dist/esm/verdocs-field-payment.entry.js +1 -1
  194. package/dist/esm/verdocs-file-chooser_2.entry.js +1 -1
  195. package/dist/esm/verdocs-kba-dialog_2.entry.js +2 -2
  196. package/dist/esm/verdocs-menu-panel_2.entry.js +236 -0
  197. package/dist/esm/verdocs-ok-dialog.entry.js +1 -1
  198. package/dist/esm/verdocs-organization-card_2.entry.js +2 -2
  199. package/dist/esm/verdocs-pagination_2.entry.js +2 -2
  200. package/dist/esm/verdocs-preview_6.entry.js +2813 -106
  201. package/dist/esm/verdocs-quick-functions.entry.js +1 -1
  202. package/dist/esm/verdocs-radio-button.entry.js +1 -1
  203. package/dist/esm/verdocs-search-tabs.entry.js +1 -1
  204. package/dist/esm/verdocs-sign.entry.js +1 -1
  205. package/dist/esm/verdocs-spinner.entry.js +1 -1
  206. package/dist/esm/verdocs-status-indicator.entry.js +2 -2
  207. package/dist/esm/verdocs-template-card.entry.js +1 -1
  208. package/dist/esm/verdocs-template-document-page_2.entry.js +3 -3
  209. package/dist/esm/verdocs-template-star.entry.js +1 -1
  210. package/dist/esm/verdocs-template-tags.entry.js +1 -1
  211. package/dist/esm/verdocs-web-sdk.js +1 -1
  212. package/dist/esm-es5/{Datastore-52fcbac6.js → Datastore-d29d4aeb.js} +1 -1
  213. package/dist/esm-es5/index-272d51a4.js +1 -1
  214. package/dist/esm-es5/loader.js +1 -1
  215. package/dist/esm-es5/{utils-47de6f79.js → utils-a5f5c427.js} +1 -1
  216. package/dist/esm-es5/verdocs-build.entry.js +1 -1
  217. package/dist/esm-es5/verdocs-button_2.entry.js +1 -1
  218. package/dist/esm-es5/verdocs-checkbox_6.entry.js +1 -1
  219. package/dist/esm-es5/verdocs-contact-picker_2.entry.js +1 -1
  220. package/dist/esm-es5/verdocs-dialog.entry.js +1 -1
  221. package/dist/esm-es5/verdocs-envelope-document-page.entry.js +1 -1
  222. package/dist/esm-es5/verdocs-envelope-recipient-link_2.entry.js +1 -1
  223. package/dist/esm-es5/verdocs-envelope-recipient-summary.entry.js +1 -1
  224. package/dist/esm-es5/verdocs-envelope-sidebar.entry.js +1 -1
  225. package/dist/esm-es5/verdocs-envelopes-list.entry.js +1 -1
  226. package/dist/esm-es5/verdocs-field-attachment_13.entry.js +1 -1
  227. package/dist/esm-es5/verdocs-field-payment.entry.js +1 -1
  228. package/dist/esm-es5/verdocs-file-chooser_2.entry.js +1 -1
  229. package/dist/esm-es5/verdocs-kba-dialog_2.entry.js +1 -1
  230. package/dist/esm-es5/verdocs-menu-panel_2.entry.js +1 -0
  231. package/dist/esm-es5/verdocs-ok-dialog.entry.js +1 -1
  232. package/dist/esm-es5/verdocs-organization-card_2.entry.js +1 -1
  233. package/dist/esm-es5/verdocs-pagination_2.entry.js +1 -1
  234. package/dist/esm-es5/verdocs-preview_6.entry.js +7 -1
  235. package/dist/esm-es5/verdocs-quick-functions.entry.js +1 -1
  236. package/dist/esm-es5/verdocs-radio-button.entry.js +1 -1
  237. package/dist/esm-es5/verdocs-search-tabs.entry.js +1 -1
  238. package/dist/esm-es5/verdocs-sign.entry.js +1 -1
  239. package/dist/esm-es5/verdocs-spinner.entry.js +1 -1
  240. package/dist/esm-es5/verdocs-status-indicator.entry.js +1 -1
  241. package/dist/esm-es5/verdocs-template-card.entry.js +1 -1
  242. package/dist/esm-es5/verdocs-template-document-page_2.entry.js +1 -1
  243. package/dist/esm-es5/verdocs-template-star.entry.js +1 -1
  244. package/dist/esm-es5/verdocs-template-tags.entry.js +1 -1
  245. package/dist/esm-es5/verdocs-web-sdk.js +1 -1
  246. package/dist/types/components/controls/verdocs-menu-panel/verdocs-menu-panel.d.ts +38 -0
  247. package/dist/types/components/templates/verdocs-template-role-properties/verdocs-template-role-properties.d.ts +1 -1
  248. package/dist/types/components/templates/verdocs-template-roles/verdocs-template-roles.d.ts +5 -3
  249. package/dist/types/components.d.ts +101 -8
  250. package/dist/verdocs-web-sdk/{p-65c5398e.entry.js → p-152b9acd.entry.js} +1 -1
  251. package/dist/verdocs-web-sdk/{p-c9f40726.system.entry.js → p-1d5b9103.system.entry.js} +1 -1
  252. package/dist/verdocs-web-sdk/{p-3364cc13.system.entry.js → p-1e191c20.system.entry.js} +1 -1
  253. package/dist/verdocs-web-sdk/{p-7464b84f.entry.js → p-1e495c60.entry.js} +1 -1
  254. package/dist/verdocs-web-sdk/{p-167e3d7e.entry.js → p-2224ca6d.entry.js} +1 -1
  255. package/dist/verdocs-web-sdk/{p-bd7406ae.entry.js → p-27da4a2b.entry.js} +1 -1
  256. package/dist/verdocs-web-sdk/{p-914e131c.system.entry.js → p-2eae32d9.system.entry.js} +1 -1
  257. package/dist/verdocs-web-sdk/p-306bde40.system.entry.js +1 -0
  258. package/dist/verdocs-web-sdk/{p-0e9de098.entry.js → p-30c3f624.entry.js} +1 -1
  259. package/dist/verdocs-web-sdk/{p-8d401072.system.entry.js → p-3268dad0.system.entry.js} +1 -1
  260. package/dist/verdocs-web-sdk/p-365ed258.entry.js +1 -0
  261. package/dist/verdocs-web-sdk/{p-ddb17b3e.entry.js → p-39b72c10.entry.js} +1 -1
  262. package/dist/verdocs-web-sdk/{p-f5d01982.system.entry.js → p-417f71da.system.entry.js} +1 -1
  263. package/dist/verdocs-web-sdk/{p-b8737f7b.entry.js → p-42b157d2.entry.js} +1 -1
  264. package/dist/verdocs-web-sdk/{p-771c2f92.entry.js → p-47f32221.entry.js} +1 -1
  265. package/dist/verdocs-web-sdk/p-48ff3cce.system.entry.js +1 -0
  266. package/dist/verdocs-web-sdk/{p-3a1fa556.system.entry.js → p-4c807fe2.system.entry.js} +1 -1
  267. package/dist/verdocs-web-sdk/{p-b0b958a0.entry.js → p-51c97029.entry.js} +1 -1
  268. package/dist/verdocs-web-sdk/{p-c18c718f.system.js → p-55de8cd1.system.js} +1 -1
  269. package/dist/verdocs-web-sdk/{p-7c8938e7.system.entry.js → p-5824962b.system.entry.js} +1 -1
  270. package/dist/verdocs-web-sdk/{p-aebb0cd9.system.entry.js → p-5aa76635.system.entry.js} +1 -1
  271. package/dist/verdocs-web-sdk/{p-89cdecac.system.entry.js → p-5b0cd815.system.entry.js} +1 -1
  272. package/dist/verdocs-web-sdk/{p-a08886c1.system.entry.js → p-5ce491ac.system.entry.js} +1 -1
  273. package/dist/verdocs-web-sdk/{p-c6fd3e53.system.entry.js → p-6237ce51.system.entry.js} +1 -1
  274. package/dist/verdocs-web-sdk/{p-c7cd6843.entry.js → p-660bda06.entry.js} +1 -1
  275. package/dist/verdocs-web-sdk/{p-2be751c4.system.js → p-736a2c41.system.js} +1 -1
  276. package/dist/verdocs-web-sdk/{p-97b00cae.system.entry.js → p-7e73805f.system.entry.js} +1 -1
  277. package/dist/verdocs-web-sdk/{p-8c03fc69.entry.js → p-8025cac7.entry.js} +1 -1
  278. package/dist/verdocs-web-sdk/{p-584113d1.entry.js → p-87ac8456.entry.js} +1 -1
  279. package/dist/verdocs-web-sdk/{p-9d0b0e36.system.entry.js → p-899617aa.system.entry.js} +1 -1
  280. package/dist/verdocs-web-sdk/{p-2a1287ec.entry.js → p-899fa588.entry.js} +1 -1
  281. package/dist/verdocs-web-sdk/{p-511a4ecc.system.entry.js → p-90bc3ad0.system.entry.js} +1 -1
  282. package/dist/verdocs-web-sdk/{p-a242aa80.system.entry.js → p-917aab58.system.entry.js} +1 -1
  283. package/dist/verdocs-web-sdk/{p-524f37a0.entry.js → p-92364765.entry.js} +1 -1
  284. package/dist/verdocs-web-sdk/{p-f9b37af2.system.entry.js → p-94fe5817.system.entry.js} +1 -1
  285. package/dist/verdocs-web-sdk/{p-41cbf650.entry.js → p-99b819ad.entry.js} +1 -1
  286. package/dist/verdocs-web-sdk/{p-df04f0ca.entry.js → p-a8809e33.entry.js} +1 -1
  287. package/dist/verdocs-web-sdk/{p-a9635106.system.entry.js → p-ac6ecfad.system.entry.js} +1 -1
  288. package/dist/verdocs-web-sdk/{p-62f15675.system.entry.js → p-ad3d07a6.system.entry.js} +1 -1
  289. package/dist/verdocs-web-sdk/{p-df392ef9.entry.js → p-af1802b6.entry.js} +1 -1
  290. package/dist/verdocs-web-sdk/p-b712e729.js +1 -0
  291. package/dist/verdocs-web-sdk/{p-a165607e.entry.js → p-be4ec401.entry.js} +1 -1
  292. package/dist/verdocs-web-sdk/{p-bcc23811.entry.js → p-bea73364.entry.js} +1 -1
  293. package/dist/verdocs-web-sdk/{p-e5d291f3.system.entry.js → p-c253ae24.system.entry.js} +1 -1
  294. package/dist/verdocs-web-sdk/{p-0ca1e87c.entry.js → p-c2766b5a.entry.js} +1 -1
  295. package/dist/verdocs-web-sdk/{p-6ced37ed.entry.js → p-c3593d47.entry.js} +1 -1
  296. package/dist/verdocs-web-sdk/{p-ca712f40.system.entry.js → p-c60743ac.system.entry.js} +1 -1
  297. package/dist/verdocs-web-sdk/{p-37d747fb.system.entry.js → p-c94b0dc5.system.entry.js} +1 -1
  298. package/dist/verdocs-web-sdk/{p-78191329.system.entry.js → p-cb7aa6b8.system.entry.js} +1 -1
  299. package/dist/verdocs-web-sdk/{p-650697bd.js → p-cfed8cc1.js} +1 -1
  300. package/dist/verdocs-web-sdk/p-d6104d4b.system.entry.js +7 -0
  301. package/dist/verdocs-web-sdk/{p-54f085d1.entry.js → p-db4c36aa.entry.js} +1 -1
  302. package/dist/verdocs-web-sdk/{p-d475fff3.entry.js → p-dc558be5.entry.js} +1 -1
  303. package/dist/verdocs-web-sdk/p-e2b70dfb.system.js +1 -1
  304. package/dist/verdocs-web-sdk/{p-8221a48f.entry.js → p-e2de6329.entry.js} +1 -1
  305. package/dist/verdocs-web-sdk/{p-80ce3711.system.entry.js → p-e6d711e0.system.entry.js} +1 -1
  306. package/dist/verdocs-web-sdk/p-f1e2ec72.entry.js +8 -0
  307. package/dist/verdocs-web-sdk/{p-860b9f94.system.entry.js → p-f3b5052f.system.entry.js} +1 -1
  308. package/dist/verdocs-web-sdk/{p-8a2ff048.entry.js → p-f40fe8d7.entry.js} +1 -1
  309. package/dist/verdocs-web-sdk/{p-e83cd333.entry.js → p-f6b77cd1.entry.js} +1 -1
  310. package/dist/verdocs-web-sdk/{p-d98cbd0f.system.entry.js → p-f84932fd.system.entry.js} +1 -1
  311. package/dist/verdocs-web-sdk/{p-f4fcf7a5.entry.js → p-fc90cc87.entry.js} +1 -1
  312. package/dist/verdocs-web-sdk/{p-386d789c.system.entry.js → p-ff8143df.system.entry.js} +1 -1
  313. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  314. package/package.json +5 -4
  315. package/dist/cjs/verdocs-template-role-properties.cjs.entry.js +0 -184
  316. package/dist/components/p-8fbc64e9.js +0 -349
  317. package/dist/components/p-ea5954bd.js +0 -4
  318. package/dist/esm/verdocs-template-role-properties.entry.js +0 -180
  319. package/dist/esm-es5/verdocs-template-role-properties.entry.js +0 -1
  320. package/dist/verdocs-web-sdk/p-81c8663f.entry.js +0 -1
  321. package/dist/verdocs-web-sdk/p-9567cb7d.system.entry.js +0 -1
  322. package/dist/verdocs-web-sdk/p-982f1b36.system.entry.js +0 -1
  323. package/dist/verdocs-web-sdk/p-bb0effe1.entry.js +0 -1
  324. package/dist/verdocs-web-sdk/p-da4d4eed.js +0 -1
  325. package/dist/verdocs-web-sdk/p-edfb1951.system.entry.js +0 -1
@@ -0,0 +1,3055 @@
1
+ import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-324ed895.js';
2
+ import { VerdocsEndpoint, getTemplate, updateTemplateRole, createTemplateRole, formatFullName } from '@verdocs/js-sdk';
3
+ import { S as SDKError } from './p-fd97809c.js';
4
+ import { S as Store } from './p-b712e729.js';
5
+ import { d as defineCustomElement$8 } from './p-0e332769.js';
6
+ import { d as defineCustomElement$7 } from './p-84ae0283.js';
7
+ import { d as defineCustomElement$6 } from './p-7f32e087.js';
8
+ import { d as defineCustomElement$5 } from './p-1ae5d7e0.js';
9
+ import { d as defineCustomElement$4 } from './p-be261487.js';
10
+ import { d as defineCustomElement$3 } from './p-62743fd3.js';
11
+ import { d as defineCustomElement$2 } from './p-53585e13.js';
12
+ import { d as defineCustomElement$1 } from './p-325b3828.js';
13
+
14
+ /**!
15
+ * Sortable 1.15.6
16
+ * @author RubaXa <trash@rubaxa.org>
17
+ * @author owenm <owen23355@gmail.com>
18
+ * @license MIT
19
+ */
20
+ function ownKeys(object, enumerableOnly) {
21
+ var keys = Object.keys(object);
22
+ if (Object.getOwnPropertySymbols) {
23
+ var symbols = Object.getOwnPropertySymbols(object);
24
+ if (enumerableOnly) {
25
+ symbols = symbols.filter(function (sym) {
26
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
27
+ });
28
+ }
29
+ keys.push.apply(keys, symbols);
30
+ }
31
+ return keys;
32
+ }
33
+ function _objectSpread2(target) {
34
+ for (var i = 1; i < arguments.length; i++) {
35
+ var source = arguments[i] != null ? arguments[i] : {};
36
+ if (i % 2) {
37
+ ownKeys(Object(source), true).forEach(function (key) {
38
+ _defineProperty(target, key, source[key]);
39
+ });
40
+ } else if (Object.getOwnPropertyDescriptors) {
41
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
42
+ } else {
43
+ ownKeys(Object(source)).forEach(function (key) {
44
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
45
+ });
46
+ }
47
+ }
48
+ return target;
49
+ }
50
+ function _typeof(obj) {
51
+ "@babel/helpers - typeof";
52
+
53
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
54
+ _typeof = function (obj) {
55
+ return typeof obj;
56
+ };
57
+ } else {
58
+ _typeof = function (obj) {
59
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
60
+ };
61
+ }
62
+ return _typeof(obj);
63
+ }
64
+ function _defineProperty(obj, key, value) {
65
+ if (key in obj) {
66
+ Object.defineProperty(obj, key, {
67
+ value: value,
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true
71
+ });
72
+ } else {
73
+ obj[key] = value;
74
+ }
75
+ return obj;
76
+ }
77
+ function _extends() {
78
+ _extends = Object.assign || function (target) {
79
+ for (var i = 1; i < arguments.length; i++) {
80
+ var source = arguments[i];
81
+ for (var key in source) {
82
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
83
+ target[key] = source[key];
84
+ }
85
+ }
86
+ }
87
+ return target;
88
+ };
89
+ return _extends.apply(this, arguments);
90
+ }
91
+ function _objectWithoutPropertiesLoose(source, excluded) {
92
+ if (source == null) return {};
93
+ var target = {};
94
+ var sourceKeys = Object.keys(source);
95
+ var key, i;
96
+ for (i = 0; i < sourceKeys.length; i++) {
97
+ key = sourceKeys[i];
98
+ if (excluded.indexOf(key) >= 0) continue;
99
+ target[key] = source[key];
100
+ }
101
+ return target;
102
+ }
103
+ function _objectWithoutProperties(source, excluded) {
104
+ if (source == null) return {};
105
+ var target = _objectWithoutPropertiesLoose(source, excluded);
106
+ var key, i;
107
+ if (Object.getOwnPropertySymbols) {
108
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
109
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
110
+ key = sourceSymbolKeys[i];
111
+ if (excluded.indexOf(key) >= 0) continue;
112
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
113
+ target[key] = source[key];
114
+ }
115
+ }
116
+ return target;
117
+ }
118
+
119
+ var version = "1.15.6";
120
+
121
+ function userAgent(pattern) {
122
+ if (typeof window !== 'undefined' && window.navigator) {
123
+ return !! /*@__PURE__*/navigator.userAgent.match(pattern);
124
+ }
125
+ }
126
+ var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
127
+ var Edge = userAgent(/Edge/i);
128
+ var FireFox = userAgent(/firefox/i);
129
+ var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
130
+ var IOS = userAgent(/iP(ad|od|hone)/i);
131
+ var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
132
+
133
+ var captureMode = {
134
+ capture: false,
135
+ passive: false
136
+ };
137
+ function on(el, event, fn) {
138
+ el.addEventListener(event, fn, !IE11OrLess && captureMode);
139
+ }
140
+ function off(el, event, fn) {
141
+ el.removeEventListener(event, fn, !IE11OrLess && captureMode);
142
+ }
143
+ function matches( /**HTMLElement*/el, /**String*/selector) {
144
+ if (!selector) return;
145
+ selector[0] === '>' && (selector = selector.substring(1));
146
+ if (el) {
147
+ try {
148
+ if (el.matches) {
149
+ return el.matches(selector);
150
+ } else if (el.msMatchesSelector) {
151
+ return el.msMatchesSelector(selector);
152
+ } else if (el.webkitMatchesSelector) {
153
+ return el.webkitMatchesSelector(selector);
154
+ }
155
+ } catch (_) {
156
+ return false;
157
+ }
158
+ }
159
+ return false;
160
+ }
161
+ function getParentOrHost(el) {
162
+ return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
163
+ }
164
+ function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) {
165
+ if (el) {
166
+ ctx = ctx || document;
167
+ do {
168
+ if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
169
+ return el;
170
+ }
171
+ if (el === ctx) break;
172
+ /* jshint boss:true */
173
+ } while (el = getParentOrHost(el));
174
+ }
175
+ return null;
176
+ }
177
+ var R_SPACE = /\s+/g;
178
+ function toggleClass(el, name, state) {
179
+ if (el && name) {
180
+ if (el.classList) {
181
+ el.classList[state ? 'add' : 'remove'](name);
182
+ } else {
183
+ var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
184
+ el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
185
+ }
186
+ }
187
+ }
188
+ function css(el, prop, val) {
189
+ var style = el && el.style;
190
+ if (style) {
191
+ if (val === void 0) {
192
+ if (document.defaultView && document.defaultView.getComputedStyle) {
193
+ val = document.defaultView.getComputedStyle(el, '');
194
+ } else if (el.currentStyle) {
195
+ val = el.currentStyle;
196
+ }
197
+ return prop === void 0 ? val : val[prop];
198
+ } else {
199
+ if (!(prop in style) && prop.indexOf('webkit') === -1) {
200
+ prop = '-webkit-' + prop;
201
+ }
202
+ style[prop] = val + (typeof val === 'string' ? '' : 'px');
203
+ }
204
+ }
205
+ }
206
+ function matrix(el, selfOnly) {
207
+ var appliedTransforms = '';
208
+ if (typeof el === 'string') {
209
+ appliedTransforms = el;
210
+ } else {
211
+ do {
212
+ var transform = css(el, 'transform');
213
+ if (transform && transform !== 'none') {
214
+ appliedTransforms = transform + ' ' + appliedTransforms;
215
+ }
216
+ /* jshint boss:true */
217
+ } while (!selfOnly && (el = el.parentNode));
218
+ }
219
+ var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
220
+ /*jshint -W056 */
221
+ return matrixFn && new matrixFn(appliedTransforms);
222
+ }
223
+ function find(ctx, tagName, iterator) {
224
+ if (ctx) {
225
+ var list = ctx.getElementsByTagName(tagName),
226
+ i = 0,
227
+ n = list.length;
228
+ if (iterator) {
229
+ for (; i < n; i++) {
230
+ iterator(list[i], i);
231
+ }
232
+ }
233
+ return list;
234
+ }
235
+ return [];
236
+ }
237
+ function getWindowScrollingElement() {
238
+ var scrollingElement = document.scrollingElement;
239
+ if (scrollingElement) {
240
+ return scrollingElement;
241
+ } else {
242
+ return document.documentElement;
243
+ }
244
+ }
245
+
246
+ /**
247
+ * Returns the "bounding client rect" of given element
248
+ * @param {HTMLElement} el The element whose boundingClientRect is wanted
249
+ * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
250
+ * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
251
+ * @param {[Boolean]} undoScale Whether the container's scale() should be undone
252
+ * @param {[HTMLElement]} container The parent the element will be placed in
253
+ * @return {Object} The boundingClientRect of el, with specified adjustments
254
+ */
255
+ function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
256
+ if (!el.getBoundingClientRect && el !== window) return;
257
+ var elRect, top, left, bottom, right, height, width;
258
+ if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
259
+ elRect = el.getBoundingClientRect();
260
+ top = elRect.top;
261
+ left = elRect.left;
262
+ bottom = elRect.bottom;
263
+ right = elRect.right;
264
+ height = elRect.height;
265
+ width = elRect.width;
266
+ } else {
267
+ top = 0;
268
+ left = 0;
269
+ bottom = window.innerHeight;
270
+ right = window.innerWidth;
271
+ height = window.innerHeight;
272
+ width = window.innerWidth;
273
+ }
274
+ if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
275
+ // Adjust for translate()
276
+ container = container || el.parentNode;
277
+
278
+ // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
279
+ // Not needed on <= IE11
280
+ if (!IE11OrLess) {
281
+ do {
282
+ if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
283
+ var containerRect = container.getBoundingClientRect();
284
+
285
+ // Set relative to edges of padding box of container
286
+ top -= containerRect.top + parseInt(css(container, 'border-top-width'));
287
+ left -= containerRect.left + parseInt(css(container, 'border-left-width'));
288
+ bottom = top + elRect.height;
289
+ right = left + elRect.width;
290
+ break;
291
+ }
292
+ /* jshint boss:true */
293
+ } while (container = container.parentNode);
294
+ }
295
+ }
296
+ if (undoScale && el !== window) {
297
+ // Adjust for scale()
298
+ var elMatrix = matrix(container || el),
299
+ scaleX = elMatrix && elMatrix.a,
300
+ scaleY = elMatrix && elMatrix.d;
301
+ if (elMatrix) {
302
+ top /= scaleY;
303
+ left /= scaleX;
304
+ width /= scaleX;
305
+ height /= scaleY;
306
+ bottom = top + height;
307
+ right = left + width;
308
+ }
309
+ }
310
+ return {
311
+ top: top,
312
+ left: left,
313
+ bottom: bottom,
314
+ right: right,
315
+ width: width,
316
+ height: height
317
+ };
318
+ }
319
+
320
+ /**
321
+ * Checks if a side of an element is scrolled past a side of its parents
322
+ * @param {HTMLElement} el The element who's side being scrolled out of view is in question
323
+ * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
324
+ * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
325
+ * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
326
+ */
327
+ function isScrolledPast(el, elSide, parentSide) {
328
+ var parent = getParentAutoScrollElement(el, true),
329
+ elSideVal = getRect(el)[elSide];
330
+
331
+ /* jshint boss:true */
332
+ while (parent) {
333
+ var parentSideVal = getRect(parent)[parentSide],
334
+ visible = void 0;
335
+ if (parentSide === 'top' || parentSide === 'left') {
336
+ visible = elSideVal >= parentSideVal;
337
+ } else {
338
+ visible = elSideVal <= parentSideVal;
339
+ }
340
+ if (!visible) return parent;
341
+ if (parent === getWindowScrollingElement()) break;
342
+ parent = getParentAutoScrollElement(parent, false);
343
+ }
344
+ return false;
345
+ }
346
+
347
+ /**
348
+ * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
349
+ * and non-draggable elements
350
+ * @param {HTMLElement} el The parent element
351
+ * @param {Number} childNum The index of the child
352
+ * @param {Object} options Parent Sortable's options
353
+ * @return {HTMLElement} The child at index childNum, or null if not found
354
+ */
355
+ function getChild(el, childNum, options, includeDragEl) {
356
+ var currentChild = 0,
357
+ i = 0,
358
+ children = el.children;
359
+ while (i < children.length) {
360
+ if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
361
+ if (currentChild === childNum) {
362
+ return children[i];
363
+ }
364
+ currentChild++;
365
+ }
366
+ i++;
367
+ }
368
+ return null;
369
+ }
370
+
371
+ /**
372
+ * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
373
+ * @param {HTMLElement} el Parent element
374
+ * @param {selector} selector Any other elements that should be ignored
375
+ * @return {HTMLElement} The last child, ignoring ghostEl
376
+ */
377
+ function lastChild(el, selector) {
378
+ var last = el.lastElementChild;
379
+ while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
380
+ last = last.previousElementSibling;
381
+ }
382
+ return last || null;
383
+ }
384
+
385
+ /**
386
+ * Returns the index of an element within its parent for a selected set of
387
+ * elements
388
+ * @param {HTMLElement} el
389
+ * @param {selector} selector
390
+ * @return {number}
391
+ */
392
+ function index(el, selector) {
393
+ var index = 0;
394
+ if (!el || !el.parentNode) {
395
+ return -1;
396
+ }
397
+
398
+ /* jshint boss:true */
399
+ while (el = el.previousElementSibling) {
400
+ if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
401
+ index++;
402
+ }
403
+ }
404
+ return index;
405
+ }
406
+
407
+ /**
408
+ * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
409
+ * The value is returned in real pixels.
410
+ * @param {HTMLElement} el
411
+ * @return {Array} Offsets in the format of [left, top]
412
+ */
413
+ function getRelativeScrollOffset(el) {
414
+ var offsetLeft = 0,
415
+ offsetTop = 0,
416
+ winScroller = getWindowScrollingElement();
417
+ if (el) {
418
+ do {
419
+ var elMatrix = matrix(el),
420
+ scaleX = elMatrix.a,
421
+ scaleY = elMatrix.d;
422
+ offsetLeft += el.scrollLeft * scaleX;
423
+ offsetTop += el.scrollTop * scaleY;
424
+ } while (el !== winScroller && (el = el.parentNode));
425
+ }
426
+ return [offsetLeft, offsetTop];
427
+ }
428
+
429
+ /**
430
+ * Returns the index of the object within the given array
431
+ * @param {Array} arr Array that may or may not hold the object
432
+ * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
433
+ * @return {Number} The index of the object in the array, or -1
434
+ */
435
+ function indexOfObject(arr, obj) {
436
+ for (var i in arr) {
437
+ if (!arr.hasOwnProperty(i)) continue;
438
+ for (var key in obj) {
439
+ if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
440
+ }
441
+ }
442
+ return -1;
443
+ }
444
+ function getParentAutoScrollElement(el, includeSelf) {
445
+ // skip to window
446
+ if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
447
+ var elem = el;
448
+ var gotSelf = false;
449
+ do {
450
+ // we don't need to get elem css if it isn't even overflowing in the first place (performance)
451
+ if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
452
+ var elemCSS = css(elem);
453
+ if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
454
+ if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
455
+ if (gotSelf || includeSelf) return elem;
456
+ gotSelf = true;
457
+ }
458
+ }
459
+ /* jshint boss:true */
460
+ } while (elem = elem.parentNode);
461
+ return getWindowScrollingElement();
462
+ }
463
+ function extend(dst, src) {
464
+ if (dst && src) {
465
+ for (var key in src) {
466
+ if (src.hasOwnProperty(key)) {
467
+ dst[key] = src[key];
468
+ }
469
+ }
470
+ }
471
+ return dst;
472
+ }
473
+ function isRectEqual(rect1, rect2) {
474
+ return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
475
+ }
476
+ var _throttleTimeout;
477
+ function throttle(callback, ms) {
478
+ return function () {
479
+ if (!_throttleTimeout) {
480
+ var args = arguments,
481
+ _this = this;
482
+ if (args.length === 1) {
483
+ callback.call(_this, args[0]);
484
+ } else {
485
+ callback.apply(_this, args);
486
+ }
487
+ _throttleTimeout = setTimeout(function () {
488
+ _throttleTimeout = void 0;
489
+ }, ms);
490
+ }
491
+ };
492
+ }
493
+ function cancelThrottle() {
494
+ clearTimeout(_throttleTimeout);
495
+ _throttleTimeout = void 0;
496
+ }
497
+ function scrollBy(el, x, y) {
498
+ el.scrollLeft += x;
499
+ el.scrollTop += y;
500
+ }
501
+ function clone(el) {
502
+ var Polymer = window.Polymer;
503
+ var $ = window.jQuery || window.Zepto;
504
+ if (Polymer && Polymer.dom) {
505
+ return Polymer.dom(el).cloneNode(true);
506
+ } else if ($) {
507
+ return $(el).clone(true)[0];
508
+ } else {
509
+ return el.cloneNode(true);
510
+ }
511
+ }
512
+ function getChildContainingRectFromElement(container, options, ghostEl) {
513
+ var rect = {};
514
+ Array.from(container.children).forEach(function (child) {
515
+ var _rect$left, _rect$top, _rect$right, _rect$bottom;
516
+ if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
517
+ var childRect = getRect(child);
518
+ rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
519
+ rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
520
+ rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
521
+ rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
522
+ });
523
+ rect.width = rect.right - rect.left;
524
+ rect.height = rect.bottom - rect.top;
525
+ rect.x = rect.left;
526
+ rect.y = rect.top;
527
+ return rect;
528
+ }
529
+ var expando = 'Sortable' + new Date().getTime();
530
+
531
+ function AnimationStateManager() {
532
+ var animationStates = [],
533
+ animationCallbackId;
534
+ return {
535
+ captureAnimationState: function captureAnimationState() {
536
+ animationStates = [];
537
+ if (!this.options.animation) return;
538
+ var children = [].slice.call(this.el.children);
539
+ children.forEach(function (child) {
540
+ if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
541
+ animationStates.push({
542
+ target: child,
543
+ rect: getRect(child)
544
+ });
545
+ var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
546
+
547
+ // If animating: compensate for current animation
548
+ if (child.thisAnimationDuration) {
549
+ var childMatrix = matrix(child, true);
550
+ if (childMatrix) {
551
+ fromRect.top -= childMatrix.f;
552
+ fromRect.left -= childMatrix.e;
553
+ }
554
+ }
555
+ child.fromRect = fromRect;
556
+ });
557
+ },
558
+ addAnimationState: function addAnimationState(state) {
559
+ animationStates.push(state);
560
+ },
561
+ removeAnimationState: function removeAnimationState(target) {
562
+ animationStates.splice(indexOfObject(animationStates, {
563
+ target: target
564
+ }), 1);
565
+ },
566
+ animateAll: function animateAll(callback) {
567
+ var _this = this;
568
+ if (!this.options.animation) {
569
+ clearTimeout(animationCallbackId);
570
+ if (typeof callback === 'function') callback();
571
+ return;
572
+ }
573
+ var animating = false,
574
+ animationTime = 0;
575
+ animationStates.forEach(function (state) {
576
+ var time = 0,
577
+ target = state.target,
578
+ fromRect = target.fromRect,
579
+ toRect = getRect(target),
580
+ prevFromRect = target.prevFromRect,
581
+ prevToRect = target.prevToRect,
582
+ animatingRect = state.rect,
583
+ targetMatrix = matrix(target, true);
584
+ if (targetMatrix) {
585
+ // Compensate for current animation
586
+ toRect.top -= targetMatrix.f;
587
+ toRect.left -= targetMatrix.e;
588
+ }
589
+ target.toRect = toRect;
590
+ if (target.thisAnimationDuration) {
591
+ // Could also check if animatingRect is between fromRect and toRect
592
+ if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) &&
593
+ // Make sure animatingRect is on line between toRect & fromRect
594
+ (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
595
+ // If returning to same place as started from animation and on same axis
596
+ time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
597
+ }
598
+ }
599
+
600
+ // if fromRect != toRect: animate
601
+ if (!isRectEqual(toRect, fromRect)) {
602
+ target.prevFromRect = fromRect;
603
+ target.prevToRect = toRect;
604
+ if (!time) {
605
+ time = _this.options.animation;
606
+ }
607
+ _this.animate(target, animatingRect, toRect, time);
608
+ }
609
+ if (time) {
610
+ animating = true;
611
+ animationTime = Math.max(animationTime, time);
612
+ clearTimeout(target.animationResetTimer);
613
+ target.animationResetTimer = setTimeout(function () {
614
+ target.animationTime = 0;
615
+ target.prevFromRect = null;
616
+ target.fromRect = null;
617
+ target.prevToRect = null;
618
+ target.thisAnimationDuration = null;
619
+ }, time);
620
+ target.thisAnimationDuration = time;
621
+ }
622
+ });
623
+ clearTimeout(animationCallbackId);
624
+ if (!animating) {
625
+ if (typeof callback === 'function') callback();
626
+ } else {
627
+ animationCallbackId = setTimeout(function () {
628
+ if (typeof callback === 'function') callback();
629
+ }, animationTime);
630
+ }
631
+ animationStates = [];
632
+ },
633
+ animate: function animate(target, currentRect, toRect, duration) {
634
+ if (duration) {
635
+ css(target, 'transition', '');
636
+ css(target, 'transform', '');
637
+ var elMatrix = matrix(this.el),
638
+ scaleX = elMatrix && elMatrix.a,
639
+ scaleY = elMatrix && elMatrix.d,
640
+ translateX = (currentRect.left - toRect.left) / (scaleX || 1),
641
+ translateY = (currentRect.top - toRect.top) / (scaleY || 1);
642
+ target.animatingX = !!translateX;
643
+ target.animatingY = !!translateY;
644
+ css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
645
+ this.forRepaintDummy = repaint(target); // repaint
646
+
647
+ css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
648
+ css(target, 'transform', 'translate3d(0,0,0)');
649
+ typeof target.animated === 'number' && clearTimeout(target.animated);
650
+ target.animated = setTimeout(function () {
651
+ css(target, 'transition', '');
652
+ css(target, 'transform', '');
653
+ target.animated = false;
654
+ target.animatingX = false;
655
+ target.animatingY = false;
656
+ }, duration);
657
+ }
658
+ }
659
+ };
660
+ }
661
+ function repaint(target) {
662
+ return target.offsetWidth;
663
+ }
664
+ function calculateRealTime(animatingRect, fromRect, toRect, options) {
665
+ return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
666
+ }
667
+
668
+ var plugins = [];
669
+ var defaults = {
670
+ initializeByDefault: true
671
+ };
672
+ var PluginManager = {
673
+ mount: function mount(plugin) {
674
+ // Set default static properties
675
+ for (var option in defaults) {
676
+ if (defaults.hasOwnProperty(option) && !(option in plugin)) {
677
+ plugin[option] = defaults[option];
678
+ }
679
+ }
680
+ plugins.forEach(function (p) {
681
+ if (p.pluginName === plugin.pluginName) {
682
+ throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
683
+ }
684
+ });
685
+ plugins.push(plugin);
686
+ },
687
+ pluginEvent: function pluginEvent(eventName, sortable, evt) {
688
+ var _this = this;
689
+ this.eventCanceled = false;
690
+ evt.cancel = function () {
691
+ _this.eventCanceled = true;
692
+ };
693
+ var eventNameGlobal = eventName + 'Global';
694
+ plugins.forEach(function (plugin) {
695
+ if (!sortable[plugin.pluginName]) return;
696
+ // Fire global events if it exists in this sortable
697
+ if (sortable[plugin.pluginName][eventNameGlobal]) {
698
+ sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
699
+ sortable: sortable
700
+ }, evt));
701
+ }
702
+
703
+ // Only fire plugin event if plugin is enabled in this sortable,
704
+ // and plugin has event defined
705
+ if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
706
+ sortable[plugin.pluginName][eventName](_objectSpread2({
707
+ sortable: sortable
708
+ }, evt));
709
+ }
710
+ });
711
+ },
712
+ initializePlugins: function initializePlugins(sortable, el, defaults, options) {
713
+ plugins.forEach(function (plugin) {
714
+ var pluginName = plugin.pluginName;
715
+ if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
716
+ var initialized = new plugin(sortable, el, sortable.options);
717
+ initialized.sortable = sortable;
718
+ initialized.options = sortable.options;
719
+ sortable[pluginName] = initialized;
720
+
721
+ // Add default options from plugin
722
+ _extends(defaults, initialized.defaults);
723
+ });
724
+ for (var option in sortable.options) {
725
+ if (!sortable.options.hasOwnProperty(option)) continue;
726
+ var modified = this.modifyOption(sortable, option, sortable.options[option]);
727
+ if (typeof modified !== 'undefined') {
728
+ sortable.options[option] = modified;
729
+ }
730
+ }
731
+ },
732
+ getEventProperties: function getEventProperties(name, sortable) {
733
+ var eventProperties = {};
734
+ plugins.forEach(function (plugin) {
735
+ if (typeof plugin.eventProperties !== 'function') return;
736
+ _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
737
+ });
738
+ return eventProperties;
739
+ },
740
+ modifyOption: function modifyOption(sortable, name, value) {
741
+ var modifiedValue;
742
+ plugins.forEach(function (plugin) {
743
+ // Plugin must exist on the Sortable
744
+ if (!sortable[plugin.pluginName]) return;
745
+
746
+ // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
747
+ if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
748
+ modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
749
+ }
750
+ });
751
+ return modifiedValue;
752
+ }
753
+ };
754
+
755
+ function dispatchEvent(_ref) {
756
+ var sortable = _ref.sortable,
757
+ rootEl = _ref.rootEl,
758
+ name = _ref.name,
759
+ targetEl = _ref.targetEl,
760
+ cloneEl = _ref.cloneEl,
761
+ toEl = _ref.toEl,
762
+ fromEl = _ref.fromEl,
763
+ oldIndex = _ref.oldIndex,
764
+ newIndex = _ref.newIndex,
765
+ oldDraggableIndex = _ref.oldDraggableIndex,
766
+ newDraggableIndex = _ref.newDraggableIndex,
767
+ originalEvent = _ref.originalEvent,
768
+ putSortable = _ref.putSortable,
769
+ extraEventProperties = _ref.extraEventProperties;
770
+ sortable = sortable || rootEl && rootEl[expando];
771
+ if (!sortable) return;
772
+ var evt,
773
+ options = sortable.options,
774
+ onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
775
+ // Support for new CustomEvent feature
776
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
777
+ evt = new CustomEvent(name, {
778
+ bubbles: true,
779
+ cancelable: true
780
+ });
781
+ } else {
782
+ evt = document.createEvent('Event');
783
+ evt.initEvent(name, true, true);
784
+ }
785
+ evt.to = toEl || rootEl;
786
+ evt.from = fromEl || rootEl;
787
+ evt.item = targetEl || rootEl;
788
+ evt.clone = cloneEl;
789
+ evt.oldIndex = oldIndex;
790
+ evt.newIndex = newIndex;
791
+ evt.oldDraggableIndex = oldDraggableIndex;
792
+ evt.newDraggableIndex = newDraggableIndex;
793
+ evt.originalEvent = originalEvent;
794
+ evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
795
+ var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
796
+ for (var option in allEventProperties) {
797
+ evt[option] = allEventProperties[option];
798
+ }
799
+ if (rootEl) {
800
+ rootEl.dispatchEvent(evt);
801
+ }
802
+ if (options[onName]) {
803
+ options[onName].call(sortable, evt);
804
+ }
805
+ }
806
+
807
+ var _excluded = ["evt"];
808
+ var pluginEvent = function pluginEvent(eventName, sortable) {
809
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
810
+ originalEvent = _ref.evt,
811
+ data = _objectWithoutProperties(_ref, _excluded);
812
+ PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
813
+ dragEl: dragEl,
814
+ parentEl: parentEl,
815
+ ghostEl: ghostEl,
816
+ rootEl: rootEl,
817
+ nextEl: nextEl,
818
+ lastDownEl: lastDownEl,
819
+ cloneEl: cloneEl,
820
+ cloneHidden: cloneHidden,
821
+ dragStarted: moved,
822
+ putSortable: putSortable,
823
+ activeSortable: Sortable.active,
824
+ originalEvent: originalEvent,
825
+ oldIndex: oldIndex,
826
+ oldDraggableIndex: oldDraggableIndex,
827
+ newIndex: newIndex,
828
+ newDraggableIndex: newDraggableIndex,
829
+ hideGhostForTarget: _hideGhostForTarget,
830
+ unhideGhostForTarget: _unhideGhostForTarget,
831
+ cloneNowHidden: function cloneNowHidden() {
832
+ cloneHidden = true;
833
+ },
834
+ cloneNowShown: function cloneNowShown() {
835
+ cloneHidden = false;
836
+ },
837
+ dispatchSortableEvent: function dispatchSortableEvent(name) {
838
+ _dispatchEvent({
839
+ sortable: sortable,
840
+ name: name,
841
+ originalEvent: originalEvent
842
+ });
843
+ }
844
+ }, data));
845
+ };
846
+ function _dispatchEvent(info) {
847
+ dispatchEvent(_objectSpread2({
848
+ putSortable: putSortable,
849
+ cloneEl: cloneEl,
850
+ targetEl: dragEl,
851
+ rootEl: rootEl,
852
+ oldIndex: oldIndex,
853
+ oldDraggableIndex: oldDraggableIndex,
854
+ newIndex: newIndex,
855
+ newDraggableIndex: newDraggableIndex
856
+ }, info));
857
+ }
858
+ var dragEl,
859
+ parentEl,
860
+ ghostEl,
861
+ rootEl,
862
+ nextEl,
863
+ lastDownEl,
864
+ cloneEl,
865
+ cloneHidden,
866
+ oldIndex,
867
+ newIndex,
868
+ oldDraggableIndex,
869
+ newDraggableIndex,
870
+ activeGroup,
871
+ putSortable,
872
+ awaitingDragStarted = false,
873
+ ignoreNextClick = false,
874
+ sortables = [],
875
+ tapEvt,
876
+ touchEvt,
877
+ lastDx,
878
+ lastDy,
879
+ tapDistanceLeft,
880
+ tapDistanceTop,
881
+ moved,
882
+ lastTarget,
883
+ lastDirection,
884
+ pastFirstInvertThresh = false,
885
+ isCircumstantialInvert = false,
886
+ targetMoveDistance,
887
+ // For positioning ghost absolutely
888
+ ghostRelativeParent,
889
+ ghostRelativeParentInitialScroll = [],
890
+ // (left, top)
891
+
892
+ _silent = false,
893
+ savedInputChecked = [];
894
+
895
+ /** @const */
896
+ var documentExists = typeof document !== 'undefined',
897
+ PositionGhostAbsolutely = IOS,
898
+ CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
899
+ // This will not pass for IE9, because IE9 DnD only works on anchors
900
+ supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
901
+ supportCssPointerEvents = function () {
902
+ if (!documentExists) return;
903
+ // false when <= IE11
904
+ if (IE11OrLess) {
905
+ return false;
906
+ }
907
+ var el = document.createElement('x');
908
+ el.style.cssText = 'pointer-events:auto';
909
+ return el.style.pointerEvents === 'auto';
910
+ }(),
911
+ _detectDirection = function _detectDirection(el, options) {
912
+ var elCSS = css(el),
913
+ elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
914
+ child1 = getChild(el, 0, options),
915
+ child2 = getChild(el, 1, options),
916
+ firstChildCSS = child1 && css(child1),
917
+ secondChildCSS = child2 && css(child2),
918
+ firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
919
+ secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
920
+ if (elCSS.display === 'flex') {
921
+ return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
922
+ }
923
+ if (elCSS.display === 'grid') {
924
+ return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
925
+ }
926
+ if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
927
+ var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
928
+ return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
929
+ }
930
+ return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
931
+ },
932
+ _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
933
+ var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
934
+ dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
935
+ dragElOppLength = vertical ? dragRect.width : dragRect.height,
936
+ targetS1Opp = vertical ? targetRect.left : targetRect.top,
937
+ targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
938
+ targetOppLength = vertical ? targetRect.width : targetRect.height;
939
+ return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
940
+ },
941
+ /**
942
+ * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
943
+ * @param {Number} x X position
944
+ * @param {Number} y Y position
945
+ * @return {HTMLElement} Element of the first found nearest Sortable
946
+ */
947
+ _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
948
+ var ret;
949
+ sortables.some(function (sortable) {
950
+ var threshold = sortable[expando].options.emptyInsertThreshold;
951
+ if (!threshold || lastChild(sortable)) return;
952
+ var rect = getRect(sortable),
953
+ insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
954
+ insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
955
+ if (insideHorizontally && insideVertically) {
956
+ return ret = sortable;
957
+ }
958
+ });
959
+ return ret;
960
+ },
961
+ _prepareGroup = function _prepareGroup(options) {
962
+ function toFn(value, pull) {
963
+ return function (to, from, dragEl, evt) {
964
+ var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
965
+ if (value == null && (pull || sameGroup)) {
966
+ // Default pull value
967
+ // Default pull and put value if same group
968
+ return true;
969
+ } else if (value == null || value === false) {
970
+ return false;
971
+ } else if (pull && value === 'clone') {
972
+ return value;
973
+ } else if (typeof value === 'function') {
974
+ return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
975
+ } else {
976
+ var otherGroup = (pull ? to : from).options.group.name;
977
+ return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
978
+ }
979
+ };
980
+ }
981
+ var group = {};
982
+ var originalGroup = options.group;
983
+ if (!originalGroup || _typeof(originalGroup) != 'object') {
984
+ originalGroup = {
985
+ name: originalGroup
986
+ };
987
+ }
988
+ group.name = originalGroup.name;
989
+ group.checkPull = toFn(originalGroup.pull, true);
990
+ group.checkPut = toFn(originalGroup.put);
991
+ group.revertClone = originalGroup.revertClone;
992
+ options.group = group;
993
+ },
994
+ _hideGhostForTarget = function _hideGhostForTarget() {
995
+ if (!supportCssPointerEvents && ghostEl) {
996
+ css(ghostEl, 'display', 'none');
997
+ }
998
+ },
999
+ _unhideGhostForTarget = function _unhideGhostForTarget() {
1000
+ if (!supportCssPointerEvents && ghostEl) {
1001
+ css(ghostEl, 'display', '');
1002
+ }
1003
+ };
1004
+
1005
+ // #1184 fix - Prevent click event on fallback if dragged but item not changed position
1006
+ if (documentExists && !ChromeForAndroid) {
1007
+ document.addEventListener('click', function (evt) {
1008
+ if (ignoreNextClick) {
1009
+ evt.preventDefault();
1010
+ evt.stopPropagation && evt.stopPropagation();
1011
+ evt.stopImmediatePropagation && evt.stopImmediatePropagation();
1012
+ ignoreNextClick = false;
1013
+ return false;
1014
+ }
1015
+ }, true);
1016
+ }
1017
+ var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
1018
+ if (dragEl) {
1019
+ evt = evt.touches ? evt.touches[0] : evt;
1020
+ var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
1021
+ if (nearest) {
1022
+ // Create imitation event
1023
+ var event = {};
1024
+ for (var i in evt) {
1025
+ if (evt.hasOwnProperty(i)) {
1026
+ event[i] = evt[i];
1027
+ }
1028
+ }
1029
+ event.target = event.rootEl = nearest;
1030
+ event.preventDefault = void 0;
1031
+ event.stopPropagation = void 0;
1032
+ nearest[expando]._onDragOver(event);
1033
+ }
1034
+ }
1035
+ };
1036
+ var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
1037
+ if (dragEl) {
1038
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1039
+ }
1040
+ };
1041
+
1042
+ /**
1043
+ * @class Sortable
1044
+ * @param {HTMLElement} el
1045
+ * @param {Object} [options]
1046
+ */
1047
+ function Sortable(el, options) {
1048
+ if (!(el && el.nodeType && el.nodeType === 1)) {
1049
+ throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
1050
+ }
1051
+ this.el = el; // root element
1052
+ this.options = options = _extends({}, options);
1053
+
1054
+ // Export instance
1055
+ el[expando] = this;
1056
+ var defaults = {
1057
+ group: null,
1058
+ sort: true,
1059
+ disabled: false,
1060
+ store: null,
1061
+ handle: null,
1062
+ draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
1063
+ swapThreshold: 1,
1064
+ // percentage; 0 <= x <= 1
1065
+ invertSwap: false,
1066
+ // invert always
1067
+ invertedSwapThreshold: null,
1068
+ // will be set to same as swapThreshold if default
1069
+ removeCloneOnHide: true,
1070
+ direction: function direction() {
1071
+ return _detectDirection(el, this.options);
1072
+ },
1073
+ ghostClass: 'sortable-ghost',
1074
+ chosenClass: 'sortable-chosen',
1075
+ dragClass: 'sortable-drag',
1076
+ ignore: 'a, img',
1077
+ filter: null,
1078
+ preventOnFilter: true,
1079
+ animation: 0,
1080
+ easing: null,
1081
+ setData: function setData(dataTransfer, dragEl) {
1082
+ dataTransfer.setData('Text', dragEl.textContent);
1083
+ },
1084
+ dropBubble: false,
1085
+ dragoverBubble: false,
1086
+ dataIdAttr: 'data-id',
1087
+ delay: 0,
1088
+ delayOnTouchOnly: false,
1089
+ touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
1090
+ forceFallback: false,
1091
+ fallbackClass: 'sortable-fallback',
1092
+ fallbackOnBody: false,
1093
+ fallbackTolerance: 0,
1094
+ fallbackOffset: {
1095
+ x: 0,
1096
+ y: 0
1097
+ },
1098
+ // Disabled on Safari: #1571; Enabled on Safari IOS: #2244
1099
+ supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && (!Safari || IOS),
1100
+ emptyInsertThreshold: 5
1101
+ };
1102
+ PluginManager.initializePlugins(this, el, defaults);
1103
+
1104
+ // Set default options
1105
+ for (var name in defaults) {
1106
+ !(name in options) && (options[name] = defaults[name]);
1107
+ }
1108
+ _prepareGroup(options);
1109
+
1110
+ // Bind all private methods
1111
+ for (var fn in this) {
1112
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
1113
+ this[fn] = this[fn].bind(this);
1114
+ }
1115
+ }
1116
+
1117
+ // Setup drag mode
1118
+ this.nativeDraggable = options.forceFallback ? false : supportDraggable;
1119
+ if (this.nativeDraggable) {
1120
+ // Touch start threshold cannot be greater than the native dragstart threshold
1121
+ this.options.touchStartThreshold = 1;
1122
+ }
1123
+
1124
+ // Bind events
1125
+ if (options.supportPointer) {
1126
+ on(el, 'pointerdown', this._onTapStart);
1127
+ } else {
1128
+ on(el, 'mousedown', this._onTapStart);
1129
+ on(el, 'touchstart', this._onTapStart);
1130
+ }
1131
+ if (this.nativeDraggable) {
1132
+ on(el, 'dragover', this);
1133
+ on(el, 'dragenter', this);
1134
+ }
1135
+ sortables.push(this.el);
1136
+
1137
+ // Restore sorting
1138
+ options.store && options.store.get && this.sort(options.store.get(this) || []);
1139
+
1140
+ // Add animation state manager
1141
+ _extends(this, AnimationStateManager());
1142
+ }
1143
+ Sortable.prototype = /** @lends Sortable.prototype */{
1144
+ constructor: Sortable,
1145
+ _isOutsideThisEl: function _isOutsideThisEl(target) {
1146
+ if (!this.el.contains(target) && target !== this.el) {
1147
+ lastTarget = null;
1148
+ }
1149
+ },
1150
+ _getDirection: function _getDirection(evt, target) {
1151
+ return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
1152
+ },
1153
+ _onTapStart: function _onTapStart( /** Event|TouchEvent */evt) {
1154
+ if (!evt.cancelable) return;
1155
+ var _this = this,
1156
+ el = this.el,
1157
+ options = this.options,
1158
+ preventOnFilter = options.preventOnFilter,
1159
+ type = evt.type,
1160
+ touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
1161
+ target = (touch || evt).target,
1162
+ originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
1163
+ filter = options.filter;
1164
+ _saveInputCheckedState(el);
1165
+
1166
+ // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
1167
+ if (dragEl) {
1168
+ return;
1169
+ }
1170
+ if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
1171
+ return; // only left button and enabled
1172
+ }
1173
+
1174
+ // cancel dnd if original target is content editable
1175
+ if (originalTarget.isContentEditable) {
1176
+ return;
1177
+ }
1178
+
1179
+ // Safari ignores further event handling after mousedown
1180
+ if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
1181
+ return;
1182
+ }
1183
+ target = closest(target, options.draggable, el, false);
1184
+ if (target && target.animated) {
1185
+ return;
1186
+ }
1187
+ if (lastDownEl === target) {
1188
+ // Ignoring duplicate `down`
1189
+ return;
1190
+ }
1191
+
1192
+ // Get the index of the dragged element within its parent
1193
+ oldIndex = index(target);
1194
+ oldDraggableIndex = index(target, options.draggable);
1195
+
1196
+ // Check filter
1197
+ if (typeof filter === 'function') {
1198
+ if (filter.call(this, evt, target, this)) {
1199
+ _dispatchEvent({
1200
+ sortable: _this,
1201
+ rootEl: originalTarget,
1202
+ name: 'filter',
1203
+ targetEl: target,
1204
+ toEl: el,
1205
+ fromEl: el
1206
+ });
1207
+ pluginEvent('filter', _this, {
1208
+ evt: evt
1209
+ });
1210
+ preventOnFilter && evt.preventDefault();
1211
+ return; // cancel dnd
1212
+ }
1213
+ } else if (filter) {
1214
+ filter = filter.split(',').some(function (criteria) {
1215
+ criteria = closest(originalTarget, criteria.trim(), el, false);
1216
+ if (criteria) {
1217
+ _dispatchEvent({
1218
+ sortable: _this,
1219
+ rootEl: criteria,
1220
+ name: 'filter',
1221
+ targetEl: target,
1222
+ fromEl: el,
1223
+ toEl: el
1224
+ });
1225
+ pluginEvent('filter', _this, {
1226
+ evt: evt
1227
+ });
1228
+ return true;
1229
+ }
1230
+ });
1231
+ if (filter) {
1232
+ preventOnFilter && evt.preventDefault();
1233
+ return; // cancel dnd
1234
+ }
1235
+ }
1236
+ if (options.handle && !closest(originalTarget, options.handle, el, false)) {
1237
+ return;
1238
+ }
1239
+
1240
+ // Prepare `dragstart`
1241
+ this._prepareDragStart(evt, touch, target);
1242
+ },
1243
+ _prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target) {
1244
+ var _this = this,
1245
+ el = _this.el,
1246
+ options = _this.options,
1247
+ ownerDocument = el.ownerDocument,
1248
+ dragStartFn;
1249
+ if (target && !dragEl && target.parentNode === el) {
1250
+ var dragRect = getRect(target);
1251
+ rootEl = el;
1252
+ dragEl = target;
1253
+ parentEl = dragEl.parentNode;
1254
+ nextEl = dragEl.nextSibling;
1255
+ lastDownEl = target;
1256
+ activeGroup = options.group;
1257
+ Sortable.dragged = dragEl;
1258
+ tapEvt = {
1259
+ target: dragEl,
1260
+ clientX: (touch || evt).clientX,
1261
+ clientY: (touch || evt).clientY
1262
+ };
1263
+ tapDistanceLeft = tapEvt.clientX - dragRect.left;
1264
+ tapDistanceTop = tapEvt.clientY - dragRect.top;
1265
+ this._lastX = (touch || evt).clientX;
1266
+ this._lastY = (touch || evt).clientY;
1267
+ dragEl.style['will-change'] = 'all';
1268
+ dragStartFn = function dragStartFn() {
1269
+ pluginEvent('delayEnded', _this, {
1270
+ evt: evt
1271
+ });
1272
+ if (Sortable.eventCanceled) {
1273
+ _this._onDrop();
1274
+ return;
1275
+ }
1276
+ // Delayed drag has been triggered
1277
+ // we can re-enable the events: touchmove/mousemove
1278
+ _this._disableDelayedDragEvents();
1279
+ if (!FireFox && _this.nativeDraggable) {
1280
+ dragEl.draggable = true;
1281
+ }
1282
+
1283
+ // Bind the events: dragstart/dragend
1284
+ _this._triggerDragStart(evt, touch);
1285
+
1286
+ // Drag start event
1287
+ _dispatchEvent({
1288
+ sortable: _this,
1289
+ name: 'choose',
1290
+ originalEvent: evt
1291
+ });
1292
+
1293
+ // Chosen item
1294
+ toggleClass(dragEl, options.chosenClass, true);
1295
+ };
1296
+
1297
+ // Disable "draggable"
1298
+ options.ignore.split(',').forEach(function (criteria) {
1299
+ find(dragEl, criteria.trim(), _disableDraggable);
1300
+ });
1301
+ on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
1302
+ on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
1303
+ on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
1304
+ if (options.supportPointer) {
1305
+ on(ownerDocument, 'pointerup', _this._onDrop);
1306
+ // Native D&D triggers pointercancel
1307
+ !this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
1308
+ } else {
1309
+ on(ownerDocument, 'mouseup', _this._onDrop);
1310
+ on(ownerDocument, 'touchend', _this._onDrop);
1311
+ on(ownerDocument, 'touchcancel', _this._onDrop);
1312
+ }
1313
+
1314
+ // Make dragEl draggable (must be before delay for FireFox)
1315
+ if (FireFox && this.nativeDraggable) {
1316
+ this.options.touchStartThreshold = 4;
1317
+ dragEl.draggable = true;
1318
+ }
1319
+ pluginEvent('delayStart', this, {
1320
+ evt: evt
1321
+ });
1322
+
1323
+ // Delay is impossible for native DnD in Edge or IE
1324
+ if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
1325
+ if (Sortable.eventCanceled) {
1326
+ this._onDrop();
1327
+ return;
1328
+ }
1329
+ // If the user moves the pointer or let go the click or touch
1330
+ // before the delay has been reached:
1331
+ // disable the delayed drag
1332
+ if (options.supportPointer) {
1333
+ on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
1334
+ on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
1335
+ } else {
1336
+ on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
1337
+ on(ownerDocument, 'touchend', _this._disableDelayedDrag);
1338
+ on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
1339
+ }
1340
+ on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
1341
+ on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
1342
+ options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
1343
+ _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
1344
+ } else {
1345
+ dragStartFn();
1346
+ }
1347
+ }
1348
+ },
1349
+ _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent **/e) {
1350
+ var touch = e.touches ? e.touches[0] : e;
1351
+ if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
1352
+ this._disableDelayedDrag();
1353
+ }
1354
+ },
1355
+ _disableDelayedDrag: function _disableDelayedDrag() {
1356
+ dragEl && _disableDraggable(dragEl);
1357
+ clearTimeout(this._dragStartTimer);
1358
+ this._disableDelayedDragEvents();
1359
+ },
1360
+ _disableDelayedDragEvents: function _disableDelayedDragEvents() {
1361
+ var ownerDocument = this.el.ownerDocument;
1362
+ off(ownerDocument, 'mouseup', this._disableDelayedDrag);
1363
+ off(ownerDocument, 'touchend', this._disableDelayedDrag);
1364
+ off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
1365
+ off(ownerDocument, 'pointerup', this._disableDelayedDrag);
1366
+ off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
1367
+ off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
1368
+ off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
1369
+ off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
1370
+ },
1371
+ _triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) {
1372
+ touch = touch || evt.pointerType == 'touch' && evt;
1373
+ if (!this.nativeDraggable || touch) {
1374
+ if (this.options.supportPointer) {
1375
+ on(document, 'pointermove', this._onTouchMove);
1376
+ } else if (touch) {
1377
+ on(document, 'touchmove', this._onTouchMove);
1378
+ } else {
1379
+ on(document, 'mousemove', this._onTouchMove);
1380
+ }
1381
+ } else {
1382
+ on(dragEl, 'dragend', this);
1383
+ on(rootEl, 'dragstart', this._onDragStart);
1384
+ }
1385
+ try {
1386
+ if (document.selection) {
1387
+ _nextTick(function () {
1388
+ document.selection.empty();
1389
+ });
1390
+ } else {
1391
+ window.getSelection().removeAllRanges();
1392
+ }
1393
+ } catch (err) {}
1394
+ },
1395
+ _dragStarted: function _dragStarted(fallback, evt) {
1396
+ awaitingDragStarted = false;
1397
+ if (rootEl && dragEl) {
1398
+ pluginEvent('dragStarted', this, {
1399
+ evt: evt
1400
+ });
1401
+ if (this.nativeDraggable) {
1402
+ on(document, 'dragover', _checkOutsideTargetEl);
1403
+ }
1404
+ var options = this.options;
1405
+
1406
+ // Apply effect
1407
+ !fallback && toggleClass(dragEl, options.dragClass, false);
1408
+ toggleClass(dragEl, options.ghostClass, true);
1409
+ Sortable.active = this;
1410
+ fallback && this._appendGhost();
1411
+
1412
+ // Drag start event
1413
+ _dispatchEvent({
1414
+ sortable: this,
1415
+ name: 'start',
1416
+ originalEvent: evt
1417
+ });
1418
+ } else {
1419
+ this._nulling();
1420
+ }
1421
+ },
1422
+ _emulateDragOver: function _emulateDragOver() {
1423
+ if (touchEvt) {
1424
+ this._lastX = touchEvt.clientX;
1425
+ this._lastY = touchEvt.clientY;
1426
+ _hideGhostForTarget();
1427
+ var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1428
+ var parent = target;
1429
+ while (target && target.shadowRoot) {
1430
+ target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1431
+ if (target === parent) break;
1432
+ parent = target;
1433
+ }
1434
+ dragEl.parentNode[expando]._isOutsideThisEl(target);
1435
+ if (parent) {
1436
+ do {
1437
+ if (parent[expando]) {
1438
+ var inserted = void 0;
1439
+ inserted = parent[expando]._onDragOver({
1440
+ clientX: touchEvt.clientX,
1441
+ clientY: touchEvt.clientY,
1442
+ target: target,
1443
+ rootEl: parent
1444
+ });
1445
+ if (inserted && !this.options.dragoverBubble) {
1446
+ break;
1447
+ }
1448
+ }
1449
+ target = parent; // store last element
1450
+ }
1451
+ /* jshint boss:true */ while (parent = getParentOrHost(parent));
1452
+ }
1453
+ _unhideGhostForTarget();
1454
+ }
1455
+ },
1456
+ _onTouchMove: function _onTouchMove( /**TouchEvent*/evt) {
1457
+ if (tapEvt) {
1458
+ var options = this.options,
1459
+ fallbackTolerance = options.fallbackTolerance,
1460
+ fallbackOffset = options.fallbackOffset,
1461
+ touch = evt.touches ? evt.touches[0] : evt,
1462
+ ghostMatrix = ghostEl && matrix(ghostEl, true),
1463
+ scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
1464
+ scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
1465
+ relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
1466
+ dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
1467
+ dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
1468
+
1469
+ // only set the status to dragging, when we are actually dragging
1470
+ if (!Sortable.active && !awaitingDragStarted) {
1471
+ if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
1472
+ return;
1473
+ }
1474
+ this._onDragStart(evt, true);
1475
+ }
1476
+ if (ghostEl) {
1477
+ if (ghostMatrix) {
1478
+ ghostMatrix.e += dx - (lastDx || 0);
1479
+ ghostMatrix.f += dy - (lastDy || 0);
1480
+ } else {
1481
+ ghostMatrix = {
1482
+ a: 1,
1483
+ b: 0,
1484
+ c: 0,
1485
+ d: 1,
1486
+ e: dx,
1487
+ f: dy
1488
+ };
1489
+ }
1490
+ var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
1491
+ css(ghostEl, 'webkitTransform', cssMatrix);
1492
+ css(ghostEl, 'mozTransform', cssMatrix);
1493
+ css(ghostEl, 'msTransform', cssMatrix);
1494
+ css(ghostEl, 'transform', cssMatrix);
1495
+ lastDx = dx;
1496
+ lastDy = dy;
1497
+ touchEvt = touch;
1498
+ }
1499
+ evt.cancelable && evt.preventDefault();
1500
+ }
1501
+ },
1502
+ _appendGhost: function _appendGhost() {
1503
+ // Bug if using scale(): https://stackoverflow.com/questions/2637058
1504
+ // Not being adjusted for
1505
+ if (!ghostEl) {
1506
+ var container = this.options.fallbackOnBody ? document.body : rootEl,
1507
+ rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
1508
+ options = this.options;
1509
+
1510
+ // Position absolutely
1511
+ if (PositionGhostAbsolutely) {
1512
+ // Get relatively positioned parent
1513
+ ghostRelativeParent = container;
1514
+ while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
1515
+ ghostRelativeParent = ghostRelativeParent.parentNode;
1516
+ }
1517
+ if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
1518
+ if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
1519
+ rect.top += ghostRelativeParent.scrollTop;
1520
+ rect.left += ghostRelativeParent.scrollLeft;
1521
+ } else {
1522
+ ghostRelativeParent = getWindowScrollingElement();
1523
+ }
1524
+ ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
1525
+ }
1526
+ ghostEl = dragEl.cloneNode(true);
1527
+ toggleClass(ghostEl, options.ghostClass, false);
1528
+ toggleClass(ghostEl, options.fallbackClass, true);
1529
+ toggleClass(ghostEl, options.dragClass, true);
1530
+ css(ghostEl, 'transition', '');
1531
+ css(ghostEl, 'transform', '');
1532
+ css(ghostEl, 'box-sizing', 'border-box');
1533
+ css(ghostEl, 'margin', 0);
1534
+ css(ghostEl, 'top', rect.top);
1535
+ css(ghostEl, 'left', rect.left);
1536
+ css(ghostEl, 'width', rect.width);
1537
+ css(ghostEl, 'height', rect.height);
1538
+ css(ghostEl, 'opacity', '0.8');
1539
+ css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
1540
+ css(ghostEl, 'zIndex', '100000');
1541
+ css(ghostEl, 'pointerEvents', 'none');
1542
+ Sortable.ghost = ghostEl;
1543
+ container.appendChild(ghostEl);
1544
+
1545
+ // Set transform-origin
1546
+ css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
1547
+ }
1548
+ },
1549
+ _onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback) {
1550
+ var _this = this;
1551
+ var dataTransfer = evt.dataTransfer;
1552
+ var options = _this.options;
1553
+ pluginEvent('dragStart', this, {
1554
+ evt: evt
1555
+ });
1556
+ if (Sortable.eventCanceled) {
1557
+ this._onDrop();
1558
+ return;
1559
+ }
1560
+ pluginEvent('setupClone', this);
1561
+ if (!Sortable.eventCanceled) {
1562
+ cloneEl = clone(dragEl);
1563
+ cloneEl.removeAttribute("id");
1564
+ cloneEl.draggable = false;
1565
+ cloneEl.style['will-change'] = '';
1566
+ this._hideClone();
1567
+ toggleClass(cloneEl, this.options.chosenClass, false);
1568
+ Sortable.clone = cloneEl;
1569
+ }
1570
+
1571
+ // #1143: IFrame support workaround
1572
+ _this.cloneId = _nextTick(function () {
1573
+ pluginEvent('clone', _this);
1574
+ if (Sortable.eventCanceled) return;
1575
+ if (!_this.options.removeCloneOnHide) {
1576
+ rootEl.insertBefore(cloneEl, dragEl);
1577
+ }
1578
+ _this._hideClone();
1579
+ _dispatchEvent({
1580
+ sortable: _this,
1581
+ name: 'clone'
1582
+ });
1583
+ });
1584
+ !fallback && toggleClass(dragEl, options.dragClass, true);
1585
+
1586
+ // Set proper drop events
1587
+ if (fallback) {
1588
+ ignoreNextClick = true;
1589
+ _this._loopId = setInterval(_this._emulateDragOver, 50);
1590
+ } else {
1591
+ // Undo what was set in _prepareDragStart before drag started
1592
+ off(document, 'mouseup', _this._onDrop);
1593
+ off(document, 'touchend', _this._onDrop);
1594
+ off(document, 'touchcancel', _this._onDrop);
1595
+ if (dataTransfer) {
1596
+ dataTransfer.effectAllowed = 'move';
1597
+ options.setData && options.setData.call(_this, dataTransfer, dragEl);
1598
+ }
1599
+ on(document, 'drop', _this);
1600
+
1601
+ // #1276 fix:
1602
+ css(dragEl, 'transform', 'translateZ(0)');
1603
+ }
1604
+ awaitingDragStarted = true;
1605
+ _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
1606
+ on(document, 'selectstart', _this);
1607
+ moved = true;
1608
+ window.getSelection().removeAllRanges();
1609
+ if (Safari) {
1610
+ css(document.body, 'user-select', 'none');
1611
+ }
1612
+ },
1613
+ // Returns true - if no further action is needed (either inserted or another condition)
1614
+ _onDragOver: function _onDragOver( /**Event*/evt) {
1615
+ var el = this.el,
1616
+ target = evt.target,
1617
+ dragRect,
1618
+ targetRect,
1619
+ revert,
1620
+ options = this.options,
1621
+ group = options.group,
1622
+ activeSortable = Sortable.active,
1623
+ isOwner = activeGroup === group,
1624
+ canSort = options.sort,
1625
+ fromSortable = putSortable || activeSortable,
1626
+ vertical,
1627
+ _this = this,
1628
+ completedFired = false;
1629
+ if (_silent) return;
1630
+ function dragOverEvent(name, extra) {
1631
+ pluginEvent(name, _this, _objectSpread2({
1632
+ evt: evt,
1633
+ isOwner: isOwner,
1634
+ axis: vertical ? 'vertical' : 'horizontal',
1635
+ revert: revert,
1636
+ dragRect: dragRect,
1637
+ targetRect: targetRect,
1638
+ canSort: canSort,
1639
+ fromSortable: fromSortable,
1640
+ target: target,
1641
+ completed: completed,
1642
+ onMove: function onMove(target, after) {
1643
+ return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
1644
+ },
1645
+ changed: changed
1646
+ }, extra));
1647
+ }
1648
+
1649
+ // Capture animation state
1650
+ function capture() {
1651
+ dragOverEvent('dragOverAnimationCapture');
1652
+ _this.captureAnimationState();
1653
+ if (_this !== fromSortable) {
1654
+ fromSortable.captureAnimationState();
1655
+ }
1656
+ }
1657
+
1658
+ // Return invocation when dragEl is inserted (or completed)
1659
+ function completed(insertion) {
1660
+ dragOverEvent('dragOverCompleted', {
1661
+ insertion: insertion
1662
+ });
1663
+ if (insertion) {
1664
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
1665
+ if (isOwner) {
1666
+ activeSortable._hideClone();
1667
+ } else {
1668
+ activeSortable._showClone(_this);
1669
+ }
1670
+ if (_this !== fromSortable) {
1671
+ // Set ghost class to new sortable's ghost class
1672
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
1673
+ toggleClass(dragEl, options.ghostClass, true);
1674
+ }
1675
+ if (putSortable !== _this && _this !== Sortable.active) {
1676
+ putSortable = _this;
1677
+ } else if (_this === Sortable.active && putSortable) {
1678
+ putSortable = null;
1679
+ }
1680
+
1681
+ // Animation
1682
+ if (fromSortable === _this) {
1683
+ _this._ignoreWhileAnimating = target;
1684
+ }
1685
+ _this.animateAll(function () {
1686
+ dragOverEvent('dragOverAnimationComplete');
1687
+ _this._ignoreWhileAnimating = null;
1688
+ });
1689
+ if (_this !== fromSortable) {
1690
+ fromSortable.animateAll();
1691
+ fromSortable._ignoreWhileAnimating = null;
1692
+ }
1693
+ }
1694
+
1695
+ // Null lastTarget if it is not inside a previously swapped element
1696
+ if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
1697
+ lastTarget = null;
1698
+ }
1699
+
1700
+ // no bubbling and not fallback
1701
+ if (!options.dragoverBubble && !evt.rootEl && target !== document) {
1702
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1703
+
1704
+ // Do not detect for empty insert if already inserted
1705
+ !insertion && nearestEmptyInsertDetectEvent(evt);
1706
+ }
1707
+ !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
1708
+ return completedFired = true;
1709
+ }
1710
+
1711
+ // Call when dragEl has been inserted
1712
+ function changed() {
1713
+ newIndex = index(dragEl);
1714
+ newDraggableIndex = index(dragEl, options.draggable);
1715
+ _dispatchEvent({
1716
+ sortable: _this,
1717
+ name: 'change',
1718
+ toEl: el,
1719
+ newIndex: newIndex,
1720
+ newDraggableIndex: newDraggableIndex,
1721
+ originalEvent: evt
1722
+ });
1723
+ }
1724
+ if (evt.preventDefault !== void 0) {
1725
+ evt.cancelable && evt.preventDefault();
1726
+ }
1727
+ target = closest(target, options.draggable, el, true);
1728
+ dragOverEvent('dragOver');
1729
+ if (Sortable.eventCanceled) return completedFired;
1730
+ if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
1731
+ return completed(false);
1732
+ }
1733
+ ignoreNextClick = false;
1734
+ if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
1735
+ : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
1736
+ vertical = this._getDirection(evt, target) === 'vertical';
1737
+ dragRect = getRect(dragEl);
1738
+ dragOverEvent('dragOverValid');
1739
+ if (Sortable.eventCanceled) return completedFired;
1740
+ if (revert) {
1741
+ parentEl = rootEl; // actualization
1742
+ capture();
1743
+ this._hideClone();
1744
+ dragOverEvent('revert');
1745
+ if (!Sortable.eventCanceled) {
1746
+ if (nextEl) {
1747
+ rootEl.insertBefore(dragEl, nextEl);
1748
+ } else {
1749
+ rootEl.appendChild(dragEl);
1750
+ }
1751
+ }
1752
+ return completed(true);
1753
+ }
1754
+ var elLastChild = lastChild(el, options.draggable);
1755
+ if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
1756
+ // Insert to end of list
1757
+
1758
+ // If already at end of list: Do not insert
1759
+ if (elLastChild === dragEl) {
1760
+ return completed(false);
1761
+ }
1762
+
1763
+ // if there is a last element, it is the target
1764
+ if (elLastChild && el === evt.target) {
1765
+ target = elLastChild;
1766
+ }
1767
+ if (target) {
1768
+ targetRect = getRect(target);
1769
+ }
1770
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
1771
+ capture();
1772
+ if (elLastChild && elLastChild.nextSibling) {
1773
+ // the last draggable element is not the last node
1774
+ el.insertBefore(dragEl, elLastChild.nextSibling);
1775
+ } else {
1776
+ el.appendChild(dragEl);
1777
+ }
1778
+ parentEl = el; // actualization
1779
+
1780
+ changed();
1781
+ return completed(true);
1782
+ }
1783
+ } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
1784
+ // Insert to start of list
1785
+ var firstChild = getChild(el, 0, options, true);
1786
+ if (firstChild === dragEl) {
1787
+ return completed(false);
1788
+ }
1789
+ target = firstChild;
1790
+ targetRect = getRect(target);
1791
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
1792
+ capture();
1793
+ el.insertBefore(dragEl, firstChild);
1794
+ parentEl = el; // actualization
1795
+
1796
+ changed();
1797
+ return completed(true);
1798
+ }
1799
+ } else if (target.parentNode === el) {
1800
+ targetRect = getRect(target);
1801
+ var direction = 0,
1802
+ targetBeforeFirstSwap,
1803
+ differentLevel = dragEl.parentNode !== el,
1804
+ differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
1805
+ side1 = vertical ? 'top' : 'left',
1806
+ scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
1807
+ scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
1808
+ if (lastTarget !== target) {
1809
+ targetBeforeFirstSwap = targetRect[side1];
1810
+ pastFirstInvertThresh = false;
1811
+ isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
1812
+ }
1813
+ direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
1814
+ var sibling;
1815
+ if (direction !== 0) {
1816
+ // Check if target is beside dragEl in respective direction (ignoring hidden elements)
1817
+ var dragIndex = index(dragEl);
1818
+ do {
1819
+ dragIndex -= direction;
1820
+ sibling = parentEl.children[dragIndex];
1821
+ } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
1822
+ }
1823
+ // If dragEl is already beside target: Do not insert
1824
+ if (direction === 0 || sibling === target) {
1825
+ return completed(false);
1826
+ }
1827
+ lastTarget = target;
1828
+ lastDirection = direction;
1829
+ var nextSibling = target.nextElementSibling,
1830
+ after = false;
1831
+ after = direction === 1;
1832
+ var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
1833
+ if (moveVector !== false) {
1834
+ if (moveVector === 1 || moveVector === -1) {
1835
+ after = moveVector === 1;
1836
+ }
1837
+ _silent = true;
1838
+ setTimeout(_unsilent, 30);
1839
+ capture();
1840
+ if (after && !nextSibling) {
1841
+ el.appendChild(dragEl);
1842
+ } else {
1843
+ target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
1844
+ }
1845
+
1846
+ // Undo chrome's scroll adjustment (has no effect on other browsers)
1847
+ if (scrolledPastTop) {
1848
+ scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
1849
+ }
1850
+ parentEl = dragEl.parentNode; // actualization
1851
+
1852
+ // must be done before animation
1853
+ if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
1854
+ targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
1855
+ }
1856
+ changed();
1857
+ return completed(true);
1858
+ }
1859
+ }
1860
+ if (el.contains(dragEl)) {
1861
+ return completed(false);
1862
+ }
1863
+ }
1864
+ return false;
1865
+ },
1866
+ _ignoreWhileAnimating: null,
1867
+ _offMoveEvents: function _offMoveEvents() {
1868
+ off(document, 'mousemove', this._onTouchMove);
1869
+ off(document, 'touchmove', this._onTouchMove);
1870
+ off(document, 'pointermove', this._onTouchMove);
1871
+ off(document, 'dragover', nearestEmptyInsertDetectEvent);
1872
+ off(document, 'mousemove', nearestEmptyInsertDetectEvent);
1873
+ off(document, 'touchmove', nearestEmptyInsertDetectEvent);
1874
+ },
1875
+ _offUpEvents: function _offUpEvents() {
1876
+ var ownerDocument = this.el.ownerDocument;
1877
+ off(ownerDocument, 'mouseup', this._onDrop);
1878
+ off(ownerDocument, 'touchend', this._onDrop);
1879
+ off(ownerDocument, 'pointerup', this._onDrop);
1880
+ off(ownerDocument, 'pointercancel', this._onDrop);
1881
+ off(ownerDocument, 'touchcancel', this._onDrop);
1882
+ off(document, 'selectstart', this);
1883
+ },
1884
+ _onDrop: function _onDrop( /**Event*/evt) {
1885
+ var el = this.el,
1886
+ options = this.options;
1887
+
1888
+ // Get the index of the dragged element within its parent
1889
+ newIndex = index(dragEl);
1890
+ newDraggableIndex = index(dragEl, options.draggable);
1891
+ pluginEvent('drop', this, {
1892
+ evt: evt
1893
+ });
1894
+ parentEl = dragEl && dragEl.parentNode;
1895
+
1896
+ // Get again after plugin event
1897
+ newIndex = index(dragEl);
1898
+ newDraggableIndex = index(dragEl, options.draggable);
1899
+ if (Sortable.eventCanceled) {
1900
+ this._nulling();
1901
+ return;
1902
+ }
1903
+ awaitingDragStarted = false;
1904
+ isCircumstantialInvert = false;
1905
+ pastFirstInvertThresh = false;
1906
+ clearInterval(this._loopId);
1907
+ clearTimeout(this._dragStartTimer);
1908
+ _cancelNextTick(this.cloneId);
1909
+ _cancelNextTick(this._dragStartId);
1910
+
1911
+ // Unbind events
1912
+ if (this.nativeDraggable) {
1913
+ off(document, 'drop', this);
1914
+ off(el, 'dragstart', this._onDragStart);
1915
+ }
1916
+ this._offMoveEvents();
1917
+ this._offUpEvents();
1918
+ if (Safari) {
1919
+ css(document.body, 'user-select', '');
1920
+ }
1921
+ css(dragEl, 'transform', '');
1922
+ if (evt) {
1923
+ if (moved) {
1924
+ evt.cancelable && evt.preventDefault();
1925
+ !options.dropBubble && evt.stopPropagation();
1926
+ }
1927
+ ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
1928
+ if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
1929
+ // Remove clone(s)
1930
+ cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
1931
+ }
1932
+ if (dragEl) {
1933
+ if (this.nativeDraggable) {
1934
+ off(dragEl, 'dragend', this);
1935
+ }
1936
+ _disableDraggable(dragEl);
1937
+ dragEl.style['will-change'] = '';
1938
+
1939
+ // Remove classes
1940
+ // ghostClass is added in dragStarted
1941
+ if (moved && !awaitingDragStarted) {
1942
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
1943
+ }
1944
+ toggleClass(dragEl, this.options.chosenClass, false);
1945
+
1946
+ // Drag stop event
1947
+ _dispatchEvent({
1948
+ sortable: this,
1949
+ name: 'unchoose',
1950
+ toEl: parentEl,
1951
+ newIndex: null,
1952
+ newDraggableIndex: null,
1953
+ originalEvent: evt
1954
+ });
1955
+ if (rootEl !== parentEl) {
1956
+ if (newIndex >= 0) {
1957
+ // Add event
1958
+ _dispatchEvent({
1959
+ rootEl: parentEl,
1960
+ name: 'add',
1961
+ toEl: parentEl,
1962
+ fromEl: rootEl,
1963
+ originalEvent: evt
1964
+ });
1965
+
1966
+ // Remove event
1967
+ _dispatchEvent({
1968
+ sortable: this,
1969
+ name: 'remove',
1970
+ toEl: parentEl,
1971
+ originalEvent: evt
1972
+ });
1973
+
1974
+ // drag from one list and drop into another
1975
+ _dispatchEvent({
1976
+ rootEl: parentEl,
1977
+ name: 'sort',
1978
+ toEl: parentEl,
1979
+ fromEl: rootEl,
1980
+ originalEvent: evt
1981
+ });
1982
+ _dispatchEvent({
1983
+ sortable: this,
1984
+ name: 'sort',
1985
+ toEl: parentEl,
1986
+ originalEvent: evt
1987
+ });
1988
+ }
1989
+ putSortable && putSortable.save();
1990
+ } else {
1991
+ if (newIndex !== oldIndex) {
1992
+ if (newIndex >= 0) {
1993
+ // drag & drop within the same list
1994
+ _dispatchEvent({
1995
+ sortable: this,
1996
+ name: 'update',
1997
+ toEl: parentEl,
1998
+ originalEvent: evt
1999
+ });
2000
+ _dispatchEvent({
2001
+ sortable: this,
2002
+ name: 'sort',
2003
+ toEl: parentEl,
2004
+ originalEvent: evt
2005
+ });
2006
+ }
2007
+ }
2008
+ }
2009
+ if (Sortable.active) {
2010
+ /* jshint eqnull:true */
2011
+ if (newIndex == null || newIndex === -1) {
2012
+ newIndex = oldIndex;
2013
+ newDraggableIndex = oldDraggableIndex;
2014
+ }
2015
+ _dispatchEvent({
2016
+ sortable: this,
2017
+ name: 'end',
2018
+ toEl: parentEl,
2019
+ originalEvent: evt
2020
+ });
2021
+
2022
+ // Save sorting
2023
+ this.save();
2024
+ }
2025
+ }
2026
+ }
2027
+ this._nulling();
2028
+ },
2029
+ _nulling: function _nulling() {
2030
+ pluginEvent('nulling', this);
2031
+ 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;
2032
+ savedInputChecked.forEach(function (el) {
2033
+ el.checked = true;
2034
+ });
2035
+ savedInputChecked.length = lastDx = lastDy = 0;
2036
+ },
2037
+ handleEvent: function handleEvent( /**Event*/evt) {
2038
+ switch (evt.type) {
2039
+ case 'drop':
2040
+ case 'dragend':
2041
+ this._onDrop(evt);
2042
+ break;
2043
+ case 'dragenter':
2044
+ case 'dragover':
2045
+ if (dragEl) {
2046
+ this._onDragOver(evt);
2047
+ _globalDragOver(evt);
2048
+ }
2049
+ break;
2050
+ case 'selectstart':
2051
+ evt.preventDefault();
2052
+ break;
2053
+ }
2054
+ },
2055
+ /**
2056
+ * Serializes the item into an array of string.
2057
+ * @returns {String[]}
2058
+ */
2059
+ toArray: function toArray() {
2060
+ var order = [],
2061
+ el,
2062
+ children = this.el.children,
2063
+ i = 0,
2064
+ n = children.length,
2065
+ options = this.options;
2066
+ for (; i < n; i++) {
2067
+ el = children[i];
2068
+ if (closest(el, options.draggable, this.el, false)) {
2069
+ order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
2070
+ }
2071
+ }
2072
+ return order;
2073
+ },
2074
+ /**
2075
+ * Sorts the elements according to the array.
2076
+ * @param {String[]} order order of the items
2077
+ */
2078
+ sort: function sort(order, useAnimation) {
2079
+ var items = {},
2080
+ rootEl = this.el;
2081
+ this.toArray().forEach(function (id, i) {
2082
+ var el = rootEl.children[i];
2083
+ if (closest(el, this.options.draggable, rootEl, false)) {
2084
+ items[id] = el;
2085
+ }
2086
+ }, this);
2087
+ useAnimation && this.captureAnimationState();
2088
+ order.forEach(function (id) {
2089
+ if (items[id]) {
2090
+ rootEl.removeChild(items[id]);
2091
+ rootEl.appendChild(items[id]);
2092
+ }
2093
+ });
2094
+ useAnimation && this.animateAll();
2095
+ },
2096
+ /**
2097
+ * Save the current sorting
2098
+ */
2099
+ save: function save() {
2100
+ var store = this.options.store;
2101
+ store && store.set && store.set(this);
2102
+ },
2103
+ /**
2104
+ * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
2105
+ * @param {HTMLElement} el
2106
+ * @param {String} [selector] default: `options.draggable`
2107
+ * @returns {HTMLElement|null}
2108
+ */
2109
+ closest: function closest$1(el, selector) {
2110
+ return closest(el, selector || this.options.draggable, this.el, false);
2111
+ },
2112
+ /**
2113
+ * Set/get option
2114
+ * @param {string} name
2115
+ * @param {*} [value]
2116
+ * @returns {*}
2117
+ */
2118
+ option: function option(name, value) {
2119
+ var options = this.options;
2120
+ if (value === void 0) {
2121
+ return options[name];
2122
+ } else {
2123
+ var modifiedValue = PluginManager.modifyOption(this, name, value);
2124
+ if (typeof modifiedValue !== 'undefined') {
2125
+ options[name] = modifiedValue;
2126
+ } else {
2127
+ options[name] = value;
2128
+ }
2129
+ if (name === 'group') {
2130
+ _prepareGroup(options);
2131
+ }
2132
+ }
2133
+ },
2134
+ /**
2135
+ * Destroy
2136
+ */
2137
+ destroy: function destroy() {
2138
+ pluginEvent('destroy', this);
2139
+ var el = this.el;
2140
+ el[expando] = null;
2141
+ off(el, 'mousedown', this._onTapStart);
2142
+ off(el, 'touchstart', this._onTapStart);
2143
+ off(el, 'pointerdown', this._onTapStart);
2144
+ if (this.nativeDraggable) {
2145
+ off(el, 'dragover', this);
2146
+ off(el, 'dragenter', this);
2147
+ }
2148
+ // Remove draggable attributes
2149
+ Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
2150
+ el.removeAttribute('draggable');
2151
+ });
2152
+ this._onDrop();
2153
+ this._disableDelayedDragEvents();
2154
+ sortables.splice(sortables.indexOf(this.el), 1);
2155
+ this.el = el = null;
2156
+ },
2157
+ _hideClone: function _hideClone() {
2158
+ if (!cloneHidden) {
2159
+ pluginEvent('hideClone', this);
2160
+ if (Sortable.eventCanceled) return;
2161
+ css(cloneEl, 'display', 'none');
2162
+ if (this.options.removeCloneOnHide && cloneEl.parentNode) {
2163
+ cloneEl.parentNode.removeChild(cloneEl);
2164
+ }
2165
+ cloneHidden = true;
2166
+ }
2167
+ },
2168
+ _showClone: function _showClone(putSortable) {
2169
+ if (putSortable.lastPutMode !== 'clone') {
2170
+ this._hideClone();
2171
+ return;
2172
+ }
2173
+ if (cloneHidden) {
2174
+ pluginEvent('showClone', this);
2175
+ if (Sortable.eventCanceled) return;
2176
+
2177
+ // show clone at dragEl or original position
2178
+ if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
2179
+ rootEl.insertBefore(cloneEl, dragEl);
2180
+ } else if (nextEl) {
2181
+ rootEl.insertBefore(cloneEl, nextEl);
2182
+ } else {
2183
+ rootEl.appendChild(cloneEl);
2184
+ }
2185
+ if (this.options.group.revertClone) {
2186
+ this.animate(dragEl, cloneEl);
2187
+ }
2188
+ css(cloneEl, 'display', '');
2189
+ cloneHidden = false;
2190
+ }
2191
+ }
2192
+ };
2193
+ function _globalDragOver( /**Event*/evt) {
2194
+ if (evt.dataTransfer) {
2195
+ evt.dataTransfer.dropEffect = 'move';
2196
+ }
2197
+ evt.cancelable && evt.preventDefault();
2198
+ }
2199
+ function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
2200
+ var evt,
2201
+ sortable = fromEl[expando],
2202
+ onMoveFn = sortable.options.onMove,
2203
+ retVal;
2204
+ // Support for new CustomEvent feature
2205
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
2206
+ evt = new CustomEvent('move', {
2207
+ bubbles: true,
2208
+ cancelable: true
2209
+ });
2210
+ } else {
2211
+ evt = document.createEvent('Event');
2212
+ evt.initEvent('move', true, true);
2213
+ }
2214
+ evt.to = toEl;
2215
+ evt.from = fromEl;
2216
+ evt.dragged = dragEl;
2217
+ evt.draggedRect = dragRect;
2218
+ evt.related = targetEl || toEl;
2219
+ evt.relatedRect = targetRect || getRect(toEl);
2220
+ evt.willInsertAfter = willInsertAfter;
2221
+ evt.originalEvent = originalEvent;
2222
+ fromEl.dispatchEvent(evt);
2223
+ if (onMoveFn) {
2224
+ retVal = onMoveFn.call(sortable, evt, originalEvent);
2225
+ }
2226
+ return retVal;
2227
+ }
2228
+ function _disableDraggable(el) {
2229
+ el.draggable = false;
2230
+ }
2231
+ function _unsilent() {
2232
+ _silent = false;
2233
+ }
2234
+ function _ghostIsFirst(evt, vertical, sortable) {
2235
+ var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
2236
+ var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
2237
+ var spacer = 10;
2238
+ return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
2239
+ }
2240
+ function _ghostIsLast(evt, vertical, sortable) {
2241
+ var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
2242
+ var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
2243
+ var spacer = 10;
2244
+ return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
2245
+ }
2246
+ function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
2247
+ var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
2248
+ targetLength = vertical ? targetRect.height : targetRect.width,
2249
+ targetS1 = vertical ? targetRect.top : targetRect.left,
2250
+ targetS2 = vertical ? targetRect.bottom : targetRect.right,
2251
+ invert = false;
2252
+ if (!invertSwap) {
2253
+ // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
2254
+ if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
2255
+ // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
2256
+ // check if past first invert threshold on side opposite of lastDirection
2257
+ if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
2258
+ // past first invert threshold, do not restrict inverted threshold to dragEl shadow
2259
+ pastFirstInvertThresh = true;
2260
+ }
2261
+ if (!pastFirstInvertThresh) {
2262
+ // dragEl shadow (target move distance shadow)
2263
+ if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
2264
+ : mouseOnAxis > targetS2 - targetMoveDistance) {
2265
+ return -lastDirection;
2266
+ }
2267
+ } else {
2268
+ invert = true;
2269
+ }
2270
+ } else {
2271
+ // Regular
2272
+ if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
2273
+ return _getInsertDirection(target);
2274
+ }
2275
+ }
2276
+ }
2277
+ invert = invert || invertSwap;
2278
+ if (invert) {
2279
+ // Invert of regular
2280
+ if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
2281
+ return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
2282
+ }
2283
+ }
2284
+ return 0;
2285
+ }
2286
+
2287
+ /**
2288
+ * Gets the direction dragEl must be swapped relative to target in order to make it
2289
+ * seem that dragEl has been "inserted" into that element's position
2290
+ * @param {HTMLElement} target The target whose position dragEl is being inserted at
2291
+ * @return {Number} Direction dragEl must be swapped
2292
+ */
2293
+ function _getInsertDirection(target) {
2294
+ if (index(dragEl) < index(target)) {
2295
+ return 1;
2296
+ } else {
2297
+ return -1;
2298
+ }
2299
+ }
2300
+
2301
+ /**
2302
+ * Generate id
2303
+ * @param {HTMLElement} el
2304
+ * @returns {String}
2305
+ * @private
2306
+ */
2307
+ function _generateId(el) {
2308
+ var str = el.tagName + el.className + el.src + el.href + el.textContent,
2309
+ i = str.length,
2310
+ sum = 0;
2311
+ while (i--) {
2312
+ sum += str.charCodeAt(i);
2313
+ }
2314
+ return sum.toString(36);
2315
+ }
2316
+ function _saveInputCheckedState(root) {
2317
+ savedInputChecked.length = 0;
2318
+ var inputs = root.getElementsByTagName('input');
2319
+ var idx = inputs.length;
2320
+ while (idx--) {
2321
+ var el = inputs[idx];
2322
+ el.checked && savedInputChecked.push(el);
2323
+ }
2324
+ }
2325
+ function _nextTick(fn) {
2326
+ return setTimeout(fn, 0);
2327
+ }
2328
+ function _cancelNextTick(id) {
2329
+ return clearTimeout(id);
2330
+ }
2331
+
2332
+ // Fixed #973:
2333
+ if (documentExists) {
2334
+ on(document, 'touchmove', function (evt) {
2335
+ if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
2336
+ evt.preventDefault();
2337
+ }
2338
+ });
2339
+ }
2340
+
2341
+ // Export utils
2342
+ Sortable.utils = {
2343
+ on: on,
2344
+ off: off,
2345
+ css: css,
2346
+ find: find,
2347
+ is: function is(el, selector) {
2348
+ return !!closest(el, selector, el, false);
2349
+ },
2350
+ extend: extend,
2351
+ throttle: throttle,
2352
+ closest: closest,
2353
+ toggleClass: toggleClass,
2354
+ clone: clone,
2355
+ index: index,
2356
+ nextTick: _nextTick,
2357
+ cancelNextTick: _cancelNextTick,
2358
+ detectDirection: _detectDirection,
2359
+ getChild: getChild,
2360
+ expando: expando
2361
+ };
2362
+
2363
+ /**
2364
+ * Get the Sortable instance of an element
2365
+ * @param {HTMLElement} element The element
2366
+ * @return {Sortable|undefined} The instance of Sortable
2367
+ */
2368
+ Sortable.get = function (element) {
2369
+ return element[expando];
2370
+ };
2371
+
2372
+ /**
2373
+ * Mount a plugin to Sortable
2374
+ * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
2375
+ */
2376
+ Sortable.mount = function () {
2377
+ for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
2378
+ plugins[_key] = arguments[_key];
2379
+ }
2380
+ if (plugins[0].constructor === Array) plugins = plugins[0];
2381
+ plugins.forEach(function (plugin) {
2382
+ if (!plugin.prototype || !plugin.prototype.constructor) {
2383
+ throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
2384
+ }
2385
+ if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
2386
+ PluginManager.mount(plugin);
2387
+ });
2388
+ };
2389
+
2390
+ /**
2391
+ * Create sortable instance
2392
+ * @param {HTMLElement} el
2393
+ * @param {Object} [options]
2394
+ */
2395
+ Sortable.create = function (el, options) {
2396
+ return new Sortable(el, options);
2397
+ };
2398
+
2399
+ // Export
2400
+ Sortable.version = version;
2401
+
2402
+ var autoScrolls = [],
2403
+ scrollEl,
2404
+ scrollRootEl,
2405
+ scrolling = false,
2406
+ lastAutoScrollX,
2407
+ lastAutoScrollY,
2408
+ touchEvt$1,
2409
+ pointerElemChangedInterval;
2410
+ function AutoScrollPlugin() {
2411
+ function AutoScroll() {
2412
+ this.defaults = {
2413
+ scroll: true,
2414
+ forceAutoScrollFallback: false,
2415
+ scrollSensitivity: 30,
2416
+ scrollSpeed: 10,
2417
+ bubbleScroll: true
2418
+ };
2419
+
2420
+ // Bind all private methods
2421
+ for (var fn in this) {
2422
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
2423
+ this[fn] = this[fn].bind(this);
2424
+ }
2425
+ }
2426
+ }
2427
+ AutoScroll.prototype = {
2428
+ dragStarted: function dragStarted(_ref) {
2429
+ var originalEvent = _ref.originalEvent;
2430
+ if (this.sortable.nativeDraggable) {
2431
+ on(document, 'dragover', this._handleAutoScroll);
2432
+ } else {
2433
+ if (this.options.supportPointer) {
2434
+ on(document, 'pointermove', this._handleFallbackAutoScroll);
2435
+ } else if (originalEvent.touches) {
2436
+ on(document, 'touchmove', this._handleFallbackAutoScroll);
2437
+ } else {
2438
+ on(document, 'mousemove', this._handleFallbackAutoScroll);
2439
+ }
2440
+ }
2441
+ },
2442
+ dragOverCompleted: function dragOverCompleted(_ref2) {
2443
+ var originalEvent = _ref2.originalEvent;
2444
+ // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
2445
+ if (!this.options.dragOverBubble && !originalEvent.rootEl) {
2446
+ this._handleAutoScroll(originalEvent);
2447
+ }
2448
+ },
2449
+ drop: function drop() {
2450
+ if (this.sortable.nativeDraggable) {
2451
+ off(document, 'dragover', this._handleAutoScroll);
2452
+ } else {
2453
+ off(document, 'pointermove', this._handleFallbackAutoScroll);
2454
+ off(document, 'touchmove', this._handleFallbackAutoScroll);
2455
+ off(document, 'mousemove', this._handleFallbackAutoScroll);
2456
+ }
2457
+ clearPointerElemChangedInterval();
2458
+ clearAutoScrolls();
2459
+ cancelThrottle();
2460
+ },
2461
+ nulling: function nulling() {
2462
+ touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
2463
+ autoScrolls.length = 0;
2464
+ },
2465
+ _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
2466
+ this._handleAutoScroll(evt, true);
2467
+ },
2468
+ _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
2469
+ var _this = this;
2470
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2471
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2472
+ elem = document.elementFromPoint(x, y);
2473
+ touchEvt$1 = evt;
2474
+
2475
+ // IE does not seem to have native autoscroll,
2476
+ // Edge's autoscroll seems too conditional,
2477
+ // MACOS Safari does not have autoscroll,
2478
+ // Firefox and Chrome are good
2479
+ if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
2480
+ autoScroll(evt, this.options, elem, fallback);
2481
+
2482
+ // Listener for pointer element change
2483
+ var ogElemScroller = getParentAutoScrollElement(elem, true);
2484
+ if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
2485
+ pointerElemChangedInterval && clearPointerElemChangedInterval();
2486
+ // Detect for pointer elem change, emulating native DnD behaviour
2487
+ pointerElemChangedInterval = setInterval(function () {
2488
+ var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
2489
+ if (newElem !== ogElemScroller) {
2490
+ ogElemScroller = newElem;
2491
+ clearAutoScrolls();
2492
+ }
2493
+ autoScroll(evt, _this.options, newElem, fallback);
2494
+ }, 10);
2495
+ lastAutoScrollX = x;
2496
+ lastAutoScrollY = y;
2497
+ }
2498
+ } else {
2499
+ // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
2500
+ if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
2501
+ clearAutoScrolls();
2502
+ return;
2503
+ }
2504
+ autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
2505
+ }
2506
+ }
2507
+ };
2508
+ return _extends(AutoScroll, {
2509
+ pluginName: 'scroll',
2510
+ initializeByDefault: true
2511
+ });
2512
+ }
2513
+ function clearAutoScrolls() {
2514
+ autoScrolls.forEach(function (autoScroll) {
2515
+ clearInterval(autoScroll.pid);
2516
+ });
2517
+ autoScrolls = [];
2518
+ }
2519
+ function clearPointerElemChangedInterval() {
2520
+ clearInterval(pointerElemChangedInterval);
2521
+ }
2522
+ var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
2523
+ // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
2524
+ if (!options.scroll) return;
2525
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2526
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2527
+ sens = options.scrollSensitivity,
2528
+ speed = options.scrollSpeed,
2529
+ winScroller = getWindowScrollingElement();
2530
+ var scrollThisInstance = false,
2531
+ scrollCustomFn;
2532
+
2533
+ // New scroll root, set scrollEl
2534
+ if (scrollRootEl !== rootEl) {
2535
+ scrollRootEl = rootEl;
2536
+ clearAutoScrolls();
2537
+ scrollEl = options.scroll;
2538
+ scrollCustomFn = options.scrollFn;
2539
+ if (scrollEl === true) {
2540
+ scrollEl = getParentAutoScrollElement(rootEl, true);
2541
+ }
2542
+ }
2543
+ var layersOut = 0;
2544
+ var currentParent = scrollEl;
2545
+ do {
2546
+ var el = currentParent,
2547
+ rect = getRect(el),
2548
+ top = rect.top,
2549
+ bottom = rect.bottom,
2550
+ left = rect.left,
2551
+ right = rect.right,
2552
+ width = rect.width,
2553
+ height = rect.height,
2554
+ canScrollX = void 0,
2555
+ canScrollY = void 0,
2556
+ scrollWidth = el.scrollWidth,
2557
+ scrollHeight = el.scrollHeight,
2558
+ elCSS = css(el),
2559
+ scrollPosX = el.scrollLeft,
2560
+ scrollPosY = el.scrollTop;
2561
+ if (el === winScroller) {
2562
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
2563
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
2564
+ } else {
2565
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
2566
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
2567
+ }
2568
+ var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
2569
+ var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
2570
+ if (!autoScrolls[layersOut]) {
2571
+ for (var i = 0; i <= layersOut; i++) {
2572
+ if (!autoScrolls[i]) {
2573
+ autoScrolls[i] = {};
2574
+ }
2575
+ }
2576
+ }
2577
+ if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
2578
+ autoScrolls[layersOut].el = el;
2579
+ autoScrolls[layersOut].vx = vx;
2580
+ autoScrolls[layersOut].vy = vy;
2581
+ clearInterval(autoScrolls[layersOut].pid);
2582
+ if (vx != 0 || vy != 0) {
2583
+ scrollThisInstance = true;
2584
+ /* jshint loopfunc:true */
2585
+ autoScrolls[layersOut].pid = setInterval(function () {
2586
+ // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
2587
+ if (isFallback && this.layer === 0) {
2588
+ Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
2589
+ }
2590
+ var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
2591
+ var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
2592
+ if (typeof scrollCustomFn === 'function') {
2593
+ if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
2594
+ return;
2595
+ }
2596
+ }
2597
+ scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
2598
+ }.bind({
2599
+ layer: layersOut
2600
+ }), 24);
2601
+ }
2602
+ }
2603
+ layersOut++;
2604
+ } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
2605
+ scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
2606
+ }, 30);
2607
+
2608
+ var drop = function drop(_ref) {
2609
+ var originalEvent = _ref.originalEvent,
2610
+ putSortable = _ref.putSortable,
2611
+ dragEl = _ref.dragEl,
2612
+ activeSortable = _ref.activeSortable,
2613
+ dispatchSortableEvent = _ref.dispatchSortableEvent,
2614
+ hideGhostForTarget = _ref.hideGhostForTarget,
2615
+ unhideGhostForTarget = _ref.unhideGhostForTarget;
2616
+ if (!originalEvent) return;
2617
+ var toSortable = putSortable || activeSortable;
2618
+ hideGhostForTarget();
2619
+ var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
2620
+ var target = document.elementFromPoint(touch.clientX, touch.clientY);
2621
+ unhideGhostForTarget();
2622
+ if (toSortable && !toSortable.el.contains(target)) {
2623
+ dispatchSortableEvent('spill');
2624
+ this.onSpill({
2625
+ dragEl: dragEl,
2626
+ putSortable: putSortable
2627
+ });
2628
+ }
2629
+ };
2630
+ function Revert() {}
2631
+ Revert.prototype = {
2632
+ startIndex: null,
2633
+ dragStart: function dragStart(_ref2) {
2634
+ var oldDraggableIndex = _ref2.oldDraggableIndex;
2635
+ this.startIndex = oldDraggableIndex;
2636
+ },
2637
+ onSpill: function onSpill(_ref3) {
2638
+ var dragEl = _ref3.dragEl,
2639
+ putSortable = _ref3.putSortable;
2640
+ this.sortable.captureAnimationState();
2641
+ if (putSortable) {
2642
+ putSortable.captureAnimationState();
2643
+ }
2644
+ var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
2645
+ if (nextSibling) {
2646
+ this.sortable.el.insertBefore(dragEl, nextSibling);
2647
+ } else {
2648
+ this.sortable.el.appendChild(dragEl);
2649
+ }
2650
+ this.sortable.animateAll();
2651
+ if (putSortable) {
2652
+ putSortable.animateAll();
2653
+ }
2654
+ },
2655
+ drop: drop
2656
+ };
2657
+ _extends(Revert, {
2658
+ pluginName: 'revertOnSpill'
2659
+ });
2660
+ function Remove() {}
2661
+ Remove.prototype = {
2662
+ onSpill: function onSpill(_ref4) {
2663
+ var dragEl = _ref4.dragEl,
2664
+ putSortable = _ref4.putSortable;
2665
+ var parentSortable = putSortable || this.sortable;
2666
+ parentSortable.captureAnimationState();
2667
+ dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
2668
+ parentSortable.animateAll();
2669
+ },
2670
+ drop: drop
2671
+ };
2672
+ _extends(Remove, {
2673
+ pluginName: 'removeOnSpill'
2674
+ });
2675
+
2676
+ Sortable.mount(new AutoScrollPlugin());
2677
+ Sortable.mount(Remove, Revert);
2678
+
2679
+ const verdocsTemplateRolesCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-roles{display:block;max-width:600px;font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif}verdocs-template-roles .roles{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:10px;margin-top:10px}verdocs-template-roles .roles .sequence{gap:10px;height:34px;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;font-weight:500;-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{margin:0;padding:0;border:none;opacity:0.3;cursor:pointer;background:none;-webkit-transform:scale(0.75);transform:scale(0.75)}verdocs-template-roles .add-role:hover{opacity:1}verdocs-template-roles .add-role svg{width:32px;height:32px}verdocs-template-roles .add-step{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-roles .add-step:hover{opacity:1}verdocs-template-roles .add-step svg{width:32px;height:32px}verdocs-template-roles.dragging .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.dragging .roles .sequence.add-sequence .add-role,verdocs-template-roles.dragging .roles .sequence.add-sequence .add-step-label{display:none}verdocs-template-roles.dragging .roles .sequence.add-sequence .sequence-roles{display:-ms-flexbox;display:flex;min-width:150px;background:#e0e0e0}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}";
2680
+ const VerdocsTemplateRolesStyle0 = verdocsTemplateRolesCss;
2681
+
2682
+ const 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>';
2683
+ const 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>`;
2684
+ const 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>';
2685
+ const 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>`;
2686
+ const 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>`;
2687
+ const VerdocsTemplateRoles = /*@__PURE__*/ proxyCustomElement(class VerdocsTemplateRoles extends H {
2688
+ constructor() {
2689
+ super();
2690
+ this.__registerHost();
2691
+ this.next = createEvent(this, "next", 7);
2692
+ this.exit = createEvent(this, "exit", 7);
2693
+ this.sdkError = createEvent(this, "sdkError", 7);
2694
+ this.rolesUpdated = createEvent(this, "rolesUpdated", 7);
2695
+ this.templateListenerId = null;
2696
+ this.endpoint = VerdocsEndpoint.getDefault();
2697
+ this.templateId = '';
2698
+ this.showingRoleDialog = null;
2699
+ this.sender = null;
2700
+ this.dragging = false;
2701
+ this.loading = true;
2702
+ this.template = null;
2703
+ }
2704
+ disconnectedCallback() {
2705
+ this.unlistenToTemplate();
2706
+ }
2707
+ async listenToTemplate() {
2708
+ console.log('[ROLES] Loading template', this.templateId);
2709
+ this.unlistenToTemplate();
2710
+ Store.subscribe('templates', this.templateId, () => getTemplate(this.endpoint, this.templateId), false, (template) => {
2711
+ console.log('[ROLES] Template Updated', template);
2712
+ this.template = template;
2713
+ this.loading = false;
2714
+ });
2715
+ }
2716
+ unlistenToTemplate() {
2717
+ if (this.templateListenerId) {
2718
+ Store.store.delListener(this.templateListenerId);
2719
+ this.templateListenerId = null;
2720
+ }
2721
+ }
2722
+ async componentWillLoad() {
2723
+ var _a, _b, _c;
2724
+ try {
2725
+ this.endpoint.loadSession();
2726
+ if (!this.templateId) {
2727
+ console.log(`[ROLES] Missing required template ID ${this.templateId}`);
2728
+ return;
2729
+ }
2730
+ if (!this.endpoint.session) {
2731
+ console.log('[ROLES] Unable to start builder session, must be authenticated');
2732
+ return;
2733
+ }
2734
+ this.listenToTemplate();
2735
+ }
2736
+ catch (e) {
2737
+ console.log('[FIELDS] Error with preview session', e);
2738
+ (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
2739
+ }
2740
+ }
2741
+ componentDidRender() {
2742
+ // Existing sequence numbers
2743
+ const sequenceNumbers = this.getSequenceNumbers();
2744
+ sequenceNumbers.forEach(sequence => {
2745
+ const el = document.getElementById(`verdocs-roles-sequence-${sequence}`);
2746
+ if (el) {
2747
+ new Sortable(el, {
2748
+ group: 'roles',
2749
+ animation: 150,
2750
+ dragoverBubble: true,
2751
+ filter: '.no-drag',
2752
+ onEnd: this.handleMoveEnd.bind(this),
2753
+ onChoose: () => (this.dragging = true),
2754
+ onUnchoose: () => (this.dragging = false),
2755
+ });
2756
+ }
2757
+ });
2758
+ const el = document.getElementById(`verdocs-roles-sequence-${sequenceNumbers.length + 1}`);
2759
+ if (el) {
2760
+ new Sortable(el, {
2761
+ group: 'roles',
2762
+ animation: 150,
2763
+ dragoverBubble: true,
2764
+ filter: '.no-drag',
2765
+ onEnd: this.handleMoveEnd.bind(this),
2766
+ onChoose: () => (this.dragging = true),
2767
+ onUnchoose: () => (this.dragging = false),
2768
+ });
2769
+ }
2770
+ }
2771
+ handleMoveEnd(evt) {
2772
+ const fromSeq = +evt.from.id.split('-').pop();
2773
+ const toSeq = +evt.to.id.split('-').pop();
2774
+ const fromIndex = +evt.oldIndex + 1;
2775
+ const toIndex = +evt.newIndex + 1;
2776
+ // console.log(`Move from ${fromSeq}:${fromIndex} to ${toSeq}:${toIndex}`, evt.item);
2777
+ const sortableRoles = {};
2778
+ const sequenceNumbers = this.getSequenceNumbers();
2779
+ sequenceNumbers.forEach(sequence => {
2780
+ sortableRoles[sequence] = JSON.parse(JSON.stringify(this.getRolesAtSequence(sequence)));
2781
+ });
2782
+ // We might be adding a new sequence number now. Make sure we have an array to drop
2783
+ // the record into.
2784
+ sortableRoles[sequenceNumbers.length + 1] = [];
2785
+ const role = sortableRoles[fromSeq].splice(fromIndex - 1, 1)[0];
2786
+ sortableRoles[toSeq].splice(toIndex - 1, 0, role);
2787
+ const renumberRequests = [];
2788
+ Object.entries(sortableRoles).forEach(([targetSeq, roles]) => {
2789
+ roles.forEach((role, index) => {
2790
+ console.log('Evaluating role', role.name, role.sequence, role.order);
2791
+ const targetOrder = +index + 1;
2792
+ if (role.sequence !== +targetSeq || role.order !== targetOrder) {
2793
+ role.sequence = +targetSeq;
2794
+ role.order = targetOrder;
2795
+ renumberRequests.push(updateTemplateRole(this.endpoint, this.templateId, role.name, { sequence: +targetSeq, order: targetOrder })
2796
+ .then(r => console.log('[ROLES] Updated role', role.name, r))
2797
+ .catch(e => console.log('[ROLES] Error updating role', e)));
2798
+ }
2799
+ });
2800
+ });
2801
+ // When renumbering, we don't try to update the store for every individual item
2802
+ // changing. We just do it once at the end.
2803
+ console.log(`[ROLES] Awaiting ${renumberRequests.length} renumber requests`, renumberRequests);
2804
+ return Promise.all(renumberRequests).then(async () => {
2805
+ const newTemplate = JSON.parse(JSON.stringify(this.template));
2806
+ newTemplate.roles = Object.keys(sortableRoles).reduce((acc, seq) => acc.concat(sortableRoles[seq]), []);
2807
+ await Store.getTemplate(this.endpoint, this.templateId, true);
2808
+ // Store.updateTemplate(this.templateId, newTemplate);
2809
+ });
2810
+ }
2811
+ handleCancel() {
2812
+ var _a;
2813
+ (_a = this.exit) === null || _a === void 0 ? void 0 : _a.emit();
2814
+ }
2815
+ handleSubmit() {
2816
+ var _a;
2817
+ (_a = this.next) === null || _a === void 0 ? void 0 : _a.emit();
2818
+ }
2819
+ getSortedRoles() {
2820
+ var _a;
2821
+ // NOTE: This mutates the source array but that's OK because everything that touches
2822
+ // it will want the same thing done.
2823
+ return (((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || []).sort((a, b) => {
2824
+ return a.sequence === b.sequence ? a.order - b.order : a.sequence - b.sequence;
2825
+ });
2826
+ }
2827
+ getSequenceNumbers() {
2828
+ var _a;
2829
+ const sequenceNumbers = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || []).map(role => role.sequence);
2830
+ const deduped = [...new Set(sequenceNumbers)];
2831
+ deduped.sort((a, b) => a - b);
2832
+ return deduped;
2833
+ }
2834
+ getRoleNames() {
2835
+ const roles = this.getSortedRoles();
2836
+ return roles.map(role => role.name);
2837
+ }
2838
+ getRolesAtSequence(sequence) {
2839
+ var _a;
2840
+ // Entries can be undefined when deleted because Stencil has no remove() operator yet for stores.
2841
+ // See https://github.com/ionic-team/stencil-store/issues/23
2842
+ return (((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || []).filter(role => role && role.sequence === sequence);
2843
+ }
2844
+ // When the user drags a role around, we handle placement "between" items by assigning it a half-order number
2845
+ // e.g. 1.5 to place it between items 1 and 2, 0.5 to place it at the beginning, or last+0.5 to place it at the end.
2846
+ // Then we re-sort the list of roles and renumber them.
2847
+ async renumberTemplateRoles() {
2848
+ const sortableRoles = {};
2849
+ const renumberRequests = [];
2850
+ const sequenceNumbers = this.getSequenceNumbers();
2851
+ console.log('Sorting sequences', sequenceNumbers);
2852
+ sequenceNumbers.forEach(targetSeq => {
2853
+ sortableRoles[targetSeq].forEach((role, targetOrderMinusOne) => {
2854
+ const targetOrder = +targetOrderMinusOne + 1;
2855
+ if (role.sequence !== +targetSeq || role.order !== targetOrder) {
2856
+ console.log('[ROLES] Updating role', role.name, 'from', role.sequence, role.order, 'to', targetSeq, targetOrder);
2857
+ role.sequence = +targetSeq;
2858
+ role.order = targetOrder;
2859
+ renumberRequests.push(updateTemplateRole(this.endpoint, this.templateId, role.name, { sequence: +targetSeq, order: targetOrder })
2860
+ .then(r => console.log('[ROLES] Updated role', role.name, r))
2861
+ .catch(e => console.log('[ROLES] Error updating role', e)));
2862
+ }
2863
+ });
2864
+ });
2865
+ console.log('Sortable Roles', sortableRoles);
2866
+ console.log(`[ROLES] Awaiting ${renumberRequests.length} renumber requests`);
2867
+ return Promise.all(renumberRequests).then(async () => {
2868
+ // When renumbering, we don't try to update the store for every individual item
2869
+ // changing. We just do it once at the end.
2870
+ const newTemplate = JSON.parse(JSON.stringify(this.template));
2871
+ newTemplate.roles = Object.keys(sortableRoles).reduce((acc, seq) => acc.concat(sortableRoles[seq]), []);
2872
+ console.log('[ROLES] Done renumbering', newTemplate.roles.map(r => ({ name: r.name, sequence: r.sequence, order: r.order })));
2873
+ Store.updateTemplate(this.templateId, newTemplate);
2874
+ // TODO: Explore race condition in reordering roles
2875
+ // this.template = await Store.getTemplate(this.endpoint, this.templateId, true);
2876
+ });
2877
+ // // Avoid dupe renumber attempts
2878
+ // const renumbered = [];
2879
+ //
2880
+ // // If the user dragged an entry from below a row to above it, we end up here like [1,0]. Make sure it's [0,1] for the next operation.
2881
+ // const renumberRequests = [];
2882
+ // this.getSequenceNumbers().forEach((originalSequence, newSequenceIndex) => {
2883
+ // this.getRolesAtSequence(originalSequence).forEach((role, newOrderIndex) => {
2884
+ // if (!renumbered.includes(role.name)) {
2885
+ // if (role.sequence !== newSequenceIndex + 1 || role.order !== newOrderIndex + 1) {
2886
+ // role.sequence = newSequenceIndex + 1;
2887
+ // role.order = newOrderIndex + 1;
2888
+ // renumbered.push(role.name);
2889
+ // // console.log('[ROLES] Renumbering', role.name, targetSequence, targetOrder);
2890
+ // renumberRequests.push(updateTemplateRole(this.endpoint, this.templateId, role.name, {sequence: role.sequence, order: role.order}));
2891
+ // }
2892
+ // }
2893
+ // });
2894
+ // });
2895
+ //
2896
+ // if (renumberRequests.length > 0) {
2897
+ // console.log(`[ROLES] Submitting ${renumberRequests.length} renumber requests`);
2898
+ // return Promise.all(renumberRequests).then(async () => {
2899
+ // // When renumbering, we don't try to update the store for every individual item
2900
+ // // changing. We just do it once at the end.
2901
+ // this.template = await Store.getTemplate(this.endpoint, this.templateId, true);
2902
+ // });
2903
+ // }
2904
+ //
2905
+ // return true;
2906
+ }
2907
+ // Look for name conflicts, because they're UGC and can be anything, regardless of order.
2908
+ getNextRoleName() {
2909
+ var _a, _b;
2910
+ let name = '';
2911
+ let nextNumber = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || []).length;
2912
+ do {
2913
+ nextNumber++;
2914
+ name = `Recipient ${nextNumber}`;
2915
+ } while (!name || (((_b = this.template) === null || _b === void 0 ? void 0 : _b.roles) || []).some(role => role && role.name === name));
2916
+ return name;
2917
+ }
2918
+ callCreateRole(name, sequence, order) {
2919
+ console.log('[ROLES] Will create role', { name, sequence, order });
2920
+ createTemplateRole(this.endpoint, this.templateId, {
2921
+ template_id: this.templateId,
2922
+ name,
2923
+ sequence,
2924
+ message: '',
2925
+ order,
2926
+ full_name: null,
2927
+ first_name: '',
2928
+ last_name: '',
2929
+ email: '',
2930
+ phone: '',
2931
+ type: 'signer',
2932
+ delegator: false,
2933
+ kba_method: null,
2934
+ })
2935
+ .then(async (role) => {
2936
+ var _a;
2937
+ console.log('[ROLES] Created role', role);
2938
+ const newTemplate = JSON.parse(JSON.stringify(this.template));
2939
+ newTemplate.roles.push(role);
2940
+ // TODO: Verify this immediately triggers a self-update
2941
+ console.log('Updating template in data store');
2942
+ Store.updateTemplate(this.templateId, newTemplate);
2943
+ // This will re-sort the roles and renumbers them via server calls if necessary
2944
+ await this.renumberTemplateRoles();
2945
+ (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
2946
+ })
2947
+ .catch(e => {
2948
+ console.log('[ROLES] Error creating role', e);
2949
+ });
2950
+ }
2951
+ handleAddRole(e, sequence) {
2952
+ e.stopPropagation();
2953
+ const order = this.getRolesAtSequence(sequence).length + 1;
2954
+ const name = this.getNextRoleName();
2955
+ this.callCreateRole(name, sequence, order);
2956
+ }
2957
+ handleAddStep(e, sequence) {
2958
+ e.stopPropagation();
2959
+ const order = 1;
2960
+ const name = this.getNextRoleName();
2961
+ this.callCreateRole(name, sequence, order);
2962
+ }
2963
+ render() {
2964
+ if (!this.endpoint.session) {
2965
+ return (h(Host, null, h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
2966
+ }
2967
+ if (this.loading || !this.template) {
2968
+ return (h(Host, { class: "loading" }, h("verdocs-loader", null)));
2969
+ }
2970
+ console.log('[ROLES] Rendering', this.template.roles.map(r => ({ name: r.name, sequence: r.sequence, order: r.order })));
2971
+ const roleNames = this.getRoleNames();
2972
+ const sequences = this.getSequenceNumbers();
2973
+ console.log('Rendering sequences', sequences, roleNames);
2974
+ // style={{backgroundColor: getRGBA(getRoleIndex(this.template, role.name))}}
2975
+ return (h(Host, { class: { dragging: this.dragging } }, h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, h("h5", null, "Roles and Workflow"), h("div", { class: "roles" }, sequences.map(sequence => (h("div", { class: "sequence" }, h("div", { class: "sequence-label no-drag" }, sequence, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequence}`, "data-sequence": sequence }, this.getRolesAtSequence(sequence).map(role => {
2976
+ const unknown = !role.email;
2977
+ return unknown ? (h("div", { class: "role", "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, h("div", { class: "role-name" }, role.name), h("div", { class: "icons" }, h("div", { class: "gear-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" }), h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover })))) : (h("div", { class: "role", "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, h("div", { class: "role-name" }, formatFullName(role)), h("div", { class: "icons" }, h("div", { class: "gear-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" }), h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }))));
2978
+ })), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) })))), h("div", { class: "sequence add-sequence" }, h("div", { class: "sequence-label no-drag" }, sequences.length + 1, "."), h("div", { class: "sequence-roles", id: `verdocs-roles-sequence-${sequences.length + 1}`, "data-sequence": sequences.length + 1 }, h("div", { class: "role-name add-step-label" }, "Add Step.")), h("button", { class: "add-role no-drag", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequences.length + 1) }))), roleNames.length < 1 && (h("div", { class: "empty" }, "You must add at least one Role before proceeding.", h("br", null), " Click the ", h("span", { innerHTML: plusIcon }), " Add button above to get started.")), h("div", { class: "buttons" }, h("div", { class: "flex-fill" }), h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (h("verdocs-menu-panel", { onClose: () => (this.showingRoleDialog = null) }, h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
2979
+ var _a;
2980
+ (_a = document.getElementById('verdocs-menu-panel-overlay')) === null || _a === void 0 ? void 0 : _a.remove();
2981
+ this.showingRoleDialog = null;
2982
+ }, onDelete: async () => {
2983
+ var _a;
2984
+ this.showingRoleDialog = null;
2985
+ // This will re-sort the roles and renumbers them via server calls if necessary
2986
+ await this.renumberTemplateRoles();
2987
+ (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'deleted', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
2988
+ } })))));
2989
+ }
2990
+ get el() { return this; }
2991
+ static get style() { return VerdocsTemplateRolesStyle0; }
2992
+ }, [0, "verdocs-template-roles", {
2993
+ "endpoint": [16],
2994
+ "templateId": [1, "template-id"],
2995
+ "showingRoleDialog": [32],
2996
+ "sender": [32],
2997
+ "dragging": [32],
2998
+ "loading": [32],
2999
+ "template": [32]
3000
+ }]);
3001
+ function defineCustomElement() {
3002
+ if (typeof customElements === "undefined") {
3003
+ return;
3004
+ }
3005
+ const components = ["verdocs-template-roles", "verdocs-button", "verdocs-component-error", "verdocs-help-icon", "verdocs-loader", "verdocs-menu-panel", "verdocs-select-input", "verdocs-template-role-properties", "verdocs-text-input"];
3006
+ components.forEach(tagName => { switch (tagName) {
3007
+ case "verdocs-template-roles":
3008
+ if (!customElements.get(tagName)) {
3009
+ customElements.define(tagName, VerdocsTemplateRoles);
3010
+ }
3011
+ break;
3012
+ case "verdocs-button":
3013
+ if (!customElements.get(tagName)) {
3014
+ defineCustomElement$8();
3015
+ }
3016
+ break;
3017
+ case "verdocs-component-error":
3018
+ if (!customElements.get(tagName)) {
3019
+ defineCustomElement$7();
3020
+ }
3021
+ break;
3022
+ case "verdocs-help-icon":
3023
+ if (!customElements.get(tagName)) {
3024
+ defineCustomElement$6();
3025
+ }
3026
+ break;
3027
+ case "verdocs-loader":
3028
+ if (!customElements.get(tagName)) {
3029
+ defineCustomElement$5();
3030
+ }
3031
+ break;
3032
+ case "verdocs-menu-panel":
3033
+ if (!customElements.get(tagName)) {
3034
+ defineCustomElement$4();
3035
+ }
3036
+ break;
3037
+ case "verdocs-select-input":
3038
+ if (!customElements.get(tagName)) {
3039
+ defineCustomElement$3();
3040
+ }
3041
+ break;
3042
+ case "verdocs-template-role-properties":
3043
+ if (!customElements.get(tagName)) {
3044
+ defineCustomElement$2();
3045
+ }
3046
+ break;
3047
+ case "verdocs-text-input":
3048
+ if (!customElements.get(tagName)) {
3049
+ defineCustomElement$1();
3050
+ }
3051
+ break;
3052
+ } });
3053
+ }
3054
+
3055
+ export { VerdocsTemplateRoles as V, defineCustomElement as d };