hemfixarna-web-components 1.6.4 → 1.7.0

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 (262) hide show
  1. package/dist/cjs/{hemfixarna-address_36.cjs.entry.js → hemfixarna-address_15.cjs.entry.js} +341 -1030
  2. package/dist/cjs/hemfixarna-address_15.cjs.entry.js.map +1 -0
  3. package/dist/cjs/hemfixarna-byggmax.cjs.entry.js +26 -0
  4. package/dist/cjs/hemfixarna-byggmax.cjs.entry.js.map +1 -0
  5. package/dist/cjs/hemfixarna-category.cjs.entry.js +28 -0
  6. package/dist/cjs/hemfixarna-category.cjs.entry.js.map +1 -0
  7. package/dist/cjs/hemfixarna-components.cjs.js +1 -1
  8. package/dist/cjs/hemfixarna-components.cjs.js.map +1 -1
  9. package/dist/cjs/hemfixarna-doro.cjs.entry.js +26 -0
  10. package/dist/cjs/hemfixarna-doro.cjs.entry.js.map +1 -0
  11. package/dist/cjs/hemfixarna-elfa.cjs.entry.js +26 -0
  12. package/dist/cjs/hemfixarna-elfa.cjs.entry.js.map +1 -0
  13. package/dist/cjs/hemfixarna-fargvaruhuset.cjs.entry.js +23 -0
  14. package/dist/cjs/hemfixarna-fargvaruhuset.cjs.entry.js.map +1 -0
  15. package/dist/cjs/hemfixarna-flyttsmart.cjs.entry.js +23 -0
  16. package/dist/cjs/hemfixarna-flyttsmart.cjs.entry.js.map +1 -0
  17. package/dist/cjs/hemfixarna-forebygg.cjs.entry.js +26 -0
  18. package/dist/cjs/hemfixarna-forebygg.cjs.entry.js.map +1 -0
  19. package/dist/cjs/hemfixarna-hornbach.cjs.entry.js +26 -0
  20. package/dist/cjs/hemfixarna-hornbach.cjs.entry.js.map +1 -0
  21. package/dist/cjs/hemfixarna-kbygg.cjs.entry.js +23 -0
  22. package/dist/cjs/hemfixarna-kbygg.cjs.entry.js.map +1 -0
  23. package/dist/cjs/hemfixarna-klint.cjs.entry.js +23 -0
  24. package/dist/cjs/hemfixarna-klint.cjs.entry.js.map +1 -0
  25. package/dist/cjs/hemfixarna-kund.cjs.entry.js +23 -0
  26. package/dist/cjs/hemfixarna-kund.cjs.entry.js.map +1 -0
  27. package/dist/cjs/hemfixarna-norrgavel.cjs.entry.js +23 -0
  28. package/dist/cjs/hemfixarna-norrgavel.cjs.entry.js.map +1 -0
  29. package/dist/cjs/hemfixarna-power.cjs.entry.js +23 -0
  30. package/dist/cjs/hemfixarna-power.cjs.entry.js.map +1 -0
  31. package/dist/cjs/hemfixarna-service.cjs.entry.js +24 -0
  32. package/dist/cjs/hemfixarna-service.cjs.entry.js.map +1 -0
  33. package/dist/cjs/hemfixarna-skanska.cjs.entry.js +26 -0
  34. package/dist/cjs/hemfixarna-skanska.cjs.entry.js.map +1 -0
  35. package/dist/cjs/hemfixarna-sparfonster.cjs.entry.js +23 -0
  36. package/dist/cjs/hemfixarna-sparfonster.cjs.entry.js.map +1 -0
  37. package/dist/cjs/hemfixarna-string-furniture.cjs.entry.js +26 -0
  38. package/dist/cjs/hemfixarna-string-furniture.cjs.entry.js.map +1 -0
  39. package/dist/cjs/hemfixarna-superfront.cjs.entry.js +24 -0
  40. package/dist/cjs/hemfixarna-superfront.cjs.entry.js.map +1 -0
  41. package/dist/cjs/hemfixarna-tesla.cjs.entry.js +23 -0
  42. package/dist/cjs/hemfixarna-tesla.cjs.entry.js.map +1 -0
  43. package/dist/cjs/hemfixarna-traningspartner.cjs.entry.js +23 -0
  44. package/dist/cjs/hemfixarna-traningspartner.cjs.entry.js.map +1 -0
  45. package/dist/cjs/hemfixarna-zaptec.cjs.entry.js +23 -0
  46. package/dist/cjs/hemfixarna-zaptec.cjs.entry.js.map +1 -0
  47. package/dist/cjs/index-4695c475.js +258 -0
  48. package/dist/cjs/index-4695c475.js.map +1 -0
  49. package/dist/cjs/index-8054ce93.js +42 -0
  50. package/dist/cjs/index-8054ce93.js.map +1 -0
  51. package/dist/cjs/index-b83343b9.js.map +1 -1
  52. package/dist/cjs/loader.cjs.js +1 -1
  53. package/dist/cjs/loader.cjs.js.map +1 -1
  54. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js +2 -82
  55. package/dist/collection/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.js.map +1 -1
  56. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js +1 -20
  57. package/dist/collection/components/customers/hemfixarna-doro/hemfixarna-doro.js.map +1 -1
  58. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js +1 -39
  59. package/dist/collection/components/customers/hemfixarna-elfa/hemfixarna-elfa.js.map +1 -1
  60. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js +1 -39
  61. package/dist/collection/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.js.map +1 -1
  62. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js +1 -39
  63. package/dist/collection/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.js.map +1 -1
  64. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js +1 -20
  65. package/dist/collection/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.js.map +1 -1
  66. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js +1 -39
  67. package/dist/collection/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.js.map +1 -1
  68. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js +1 -39
  69. package/dist/collection/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.js.map +1 -1
  70. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js +1 -20
  71. package/dist/collection/components/customers/hemfixarna-klint/hemfixarna-klint.js.map +1 -1
  72. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js +1 -20
  73. package/dist/collection/components/customers/hemfixarna-kund/hemfixarna-kund.js.map +1 -1
  74. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js +1 -39
  75. package/dist/collection/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.js.map +1 -1
  76. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js +1 -38
  77. package/dist/collection/components/customers/hemfixarna-power/hemfixarna-power.js.map +1 -1
  78. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js +1 -38
  79. package/dist/collection/components/customers/hemfixarna-skanska/hemfixarna-skanska.js.map +1 -1
  80. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js +1 -38
  81. package/dist/collection/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.js.map +1 -1
  82. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js +1 -20
  83. package/dist/collection/components/customers/hemfixarna-string/hemfixarna-string-furniture.js.map +1 -1
  84. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js +1 -1
  85. package/dist/collection/components/customers/hemfixarna-superfront.tsx/hemfixarna-superfront.js.map +1 -1
  86. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js +1 -39
  87. package/dist/collection/components/customers/hemfixarna-tesla/hemfixarna-tesla.js.map +1 -1
  88. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js +1 -20
  89. package/dist/collection/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.js.map +1 -1
  90. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js +1 -39
  91. package/dist/collection/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.js.map +1 -1
  92. package/dist/collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js +1 -60
  93. package/dist/collection/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.js.map +1 -1
  94. package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js +1 -28
  95. package/dist/collection/components/hemfixarna-cart/hemfixarna-cart.js.map +1 -1
  96. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js +27 -236
  97. package/dist/collection/components/hemfixarna-component/hemfixarna-component.js.map +1 -1
  98. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js +75 -39
  99. package/dist/collection/components/hemfixarna-demo/hemfixarna-demo.js.map +1 -1
  100. package/dist/collection/components/hemfixarna-info/hemfixarna-info.js +2 -2
  101. package/dist/collection/components/hemfixarna-info/hemfixarna-info.js.map +1 -1
  102. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.js +2 -1
  103. package/dist/collection/components/hemfixarna-invoice/hemfixarna-invoice.js.map +1 -1
  104. package/dist/collection/components/hemfixarna-order/hemfixarna-order.js +1 -26
  105. package/dist/collection/components/hemfixarna-order/hemfixarna-order.js.map +1 -1
  106. package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js +7 -41
  107. package/dist/collection/components/hemfixarna-orderrows/hemfixarna-orderrows.js.map +1 -1
  108. package/dist/collection/types/index.js +4 -0
  109. package/dist/collection/types/index.js.map +1 -1
  110. package/dist/collection/utils/api.js +18 -2
  111. package/dist/collection/utils/api.js.map +1 -1
  112. package/dist/collection/utils/creditSafe.js +2 -2
  113. package/dist/collection/utils/creditSafe.js.map +1 -1
  114. package/dist/collection/utils/enviroment.js +31 -0
  115. package/dist/collection/utils/enviroment.js.map +1 -0
  116. package/dist/collection/utils/felixApi.js +2 -1
  117. package/dist/collection/utils/felixApi.js.map +1 -1
  118. package/dist/collection/utils/felixFunctions.js +0 -1
  119. package/dist/collection/utils/felixFunctions.js.map +1 -1
  120. package/dist/esm/hemfixarna-address_15.entry.js +2056 -0
  121. package/dist/esm/hemfixarna-address_15.entry.js.map +1 -0
  122. package/dist/esm/hemfixarna-byggmax.entry.js +22 -0
  123. package/dist/esm/hemfixarna-byggmax.entry.js.map +1 -0
  124. package/dist/esm/hemfixarna-category.entry.js +24 -0
  125. package/dist/esm/hemfixarna-category.entry.js.map +1 -0
  126. package/dist/esm/hemfixarna-components.js +3 -3
  127. package/dist/esm/hemfixarna-components.js.map +1 -1
  128. package/dist/esm/hemfixarna-doro.entry.js +22 -0
  129. package/dist/esm/hemfixarna-doro.entry.js.map +1 -0
  130. package/dist/esm/hemfixarna-elfa.entry.js +22 -0
  131. package/dist/esm/hemfixarna-elfa.entry.js.map +1 -0
  132. package/dist/esm/hemfixarna-fargvaruhuset.entry.js +19 -0
  133. package/dist/esm/hemfixarna-fargvaruhuset.entry.js.map +1 -0
  134. package/dist/esm/hemfixarna-flyttsmart.entry.js +19 -0
  135. package/dist/esm/hemfixarna-flyttsmart.entry.js.map +1 -0
  136. package/dist/esm/hemfixarna-forebygg.entry.js +22 -0
  137. package/dist/esm/hemfixarna-forebygg.entry.js.map +1 -0
  138. package/dist/esm/hemfixarna-hornbach.entry.js +22 -0
  139. package/dist/esm/hemfixarna-hornbach.entry.js.map +1 -0
  140. package/dist/esm/hemfixarna-kbygg.entry.js +19 -0
  141. package/dist/esm/hemfixarna-kbygg.entry.js.map +1 -0
  142. package/dist/esm/hemfixarna-klint.entry.js +19 -0
  143. package/dist/esm/hemfixarna-klint.entry.js.map +1 -0
  144. package/dist/esm/hemfixarna-kund.entry.js +19 -0
  145. package/dist/esm/hemfixarna-kund.entry.js.map +1 -0
  146. package/dist/esm/hemfixarna-norrgavel.entry.js +19 -0
  147. package/dist/esm/hemfixarna-norrgavel.entry.js.map +1 -0
  148. package/dist/esm/hemfixarna-power.entry.js +19 -0
  149. package/dist/esm/hemfixarna-power.entry.js.map +1 -0
  150. package/dist/esm/hemfixarna-service.entry.js +20 -0
  151. package/dist/esm/hemfixarna-service.entry.js.map +1 -0
  152. package/dist/esm/hemfixarna-skanska.entry.js +22 -0
  153. package/dist/esm/hemfixarna-skanska.entry.js.map +1 -0
  154. package/dist/esm/hemfixarna-sparfonster.entry.js +19 -0
  155. package/dist/esm/hemfixarna-sparfonster.entry.js.map +1 -0
  156. package/dist/esm/hemfixarna-string-furniture.entry.js +22 -0
  157. package/dist/esm/hemfixarna-string-furniture.entry.js.map +1 -0
  158. package/dist/esm/hemfixarna-superfront.entry.js +20 -0
  159. package/dist/esm/hemfixarna-superfront.entry.js.map +1 -0
  160. package/dist/esm/hemfixarna-tesla.entry.js +19 -0
  161. package/dist/esm/hemfixarna-tesla.entry.js.map +1 -0
  162. package/dist/esm/hemfixarna-traningspartner.entry.js +19 -0
  163. package/dist/esm/hemfixarna-traningspartner.entry.js.map +1 -0
  164. package/dist/esm/hemfixarna-zaptec.entry.js +19 -0
  165. package/dist/esm/hemfixarna-zaptec.entry.js.map +1 -0
  166. package/dist/esm/{index-8c417125.js → index-04bcf90e.js} +2 -2
  167. package/dist/esm/index-04bcf90e.js.map +1 -0
  168. package/dist/esm/index-113a6b21.js +256 -0
  169. package/dist/esm/index-113a6b21.js.map +1 -0
  170. package/dist/esm/index-1fbc7a74.js +42 -0
  171. package/dist/esm/index-1fbc7a74.js.map +1 -0
  172. package/dist/esm/loader.js +3 -3
  173. package/dist/esm/loader.js.map +1 -1
  174. package/dist/hemfixarna-components/hemfixarna-components.esm.js +1 -1
  175. package/dist/hemfixarna-components/hemfixarna-components.esm.js.map +1 -1
  176. package/dist/hemfixarna-components/p-12dbf4e6.entry.js +2 -0
  177. package/dist/hemfixarna-components/p-12dbf4e6.entry.js.map +1 -0
  178. package/dist/hemfixarna-components/p-1b80999e.entry.js +2 -0
  179. package/dist/hemfixarna-components/p-1b80999e.entry.js.map +1 -0
  180. package/dist/hemfixarna-components/p-1f875c7a.entry.js +2 -0
  181. package/dist/hemfixarna-components/p-1f875c7a.entry.js.map +1 -0
  182. package/dist/hemfixarna-components/{p-852e7173.js → p-32a8152b.js} +2 -2
  183. package/dist/hemfixarna-components/p-32a8152b.js.map +1 -0
  184. package/dist/hemfixarna-components/p-3acd1346.entry.js +2 -0
  185. package/dist/hemfixarna-components/p-3acd1346.entry.js.map +1 -0
  186. package/dist/hemfixarna-components/p-53afbc10.entry.js +2 -0
  187. package/dist/hemfixarna-components/p-53afbc10.entry.js.map +1 -0
  188. package/dist/hemfixarna-components/p-53f0abfa.entry.js +2 -0
  189. package/dist/hemfixarna-components/p-53f0abfa.entry.js.map +1 -0
  190. package/dist/hemfixarna-components/p-61b4597f.entry.js +2 -0
  191. package/dist/hemfixarna-components/p-61b4597f.entry.js.map +1 -0
  192. package/dist/hemfixarna-components/p-6c1d21dd.entry.js +2 -0
  193. package/dist/hemfixarna-components/p-6c1d21dd.entry.js.map +1 -0
  194. package/dist/hemfixarna-components/p-6f6601b8.entry.js +2 -0
  195. package/dist/hemfixarna-components/p-6f6601b8.entry.js.map +1 -0
  196. package/dist/hemfixarna-components/p-7c122f15.entry.js +2 -0
  197. package/dist/hemfixarna-components/p-7c122f15.entry.js.map +1 -0
  198. package/dist/hemfixarna-components/p-8356796a.entry.js +2 -0
  199. package/dist/hemfixarna-components/p-8356796a.entry.js.map +1 -0
  200. package/dist/hemfixarna-components/p-8d509bf1.entry.js +2 -0
  201. package/dist/hemfixarna-components/p-8d509bf1.entry.js.map +1 -0
  202. package/dist/hemfixarna-components/p-8f0a688c.entry.js +2 -0
  203. package/dist/hemfixarna-components/p-8f0a688c.entry.js.map +1 -0
  204. package/dist/hemfixarna-components/p-9b1e6bc2.entry.js +2 -0
  205. package/dist/hemfixarna-components/p-9b1e6bc2.entry.js.map +1 -0
  206. package/dist/hemfixarna-components/p-a3d759d9.js +2 -0
  207. package/dist/hemfixarna-components/p-a3d759d9.js.map +1 -0
  208. package/dist/hemfixarna-components/p-a9845efc.entry.js +2 -0
  209. package/dist/hemfixarna-components/p-a9845efc.entry.js.map +1 -0
  210. package/dist/hemfixarna-components/p-ae3fc85c.entry.js +2 -0
  211. package/dist/hemfixarna-components/p-ae3fc85c.entry.js.map +1 -0
  212. package/dist/hemfixarna-components/p-b6bc1537.entry.js +2 -0
  213. package/dist/hemfixarna-components/p-b6bc1537.entry.js.map +1 -0
  214. package/dist/hemfixarna-components/p-cb1634e8.entry.js +2 -0
  215. package/dist/hemfixarna-components/p-cb1634e8.entry.js.map +1 -0
  216. package/dist/hemfixarna-components/p-cfdc93e9.js +2 -0
  217. package/dist/hemfixarna-components/p-cfdc93e9.js.map +1 -0
  218. package/dist/hemfixarna-components/p-dabad8a7.entry.js +2 -0
  219. package/dist/hemfixarna-components/p-dabad8a7.entry.js.map +1 -0
  220. package/dist/hemfixarna-components/p-dfcefa54.entry.js +2 -0
  221. package/dist/hemfixarna-components/p-dfcefa54.entry.js.map +1 -0
  222. package/dist/hemfixarna-components/p-e0aad0ff.entry.js +2 -0
  223. package/dist/hemfixarna-components/p-e0aad0ff.entry.js.map +1 -0
  224. package/dist/hemfixarna-components/p-edac9f21.entry.js +2 -0
  225. package/dist/hemfixarna-components/p-edac9f21.entry.js.map +1 -0
  226. package/dist/types/components/customers/hemfixarna-byggmax/hemfixarna-byggmax.d.ts +1 -6
  227. package/dist/types/components/customers/hemfixarna-doro/hemfixarna-doro.d.ts +0 -1
  228. package/dist/types/components/customers/hemfixarna-elfa/hemfixarna-elfa.d.ts +0 -2
  229. package/dist/types/components/customers/hemfixarna-fargvaruhuset/hemfixarna-fargvaruhuset.d.ts +0 -2
  230. package/dist/types/components/customers/hemfixarna-flyttsmart/hemfixarna-flyttsmart.d.ts +0 -2
  231. package/dist/types/components/customers/hemfixarna-forebygg/hemfixarna-forebygg.d.ts +0 -1
  232. package/dist/types/components/customers/hemfixarna-hornbach/hemfixarna-hornbach.d.ts +0 -2
  233. package/dist/types/components/customers/hemfixarna-kbygg/hemfixarna-kbygg.d.ts +0 -2
  234. package/dist/types/components/customers/hemfixarna-klint/hemfixarna-klint.d.ts +0 -1
  235. package/dist/types/components/customers/hemfixarna-kund/hemfixarna-kund.d.ts +0 -1
  236. package/dist/types/components/customers/hemfixarna-norrgavel/hemfixarna-norrgavel.d.ts +0 -2
  237. package/dist/types/components/customers/hemfixarna-power/hemfixarna-power.d.ts +0 -2
  238. package/dist/types/components/customers/hemfixarna-skanska/hemfixarna-skanska.d.ts +0 -2
  239. package/dist/types/components/customers/hemfixarna-sparfonster/hemfixarna-sparfonster.d.ts +0 -2
  240. package/dist/types/components/customers/hemfixarna-string/hemfixarna-string-furniture.d.ts +0 -1
  241. package/dist/types/components/customers/hemfixarna-tesla/hemfixarna-tesla.d.ts +0 -2
  242. package/dist/types/components/customers/hemfixarna-traningspartner/hemfixarna-traningspartner.d.ts +0 -1
  243. package/dist/types/components/customers/hemfixarna-zaptec/hemfixarna-zaptec.d.ts +0 -2
  244. package/dist/types/components/hemfixarna-breadcrumbs/hemfixarna-breadcrumbs.d.ts +0 -4
  245. package/dist/types/components/hemfixarna-cart/hemfixarna-cart.d.ts +0 -2
  246. package/dist/types/components/hemfixarna-component/hemfixarna-component.d.ts +2 -18
  247. package/dist/types/components/hemfixarna-demo/hemfixarna-demo.d.ts +4 -2
  248. package/dist/types/components/hemfixarna-order/hemfixarna-order.d.ts +0 -2
  249. package/dist/types/components/hemfixarna-orderrows/hemfixarna-orderrows.d.ts +1 -2
  250. package/dist/types/components.d.ts +2 -100
  251. package/dist/types/types/index.d.ts +24 -22
  252. package/dist/types/utils/api.d.ts +5 -1
  253. package/dist/types/utils/enviroment.d.ts +3 -0
  254. package/package.json +4 -3
  255. package/readme.md +22 -0
  256. package/dist/cjs/hemfixarna-address_36.cjs.entry.js.map +0 -1
  257. package/dist/esm/hemfixarna-address_36.entry.js +0 -4090
  258. package/dist/esm/hemfixarna-address_36.entry.js.map +0 -1
  259. package/dist/esm/index-8c417125.js.map +0 -1
  260. package/dist/hemfixarna-components/p-852e7173.js.map +0 -1
  261. package/dist/hemfixarna-components/p-97461831.entry.js +0 -2
  262. package/dist/hemfixarna-components/p-97461831.entry.js.map +0 -1
