hemfixarna-web-components 1.8.5 → 1.8.8

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