@justifi/webcomponents 4.19.1-rc → 4.19.1-rc-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 (224) hide show
  1. package/dist/cjs/{Analytics-0b3db49d.js → Analytics-985bc298.js} +2 -3
  2. package/dist/cjs/{business.service-c384784d.js → business.service-6bb7ac82.js} +5 -6
  3. package/dist/cjs/{get-payout-csv-51a02be7.js → get-payout-csv-1391ff3e.js} +3 -4
  4. package/dist/cjs/justifi-additional-questions-form-step_10.cjs.entry.js +7 -8
  5. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +4 -5
  6. package/dist/cjs/justifi-business-details.cjs.entry.js +3 -4
  7. package/dist/cjs/justifi-business-form.cjs.entry.js +4 -5
  8. package/dist/cjs/justifi-card-form.cjs.entry.js +4 -5
  9. package/dist/cjs/justifi-checkout-core.cjs.entry.js +3 -3
  10. package/dist/cjs/justifi-checkout.cjs.entry.js +4 -5
  11. package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +3 -4
  12. package/dist/cjs/justifi-new-payment-method_4.cjs.entry.js +11 -9
  13. package/dist/cjs/justifi-owner-form_3.cjs.entry.js +1 -2
  14. package/dist/cjs/justifi-payment-details.cjs.entry.js +3 -4
  15. package/dist/cjs/justifi-payment-form.cjs.entry.js +5 -6
  16. package/dist/cjs/justifi-payment-method-form.cjs.entry.js +1 -1
  17. package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +5 -6
  18. package/dist/cjs/justifi-payments-list.cjs.entry.js +3 -4
  19. package/dist/cjs/justifi-payout-details.cjs.entry.js +3 -4
  20. package/dist/cjs/justifi-payouts-list.cjs.entry.js +3 -4
  21. package/dist/cjs/justifi-refund-form.cjs.entry.js +2 -3
  22. package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +4 -5
  23. package/dist/cjs/{package-39dc73ed.js → package-cbc08fe3.js} +2 -4
  24. package/dist/cjs/{payment.service-2dbfb83d.js → payment.service-dfcfa19b.js} +2 -3
  25. package/dist/collection/api/services/analytics.service.js +1 -2
  26. package/dist/collection/api/services/business.service.js +5 -6
  27. package/dist/collection/api/services/checkout.service.js +2 -3
  28. package/dist/collection/api/services/insurance.service.js +2 -3
  29. package/dist/collection/api/services/payment.service.js +2 -3
  30. package/dist/collection/api/services/payout.service.js +3 -4
  31. package/dist/collection/api/services/provision.service.js +2 -4
  32. package/dist/collection/api/services/reports.service.js +1 -2
  33. package/dist/collection/components/bank-account-form/bank-account-form.js +3 -4
  34. package/dist/collection/components/business-forms/business-form/business-form.js +2 -3
  35. package/dist/collection/components/business-forms/payment-provisioning/bank-account/business-bank-account-form-step.js +2 -3
  36. package/dist/collection/components/business-forms/payment-provisioning/document-uploads/business-document-upload-form-step.js +2 -3
  37. package/dist/collection/components/business-forms/payment-provisioning/terms-and-conditions/business-terms-conditions-form-step.js +2 -3
  38. package/dist/collection/components/card-form/card-form.js +3 -4
  39. package/dist/collection/components/checkout/checkout-core.js +4 -4
  40. package/dist/collection/components/checkout/new-payment-method.js +6 -4
  41. package/dist/collection/components/checkout/payment-method-options.js +3 -4
  42. package/dist/collection/components/checkout/saved-payment-method.js +3 -4
  43. package/dist/collection/components/checkout/sezzle-payment-method.js +3 -4
  44. package/dist/collection/components/payment-form/payment-form.js +3 -4
  45. package/dist/collection/components/refund-form/refund-form.js +2 -3
  46. package/dist/docs.json +8 -8
  47. package/dist/esm/{Analytics-37556050.js → Analytics-79e20e2d.js} +2 -3
  48. package/dist/esm/{business.service-eee46ab1.js → business.service-f45decfc.js} +5 -6
  49. package/dist/esm/{get-payout-csv-4d6b29d8.js → get-payout-csv-e784a2ab.js} +3 -4
  50. package/dist/esm/justifi-additional-questions-form-step_10.entry.js +7 -8
  51. package/dist/esm/justifi-bank-account-form.entry.js +4 -5
  52. package/dist/esm/justifi-business-details.entry.js +3 -4
  53. package/dist/esm/justifi-business-form.entry.js +4 -5
  54. package/dist/esm/justifi-card-form.entry.js +4 -5
  55. package/dist/esm/justifi-checkout-core.entry.js +3 -3
  56. package/dist/esm/justifi-checkout.entry.js +4 -5
  57. package/dist/esm/justifi-gross-payment-chart.entry.js +3 -4
  58. package/dist/esm/justifi-new-payment-method_4.entry.js +11 -9
  59. package/dist/esm/justifi-owner-form_3.entry.js +1 -2
  60. package/dist/esm/justifi-payment-details.entry.js +3 -4
  61. package/dist/esm/justifi-payment-form.entry.js +5 -6
  62. package/dist/esm/justifi-payment-method-form.entry.js +1 -1
  63. package/dist/esm/justifi-payment-provisioning.entry.js +5 -6
  64. package/dist/esm/justifi-payments-list.entry.js +3 -4
  65. package/dist/esm/justifi-payout-details.entry.js +3 -4
  66. package/dist/esm/justifi-payouts-list.entry.js +3 -4
  67. package/dist/esm/justifi-refund-form.entry.js +2 -3
  68. package/dist/esm/justifi-season-interruption-insurance.entry.js +4 -5
  69. package/dist/esm/{package-e2a7aa3f.js → package-cf64a48c.js} +2 -4
  70. package/dist/esm/{payment.service-9005a501.js → payment.service-dad5153b.js} +2 -3
  71. package/dist/globals.d.ts +2 -0
  72. package/dist/module/Analytics.js +1 -2
  73. package/dist/module/business-bank-account-form-step.js +2 -3
  74. package/dist/module/business-document-upload-form-step.js +2 -3
  75. package/dist/module/business-terms-conditions-form-step.js +2 -3
  76. package/dist/module/business.service.js +5 -6
  77. package/dist/module/checkout-core.js +3 -3
  78. package/dist/module/get-payout-csv.js +3 -4
  79. package/dist/module/justifi-bank-account-form.js +2 -3
  80. package/dist/module/justifi-business-form.js +2 -3
  81. package/dist/module/justifi-card-form.js +2 -3
  82. package/dist/module/justifi-checkout.js +2 -3
  83. package/dist/module/justifi-gross-payment-chart.js +1 -2
  84. package/dist/module/justifi-payment-form.js +3 -4
  85. package/dist/module/justifi-payment-provisioning.js +2 -3
  86. package/dist/module/justifi-refund-form.js +2 -3
  87. package/dist/module/justifi-season-interruption-insurance.js +2 -3
  88. package/dist/module/new-payment-method.js +5 -3
  89. package/dist/module/package.js +2 -4
  90. package/dist/module/payment-method-options.js +2 -3
  91. package/dist/module/payment.service.js +2 -3
  92. package/dist/module/saved-payment-method.js +2 -3
  93. package/dist/module/sezzle-payment-method.js +2 -3
  94. package/dist/types/components/checkout/new-payment-method.d.ts +1 -0
  95. package/dist/webcomponents/index.esm.js +1 -0
  96. package/dist/webcomponents/p-01a404ca.entry.js +44 -0
  97. package/dist/webcomponents/p-02c58e00.entry.js +97 -0
  98. package/dist/webcomponents/p-03d35880.entry.js +130 -0
  99. package/dist/webcomponents/p-05f46d63.entry.js +99 -0
  100. package/dist/webcomponents/p-06ff0429.entry.js +65 -0
  101. package/dist/webcomponents/p-08b0fb31.js +41 -1
  102. package/dist/webcomponents/p-14c91ffd.js +20 -1
  103. package/dist/webcomponents/p-1ad5995e.js +3599 -1
  104. package/dist/webcomponents/p-1ff8810b.js +29 -1
  105. package/dist/webcomponents/p-2338affa.js +213 -1
  106. package/dist/webcomponents/p-258b1ee2.entry.js +149 -0
  107. package/dist/webcomponents/p-25d8cd65.entry.js +102 -0
  108. package/dist/webcomponents/p-29c0b182.js +114 -1
  109. package/dist/webcomponents/p-2b6c9c4f.js +7 -1
  110. package/dist/webcomponents/p-2eab3c90.js +3052 -1
  111. package/dist/webcomponents/p-3e9ef4a8.js +28 -0
  112. package/dist/webcomponents/p-3fd13ca3.js +52 -1
  113. package/dist/webcomponents/p-492588bf.js +79 -0
  114. package/dist/webcomponents/p-525db3e8.js +22 -1
  115. package/dist/webcomponents/p-5482d030.entry.js +21 -0
  116. package/dist/webcomponents/p-56f6ce4c.js +10 -1
  117. package/dist/webcomponents/p-576826b1.entry.js +43 -0
  118. package/dist/webcomponents/p-5968ff8a.js +178 -1
  119. package/dist/webcomponents/p-5cb3f0b2.entry.js +261 -0
  120. package/dist/webcomponents/p-5f835b89.entry.js +606 -0
  121. package/dist/webcomponents/p-6053809a.entry.js +80 -0
  122. package/dist/webcomponents/p-6078a370.js +244 -1
  123. package/dist/webcomponents/p-66e4869f.entry.js +75 -0
  124. package/dist/webcomponents/p-6f1c56d4.entry.js +94 -0
  125. package/dist/webcomponents/p-70a2aa74.entry.js +76 -0
  126. package/dist/webcomponents/p-7582b554.entry.js +18 -0
  127. package/dist/webcomponents/p-79646550.entry.js +61 -0
  128. package/dist/webcomponents/p-7a70ff09.entry.js +133 -0
  129. package/dist/webcomponents/p-7bbf73bd.entry.js +117 -0
  130. package/dist/webcomponents/p-7d85af5c.js +16 -1
  131. package/dist/webcomponents/p-800d31fe.entry.js +162 -0
  132. package/dist/webcomponents/p-8115b2f4.js +28 -1
  133. package/dist/webcomponents/p-83125497.js +4027 -1
  134. package/dist/webcomponents/p-85fc69e5.js +90 -1
  135. package/dist/webcomponents/p-890088fc.entry.js +298 -0
  136. package/dist/webcomponents/p-89887332.js +301 -1
  137. package/dist/webcomponents/p-8df7bde8.js +27 -1
  138. package/dist/webcomponents/p-8eb774df.entry.js +54 -0
  139. package/dist/webcomponents/p-9282eab8.js +77 -0
  140. package/dist/webcomponents/p-96c12fef.entry.js +73 -0
  141. package/dist/webcomponents/p-9c9c7dac.js +24 -1
  142. package/dist/webcomponents/p-9f94bbb6.entry.js +118 -0
  143. package/dist/webcomponents/p-9fd108be.entry.js +74 -0
  144. package/dist/webcomponents/p-a5a225d9.entry.js +125 -0
  145. package/dist/webcomponents/p-a5c5821e.entry.js +101 -0
  146. package/dist/webcomponents/p-a5fb51dc.entry.js +131 -0
  147. package/dist/webcomponents/p-a6d04afc.js +44 -0
  148. package/dist/webcomponents/p-ac086069.entry.js +58 -0
  149. package/dist/webcomponents/p-acbac8b8.entry.js +131 -0
  150. package/dist/webcomponents/p-adc30a61.entry.js +145 -0
  151. package/dist/webcomponents/p-af244664.js +126 -1
  152. package/dist/webcomponents/p-b6e3d7ed.entry.js +94 -0
  153. package/dist/webcomponents/p-b82c146f.entry.js +111 -0
  154. package/dist/webcomponents/p-ba4bae6f.js +12 -1
  155. package/dist/webcomponents/p-ba5fae28.js +90 -1
  156. package/dist/webcomponents/p-c636f563.entry.js +791 -0
  157. package/dist/webcomponents/p-cb26f708.js +18 -0
  158. package/dist/webcomponents/p-d17aee2b.entry.js +26 -0
  159. package/dist/webcomponents/p-d89bad72.js +39 -1
  160. package/dist/webcomponents/p-dce846bf.js +27 -1
  161. package/dist/webcomponents/p-df21aaad.js +120 -1
  162. package/dist/webcomponents/p-e1255160.js +3 -1
  163. package/dist/webcomponents/p-e333620e.js +34 -1
  164. package/dist/webcomponents/p-e356f280.entry.js +29 -0
  165. package/dist/webcomponents/p-e3e5f95f.entry.js +98 -0
  166. package/dist/webcomponents/p-e3fab0e2.js +43 -1
  167. package/dist/webcomponents/p-eb5dbd23.entry.js +1684 -0
  168. package/dist/webcomponents/p-ec854a3e.entry.js +11053 -0
  169. package/dist/webcomponents/p-f02b75dc.entry.js +96 -0
  170. package/dist/webcomponents/p-fad19d75.js +1638 -2
  171. package/dist/webcomponents/webcomponents.css +362 -4
  172. package/dist/webcomponents/webcomponents.esm.js +20 -1
  173. package/package.json +2 -4
  174. package/dist/cjs/config-037e67d0.js +0 -15
  175. package/dist/config.js +0 -11
  176. package/dist/esm/config-58e393e2.js +0 -13
  177. package/dist/module/config.js +0 -13
  178. package/dist/types/home/runner/work/web-component-library/web-component-library/packages/webcomponents/.stencil/packages/webcomponents/config.d.ts +0 -11
  179. package/dist/webcomponents/p-023779ee.entry.js +0 -1
  180. package/dist/webcomponents/p-037763f4.entry.js +0 -1
  181. package/dist/webcomponents/p-07109641.entry.js +0 -1
  182. package/dist/webcomponents/p-0f7b9555.entry.js +0 -1
  183. package/dist/webcomponents/p-17e4246f.entry.js +0 -1
  184. package/dist/webcomponents/p-1a43e355.entry.js +0 -19
  185. package/dist/webcomponents/p-1f6afff9.entry.js +0 -1
  186. package/dist/webcomponents/p-246a6c6a.entry.js +0 -1
  187. package/dist/webcomponents/p-2d3b1692.entry.js +0 -1
  188. package/dist/webcomponents/p-30a493cd.entry.js +0 -1
  189. package/dist/webcomponents/p-32286934.js +0 -1
  190. package/dist/webcomponents/p-3f5e7e86.js +0 -1
  191. package/dist/webcomponents/p-462dc522.entry.js +0 -1
  192. package/dist/webcomponents/p-487b72a8.entry.js +0 -1
  193. package/dist/webcomponents/p-4abc17f0.entry.js +0 -1
  194. package/dist/webcomponents/p-52021fa1.entry.js +0 -1
  195. package/dist/webcomponents/p-53e64f15.entry.js +0 -1
  196. package/dist/webcomponents/p-57e1f2fd.js +0 -1
  197. package/dist/webcomponents/p-5f095525.entry.js +0 -1
  198. package/dist/webcomponents/p-62b32c4c.entry.js +0 -1
  199. package/dist/webcomponents/p-69faef3f.entry.js +0 -1
  200. package/dist/webcomponents/p-6c078cd1.js +0 -1
  201. package/dist/webcomponents/p-8e541a32.entry.js +0 -1
  202. package/dist/webcomponents/p-8f325782.entry.js +0 -1
  203. package/dist/webcomponents/p-987b5de2.entry.js +0 -1
  204. package/dist/webcomponents/p-a63fc384.entry.js +0 -1
  205. package/dist/webcomponents/p-a8220709.entry.js +0 -1
  206. package/dist/webcomponents/p-ae530971.entry.js +0 -1
  207. package/dist/webcomponents/p-b7cf49f4.entry.js +0 -1
  208. package/dist/webcomponents/p-b87b27ba.js +0 -1
  209. package/dist/webcomponents/p-bbed6107.entry.js +0 -1
  210. package/dist/webcomponents/p-be39c802.entry.js +0 -1
  211. package/dist/webcomponents/p-c28db166.js +0 -1
  212. package/dist/webcomponents/p-c9f8f7ec.entry.js +0 -1
  213. package/dist/webcomponents/p-d8355f91.entry.js +0 -1
  214. package/dist/webcomponents/p-e2c88817.entry.js +0 -1
  215. package/dist/webcomponents/p-e31f0f3e.entry.js +0 -1
  216. package/dist/webcomponents/p-edac2b43.entry.js +0 -1
  217. package/dist/webcomponents/p-ef23c091.entry.js +0 -1
  218. package/dist/webcomponents/p-f06910aa.entry.js +0 -1
  219. package/dist/webcomponents/p-f0866375.entry.js +0 -1
  220. package/dist/webcomponents/p-f0a06884.entry.js +0 -1
  221. package/dist/webcomponents/p-f2f94d9f.entry.js +0 -1
  222. package/dist/webcomponents/p-f49b7170.entry.js +0 -1
  223. package/dist/webcomponents/p-fb58feb5.entry.js +0 -1
  224. package/dist/webcomponents/p-fe33151d.entry.js +0 -1