@@ -0,0 +1,2056 @@
1
+ import { r as registerInstance, h, g as getElement, F as Fragment, a as getAssetPath } from './index-04bcf90e.js';
2
+ import { s as state } from './index-113a6b21.js';
3
+ import { B as Business, W as WidgetStyle } from './index-1fbc7a74.js';
4
+
5
+ const hideField = (field) => {
6
+ return field.split(' ').reduce((acc, curr) => {
7
+ if (curr.length <= 2) {
8
+ return acc + curr.slice(0, 1) + '* ';
9
+ }
10
+ else {
11
+ return acc + curr.slice(0, 1) + '*'.repeat(curr.length - 2) + curr.slice(-1) + ' ';
12
+ }
13
+ }, '');
14
+ };
15
+
16
+ const scrollToTop = (el) => {
17
+ if (!el)
18
+ return;
19
+ el.scrollTo({
20
+ top: 0,
21
+ behavior: 'smooth',
22
+ });
23
+ };
24
+
25
+ const HemfixarnaAddress = class {
26
+ constructor(hostRef) {
27
+ registerInstance(this, hostRef);
28
+ this.handleSubmit = (e) => {
29
+ e.preventDefault();
30
+ const streetValid = this.street.length > 0;
31
+ if (!streetValid) {
32
+ this.streetError = 'Ange en gatuadress';
33
+ }
34
+ const zipValid = this.zip.length > 0;
35
+ const zipIsNumber = /^\s*\d[\d\s]*$/.test(this.zip);
36
+ if (!zipIsNumber) {
37
+ this.zipError = 'Postnummer får endast innehålla siffror';
38
+ }
39
+ if (!zipValid) {
40
+ this.zipError = 'Ange ett postnummer';
41
+ }
42
+ const townValid = /^[^\d\s]{2,}$/.test(this.town);
43
+ if (!townValid) {
44
+ this.townError = 'Ange en ort';
45
+ }
46
+ if (streetValid && zipValid && townValid && zipIsNumber) {
47
+ state.user = Object.assign(Object.assign({}, state.user), { street: this.street, zip: this.zip, town: this.town });
48
+ state.checkoutStep = 2;
49
+ state.checkoutEdit = false;
50
+ const el = this.el.closest('.hemfixarna_content');
51
+ scrollToTop(el);
52
+ }
53
+ };
54
+ this.handleChangeStreet = (e) => {
55
+ this.streetError = null;
56
+ this.street = this.street === state.user.street ? '' : e.target.value;
57
+ };
58
+ this.handleChangeZip = (e) => {
59
+ this.zipError = null;
60
+ this.zip = this.zip === state.user.zip ? '' : e.target.value;
61
+ };
62
+ this.handleChangeTown = (e) => {
63
+ this.townError = null;
64
+ this.town = this.town === state.user.town ? '' : e.target.value;
65
+ };
66
+ this.render = () => {
67
+ return (h("form", { class: "hemfixarna_address", onSubmit: e => this.handleSubmit(e) }, h("div", null, h("input", { class: `${this.street.length ? 'input_active' : ''}`, onInput: this.handleChangeStreet, type: "text", name: "street", value: this.street === state.user.street ? hideField(this.street) : this.street }), h("label", { htmlFor: "street" }, "Gatuaddress ")), this.streetError && h("span", null, this.streetError), h("div", null, h("input", { class: `${this.zip.length ? 'input_active' : ''}`, onInput: this.handleChangeZip, type: "tel", name: "zip", value: this.zip === state.user.zip ? hideField(this.zip) : this.zip }), h("label", { htmlFor: "zip" }, "Postnummer ")), this.zipError && h("span", null, this.zipError), h("div", null, h("input", { class: `${this.town.length ? 'input_active' : ''}`, onInput: this.handleChangeTown, type: "text", name: "town", value: this.town === state.user.town ? hideField(this.town) : this.town }), h("label", { htmlFor: "town" }, "Ort ")), this.townError && h("span", null, this.townError), h("input", { type: "submit", value: "Forts\u00E4tt" })));
68
+ };
69
+ this.street = '';
70
+ this.streetError = null;
71
+ this.zip = '';
72
+ this.zipError = null;
73
+ this.town = '';
74
+ this.townError = null;
75
+ }
76
+ componentWillLoad() {
77
+ if (state.user) {
78
+ this.street = state.user.street;
79
+ this.zip = state.user.zip;
80
+ this.town = state.user.town;
81
+ }
82
+ }
83
+ get el() { return getElement(this); }
84
+ };
85
+
86
+ const getRutPrice = (price) => {
87
+ return Math.ceil(price / 2);
88
+ };
89
+ const getRotPrice = (price) => {
90
+ return Math.ceil(price * 0.7);
91
+ };
92
+ const getGreenPrice = (price) => {
93
+ return Math.ceil(price * 0.5);
94
+ };
95
+ const getProductPrice = (product, price, amount = 1) => {
96
+ if (product.rot && state.rot) {
97
+ return getRotPrice((price || product.price) * amount);
98
+ }
99
+ else if (product.rut && state.rut) {
100
+ return getRutPrice((price || product.price) * amount);
101
+ }
102
+ else if (product.green && state.green) {
103
+ return getGreenPrice((price || product.price) * amount);
104
+ }
105
+ else {
106
+ return (price || product.price) * amount;
107
+ }
108
+ };
109
+ const getProductPriceWithRotAndRut = (product) => {
110
+ if (product.rot) {
111
+ return getRotPrice(product.price);
112
+ }
113
+ else if (product.rut && state.rut) {
114
+ return getRutPrice(product.price);
115
+ }
116
+ else {
117
+ return product.price;
118
+ }
119
+ };
120
+ const getPartPrice = (part, product, amount = 1) => {
121
+ if (product.rot && state.rot) {
122
+ return getRotPrice(part.price * amount);
123
+ }
124
+ else if (product.rut && state.rut) {
125
+ return getRutPrice(part.price * amount);
126
+ }
127
+ else {
128
+ return part.price * amount;
129
+ }
130
+ };
131
+ const getStartFee = () => {
132
+ if (!state.cart)
133
+ return { rut: 0, rot: 0, green: 0 };
134
+ const hasRut = state.cart.some(item => item.rut && item.start_fee);
135
+ const hasRot = state.cart.some(item => item.rot && item.start_fee);
136
+ const hasGreen = state.cart.some(item => item.green && item.start_fee);
137
+ const rutPrice = state.rut ? getRutPrice(state.options.start_fee) : state.options.start_fee * 1;
138
+ const rotPrice = state.rot ? getRotPrice(state.options.start_fee) : state.options.start_fee * 1;
139
+ const greenPrice = state.green ? getGreenPrice(state.options.start_fee) : state.options.start_fee * 1;
140
+ return { rut: hasRut ? rutPrice : 0, rot: hasRot ? rotPrice : 0, green: hasGreen ? greenPrice : 0, length: [hasRut, hasRot, hasGreen].filter(d => d).length };
141
+ // if (hasRut && hasRot) {
142
+ // return { rut: rutPrice, rot: rotPrice, length: 2 };
143
+ // } else if (hasRut) {
144
+ // return { rut: rutPrice, rot: 0, length: 1 };
145
+ // } else if (hasRot) {
146
+ // return { rut: 0, rot: rotPrice, length: 1 };
147
+ // } else {
148
+ // return { rut: 0, rot: 0, length: 0 };
149
+ // }
150
+ };
151
+ const getItemPrice = (item) => {
152
+ const partsPrice = item.parts.reduce((acc, curr) => {
153
+ return acc + curr.price * curr.amount;
154
+ }, 0);
155
+ return getProductPrice(item, item.price * item.amount + partsPrice);
156
+ };
157
+ const calculateRot = () => {
158
+ const totalWithRot = state.cart.reduce((acc, curr) => {
159
+ return curr.rot ? acc + getItemPrice(curr) : acc;
160
+ }, 0) + getStartFee().rot;
161
+ const totalWithoutRot = state.cart.reduce((acc, curr) => {
162
+ const partsPrice = curr.parts.reduce((acc, curr) => {
163
+ return acc + curr.price * curr.amount;
164
+ }, 0);
165
+ return curr.rot ? acc + curr.price * curr.amount + partsPrice : acc;
166
+ }, 0) + Number(state.options.start_fee);
167
+ return totalWithoutRot - totalWithRot;
168
+ };
169
+ const calculateRut = () => {
170
+ const totalWithRut = state.cart.reduce((acc, curr) => {
171
+ return curr.rut ? acc + getItemPrice(curr) : acc;
172
+ }, 0) + getStartFee().rut;
173
+ const totalWithoutRut = state.cart.reduce((acc, curr) => {
174
+ const partsPrice = curr.parts.reduce((acc, curr) => {
175
+ return acc + curr.price * curr.amount;
176
+ }, 0);
177
+ return curr.rut ? acc + curr.price * curr.amount + partsPrice : acc;
178
+ }, 0) + Number(state.options.start_fee);
179
+ return totalWithoutRut - totalWithRut;
180
+ };
181
+ const calculateGreenDiscount = () => {
182
+ const totalWithGreen = state.cart.reduce((acc, curr) => {
183
+ return curr.green ? acc + getItemPrice(curr) : acc;
184
+ }, 0) + getStartFee().green;
185
+ const totalWithoutGreen = state.cart.reduce((acc, curr) => {
186
+ const partsPrice = curr.parts.reduce((acc, curr) => {
187
+ return acc + curr.price * curr.amount;
188
+ }, 0);
189
+ return curr.green ? acc + curr.price * curr.amount + partsPrice : acc;
190
+ }, 0) + Number(state.options.start_fee);
191
+ return totalWithoutGreen - totalWithGreen;
192
+ };
193
+ const getTotalPrice = () => {
194
+ return state.cart.reduce((acc, curr) => acc + getItemPrice(curr), 0) + getStartFee().rot + getStartFee().rut;
195
+ };
196
+
197
+ const isProduct = (category) => {
198
+ return category.post_name !== undefined;
199
+ };
200
+ const isBusiness = (partner) => {
201
+ return Object.values(Business).includes(partner);
202
+ };
203
+
204
+ const HemfixarnaBox = class {
205
+ constructor(hostRef) {
206
+ registerInstance(this, hostRef);
207
+ this.post = undefined;
208
+ this.category = undefined;
209
+ this.icon = undefined;
210
+ this.postTitle = undefined;
211
+ }
212
+ setTaxonomy(taxonomy) {
213
+ if (taxonomy) {
214
+ if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.taxonomy) === 'service_cat') {
215
+ state.selectedCategory = taxonomy;
216
+ state.step = 2;
217
+ }
218
+ else if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.post_type) === 'service') {
219
+ state.selectedService = taxonomy;
220
+ state.step = 3;
221
+ }
222
+ else if ((taxonomy === null || taxonomy === void 0 ? void 0 : taxonomy.post_type) === 'ikea_product') {
223
+ state.selectedProduct = taxonomy;
224
+ state.step = 4;
225
+ }
226
+ const el = this.el.closest('.hemfixarna_content');
227
+ scrollToTop(el);
228
+ }
229
+ }
230
+ setProduct() {
231
+ state.selectedProduct = this.category;
232
+ state.step = 4;
233
+ state.selectedCustomerCategory = null;
234
+ const el = this.el.closest('.hemfixarna_content');
235
+ scrollToTop(el);
236
+ }
237
+ render() {
238
+ return this.category ? (h(Fragment, null, isProduct(this.category) ? (h("li", { onClick: () => this.setProduct() }, h("img", { class: "hemfixarna_logo", height: 82, src: this.category.icon, alt: this.category.post_name }), h("div", null, h("p", null, this.category.title), !this.category.invoice ? h("p", { class: "price" }, "Fr\u00E5n ", getProductPrice(this.category), "kr") : null))) : (h("li", { onClick: () => (state.selectedCustomerCategory = this.category) }, h("img", { class: "hemfixarna_logo", height: 82, src: this.category.icon, alt: this.category.name }), h("div", null, h("p", null, this.category.name)))))) : (h("li", { onClick: () => this.setTaxonomy(this.post) }, this.post.icon && h("img", { class: "hemfixarna_logo", height: 82, src: this.icon, alt: this.postTitle }), h("div", null, h("p", null, this.postTitle), state.step === 3 && h("p", { class: "price" }, "Fr\u00E5n ", getProductPrice(this.post), "kr"))));
239
+ }
240
+ get el() { return getElement(this); }
241
+ };
242
+
243
+ const HemfixarnaBreadcrumbs = class {
244
+ constructor(hostRef) {
245
+ registerInstance(this, hostRef);
246
+ this.triggerScrollTotop = () => {
247
+ const el = this.el.nextSibling;
248
+ scrollToTop(el);
249
+ };
250
+ this.closeModal = undefined;
251
+ }
252
+ getCartLength() {
253
+ return state.cart.reduce((acc, curr) => acc + curr.amount, 0);
254
+ }
255
+ handleCartClick() {
256
+ var _a;
257
+ if ((_a = state.cart) === null || _a === void 0 ? void 0 : _a.length) {
258
+ state.step = 5;
259
+ this.triggerScrollTotop();
260
+ }
261
+ }
262
+ handleHomePageClick() {
263
+ state.step = 1;
264
+ state.parentCategory = null;
265
+ state.selectedCustomerCategory = null;
266
+ this.triggerScrollTotop();
267
+ setTimeout(() => {
268
+ state.selectedCategory = null;
269
+ state.selectedProduct = null;
270
+ state.maleri = null;
271
+ state.selectedService = null;
272
+ }, 200);
273
+ }
274
+ render() {
275
+ const logo = getAssetPath(`./assets/hemfixarna.svg`);
276
+ const close = getAssetPath(`./assets/close.svg`);
277
+ const cart = getAssetPath(`./assets/cart.svg`);
278
+ const back = getAssetPath(`./assets/back.svg`);
279
+ return (h("div", null, h("div", { class: "hemfixarna_crumbs" }, h("div", { class: "hemfixarna_crumbs--links" }, h("img", { onClick: () => this.handleHomePageClick(), src: logo, width: 110 }), h("img", { onClick: () => this.closeModal(), class: "close", src: close, width: 32 }), h("div", null, h("button", { onClick: () => this.handleHomePageClick() }, "Alla tj\u00E4nster"))), h("div", { class: "hemfixarna_crumbs--right" }, h("hemfixarna-contact", null), h("div", { onClick: () => this.handleCartClick(), class: `cart ${this.getCartLength() > 0 ? 'cart_active' : ''}` }, h("img", { src: cart, width: 24 }), h("span", null, this.getCartLength())))), [3, 4].includes(state.step) && !state.customer && (h("button", { class: "hemfixarna_crumbs--back", onClick: () => {
280
+ state.step = state.step === 4 ? 3 : 2;
281
+ } }, h("img", { width: 24, src: back, alt: "back arrow" }), h("span", null, "Se allt ", state.step === 4 ? state.selectedService.post_title : state.selectedCategory.name))), !state.parentCategory && state.step && state.selectedCustomerCategory && (h("button", { class: "hemfixarna_crumbs--back", onClick: () => {
282
+ state.step = 1;
283
+ state.selectedCustomerCategory = null;
284
+ state.selectedProduct = null;
285
+ state.maleri = null;
286
+ } }, h("img", { width: 24, src: back, alt: "back arrow" }), h("span", null, "Se alla tj\u00E4nster"))), state.parentCategory && state.step < 5 && (h("button", { class: "hemfixarna_crumbs--back", onClick: () => {
287
+ state.step = 1;
288
+ state.selectedCustomerCategory = state.parentCategory;
289
+ state.selectedProduct = null;
290
+ state.maleri = null;
291
+ } }, h("img", { width: 24, src: back, alt: "back arrow" }), h("span", null, "Se allt ", state.parentCategory.name)))));
292
+ }
293
+ get el() { return getElement(this); }
294
+ };
295
+
296
+ const HemfixarnaCart = class {
297
+ constructor(hostRef) {
298
+ registerInstance(this, hostRef);
299
+ }
300
+ render() {
301
+ const back = getAssetPath(`./assets/back.svg`);
302
+ return (h("div", { class: "hemfixarna_cart" }, h("div", { class: "hemfixarna_cart--left" }, h("h2", null, state.checkoutStep === 2 && !state.checkoutEdit && (h("button", { onClick: () => {
303
+ state.checkoutStep = 1;
304
+ } }, h("img", { width: 24, src: back, alt: "back arrow" }))), "Din bokning"), h("hemfixarna-orderrows", null)), h("div", { class: "hemfixarna_cart--right" }, h("h2", null, state.checkoutStep === 2 && !state.checkoutEdit && (h("button", { onClick: () => {
305
+ state.checkoutStep = 1;
306
+ } }, h("img", { width: 24, src: back, alt: "back arrow" }))), "Dina uppgifter"), h("hemfixarna-checkout", null), h("hemfixarna-info", null))));
307
+ }
308
+ };
309
+
310
+ const livePreviewUrl = 'hemfixarna-partner.vercel.app';
311
+ const getDefaultApiUrl = () => {
312
+ if (window.location.href.includes('vercel.app') && !window.location.href.includes(livePreviewUrl)) {
313
+ return 'https://hemfixare.dev.afonso.se';
314
+ }
315
+ else {
316
+ return 'https://hemfixarna.se';
317
+ }
318
+ };
319
+ const getApiUrl = () => {
320
+ if (typeof process !== 'undefined' && process.env && process.env.API_URL) {
321
+ return process.env.API_URL;
322
+ }
323
+ return getDefaultApiUrl();
324
+ };
325
+ const getDefaultCreditSafeApiUrl = () => {
326
+ if (window.location.href.includes('vercel.app')) {
327
+ return 'https://hemfixare-lookup-dev.vercel.app/api';
328
+ }
329
+ else {
330
+ return 'https://hemfixare-lookup.vercel.app/api';
331
+ }
332
+ };
333
+ const getCreditSafeApiUrl = () => {
334
+ if (typeof process !== 'undefined' && process.env && process.env.CREDIT_SAFE_API_URL) {
335
+ return process.env.CREDIT_SAFE_API_URL;
336
+ }
337
+ return getDefaultCreditSafeApiUrl();
338
+ };
339
+
340
+ const base$2 = `${getApiUrl()}/wp-json/headless`;
341
+ async function fetchWithType(request, options) {
342
+ const response = await fetch(request, options);
343
+ const body = await response.json();
344
+ return body;
345
+ }
346
+ const getCustomer = async (slug) => {
347
+ try {
348
+ const res = await fetch(`${base$2}/customer/${slug}`);
349
+ return await res.json();
350
+ }
351
+ catch (error) {
352
+ console.log(error);
353
+ }
354
+ };
355
+ const loginCustomer = async ({ id, password }) => {
356
+ try {
357
+ const res = await fetch(`${base$2}/customer/login`, {
358
+ method: 'POST',
359
+ body: JSON.stringify({ id, password }),
360
+ headers: {
361
+ 'Content-Type': 'application/json',
362
+ },
363
+ });
364
+ return res.status;
365
+ }
366
+ catch (error) {
367
+ console.log(error);
368
+ }
369
+ };
370
+ const getOptions = async () => {
371
+ try {
372
+ const res = await fetch(`${base$2}/webcoptions`);
373
+ return (await res.json());
374
+ }
375
+ catch (error) {
376
+ console.log(error);
377
+ }
378
+ };
379
+ const getRut = async () => {
380
+ try {
381
+ const data = await fetchWithType(`${base$2}/rut`);
382
+ return data;
383
+ }
384
+ catch (error) {
385
+ console.log(error);
386
+ }
387
+ };
388
+ const getRot = async () => {
389
+ try {
390
+ const res = await fetch(`${base$2}/rot`);
391
+ return (await res.json());
392
+ }
393
+ catch (error) {
394
+ console.log(error);
395
+ }
396
+ };
397
+ const getGreenDiscount = async () => {
398
+ try {
399
+ const res = await fetch(`${base$2}/green-discount`);
400
+ return await res.json();
401
+ }
402
+ catch (error) {
403
+ console.log(error);
404
+ }
405
+ };
406
+ const postOrder = async (data) => {
407
+ try {
408
+ const res = await fetch(`${base$2}/weborder`, {
409
+ method: 'POST',
410
+ body: JSON.stringify(data),
411
+ headers: {
412
+ 'Content-Type': 'application/json',
413
+ },
414
+ });
415
+ return (await res.json());
416
+ }
417
+ catch (error) {
418
+ console.log(error);
419
+ }
420
+ };
421
+
422
+ const base$1 = `${getApiUrl()}/wp-json/felix`;
423
+ const postPerson = async (felixOrder) => {
424
+ try {
425
+ return await fetchWithType(`${base$1}/createperson`, {
426
+ method: 'POST',
427
+ body: JSON.stringify(felixOrder),
428
+ headers: {
429
+ 'Content-Type': 'application/json',
430
+ },
431
+ });
432
+ }
433
+ catch (error) {
434
+ console.log(error);
435
+ }
436
+ };
437
+
438
+ const HemfixarnaCheckout = class {
439
+ constructor(hostRef) {
440
+ registerInstance(this, hostRef);
441
+ this.handleChangeDate = (e) => {
442
+ this.dateError = null;
443
+ this.date = e.target.value;
444
+ };
445
+ this.handleChangeTerms = () => {
446
+ this.generalError = null;
447
+ };
448
+ this.sendOrder = async () => {
449
+ var _a, _b, _c, _d;
450
+ if (this.loading)
451
+ return;
452
+ this.loading = true;
453
+ let order = {
454
+ firstName: state.creditSafeUser.firstName,
455
+ lastName: state.creditSafeUser.lastName,
456
+ street: state.user.street,
457
+ zip: state.user.zip,
458
+ town: state.user.town,
459
+ ssn: state.user.ssn,
460
+ email: state.user.email,
461
+ phone: state.user.phone,
462
+ url: `${state.business === Business.string ? 'string' : state.business}-webk`,
463
+ date: this.date,
464
+ products: [
465
+ ...state.cart.map(item => {
466
+ const parts = item.parts.map(part => ({
467
+ id: String(part.id),
468
+ name: part.name,
469
+ quantity: part.amount,
470
+ rut: 0,
471
+ rot: 0,
472
+ }));
473
+ return [
474
+ {
475
+ id: String(item.id),
476
+ name: item.name,
477
+ quantity: item.amount,
478
+ rot: item.rot ? 1 : 0,
479
+ rut: item.rut ? 1 : 0,
480
+ },
481
+ ...parts,
482
+ ];
483
+ }),
484
+ ].flat(),
485
+ creditSafe: state.creditSafeUser,
486
+ customer: state.business,
487
+ id_source: '',
488
+ id_sub_source: '',
489
+ seller_id: (_a = this.sellerID) !== null && _a !== void 0 ? _a : '',
490
+ referral_id: (_b = this.RefferalID) !== null && _b !== void 0 ? _b : '',
491
+ };
492
+ const felixOrder = await postPerson(order);
493
+ if (!felixOrder || !((_d = (_c = felixOrder.response) === null || _c === void 0 ? void 0 : _c.scriptResult) === null || _d === void 0 ? void 0 : _d.includes('OK'))) {
494
+ order = Object.assign(Object.assign({}, order), { felixStatus: 'error' });
495
+ }
496
+ else {
497
+ order = Object.assign(Object.assign({}, order), { felixStatus: 'success' });
498
+ }
499
+ try {
500
+ const { data: orderConfirm, status } = await postOrder(order);
501
+ if (orderConfirm && status && status === 200) {
502
+ state.step = 6;
503
+ const el = this.el.closest('.hemfixarna_content');
504
+ scrollToTop(el);
505
+ }
506
+ else {
507
+ this.generalError = 'Något gick fel, försök igen senare';
508
+ }
509
+ }
510
+ catch (error) {
511
+ this.generalError = 'Något gick fel, försök igen senare';
512
+ }
513
+ this.loading = false;
514
+ };
515
+ this.handleSubmit = (e) => {
516
+ e.preventDefault();
517
+ this.generalError = null;
518
+ const validDate = this.date.length > 0;
519
+ if (!validDate) {
520
+ this.dateError = 'Ange ett giltigt datum';
521
+ }
522
+ const checkBoxes = Array.from(this.el.querySelectorAll('input[type="checkbox"]'));
523
+ const notValidTerms = checkBoxes.find(i => !i.checked);
524
+ if (notValidTerms) {
525
+ this.generalError = 'Du måste godkänna villkoren';
526
+ }
527
+ // if (state.customer.source) {
528
+ // if (!this.sellerID) {
529
+ // this.generalError = 'Ange säljare';
530
+ // return;
531
+ // }
532
+ // if (state.customer.source.sub_sources?.length && !this.selectedSubSource) {
533
+ // this.generalError = 'Välj underkälla';
534
+ // return;
535
+ // }
536
+ // }
537
+ if (validDate && !notValidTerms) {
538
+ this.sendOrder();
539
+ }
540
+ };
541
+ this.handleKeyDown = (event) => {
542
+ this.enteredPin += event.key;
543
+ const correctPin = '+0033';
544
+ if (this.enteredPin.length === correctPin.length) {
545
+ if (this.enteredPin === correctPin) {
546
+ localStorage.setItem('show_sources', 'true');
547
+ this.showSources = true;
548
+ window.removeEventListener('keydown', this.handleKeyDown);
549
+ }
550
+ this.enteredPin = '';
551
+ }
552
+ clearTimeout(this.pinTimeout);
553
+ this.pinTimeout = setTimeout(() => (this.enteredPin = ''), 5000);
554
+ };
555
+ this.render = () => {
556
+ var _a;
557
+ const dateLogo = getAssetPath(`./assets/date.svg`);
558
+ const down = getAssetPath(`./assets/down.svg`);
559
+ const loading = getAssetPath(`./assets/spinner.gif`);
560
+ if (state.checkoutEdit) {
561
+ return h("hemfixarna-address", null);
562
+ }
563
+ else if (state.checkoutStep === 1) {
564
+ return h("hemfixarna-getuser", null);
565
+ }
566
+ else if (state.checkoutStep === 2) {
567
+ return (h("div", { class: "mb-2" }, h("div", { class: "hemfixarna_addressinfo" }, h("div", null, h("p", null, hideField(state.user.firstName)), h("p", null, hideField(state.user.lastName)), h("p", null, state.user.email), h("p", null, state.user.phone)), h("div", null, h("p", null, hideField(state.user.street)), h("p", null, hideField(state.user.zip)), h("p", null, hideField(state.user.town))), h("button", { onClick: () => (state.checkoutEdit = true) }, "Beh\u00F6ver du \u00E4ndra adressen?")), h("form", { onSubmit: e => this.handleSubmit(e) }, h("div", null, h("img", { src: dateLogo, width: 24 }), h("input", { class: `${this.date.length ? 'input_active' : ''}`, min: new Date().toISOString().split('T')[0], onChange: e => this.handleChangeDate(e), type: "date", name: "date", value: this.date }), h("label", { htmlFor: "date" }, "Tidigaste datum f\u00F6r hembes\u00F6k"), h("img", { src: down, width: 24 })), this.dateError && h("span", null, this.dateError), state.customer.source && this.showSources ? (h(Fragment, null, h("p", null, "Inloggad som:", h("strong", null, " ", state.customer.source.fieldData.So01_Name)), h("label", null, "S\u00E4ljare (S\u00E4ljarId)", h("input", { type: "text", value: this.sellerID, onChange: e => (this.sellerID = e.target.value) })), h("label", null, "PartnerOrderID (RefferalID)", h("input", { type: "text", value: this.RefferalID, onChange: e => (this.RefferalID = e.target.value) })), ((_a = state.customer.source.sub_sources) === null || _a === void 0 ? void 0 : _a.length) ? (h("div", null, h("select", { onChange: e => (this.selectedSubSource = e.target.value) }, h("option", { disabled: true, selected: true, value: "null" }, "V\u00E4lj underk\u00E4lla"), state.customer.source.sub_sources.map(sub => (h("option", { value: sub['So_SubSource::_id'] }, sub['So_SubSource::Sus01_Name'])))))) : (h("h4", null, "Det finns inga underk\u00E4llor att v\u00E4lja")))) : null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: () => this.handleChangeTerms(), type: "checkbox" }), h("span", { innerHTML: state.options.terms })), state.cart
568
+ .filter(i => { var _a; return (_a = i.terms_checkout) === null || _a === void 0 ? void 0 : _a.length; })
569
+ .map(item => (h(Fragment, null, h("label", { class: "hemfixarna_checkbox" }, h("input", { onChange: () => this.handleChangeTerms(), type: "checkbox" }), h("span", null, item.terms_checkout))))), this.generalError && h("span", null, this.generalError), h("div", { class: this.loading ? 'loading' : '' }, h("input", { type: "submit", value: this.loading ? '' : 'Skicka bokning' }), h("img", { width: 20, height: 20, src: loading, alt: "spinner" })))));
570
+ }
571
+ };
572
+ this.date = '';
573
+ this.dateError = null;
574
+ this.generalError = null;
575
+ this.loading = false;
576
+ this.enteredPin = '';
577
+ this.selectedSubSource = null;
578
+ this.partnerOrderId = null;
579
+ this.showSources = false;
580
+ this.sellerID = null;
581
+ this.RefferalID = null;
582
+ }
583
+ componentWillLoad() {
584
+ if (Boolean(state.user && state.user.street)) {
585
+ state.checkoutStep = 2;
586
+ }
587
+ if (state.customer && state.customer.source) {
588
+ window.addEventListener('keydown', this.handleKeyDown);
589
+ }
590
+ const showSources = localStorage.getItem('show_sources');
591
+ if (showSources) {
592
+ this.showSources = true;
593
+ }
594
+ }
595
+ disconnectedCallback() {
596
+ window.removeEventListener('keydown', this.handleKeyDown);
597
+ }
598
+ get el() { return getElement(this); }
599
+ };
600
+
601
+ const hemfixarnaCss = "@import url(\"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap\");\n@keyframes fadeIn {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n* {\n box-sizing: border-box;\n}\n\n:host {\n font-family: \"Inter\", sans-serif;\n}\n:host input[type=text] {\n padding: 16px;\n width: 100%;\n font-size: 16px;\n border: 1px solid #fcd9c9;\n}\n:host .mb-2 {\n margin-bottom: 32px;\n}\n:host button {\n color: #474444;\n}\n:host form {\n display: flex;\n flex-direction: column;\n gap: 16px;\n position: relative;\n}\n:host form button {\n position: absolute;\n right: 0;\n top: -1rem;\n}\n:host form img {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n pointer-events: none;\n}\n:host form img:first-of-type {\n left: 16px;\n}\n:host form img:last-of-type {\n right: 16px;\n}\n:host form span {\n margin-top: -8px;\n color: #ec6632;\n}\n:host form p {\n text-align: center;\n}\n:host form p {\n margin: 0;\n}\n:host form div {\n position: relative;\n}\n:host form div label {\n pointer-events: none;\n position: absolute;\n left: 16px;\n top: 50%;\n transform: translateY(-50%);\n background: #fff;\n padding: 4px;\n transition: 0.2s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n}\n:host form div input {\n padding: 16px;\n width: 100%;\n font-size: 16px;\n border: 1px solid #fcd9c9;\n}\n:host form div input:focus ~ label,\n:host form div .input_active ~ label {\n top: 0;\n transform: translateY(-50%);\n background: linear-gradient(180deg, #fffaf2 50%, #fff 50%);\n}\n:host form select {\n padding: 0.75rem 1rem;\n width: 100%;\n}\n:host h1 {\n font-size: 24px;\n font-weight: 400;\n line-height: 32px;\n letter-spacing: -3%;\n text-align: left;\n margin: 0 0 8px;\n}\n:host h2 {\n margin: 0 0 24px;\n font-weight: 700;\n font-size: 20px;\n line-height: 28px;\n letter-spacing: -3%;\n}\n:host p {\n font-size: 16px;\n font-weight: 400;\n line-height: 24px;\n letter-spacing: -3%;\n}\n:host .hemfixarna {\n width: 100%;\n /* Hide default HTML checkbox */\n /* The slider */\n}\n:host .hemfixarna_contact {\n display: flex;\n gap: 16px;\n}\n:host .hemfixarna_contact a {\n display: flex;\n align-items: center;\n gap: 8px;\n color: #474444;\n text-decoration: none;\n font-weight: 600;\n font-size: 13px;\n}\n:host .hemfixarna_contact a:hover {\n text-decoration: underline;\n}\n:host .hemfixarna_contact--horizontal span {\n display: none;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_contact--horizontal span {\n display: initial;\n }\n}\n:host .hemfixarna_painting {\n opacity: 0;\n padding: 0 1rem;\n animation: fadeIn 0.5s forwards 0.3s;\n}\n:host .hemfixarna_painting > h2,\n:host .hemfixarna_painting p {\n text-align: center;\n padding: 0 16px;\n}\n:host .hemfixarna_painting > h2 {\n margin: 0 0 8px;\n}\n:host .hemfixarna_partnerlogo {\n max-height: 50px;\n min-height: 45px;\n object-fit: contain;\n max-width: 150px;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_partnerlogo {\n max-width: 200px;\n }\n}\n:host .hemfixarna_nav {\n position: absolute;\n top: 0;\n width: 100dvw;\n left: 0;\n height: 80px;\n z-index: 9999;\n}\n:host .hemfixarna_nav--links {\n display: none !important;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_nav--links {\n display: flex !important;\n }\n}\n:host .hemfixarna_nav--links a {\n color: #ec6632;\n text-decoration: none;\n border: 1px solid rgba(255, 255, 255, 0.3);\n border-radius: 56px;\n padding: 8px 32px;\n text-transform: capitalize;\n}\n:host .hemfixarna_nav > div {\n position: relative;\n overflow: hidden;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0 16px;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_nav > div {\n padding: 0 32px;\n }\n}\n:host .hemfixarna_nav > div > div {\n display: flex;\n gap: 32px;\n justify-content: space-between;\n}\n:host .hemfixarna_nav > div > img {\n position: absolute;\n width: 100%;\n height: 100%;\n top: 0;\n left: 0;\n z-index: -1;\n}\n:host .hemfixarna_nav a {\n text-decoration: none;\n}\n:host .hemfixarna_nav p {\n color: #474444;\n}\n:host .hemfixarna_nav p.with-bg {\n color: #fff;\n}\n:host .hemfixarna_standalone .hemfixarna_backdrop {\n background: #fffaf2;\n opacity: 1;\n}\n:host .hemfixarna_standalone .hemfixarna_modal {\n top: 80px;\n transform: translateX(-50%);\n border: none;\n height: calc(100dvh - 80px);\n opacity: 0;\n}\n:host .hemfixarna_standalone .hemfixarna_modal--open {\n opacity: 1;\n}\n:host .hemfixarna .switch {\n position: relative;\n display: inline-block;\n width: 40px;\n height: 20px;\n}\n:host .hemfixarna .switch input {\n opacity: 0;\n width: 0;\n height: 0;\n}\n:host .hemfixarna .slider {\n position: absolute;\n cursor: pointer;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #ccc;\n -webkit-transition: 0.4s;\n transition: 0.4s;\n border-radius: 34px;\n}\n:host .hemfixarna .slider:before {\n position: absolute;\n content: \"\";\n height: 18px;\n width: 18px;\n left: 2px;\n bottom: 1px;\n background-color: white;\n -webkit-transition: 0.4s;\n transition: 0.4s;\n border-radius: 50%;\n}\n:host .hemfixarna input:checked + .slider {\n background-color: #fcd9c9;\n}\n:host .hemfixarna input:focus + .slider {\n box-shadow: 0 0 1px #fcd9c9;\n}\n:host .hemfixarna input:checked + .slider:before {\n -webkit-transform: translateX(18px);\n -ms-transform: translateX(18px);\n transform: translateX(18px);\n background: #ec6632;\n}\n:host .hemfixarna_maleribox {\n background: #fff;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n width: 100%;\n min-height: 132px;\n padding: 24px;\n display: flex;\n align-items: center;\n gap: 24px;\n text-align: left;\n}\n:host .hemfixarna_maleribox:hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_checkbox {\n display: grid;\n grid-template-columns: 40px auto;\n font-size: 16px;\n font-weight: 400;\n line-height: 24px;\n letter-spacing: -3%;\n}\n:host .hemfixarna_checkbox > span {\n transform: translateY(6px);\n}\n:host .hemfixarna_checkbox span,\n:host .hemfixarna_checkbox span p {\n color: #474444;\n font-size: 14px;\n}\n:host .hemfixarna_checkbox p {\n text-align: left;\n}\n:host .hemfixarna_info {\n display: flex;\n flex-direction: column;\n gap: 24px;\n padding: 32px;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n border-radius: 4px;\n border: 1px solid #fcd9c9;\n}\n:host .hemfixarna_info h2 {\n margin: 0;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_info {\n position: sticky;\n top: 0;\n }\n}\n:host .hemfixarna_infomodal {\n position: absolute;\n top: 40%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 100%;\n max-width: 80%;\n background: #fffaf2;\n border: 1px solid #fcd9c9;\n padding: 32px;\n z-index: 99;\n border-radius: 4px;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n:host .hemfixarna_infomodal p,\n:host .hemfixarna_infomodal h4 {\n margin: 0;\n}\n:host .hemfixarna_infomodal button {\n background: #ec6632;\n color: #fff;\n border-radius: 60px;\n font-size: 16px;\n padding: 8px 16px;\n}\n:host .hemfixarna_addressinfo {\n padding: 16px 16px 64px;\n border: 1px solid #fcd9c9;\n position: relative;\n margin-bottom: 32px;\n display: grid;\n grid-template-columns: 1fr;\n gap: 8px;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_addressinfo {\n grid-template-columns: 1fr 1fr;\n }\n}\n:host .hemfixarna_addressinfo button {\n position: absolute;\n bottom: 16px;\n right: 16px;\n font-weight: 500;\n text-underline-offset: 2px;\n text-decoration: underline;\n}\n:host .hemfixarna_part {\n background: #fff;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n display: grid;\n padding: 16px;\n grid-template-columns: auto 75px;\n}\n:host .hemfixarna_counter {\n display: flex;\n align-items: center;\n}\n:host .hemfixarna_counter span {\n padding: 0 8px;\n}\n:host .hemfixarna_counter img {\n cursor: pointer;\n}\n:host .hemfixarna_counter img:not(.disabled):hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_description {\n display: grid;\n gap: 16px;\n}\n:host .hemfixarna_description ul {\n list-style: disc;\n padding-right: 12px;\n transform: translateX(12px);\n}\n:host .hemfixarna_description--hidden {\n max-height: 140px;\n overflow: hidden;\n position: relative;\n cursor: pointer;\n}\n:host .hemfixarna_description--hidden::after {\n content: \"\";\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n height: 128px;\n background: linear-gradient(180deg, rgba(255, 253, 250, 0), rgba(255, 253, 250, 0.46) 50%, #fffaf2);\n}\n:host .hemfixarna_terms {\n font-size: 14px;\n}\n:host .hemfixarna_terms a {\n color: inherit;\n}\n:host .hemfixarna_logo {\n height: 64px;\n}\n:host .hemfixarna_box {\n padding: 16px;\n display: flex;\n align-items: center;\n width: 100%;\n box-sizing: border-box;\n border-radius: 4px;\n gap: 16px 8px;\n border-radius: 4px;\n gap: 16px 8px;\n}\n:host .hemfixarna_box p,\n:host .hemfixarna_box span {\n font-size: 15px;\n}\n:host .hemfixarna_box .underline {\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n:host .hemfixarna_box .pointer {\n cursor: pointer;\n}\n:host .hemfixarna_box .p-s {\n font-size: 12px;\n}\n:host .hemfixarna_box > div {\n display: grid;\n gap: 8px;\n}\n:host .hemfixarna_box--standard {\n background: #fffaf2;\n border: 1px solid #fcd9c9;\n}\n:host .hemfixarna_box--alternative, :host .hemfixarna_box--alternative_2, :host .hemfixarna_box--alternative_3 {\n background: transparent;\n border: 1px solid #e3e3e3;\n}\n:host .hemfixarna_box--alternative_2, :host .hemfixarna_box--alternative_3 {\n box-shadow: 0px 2px 16px 0px rgba(0, 0, 0, 0.0784313725);\n}\n:host .hemfixarna_box--alternative_3 {\n justify-content: center;\n}\n:host .hemfixarna_altbtn {\n display: flex !important;\n flex-direction: column;\n gap: 8px;\n align-items: center;\n margin-left: auto;\n}\n:host .hemfixarna_btn {\n margin-left: auto;\n}\n:host .hemfixarna_btn, :host .hemfixarna_buy,\n:host .hemfixarna input[type=submit] {\n border: none;\n border-radius: 60px;\n font-weight: 600;\n letter-spacing: 0.5px;\n line-height: 20px;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_btn:not(.disabled):hover, :host .hemfixarna_buy:not(.disabled):hover,\n:host .hemfixarna input[type=submit]:not(.disabled):hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna div:has(> input[type=submit]) {\n position: relative;\n}\n:host .hemfixarna div:has(> input[type=submit]) input {\n cursor: pointer;\n}\n:host .hemfixarna div:has(> input[type=submit]) img {\n display: none;\n}\n:host .hemfixarna .loading {\n cursor: default;\n opacity: 0.6;\n}\n:host .hemfixarna .loading > img {\n display: initial !important;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n:host .hemfixarna_btn {\n font-size: 14px;\n background: #c84e18;\n color: #fff;\n padding: 16px 24px;\n white-space: nowrap;\n position: relative;\n}\n:host .hemfixarna_btn span {\n position: absolute;\n background: #fff;\n border-radius: 100%;\n width: 24px;\n height: 24px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-weight: 600;\n font-size: 13px;\n line-height: 11px;\n top: -6px;\n right: -12px;\n}\n:host .hemfixarna_btn span {\n background: #25a710;\n color: #fff;\n right: 0 !important;\n}\n:host .hemfixarna_buy,\n:host .hemfixarna input[type=submit] {\n font-size: 21px;\n background: #25a710;\n color: #fff;\n padding: 16px 24px;\n}\n:host .hemfixarna .disabled {\n opacity: 0.5;\n cursor: default;\n}\n:host .hemfixarna_modal {\n position: fixed;\n background: #fffaf2;\n border: 1px solid #fcd9c9;\n border-radius: 4px;\n top: 50%;\n left: 50%;\n z-index: 1000;\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n transform: translate(-50%, -50%) scale(0.7);\n opacity: 0;\n height: 92%;\n width: 92%;\n max-width: 920px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n:host .hemfixarna_modal--open {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n}\n:host .hemfixarna_backdrop {\n z-index: 999;\n position: fixed;\n background: #474444;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n opacity: 0;\n transition: transform 0.1s cubic-bezier(0.465, 0.183, 0.153, 0.946), opacity 0.1s cubic-bezier(0.465, 0.183, 0.153, 0.946);\n}\n:host .hemfixarna_backdrop--open {\n opacity: 0.3;\n}\n:host .hemfixarna_order {\n position: absolute;\n top: -1px;\n left: -1px;\n right: -1px;\n bottom: -1px;\n background-repeat: no-repeat !important;\n background-size: cover !important;\n background-position: center !important;\n display: grid;\n grid-template-columns: 1fr 1fr;\n padding: 48px 32px 64px;\n}\n@media (max-width: 768px) {\n :host .hemfixarna_order {\n grid-template-columns: 1fr;\n grid-template-rows: 0 auto;\n }\n}\n:host .hemfixarna_order > div:last-of-type {\n background: #fffaf2;\n padding: 32px;\n display: flex;\n flex-direction: column;\n max-height: 100%;\n overflow: auto;\n}\n:host .hemfixarna_order img {\n cursor: pointer;\n}\n:host .hemfixarna_order button {\n margin: 16px 0;\n padding: 0;\n text-decoration: underline;\n text-underline-offset: 2px;\n font-size: 14px;\n font-weight: 600;\n}\n:host .hemfixarna_cart {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 32px;\n}\n@media (max-width: 768px) {\n :host .hemfixarna_cart {\n grid-template-columns: 1fr;\n gap: 0;\n }\n}\n:host .hemfixarna_cart--right h2, :host .hemfixarna_cart--left h2 {\n display: flex;\n align-items: center;\n}\n:host .hemfixarna_cart--right h2 img, :host .hemfixarna_cart--left h2 img {\n margin-top: 3.2px;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_cart--left h2 button {\n display: none;\n }\n}\n@media (max-width: 768px) {\n :host .hemfixarna_cart--right h2 button {\n display: none;\n }\n}\n:host .hemfixarna_cart--startfee {\n display: flex;\n justify-content: space-between;\n}\n:host .hemfixarna_cart--rutrot {\n display: flex;\n justify-content: space-between;\n}\n:host .hemfixarna_cart--rutrot div {\n display: flex;\n gap: 16px;\n align-items: center;\n}\n:host .hemfixarna_cart--additional {\n display: flex;\n flex-direction: column;\n gap: 16px;\n padding: 16px;\n border-top: 1px solid #fcd9c9;\n}\n:host .hemfixarna_cart--additional p {\n font-size: 14px;\n}\n:host .hemfixarna_cart--additional strong {\n text-decoration: underline;\n text-underline-offset: 2px;\n cursor: pointer;\n position: relative;\n}\n:host .hemfixarna_cart--additional strong img {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n right: -24px;\n}\n:host .hemfixarna_cart--price {\n border-top: 1px solid #fcd9c9;\n padding: 16px;\n display: flex;\n justify-content: space-between;\n}\n:host .hemfixarna_cart--price h3 {\n margin: 0;\n}\n:host .hemfixarna_cart--item {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 16px 0;\n border-top: 1px solid #fcd9c9;\n}\n:host .hemfixarna_cart--item span {\n font-size: 12px;\n}\n:host .hemfixarna_cart--item > div {\n display: flex;\n justify-content: space-between;\n}\n:host .hemfixarna_cart--item > div > div {\n display: flex;\n align-items: center;\n gap: 16px;\n}\n:host .hemfixarna_cart--item > div button {\n color: #ec6632;\n}\n:host .hemfixarna_categories {\n display: flex;\n flex-direction: column;\n gap: 24px;\n}\n:host .hemfixarna_categories--wrapper {\n gap: 32px;\n display: grid;\n grid-template-columns: 1fr 1fr;\n}\n@media (max-width: 768px) {\n :host .hemfixarna_categories--wrapper {\n grid-template-columns: 1fr;\n }\n}\n:host .hemfixarna_categories li {\n position: relative;\n background: #fff;\n border-radius: 4px;\n min-height: 132px;\n padding: 24px;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n display: flex;\n align-items: center;\n gap: 24px;\n cursor: pointer;\n}\n:host .hemfixarna_categories li:hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_categories li > button {\n height: 100%;\n width: 100%;\n}\n:host .hemfixarna_categories li .price {\n font-weight: 700;\n}\n:host .hemfixarna_content {\n height: 100%;\n overflow: auto;\n padding: 0 32px 64px;\n}\n:host .hemfixarna_content--5 {\n padding-top: 16px;\n}\n:host .hemfixarna_content--painting {\n padding: 0;\n overflow: initial;\n}\n:host .hemfixarna_crumbs {\n position: relative;\n padding: 16px 24px;\n border-bottom: 1px solid #fcd9c9;\n display: flex;\n justify-content: space-between;\n}\n:host .hemfixarna_crumbs--back {\n padding: 16px 24px 8px;\n display: flex;\n align-items: center;\n gap: 8px;\n box-shadow: none !important;\n}\n:host .hemfixarna_crumbs--back:hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_crumbs img {\n cursor: pointer;\n}\n:host .hemfixarna_crumbs .close {\n position: absolute;\n right: -16px;\n top: -16px;\n z-index: 9;\n -webkit-transform: translate3d(0, 0, 0);\n}\n:host .hemfixarna_crumbs .cart {\n display: flex;\n padding-left: 16px;\n position: relative;\n}\n:host .hemfixarna_crumbs .cart img {\n cursor: inherit;\n}\n:host .hemfixarna_crumbs .cart span {\n position: absolute;\n background: #fff;\n border-radius: 100%;\n width: 24px;\n height: 24px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-weight: 600;\n font-size: 13px;\n line-height: 11px;\n top: -6px;\n right: -12px;\n}\n:host .hemfixarna_crumbs .cart_active {\n cursor: pointer;\n}\n:host .hemfixarna_crumbs .cart_active span {\n background: #25a710;\n color: #fff;\n}\n:host .hemfixarna_crumbs--links {\n display: flex;\n align-items: center;\n gap: 16px;\n overflow: auto;\n}\n@media (min-width: 769px) {\n :host .hemfixarna_crumbs--links {\n -ms-overflow-style: none;\n }\n :host .hemfixarna_crumbs--links::-webkit-scrollbar {\n display: none;\n }\n :host .hemfixarna_crumbs--links::-webkit-scrollbar-button {\n display: none;\n }\n}\n:host .hemfixarna_crumbs--right {\n display: flex;\n align-items: center;\n}\n:host .hemfixarna_crumbs button {\n white-space: nowrap;\n background: #f1ded6;\n border-radius: 64px;\n padding: 12px 16px;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.3px;\n box-shadow: none !important;\n}\n:host .hemfixarna_crumbs button:not(.active):hover {\n transition: 0.1s all cubic-bezier(0.465, 0.183, 0.153, 0.946);\n filter: brightness(1.02);\n transform: scale(1.01);\n box-shadow: 0px 8px 16px 2px rgba(0, 0, 0, 0.0392156863);\n}\n@media (max-width: 768px) {\n :host .hemfixarna_crumbs button {\n display: none;\n }\n}\n:host .hemfixarna_crumbs .active {\n background: #fffaf2;\n cursor: default;\n}\n:host .hemfixarna_features {\n gap: 12px !important;\n}\n:host .hemfixarna_features li {\n display: flex;\n gap: 16px;\n align-items: center;\n}\n:host .hemfixarna_address {\n margin-bottom: 16px;\n}\n:host .hemfixarna_product {\n display: grid;\n gap: 16px;\n}\n:host .hemfixarna_product--link {\n font-weight: 700;\n color: #474444;\n text-underline-offset: 4px;\n}\n:host .hemfixarna_product--left {\n gap: 32px;\n}\n:host .hemfixarna_product--right {\n gap: 32px;\n}\n:host .hemfixarna_product--price {\n margin-top: 4px;\n font-weight: 700;\n}\n:host .hemfixarna_product--total {\n text-align: center;\n margin: -16px 0;\n font-size: 21px;\n line-height: 28px;\n}\n:host .hemfixarna_product--item {\n background: #fff;\n padding: 16px;\n display: grid;\n grid-template-columns: auto 75px;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.0392156863);\n}\n:host .hemfixarna_product--grid {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 32px;\n}\n@media (max-width: 768px) {\n :host .hemfixarna_product--grid {\n grid-template-columns: 1fr;\n }\n}\n:host .hemfixarna_product--grid > div {\n display: flex;\n flex-direction: column;\n}\n:host .hemfixarna_product--grid ul {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n:host .hemfixarna_product p {\n margin: 0;\n}\n:host .hemfixarna_product--top {\n display: flex;\n gap: 32px;\n}\n:host .hemfixarna_product--top img {\n object-fit: contain;\n}\n:host .hemfixarna_product--top > div {\n width: 100%;\n}\n:host .hemfixarna_product--top > div h1 {\n max-width: 80%;\n}\n@media (max-width: 768px) {\n :host .hemfixarna_product--top > div h1 {\n max-width: 100%;\n }\n}\n:host .hemfixarna_product--top h4 {\n margin-bottom: 8px;\n}\n:host h5,\n:host p {\n margin: 0;\n}\n:host input[type=submit] {\n cursor: pointer;\n}\n:host input[type=date] ~ label {\n left: 56px;\n}\n:host input[type=date] {\n border: 1px solid #fcd9c9;\n padding-left: 64px;\n}\n:host input[type=checkbox] {\n height: 18px;\n width: 18px;\n border: 1px solid #fcd9c9;\n}\n:host input[type=checkbox]:checked {\n background: red;\n}\n:host input[type=date]::-webkit-calendar-picker-indicator {\n background: transparent;\n bottom: 0;\n color: transparent;\n cursor: pointer;\n height: auto;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n width: auto;\n}\n:host button,\n:host a {\n cursor: pointer;\n background: none;\n border: none;\n}\n:host ul {\n list-style: none;\n margin: 0;\n padding: 0;\n}";
602
+
603
+ const HemfixarnaComponent = class {
604
+ constructor(hostRef) {
605
+ registerInstance(this, hostRef);
606
+ this.triggerScrollTotop = () => {
607
+ const el = this.el.shadowRoot.querySelector('.hemfixarna_content');
608
+ scrollToTop(el);
609
+ };
610
+ this.modal = false;
611
+ this.showModal = false;
612
+ this.product = null;
613
+ this.id = undefined;
614
+ this.business = undefined;
615
+ this.widgetStyle = WidgetStyle.standard;
616
+ this.buttonColor = undefined;
617
+ this.buttonBg = undefined;
618
+ this.proppedProduct = null;
619
+ }
620
+ loadCategoryOrProduct(id) {
621
+ this.proppedProduct = null;
622
+ if (id.startsWith('c-')) {
623
+ const categories = [...state.customer.categories, ...state.customer.categories.map(c => { var _a; return (_a = c.sub_categories) !== null && _a !== void 0 ? _a : []; })].flat();
624
+ const category = categories.find(c => c && c.id === id.replace('c-', ''));
625
+ if (category) {
626
+ state.selectedCustomerCategory = category;
627
+ state.step = 2;
628
+ }
629
+ }
630
+ else {
631
+ const products = state.customer.categories
632
+ .map(c => (c.show_products ? c.products : c.sub_categories ? c.sub_categories.map(c => c.products) : []))
633
+ .flat()
634
+ .flat();
635
+ const product = products.find(p => p && p.fields.ID === parseInt(id));
636
+ if (product) {
637
+ state.selectedProduct = product.fields;
638
+ state.step = 4;
639
+ this.proppedProduct = product.fields;
640
+ }
641
+ }
642
+ }
643
+ async watchIdChange(id) {
644
+ if (id && state.customer) {
645
+ if (id === 'maleri') {
646
+ state.maleri = true;
647
+ state.step = 4;
648
+ }
649
+ else {
650
+ this.loadCategoryOrProduct(id);
651
+ }
652
+ }
653
+ }
654
+ async componentWillLoad() {
655
+ state.business = this.business;
656
+ const cart = window.sessionStorage.getItem(`hemfixarna-${this.business}-cart`);
657
+ if (cart) {
658
+ state.cart = JSON.parse(cart);
659
+ }
660
+ const user = window.sessionStorage.getItem(`hemfixarna-${this.business}-user`);
661
+ if (user) {
662
+ state.user = JSON.parse(user);
663
+ }
664
+ const creditSafeUser = window.sessionStorage.getItem(`hemfixarna-${this.business}-creditSafeUser`);
665
+ if (creditSafeUser) {
666
+ state.creditSafeUser = JSON.parse(creditSafeUser);
667
+ }
668
+ const [options, rut, rot, greenDiscount] = await Promise.all([getOptions(), getRut(), getRot(), getGreenDiscount()]);
669
+ try {
670
+ const customer = await getCustomer(this.business);
671
+ if ((customer === null || customer === void 0 ? void 0 : customer.code) === 'not_found') {
672
+ console.warn('customer not found');
673
+ }
674
+ else if (customer) {
675
+ state.customer = customer;
676
+ if (this.id) {
677
+ if (this.id === 'maleri') {
678
+ state.maleri = true;
679
+ state.step = 4;
680
+ }
681
+ else {
682
+ this.loadCategoryOrProduct(this.id);
683
+ }
684
+ }
685
+ }
686
+ }
687
+ catch (error) {
688
+ console.warn('customer not found');
689
+ }
690
+ state.rotOptions = rot;
691
+ state.rutOptions = rut;
692
+ state.greenOptions = greenDiscount;
693
+ state.options = options;
694
+ }
695
+ // Open close modal && click outside event
696
+ openModal() {
697
+ this.modal = true;
698
+ setTimeout(() => {
699
+ this.showModal = true;
700
+ }, 50);
701
+ }
702
+ closeModal() {
703
+ this.showModal = false;
704
+ setTimeout(() => {
705
+ this.modal = false;
706
+ }, 200);
707
+ }
708
+ handleClick(e) {
709
+ if ((e === null || e === void 0 ? void 0 : e.composedPath()[0]).classList.contains('hemfixarna_backdrop')) {
710
+ this.closeModal();
711
+ }
712
+ const infomodal = this.el.shadowRoot.querySelector('.hemfixarna_infomodal');
713
+ if (infomodal) {
714
+ const isClickInside = infomodal.contains(e.composedPath()[0]);
715
+ if (!isClickInside) {
716
+ state.modal = null;
717
+ }
718
+ }
719
+ }
720
+ getCartLength() {
721
+ return state.cart.reduce((acc, curr) => acc + curr.amount, 0);
722
+ }
723
+ render() {
724
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
725
+ const logo = getAssetPath(`./assets/hemfixarna.svg`);
726
+ const pensel = getAssetPath(`./assets/pensel.svg`);
727
+ const monteringLogo = getAssetPath(`./assets/montering.svg`);
728
+ return (h("div", { class: "hemfixarna" }, h("div", { class: `hemfixarna_box hemfixarna_box--${this.widgetStyle}` }, [WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) ? (h("img", { src: this.id === 'maleri' ? pensel : monteringLogo, alt: "montering logo", width: 32, height: 32 })) : null, h("div", null, h("div", null, h("p", { onClick: () => this.openModal(), class: `pointer ${[WidgetStyle.alternative_2, WidgetStyle.alternative_3].includes(this.widgetStyle) && state.selectedProduct ? 'underline' : ''}` }, this.id === 'maleri' ? (h("span", null, "Ber\u00E4kna fast pris p\u00E5 m\u00E5leri & tapetsering h\u00E4r")) : (h(Fragment, null, !state.selectedCustomerCategory && !this.product && !this.proppedProduct ? (h(Fragment, null, ((_a = state.customer) === null || _a === void 0 ? void 0 : _a.widget_title) ? (h("span", null, state.customer.widget_title)) : (h("span", null, "Montering/Installation - ", h("strong", { class: "underline" }, "se priser h\u00E4r"))))) : (h(Fragment, null, ((_b = this.product) === null || _b === void 0 ? void 0 : _b.title) || ((_c = this.proppedProduct) === null || _c === void 0 ? void 0 : _c.title) || ((_d = state.selectedCustomerCategory) === null || _d === void 0 ? void 0 : _d.widget_title) || (h("span", null, "Montering", h("wbr", null), "/Installation ", (_f = (_e = state.selectedCustomerCategory) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : 'på plats', " - ", h("strong", { class: "underline" }, "se priser h\u00E4r"))), this.proppedProduct && !((_g = this.product) === null || _g === void 0 ? void 0 : _g.invoice) && !((_h = this.proppedProduct) === null || _h === void 0 ? void 0 : _h.invoice) ? (h("span", null, ' från', " ", h("strong", null, getProductPriceWithRotAndRut(this.proppedProduct || this.product), "kr"))) : null)))))), this.widgetStyle === WidgetStyle.standard ? h("img", { src: logo, width: 104 }) : null, this.widgetStyle === WidgetStyle.alternative ? (h("span", { class: "p-s" }, "Utf\u00F6rs av ", h("strong", null, "Hemfixarna"))) : null), [WidgetStyle.standard, WidgetStyle.alternative].includes(this.widgetStyle) ? (h("button", { onClick: () => this.openModal(), class: "hemfixarna_btn", style: {
729
+ color: ((_j = this.buttonColor) === null || _j === void 0 ? void 0 : _j.startsWith('#')) || !((_k = this.buttonColor) === null || _k === void 0 ? void 0 : _k.length) ? this.buttonColor : `#${this.buttonColor}`,
730
+ backgroundColor: ((_l = this.buttonBg) === null || _l === void 0 ? void 0 : _l.startsWith('#')) || !((_m = this.buttonBg) === null || _m === void 0 ? void 0 : _m.length) ? this.buttonBg : `#${this.buttonBg}`,
731
+ } }, "Best\u00E4ll h\u00E4r", this.getCartLength() > 0 && h("span", null, this.getCartLength()))) : null, WidgetStyle.alternative_2 === this.widgetStyle ? (h("div", { class: "hemfixarna_altbtn" }, h("strong", { class: "p-s" }, "Utf\u00F6rs av"), h("img", { src: logo, alt: "hemfixarna logo", width: 98 }))) : null), this.modal && (h("div", null, h("div", { class: `hemfixarna_modal ${this.showModal ? 'hemfixarna_modal--open' : ''}` }, state.modal && (h("div", { class: "hemfixarna_infomodal" }, state.modal.title && h("h2", null, state.modal.title), state.modal.text.map((t) => (h("p", { innerHTML: t }))), h("div", null, h("button", { onClick: () => (state.modal = null) }, "St\u00E4ng")))), state.customer && h("hemfixarna-breadcrumbs", { closeModal: () => this.closeModal() }), h("div", { class: `hemfixarna_content hemfixarna_content--${state.step} ${state.step === 4 && state.maleri ? 'hemfixarna_content--painting' : ''}` }, state.step < 4 && h("hemfixarna-start", null), state.step === 4 && h("hemfixarna-product", null), state.step === 5 && h("hemfixarna-cart", null), state.step === 6 && h("hemfixarna-order", null))), h("div", { class: `hemfixarna_backdrop ${this.showModal ? 'hemfixarna_backdrop--open' : ''}` })))));
732
+ }
733
+ static get assetsDirs() { return ["assets"]; }
734
+ get el() { return getElement(this); }
735
+ static get watchers() { return {
736
+ "id": ["watchIdChange"]
737
+ }; }
738
+ };
739
+ HemfixarnaComponent.style = hemfixarnaCss;
740
+
741
+ const HemfixarnaInfo$1 = class {
742
+ constructor(hostRef) {
743
+ registerInstance(this, hostRef);
744
+ this.vertical = false;
745
+ }
746
+ render() {
747
+ return (h("div", { class: `hemfixarna_contact ${this.vertical ? 'hemfixarna_contact--vertical' : 'hemfixarna_contact--horizontal'}` }, h("a", { href: "tel:0770-220 720" }, h("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { d: "M7 4V20H17V4H7ZM6 2H18C18.5523 2 19 2.44772 19 3V21C19 21.5523 18.5523 22 18 22H6C5.44772 22 5 21.5523 5 21V3C5 2.44772 5.44772 2 6 2ZM12 17C12.5523 17 13 17.4477 13 18C13 18.5523 12.5523 19 12 19C11.4477 19 11 18.5523 11 18C11 17.4477 11.4477 17 12 17Z", fill: "#C84E18" })), h("span", null, "0770-220 720")), h("a", { href: "https://hemfixarna.se/kundservice/", target: "_blank" }, h("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("g", { "clip-path": "url(#clip0_1001_894)" }, h("path", { d: "M21 12.22C21 6.73 16.74 3 12 3C7.31 3 3 6.65 3 12.28C2.4 12.62 2 13.26 2 14V16C2 17.1 2.9 18 4 18H5V11.9C5 8.03 8.13 4.9 12 4.9C15.87 4.9 19 8.03 19 11.9V19H11V21H19C20.1 21 21 20.1 21 19V17.78C21.59 17.47 22 16.86 22 16.14V13.84C22 13.14 21.59 12.53 21 12.22Z", fill: "#C84E18" }), h("path", { d: "M9 14C9.55228 14 10 13.5523 10 13C10 12.4477 9.55228 12 9 12C8.44772 12 8 12.4477 8 13C8 13.5523 8.44772 14 9 14Z", fill: "#C84E18" }), h("path", { d: "M15 14C15.5523 14 16 13.5523 16 13C16 12.4477 15.5523 12 15 12C14.4477 12 14 12.4477 14 13C14 13.5523 14.4477 14 15 14Z", fill: "#C84E18" }), h("path", { d: "M18 11.03C17.52 8.18 15.04 6 12.05 6C9.01997 6 5.75997 8.51 6.01997 12.45C8.48997 11.44 10.35 9.24 10.88 6.56C12.19 9.19 14.88 11 18 11.03Z", fill: "#C84E18" })), h("defs", null, h("clipPath", { id: "clip0_1001_894" }, h("rect", { width: "24", height: "24", fill: "white" })))), h("span", null, "Kundservice"))));
748
+ }
749
+ };
750
+
751
+ const hemfixarnaDemoCss = "@import url(\"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap\"); :host{font-family:\"Inter\", sans-serif}:host .hemfixarna_widgetstyles label{cursor:pointer}:host .hemfixarna_widgetstyles>div{display:flex;gap:1rem}:host .hemfixarna_widgetstyles h5{margin:1rem 0}:host .hemfixarna_example{margin-bottom:16px;background:#000;padding:16px;color:#fff;display:flex;justify-content:space-between;cursor:pointer;max-width:500px;box-sizing:border-box;position:relative}:host .hemfixarna_example--tooltip{background:#000;top:-48px;font-size:16px;left:40%;color:white;padding:8px;position:absolute;opacity:0}:host .hemfixarna_example--tooltip::after{content:\"\";position:absolute;top:100%;left:50%;margin-left:-5px;border-width:5px;border-style:solid;border-color:#000 transparent transparent transparent}:host .hemfixarna_example:hover .hemfixarna_example--tooltip{opacity:1}:host .hemfixarna_example p{font-size:14px}:host .hemfixarna_example img{filter:invert(1)}:host .hemfixarna_install{display:grid;gap:8px;margin-top:16px}:host .hemfixarna_product--label{background:#e1e0f5}:host .hemfixarna_categories{max-height:100%;overflow:auto;position:relative}:host .hemfixarna_categories--label{display:flex;align-items:center;justify-content:space-between;padding:8px}:host .hemfixarna_categories--label button{background:#3f3a92;border:none;font-weight:600;padding:3.2px 9.6px;border-radius:10px;margin-right:8px;color:#ece8e8}:host .hemfixarna_categories--label button:active{transform:scale(0.95)}:host .hemfixarna_categories--label--big{font-weight:600;border-bottom:1px solid black}:host p{margin:0}:host span{color:darkolivegreen;font-size:10px}:host button{cursor:pointer}:host>div:not(.hemfixarna_hosted){grid-template-columns:1fr 1fr}:host .hemfixarna_hosted .hemfixarna_scripts{display:none}:host>div{display:grid;gap:32px;width:100%;height:100vh;place-items:center;overflow:hidden;padding:16px 32px;box-sizing:border-box}:host>div>*{width:100%}:host>div>div{max-width:500px}:host>div ul{margin:0;padding:0;list-style:none}:host>div ul ul{gap:1px;display:grid}:host>div ul li{padding-left:16px;background:#fff}";
752
+
753
+ const MyComponent = class {
754
+ constructor(hostRef) {
755
+ registerInstance(this, hostRef);
756
+ this.debounce = null;
757
+ this.cdnLink = '<script type="module" src="https://cdn.jsdelivr.net/npm//hemfixarna-web-components@latest/dist/hemfixarna-components/hemfixarna-components.esm.js"></script>';
758
+ this.selectedSlug = undefined;
759
+ this.selectedID = undefined;
760
+ this.tooltipText = 'Kopiera till urklipp';
761
+ this.tree = null;
762
+ this.customer = null;
763
+ this.widgetStyle = WidgetStyle.standard;
764
+ this.buttonBg = '';
765
+ this.buttonColor = '';
766
+ this.partner = undefined;
767
+ this.colorAccessibility = undefined;
768
+ this.loggedIn = false;
769
+ this.loginError = false;
770
+ }
771
+ debouncedFunction() {
772
+ if (this.debounce !== null) {
773
+ clearTimeout(this.debounce);
774
+ this.debounce = null;
775
+ }
776
+ this.debounce = window.setTimeout(() => {
777
+ this.checkColorAccessibility();
778
+ this.debounce = null;
779
+ }, 1500);
780
+ }
781
+ async checkColorAccessibility() {
782
+ const defaultTextColor = '#fff';
783
+ const defaultBgColor = '#c84e18';
784
+ const firstColor = this.buttonBg.length ? (this.buttonBg.startsWith('#') ? this.buttonBg : `#${this.buttonBg}`) : defaultBgColor;
785
+ const secondColor = this.buttonColor.length ? (this.buttonColor.startsWith('#') ? this.buttonColor : `#${this.buttonColor}`) : defaultTextColor;
786
+ try {
787
+ const response = await fetch('https://www.aremycolorsaccessible.com/api/are-they', {
788
+ mode: 'cors',
789
+ method: 'POST',
790
+ body: JSON.stringify({ colors: [firstColor, secondColor] }),
791
+ });
792
+ if (!response) {
793
+ throw new Error('Network response was not ok');
794
+ }
795
+ const json = await response.json();
796
+ if (json && (json)) {
797
+ this.colorAccessibility = json;
798
+ }
799
+ }
800
+ catch (error) {
801
+ console.warn('Error fetching color accessibility:', error);
802
+ }
803
+ }
804
+ getColor(rating) {
805
+ switch (rating) {
806
+ case 'AAA':
807
+ return 'green';
808
+ case 'AA':
809
+ return 'orange';
810
+ case 'A':
811
+ return 'yellow';
812
+ case 'Fail':
813
+ return 'red';
814
+ default:
815
+ return 'black';
816
+ }
817
+ }
818
+ async componentWillLoad() {
819
+ const partner = window.location.pathname.replace('/', '');
820
+ if (!isBusiness(partner) && partner)
821
+ return;
822
+ this.partner = partner ? partner : Business.kund;
823
+ const customer = await getCustomer(this.partner);
824
+ if (customer.code !== 'not_found' && customer) {
825
+ this.customer = customer;
826
+ if (!this.customer.password_protected || window.localStorage.getItem(`${this.customer.ID}-loggedin`)) {
827
+ this.loggedIn = true;
828
+ }
829
+ }
830
+ }
831
+ getExample() {
832
+ return `<hemfixarna-component business="${this.partner}"${this.selectedSlug ? ` slug="${this.selectedSlug}" ` : ''}${this.selectedID ? ` id="${this.selectedID}" ` : ''} ${this.widgetStyle === WidgetStyle.standard ? '' : `widget-style="${this.widgetStyle}"`} ${this.buttonColor.length ? `button-color="${this.buttonColor}"` : ''} ${this.buttonBg.length ? `button-bg="${this.buttonBg}"` : ''}></hemfixarna-component>`;
833
+ }
834
+ copyExample() {
835
+ navigator.clipboard.writeText(this.getExample());
836
+ this.tooltipText = 'Snippet kopierad';
837
+ setTimeout(() => {
838
+ this.tooltipText = 'Kopiera till urklipp';
839
+ }, 2000);
840
+ }
841
+ copyCdn() {
842
+ navigator.clipboard.writeText(this.cdnLink);
843
+ this.tooltipText = 'Text kopierad';
844
+ setTimeout(() => {
845
+ this.tooltipText = 'Kopiera till urklipp';
846
+ }, 2000);
847
+ }
848
+ copyNpmInstall() {
849
+ navigator.clipboard.writeText('npm i hemfixarna-web-components');
850
+ this.tooltipText = 'Text kopierad';
851
+ setTimeout(() => {
852
+ this.tooltipText = 'Kopiera till urklipp';
853
+ }, 2000);
854
+ }
855
+ showMaleri() {
856
+ var _a;
857
+ const allCategories = (_a = this.customer) === null || _a === void 0 ? void 0 : _a.categories.map(c => (c.sub_categories ? c.sub_categories : c)).flat();
858
+ return allCategories === null || allCategories === void 0 ? void 0 : allCategories.some(c => c.add_painting);
859
+ }
860
+ async handleLogin() {
861
+ const shadowHost = document.querySelector('hemfixarna-demo');
862
+ const shadowRoot = shadowHost.shadowRoot;
863
+ const passwordInput = shadowRoot.querySelector('input[type="password"]');
864
+ const password = passwordInput.value;
865
+ this.loginError = false;
866
+ try {
867
+ const status = await loginCustomer({ id: this.customer.ID, password: password });
868
+ if (status === 200) {
869
+ this.loggedIn = true;
870
+ window.localStorage.setItem(`${this.customer.ID}-loggedin`, 'true');
871
+ }
872
+ else {
873
+ this.loginError = true;
874
+ }
875
+ }
876
+ catch (error) {
877
+ console.log(error);
878
+ this.loginError = true;
879
+ }
880
+ }
881
+ render() {
882
+ var _a;
883
+ const copy = getAssetPath(`./assets/copy.png`);
884
+ return this.customer ? (h(Fragment, null, this.loggedIn ? (h("div", { class: ((_a = this.customer) === null || _a === void 0 ? void 0 : _a.at_hemfixarna) ? 'hemfixarna_hosted' : '' }, h("div", { class: "hemfixarna_scripts" }, h("div", { onClick: () => this.copyExample(), class: "hemfixarna_example" }, h("p", null, this.getExample()), h("img", { src: copy, height: 20 }), h("span", { class: "hemfixarna_example--tooltip" }, this.tooltipText)), h("hemfixarna-component", { business: this.partner, buttonBg: this.buttonBg, buttonColor: this.buttonColor, widgetStyle: this.widgetStyle, id: this.selectedID }), h("div", { class: "hemfixarna_install" }, h("div", { onClick: () => this.copyCdn(), class: "hemfixarna_example" }, h("p", null, this.cdnLink), h("span", { class: "hemfixarna_example--tooltip" }, this.tooltipText), h("img", { src: copy, height: 20 }))), h("div", { class: "hemfixarna_widgetstyles" }, h("h5", null, "Widget styles"), h("div", null, Object.values(WidgetStyle).map(style => (h("label", { key: style }, h("input", { type: "radio", value: style, checked: this.widgetStyle === style, onChange: () => (this.widgetStyle = style) }), style)))), h("div", null, h("div", null, h("h5", null, "Button background color"), h("input", { type: "text", value: this.buttonBg, onInput: e => (this.buttonBg = e.target.value) })), h("div", null, h("h5", null, "Button text color"), h("input", { type: "text", value: this.buttonColor, onInput: e => (this.buttonColor = e.target.value) })))), h("span", null, "Write an hexa code no # needed"), this.colorAccessibility ? (h("div", null, h("h5", null, "Tillg\u00E4nglighetsrapport"), h("div", null, h("strong", null, "Liten text:"), h("span", { style: { color: this.getColor(this.colorAccessibility.small) } }, this.colorAccessibility.small), h("br", null), h("strong", null, "Fet text:"), h("span", { style: { color: this.getColor(this.colorAccessibility.bold) } }, this.colorAccessibility.bold), h("br", null), h("strong", null, "Stor text:"), h("span", { style: { color: this.getColor(this.colorAccessibility.large) } }, this.colorAccessibility.large), h("br", null), h("strong", null, "Kontrastf\u00F6rh\u00E5llande:"), " ", this.colorAccessibility.contrast))) : null), h("ul", { class: "hemfixarna_categories" }, h("div", null, this.customer.logo ? (h("div", { style: { width: '100%', display: 'flex', justifyContent: 'center' } }, h("img", { style: { maxWidth: '250px', height: 'auto', margin: '0 auto 2rem' }, src: this.customer.logo.url, alt: this.customer.post_title }))) : null, this.showMaleri() ? (h("li", null, h("div", { class: "hemfixarna_categories--label hemfixarna_categories--label--big" }, h("div", null, h("p", null, "M\u00E5leriverktyget"), h("span", null, "maleri")), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText('maleri') }, "Kopiera ID"), this.customer.at_hemfixarna ? (h("button", { onClick: () => navigator.clipboard.writeText(`${getApiUrl()}/partner/${this.customer.post_name}?id=maleri`) }, "Kopiera URL")) : (h("button", { onClick: () => (this.selectedID = 'maleri') }, "Ladda m\u00E5leri")))))) : null, this.customer.categories.map(c => (h("li", null, h("div", { class: "hemfixarna_categories--label hemfixarna_categories--label--big" }, h("div", null, h("p", null, c.name), h("span", null, `c-${c.id}`)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(`c-${c.id}`) }, "Kopiera ID"), this.customer.at_hemfixarna ? (h("button", { onClick: () => navigator.clipboard.writeText(`${getApiUrl()}/partner/${this.customer.post_name}?id=c-${c.id}`) }, "Kopiera URL")) : (h("button", { onClick: () => (this.selectedID = `c-${c.id}`) }, "Ladda kategori")))), c.show_products && c.products ? (h("ul", null, c.products.map(p => (h("li", null, h("div", { class: "hemfixarna_categories--label hemfixarna_product--label" }, h("div", null, h("p", null, p.fields.title), h("span", null, p.fields.ID)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(String(p.fields.ID)) }, "Kopiera ID"), this.customer.at_hemfixarna ? (h("button", { onClick: () => navigator.clipboard.writeText(`${getApiUrl()}/partner/${this.customer.post_name}?id=${p.fields.ID}`) }, "Kopiera URL")) : (h("button", { onClick: () => (this.selectedID = String(p.fields.ID)) }, "Ladda produkt"))))))))) : (h("ul", null, c.sub_categories &&
885
+ c.sub_categories.map(sc => (h("li", null, h("div", { class: "hemfixarna_categories--label" }, h("div", null, h("p", null, sc.name), h("span", null, `c-${sc.id}`)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(`c-${sc.id}`) }, "Kopiera ID"), this.customer.at_hemfixarna ? (h("button", { onClick: () => navigator.clipboard.writeText(`${getApiUrl()}/partner/${this.customer.post_name}?id=c-${c.id}`) }, "Kopiera URL")) : (h("button", { onClick: () => (this.selectedID = `c-${sc.id}`) }, "Ladda kategori")))), h("ul", null, sc.products.map(p => (h("li", null, h("div", { class: "hemfixarna_categories--label hemfixarna_product--label" }, h("div", null, h("p", null, p.fields.title), h("span", null, p.fields.ID)), h("div", null, h("button", { onClick: () => navigator.clipboard.writeText(String(p.fields.ID)) }, "Kopiera ID"), this.customer.at_hemfixarna ? (h("button", { onClick: () => navigator.clipboard.writeText(`${getApiUrl()}/partner/${this.customer.post_name}?id=${p.fields.ID}`) }, "Kopiera URL")) : (h("button", { onClick: () => (this.selectedID = String(p.fields.ID)) }, "Ladda produkt")))))))))))))))))))) : (h("div", null, h("form", { onSubmit: e => {
886
+ e.preventDefault();
887
+ this.handleLogin();
888
+ }, style: {
889
+ display: 'flex',
890
+ flexDirection: 'column',
891
+ gap: '1rem',
892
+ maxWidth: '300px',
893
+ margin: 'auto',
894
+ padding: '20px',
895
+ border: '1px solid #ccc',
896
+ borderRadius: '5px',
897
+ gridColumn: 'span 2',
898
+ } }, h("input", { type: "password", placeholder: "L\u00F6senord" }), h("button", { type: "submit" }, "Logga in"), this.loginError && h("span", null, "Fel l\u00F6senord")))))) : (h("h1", { style: {
899
+ textAlign: 'center',
900
+ margin: 'auto',
901
+ padding: '20px',
902
+ fontSize: '24px',
903
+ fontWeight: 'bold',
904
+ color: 'red',
905
+ } }, "No customer found"));
906
+ }
907
+ static get watchers() { return {
908
+ "buttonBg": ["debouncedFunction"],
909
+ "buttonColor": ["debouncedFunction"]
910
+ }; }
911
+ };
912
+ MyComponent.style = hemfixarnaDemoCss;
913
+
914
+ // src/errors.ts
915
+ var PersonnummerError = class extends Error {
916
+ constructor() {
917
+ super("Invalid swedish personal identity number");
918
+ }
919
+ };
920
+
921
+ // src/utils.ts
922
+ var compareAsc = (dateLeft, dateRight) => {
923
+ const diff = dateLeft.getTime() - dateRight.getTime();
924
+ return diff < 0 ? -1 : diff > 0 ? 1 : diff;
925
+ };
926
+ var diffInYears = (dateLeft, dateRight) => {
927
+ const sign = compareAsc(dateLeft, dateRight);
928
+ const yearDiff = Math.abs(dateLeft.getFullYear() - dateRight.getFullYear());
929
+ dateLeft.setFullYear(dateLeft.getFullYear() - sign * yearDiff);
930
+ const isLastYearNotFull = compareAsc(dateLeft, dateRight) === -sign;
931
+ const result = sign * (yearDiff - +isLastYearNotFull);
932
+ return result === 0 ? 0 : result;
933
+ };
934
+ var luhn = (str) => {
935
+ let sum = 0;
936
+ str += "";
937
+ for (let i = 0, l = str.length; i < l; i++) {
938
+ let v = parseInt(str[i]);
939
+ v *= 2 - i % 2;
940
+ if (v > 9) {
941
+ v -= 9;
942
+ }
943
+ sum += v;
944
+ }
945
+ return Math.ceil(sum / 10) * 10 - sum;
946
+ };
947
+ var testDate = (year, month, day) => {
948
+ month -= 1;
949
+ const date = new Date(year, month, day);
950
+ return !(date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day);
951
+ };
952
+
953
+ // src/index.ts
954
+ var Personnummer = class {
955
+ /**
956
+ * Personnummer constructor.
957
+ *
958
+ * @param {string} pin
959
+ * @param {object} options
960
+ */
961
+ constructor(pin, options) {
962
+ /**
963
+ * Personnummer century.
964
+ *
965
+ * @var {string}
966
+ */
967
+ this._century = "";
968
+ /**
969
+ * Personnummer full year.
970
+ *
971
+ * @var {string}
972
+ */
973
+ this._fullYear = "";
974
+ /**
975
+ * Personnummer year.
976
+ *
977
+ * @var {string}
978
+ */
979
+ this._year = "";
980
+ /**
981
+ * Personnummer month.
982
+ *
983
+ * @var {string}
984
+ */
985
+ this._month = "";
986
+ /**
987
+ * Personnummer day.
988
+ *
989
+ * @var {string}
990
+ */
991
+ this._day = "";
992
+ /**
993
+ * Personnummer seperator.
994
+ *
995
+ * @var {string}
996
+ */
997
+ this._sep = "";
998
+ /**
999
+ * Personnumer first three of the last four numbers.
1000
+ *
1001
+ * @var {string}
1002
+ */
1003
+ this._num = "";
1004
+ /**
1005
+ * The last number of the personnummer.
1006
+ *
1007
+ * @var {string}
1008
+ */
1009
+ this._check = "";
1010
+ this.parse(pin, {
1011
+ allowCoordinationNumber: true,
1012
+ allowInterimNumber: false,
1013
+ ...options
1014
+ });
1015
+ }
1016
+ /**
1017
+ * Get century.
1018
+ *
1019
+ * @return {string}
1020
+ */
1021
+ get century() {
1022
+ return this._century;
1023
+ }
1024
+ /**
1025
+ * Get age.
1026
+ *
1027
+ * @return {string}
1028
+ */
1029
+ get fullYear() {
1030
+ return this._fullYear;
1031
+ }
1032
+ /**
1033
+ * Get age.
1034
+ *
1035
+ * @return {string}
1036
+ */
1037
+ get year() {
1038
+ return this._year;
1039
+ }
1040
+ /**
1041
+ * Get month.
1042
+ *
1043
+ * @return {string}
1044
+ */
1045
+ get month() {
1046
+ return this._month;
1047
+ }
1048
+ /**
1049
+ * Get day.
1050
+ *
1051
+ * @return {string}
1052
+ */
1053
+ get day() {
1054
+ return this._day;
1055
+ }
1056
+ /**
1057
+ * Get sep.
1058
+ *
1059
+ * @return {string}
1060
+ */
1061
+ get sep() {
1062
+ return this._sep;
1063
+ }
1064
+ /**
1065
+ * Get num.
1066
+ *
1067
+ * @return {string}
1068
+ */
1069
+ get num() {
1070
+ return this._num;
1071
+ }
1072
+ /**
1073
+ * Get check.
1074
+ *
1075
+ * @return {string}
1076
+ */
1077
+ get check() {
1078
+ return this._check;
1079
+ }
1080
+ /**
1081
+ * Parse personnummer.
1082
+ *
1083
+ * @param {string} pin
1084
+ * @param {object} options
1085
+ *
1086
+ * @return {Personnummer}
1087
+ */
1088
+ static parse(pin, options) {
1089
+ return new Personnummer(pin, options);
1090
+ }
1091
+ /**
1092
+ * Validate a Swedish personal identity number.
1093
+ *
1094
+ * @param {string} str
1095
+ * @param {object} options
1096
+ *
1097
+ * @return {boolean}
1098
+ */
1099
+ static valid(pin, options) {
1100
+ try {
1101
+ Personnummer.parse(pin, options);
1102
+ return true;
1103
+ } catch (e) {
1104
+ return false;
1105
+ }
1106
+ }
1107
+ /**
1108
+ * Parse personnummer and set class properties.
1109
+ *
1110
+ * @param {string} pin
1111
+ * @param {object} options
1112
+ */
1113
+ parse(pin, options) {
1114
+ if (pin.length < 10 || pin.length > 13) {
1115
+ throw new PersonnummerError();
1116
+ }
1117
+ const reg = /^(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([+-]?)((?!000)\d{3}|[TRSUWXJKLMN]\d{2})(\d)$/;
1118
+ const match = reg.exec(pin);
1119
+ if (!match) {
1120
+ throw new PersonnummerError();
1121
+ }
1122
+ const century = match[1];
1123
+ const year = match[2];
1124
+ const month = match[3];
1125
+ const day = match[4];
1126
+ const sep = match[5];
1127
+ const num = match[6];
1128
+ const check = match[7];
1129
+ if (typeof century === "undefined" || !century.length) {
1130
+ const d = /* @__PURE__ */ new Date();
1131
+ let baseYear = 0;
1132
+ if (sep === "+") {
1133
+ this._sep = "+";
1134
+ baseYear = d.getFullYear() - 100;
1135
+ } else {
1136
+ this._sep = "-";
1137
+ baseYear = d.getFullYear();
1138
+ }
1139
+ this._century = ("" + (baseYear - (baseYear - parseInt(year)) % 100)).substr(0, 2);
1140
+ } else {
1141
+ this._century = century;
1142
+ if ((/* @__PURE__ */ new Date()).getFullYear() - parseInt(century + year, 10) < 100) {
1143
+ this._sep = "-";
1144
+ } else {
1145
+ this._sep = "+";
1146
+ }
1147
+ }
1148
+ this._year = year;
1149
+ this._fullYear = this._century + year;
1150
+ this._month = month;
1151
+ this._day = day;
1152
+ this._num = num;
1153
+ this._check = check;
1154
+ if (!this.valid()) {
1155
+ throw new PersonnummerError();
1156
+ }
1157
+ if (!(options == null ? void 0 : options.allowCoordinationNumber) && this.isCoordinationNumber()) {
1158
+ throw new PersonnummerError();
1159
+ }
1160
+ if (!(options == null ? void 0 : options.allowInterimNumber) && this.isInterimNumber()) {
1161
+ throw new PersonnummerError();
1162
+ }
1163
+ }
1164
+ /**
1165
+ * Validate a Swedish personal identity number.
1166
+ *
1167
+ * @return {boolean}
1168
+ */
1169
+ valid() {
1170
+ const valid = luhn(
1171
+ this.year + this.month + this.day + this.num.replace(/[TRSUWXJKLMN]/, "1")
1172
+ ) === +this.check && !!this.check;
1173
+ if (valid && testDate(parseInt(this.century + this.year), +this.month, +this.day)) {
1174
+ return valid;
1175
+ }
1176
+ return valid && testDate(parseInt(this.century + this.year), +this.month, +this.day - 60);
1177
+ }
1178
+ /**
1179
+ * Format a Swedish personal identity number as one of the official formats,
1180
+ * A long format or a short format.
1181
+ *
1182
+ * If the input number could not be parsed a empty string will be returned.
1183
+ *
1184
+ * @param {boolean} longFormat
1185
+ *
1186
+ * @return {string}
1187
+ */
1188
+ format(longFormat = false) {
1189
+ if (longFormat) {
1190
+ return `${this.century}${this.year}${this.month}${this.day}${this.num}${this.check}`;
1191
+ }
1192
+ return `${this.year}${this.month}${this.day}${this.sep}${this.num}${this.check}`;
1193
+ }
1194
+ /**
1195
+ * Get age from a Swedish personal identity number.
1196
+ *
1197
+ * @return {number}
1198
+ */
1199
+ getAge() {
1200
+ const date = this.getDate();
1201
+ return diffInYears(new Date(Date.now()), date);
1202
+ }
1203
+ /**
1204
+ * Get date from a Swedish personal identity number.
1205
+ *
1206
+ * @return {Date}
1207
+ */
1208
+ getDate() {
1209
+ let ageDay = +this.day;
1210
+ if (this.isCoordinationNumber()) {
1211
+ ageDay -= 60;
1212
+ }
1213
+ const ageDate = this.century + this.year + "-" + this.month + "-" + (ageDay < 10 ? "0" + ageDay : ageDay);
1214
+ return new Date(ageDate);
1215
+ }
1216
+ /**
1217
+ * Check if a Swedish personal identity number is a interim number or not.
1218
+ *
1219
+ * @return {boolean}
1220
+ */
1221
+ isInterimNumber() {
1222
+ return /[TRSUWXJKLMN]/.test(this.num[0]);
1223
+ }
1224
+ /**
1225
+ * Check if a Swedish personal identity number is a coordination number or not.
1226
+ *
1227
+ * @return {boolean}
1228
+ */
1229
+ isCoordinationNumber() {
1230
+ return testDate(
1231
+ parseInt(this.century + this.year),
1232
+ +this.month,
1233
+ +this.day - 60
1234
+ );
1235
+ }
1236
+ /**
1237
+ * Check if a Swedish personal identity number is for a female.
1238
+ *
1239
+ * @return {boolean}
1240
+ */
1241
+ isFemale() {
1242
+ return !this.isMale();
1243
+ }
1244
+ /**
1245
+ * Check if a Swedish personal identity number is for a male.
1246
+ *
1247
+ * @return {boolean}
1248
+ */
1249
+ isMale() {
1250
+ const sexDigit = parseInt(this.num.substr(-1));
1251
+ return sexDigit % 2 === 1;
1252
+ }
1253
+ };
1254
+ var src_default = Personnummer;
1255
+
1256
+ function createCommonjsModule(fn, basedir, module) {
1257
+ return module = {
1258
+ path: basedir,
1259
+ exports: {},
1260
+ require: function (path, base) {
1261
+ return commonjsRequire();
1262
+ }
1263
+ }, fn(module, module.exports), module.exports;
1264
+ }
1265
+
1266
+ function commonjsRequire () {
1267
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
1268
+ }
1269
+
1270
+ var utf8 = createCommonjsModule(function (module, exports) {
1271
+ // tslint:disable:no-bitwise
1272
+ Object.defineProperty(exports, "__esModule", { value: true });
1273
+ exports.utf8 = void 0;
1274
+ exports.utf8 = {
1275
+ encode: encode,
1276
+ decode: decode,
1277
+ };
1278
+ function encode(unicodeText) {
1279
+ unicodeText = unicodeText.replace(/\r\n/g, "\n");
1280
+ var result = "";
1281
+ for (var i = 0; i < unicodeText.length; i++) {
1282
+ var char = unicodeText.charCodeAt(i);
1283
+ if (char < 128) {
1284
+ result += String.fromCharCode(char);
1285
+ }
1286
+ else if (char > 127 && char < 2048) {
1287
+ result += String.fromCharCode((char >> 6) | 192);
1288
+ result += String.fromCharCode((char & 63) | 128);
1289
+ }
1290
+ else {
1291
+ result += String.fromCharCode((char >> 12) | 224);
1292
+ result += String.fromCharCode(((char >> 6) & 63) | 128);
1293
+ result += String.fromCharCode((char & 63) | 128);
1294
+ }
1295
+ }
1296
+ return result;
1297
+ }
1298
+ function decode(utf8Text) {
1299
+ var result = "";
1300
+ var i = 0;
1301
+ var char1 = 0;
1302
+ var char2 = 0;
1303
+ var char3 = 0;
1304
+ while (i < utf8Text.length) {
1305
+ char1 = utf8Text.charCodeAt(i);
1306
+ if (char1 < 128) {
1307
+ result += String.fromCharCode(char1);
1308
+ i++;
1309
+ }
1310
+ else if (char1 > 191 && char1 < 224) {
1311
+ char2 = utf8Text.charCodeAt(i + 1);
1312
+ result += String.fromCharCode(((char1 & 31) << 6) | (char2 & 63));
1313
+ i += 2;
1314
+ }
1315
+ else {
1316
+ char2 = utf8Text.charCodeAt(i + 1);
1317
+ char3 = utf8Text.charCodeAt(i + 2);
1318
+ result += String.fromCharCode(((char1 & 15) << 12) | ((char2 & 63) << 6) | (char3 & 63));
1319
+ i += 3;
1320
+ }
1321
+ }
1322
+ return result;
1323
+ }
1324
+ });
1325
+
1326
+ var md5 = createCommonjsModule(function (module, exports) {
1327
+ // tslint:disable:no-bitwise
1328
+ Object.defineProperty(exports, "__esModule", { value: true });
1329
+ exports.generate = void 0;
1330
+
1331
+ function generate(unicodeText) {
1332
+ var x = [];
1333
+ var k;
1334
+ var AA;
1335
+ var BB;
1336
+ var CC;
1337
+ var DD;
1338
+ var a;
1339
+ var b;
1340
+ var c;
1341
+ var d;
1342
+ var S11 = 7;
1343
+ var S12 = 12;
1344
+ var S13 = 17;
1345
+ var S14 = 22;
1346
+ var S21 = 5;
1347
+ var S22 = 9;
1348
+ var S23 = 14;
1349
+ var S24 = 20;
1350
+ var S31 = 4;
1351
+ var S32 = 11;
1352
+ var S33 = 16;
1353
+ var S34 = 23;
1354
+ var S41 = 6;
1355
+ var S42 = 10;
1356
+ var S43 = 15;
1357
+ var S44 = 21;
1358
+ var utf8Text = utf8.utf8.encode(unicodeText);
1359
+ x = convertToWordArray(utf8Text);
1360
+ a = 0x67452301;
1361
+ b = 0xefcdab89;
1362
+ c = 0x98badcfe;
1363
+ d = 0x10325476;
1364
+ for (k = 0; k < x.length; k += 16) {
1365
+ AA = a;
1366
+ BB = b;
1367
+ CC = c;
1368
+ DD = d;
1369
+ a = FF(a, b, c, d, x[k + 0], S11, 0xd76aa478);
1370
+ d = FF(d, a, b, c, x[k + 1], S12, 0xe8c7b756);
1371
+ c = FF(c, d, a, b, x[k + 2], S13, 0x242070db);
1372
+ b = FF(b, c, d, a, x[k + 3], S14, 0xc1bdceee);
1373
+ a = FF(a, b, c, d, x[k + 4], S11, 0xf57c0faf);
1374
+ d = FF(d, a, b, c, x[k + 5], S12, 0x4787c62a);
1375
+ c = FF(c, d, a, b, x[k + 6], S13, 0xa8304613);
1376
+ b = FF(b, c, d, a, x[k + 7], S14, 0xfd469501);
1377
+ a = FF(a, b, c, d, x[k + 8], S11, 0x698098d8);
1378
+ d = FF(d, a, b, c, x[k + 9], S12, 0x8b44f7af);
1379
+ c = FF(c, d, a, b, x[k + 10], S13, 0xffff5bb1);
1380
+ b = FF(b, c, d, a, x[k + 11], S14, 0x895cd7be);
1381
+ a = FF(a, b, c, d, x[k + 12], S11, 0x6b901122);
1382
+ d = FF(d, a, b, c, x[k + 13], S12, 0xfd987193);
1383
+ c = FF(c, d, a, b, x[k + 14], S13, 0xa679438e);
1384
+ b = FF(b, c, d, a, x[k + 15], S14, 0x49b40821);
1385
+ a = GG(a, b, c, d, x[k + 1], S21, 0xf61e2562);
1386
+ d = GG(d, a, b, c, x[k + 6], S22, 0xc040b340);
1387
+ c = GG(c, d, a, b, x[k + 11], S23, 0x265e5a51);
1388
+ b = GG(b, c, d, a, x[k + 0], S24, 0xe9b6c7aa);
1389
+ a = GG(a, b, c, d, x[k + 5], S21, 0xd62f105d);
1390
+ d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
1391
+ c = GG(c, d, a, b, x[k + 15], S23, 0xd8a1e681);
1392
+ b = GG(b, c, d, a, x[k + 4], S24, 0xe7d3fbc8);
1393
+ a = GG(a, b, c, d, x[k + 9], S21, 0x21e1cde6);
1394
+ d = GG(d, a, b, c, x[k + 14], S22, 0xc33707d6);
1395
+ c = GG(c, d, a, b, x[k + 3], S23, 0xf4d50d87);
1396
+ b = GG(b, c, d, a, x[k + 8], S24, 0x455a14ed);
1397
+ a = GG(a, b, c, d, x[k + 13], S21, 0xa9e3e905);
1398
+ d = GG(d, a, b, c, x[k + 2], S22, 0xfcefa3f8);
1399
+ c = GG(c, d, a, b, x[k + 7], S23, 0x676f02d9);
1400
+ b = GG(b, c, d, a, x[k + 12], S24, 0x8d2a4c8a);
1401
+ a = HH(a, b, c, d, x[k + 5], S31, 0xfffa3942);
1402
+ d = HH(d, a, b, c, x[k + 8], S32, 0x8771f681);
1403
+ c = HH(c, d, a, b, x[k + 11], S33, 0x6d9d6122);
1404
+ b = HH(b, c, d, a, x[k + 14], S34, 0xfde5380c);
1405
+ a = HH(a, b, c, d, x[k + 1], S31, 0xa4beea44);
1406
+ d = HH(d, a, b, c, x[k + 4], S32, 0x4bdecfa9);
1407
+ c = HH(c, d, a, b, x[k + 7], S33, 0xf6bb4b60);
1408
+ b = HH(b, c, d, a, x[k + 10], S34, 0xbebfbc70);
1409
+ a = HH(a, b, c, d, x[k + 13], S31, 0x289b7ec6);
1410
+ d = HH(d, a, b, c, x[k + 0], S32, 0xeaa127fa);
1411
+ c = HH(c, d, a, b, x[k + 3], S33, 0xd4ef3085);
1412
+ b = HH(b, c, d, a, x[k + 6], S34, 0x4881d05);
1413
+ a = HH(a, b, c, d, x[k + 9], S31, 0xd9d4d039);
1414
+ d = HH(d, a, b, c, x[k + 12], S32, 0xe6db99e5);
1415
+ c = HH(c, d, a, b, x[k + 15], S33, 0x1fa27cf8);
1416
+ b = HH(b, c, d, a, x[k + 2], S34, 0xc4ac5665);
1417
+ a = II(a, b, c, d, x[k + 0], S41, 0xf4292244);
1418
+ d = II(d, a, b, c, x[k + 7], S42, 0x432aff97);
1419
+ c = II(c, d, a, b, x[k + 14], S43, 0xab9423a7);
1420
+ b = II(b, c, d, a, x[k + 5], S44, 0xfc93a039);
1421
+ a = II(a, b, c, d, x[k + 12], S41, 0x655b59c3);
1422
+ d = II(d, a, b, c, x[k + 3], S42, 0x8f0ccc92);
1423
+ c = II(c, d, a, b, x[k + 10], S43, 0xffeff47d);
1424
+ b = II(b, c, d, a, x[k + 1], S44, 0x85845dd1);
1425
+ a = II(a, b, c, d, x[k + 8], S41, 0x6fa87e4f);
1426
+ d = II(d, a, b, c, x[k + 15], S42, 0xfe2ce6e0);
1427
+ c = II(c, d, a, b, x[k + 6], S43, 0xa3014314);
1428
+ b = II(b, c, d, a, x[k + 13], S44, 0x4e0811a1);
1429
+ a = II(a, b, c, d, x[k + 4], S41, 0xf7537e82);
1430
+ d = II(d, a, b, c, x[k + 11], S42, 0xbd3af235);
1431
+ c = II(c, d, a, b, x[k + 2], S43, 0x2ad7d2bb);
1432
+ b = II(b, c, d, a, x[k + 9], S44, 0xeb86d391);
1433
+ a = addUnsigned(a, AA);
1434
+ b = addUnsigned(b, BB);
1435
+ c = addUnsigned(c, CC);
1436
+ d = addUnsigned(d, DD);
1437
+ }
1438
+ return wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
1439
+ }
1440
+ exports.generate = generate;
1441
+ function rotateLeft(lValue, iShiftBits) {
1442
+ return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
1443
+ }
1444
+ function addUnsigned(lX, lY) {
1445
+ var lX4;
1446
+ var lY4;
1447
+ var lX8;
1448
+ var lY8;
1449
+ var lResult;
1450
+ lX8 = lX & 0x80000000;
1451
+ lY8 = lY & 0x80000000;
1452
+ lX4 = lX & 0x40000000;
1453
+ lY4 = lY & 0x40000000;
1454
+ lResult = (lX & 0x3fffffff) + (lY & 0x3fffffff);
1455
+ if (lX4 & lY4) {
1456
+ return lResult ^ 0x80000000 ^ lX8 ^ lY8;
1457
+ }
1458
+ if (lX4 | lY4) {
1459
+ if (lResult & 0x40000000) {
1460
+ return lResult ^ 0xc0000000 ^ lX8 ^ lY8;
1461
+ }
1462
+ else {
1463
+ return lResult ^ 0x40000000 ^ lX8 ^ lY8;
1464
+ }
1465
+ }
1466
+ else {
1467
+ return lResult ^ lX8 ^ lY8;
1468
+ }
1469
+ }
1470
+ function F(x, y, z) {
1471
+ return (x & y) | (~x & z);
1472
+ }
1473
+ function G(x, y, z) {
1474
+ return (x & z) | (y & ~z);
1475
+ }
1476
+ function H(x, y, z) {
1477
+ return x ^ y ^ z;
1478
+ }
1479
+ function I(x, y, z) {
1480
+ return y ^ (x | ~z);
1481
+ }
1482
+ function FF(a, b, c, d, x, s, ac) {
1483
+ a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
1484
+ return addUnsigned(rotateLeft(a, s), b);
1485
+ }
1486
+ function GG(a, b, c, d, x, s, ac) {
1487
+ a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
1488
+ return addUnsigned(rotateLeft(a, s), b);
1489
+ }
1490
+ function HH(a, b, c, d, x, s, ac) {
1491
+ a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
1492
+ return addUnsigned(rotateLeft(a, s), b);
1493
+ }
1494
+ function II(a, b, c, d, x, s, ac) {
1495
+ a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
1496
+ return addUnsigned(rotateLeft(a, s), b);
1497
+ }
1498
+ function convertToWordArray(value) {
1499
+ var lWordCount;
1500
+ var lMessageLength = value.length;
1501
+ var lNumberOfWordsTemp1 = lMessageLength + 8;
1502
+ var lNumberOfWordsTemp2 = (lNumberOfWordsTemp1 - (lNumberOfWordsTemp1 % 64)) / 64;
1503
+ var lNumberOfWords = (lNumberOfWordsTemp2 + 1) * 16;
1504
+ var lWordArray = Array(lNumberOfWords - 1);
1505
+ var lBytePosition = 0;
1506
+ var lByteCount = 0;
1507
+ while (lByteCount < lMessageLength) {
1508
+ lWordCount = (lByteCount - (lByteCount % 4)) / 4;
1509
+ lBytePosition = (lByteCount % 4) * 8;
1510
+ lWordArray[lWordCount] =
1511
+ lWordArray[lWordCount] | (value.charCodeAt(lByteCount) << lBytePosition);
1512
+ lByteCount++;
1513
+ }
1514
+ lWordCount = (lByteCount - (lByteCount % 4)) / 4;
1515
+ lBytePosition = (lByteCount % 4) * 8;
1516
+ lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
1517
+ lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
1518
+ lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
1519
+ return lWordArray;
1520
+ }
1521
+ function wordToHex(lValue) {
1522
+ var wordToHexValue = "";
1523
+ var wordToHexValueTemp = "";
1524
+ var lByte;
1525
+ var lCount;
1526
+ for (lCount = 0; lCount <= 3; lCount++) {
1527
+ lByte = (lValue >>> (lCount * 8)) & 255;
1528
+ wordToHexValueTemp = "0" + lByte.toString(16);
1529
+ wordToHexValue =
1530
+ wordToHexValue + wordToHexValueTemp.substr(wordToHexValueTemp.length - 2, 2);
1531
+ }
1532
+ return wordToHexValue;
1533
+ }
1534
+ });
1535
+
1536
+ var lib = createCommonjsModule(function (module, exports) {
1537
+ Object.defineProperty(exports, "__esModule", { value: true });
1538
+ exports.MD5 = exports.generate = void 0;
1539
+
1540
+ var md5_2 = md5;
1541
+ Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return md5_2.generate; } });
1542
+ exports.MD5 = {
1543
+ generate: md5.generate,
1544
+ };
1545
+ });
1546
+
1547
+ const apiSearch = async (query) => {
1548
+ const res = await fetch(getCreditSafeApiUrl(), {
1549
+ method: 'POST',
1550
+ headers: {
1551
+ 'Content-Type': 'application/json',
1552
+ },
1553
+ body: JSON.stringify({
1554
+ query,
1555
+ hash: lib.MD5.generate(String.fromCharCode(83, 101, 67, 82, 101, 116) + query),
1556
+ }),
1557
+ });
1558
+ const data = await res.json();
1559
+ return data;
1560
+ };
1561
+
1562
+ const HemfixarnaGetuser = class {
1563
+ constructor(hostRef) {
1564
+ registerInstance(this, hostRef);
1565
+ this.handleChangeEmail = (e) => {
1566
+ this.emailError = null;
1567
+ this.email = e.target.value;
1568
+ };
1569
+ this.handleChangePhone = (e) => {
1570
+ this.phoneError = null;
1571
+ this.phone = e.target.value;
1572
+ };
1573
+ this.handleChangessn = (e) => {
1574
+ this.ssnError = null;
1575
+ this.ssn = e.target.value;
1576
+ };
1577
+ this.handleSubmit = async (e) => {
1578
+ e.preventDefault();
1579
+ const emailRegex = new RegExp(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);
1580
+ const validEmail = emailRegex.test(this.email);
1581
+ if (!validEmail) {
1582
+ this.emailError = 'Ange en giltig e-postadress';
1583
+ }
1584
+ const validPhone = /^[\d\s()+-]{6,}$/.test(this.phone);
1585
+ if (!validPhone) {
1586
+ this.phoneError = 'Ange ett giltigt telefonnummer';
1587
+ }
1588
+ const validssn = src_default.valid(this.ssn);
1589
+ if (!validssn) {
1590
+ this.ssnError = 'Ange ett giltigt personnummer';
1591
+ }
1592
+ else if (validssn) {
1593
+ const pn = src_default.parse(this.ssn).format(true);
1594
+ this.ssn = [pn.slice(0, 8), '-', pn.slice(8)].join('');
1595
+ }
1596
+ if (validEmail && validPhone && validssn) {
1597
+ try {
1598
+ const creditSafeData = await apiSearch(this.ssn);
1599
+ if (creditSafeData) {
1600
+ state.creditSafeUser = creditSafeData;
1601
+ state.checkoutStep = 2;
1602
+ state.user = Object.assign(Object.assign({}, creditSafeData), { email: this.email, phone: this.phone, ssn: this.ssn });
1603
+ }
1604
+ else {
1605
+ this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';
1606
+ }
1607
+ }
1608
+ catch (e) {
1609
+ this.ssnError = 'Vi kunde tyvärr inte hitta en address med ditt angivna personnummer';
1610
+ console.log(e);
1611
+ }
1612
+ finally {
1613
+ const el = this.el.closest('.hemfixarna_content');
1614
+ scrollToTop(el);
1615
+ }
1616
+ }
1617
+ };
1618
+ this.render = () => {
1619
+ return (h("form", { class: "mb-2", onSubmit: e => this.handleSubmit(e) }, h("div", null, h("input", { class: `${this.email.length ? 'input_active' : ''}`, onChange: e => this.handleChangeEmail(e), type: "email", name: "email", value: this.email }), h("label", { htmlFor: "email" }, "E-post ")), this.emailError && h("span", null, this.emailError), h("div", null, h("input", { class: `${this.phone.length ? 'input_active' : ''}`, onChange: e => this.handleChangePhone(e), type: "tel", name: "phone", value: this.phone }), h("label", { htmlFor: "phone" }, "Mobiltelefon ")), this.phoneError && h("span", null, this.phoneError), h("div", null, h("input", { class: `${this.ssn.length ? 'input_active' : ''}`, onChange: e => this.handleChangessn(e), type: "tel", name: "ssn", value: this.ssn }), h("label", { htmlFor: "phone" }, "Personnummer*")), this.ssnError && h("span", null, this.ssnError), h("input", { type: "submit", value: "Forts\u00E4tt*" }), h("p", null, "*Vi h\u00E4mtar din adress")));
1620
+ };
1621
+ this.email = '';
1622
+ this.emailError = null;
1623
+ this.phone = '';
1624
+ this.phoneError = null;
1625
+ this.ssn = '';
1626
+ this.ssnError = null;
1627
+ }
1628
+ componentWillLoad() {
1629
+ if (state.user) {
1630
+ this.email = state.user.email;
1631
+ this.phone = state.user.phone;
1632
+ this.ssn = state.user.ssn;
1633
+ }
1634
+ }
1635
+ get el() { return getElement(this); }
1636
+ };
1637
+
1638
+ const HemfixarnaInfo = class {
1639
+ constructor(hostRef) {
1640
+ registerInstance(this, hostRef);
1641
+ this.logo = getAssetPath(`./assets/hemfixarna.svg`);
1642
+ }
1643
+ render() {
1644
+ var _a, _b;
1645
+ const checked = getAssetPath(`./assets/checked.svg`);
1646
+ return (h("div", { class: "hemfixarna_info" }, state.step < 5 ? (h(Fragment, null, h("h2", null, state.customer.info_title), h("p", null, state.customer.info_text))) : (h("h2", null, state.customer.checkout_title)), h("ul", { class: "hemfixarna_features" }, state.step < 5 ? (h(Fragment, null, ((_a = state.customer.trust_badges) === null || _a === void 0 ? void 0 : _a.length) ? (h(Fragment, null, state.customer.trust_badges.map(l => (h("li", { key: l.text }, h("img", { src: checked, alt: "checked" }), h("p", null, l.text)))))) : (h(Fragment, null, state.options.trust.map(l => (h("li", { key: l.trust_badge }, h("img", { src: checked, alt: "checked" }), h("p", null, l.trust_badge)))))))) : (h(Fragment, null, (_b = state.customer.checkout_trust_badges) === null || _b === void 0 ? void 0 : _b.map(l => (h("li", { key: l.text }, h("img", { src: checked, alt: "checked" }), h("p", null, l.text))))))), h("img", { src: this.logo, width: 200, alt: "hemfixarna" }), h("a", { class: "hemfixarna_product--link", target: "_blank", href: state.options.link.url }, state.options.link.title)));
1647
+ }
1648
+ };
1649
+
1650
+ const hemfixarnaInvoiceCss = ":host .invoice{gap:16px;display:grid}:host .invoice form>span{text-align:center;padding:16px 0}:host .invoice img{right:unset;left:unset;position:initial;transform:none}:host .invoice label{cursor:pointer;font-size:14px;display:flex;align-items:flex-start;padding:16px 0}:host .invoice label input{margin:0 5px 0 0;accent-color:#ea662c}:host .invoice-preview{display:flex;gap:4px}:host .invoice-preview div{position:relative}:host .invoice-preview div button{position:absolute;top:0;right:0;padding:0}:host .invoice-preview div button img{width:24px;height:24px}:host .invoice-preview div>img{width:100px;height:80px;object-fit:cover}:host .invoice input[type=email],:host .invoice input[type=tel],:host .invoice textarea{padding:16px;border:1px solid #fcd9c9;font-size:16px}:host .invoice textarea{resize:none;height:200px;font-family:\"Inter\", sans-serif}:host .invoice div:has(>input[type=file]){display:flex;align-items:center;justify-content:center;cursor:pointer;background:#fff;border:1px solid #fcd9c9;padding:32px 16px;gap:16px}:host .invoice div:has(>input[type=file]) span{color:#000;font-size:12px}:host .invoice input[type=file]{display:none}";
1651
+
1652
+ const base = `${getApiUrl()}/wp-json/headless`;
1653
+ const HemfixarnaInvoice = class {
1654
+ constructor(hostRef) {
1655
+ registerInstance(this, hostRef);
1656
+ this.formError = null;
1657
+ this.displayImages = [];
1658
+ this.formImages = [];
1659
+ this.formState = 'initial';
1660
+ }
1661
+ isValidEmail(email) {
1662
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
1663
+ return emailRegex.test(email);
1664
+ }
1665
+ componentDidRender() {
1666
+ const form = this.el.querySelector('form');
1667
+ if (form) {
1668
+ form.addEventListener('input', () => {
1669
+ this.formError = null;
1670
+ });
1671
+ }
1672
+ }
1673
+ disconnectedCallback() {
1674
+ const form = this.el.querySelector('form');
1675
+ if (form) {
1676
+ form.removeEventListener('input', () => {
1677
+ this.formError = null;
1678
+ });
1679
+ }
1680
+ }
1681
+ async submit(e) {
1682
+ var _a;
1683
+ e.preventDefault();
1684
+ this.formState = 'loading';
1685
+ this.formError = null;
1686
+ const form = e.currentTarget.elements;
1687
+ const values = {
1688
+ description: form.descriptionInput.value.length ? form.descriptionInput.value : null,
1689
+ email: form.emailInput.value.length ? form.emailInput.value : null,
1690
+ tel: form.telInput.value.length ? form.telInput.value : null,
1691
+ terms: (_a = form.termsInput) === null || _a === void 0 ? void 0 : _a.checked,
1692
+ };
1693
+ if (!values.description) {
1694
+ this.formError = 'Vänligen fyll i formulärtexten';
1695
+ this.formState = 'initial';
1696
+ return;
1697
+ }
1698
+ if (!values.email || !this.isValidEmail(values.email)) {
1699
+ this.formError = 'Vänligen ange en giltig e-postadress';
1700
+ this.formState = 'initial';
1701
+ return;
1702
+ }
1703
+ if (!values.tel) {
1704
+ this.formError = 'Vänligen ange ditt telefonnummer';
1705
+ this.formState = 'initial';
1706
+ return;
1707
+ }
1708
+ if (state.selectedProduct.terms_show_checkbox && !values.terms) {
1709
+ this.formError = 'Vänligen acceptera villkoren';
1710
+ this.formState = 'initial';
1711
+ return;
1712
+ }
1713
+ const formData = new FormData();
1714
+ formData.append('text', values.description);
1715
+ formData.append('email', values.email);
1716
+ formData.append('phone', values.tel);
1717
+ formData.append('customer', state.business);
1718
+ this.formImages.forEach(file => {
1719
+ formData.append('images[]', file);
1720
+ });
1721
+ formData.append('product', JSON.stringify({
1722
+ title: state.selectedProduct.title,
1723
+ amount: 1,
1724
+ has_rut: state.selectedProduct.rut,
1725
+ has_rot: state.selectedProduct.rot,
1726
+ has_green: state.selectedProduct.green,
1727
+ ID: state.selectedProduct.ID,
1728
+ parts: [],
1729
+ }));
1730
+ try {
1731
+ const res = await fetch(`${base}/saveinvoiceproduct`, {
1732
+ method: 'POST',
1733
+ body: formData,
1734
+ });
1735
+ const { response } = await res.json();
1736
+ if (response.code === 200) {
1737
+ state.checkoutInvoice = true;
1738
+ state.step = 6;
1739
+ }
1740
+ else {
1741
+ this.formError = 'Vi kan inte ta emot din beställning just nu';
1742
+ this.formState = 'initial';
1743
+ }
1744
+ }
1745
+ catch (error) {
1746
+ this.formError = 'Vi kan inte ta emot din beställning just nu';
1747
+ this.formState = 'initial';
1748
+ }
1749
+ }
1750
+ handleImageDrop(e) {
1751
+ e.preventDefault();
1752
+ const files = e.dataTransfer.files;
1753
+ for (let i = 0; i < files.length; i++) {
1754
+ const file = files[i];
1755
+ if (file.type.startsWith('image/')) {
1756
+ const reader = new FileReader();
1757
+ reader.onload = () => {
1758
+ this.displayImages = [...this.displayImages, reader.result];
1759
+ this.formImages = [...this.formImages, file];
1760
+ };
1761
+ reader.readAsDataURL(file);
1762
+ }
1763
+ }
1764
+ }
1765
+ handleFileInputChange(e) {
1766
+ e.preventDefault();
1767
+ const files = e.target.files;
1768
+ for (let i = 0; i < files.length; i++) {
1769
+ const file = files[i];
1770
+ if (file.type.startsWith('image/')) {
1771
+ const reader = new FileReader();
1772
+ reader.onload = () => {
1773
+ this.displayImages = [...this.displayImages, reader.result];
1774
+ this.formImages = [...this.formImages, file];
1775
+ };
1776
+ reader.readAsDataURL(file);
1777
+ }
1778
+ }
1779
+ }
1780
+ handleImageClick() {
1781
+ this.el.querySelector('.hemfixarna-file-upload').click();
1782
+ }
1783
+ preventDragOver(e) {
1784
+ e.preventDefault();
1785
+ }
1786
+ removeImage(index) {
1787
+ this.displayImages = this.displayImages.filter((_, i) => i !== index);
1788
+ this.formImages = this.formImages.filter((_, i) => i !== index);
1789
+ }
1790
+ render() {
1791
+ const upload = getAssetPath(`./assets/drag-drop.svg`);
1792
+ return (h("div", { class: "invoice" }, h("p", null, state.selectedProduct.invoice_description), h("form", { onSubmit: e => this.submit(e) }, h("textarea", { name: "descriptionInput", placeholder: "Beskriv ditt \u00E4rende" }), h("div", { role: "button", "aria-label": "upload image", onDragOver: e => this.preventDragOver(e), onDrop: e => this.handleImageDrop(e), onClick: () => this.handleImageClick() }, h("img", { src: upload, alt: "hemfixarna_logo", width: 24 }), h("div", null, h("p", null, "Bifoga ev bilder"), h("span", null, "(dra bilder hit)")), h("input", { onChange: e => this.handleFileInputChange(e), class: "hemfixarna-file-upload", accept: "image/*", type: "file", multiple: true, name: "fileInput" })), h("div", { class: "invoice-preview" }, this.displayImages.map((img, i) => (h("div", { key: i }, h("img", { src: img, alt: "uploaded image" }), h("button", { onClick: () => this.removeImage(i) }, h("img", { src: getAssetPath(`./assets/close.svg`), alt: "close" })))))), h("input", { placeholder: "E-post", type: "email", name: "emailInput" }), h("input", { placeholder: "Telefonnummer", type: "tel", name: "telInput" }), state.selectedProduct.terms_show_checkbox ? (h("label", null, h("input", { type: "checkbox", name: "termsInput" }), state.selectedProduct.terms)) : null, this.formError ? h("span", null, this.formError) : null, h("input", { type: "submit", value: this.formState === 'loading' ? 'Skickar' : 'Kontakta mig' }))));
1793
+ }
1794
+ get el() { return getElement(this); }
1795
+ };
1796
+ HemfixarnaInvoice.style = hemfixarnaInvoiceCss;
1797
+
1798
+ const HemfixarnaOrder = class {
1799
+ constructor(hostRef) {
1800
+ registerInstance(this, hostRef);
1801
+ this.render = () => {
1802
+ return (h("div", { style: { background: `url(${state.options.thank_you_image})` }, class: "hemfixarna_order" }, h("div", null), h("div", null, h("h2", null, state.checkoutInvoice ? 'Tack för din förfrågan' : 'Tack för din bokning'), state.checkoutInvoice ? h("p", null, "Vi \u00E5terkommer inom kort till dig p\u00E5 angivet telefonnummer eller epost") : null, state.checkoutInvoice ? h("div", null) : h("hemfixarna-orderrows", { cart: false }), h("span", { onClick: () => this.resetShop() }, h("button", null, "G\u00F6r en ny bokning")), h("hemfixarna-info", null))));
1803
+ };
1804
+ }
1805
+ resetShop() {
1806
+ state.step = 1;
1807
+ state.cart = [];
1808
+ state.selectedCategory = null;
1809
+ state.selectedService = null;
1810
+ state.selectedProduct = null;
1811
+ state.maleri = null;
1812
+ state.checkoutStep = 1;
1813
+ }
1814
+ disconnectedCallback() {
1815
+ this.resetShop();
1816
+ }
1817
+ };
1818
+
1819
+ const HemfixarnaOrderrows = class {
1820
+ constructor(hostRef) {
1821
+ registerInstance(this, hostRef);
1822
+ this.cart = true;
1823
+ }
1824
+ goToProduct(id) {
1825
+ const products = state.customer.categories
1826
+ .map(c => (c.show_products ? c.products : c.sub_categories ? c.sub_categories.map(c => c.products) : []))
1827
+ .flat()
1828
+ .flat();
1829
+ const product = products.find(p => p && p.fields.ID === id);
1830
+ if (product) {
1831
+ state.selectedProduct = product.fields;
1832
+ state.step = 4;
1833
+ }
1834
+ }
1835
+ openRot() {
1836
+ state.modal = {
1837
+ title: state.rotOptions.rot_start_fee_heading,
1838
+ text: [state.rotOptions.rot_start_fee_text, state.rotOptions.rot_start_fee_text_secondary],
1839
+ };
1840
+ }
1841
+ openRut() {
1842
+ state.modal = {
1843
+ title: state.rutOptions.rut_start_fee_heading,
1844
+ text: [state.rutOptions.rut_start_fee_text, state.rutOptions.rut_start_fee_text_secondary],
1845
+ };
1846
+ }
1847
+ openGreen() {
1848
+ state.modal = {
1849
+ title: state.greenOptions.green_start_fee_heading,
1850
+ text: [state.greenOptions.green_start_fee_text, state.greenOptions.green_start_fee_text_secondary],
1851
+ };
1852
+ }
1853
+ getDiscountedInfo(item) {
1854
+ if (item.rut && state.rut) {
1855
+ return ' (efter RUT-avdrag)';
1856
+ }
1857
+ else if (item.rot && state.rot) {
1858
+ return ' (efter ROT-avdrag)';
1859
+ }
1860
+ else if (item.green && state.green) {
1861
+ return ' (efter Grön teknik avdrag)';
1862
+ }
1863
+ else {
1864
+ return '';
1865
+ }
1866
+ }
1867
+ render() {
1868
+ const info = getAssetPath(`./assets/info.svg`);
1869
+ return (h(Fragment, null, h("ul", { class: "hemfixarna_cart--items" }, state.cart.map(item => {
1870
+ var _a;
1871
+ return (h("li", { class: "hemfixarna_cart--item" }, h("div", null, h("div", null, item.icon && h("img", { width: 30, src: (_a = item.icon.url) !== null && _a !== void 0 ? _a : item.icon, alt: item.name }), h("p", null, h("strong", null, item.amount, "x "), item.name)), this.cart && h("button", { onClick: () => this.goToProduct(item.id) }, "\u00C4ndra")), h("p", null, h("strong", null, getProductPrice(item, item.price, item.amount), "kr"), h("span", null, this.getDiscountedInfo(item))), item.parts.length > 0 && (h("ul", null, item.parts.map(part => (h("li", null, h("p", null, h("strong", null, part.amount, "x "), part.name), h("p", null, h("strong", null, getPartPrice(part, item, part.amount), "kr")))))))));
1872
+ })), h("div", { class: "hemfixarna_cart--additional" }, h("div", null, getStartFee().rot > 0 && (h("div", { class: "hemfixarna_cart--startfee" }, h("p", null, h("strong", { onClick: () => this.openRot() }, state.rotOptions.rot_start_fee_heading, h("img", { height: 16, src: info, alt: "info monteringsavgift" }))), h("p", null, getStartFee().rot, "kr"))), getStartFee().rut > 0 && (h("div", { class: "hemfixarna_cart--startfee" }, h("p", null, h("strong", { onClick: () => this.openRut() }, state.rutOptions.rut_start_fee_heading, h("img", { height: 16, src: info, alt: "info monteringsavgift" }))), h("p", null, getStartFee().rut, "kr"))), getStartFee().green > 0 && (h("div", { class: "hemfixarna_cart--startfee" }, h("p", null, h("strong", { onClick: () => this.openGreen() }, state.greenOptions.green_start_fee_heading, h("img", { height: 16, src: info, alt: "info monteringsavgift" }))), h("p", null, getStartFee().green, "kr")))), state.cart.find((item) => item.rot) && (h("div", { class: "hemfixarna_cart--rutrot" }, h("div", null, this.cart && (h("label", { class: "switch" }, h("input", { checked: state.rot, onChange: () => (state.rot = !state.rot), type: "checkbox" }), h("span", { class: "slider" }))), h("p", null, "ROT-avdrag")), h("p", null, "(-", state.rot ? calculateRot() : 0, "kr)"))), state.cart.find((item) => item.rut) && (h("div", { class: "hemfixarna_cart--rutrot" }, h("div", null, h("label", { class: "switch" }, h("input", { onChange: () => (state.rut = !state.rut), checked: state.rut, type: "checkbox" }), h("span", { class: "slider" })), h("p", null, "RUT-avdrag")), h("p", null, "(-", state.rut ? calculateRut() : 0, "kr)"))), state.cart.find((item) => item.green) && (h("div", { class: "hemfixarna_cart--rutrot" }, h("div", null, h("label", { class: "switch" }, h("input", { onChange: () => (state.green = !state.green), checked: state.green, type: "checkbox" }), h("span", { class: "slider" })), h("p", null, "Gr\u00F6n teknik avdrag")), h("p", null, "(-", state.green ? calculateGreenDiscount() : 0, "kr)")))), h("div", { class: "hemfixarna_cart--price" }, h("h2", null, "Totalbelopp: "), h("h2", null, getTotalPrice(), "kr"))));
1873
+ }
1874
+ };
1875
+
1876
+ const hemfixarnaProductCss = "";
1877
+
1878
+ const HemfixarnaProduct = class {
1879
+ constructor(hostRef) {
1880
+ registerInstance(this, hostRef);
1881
+ this.amount = 0;
1882
+ this.hideDescription = true;
1883
+ }
1884
+ addProduct() {
1885
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
1886
+ if (productInCart) {
1887
+ productInCart.amount++;
1888
+ state.cart = [...state.cart];
1889
+ }
1890
+ else {
1891
+ state.cart = [
1892
+ ...state.cart,
1893
+ {
1894
+ id: state.selectedProduct.ID,
1895
+ rut: state.selectedProduct.rut,
1896
+ rot: state.selectedProduct.rot,
1897
+ green: state.selectedProduct.green,
1898
+ amount: 1,
1899
+ parts: [],
1900
+ price: state.selectedProduct.price,
1901
+ name: state.selectedProduct.title,
1902
+ start_fee: !state.selectedProduct.hide_start_fee,
1903
+ terms_checkout: state.selectedProduct.terms_checkout,
1904
+ icon: state.selectedProduct.icon,
1905
+ },
1906
+ ];
1907
+ }
1908
+ }
1909
+ removeProduct() {
1910
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
1911
+ if (productInCart && productInCart.amount > 1) {
1912
+ productInCart.amount--;
1913
+ state.cart = [...state.cart];
1914
+ }
1915
+ else {
1916
+ state.cart = state.cart.filter(p => p.id !== state.selectedProduct.ID);
1917
+ }
1918
+ }
1919
+ //Handle cart and parts
1920
+ addPart(part) {
1921
+ var _a;
1922
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
1923
+ if (productInCart) {
1924
+ const partInCart = productInCart.parts.find(sp => sp.id === part.ID);
1925
+ if (partInCart) {
1926
+ partInCart.amount++;
1927
+ productInCart.parts = [...productInCart.parts];
1928
+ }
1929
+ else {
1930
+ productInCart.parts = [...productInCart.parts, { id: part.ID, amount: 1, price: part.price, name: (_a = part.title) !== null && _a !== void 0 ? _a : part.title }];
1931
+ }
1932
+ state.cart = [...state.cart.filter(p => p.id !== productInCart.id), productInCart];
1933
+ }
1934
+ }
1935
+ removePart(part) {
1936
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
1937
+ if (productInCart) {
1938
+ const partInCart = productInCart.parts.find(sp => sp.id === part.ID);
1939
+ if (partInCart && partInCart.amount > 1) {
1940
+ partInCart.amount--;
1941
+ productInCart.parts = [...productInCart.parts];
1942
+ }
1943
+ else {
1944
+ productInCart.parts = productInCart.parts.filter(sp => sp.id !== part.ID);
1945
+ }
1946
+ state.cart = [...state.cart.filter(p => p.id !== productInCart.id), productInCart];
1947
+ }
1948
+ }
1949
+ goToCart() {
1950
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
1951
+ if (productInCart) {
1952
+ state.step = 5;
1953
+ const el = this.el.closest('.hemfixarna_content');
1954
+ scrollToTop(el);
1955
+ }
1956
+ }
1957
+ getAmount() {
1958
+ var _a;
1959
+ return ((_a = state.cart.find(p => p.id === state.selectedProduct.ID)) === null || _a === void 0 ? void 0 : _a.amount) || 0;
1960
+ }
1961
+ getPartAmount(partId) {
1962
+ var _a;
1963
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
1964
+ return ((_a = productInCart === null || productInCart === void 0 ? void 0 : productInCart.parts.find(sp => sp.id === partId)) === null || _a === void 0 ? void 0 : _a.amount) || 0;
1965
+ }
1966
+ getTotalPrice() {
1967
+ let price = 0;
1968
+ const productInCart = state.cart.find(p => p.id === state.selectedProduct.ID);
1969
+ if (productInCart) {
1970
+ const partsPrice = productInCart.parts.reduce((acc, curr) => {
1971
+ const part = state.selectedProduct.parts.find(p => p.ID === curr.id);
1972
+ if (part) {
1973
+ return acc + part.price * curr.amount;
1974
+ }
1975
+ return acc;
1976
+ }, 0);
1977
+ price = state.selectedProduct.price * productInCart.amount + partsPrice;
1978
+ }
1979
+ else {
1980
+ price = state.selectedProduct.price;
1981
+ }
1982
+ return getProductPrice(state.selectedProduct, price);
1983
+ }
1984
+ componentDidRender() {
1985
+ const linkElem = document.createElement('link');
1986
+ linkElem.setAttribute('rel', 'stylesheet');
1987
+ linkElem.setAttribute('href', 'https://painting-frontend.vercel.app/static/css/main.css');
1988
+ const fonts = document.createElement('link');
1989
+ fonts.setAttribute('rel', 'stylesheet');
1990
+ fonts.setAttribute('href', 'https://painting-frontend.vercel.app/fonts.css');
1991
+ const checkAndInjectCSS = () => {
1992
+ const parents = this.el.getElementsByTagName('hemfixare-calculator');
1993
+ if (parents.length > 0 && parents[0].shadowRoot !== null) {
1994
+ parents[0].shadowRoot.appendChild(linkElem);
1995
+ parents[0].shadowRoot.appendChild(fonts);
1996
+ }
1997
+ else {
1998
+ setTimeout(checkAndInjectCSS, 1);
1999
+ }
2000
+ };
2001
+ checkAndInjectCSS();
2002
+ }
2003
+ render() {
2004
+ var _a, _b, _c;
2005
+ const checked = getAssetPath(`./assets/checked.svg`);
2006
+ const plus = getAssetPath(`./assets/plus.svg`);
2007
+ const minus = getAssetPath(`./assets/minus.svg`);
2008
+ if (state.maleri) {
2009
+ return (h("div", { class: "hemfixarna_painting" }, h("script", { type: "text/javascript", src: ['localhost', 'vercel'].some(v => window.location.href.includes(v))
2010
+ ? 'https://painting-dev.vercel.app/static/js/main.js'
2011
+ : 'https://painting-frontend.vercel.app/static/js/main.js', defer: true, async: true }), h("hemfixare-calculator", { title: state.options.maleri_title, subtitle: state.options.maleri_text, modal: "true", customer: state.business === Business.string ? 'string' : state.business })));
2012
+ }
2013
+ return state.selectedProduct ? (h("div", { class: "hemfixarna_product" }, h("div", { class: "hemfixarna_product--top" }, state.selectedProduct.icon && (h("img", { width: 80, src: (_a = state.selectedProduct.icon.url) !== null && _a !== void 0 ? _a : state.selectedProduct.icon, alt: state.selectedProduct.title })), h("div", null, h("h1", null, state.selectedProduct.title), !state.selectedProduct.invoice ? h("h2", null, getProductPrice(state.selectedProduct), " kr/st") : h("h2", null, state.selectedProduct.invoice_price))), h("div", { class: "hemfixarna_product--grid" }, h("div", { class: "hemfixarna_product--left" }, ((_b = state.selectedProduct.list) === null || _b === void 0 ? void 0 : _b.length) && (h("ul", { class: "hemfixarna_features" }, state.selectedProduct.list.map(l => (h("li", { key: l.bullet }, h("img", { src: checked, alt: "checked" }), h("p", null, l.bullet)))))), state.selectedProduct.description && (h("p", { onClick: () => (this.hideDescription = false), class: `hemfixarna_description ${this.hideDescription ? 'hemfixarna_description--hidden' : ''}`, innerHTML: state.selectedProduct.description }))), h("div", { class: "hemfixarna_product--right" }, state.selectedProduct.invoice ? (h("hemfixarna-invoice", null)) : (h(Fragment, null, h("ul", null, h("li", { class: "hemfixarna_product--item" }, h("div", null, h("p", null, state.selectedProduct.title), h("p", { class: "hemfixarna_product--price" }, getProductPrice(state.selectedProduct), "kr/st")), h("div", { class: "hemfixarna_counter" }, h("img", { class: `${this.getAmount() === 0 ? 'disabled' : ''}`, src: minus, onClick: () => this.removeProduct() }), h("span", null, this.getAmount()), h("img", { src: plus, onClick: () => this.addProduct() }))), ((_c = state.selectedProduct.parts) === null || _c === void 0 ? void 0 : _c.length) &&
2014
+ state.selectedProduct.parts.map(p => {
2015
+ var _a;
2016
+ return (h("li", { class: "hemfixarna_part" }, h("div", null, h("p", null, (_a = p.title) !== null && _a !== void 0 ? _a : p.title), h("p", { class: "hemfixarna_product--price" }, getPartPrice(p, state.selectedProduct), "kr/st")), h("div", { class: "hemfixarna_counter" }, h("img", { class: `${this.getPartAmount(p.ID) === 0 ? 'disabled' : ''}`, src: minus, onClick: () => this.removePart(p) }), h("span", null, this.getPartAmount(p.ID)), h("img", { class: `${this.getAmount() === 0 ? 'disabled' : ''}`, src: plus, onClick: () => this.addPart(p) }))));
2017
+ })), h("h4", { class: "hemfixarna_product--total" }, "Totalt ", this.getTotalPrice(), " kr"), h("button", { onClick: () => this.goToCart(), class: `hemfixarna_buy ${this.getAmount() === 0 ? 'disabled' : ''}` }, "Forts\u00E4tt"))), !state.selectedProduct.hide_start_fee && (state.selectedProduct.rot || state.selectedProduct.rut) && state.rutOptions && state.rotOptions && (h("p", { class: "hemfixarna_terms" }, h("strong", null, state.selectedProduct.rot ? state.rotOptions.rot_start_fee_heading : state.rutOptions.rut_start_fee_heading), h("br", null), h("span", { innerHTML: state.selectedProduct.rot ? state.rotOptions.rot_start_fee_text : state.rutOptions.rut_start_fee_text }))), state.options && h("hemfixarna-info", null))))) : null;
2018
+ }
2019
+ get el() { return getElement(this); }
2020
+ };
2021
+ HemfixarnaProduct.style = hemfixarnaProductCss;
2022
+
2023
+ const HemfixarnaGrid = class {
2024
+ constructor(hostRef) {
2025
+ registerInstance(this, hostRef);
2026
+ this.tree = undefined;
2027
+ this.slug = undefined;
2028
+ }
2029
+ isMainCategory(category) {
2030
+ return category.show_products !== undefined;
2031
+ }
2032
+ handleMaleriClick() {
2033
+ state.step = 4;
2034
+ state.maleri = true;
2035
+ }
2036
+ render() {
2037
+ var _a;
2038
+ const maleriLogo = getAssetPath('./assets/gubbe-pensel.svg');
2039
+ return state.customer ? (h("div", null, h("h2", null, state.selectedCustomerCategory ? state.selectedCustomerCategory.name : 'Alla tjänster'), h("div", { class: "hemfixarna_categories--wrapper" }, h("ul", { class: "hemfixarna_categories" }, ((_a = state.selectedCustomerCategory) === null || _a === void 0 ? void 0 : _a.add_painting) ? (h("button", { onClick: () => this.handleMaleriClick(), class: "hemfixarna_maleribox" }, h("img", { height: 64, src: maleriLogo, alt: "M\u00E5leri Logotyp" }), h("p", null, "Ber\u00E4kna fast pris p\u00E5 m\u00E5leri & tapetsering h\u00E4r"))) : null, state.selectedCustomerCategory
2040
+ ? this.isMainCategory(state.selectedCustomerCategory) && state.selectedCustomerCategory.sub_categories && !state.selectedCustomerCategory.show_products
2041
+ ? state.selectedCustomerCategory.sub_categories.map(c => h("hemfixarna-box", { category: c }))
2042
+ : state.selectedCustomerCategory.products
2043
+ ? state.selectedCustomerCategory.products.map(c => h("hemfixarna-box", { category: c.fields }))
2044
+ : null
2045
+ : state.customer.categories.map(c => h("hemfixarna-box", { category: c }))), h("hemfixarna-info", null)))) : (h("div", null, h("h2", null, "Alla tj\u00E4nster"), h("div", { class: "hemfixarna_categories--wrapper" }, h("ul", { class: "hemfixarna_categories" }, this.tree.sub_cats
2046
+ .sort((a, b) => (a.name < b.name ? -1 : 1))
2047
+ .map(c => {
2048
+ var _a;
2049
+ return (h("hemfixarna-box", { post: c, icon: (_a = c.icon.url) !== null && _a !== void 0 ? _a : c.icon, postTitle: c.name }));
2050
+ })), h("hemfixarna-info", null))));
2051
+ }
2052
+ };
2053
+
2054
+ export { HemfixarnaAddress as hemfixarna_address, HemfixarnaBox as hemfixarna_box, HemfixarnaBreadcrumbs as hemfixarna_breadcrumbs, HemfixarnaCart as hemfixarna_cart, HemfixarnaCheckout as hemfixarna_checkout, HemfixarnaComponent as hemfixarna_component, HemfixarnaInfo$1 as hemfixarna_contact, MyComponent as hemfixarna_demo, HemfixarnaGetuser as hemfixarna_getuser, HemfixarnaInfo as hemfixarna_info, HemfixarnaInvoice as hemfixarna_invoice, HemfixarnaOrder as hemfixarna_order, HemfixarnaOrderrows as hemfixarna_orderrows, HemfixarnaProduct as hemfixarna_product, HemfixarnaGrid as hemfixarna_start };
2055
+
2056
+ //# sourceMappingURL=hemfixarna-address_15.entry.js.map