@@ -1 +1,29 @@
1
- import{S as n}from"./p-6078a370.js";function t(t){const o=n.find((n=>n.label===t));return o?o.value:t}function o(n){return/^\d$/.test(n)?"0"+n:n}function r(n,t,r){if(n&&t&&r)return`${n}-${o(t)}-${o(r)}`}function a(n){const t=n.value,[o,r,a]=t.split("-");return{dob_year:o,dob_month:r,dob_day:a}}function u(n){return n.associated_accounts.length>0}export{u as a,r as c,a as d,o as f,t as g}
1
+ import { S as StateOptions } from './p-6078a370.js';
2
+
3
+ function getStateAbbreviation(stateName) {
4
+ const state = StateOptions.find(s => s.label === stateName);
5
+ return state ? state.value : stateName;
6
+ }
7
+ // filterNumber is intended to be used to format a string that contains a single digit to a two digit string.
8
+ function filterNumber(num) {
9
+ if (/^\d$/.test(num)) {
10
+ return '0' + num;
11
+ }
12
+ return num;
13
+ }
14
+ function constructDate(year, month, day) {
15
+ if (!year || !month || !day) {
16
+ return;
17
+ }
18
+ return `${year}-${filterNumber(month)}-${filterNumber(day)}`;
19
+ }
20
+ function deconstructDate(formInput) {
21
+ const dateString = formInput.value;
22
+ const [dob_year, dob_month, dob_day] = dateString.split('-');
23
+ return { dob_year, dob_month, dob_day };
24
+ }
25
+ function checkProvisioningStatus(business) {
26
+ return business.associated_accounts.length > 0;
27
+ }
28
+
29
+ export { checkProvisioningStatus as a, constructDate as c, deconstructDate as d, filterNumber as f, getStateAbbreviation as g };
@@ -1 +1,213 @@
1
- import{a as e,f as t}from"./p-fad19d75.js";const s=e=>!("isConnected"in e)||e.isConnected,n=(()=>{let e;return(...t)=>{e&&clearTimeout(e),e=setTimeout((()=>{e=0,(e=>{for(let t of e.keys())e.set(t,e.get(t).filter(s))})(...t)}),2e3)}})(),o=e=>"function"==typeof e?e():e,r=(s,r)=>{const a=((e,t=((e,t)=>e!==t))=>{const s=o(e);let n=new Map(Object.entries(null!=s?s:{}));const r={dispose:[],get:[],set:[],reset:[]},a=()=>{var t;n=new Map(Object.entries(null!==(t=o(e))&&void 0!==t?t:{})),r.reset.forEach((e=>e()))},c=e=>(r.get.forEach((t=>t(e))),n.get(e)),i=(e,s)=>{const o=n.get(e);t(s,o,e)&&(n.set(e,s),r.set.forEach((t=>t(e,s,o))))},u="undefined"==typeof Proxy?{}:new Proxy(s,{get:(e,t)=>c(t),ownKeys:()=>Array.from(n.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>n.has(t),set:(e,t,s)=>(i(t,s),!0)}),p=(e,t)=>(r[e].push(t),()=>{((e,t)=>{const s=e.indexOf(t);s>=0&&(e[s]=e[e.length-1],e.length--)})(r[e],t)});return{state:u,get:c,set:i,on:p,onChange:(t,s)=>{const n=p("set",((e,n)=>{e===t&&s(n)})),r=p("reset",(()=>s(o(e)[t])));return()=>{n(),r()}},use:(...e)=>{const t=e.reduce(((e,t)=>(t.set&&e.push(p("set",t.set)),t.get&&e.push(p("get",t.get)),t.reset&&e.push(p("reset",t.reset)),t.dispose&&e.push(p("dispose",t.dispose)),e)),[]);return()=>t.forEach((e=>e()))},dispose:()=>{r.dispose.forEach((e=>e())),a()},reset:a,forceUpdate:e=>{const t=n.get(e);r.set.forEach((s=>s(e,t,t)))}}})(s,r);return a.use((()=>{if("function"!=typeof e)return{};const s=new Map;return{dispose:()=>s.clear(),get:t=>{const n=e();n&&((e,t,s)=>{const n=e.get(t);n?n.includes(s)||n.push(s):e.set(t,[s])})(s,t,n)},set:e=>{const o=s.get(e);o&&s.set(e,o.filter(t)),n(s)},reset:()=>{s.forEach((e=>e.forEach(t))),n(s)}}})()),a},a=r({}),{state:c,on:i}=a,u=r({}),{state:p}=u,f=()=>{let e=!0;return Object.keys(c).forEach((t=>{null===c[t]?(p[t]=!0,e=!1):p[t]=!1})),{isValid:e}};export{c as a,p as b,i,f as v}
1
+ import { a as getRenderingRef, f as forceUpdate } from './p-fad19d75.js';
2
+
3
+ const appendToMap = (map, propName, value) => {
4
+ const items = map.get(propName);
5
+ if (!items) {
6
+ map.set(propName, [value]);
7
+ }
8
+ else if (!items.includes(value)) {
9
+ items.push(value);
10
+ }
11
+ };
12
+ const debounce = (fn, ms) => {
13
+ let timeoutId;
14
+ return (...args) => {
15
+ if (timeoutId) {
16
+ clearTimeout(timeoutId);
17
+ }
18
+ timeoutId = setTimeout(() => {
19
+ timeoutId = 0;
20
+ fn(...args);
21
+ }, ms);
22
+ };
23
+ };
24
+
25
+ /**
26
+ * Check if a possible element isConnected.
27
+ * The property might not be there, so we check for it.
28
+ *
29
+ * We want it to return true if isConnected is not a property,
30
+ * otherwise we would remove these elements and would not update.
31
+ *
32
+ * Better leak in Edge than to be useless.
33
+ */
34
+ const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
35
+ const cleanupElements = debounce((map) => {
36
+ for (let key of map.keys()) {
37
+ map.set(key, map.get(key).filter(isConnected));
38
+ }
39
+ }, 2000);
40
+ const stencilSubscription = () => {
41
+ if (typeof getRenderingRef !== 'function') {
42
+ // If we are not in a stencil project, we do nothing.
43
+ // This function is not really exported by @stencil/core.
44
+ return {};
45
+ }
46
+ const elmsToUpdate = new Map();
47
+ return {
48
+ dispose: () => elmsToUpdate.clear(),
49
+ get: (propName) => {
50
+ const elm = getRenderingRef();
51
+ if (elm) {
52
+ appendToMap(elmsToUpdate, propName, elm);
53
+ }
54
+ },
55
+ set: (propName) => {
56
+ const elements = elmsToUpdate.get(propName);
57
+ if (elements) {
58
+ elmsToUpdate.set(propName, elements.filter(forceUpdate));
59
+ }
60
+ cleanupElements(elmsToUpdate);
61
+ },
62
+ reset: () => {
63
+ elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
64
+ cleanupElements(elmsToUpdate);
65
+ },
66
+ };
67
+ };
68
+
69
+ const unwrap = (val) => (typeof val === 'function' ? val() : val);
70
+ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
71
+ const unwrappedState = unwrap(defaultState);
72
+ let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
73
+ const handlers = {
74
+ dispose: [],
75
+ get: [],
76
+ set: [],
77
+ reset: [],
78
+ };
79
+ const reset = () => {
80
+ var _a;
81
+ // When resetting the state, the default state may be a function - unwrap it to invoke it.
82
+ // otherwise, the state won't be properly reset
83
+ states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
84
+ handlers.reset.forEach((cb) => cb());
85
+ };
86
+ const dispose = () => {
87
+ // Call first dispose as resetting the state would
88
+ // cause less updates ;)
89
+ handlers.dispose.forEach((cb) => cb());
90
+ reset();
91
+ };
92
+ const get = (propName) => {
93
+ handlers.get.forEach((cb) => cb(propName));
94
+ return states.get(propName);
95
+ };
96
+ const set = (propName, value) => {
97
+ const oldValue = states.get(propName);
98
+ if (shouldUpdate(value, oldValue, propName)) {
99
+ states.set(propName, value);
100
+ handlers.set.forEach((cb) => cb(propName, value, oldValue));
101
+ }
102
+ };
103
+ const state = (typeof Proxy === 'undefined'
104
+ ? {}
105
+ : new Proxy(unwrappedState, {
106
+ get(_, propName) {
107
+ return get(propName);
108
+ },
109
+ ownKeys(_) {
110
+ return Array.from(states.keys());
111
+ },
112
+ getOwnPropertyDescriptor() {
113
+ return {
114
+ enumerable: true,
115
+ configurable: true,
116
+ };
117
+ },
118
+ has(_, propName) {
119
+ return states.has(propName);
120
+ },
121
+ set(_, propName, value) {
122
+ set(propName, value);
123
+ return true;
124
+ },
125
+ }));
126
+ const on = (eventName, callback) => {
127
+ handlers[eventName].push(callback);
128
+ return () => {
129
+ removeFromArray(handlers[eventName], callback);
130
+ };
131
+ };
132
+ const onChange = (propName, cb) => {
133
+ const unSet = on('set', (key, newValue) => {
134
+ if (key === propName) {
135
+ cb(newValue);
136
+ }
137
+ });
138
+ // We need to unwrap the defaultState because it might be a function.
139
+ // Otherwise we might not be sending the right reset value.
140
+ const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
141
+ return () => {
142
+ unSet();
143
+ unReset();
144
+ };
145
+ };
146
+ const use = (...subscriptions) => {
147
+ const unsubs = subscriptions.reduce((unsubs, subscription) => {
148
+ if (subscription.set) {
149
+ unsubs.push(on('set', subscription.set));
150
+ }
151
+ if (subscription.get) {
152
+ unsubs.push(on('get', subscription.get));
153
+ }
154
+ if (subscription.reset) {
155
+ unsubs.push(on('reset', subscription.reset));
156
+ }
157
+ if (subscription.dispose) {
158
+ unsubs.push(on('dispose', subscription.dispose));
159
+ }
160
+ return unsubs;
161
+ }, []);
162
+ return () => unsubs.forEach((unsub) => unsub());
163
+ };
164
+ const forceUpdate = (key) => {
165
+ const oldValue = states.get(key);
166
+ handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
167
+ };
168
+ return {
169
+ state,
170
+ get,
171
+ set,
172
+ on,
173
+ onChange,
174
+ use,
175
+ dispose,
176
+ reset,
177
+ forceUpdate,
178
+ };
179
+ };
180
+ const removeFromArray = (array, item) => {
181
+ const index = array.indexOf(item);
182
+ if (index >= 0) {
183
+ array[index] = array[array.length - 1];
184
+ array.length--;
185
+ }
186
+ };
187
+
188
+ const createStore = (defaultState, shouldUpdate) => {
189
+ const map = createObservableMap(defaultState, shouldUpdate);
190
+ map.use(stencilSubscription());
191
+ return map;
192
+ };
193
+
194
+ const insuranceValuesStore = createStore({});
195
+ const { state: insuranceValues, on: insuranceValuesOn } = insuranceValuesStore;
196
+ const insuranceErrorsStore = createStore({});
197
+ const { state: insuranceErrors } = insuranceErrorsStore;
198
+ const validateInsuranceValues = () => {
199
+ let valid = true;
200
+ Object.keys(insuranceValues).forEach((key) => {
201
+ const noSelection = insuranceValues[key] === null;
202
+ if (noSelection) {
203
+ insuranceErrors[key] = true;
204
+ valid = false;
205
+ }
206
+ else {
207
+ insuranceErrors[key] = false;
208
+ }
209
+ });
210
+ return { isValid: valid };
211
+ };
212
+
213
+ export { insuranceValues as a, insuranceErrors as b, insuranceValuesOn as i, validateInsuranceValues as v };
@@ -0,0 +1,149 @@
1
+ import { r as registerInstance, c as createEvent, h } from './p-fad19d75.js';
2
+ import { f as formatCurrency } from './p-83125497.js';
3
+ import { C as ComponentErrorSeverity } from './p-14c91ffd.js';
4
+ import { i as insuranceValuesOn, v as validateInsuranceValues, a as insuranceValues } from './p-2338affa.js';
5
+ import { B as Button } from './p-9c9c7dac.js';
6
+ import { S as StyledHost } from './p-ba4bae6f.js';
7
+ import { S as Skeleton } from './p-08b0fb31.js';
8
+
9
+ class Checkout {
10
+ constructor(data) {
11
+ Object.assign(this, data);
12
+ }
13
+ }
14
+
15
+ const checkoutCoreCss = ":host{display:block}justifi-payment-method-form{display:block;margin-left:calc(var(--jfi-layout-padding) * -1);margin-right:calc(var(--jfi-layout-padding) * -1)}.jfi-checkout-core{color:var(--jfi-body-color)}*::part(label){color:var(--jfi-form-label-color);font-family:var(--jfi-form-label-font-family);font-weight:var(--jfi-form-label-font-weight);font-size:var(--jfi-form-label-font-size);margin:var(--jfi-form-label-margin)}*::part(input){font-family:var(--jfi-layout-font-family);background-color:var(--jfi-form-control-background-color);border-color:var(--jfi-form-control-border-color);border-width:var(--jfi-form-control-border-width);border-bottom-width:var(--jfi-form-control-border-bottom-width);border-left-width:var(--jfi-form-control-border-left-width);border-right-width:var(--jfi-form-control-border-right-width);border-top-width:var(--jfi-form-control-border-top-width);border-radius:var(--jfi-form-control-border-radius);border-style:var(--jfi-form-control-border-style);box-shadow:var(--jfi-form-control-box-shadow);color:var(--jfi-form-control-color);font-size:var(--jfi-form-control-font-size);font-weight:var(--jfi-form-control-font-weight);line-height:var(--jfi-form-control-line-height);margin:var(--jfi-form-control-margin);padding:var(--jfi-form-control-padding)}*::part(input):focus{color:var(--jfi-form-control-color-focus);border-color:var(--jfi-form-control-border-color-focus);box-shadow:var(--jfi-form-control-box-shadow-focus)}*::part(input-invalid){border-color:var(--jfi-form-control-border-color-error);box-shadow:var(--jfi-form-control-box-shadow-error)}*::part(input-invalid):focus{border-color:var(--jfi-form-control-border-color-error);box-shadow:var(--jfi-form-control-box-shadow-error-focus)}*::part(invalid-feedback){color:var(--jfi-error-message-color);font-size:var(--jfi-error-message-font-size);margin:var(--jfi-error-message-margin);line-height:normal}.jfi-submit-button{font-family:var(--jfi-layout-font-family);color:var(--jfi-submit-button-color);background-color:var(--jfi-submit-button-background-color);border-color:var(--jfi-submit-button-border-color);padding:var(--jfi-submit-button-padding);font-size:var(--jfi-submit-button-font-size);border-radius:var(--jfi-submit-button-border-radius);width:var(--jfi-submit-button-width);box-shadow:var(--jfi-submit-button-box-shadow);line-height:var(--jfi-submit-button-line-height);text-transform:var(--jfi-submit-button-text-transform)}.jfi-submit-button:hover{color:var(--jfi-submit-button-color-hover);background-color:var(--jfi-submit-button-background-color-hover);border-color:var(--jfi-submit-button-border-color-hover)}.jfi-submit-button:focus{color:var(--jfi-submit-button-color-focus);background-color:var(--jfi-submit-button-background-color-focus);border-color:var(--jfi-submit-button-border-color-focus)}.btn.jfi-submit-button:active{color:var(--jfi-submit-button-color-active);background-color:var(--jfi-submit-button-background-color-active);border-color:var(--jfi-submit-button-border-color-active)}.btn.jfi-submit-button-loading{min-width:75px;color:var(--jfi-submit-button-color-loading);background-color:var(--jfi-submit-button-background-color-loading);border-color:var(--jfi-submit-button-border-color-loading)}.btn.jfi-submit-button-loading .spinner-border{border-top-color:var(--jfi-submit-button-color-loading);border-bottom-color:var(--jfi-submit-button-color-loading);border-left-color:var(--jfi-submit-button-color-loading)}";
16
+ const JustifiCheckoutCoreStyle0 = checkoutCoreCss;
17
+
18
+ const headerCss = ".jfi-header{color:var(--jfi-header-color);border-bottom:var(--jfi-header-border)}";
19
+ const JustifiCheckoutCoreStyle1 = headerCss;
20
+
21
+ const CheckoutCore = class {
22
+ constructor(hostRef) {
23
+ registerInstance(this, hostRef);
24
+ this.submitted = createEvent(this, "submitted", 7);
25
+ this.errorEvent = createEvent(this, "error-event", 7);
26
+ this.loaded = createEvent(this, "loaded", 7);
27
+ this.completeCheckout = async (payment) => {
28
+ this.complete({
29
+ payment,
30
+ onSuccess: this.onSubmitted,
31
+ onError: this.onError,
32
+ });
33
+ };
34
+ this.onSubmitted = (data) => {
35
+ this.submitted.emit(data);
36
+ this.renderState = 'success';
37
+ };
38
+ this.onError = ({ error, code, severity }) => {
39
+ this.serverError = error;
40
+ this.errorEvent.emit({
41
+ errorCode: code,
42
+ message: error,
43
+ severity,
44
+ });
45
+ this.renderState = 'error';
46
+ };
47
+ this.iframeOrigin = undefined;
48
+ this.authToken = undefined;
49
+ this.getCheckout = undefined;
50
+ this.complete = undefined;
51
+ this.checkoutId = undefined;
52
+ this.disableCreditCard = undefined;
53
+ this.disableBankAccount = undefined;
54
+ this.disableBnpl = undefined;
55
+ this.disablePaymentMethodGroup = undefined;
56
+ this.hasLoadedFonts = false;
57
+ this.checkout = undefined;
58
+ this.serverError = undefined;
59
+ this.renderState = 'loading';
60
+ this.creatingNewPaymentMethod = false;
61
+ this.insuranceToggled = false;
62
+ }
63
+ async fillBillingForm(fields) {
64
+ this.paymentMethodOptionsRef.fillBillingForm(fields);
65
+ }
66
+ componentWillLoad() {
67
+ console.log('CheckoutCore: componentWillLoad iframeOrigin', this, this.iframeOrigin);
68
+ if (this.getCheckout) {
69
+ this.fetchData();
70
+ // Refresh the checkout data when insurance is added or removed
71
+ insuranceValuesOn('set', (key) => {
72
+ const value = insuranceValues[key];
73
+ if (value !== undefined) {
74
+ this.insuranceToggled = value;
75
+ this.fetchData();
76
+ }
77
+ });
78
+ }
79
+ }
80
+ fetchData() {
81
+ this.renderState = 'loading';
82
+ this.getCheckout({
83
+ onSuccess: ({ checkout }) => {
84
+ this.checkout = new Checkout(checkout);
85
+ const { status } = this.checkout;
86
+ this.loaded.emit({ checkout_status: status });
87
+ this.renderState = 'success';
88
+ },
89
+ onError: ({ error, code, severity }) => {
90
+ this.serverError = error;
91
+ this.renderState = 'error';
92
+ this.errorEvent.emit({
93
+ errorCode: code,
94
+ message: error,
95
+ severity,
96
+ });
97
+ }
98
+ });
99
+ }
100
+ ;
101
+ async submit(event) {
102
+ var _a;
103
+ event.preventDefault();
104
+ this.renderState = 'loading';
105
+ const insuranceValidation = validateInsuranceValues();
106
+ const payload = await this.paymentMethodOptionsRef.resolvePaymentMethod(insuranceValidation);
107
+ if (payload.validationError) {
108
+ this.renderState = 'error';
109
+ }
110
+ else if (payload.error) {
111
+ this.renderState = 'error';
112
+ this.serverError = payload.error.message;
113
+ this.onError({
114
+ code: payload.error.code,
115
+ error: payload.error.message,
116
+ severity: ComponentErrorSeverity.ERROR,
117
+ });
118
+ }
119
+ else if (payload.token) {
120
+ this.completeCheckout({ payment_mode: 'ecom', payment_token: payload.token });
121
+ }
122
+ else if (((_a = payload.bnpl) === null || _a === void 0 ? void 0 : _a.status) === 'success') {
123
+ this.completeCheckout({ payment_mode: 'bnpl' });
124
+ }
125
+ else {
126
+ this.renderState = 'error';
127
+ }
128
+ }
129
+ get isLoading() {
130
+ return this.renderState === 'loading';
131
+ }
132
+ get isError() {
133
+ return this.renderState === 'error';
134
+ }
135
+ get paymentType() {
136
+ var _a, _b, _c, _d, _e;
137
+ return (h("section", null, h("div", { class: !this.isLoading && 'visually-hidden' }, h(Skeleton, { variant: "rounded", height: "300px" })), h("div", { class: this.isLoading && 'visually-hidden' }, h("justifi-payment-method-options", { ref: (el) => (this.paymentMethodOptionsRef = el), "show-card": !this.disableCreditCard, "show-ach": !this.disableBankAccount, "show-bnpl": !this.disableBnpl, paymentMethodGroupId: (_a = this.checkout) === null || _a === void 0 ? void 0 : _a.payment_method_group_id, "show-saved-payment-methods": !this.disablePaymentMethodGroup, bnpl: (_b = this.checkout) === null || _b === void 0 ? void 0 : _b.bnpl, authToken: this.authToken, "account-id": (_c = this.checkout) === null || _c === void 0 ? void 0 : _c.account_id, savedPaymentMethods: ((_d = this.checkout) === null || _d === void 0 ? void 0 : _d.payment_methods) || [], paymentAmount: (_e = this.checkout) === null || _e === void 0 ? void 0 : _e.payment_amount, insuranceToggled: this.insuranceToggled }))));
138
+ }
139
+ get summary() {
140
+ var _a, _b;
141
+ return (h("section", null, h("div", { class: !this.isLoading && 'visually-hidden' }, h(Skeleton, { height: "24px" })), h("div", { class: this.isLoading && 'visually-hidden' }, h("div", { class: "jfi-payment-description" }, (_a = this.checkout) === null || _a === void 0 ? void 0 : _a.payment_description), h("div", { class: "jfi-payment-total" }, h("span", { class: "jfi-payment-total-label" }, "Total"), "\u00A0", h("span", { class: "jfi-payment-total-amount" }, formatCurrency(+((_b = this.checkout) === null || _b === void 0 ? void 0 : _b.total_amount)))))));
142
+ }
143
+ render() {
144
+ return (h(StyledHost, { key: '991ae6970e426028ace0d1e8327119bc197639b0' }, h("div", { key: '1e57ee21429b494240e644235a2d5815ced99d43', class: "row gy-3 jfi-checkout-core" }, h("div", { key: '70023ce10dea6ff8d5bd8e30c7d474f774682c65', class: "col-12" }, h("h2", { key: '8b09b03c1998e4d60e174fefb3d196e48d50b84a', class: "fs-5 fw-bold pb-3 jfi-header" }, "Summary"), this.summary), h("div", { key: 'e3bbdaaaf010451a31fe9c60bdf81e89bdd142f2', class: "col-12" }, h("slot", { key: '442a01184960f42b5e1f6694798633d3e7219bf5', name: "insurance" })), h("div", { key: '716e26e3dc675e9d72a3a992b1cb212ce48ffb1a', class: "col-12 mt-4" }, h("h2", { key: '762cfc8549b20d16583d0fd8748bde8035042c00', class: "fs-5 fw-bold pb-3 jfi-header" }, "Payment"), h("h3", { key: 'f07d716a87f3e2bd44471f7e93f7af5f5d20440e', class: "fs-6 fw-bold lh-lg" }, "Select payment type"), h("div", { key: '1156291dd748b90d64a08916ffb98c3123132175', class: "d-flex flex-column" }, this.paymentType)), h("div", { key: 'a5bd142a1c72c5abb29338a2cf24c180119d4ea7', class: "col-12" }, h("div", { key: '5a94ed9d54fd3dd24cfe3e34c23ee3c4995eca6d', class: "d-flex justify-content-end" }, h(Button, { key: '7fce3940d8fe562aa7c23e38201b5d2924157288', type: "submit", variant: "primary", onClick: (e) => this.submit(e), disabled: this.isLoading, isLoading: this.isLoading, style: { width: '100%' } }, "Pay"))))));
145
+ }
146
+ };
147
+ CheckoutCore.style = JustifiCheckoutCoreStyle0 + JustifiCheckoutCoreStyle1;
148
+
149
+ export { CheckoutCore as justifi_checkout_core };
@@ -0,0 +1,102 @@
1
+ import { r as registerInstance, c as createEvent, h } from './p-fad19d75.js';
2
+ import { a as BusinessFormClickActions } from './p-d89bad72.js';
3
+ import { a as ComponentErrorCodes, C as ComponentErrorSeverity } from './p-14c91ffd.js';
4
+ import { a as checkProvisioningStatus } from './p-1ff8810b.js';
5
+ import { S as StyledHost } from './p-ba4bae6f.js';
6
+ import './p-6078a370.js';
7
+
8
+ const PaymentProvisioningCore = class {
9
+ constructor(hostRef) {
10
+ registerInstance(this, hostRef);
11
+ this.clickEvent = createEvent(this, "click-event", 7);
12
+ this.errorEvent = createEvent(this, "error-event", 7);
13
+ this.submitted = createEvent(this, "submitted", 7);
14
+ this.setBusinessProvisioned = () => {
15
+ this.getBusiness({
16
+ onSuccess: (response) => {
17
+ this.businessProvisioned = checkProvisioningStatus(response.data);
18
+ if (this.businessProvisioned) {
19
+ this.errorEvent.emit({
20
+ message: 'A request to provision payments for this business has already been submitted.',
21
+ errorCode: ComponentErrorCodes.PROVISIONING_REQUESTED,
22
+ severity: ComponentErrorSeverity.INFO,
23
+ });
24
+ }
25
+ },
26
+ onError: ({ error, code, severity }) => {
27
+ this.errorEvent.emit({
28
+ message: error,
29
+ errorCode: code,
30
+ severity: severity
31
+ });
32
+ }
33
+ });
34
+ };
35
+ this.postProvisioningData = () => {
36
+ this.postProvisioning({
37
+ onSuccess: (response) => {
38
+ this.submitted.emit({ data: { response } });
39
+ },
40
+ onError: ({ error, code, severity }) => {
41
+ this.submitted.emit({ data: { error } });
42
+ this.errorEvent.emit({
43
+ message: error,
44
+ errorCode: code,
45
+ severity: severity
46
+ });
47
+ }
48
+ });
49
+ };
50
+ this.refs = [];
51
+ this.incrementSteps = () => {
52
+ if (this.currentStep < this.totalSteps) {
53
+ return this.currentStep++;
54
+ }
55
+ };
56
+ this.decrementSteps = () => { return this.currentStep--; };
57
+ this.previousStepButtonOnClick = () => {
58
+ this.clickEvent.emit({ name: BusinessFormClickActions.previousStep });
59
+ this.decrementSteps();
60
+ };
61
+ this.nextStepButtonOnClick = (e, clickEventName) => {
62
+ e.preventDefault();
63
+ this.clickEvent.emit({ name: clickEventName });
64
+ const currentStep = this.refs[this.currentStep];
65
+ currentStep.validateAndSubmit({ onSuccess: this.incrementSteps });
66
+ };
67
+ this.loading = false;
68
+ this.businessProvisioned = false;
69
+ this.currentStep = 0;
70
+ this.errorMessage = undefined;
71
+ this.businessId = undefined;
72
+ this.authToken = undefined;
73
+ this.allowOptionalFields = false;
74
+ this.formTitle = undefined;
75
+ this.getBusiness = undefined;
76
+ this.postProvisioning = undefined;
77
+ }
78
+ componentWillLoad() {
79
+ this.getBusiness && this.setBusinessProvisioned();
80
+ this.refs = [this.coreInfoRef, this.legalAddressRef, this.additionalQuestionsRef, this.representativeRef, this.ownersRef, this.bankAccountRef, this.documentUploadRef, this.termsRef];
81
+ }
82
+ get businessEndpoint() {
83
+ return `entities/business/${this.businessId}`;
84
+ }
85
+ get formDisabled() {
86
+ return this.loading || this.businessProvisioned;
87
+ }
88
+ get totalSteps() {
89
+ return this.refs.length - 1;
90
+ }
91
+ get stepCounter() {
92
+ return `${this.currentStep + 1} of ${this.totalSteps + 1}`;
93
+ }
94
+ handleFormLoading(event) {
95
+ this.loading = event.detail;
96
+ }
97
+ render() {
98
+ return (h(StyledHost, { key: '80f2730a6a4e273391888b086c3633a3dec012b8', exportparts: 'label,input,input-invalid' }, h("div", { key: 'b4e7be2fed14b404ee7bcbe42c3c1c54bb78fdb6', class: 'row gap-3' }, h("h1", { key: 'f477beb7934a94a74dfc6b8a9c18cc54a720f70e' }, this.formTitle), h("justifi-payment-provisioning-form-steps", { key: 'e74aa3a01cfe7550f4917d28ccda1aca211d9394', businessId: this.businessId, authToken: this.authToken, refs: this.refs, currentStep: this.currentStep, allowOptionalFields: this.allowOptionalFields, handleFormLoading: this.handleFormLoading, onFormCompleted: () => this.postProvisioningData() }), h("div", { key: '26a585ec4b6b677cb01ac17696269168887f4c76', class: 'd-flex justify-content-between align-items-center' }, h("div", { key: 'ca5ddc176f8c2eb3315620076b401e47f45039bd', class: 'd-flex align-items-center' }, this.stepCounter), h("justifi-payment-provisioning-form-buttons", { key: '8299387bf859b33c829d29d66947c3c053ffa53c', currentStep: this.currentStep, totalSteps: this.totalSteps, formLoading: this.loading, formDisabled: this.formDisabled, previousStepButtonOnClick: this.previousStepButtonOnClick, nextStepButtonOnClick: this.nextStepButtonOnClick })))));
99
+ }
100
+ };
101
+
102
+ export { PaymentProvisioningCore as justifi_payment_provisioning_core };
@@ -1 +1,114 @@
1
- let n;const t=new Uint8Array(16);function r(){if(!n&&(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!n))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(t)}const o=[];for(let n=0;n<256;++n)o.push((n+256).toString(16).slice(1));const e={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(n,t,c){if(e.randomUUID&&!t&&!n)return e.randomUUID();const u=(n=n||{}).random||(n.rng||r)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,t){c=c||0;for(let n=0;n<16;++n)t[c+n]=u[n];return t}return function(n,t=0){return o[n[t+0]]+o[n[t+1]]+o[n[t+2]]+o[n[t+3]]+"-"+o[n[t+4]]+o[n[t+5]]+"-"+o[n[t+6]]+o[n[t+7]]+"-"+o[n[t+8]]+o[n[t+9]]+"-"+o[n[t+10]]+o[n[t+11]]+o[n[t+12]]+o[n[t+13]]+o[n[t+14]]+o[n[t+15]]}(u)}const u=({authToken:n,apiOrigin:t})=>{async function r(){return n?{Authorization:`Bearer ${n}`,"Idempotency-Key":c(),"Content-Type":"application/json"}:{"Content-Type":"application/json"}}async function o(n,o,e,c,u){const i=`${t}/v1/${n}`,a=e?`${i}?${new URLSearchParams(e)}`:i,p=await fetch(a,{method:o,headers:await r(),body:c,signal:u});if(p)return 204===p.status?{}:p.json();!function(n){console.error(`Error fetching from ${n}`)}(a)}return{get:async function(n,t,r){return o(n,"GET",t,null,r)},post:async function(n,t,r,e){return o(n,"POST",r,t,e)},put:async function(n,t,r,e){return o(n,"PUT",r,t,e)},patch:async function(n,t,r,e){return o(n,"PATCH",r,t,e)},destroy:async function(n,t,r){return o(n,"DELETE",t,null,r)}}};export{u as A}
1
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
2
+ // require the crypto API and do not support built-in fallback to lower quality random number
3
+ // generators (like Math.random()).
4
+ let getRandomValues;
5
+ const rnds8 = new Uint8Array(16);
6
+ function rng() {
7
+ // lazy load so that environments that need to polyfill have a chance to do so
8
+ if (!getRandomValues) {
9
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
10
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
11
+
12
+ if (!getRandomValues) {
13
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
14
+ }
15
+ }
16
+
17
+ return getRandomValues(rnds8);
18
+ }
19
+
20
+ /**
21
+ * Convert array of 16 byte values to UUID string format of the form:
22
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
23
+ */
24
+
25
+ const byteToHex = [];
26
+
27
+ for (let i = 0; i < 256; ++i) {
28
+ byteToHex.push((i + 0x100).toString(16).slice(1));
29
+ }
30
+
31
+ function unsafeStringify(arr, offset = 0) {
32
+ // Note: Be careful editing this code! It's been tuned for performance
33
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
34
+ return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
35
+ }
36
+
37
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
38
+ const native = {
39
+ randomUUID
40
+ };
41
+
42
+ function v4(options, buf, offset) {
43
+ if (native.randomUUID && !buf && !options) {
44
+ return native.randomUUID();
45
+ }
46
+
47
+ options = options || {};
48
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
49
+
50
+ rnds[6] = rnds[6] & 0x0f | 0x40;
51
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
52
+
53
+ if (buf) {
54
+ offset = offset || 0;
55
+
56
+ for (let i = 0; i < 16; ++i) {
57
+ buf[offset + i] = rnds[i];
58
+ }
59
+
60
+ return buf;
61
+ }
62
+
63
+ return unsafeStringify(rnds);
64
+ }
65
+
66
+ const Api = ({ authToken, apiOrigin }) => {
67
+ async function getAuthorizationHeader() {
68
+ if (!authToken) {
69
+ return {
70
+ 'Content-Type': 'application/json',
71
+ };
72
+ }
73
+ return {
74
+ Authorization: `Bearer ${authToken}`,
75
+ 'Idempotency-Key': v4(),
76
+ 'Content-Type': 'application/json',
77
+ };
78
+ }
79
+ async function makeRequest(endpoint, method, params, body, signal) {
80
+ const url = `${apiOrigin}/v1/${endpoint}`;
81
+ const requestUrl = params ? `${url}?${new URLSearchParams(params)}` : url;
82
+ const response = await fetch(requestUrl, {
83
+ method: method,
84
+ headers: await getAuthorizationHeader(),
85
+ body: body,
86
+ signal: signal,
87
+ });
88
+ if (response) {
89
+ return response.status === 204 ? {} : response.json();
90
+ }
91
+ handleError(requestUrl);
92
+ }
93
+ async function get(endpoint, params, signal) {
94
+ return makeRequest(endpoint, 'GET', params, null, signal);
95
+ }
96
+ async function post(endpoint, body, params, signal) {
97
+ return makeRequest(endpoint, 'POST', params, body, signal);
98
+ }
99
+ async function put(endpoint, body, params, signal) {
100
+ return makeRequest(endpoint, 'PUT', params, body, signal);
101
+ }
102
+ async function patch(endpoint, body, params, signal) {
103
+ return makeRequest(endpoint, 'PATCH', params, body, signal);
104
+ }
105
+ async function destroy(endpoint, params, signal) {
106
+ return makeRequest(endpoint, 'DELETE', params, null, signal);
107
+ }
108
+ return { get, post, put, patch, destroy };
109
+ };
110
+ function handleError(requestUrl) {
111
+ console.error(`Error fetching from ${requestUrl}`);
112
+ }
113
+
114
+ export { Api as A };
@@ -1 +1,7 @@
1
- const e="\ntable-head,table-head-row,table-head-cell,table-body,table-row,table-row-even,\ntable-row-odd,table-cell,loading-state-cell,loading-state-spinner,error-state,\nempty-state,pagination-bar,page-arrow,page-button,page-button-disabled,page-button-text\n";export{e as t}
1
+ const tableExportedParts = `
2
+ table-head,table-head-row,table-head-cell,table-body,table-row,table-row-even,
3
+ table-row-odd,table-cell,loading-state-cell,loading-state-spinner,error-state,
4
+ empty-state,pagination-bar,page-arrow,page-button,page-button-disabled,page-button-text
5
+ `;
6
+
7
+ export { tableExportedParts as t };