@cling-se/widget 0.17.0 → 1.0.0-beta.2

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 (232) hide show
  1. package/dist/AddClientCallout-e8d19R3f.js +101 -0
  2. package/dist/AnswerModal-BGvB8IVV.js +3291 -0
  3. package/dist/AttachmentItem-CkHbAm4l.js +171 -0
  4. package/dist/BaseUpload-BiJBcWRu.js +2472 -0
  5. package/dist/BlockMedia-CW5wgipC.js +103 -0
  6. package/dist/CCallout-Cy2eeIYd.js +104 -0
  7. package/dist/{CCurrencyDropdown-C2rXt2cJ.js → CCurrencyDropdown-DE_3CTjm.js} +91 -53
  8. package/dist/CDropdownItem-Dmq5gYzA.js +751 -0
  9. package/dist/CFormField.vue_vue_type_script_setup_true_lang-D_U9coAY.js +292 -0
  10. package/dist/{CPhoneFormat-C8VPsiK6.js → CPhoneFormat-BS2nP9kc.js} +13 -21
  11. package/dist/CPhoneInput-Bf6329PO.js +207 -0
  12. package/dist/CPriceInput-d1yjuMQr.js +140 -0
  13. package/dist/CSelect-DgnT07Hk.js +98 -0
  14. package/dist/CSkeleton.vue_vue_type_script_setup_true_lang-Ckl--dyv.js +51 -0
  15. package/dist/ClientAutocomplete-9JzGcO9O.js +532 -0
  16. package/dist/ClientModal-BzWQtWSZ.js +1181 -0
  17. package/dist/ColorPicker-BvoFN8nu.js +1408 -0
  18. package/dist/CompanyModal-Bp4V_az9.js +250 -0
  19. package/dist/ContentWrapper-CuH6xKmo.js +265 -0
  20. package/dist/CoverBlockSettings-BA5L0Zee.js +861 -0
  21. package/dist/DocAnswer-BcNA_KEg.js +33 -0
  22. package/dist/DocDetails-CStEwWnU.js +448 -0
  23. package/dist/DocForm-BOoILf5E.js +6748 -0
  24. package/dist/DocFormSend-CQIf-HJY.js +171 -0
  25. package/dist/DocLinks-BRX5QzNe.js +36 -0
  26. package/dist/DocModalBase-D72yWj-x.js +29 -0
  27. package/dist/DocPrint-BI1LXUPE.js +399 -0
  28. package/dist/DocReceipt-DaZ4V76p.js +341 -0
  29. package/dist/DocSendReminder-DKGZlo7s.js +181 -0
  30. package/dist/DocTextEditor-Dm-cTZpA.js +19413 -0
  31. package/dist/DocTimeline-DCwofzuk.js +537 -0
  32. package/dist/DocumentClient-vJdxCB53.js +90 -0
  33. package/dist/DocumentLayout-CKSi42ev.js +1368 -0
  34. package/dist/DocumentLogotype-DbQlvQ-y.js +162 -0
  35. package/dist/DocumentVoided-CRX2WxWO.js +33 -0
  36. package/dist/EmbedInput-B-oeC4Wy.js +157 -0
  37. package/dist/EmbedSettings-B9Yka2yB.js +103 -0
  38. package/dist/ErrorCallout-B_ygH33E.js +34 -0
  39. package/dist/FilePreviewModal-Bf3ELTow.js +202 -0
  40. package/dist/Flag-BwTgCNHO.js +41 -0
  41. package/dist/HeaderSettings-DvC7nlyY.js +720 -0
  42. package/dist/ImageSelectModal-D3sP3lhR.js +119 -0
  43. package/dist/ImageUploadWrapper-RWNa-yIq.js +1585 -0
  44. package/dist/Index-0_3ULrWX.js +126 -0
  45. package/dist/Index-4NPe0sfX.js +629 -0
  46. package/dist/Index-B1uA0FF6.js +4 -0
  47. package/dist/Index-BBkCYm2q.js +201 -0
  48. package/dist/{Index-LzN6dktq.js → Index-BBwvo7S9.js} +10 -18
  49. package/dist/Index-BEMlsYwJ.js +68 -0
  50. package/dist/Index-BRBhJ6kz.js +21 -0
  51. package/dist/{Index-BPUYpfLJ.js → Index-BTFmHjUt.js} +47 -60
  52. package/dist/Index-BcUNnxLC.js +1098 -0
  53. package/dist/Index-Bo6ExBUL.js +93 -0
  54. package/dist/Index-BvMPCgdH.js +102 -0
  55. package/dist/Index-Bx5TOI9k.js +74 -0
  56. package/dist/Index-C7GZS8EI.js +16 -0
  57. package/dist/Index-CNWhm07R.js +25 -0
  58. package/dist/{Index-BUK-1yVR.js → Index-CQpznMKV.js} +9 -17
  59. package/dist/Index-CRzsnIij.js +159 -0
  60. package/dist/Index-CeSG1C41.js +140 -0
  61. package/dist/Index-CjfjdZj5.js +52 -0
  62. package/dist/Index-CskKmZpd.js +363 -0
  63. package/dist/Index-D5qwbCo1.js +28 -0
  64. package/dist/Index-D8Ae1Txt.js +228 -0
  65. package/dist/Index-DE8aenDB.js +3452 -0
  66. package/dist/Index-DI5EB5Rt.js +39 -0
  67. package/dist/Index-DaV57YPP.js +163 -0
  68. package/dist/Index-DbwkmoyM.js +38 -0
  69. package/dist/Index-Df9skok6.js +70 -0
  70. package/dist/{Index-BHJGfHm9.js → Index-DfLLA0ij.js} +313 -206
  71. package/dist/Index-Dw1CO5F9.js +76 -0
  72. package/dist/Index-PZXyOoVb.js +87 -0
  73. package/dist/{Index-BioOegOO.js → Index-ZUnH-BHj.js} +10 -18
  74. package/dist/Index-cjKGSiDi.js +136 -0
  75. package/dist/Index-m-goRuKD.js +49 -0
  76. package/dist/Index-rGeWbLcB.js +47 -0
  77. package/dist/Index-vrljNp6G.js +28 -0
  78. package/dist/Index.vue_vue_type_script_lang-aeVuChGF.js +671 -0
  79. package/dist/InputToggleRow-v6qAWPg6.js +99 -0
  80. package/dist/ManualPopover-BONBJIUA.js +57 -0
  81. package/dist/MediaWrapper-CXb2UGd9.js +18 -0
  82. package/dist/{NotBindingText-CM3FN0A6.js → NotBindingText-BqESO13N.js} +13 -17
  83. package/dist/PackageGroup-AIysVmyh.js +1058 -0
  84. package/dist/PdfTerms-BlhHdTu3.js +34 -0
  85. package/dist/PdfViewer-DwZ1rwlN.js +392 -0
  86. package/dist/PlainHtml.vue_vue_type_script_setup_true_lang-D6NNUTz0.js +17 -0
  87. package/dist/PriceHeader-C4XhnoA3.js +488 -0
  88. package/dist/SearchApi-B7lXgUY6.js +137 -0
  89. package/dist/SendForm-BcD0xSvB.js +7031 -0
  90. package/dist/Setup-C2qaYDei.js +47 -0
  91. package/dist/{SmartList-DhhjSWLO.js → SmartList-DqG7Q5t7.js} +16 -24
  92. package/dist/Sortable.vue_vue_type_script_setup_true_lang-CzMbr8AX.js +1303 -0
  93. package/dist/{TermsSettings-BEQwmkFH.js → TermsSettings-BOCONyM4.js} +169 -56
  94. package/dist/ThemeColorRow-sjGdMzGN.js +108 -0
  95. package/dist/ToggleBinding-7oq_oXPt.js +44 -0
  96. package/dist/UploadModal-C_X2NjVY.js +134 -0
  97. package/dist/VideoPlayerInput-BsUcmpl4.js +135 -0
  98. package/dist/VideoPlayerSettings-BXMmxaZQ.js +78 -0
  99. package/dist/VideoSelectModal-CW0OweCw.js +217 -0
  100. package/dist/{anime.es-BrPTThYb.js → anime.es-gdcpA-eY.js} +1 -2
  101. package/dist/{color-TdtKxwVa.js → color-HetJPhlA.js} +1 -2
  102. package/dist/{debounce-D0hKNU85.js → debounce-DNl99Gyo.js} +10 -10
  103. package/dist/dom-CkTGWrfu.js +69 -0
  104. package/dist/{focusDrawerMixin-C_aTLmK0.js → focusDrawerMixin-BwcErMDY.js} +1 -1
  105. package/dist/{formDrawerState-Da4mcbab.js → formDrawerState-DaurePnd.js} +2 -2
  106. package/dist/helpers-CPW--XIz.js +44 -0
  107. package/dist/index-BjiGCJPI.js +149 -0
  108. package/dist/index-CFNv6OvX.js +188 -0
  109. package/dist/index-Cx71On5Z.js +508 -0
  110. package/dist/index-DKMxIBz_.js +270 -0
  111. package/dist/index-DKf5SGLD.js +125 -0
  112. package/dist/index-E32WgUp9.js +3525 -0
  113. package/dist/index-kp-GC5I0.js +513 -0
  114. package/dist/index.es.js +2 -5
  115. package/dist/index.umd.js +285 -1485
  116. package/dist/{main-BgzLHIoo.js → main-Cb-nyil1.js} +41414 -42507
  117. package/dist/mapFormMixin-D3BihYWW.js +1544 -0
  118. package/dist/omit--YYr41Xp.js +31 -0
  119. package/dist/{publicSenderState-DB4BHByV.js → publicSenderState-CdRW_Wwp.js} +4 -4
  120. package/dist/splitpanes-D-ThFkeR.js +342 -0
  121. package/dist/style.css +1 -4
  122. package/dist/template-BvaNnq-g.js +1493 -0
  123. package/dist/{throttle-DT2UVOqm.js → throttle-D-bUGaVh.js} +2 -2
  124. package/dist/tippy.esm-BmKNqohP.js +1994 -0
  125. package/dist/useTermsModal-Dhf6_eYb.js +87 -0
  126. package/dist/{utils-nos8CB1L.js → utils-CBPcYdLv.js} +8 -11
  127. package/dist/validation-DOcUOoMe.js +40 -0
  128. package/package.json +18 -21
  129. package/dist/AddClientCallout-BJzBdba1.js +0 -48
  130. package/dist/AnswerModal-frHq1g4s.js +0 -3874
  131. package/dist/AttachmentItem-BaN0OrEV.js +0 -85
  132. package/dist/BaseDatePicker-B-AfdrSb.js +0 -3187
  133. package/dist/BaseUpload-CY3lTcte.js +0 -1977
  134. package/dist/BlockMedia-Bb5wQIDg.js +0 -76
  135. package/dist/CCallout-5quI6yyk.js +0 -58
  136. package/dist/CDropdownItem-CaoSQX6X.js +0 -640
  137. package/dist/CFormField-Dd2Y71JG.js +0 -240
  138. package/dist/CPhoneInput-BU1t6eo_.js +0 -138
  139. package/dist/CPriceInput-pv2aIVkH.js +0 -116
  140. package/dist/CSelect-CrM45B7V.js +0 -91
  141. package/dist/CSkeleton-BkvONMqL.js +0 -55
  142. package/dist/ClientAutocomplete-BRXIKQSk.js +0 -438
  143. package/dist/ClientModal-CvHAptV2.js +0 -666
  144. package/dist/ColorPicker-RgoXRrud.js +0 -2879
  145. package/dist/CompanyModal-OL4bD9Gk.js +0 -147
  146. package/dist/ContentWrapper-8HduCnR4.js +0 -190
  147. package/dist/CoverBlockSettings-DUv8AcdX.js +0 -659
  148. package/dist/DocAnswer-DiyFfpT2.js +0 -36
  149. package/dist/DocDetails-BxNRfBnK.js +0 -263
  150. package/dist/DocForm-MGp-o0pu.js +0 -5017
  151. package/dist/DocFormSend-q_QuVCqh.js +0 -146
  152. package/dist/DocLinks-DGDdp30U.js +0 -38
  153. package/dist/DocModalBase-qG4RqwBn.js +0 -28
  154. package/dist/DocPrint-Cln3kt0g.js +0 -240
  155. package/dist/DocReceipt-nbsJ-ukZ.js +0 -217
  156. package/dist/DocSendReminder-B3qdqduf.js +0 -140
  157. package/dist/DocTextEditor-CQDnjnRY.js +0 -17193
  158. package/dist/DocTimeline-CgKHoDcG.js +0 -485
  159. package/dist/DocumentClient-UZlnIlz5.js +0 -136
  160. package/dist/DocumentLayout-Dvr4zgyF.js +0 -4880
  161. package/dist/DocumentLogotype-mAVgMRHr.js +0 -92
  162. package/dist/DocumentVoided-BXYNrf_6.js +0 -25
  163. package/dist/EmbedInput-YRUrw3c6.js +0 -117
  164. package/dist/EmbedSettings-DvRreF7H.js +0 -74
  165. package/dist/ErrorCallout-DVknpLVY.js +0 -27
  166. package/dist/FilePreviewModal-DC56FaGy.js +0 -81
  167. package/dist/Flag-D5iZLESg.js +0 -46
  168. package/dist/HeaderSettings-DXZnZL7A.js +0 -440
  169. package/dist/ImageSelectModal-Bu4_xZga.js +0 -86
  170. package/dist/ImageUploadWrapper-CtZhkAm1.js +0 -1604
  171. package/dist/Index-B1dJO6Bk.js +0 -54
  172. package/dist/Index-B3pz1coY.js +0 -150
  173. package/dist/Index-BHgW8EHW.js +0 -2446
  174. package/dist/Index-BNucs2O-.js +0 -154
  175. package/dist/Index-BW-EtZ1z.js +0 -55
  176. package/dist/Index-BjKACpun.js +0 -66
  177. package/dist/Index-C94BL4uU.js +0 -294
  178. package/dist/Index-CB57haU8.js +0 -58
  179. package/dist/Index-CP17iXT6.js +0 -25
  180. package/dist/Index-CUSbvjoD.js +0 -62
  181. package/dist/Index-CVnD6jo5.js +0 -25
  182. package/dist/Index-Ci5zdPeT.js +0 -28
  183. package/dist/Index-CikqSMjb.js +0 -41
  184. package/dist/Index-CxO4tJ3U.js +0 -26
  185. package/dist/Index-D4J4BpHd.js +0 -230
  186. package/dist/Index-DAQQQlut.js +0 -754
  187. package/dist/Index-DNxSR72J.js +0 -73
  188. package/dist/Index-DPuKRwmu.js +0 -41
  189. package/dist/Index-DSy8QG8T.js +0 -32
  190. package/dist/Index-DX6_D-J-.js +0 -77
  191. package/dist/Index-Dk0KaIKg.js +0 -643
  192. package/dist/Index-Hkzoh9QR.js +0 -24
  193. package/dist/Index-KsHJxWAa.js +0 -94
  194. package/dist/Index-TtItTuv6.js +0 -33
  195. package/dist/Index-YAD39Qvg.js +0 -146
  196. package/dist/Index-eh909lAz.js +0 -107
  197. package/dist/Index-otowKI_C.js +0 -56
  198. package/dist/Index-t_oVV8Rc.js +0 -84
  199. package/dist/Index-vG96oEXZ.js +0 -144
  200. package/dist/InputToggleRow-CcqJDguN.js +0 -57
  201. package/dist/ManualPopover-BE2IN-XU.js +0 -60
  202. package/dist/MediaWrapper-lnGUFiyc.js +0 -23
  203. package/dist/PackageGroup-BsmxOMLW.js +0 -704
  204. package/dist/PdfTerms-BgYwZoAZ.js +0 -31
  205. package/dist/PdfViewer-C0lDpjte.js +0 -383
  206. package/dist/PlainHtml-5YwYVj1v.js +0 -27
  207. package/dist/PriceHeader-CxqhpGS-.js +0 -338
  208. package/dist/SearchApi-BndaIbri.js +0 -161
  209. package/dist/SendForm-D7U9fG-5.js +0 -1023
  210. package/dist/Setup-CmAK2_ZT.js +0 -50
  211. package/dist/ThemeColorRow-BlnhzebY.js +0 -69
  212. package/dist/ToggleBinding-t_58JFya.js +0 -42
  213. package/dist/UploadModal-T-WpYNsN.js +0 -95
  214. package/dist/VideoPlayerInput-DKHKjMgX.js +0 -97
  215. package/dist/VideoPlayerSettings-DDMlUvSt.js +0 -61
  216. package/dist/VideoSelectModal-B9bbP0dd.js +0 -104
  217. package/dist/answerDocumentMixin-DXI_E5Kx.js +0 -51
  218. package/dist/dom-CWsqMElk.js +0 -71
  219. package/dist/formValidationMixin-WZ2lGndu.js +0 -49
  220. package/dist/index-B2l57ilt.js +0 -102
  221. package/dist/index-COKDjmM2.js +0 -167
  222. package/dist/index-HtKGcIng.js +0 -2700
  223. package/dist/index-LQ7NztTt.js +0 -81
  224. package/dist/index-fx5gR8fM.js +0 -351
  225. package/dist/index-zXXJrTvv.js +0 -492
  226. package/dist/mapFormMixin-CQgSN7dv.js +0 -3028
  227. package/dist/omit-ScS7B6c5.js +0 -31
  228. package/dist/simplebar.min-B0cB_p8g.js +0 -71
  229. package/dist/splitpanes-BHUVsCZF.js +0 -382
  230. package/dist/tippy.esm-CR89mtdY.js +0 -1805
  231. package/dist/vuedraggable.umd-CkXXkt1b.js +0 -3161
  232. package/dist/vuex.esm-DKGl8mcw.js +0 -467
@@ -0,0 +1,3452 @@
1
+ import { m as F } from "./mapFormMixin-D3BihYWW.js";
2
+ import { C as ge } from "./CCallout-Cy2eeIYd.js";
3
+ import { C as q, a as G, w as ve } from "./CDropdownItem-Dmq5gYzA.js";
4
+ import { E as se } from "./ErrorCallout-B_ygH33E.js";
5
+ import { dD as fe, dE as ne, dF as ye, dG as ke, dH as be, dI as we, a1 as Ie, dJ as $e, _ as S, b as v, o as a, d as c, s as l, v as m, n as x, F as A, k as V, l as Z, f as w, e as u, m as R, a as B, g as M, A as j, w as g, Z as E, af as W, S as Q, ao as N, dC as _e, dK as X, aL as Te, a6 as ee, d7 as U, aK as Ae, dL as Ce, d8 as Pe, a3 as O, E as D, c as T, B as I, dM as xe, dN as Ve, dO as ae, U as Se, bE as oe, G as De, aa as P, aj as Me, I as Re, T as Le, aH as z, ab as Oe, ad as Ee, dP as Ue, a9 as Be, cU as We, aG as ze, bp as te } from "./main-Cb-nyil1.js";
6
+ import { u as Fe, a as je } from "./DocumentLayout-CKSi42ev.js";
7
+ import { T as Ne } from "./DocTextEditor-Dm-cTZpA.js";
8
+ import { _ as He, m as qe } from "./Sortable.vue_vue_type_script_setup_true_lang-CzMbr8AX.js";
9
+ import { o as le } from "./omit--YYr41Xp.js";
10
+ import { C as K } from "./CPriceInput-d1yjuMQr.js";
11
+ import { u as re } from "./index-kp-GC5I0.js";
12
+ import { S as Ge } from "./SearchApi-B7lXgUY6.js";
13
+ import { b as Ke } from "./index-BjiGCJPI.js";
14
+ import { _ as ce } from "./CFormField.vue_vue_type_script_setup_true_lang-D_U9coAY.js";
15
+ const Ye = [
16
+ "unit",
17
+ "m2",
18
+ "hour",
19
+ "m",
20
+ "m3",
21
+ "day",
22
+ "kg",
23
+ "litre",
24
+ "km",
25
+ "mile",
26
+ "month",
27
+ "week",
28
+ "ton",
29
+ "year",
30
+ "kWh"
31
+ ];
32
+ function Ze() {
33
+ }
34
+ var Je = Ze, J = fe, Qe = Je, Xe = ne, et = 1 / 0, tt = J && 1 / Xe(new J([, -0]))[1] == et ? function(e) {
35
+ return new J(e);
36
+ } : Qe, it = tt, st = ye, nt = ke, at = be, ot = we, lt = it, rt = ne, ct = 200;
37
+ function dt(e, t, s) {
38
+ var o = -1, n = nt, i = e.length, y = !0, h = [], f = h;
39
+ if (s)
40
+ y = !1, n = at;
41
+ else if (i >= ct) {
42
+ var p = t ? null : lt(e);
43
+ if (p)
44
+ return rt(p);
45
+ y = !1, n = ot, f = new st();
46
+ } else
47
+ f = t ? [] : h;
48
+ e:
49
+ for (; ++o < i; ) {
50
+ var b = e[o], k = t ? t(b) : b;
51
+ if (b = s || b !== 0 ? b : 0, y && k === k) {
52
+ for (var C = f.length; C--; )
53
+ if (f[C] === k)
54
+ continue e;
55
+ t && f.push(k), h.push(b);
56
+ } else n(f, k, s) || (f !== h && f.push(k), h.push(b));
57
+ }
58
+ return h;
59
+ }
60
+ var ut = dt, pt = $e, mt = ut;
61
+ function ht(e, t) {
62
+ return e && e.length ? mt(e, pt(t)) : [];
63
+ }
64
+ var gt = ht;
65
+ const vt = /* @__PURE__ */ Ie(gt), ft = {
66
+ name: "PackageGroupSelect",
67
+ i18nOptions: {
68
+ namespaces: "PackageGroupSelect",
69
+ messages: {
70
+ en: {
71
+ title: "What do you want to offer?",
72
+ typeOptions: {
73
+ single: {
74
+ title: "Single Option",
75
+ subTitle: "Offer one package."
76
+ },
77
+ radio: {
78
+ title: "Packages",
79
+ subTitle: "Offer several packages and let your client choose <strong>one<strong>."
80
+ },
81
+ checkbox: {
82
+ title: "Multi Options",
83
+ subTitle: "Offer many packages and let your client select <strong>multiple</strong> ones."
84
+ }
85
+ }
86
+ },
87
+ sv: {
88
+ title: "Vad vill du erbjuda för prisförslag?",
89
+ typeOptions: {
90
+ single: {
91
+ title: "Ett alternativ",
92
+ subTitle: "Erbjud ett paket."
93
+ },
94
+ radio: {
95
+ title: "Paket",
96
+ subTitle: "Erbjud flera paket och låt din kund välja <strong>ett</strong> av paketen."
97
+ },
98
+ checkbox: {
99
+ title: "Flera val",
100
+ subTitle: "Erbjud många paket som din kund välja <strong>flera</strong> utav."
101
+ }
102
+ }
103
+ }
104
+ }
105
+ },
106
+ emits: ["input"],
107
+ setup() {
108
+ return { docWidth: Fe() };
109
+ },
110
+ data() {
111
+ return {
112
+ options: [
113
+ {
114
+ value: "single",
115
+ background: "hsl(209, 94%, 73%)",
116
+ title: this.$t("typeOptions.single.title"),
117
+ subTitle: this.$t("typeOptions.single.subTitle")
118
+ },
119
+ {
120
+ value: "radio",
121
+ background: "hsl(222, 96%, 73%)",
122
+ title: this.$t("typeOptions.radio.title"),
123
+ subTitle: this.$t("typeOptions.radio.subTitle")
124
+ },
125
+ {
126
+ value: "checkbox",
127
+ background: "hsl(241, 95%, 73%)",
128
+ title: this.$t("typeOptions.checkbox.title"),
129
+ subTitle: this.$t("typeOptions.checkbox.subTitle")
130
+ }
131
+ ]
132
+ };
133
+ }
134
+ }, yt = {
135
+ class: "font-inter",
136
+ style: { padding: "calc(2 * var(--rem)) 0 calc(1 * var(--rem)) 0", color: "#111" }
137
+ }, kt = { style: { "font-size": "18px", "font-weight": "600", "text-align": "center", "margin-bottom": "calc(1.5 * var(--rem))" } }, bt = ["onClick"], wt = { class: "package-group-option__illustration" }, It = {
138
+ key: 0,
139
+ class: "package-group-option__illustration-card animate"
140
+ }, $t = { class: "package-group-option__title" }, _t = ["innerHTML"];
141
+ function Tt(e, t, s, o, n, i) {
142
+ const y = v("CIcon");
143
+ return a(), c("div", yt, [
144
+ l("div", kt, m(e.$t("title")), 1),
145
+ l("div", null, [
146
+ l("div", {
147
+ class: x([{ "is-700-or-less": o.docWidth <= 700 }, "options"])
148
+ }, [
149
+ (a(!0), c(A, null, V(n.options, (h, f) => (a(), c("div", {
150
+ key: f,
151
+ style: Z({ backgroundColor: h.background }),
152
+ class: "package-group-option",
153
+ onClick: (p) => e.$emit("input", h.value)
154
+ }, [
155
+ l("div", wt, [
156
+ h.value === "single" ? (a(), c("div", It, t[0] || (t[0] = [
157
+ l("div", { style: { flex: "1 1 auto" } }, [
158
+ l("div", {
159
+ style: { width: "40%", height: "10px", "margin-bottom": "8px" },
160
+ class: "bg-gray-100"
161
+ }),
162
+ l("div", {
163
+ style: { width: "80%", height: "10px" },
164
+ class: "bg-gray-100"
165
+ })
166
+ ], -1)
167
+ ]))) : w("", !0),
168
+ h.value === "radio" ? (a(), c(A, { key: 1 }, V(3, (p) => l("div", {
169
+ key: p,
170
+ class: x([{ animate: p === 2 }, "package-group-option__illustration-card"])
171
+ }, [
172
+ l("div", {
173
+ style: Z([
174
+ p === 2 && {
175
+ boxShadow: `0 0 0 1px white, 0 0 0 2px ${h.background}`,
176
+ backgroundColor: h.background
177
+ },
178
+ { width: "8px", height: "8px", "border-radius": "50%", "box-shadow": `0 0 0 1px white,
179
+ 0 0 0 2px hsl(0, 0%, 76%)`, "margin-right": "10px" }
180
+ ])
181
+ }, null, 4),
182
+ t[1] || (t[1] = l("div", { style: { flex: "1 1 auto" } }, [
183
+ l("div", {
184
+ style: { width: "40%", height: "10px", "margin-bottom": "8px" },
185
+ class: "bg-gray-100"
186
+ }),
187
+ l("div", {
188
+ style: { width: "80%", height: "10px" },
189
+ class: "bg-gray-100"
190
+ })
191
+ ], -1))
192
+ ], 2)), 64)) : w("", !0),
193
+ h.value === "checkbox" ? (a(), c(A, { key: 2 }, V(3, (p) => l("div", {
194
+ key: p,
195
+ class: x([{ animate: p !== 3 }, "package-group-option__illustration-card"])
196
+ }, [
197
+ l("div", {
198
+ style: Z([p !== 3 && { backgroundColor: h.background }, { height: "12px", width: "12px", "border-radius": "2px", "background-color": "hsl(0, 0%, 76%)", "margin-right": "10px", color: "white", padding: "1px", display: "inline-flex", "align-items": "center", "justify-content": "center" }])
199
+ }, [
200
+ u(y, {
201
+ type: p !== 3 ? "check" : "empty",
202
+ "stroke-width": "5",
203
+ size: "8"
204
+ }, null, 8, ["type"])
205
+ ], 4),
206
+ t[2] || (t[2] = l("div", { style: { flex: "1 1 auto" } }, [
207
+ l("div", {
208
+ style: { width: "40%", height: "10px", "margin-bottom": "8px" },
209
+ class: "bg-gray-100"
210
+ }),
211
+ l("div", {
212
+ style: { width: "80%", height: "10px" },
213
+ class: "bg-gray-100"
214
+ })
215
+ ], -1))
216
+ ], 2)), 64)) : w("", !0)
217
+ ]),
218
+ l("div", null, [
219
+ l("div", $t, m(h.title), 1),
220
+ l("div", {
221
+ class: "package-group-option__subtitle",
222
+ innerHTML: h.subTitle
223
+ }, null, 8, _t)
224
+ ])
225
+ ], 12, bt))), 128))
226
+ ], 2)
227
+ ])
228
+ ]);
229
+ }
230
+ const At = /* @__PURE__ */ S(ft, [["render", Tt], ["__scopeId", "data-v-6f6b9465"]]), Ct = {
231
+ name: "ArticleAutocomplete",
232
+ components: {
233
+ SearchApi: Ge
234
+ },
235
+ mixins: [F([])],
236
+ props: {
237
+ tag: {
238
+ type: String,
239
+ default: null
240
+ },
241
+ modelValue: {
242
+ type: String,
243
+ required: !0
244
+ },
245
+ placement: {
246
+ type: String,
247
+ default: "bottom-start"
248
+ }
249
+ },
250
+ emits: ["update:modelValue", "select", "focus", "blur"],
251
+ data() {
252
+ return {
253
+ isFocus: !1,
254
+ isOpen: !1,
255
+ selectedIndex: 0,
256
+ searchResults: []
257
+ };
258
+ },
259
+ computed: {
260
+ ...R({
261
+ articleData: "articles/articles",
262
+ ids: "articles/articleIdList"
263
+ }),
264
+ whiteList() {
265
+ const e = [];
266
+ if (this.$refs.dropdown !== void 0) {
267
+ const t = this.$refs.dropdown.querySelectorAll("*");
268
+ for (const s of t)
269
+ e.push(s);
270
+ }
271
+ if (this.$refs.input !== void 0) {
272
+ const t = this.$refs.input.$el.querySelectorAll("*");
273
+ for (const s of t)
274
+ e.push(s);
275
+ }
276
+ return e;
277
+ }
278
+ },
279
+ watch: {
280
+ searchResults(e, t) {
281
+ e.length !== t.length && (this.selectedIndex = 0);
282
+ }
283
+ },
284
+ created() {
285
+ document.addEventListener("click", this.onClickOutside, { passive: !0 });
286
+ },
287
+ beforeUnmount() {
288
+ document.removeEventListener("click", this.onClickOutside, {
289
+ passive: !0
290
+ });
291
+ },
292
+ methods: {
293
+ ...B({
294
+ loadArticles: M.LOAD_ARTICLES
295
+ }),
296
+ priceFormat: j,
297
+ search(e, t) {
298
+ this.$emit("update:modelValue", t), !this.viewSettings.isPublicForm && e({
299
+ q: t,
300
+ cb: ({ article: s = [], extensionArticle: o = [] }) => {
301
+ this.searchResults = [
302
+ ...s.sort((n, i) => n.usedTimes > i.usedTimes ? -1 : 1),
303
+ ...o
304
+ ], !this.isOpen && this.searchResults.length && this.showResults();
305
+ }
306
+ });
307
+ },
308
+ // Function consumed by parent
309
+ focus() {
310
+ this.$refs.input.focus();
311
+ },
312
+ onFocus(e) {
313
+ this.isFocus = !0, this.$emit("focus", e);
314
+ },
315
+ onBlur(e) {
316
+ this.isFocus = !1, this.$emit("blur", e);
317
+ },
318
+ showResults() {
319
+ this.isOpen = !0;
320
+ },
321
+ hideResults() {
322
+ this.isOpen = !1;
323
+ },
324
+ onSelect(e) {
325
+ this.$emit("select", e), this.hideResults(), this.$refs.input && this.$refs.input.blur();
326
+ },
327
+ onClickOutside(e) {
328
+ this.whiteList.indexOf(e.target) < 0 && this.hideResults();
329
+ },
330
+ onKeydown({ keyCode: e }) {
331
+ if (this.isOpen) {
332
+ switch (e) {
333
+ case 38:
334
+ this.selectedIndex > 0 && this.selectedIndex--;
335
+ break;
336
+ case 40:
337
+ this.selectedIndex < this.searchResults.length - 1 && this.selectedIndex++;
338
+ break;
339
+ case 13:
340
+ this.searchResults[this.selectedIndex] && (this.onSelect(this.searchResults[this.selectedIndex]), this.searchResults = []);
341
+ break;
342
+ }
343
+ this.scrollToHighlighted();
344
+ }
345
+ },
346
+ scrollToHighlighted() {
347
+ !this.$refs.dropdown || !this.$refs.dropdown.children || !this.$refs.dropdown.children[this.selectedIndex] || this.$refs.dropdown.children[this.selectedIndex].scrollIntoView({
348
+ block: "nearest"
349
+ });
350
+ }
351
+ }
352
+ }, Pt = {
353
+ key: 0,
354
+ ref: "dropdown",
355
+ class: "r-container"
356
+ }, xt = ["onClickCapture"], Vt = { class: "r-item-title truncate-text" }, St = { class: "r-item-details" }, Dt = {
357
+ key: 0,
358
+ style: { width: "18px", height: "18px", "border-radius": "2px", "background-color": "hsl(0, 0%, 60%)", display: "inline-flex", "justify-content": "center", "align-items": "center" }
359
+ }, Mt = { key: 1 }, Rt = { key: 2 }, Lt = { key: 3 }, Ot = {
360
+ key: 0,
361
+ class: "r-item-icon"
362
+ };
363
+ function Et(e, t, s, o, n, i) {
364
+ const y = v("CInput"), h = v("SearchApi"), f = v("CIcon");
365
+ return a(), c("div", E({
366
+ class: { "is-open": n.isOpen }
367
+ }, e.$attrs, {
368
+ style: { position: "relative" },
369
+ onKeydownPassive: t[0] || (t[0] = (...p) => i.onKeydown && i.onKeydown(...p))
370
+ }), [
371
+ u(h, { "custom-search": {
372
+ article: !0,
373
+ extensionArticle: !0,
374
+ project: !1
375
+ } }, {
376
+ default: g(({ fetch: p }) => [
377
+ u(y, E({
378
+ ...e.$attrs,
379
+ ...e.$props
380
+ }, {
381
+ ref: "input",
382
+ "model-value": s.modelValue,
383
+ type: s.tag,
384
+ "auto-resize": !0,
385
+ class: "r-input",
386
+ "onUpdate:modelValue": (b) => i.search(p, b),
387
+ onFocus: i.onFocus,
388
+ onKeydown: [
389
+ W(i.hideResults, ["tab"]),
390
+ W(i.hideResults, ["escape"])
391
+ ],
392
+ onBlur: i.onBlur
393
+ }), {
394
+ prefix: g(() => [
395
+ Q(e.$slots, "prefix", {}, void 0, !0)
396
+ ]),
397
+ suffix: g(() => [
398
+ Q(e.$slots, "suffix", {}, void 0, !0)
399
+ ]),
400
+ _: 2
401
+ }, 1040, ["model-value", "type", "onUpdate:modelValue", "onFocus", "onKeydown", "onBlur"])
402
+ ]),
403
+ _: 3
404
+ }),
405
+ n.isOpen ? (a(), c("div", Pt, [
406
+ (a(!0), c(A, null, V(n.searchResults, (p, b) => (a(), c("div", {
407
+ key: b,
408
+ class: x([{ active: n.selectedIndex === b }, "r-item"]),
409
+ onClickCapture: N((k) => i.onSelect(p), ["stop"])
410
+ }, [
411
+ l("div", Vt, m(p.name), 1),
412
+ l("div", St, [
413
+ p.externalReference && p.externalReference.service ? (a(), c("div", Dt, [
414
+ u(f, {
415
+ type: p.externalReference.service,
416
+ style: { color: "white" },
417
+ size: "14"
418
+ }, null, 8, ["type"])
419
+ ])) : w("", !0),
420
+ p.article_no ? (a(), c("div", Mt, m(p.article_no), 1)) : w("", !0),
421
+ p.price ? (a(), c("div", Rt, m(i.priceFormat(p.price, { currency: p.currency })), 1)) : w("", !0),
422
+ p.vat ? (a(), c("div", Lt, m(e.$t("vat.sharedTitle").capitalize()) + " " + m(p.vat) + "% ", 1)) : w("", !0)
423
+ ]),
424
+ n.selectedIndex === b ? (a(), c("div", Ot, [
425
+ u(f, {
426
+ type: "corner-down-left",
427
+ size: "16"
428
+ })
429
+ ])) : w("", !0)
430
+ ], 42, xt))), 128))
431
+ ], 512)) : w("", !0)
432
+ ], 16);
433
+ }
434
+ const de = /* @__PURE__ */ S(Ct, [["render", Et], ["__scopeId", "data-v-724e4465"]]), ie = {
435
+ isDeductable: !1,
436
+ isRut: !1,
437
+ greenRot15: !1,
438
+ greenRot20: !1,
439
+ greenRot50: !1
440
+ }, H = (e, t = "", s) => {
441
+ let o = {
442
+ ...e,
443
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
444
+ // Trigger updatedAt as it us used to decide which houseWork to prioritize
445
+ };
446
+ return typeof s < "u" && (o[s] = t), Object.keys(ie).includes(s) && t && (o = {
447
+ ...o,
448
+ ...ie,
449
+ [s]: !0
450
+ }), _e(o.quantity) !== "number" && (o.quantity = 0), X(o);
451
+ }, ue = ({
452
+ stored: e,
453
+ current: t,
454
+ hidePrice: s = !1,
455
+ activeHouseWorkType: o
456
+ }) => {
457
+ let n = Te({
458
+ ...e,
459
+ quantity: 1,
460
+ showPrice: !s,
461
+ id: null,
462
+ ArticleId: e.id,
463
+ packageId: t.packageId
464
+ });
465
+ if (o) {
466
+ const i = (f = []) => f.reduce((p, b) => ({ ...p, [b]: !1 }), {}), h = Object.values(
467
+ le({
468
+ rot: "isDeductable",
469
+ rut: "isRut",
470
+ greenRot15: "greenRot15",
471
+ greenRot20: "greenRot20",
472
+ greenRot50: "greenRot50"
473
+ }, [o])
474
+ );
475
+ h.some((f) => !!n[f]) && (n = { ...n, ...i(h) });
476
+ }
477
+ return n;
478
+ }, Ut = (e, t = null) => {
479
+ const s = ee(e.currency, t);
480
+ switch (e.priceType) {
481
+ case "approx":
482
+ return `${Ae.t("_common:approx")} ${s}`;
483
+ case "openAcc":
484
+ return `${s}/${U(e.unitType)}`;
485
+ case "markup":
486
+ return "%";
487
+ default:
488
+ return s;
489
+ }
490
+ }, pe = {
491
+ en: {
492
+ namePlaceholder: "Service or product name",
493
+ openModalTooltip: "Edit amount and unit",
494
+ hidePriceLabel: "Hide price for client",
495
+ saveAndAddTooltip: "Save and quick-add",
496
+ priceTypeTooltips: {
497
+ fixed: "The service / product is offered at a fixed price",
498
+ approx: "Show that the price is approximate",
499
+ openAcc: "Pricing on demand. E.g. charging per hour",
500
+ markup: "Show that you take a percentage markup"
501
+ },
502
+ priceTypeShort: {
503
+ approx: "Approximate price",
504
+ markup: "Markup",
505
+ openAcc: "Open Account"
506
+ },
507
+ validations: {
508
+ name: {
509
+ maxLength: "Max length of name is 255 characters"
510
+ }
511
+ }
512
+ },
513
+ sv: {
514
+ namePlaceholder: "T.ex. arbete & material",
515
+ openModalTooltip: "Justera antal / enhet",
516
+ hidePriceLabel: "Dölj pris för kund",
517
+ saveAndAddTooltip: "Spara och lägg till ny",
518
+ priceTypeTooltips: {
519
+ fixed: "Tjänsten/varan erbjuds till fast pris",
520
+ approx: "Markera att priset är ungefärligt",
521
+ openAcc: "Tjänsten / varan erbjuds löpandes",
522
+ markup: "Markera att du tar ett procentuellt påslag"
523
+ },
524
+ priceTypeShort: {
525
+ approx: "Ca. pris",
526
+ markup: "Påslag",
527
+ openAcc: "Löp. pris"
528
+ },
529
+ validations: {
530
+ name: {
531
+ maxLength: "Namnet får vara max 255 tecken långt"
532
+ }
533
+ }
534
+ }
535
+ }, me = {
536
+ article: {
537
+ name: {
538
+ maxLength: Ke(255)
539
+ }
540
+ }
541
+ }, Bt = {
542
+ // eslint-disable-next-line vue/no-reserved-component-names
543
+ name: "Article",
544
+ i18nOptions: {
545
+ namespaces: "Article",
546
+ messages: pe
547
+ },
548
+ components: {
549
+ ErrorCallout: se,
550
+ ArticleAutocomplete: de,
551
+ CPriceInput: K
552
+ },
553
+ expose: ["focusName"],
554
+ props: {
555
+ // Article object
556
+ value: {
557
+ type: Object,
558
+ required: !0
559
+ },
560
+ // If remove button is visible
561
+ enableRemove: {
562
+ type: Boolean,
563
+ default: !0
564
+ },
565
+ width: {
566
+ type: Number,
567
+ default: 1e3
568
+ },
569
+ hidePriceInput: {
570
+ type: Boolean,
571
+ default: !1
572
+ },
573
+ hidePriceOnNew: {
574
+ type: Boolean,
575
+ default: !1
576
+ },
577
+ isIncVat: {
578
+ type: Boolean,
579
+ default: !1
580
+ },
581
+ hideControls: {
582
+ type: Boolean,
583
+ default: !1
584
+ },
585
+ rootPriceType: {
586
+ type: String,
587
+ default: null
588
+ },
589
+ // The current active houseWorkType allowed when adding new articles from search
590
+ activeHouseWorkType: {
591
+ type: String,
592
+ default: null
593
+ }
594
+ },
595
+ emits: ["input", "open-modal", "remove", "focus", "select", "add", "esc"],
596
+ setup() {
597
+ return {
598
+ v$: re()
599
+ };
600
+ },
601
+ validations: me,
602
+ data() {
603
+ return {
604
+ updateData: H,
605
+ addSavedArticle: ue,
606
+ articleUnitLabel: U,
607
+ widthCompact: 580,
608
+ visualDisable: !1
609
+ };
610
+ },
611
+ computed: {
612
+ article: {
613
+ get() {
614
+ return this.value || {};
615
+ },
616
+ set(e) {
617
+ this.$emit("input", e);
618
+ }
619
+ },
620
+ details() {
621
+ const e = [], {
622
+ priceType: t,
623
+ quantity: s,
624
+ unitType: o,
625
+ price: n,
626
+ vat: i,
627
+ discount: y,
628
+ discountType: h
629
+ } = this.article;
630
+ if (t !== "fixed" && e.push({ title: this.$t(`priceTypeShort.${t}`) }), Ce(this.article)) {
631
+ const f = Pe(this.article);
632
+ e.push({
633
+ title: this.$t(`_common:deduction.${f}_percentage`)
634
+ });
635
+ }
636
+ return s && ["fixed", "approx"].includes(t) && (o !== "unit" || s > 1) && e.push({
637
+ title: U(this.article.unitType, {
638
+ count: s,
639
+ includeCount: !0
640
+ }),
641
+ ...!this.hidePriceInput && {
642
+ icon: '<svg style="margin: 0 4px;" width="6" height="6" viewBox="0 0 148 141" xmlns="http://www.w3.org/2000/svg"><path d="M73.742787 92.65535l-34.444359 47.40859-18.607391-13.51906 34.060775-46.88064L0 61.8743 7.107391 40 62 57.83569V0h23v57.99346L140.378182 40l7.107391 21.8743-54.751812 17.78994 34.060775 46.88064-18.607391 13.51906-34.444358-47.40859z" fill="currentColor" fill-rule="evenodd"/></svg>',
643
+ subTitle: j(n, {
644
+ showZero: !0,
645
+ withVat: this.isIncVat ? i : !1,
646
+ currency: this.article.currency,
647
+ decimals: 2,
648
+ hideZeroDecimals: !0
649
+ })
650
+ }
651
+ }), y && e.push({
652
+ title: "-" + (h === "fixed" ? j(y, {
653
+ withVat: this.isIncVat ? i : !1,
654
+ currency: this.article.currency
655
+ }) : `${y / 100} %`),
656
+ detailClass: "discount"
657
+ }), e;
658
+ }
659
+ },
660
+ methods: {
661
+ updateArticle(e, t) {
662
+ this.article = H(this.article, e, t);
663
+ },
664
+ onTotalPriceInputFocus() {
665
+ (this.article.discount || this.article.quantity !== 1) && this.$emit("open-modal", { focusEl: "priceInput" });
666
+ },
667
+ focusName() {
668
+ this.$refs.name.focus();
669
+ },
670
+ errorMessage(e) {
671
+ var t;
672
+ return e.$error && e.article.name.$error && ((t = e.article.name.maxLength) != null && t.$invalid) ? this.$t("validations.name.maxLength") : null;
673
+ }
674
+ }
675
+ }, Wt = { class: "top-row flex w-full" }, zt = ["innerHTML"];
676
+ function Ft(e, t, s, o, n, i) {
677
+ const y = v("CIcon"), h = v("ArticleAutocomplete"), f = v("CPriceInput"), p = v("ErrorCallout"), b = O("tooltip");
678
+ return a(), c("div", {
679
+ class: x([{
680
+ "has-details": i.details.length,
681
+ compact: s.width <= n.widthCompact,
682
+ "show-controls": !s.hideControls
683
+ }, "article-wrapper"]),
684
+ onKeydown: t[10] || (t[10] = W((k) => e.$emit("esc"), ["esc"]))
685
+ }, [
686
+ l("div", Wt, [
687
+ u(h, E({
688
+ ref: "name",
689
+ "model-value": i.article.name,
690
+ placeholder: e.$t("namePlaceholder"),
691
+ size: "large",
692
+ class: "article-name-wrapper article-input-wrapper form-control form-control-left"
693
+ }, e.$attrs, {
694
+ "onUpdate:modelValue": t[1] || (t[1] = (k) => i.updateArticle(k, "name")),
695
+ onFocus: t[2] || (t[2] = (k) => e.$emit("focus")),
696
+ onSelect: t[3] || (t[3] = () => {
697
+ e.$emit(
698
+ "input",
699
+ n.addSavedArticle({
700
+ stored: e.$event,
701
+ current: i.article,
702
+ hidePrice: s.hidePriceOnNew,
703
+ activeHouseWorkType: s.activeHouseWorkType
704
+ })
705
+ ), e.$emit("select");
706
+ })
707
+ }), {
708
+ suffix: g(() => [
709
+ s.hideControls ? w("", !0) : D((a(), c("div", {
710
+ key: 0,
711
+ class: "article-button fade-in",
712
+ onClick: t[0] || (t[0] = (k) => e.$emit("open-modal"))
713
+ }, [
714
+ u(y, {
715
+ type: "cog",
716
+ size: "18"
717
+ })
718
+ ])), [
719
+ [b, {
720
+ content: e.$t("openModalTooltip"),
721
+ delay: { show: 300, hide: 0 }
722
+ }]
723
+ ])
724
+ ]),
725
+ _: 1
726
+ }, 16, ["model-value", "placeholder"]),
727
+ s.hidePriceInput ? w("", !0) : (a(), T(f, E({
728
+ key: s.rootPriceType + i.article.priceType + i.article.unitType,
729
+ "model-value": i.article.totalAmount,
730
+ currency: i.article.currency,
731
+ "is-inc-vat": i.article.priceType !== "markup" && s.isIncVat,
732
+ vat: i.article.vat,
733
+ placeholder: e.$t("_common:price.price").capitalize(),
734
+ "price-type": i.article.priceType,
735
+ "unit-label": n.articleUnitLabel(i.article.unitType),
736
+ class: "form-control form-control-right",
737
+ style: { flex: "1 1", "min-width": "200px" }
738
+ }, e.$attrs, {
739
+ "onUpdate:modelValue": t[4] || (t[4] = (k) => i.updateArticle(k, "price")),
740
+ "onUpdate:currency": t[5] || (t[5] = (k) => e.$emit("update:currency", k)),
741
+ onFocus: t[6] || (t[6] = () => {
742
+ i.onTotalPriceInputFocus(), e.$emit("focus");
743
+ }),
744
+ onKeydown: t[7] || (t[7] = W((k) => e.$emit("add"), ["enter"]))
745
+ }), null, 16, ["model-value", "currency", "is-inc-vat", "vat", "placeholder", "price-type", "unit-label"])),
746
+ s.hideControls ? w("", !0) : (a(), c(A, { key: 1 }, [
747
+ u(y, {
748
+ class: "a-control-button close-button fade-in",
749
+ circle: "",
750
+ type: "x",
751
+ size: "18",
752
+ onClick: t[8] || (t[8] = (k) => s.enableRemove ? e.$emit("remove") : null)
753
+ }),
754
+ u(y, {
755
+ class: x([{ "c-hidden": !s.enableRemove }, "a-control-button fade-in move-button article-draggable-handle"]),
756
+ circle: "",
757
+ type: "handle",
758
+ size: "18"
759
+ }, null, 8, ["class"])
760
+ ], 64))
761
+ ]),
762
+ i.details.length ? (a(), c("div", {
763
+ key: 0,
764
+ class: "article-details-wrapper",
765
+ style: { cursor: "pointer" },
766
+ onClick: t[9] || (t[9] = (k) => e.$emit("open-modal"))
767
+ }, [
768
+ (a(!0), c(A, null, V(i.details, ({ title: k, icon: C, subTitle: d = "", detailClass: $ = "" }, r) => (a(), c("div", {
769
+ key: r,
770
+ class: x([[$], "article-details-item"])
771
+ }, [
772
+ I(m(k) + " ", 1),
773
+ C ? (a(), c("div", {
774
+ key: 0,
775
+ innerHTML: C
776
+ }, null, 8, zt)) : w("", !0),
777
+ I(" " + m(d), 1)
778
+ ], 2))), 128))
779
+ ])) : w("", !0),
780
+ o.v$.$invalid && o.v$.$dirty ? (a(), T(p, {
781
+ key: 1,
782
+ message: i.errorMessage(o.v$)
783
+ }, null, 8, ["message"])) : w("", !0)
784
+ ], 34);
785
+ }
786
+ const jt = /* @__PURE__ */ S(Bt, [["render", Ft], ["__scopeId", "data-v-df3528c4"]]), Nt = {
787
+ emits: ["go", "close"],
788
+ props: {
789
+ canForward: {
790
+ type: Boolean,
791
+ default: !1
792
+ },
793
+ canBackward: {
794
+ type: Boolean,
795
+ default: !1
796
+ }
797
+ },
798
+ created() {
799
+ document.addEventListener("keyup", this.onKeyUp);
800
+ },
801
+ beforeUnmount() {
802
+ this.removeKeyHandler();
803
+ },
804
+ methods: {
805
+ getNavTooltip(e) {
806
+ return e === -1 ? {
807
+ content: `
808
+ <div style='margin-bottom: 0.6em;'>
809
+ ${this.$t("show", { thing: this.$t("previous") })}
810
+ </div>
811
+ <div class='flex items-center justify-center w-full' style='padding-bottom: 0.5em;'>
812
+ <div style='text-align: center; background-color: hsl(0, 0%, 40%); line-height: 1; border-radius: 0.5em; display: inline-flex; align-items: center; justify-content: center; padding: 0.5em;'>
813
+ <svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M19 12H6M12 5l-7 7 7 7'></path></svg>
814
+ </div>
815
+ </div>
816
+ `,
817
+ html: !0
818
+ } : e === 1 ? {
819
+ content: `
820
+ <div style='margin-bottom: 0.6em;'>
821
+ ${this.$t("show", { thing: this.$t("next") })}
822
+ </div>
823
+ <div class='flex items-center justify-center w-full' style='padding-bottom: 0.5em;'>
824
+ <div style='text-align: center; background-color: hsl(0, 0%, 40%); line-height: 1; border-radius: 0.5em; display: inline-flex; align-items: center; justify-content: center; padding: 0.5em;'>
825
+ <svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12h13M12 5l7 7-7 7'/></svg>
826
+ </div>
827
+ </div>
828
+ `,
829
+ html: !0
830
+ } : e === "close" ? {
831
+ content: '<div style="margin-bottom: 0.6em;">Stäng</div><div style="text-align: center; opacity: 0.85;"><svg width="30" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="17 0 105.5 72" style="enable-background:new 17 0 105.5 72"><path d="M103.3 70.3H36.2c-9.6 0-17.5-7.9-17.5-17.5V19.2c0-9.6 7.9-17.5 17.5-17.5h67.1c9.6 0 17.5 7.9 17.5 17.5v33.6c0 9.6-7.9 17.5-17.5 17.5z" style="fill:none;stroke:currentColor;stroke-width:3;stroke-miterlimit:10"/><path style="fill:none" d="M17 17.8h105.5V49H17z"/><path fill="currentColor" d="M46.6 38.2c.1 5 3.3 7.1 7 7.1 2.6 0 4.2-.5 5.6-1l.6 2.6c-1.3.6-3.5 1.3-6.8 1.3-6.3 0-10-4.1-10-10.2s3.6-11 9.5-11c6.6 0 8.4 5.8 8.4 9.6 0 .8-.1 1.3-.1 1.7l-14.2-.1zm10.9-2.7c0-2.4-1-6-5.1-6-3.7 0-5.4 3.4-5.7 6h10.8zM65.1 43.9c1.1.7 3 1.5 4.9 1.5 2.7 0 3.9-1.3 3.9-3 0-1.8-1-2.7-3.8-3.7-3.7-1.3-5.4-3.3-5.4-5.8 0-3.3 2.6-6 7-6 2.1 0 3.9.6 5 1.3l-.9 2.7c-.8-.5-2.3-1.2-4.2-1.2-2.2 0-3.4 1.3-3.4 2.8 0 1.7 1.2 2.4 3.9 3.4 3.5 1.3 5.3 3.1 5.3 6.1 0 3.6-2.8 6.1-7.6 6.1-2.2 0-4.3-.5-5.7-1.4l1-2.8zM96.7 46.9c-1 .5-3.1 1.2-5.8 1.2-6.1 0-10.1-4.2-10.1-10.4 0-6.3 4.3-10.8 10.9-10.8 2.2 0 4.1.5 5.1 1l-.8 2.9c-.9-.5-2.3-1-4.3-1-4.7 0-7.2 3.4-7.2 7.7 0 4.7 3 7.6 7.1 7.6 2.1 0 3.5-.5 4.5-1l.6 2.8z"/></svg></div>',
832
+ html: !0
833
+ } : null;
834
+ },
835
+ onKeyUp(e) {
836
+ const t = document.activeElement;
837
+ !(t.hasAttribute("contenteditable") || ["input", "textarea"].includes(t.tagName.toLowerCase())) && (parseInt(e.keyCode, 10) === 37 && this.$emit("go", -1), parseInt(e.keyCode, 10) === 39 && this.$emit("go", 1));
838
+ const o = e.key || e.keyCode;
839
+ if (o === "Escape" || o === "Esc" || o === 27) {
840
+ const n = this.$modal.getOpenInstances();
841
+ if (e.defaultPrevented || n.length) return;
842
+ this.$emit("close");
843
+ }
844
+ },
845
+ removeKeyHandler() {
846
+ document.removeEventListener("keyup", this.onKeyUp);
847
+ }
848
+ }
849
+ }, Ht = { class: "l-root" };
850
+ function qt(e, t, s, o, n, i) {
851
+ const y = O("tooltip");
852
+ return a(), c("div", Ht, [
853
+ D((a(), c("div", {
854
+ class: x([{ disabled: !s.canBackward }, "l-button"]),
855
+ style: { left: "calc(-4 * var(--rem))" },
856
+ onClick: t[0] || (t[0] = (h) => e.$emit("go", -1))
857
+ }, t[2] || (t[2] = [
858
+ l("svg", {
859
+ xmlns: "http://www.w3.org/2000/svg",
860
+ width: "35",
861
+ height: "35",
862
+ viewBox: "0 0 24 24",
863
+ fill: "none",
864
+ stroke: "currentColor",
865
+ "stroke-width": "2",
866
+ "stroke-linecap": "round",
867
+ "stroke-linejoin": "round"
868
+ }, [
869
+ l("path", { d: "M15 18l-6-6 6-6" })
870
+ ], -1)
871
+ ]), 2)), [
872
+ [y, i.getNavTooltip(-1)]
873
+ ]),
874
+ D((a(), c("div", {
875
+ class: x([{ disabled: !s.canForward }, "l-button"]),
876
+ style: { right: "calc(-4 * var(--rem))" },
877
+ onClick: t[1] || (t[1] = (h) => e.$emit("go", 1))
878
+ }, t[3] || (t[3] = [
879
+ l("svg", {
880
+ xmlns: "http://www.w3.org/2000/svg",
881
+ width: "35",
882
+ height: "35",
883
+ viewBox: "0 0 24 24",
884
+ fill: "none",
885
+ stroke: "currentColor",
886
+ "stroke-width": "2",
887
+ "stroke-linecap": "round",
888
+ "stroke-linejoin": "round"
889
+ }, [
890
+ l("path", { d: "M9 18l6-6-6-6" })
891
+ ], -1)
892
+ ]), 2)), [
893
+ [y, i.getNavTooltip(1)]
894
+ ])
895
+ ]);
896
+ }
897
+ const Gt = /* @__PURE__ */ S(Nt, [["render", qt], ["__scopeId", "data-v-f685b502"]]), Kt = {
898
+ name: "ArticleUnitEditModal",
899
+ i18nOptions: {
900
+ namespaces: "ArticleUnitEditModal",
901
+ messages: {
902
+ en: {
903
+ tooltip: `
904
+ <div>
905
+ Tip: If you'd like for the unit type to pluralize automatically. Use the following format - <span style="padding: 3px; background-color: hsla(0, 0%, 100%, 0.1); border-radius: 4px;">single:plural</span>.
906
+ </div>
907
+ <div style="margin-top: 0.5em;">For example:</div>
908
+ <div style="margin-left: 0.25em;">- image:images</div>
909
+ <div style="margin-left: 0.25em;">- phone:phones</div>
910
+ `
911
+ },
912
+ sv: {
913
+ tooltip: `
914
+ <div>
915
+ Tips: Om du vill att enheten ska ta hänsyn till antalet så kan du skriva det i följande format - <span style="padding: 3px; background-color: hsla(0, 0%, 100%, 0.1); border-radius: 4px;">singular:plural</span>.
916
+ </div>
917
+ <div style="margin-top: 0.5em;">Till exempel:</div>
918
+ <div style="margin-left: 0.25em;">- bild:bilder</div>
919
+ <div style="margin-left: 0.25em;">- telefon:telefoner</div>
920
+ `
921
+ }
922
+ }
923
+ },
924
+ components: {
925
+ DragList: xe,
926
+ DragItem: Ve,
927
+ CField: ce
928
+ },
929
+ emits: ["select", "close"],
930
+ data() {
931
+ return {
932
+ hoverIndex: null,
933
+ removeConfirmIndex: null,
934
+ selectedValue: {
935
+ id: null,
936
+ value: ""
937
+ },
938
+ idList: []
939
+ };
940
+ },
941
+ computed: {
942
+ ...R({
943
+ isPosting: "unitTypes/isPosting",
944
+ stateUnitIds: "unitTypes/ids",
945
+ unitById: "unitTypes/byId"
946
+ }),
947
+ unitItems() {
948
+ return (this.idList || []).map((e) => {
949
+ const t = this.unitById(e), s = U(t.value);
950
+ return {
951
+ ...t,
952
+ label: s,
953
+ value: t.value.startsWith("$") ? t.value.replace(/^[$]/, "") : s,
954
+ raw: t.value.replace(/^[$]/, "")
955
+ // replace only first occurance of '$'
956
+ };
957
+ });
958
+ }
959
+ },
960
+ watch: {
961
+ stateUnitIds: {
962
+ immediate: !0,
963
+ handler(e) {
964
+ this.idList = e || [];
965
+ }
966
+ }
967
+ },
968
+ methods: {
969
+ ...B({
970
+ loadUnits: M.LOAD_UNIT_TYPES,
971
+ createUnit: M.CREATE_UNIT_TYPE,
972
+ updateUnit: M.UPDATE_UNIT_TYPE,
973
+ deleteUnit: M.DELETE_UNIT_TYPE
974
+ }),
975
+ onEdit(e) {
976
+ this.selectedValue = { ...e }, this.$refs.unitInput && this.$refs.unitInput.focus();
977
+ },
978
+ async submit() {
979
+ const { id: e, value: t } = this.selectedValue || {};
980
+ if (!t) throw new Error("New unitTypes need truthy value!");
981
+ const s = `$${t}`;
982
+ e ? await this.updateUnit({ id: e, body: { value: s } }) : await this.createUnit({ body: { value: s } }), this.reset(), this.$emit("select", s), this.close();
983
+ },
984
+ async remove(e, t) {
985
+ if (this.removeConfirmIndex !== t) {
986
+ this.removeConfirmIndex = t;
987
+ return;
988
+ }
989
+ await this.deleteUnit({ id: e }), this.reset(), this.removeConfirmIndex = null;
990
+ },
991
+ reset() {
992
+ this.selectedValue = { id: null, value: "" };
993
+ },
994
+ close() {
995
+ this.$emit("close");
996
+ },
997
+ async onDrop({ removedIndex: e, addedIndex: t }) {
998
+ e === null && t === null || e !== t && (this.idList = ae(this.idList, e, t), await Se(
999
+ "/unitType/setPositions",
1000
+ { ids: this.idList },
1001
+ { invalidateCache: { type: "unitType" } }
1002
+ ), this.reset(), await this.loadUnits());
1003
+ }
1004
+ }
1005
+ }, Yt = {
1006
+ class: "unit-modal-root font-inter",
1007
+ style: { position: "relative" }
1008
+ }, Zt = { style: { padding: "calc(1.5 * var(--rem))" } }, Jt = { style: { "font-weight": "600", "font-size": "18px", "margin-bottom": "calc(1.5 * var(--rem))" } }, Qt = { class: "control" }, Xt = { style: { "border-top": "1px solid hsl(0, 0%, 88%)", overflow: "auto", "max-height": "360px" } }, ei = {
1009
+ class: "text-gray-400",
1010
+ style: { "font-size": "14px", padding: "calc(1 * var(--rem)) calc(1.5 * var(--rem)) 0", "font-weight": "500" }
1011
+ }, ti = { class: "unit-modal-list" }, ii = {
1012
+ key: 0,
1013
+ class: "unit-modal-list-empty"
1014
+ }, si = ["onMouseoverPassive", "onClick"], ni = { class: "drag-handle" }, ai = { style: { "padding-left": "0.5em" } }, oi = { class: "unittype-buttons" };
1015
+ function li(e, t, s, o, n, i) {
1016
+ const y = v("CIcon"), h = v("CButton"), f = v("CInput"), p = v("CField"), b = v("DragItem"), k = v("DragList"), C = O("tooltip");
1017
+ return a(), c("div", {
1018
+ class: "modal-overlay font-inter",
1019
+ onClickPassive: t[3] || (t[3] = N((...d) => i.close && i.close(...d), ["self"]))
1020
+ }, [
1021
+ l("div", Yt, [
1022
+ l("div", Zt, [
1023
+ l("div", Jt, [
1024
+ l("span", null, m(e.$t("_common:add", { thing: e.$t("_common:unitType.unitType_plural") })), 1),
1025
+ D(u(y, {
1026
+ type: "info",
1027
+ size: "15",
1028
+ class: "text-gray-400",
1029
+ style: { "margin-left": "0.5em" }
1030
+ }, null, 512), [
1031
+ [C, { content: e.$t("tooltip"), html: !0 }]
1032
+ ])
1033
+ ]),
1034
+ u(p, {
1035
+ grouped: "",
1036
+ style: { margin: "0" }
1037
+ }, {
1038
+ default: g(() => [
1039
+ u(f, {
1040
+ ref: "unitInput",
1041
+ modelValue: n.selectedValue.value,
1042
+ "onUpdate:modelValue": t[0] || (t[0] = (d) => n.selectedValue.value = d),
1043
+ modelModifiers: { trim: !0 },
1044
+ placeholder: e.$t("_common:name").capitalize(),
1045
+ expanded: "",
1046
+ filled: "",
1047
+ class: "unit-input"
1048
+ }, oe({ _: 2 }, [
1049
+ n.selectedValue.id ? {
1050
+ name: "suffix",
1051
+ fn: g(() => [
1052
+ u(h, {
1053
+ icon: "x",
1054
+ type: "none",
1055
+ pattern: "tertiary",
1056
+ size: "small",
1057
+ style: { "border-radius": "4px" },
1058
+ onClick: i.reset
1059
+ }, null, 8, ["onClick"])
1060
+ ]),
1061
+ key: "0"
1062
+ } : void 0
1063
+ ]), 1032, ["modelValue", "placeholder"]),
1064
+ l("div", Qt, [
1065
+ u(h, {
1066
+ loading: e.isPosting,
1067
+ disabled: !n.selectedValue.value,
1068
+ type: "secondary",
1069
+ onClick: i.submit
1070
+ }, {
1071
+ default: g(() => [
1072
+ I(m(n.selectedValue.id ? e.$t("_common:save") : e.$t("_common:add")), 1)
1073
+ ]),
1074
+ _: 1
1075
+ }, 8, ["loading", "disabled", "onClick"])
1076
+ ])
1077
+ ]),
1078
+ _: 1
1079
+ })
1080
+ ]),
1081
+ l("div", Xt, [
1082
+ l("div", ei, m(e.$t("_common:unit_plural").capitalize()), 1),
1083
+ l("div", ti, [
1084
+ i.unitItems.length ? w("", !0) : (a(), c("div", ii, m(e.$t("_common:add", { thing: e.$t("_common:unit_plural") })), 1)),
1085
+ u(k, {
1086
+ "drop-placeholder": { className: "drag-drop-placeholder" },
1087
+ "drag-class": "is-dragged",
1088
+ "lock-axis": "y",
1089
+ "drag-handle-selector": ".drag-handle",
1090
+ onDrop: i.onDrop
1091
+ }, {
1092
+ default: g(() => [
1093
+ (a(!0), c(A, null, V(i.unitItems, (d, $) => (a(), T(b, {
1094
+ key: d.id
1095
+ }, {
1096
+ default: g(() => [
1097
+ l("div", {
1098
+ class: x([{ "is-editing": n.selectedValue.id === d.id }, "unit-modal-list-item"]),
1099
+ onMouseoverPassive: (r) => n.hoverIndex = $,
1100
+ onMouseleavePassive: t[2] || (t[2] = (r) => n.hoverIndex = null),
1101
+ onClick: (r) => i.onEdit(d)
1102
+ }, [
1103
+ l("div", ni, [
1104
+ u(y, {
1105
+ type: "handle",
1106
+ size: "16",
1107
+ class: "text-gray-300"
1108
+ })
1109
+ ]),
1110
+ l("div", ai, m(d.label), 1),
1111
+ D(l("span", { class: "delete-confirm" }, m(e.$t("_common:remove")) + "? ", 513), [
1112
+ [De, n.removeConfirmIndex === $]
1113
+ ]),
1114
+ l("div", oi, [
1115
+ n.hoverIndex === $ || n.removeConfirmIndex === $ ? (a(), T(h, {
1116
+ key: 0,
1117
+ type: n.removeConfirmIndex === $ ? "danger" : "none",
1118
+ pattern: n.removeConfirmIndex === $ ? "primary" : "tertiary",
1119
+ circle: "",
1120
+ icon: "x",
1121
+ size: "small",
1122
+ onClick: N((r) => i.remove(d.id, $), ["stop", "prevent"]),
1123
+ onBlur: t[1] || (t[1] = (r) => n.removeConfirmIndex = null)
1124
+ }, null, 8, ["type", "pattern", "onClick"])) : w("", !0),
1125
+ u(h, {
1126
+ icon: "edit",
1127
+ size: "small",
1128
+ type: "none",
1129
+ pattern: "tertiary",
1130
+ circle: ""
1131
+ })
1132
+ ])
1133
+ ], 42, si)
1134
+ ]),
1135
+ _: 2
1136
+ }, 1024))), 128))
1137
+ ]),
1138
+ _: 1
1139
+ }, 8, ["onDrop"])
1140
+ ])
1141
+ ])
1142
+ ])
1143
+ ], 32);
1144
+ }
1145
+ const ri = /* @__PURE__ */ S(Kt, [["render", li], ["__scopeId", "data-v-d0dffed6"]]), ci = {
1146
+ name: "ArticleUnitSelect",
1147
+ components: {
1148
+ CDropdown: q,
1149
+ CDropdownItem: G
1150
+ },
1151
+ props: {
1152
+ modelValue: {
1153
+ type: String,
1154
+ required: !0
1155
+ },
1156
+ isPublicForm: {
1157
+ type: Boolean,
1158
+ default: !1
1159
+ },
1160
+ // Optional param for plural translations
1161
+ count: {
1162
+ type: Number,
1163
+ default: 1
1164
+ }
1165
+ },
1166
+ emits: ["update:modelValue"],
1167
+ computed: {
1168
+ ...R({
1169
+ unitIds: "unitTypes/ids",
1170
+ unitById: "unitTypes/byId"
1171
+ }),
1172
+ unitItems() {
1173
+ return this.isPublicForm ? Ye : (this.unitIds || []).map((e) => this.unitById(e)).map(({ value: e }) => e);
1174
+ }
1175
+ },
1176
+ created() {
1177
+ this.isPublicForm || this.loadUnits();
1178
+ },
1179
+ methods: {
1180
+ articleUnitLabel: U,
1181
+ ...B({
1182
+ loadUnits: M.LOAD_UNIT_TYPES
1183
+ }),
1184
+ openEditModal() {
1185
+ this.$modal.show(
1186
+ ri,
1187
+ {},
1188
+ {},
1189
+ {
1190
+ select: (e) => this.$emit("update:modelValue", e)
1191
+ }
1192
+ );
1193
+ }
1194
+ }
1195
+ };
1196
+ function di(e, t, s, o, n, i) {
1197
+ const y = v("CButton"), h = v("CDropdownItem"), f = v("CDropdown");
1198
+ return a(), T(f, E({
1199
+ position: "is-bottom-left",
1200
+ maxHeight: "240px",
1201
+ ...e.$attrs
1202
+ }, {
1203
+ "model-value": s.modelValue,
1204
+ scrollable: "",
1205
+ "onUpdate:modelValue": t[0] || (t[0] = (p) => e.$emit("update:modelValue", p))
1206
+ }), {
1207
+ trigger: g(() => [
1208
+ Q(e.$slots, "default", {}, () => [
1209
+ u(y, {
1210
+ type: "none",
1211
+ pattern: "tertiary"
1212
+ }, {
1213
+ default: g(() => [
1214
+ I(m(i.articleUnitLabel(s.modelValue)), 1)
1215
+ ]),
1216
+ _: 1
1217
+ })
1218
+ ], !0)
1219
+ ]),
1220
+ footer: g(() => [
1221
+ s.isPublicForm ? w("", !0) : (a(), T(y, {
1222
+ key: 0,
1223
+ type: "none",
1224
+ pattern: "secondary",
1225
+ size: "small",
1226
+ class: "edit-button",
1227
+ onClick: i.openEditModal
1228
+ }, {
1229
+ default: g(() => [
1230
+ I(m(e.$t("_common:edit", { thing: e.$t("_common:unit_plural") })), 1)
1231
+ ]),
1232
+ _: 1
1233
+ }, 8, ["onClick"]))
1234
+ ]),
1235
+ default: g(() => [
1236
+ (a(!0), c(A, null, V(i.unitItems, (p, b) => (a(), T(h, {
1237
+ key: `${p}-${b}`,
1238
+ value: p
1239
+ }, {
1240
+ default: g(() => [
1241
+ I(m(i.articleUnitLabel(p)), 1)
1242
+ ]),
1243
+ _: 2
1244
+ }, 1032, ["value"]))), 128))
1245
+ ]),
1246
+ _: 3
1247
+ }, 16, ["model-value"]);
1248
+ }
1249
+ const ui = /* @__PURE__ */ S(ci, [["render", di], ["__scopeId", "data-v-57c52e30"]]), pi = {
1250
+ name: "ArticleModal",
1251
+ i18nOptions: {
1252
+ namespaces: "ArticleModal",
1253
+ messages: pe
1254
+ },
1255
+ components: {
1256
+ ArticleAutocomplete: de,
1257
+ ArticleUnitSelect: ui,
1258
+ ListModalButtons: Gt,
1259
+ CPriceInput: K,
1260
+ CField: ce
1261
+ },
1262
+ emits: ["add", "input", "focus", "close", "open-modal", "update:currency"],
1263
+ mixins: [ve],
1264
+ props: {
1265
+ _document: {
1266
+ type: Object,
1267
+ default: () => ({})
1268
+ },
1269
+ // Article object
1270
+ index: {
1271
+ type: Number,
1272
+ required: !0
1273
+ },
1274
+ articleList: {
1275
+ type: Array,
1276
+ required: !0
1277
+ },
1278
+ // If priceType checkboxes should be visible
1279
+ enablePriceTypes: {
1280
+ type: Boolean,
1281
+ default: !0
1282
+ },
1283
+ hidePriceInput: {
1284
+ type: Boolean,
1285
+ default: !1
1286
+ },
1287
+ hidePriceOnNew: {
1288
+ type: Boolean,
1289
+ default: !1
1290
+ },
1291
+ isIncVat: {
1292
+ type: Boolean,
1293
+ default: !1
1294
+ },
1295
+ rootPriceType: {
1296
+ type: String,
1297
+ default: "fixed"
1298
+ },
1299
+ currency: {
1300
+ type: String,
1301
+ required: !0
1302
+ },
1303
+ activeHouseWorkType: {
1304
+ type: String,
1305
+ default: null
1306
+ },
1307
+ // Mixin props are not injected when rendered within a portal
1308
+ viewSettings: {
1309
+ type: Object,
1310
+ default: () => ({
1311
+ canEdit: !1,
1312
+ isForm: !1,
1313
+ setFormValue: null,
1314
+ isPublicForm: !1
1315
+ })
1316
+ }
1317
+ },
1318
+ setup() {
1319
+ return {
1320
+ v$: re()
1321
+ };
1322
+ },
1323
+ validations: me,
1324
+ data() {
1325
+ return {
1326
+ priceSuffix: Ut,
1327
+ updateData: H,
1328
+ addSavedArticle: ue,
1329
+ vatOptions: [
1330
+ { value: 25, translation: "25%" },
1331
+ { value: 12, translation: "12%" },
1332
+ { value: 6, translation: "6%" },
1333
+ { value: 0, translation: "0%" }
1334
+ ],
1335
+ showDiscountInput: !1,
1336
+ setPricesIncVat: !1,
1337
+ getCurrencySymbol: ee,
1338
+ articleUnitLabel: U
1339
+ };
1340
+ },
1341
+ computed: {
1342
+ ...R({
1343
+ allowHidePrice: "settings/allowHidePrice",
1344
+ getCompanySetting: "settings/getCompanySetting",
1345
+ feature: "application/feature"
1346
+ }),
1347
+ article: {
1348
+ get() {
1349
+ return this.articleList[this.index] || {};
1350
+ },
1351
+ set(e) {
1352
+ this.$emit("input", e);
1353
+ }
1354
+ },
1355
+ useVat() {
1356
+ return P(this, "_document.useVat") || "";
1357
+ },
1358
+ vatType() {
1359
+ return P(this, "_document.vatType") || "";
1360
+ },
1361
+ checkboxItems() {
1362
+ const { article: e } = this || {}, { priceType: t } = this.article || {}, s = [
1363
+ ...t !== "markup" ? [
1364
+ {
1365
+ label: this.$t("discount").capitalize(),
1366
+ value: e.discount || this.showDiscountInput,
1367
+ onClick: () => {
1368
+ this.showDiscountInput || this.focusEl("discountInput"), this.showDiscountInput = !this.showDiscountInput;
1369
+ }
1370
+ }
1371
+ ] : [],
1372
+ ...this.getCompanySetting("showRot") || e.isDeductable ? [
1373
+ {
1374
+ label: this.$t("_common:deduction.rot"),
1375
+ value: this.article.isDeductable,
1376
+ onClick: () => this.updateArticle(!e.isDeductable, "isDeductable")
1377
+ }
1378
+ ] : [],
1379
+ ...this.getCompanySetting("showRut") || e.isRut ? [
1380
+ {
1381
+ label: this.$t("_common:deduction.rut"),
1382
+ value: e.isRut,
1383
+ onClick: () => this.updateArticle(!e.isRut, "isRut")
1384
+ }
1385
+ ] : [],
1386
+ ...e.greenRot15 ? [
1387
+ {
1388
+ label: this.$t("_common:deduction.greenRot15_percentage"),
1389
+ value: e.greenRot15,
1390
+ onClick: () => this.updateArticle(!e.greenRot15, "greenRot15")
1391
+ }
1392
+ ] : [],
1393
+ ...this.getCompanySetting("showGreenRot") || e.greenRot20 || e.greenRot50 ? [
1394
+ {
1395
+ label: this.$t("_common:deduction.greenRot20_percentage"),
1396
+ value: e.greenRot20,
1397
+ onClick: () => this.updateArticle(!e.greenRot20, "greenRot20")
1398
+ },
1399
+ {
1400
+ label: this.$t("_common:deduction.greenRot50_percentage"),
1401
+ value: e.greenRot50,
1402
+ onClick: () => this.updateArticle(!e.greenRot50, "greenRot50")
1403
+ }
1404
+ ] : []
1405
+ ];
1406
+ if (this.allowHidePrice) {
1407
+ const { showPrice: o } = e || {};
1408
+ s.push({
1409
+ label: this.$t("hidePriceLabel"),
1410
+ value: !o,
1411
+ onClick: () => this.updateArticle(!o, "showPrice")
1412
+ });
1413
+ }
1414
+ return s;
1415
+ },
1416
+ priceTypeOptions() {
1417
+ if (!this.enablePriceTypes || this.rootPriceType === "fixed") return [];
1418
+ const { priceType: e } = this.article, t = (o) => this.$t(`priceTypeTooltips.${o}`), s = [
1419
+ {
1420
+ label: this.$t("price.fixed"),
1421
+ tooltip: t("fixed"),
1422
+ value: e === "fixed",
1423
+ onClick: () => this.updateArticle("fixed", "priceType")
1424
+ }
1425
+ ];
1426
+ return this.rootPriceType === "approx" && s.push({
1427
+ label: this.$t("price.approx"),
1428
+ tooltip: t("approx"),
1429
+ value: e === "approx",
1430
+ onClick: () => this.updateArticle("approx", "priceType")
1431
+ }), this.rootPriceType.startsWith("openAcc") && (s.push({
1432
+ label: this.$t("price.openAcc"),
1433
+ tooltip: t("openAcc"),
1434
+ value: e === "openAcc",
1435
+ onClick: () => this.updateArticle("openAcc", "priceType")
1436
+ }), s.push({
1437
+ label: this.$t("price.markup"),
1438
+ tooltip: t("markup"),
1439
+ value: e === "markup",
1440
+ onClick: () => this.updateArticle("markup", "priceType")
1441
+ })), s;
1442
+ }
1443
+ },
1444
+ watch: {
1445
+ index: {
1446
+ immediate: !0,
1447
+ handler(e, t) {
1448
+ e !== t && (this.showDiscountInput = !1);
1449
+ }
1450
+ },
1451
+ isIncVat: {
1452
+ immediate: !0,
1453
+ handler(e) {
1454
+ this.setPricesIncVat = !!e;
1455
+ }
1456
+ },
1457
+ "article.discount": {
1458
+ immediate: !0,
1459
+ handler(e) {
1460
+ e && (this.showDiscountInput = !0);
1461
+ }
1462
+ },
1463
+ "article.priceType": {
1464
+ handler(e) {
1465
+ e === "markup" && (this.showDiscountInput = !1), ["openAcc", "markup"].includes(e) && this.updateArticle(1, "quantity");
1466
+ }
1467
+ },
1468
+ showDiscountInput(e) {
1469
+ e || this.updateArticle(0, "discount");
1470
+ }
1471
+ },
1472
+ mounted() {
1473
+ !this.article.name && this.$refs.nameInput && this.$refs.nameInput.focus(), document.addEventListener("keydown", this.onKeydown);
1474
+ },
1475
+ beforeUnmount() {
1476
+ document.removeEventListener("keydown", this.onKeydown);
1477
+ },
1478
+ methods: {
1479
+ ...B({
1480
+ createArticle: M.DO_CREATE_ARTICLE
1481
+ }),
1482
+ onCustomVatBlur(e) {
1483
+ P(e, "target.value") || "" || this.updateArticle(0, "vat");
1484
+ },
1485
+ onCustomVatInput(e) {
1486
+ const t = P(e, "target.value") || "";
1487
+ if (!t) return;
1488
+ let s = t > 100 ? t.slice(0, t.length - 1) : t;
1489
+ s < 0 && (s = 0), this.updateArticle(Number.parseFloat(s), "vat");
1490
+ },
1491
+ updateArticle(e, t) {
1492
+ this.article = H(this.article, e, t);
1493
+ },
1494
+ close() {
1495
+ this.$emit("close");
1496
+ },
1497
+ onKeydown(e) {
1498
+ e.keyCode === 13 && e.shiftKey && (e.preventDefault(), this.addNewArticle());
1499
+ },
1500
+ onGo(e) {
1501
+ const t = this.index + e;
1502
+ this.articleList[t] && (this.close(), this.$emit("open-modal", t));
1503
+ },
1504
+ async addNewArticle() {
1505
+ this.v$.$invalid || await this.saveArticle(), this.$emit("add", { openModal: !0 }), this.close();
1506
+ },
1507
+ focusEl(e) {
1508
+ this.$nextTick(() => {
1509
+ this.$nextTick(() => {
1510
+ this.$refs[e] && this.$refs[e].focus && this.$refs[e].focus();
1511
+ });
1512
+ });
1513
+ },
1514
+ onTotalPriceInputFocus() {
1515
+ this.article.quantity > 1 && this.$nextTick(() => {
1516
+ this.$refs.priceInput && this.$refs.priceInput.focus();
1517
+ });
1518
+ },
1519
+ toggleDiscountType() {
1520
+ let e = "fixed";
1521
+ this.article.discountType === "fixed" && (e = "percentage"), this.updateArticle(e, "discountType");
1522
+ },
1523
+ async onSaveArticle() {
1524
+ if (this.v$.$invalid) {
1525
+ this.v$.$touch();
1526
+ return;
1527
+ }
1528
+ await this.saveArticle(), this.close();
1529
+ },
1530
+ async saveArticle() {
1531
+ if (this.viewSettings.isPublicForm) return;
1532
+ let { ArticleId: e } = this.article;
1533
+ !e && ((s) => typeof s == "string" && !!s.trim())(this.article.name) && (e = await this.createArticle({
1534
+ body: this.article,
1535
+ showMessage: !1
1536
+ }), this.article = { ...this.article, ArticleId: e });
1537
+ }
1538
+ }
1539
+ }, mi = { class: "modal-container" }, hi = {
1540
+ class: "flex w-full",
1541
+ style: { "margin-bottom": "1.5em" }
1542
+ }, gi = {
1543
+ class: "flex",
1544
+ style: { "margin-bottom": "1.5em" }
1545
+ }, vi = {
1546
+ key: 0,
1547
+ class: "flex",
1548
+ style: { "margin-bottom": "1.5em" }
1549
+ }, fi = { style: { margin: "calc(1 * var(--rem)) calc(-0.5 * var(--rem))" } }, yi = ["value"], ki = ["value"], bi = {
1550
+ key: 1,
1551
+ class: "select-css tag-item no-chevron",
1552
+ style: { display: "inline", "min-height": "initial", background: "hsl(0, 0%, 94%)", "border-color": "hsl(0, 0%, 94%)", color: "hsl(0, 0%, 30%)" }
1553
+ }, wi = ["value"], Ii = {
1554
+ key: 1,
1555
+ class: "tag-group",
1556
+ style: { display: "flex", "flex-direction": "row", "flex-wrap": "wrap", "margin-top": "1em" }
1557
+ }, $i = ["onClick"], _i = { style: { display: "flex", "flex-direction": "row", "flex-wrap": "wrap", "margin-top": "1em" } }, Ti = ["onClick"], Ai = { class: "flex space-x-4 overflow-hidden p-4 md:p-9" };
1558
+ function Ci(e, t, s, o, n, i) {
1559
+ const y = v("ListModalButtons"), h = v("CIcon"), f = v("ArticleAutocomplete"), p = v("CField"), b = v("CInput"), k = v("CButton"), C = v("ArticleUnitSelect"), d = v("CPriceInput"), $ = O("tooltip");
1560
+ return a(), c("div", {
1561
+ class: x([{
1562
+ "full-screen": e.mq === "sm",
1563
+ "modal-overlay": !0
1564
+ }, "font-inter"]),
1565
+ onClickPassive: t[15] || (t[15] = N((...r) => i.close && i.close(...r), ["self"]))
1566
+ }, [
1567
+ l("div", mi, [
1568
+ e.mq !== "sm" ? (a(), T(y, {
1569
+ key: 0,
1570
+ "can-forward": !!s.articleList[s.index + 1],
1571
+ "can-backward": !!s.articleList[s.index - 1],
1572
+ onClose: i.close,
1573
+ onGo: t[0] || (t[0] = (r) => i.onGo(r))
1574
+ }, null, 8, ["can-forward", "can-backward", "onClose"])) : (a(), c("div", {
1575
+ key: 1,
1576
+ class: "modal-close",
1577
+ onClick: t[1] || (t[1] = (...r) => i.close && i.close(...r))
1578
+ }, [
1579
+ u(h, { type: "x" })
1580
+ ])),
1581
+ u(Me, { name: "slide" }, {
1582
+ default: g(() => [
1583
+ (a(), c("div", {
1584
+ key: i.article._uniqueId,
1585
+ class: "modal-main"
1586
+ }, [
1587
+ u(p, {
1588
+ validator: o.v$.article.name,
1589
+ messages: { maxLength: e.$t("validations.name.maxLength") },
1590
+ label: e.$t("name").capitalize(),
1591
+ "label-position": "inside",
1592
+ style: { "margin-bottom": "1.5em" },
1593
+ class: "label-selector"
1594
+ }, {
1595
+ default: g(() => [
1596
+ u(f, {
1597
+ ref: "nameInput",
1598
+ "model-value": i.article.name,
1599
+ autosize: !0,
1600
+ tag: "textarea",
1601
+ placeholder: "",
1602
+ size: "large",
1603
+ class: "input-selector",
1604
+ "onUpdate:modelValue": t[2] || (t[2] = (r) => i.updateArticle(r, "name")),
1605
+ onSelect: t[3] || (t[3] = (r) => e.$emit(
1606
+ "input",
1607
+ n.addSavedArticle({
1608
+ stored: r,
1609
+ current: i.article,
1610
+ hidePrice: s.hidePriceOnNew,
1611
+ activeHouseWorkType: s.activeHouseWorkType
1612
+ })
1613
+ ))
1614
+ }, null, 8, ["model-value"])
1615
+ ]),
1616
+ _: 1
1617
+ }, 8, ["validator", "messages", "label"]),
1618
+ l("div", hi, [
1619
+ u(p, {
1620
+ label: e.$t("quantity").capitalize(),
1621
+ "label-position": "inside",
1622
+ class: "label-selector form-control form-control-left flex-grow",
1623
+ style: { "margin-bottom": "0" }
1624
+ }, {
1625
+ default: g(() => [
1626
+ u(b, {
1627
+ "model-value": i.article.quantity,
1628
+ disabled: ["openAcc", "markup"].includes(i.article.priceType),
1629
+ placeholder: "",
1630
+ type: "number",
1631
+ size: "large",
1632
+ class: "input-selector",
1633
+ "onUpdate:modelValue": t[4] || (t[4] = (r) => i.updateArticle(Number.parseFloat(r), "quantity"))
1634
+ }, null, 8, ["model-value", "disabled"])
1635
+ ]),
1636
+ _: 1
1637
+ }, 8, ["label"]),
1638
+ u(C, {
1639
+ "model-value": i.article.unitType,
1640
+ "is-public-form": s.viewSettings.isPublicForm,
1641
+ "onUpdate:modelValue": t[5] || (t[5] = (r) => i.updateArticle(r, "unitType"))
1642
+ }, {
1643
+ default: g(() => [
1644
+ u(k, {
1645
+ class: "select-css form-control form-control-right",
1646
+ style: { width: "8em", "box-shadow": "none" }
1647
+ }, {
1648
+ default: g(() => [
1649
+ I(m(n.articleUnitLabel(i.article.unitType, {
1650
+ count: i.article.quantity
1651
+ })), 1)
1652
+ ]),
1653
+ _: 1
1654
+ })
1655
+ ]),
1656
+ _: 1
1657
+ }, 8, ["model-value", "is-public-form"])
1658
+ ]),
1659
+ s.hidePriceInput ? w("", !0) : (a(), c(A, { key: 0 }, [
1660
+ l("div", gi, [
1661
+ u(p, {
1662
+ label: e.$t("price.price").capitalize(),
1663
+ "label-position": "inside",
1664
+ class: "label-selector form-control form-control-left flex-1",
1665
+ style: { "margin-bottom": "0" }
1666
+ }, {
1667
+ default: g(() => [
1668
+ (a(), T(d, {
1669
+ ref: "priceInput",
1670
+ key: n.priceSuffix(i.article),
1671
+ "model-value": i.article.price,
1672
+ currency: i.article.currency,
1673
+ "is-inc-vat": i.article.priceType !== "markup" && n.setPricesIncVat,
1674
+ vat: i.article.vat,
1675
+ "price-type": i.article.priceType,
1676
+ "unit-label": n.articleUnitLabel(i.article.unitType),
1677
+ class: "input-selector",
1678
+ "onUpdate:modelValue": t[6] || (t[6] = (r) => i.updateArticle(r, "price")),
1679
+ "onUpdate:currency": t[7] || (t[7] = (r) => e.$emit("update:currency", r)),
1680
+ onFocus: t[8] || (t[8] = (r) => e.$emit("focus"))
1681
+ }, null, 8, ["model-value", "currency", "is-inc-vat", "vat", "price-type", "unit-label"]))
1682
+ ]),
1683
+ _: 1
1684
+ }, 8, ["label"]),
1685
+ i.useVat ? (a(), c("div", {
1686
+ key: 0,
1687
+ class: "select-css form-control form-control-right",
1688
+ style: { width: "8em" },
1689
+ onClick: t[9] || (t[9] = (r) => n.setPricesIncVat = !n.setPricesIncVat)
1690
+ }, m(s._document.$t(`vat.${n.setPricesIncVat ? "incVat" : "exVat"}`)), 1)) : w("", !0)
1691
+ ]),
1692
+ n.showDiscountInput ? (a(), c("div", vi, [
1693
+ u(p, {
1694
+ label: e.$t("discount").capitalize(),
1695
+ "label-position": "inside",
1696
+ class: "label-selector form-control form-control-left flex-grow",
1697
+ style: { "margin-bottom": "0" }
1698
+ }, {
1699
+ default: g(() => [
1700
+ u(d, {
1701
+ ref: "discountInput",
1702
+ "model-value": i.article.discount,
1703
+ currency: i.article.currency,
1704
+ "is-inc-vat": i.article.discountType !== "percentage" && n.setPricesIncVat,
1705
+ vat: i.article.vat,
1706
+ class: "input-selector",
1707
+ "suffix-class": "text-gray-400",
1708
+ "onUpdate:modelValue": t[10] || (t[10] = (r) => i.updateArticle(Math.abs(r), "discount"))
1709
+ }, oe({ _: 2 }, [
1710
+ i.article.discountType === "fixed" ? {
1711
+ name: "suffix",
1712
+ fn: g(() => [
1713
+ I(m(s._document.$t(
1714
+ `vat.${n.setPricesIncVat ? "incVat" : "exVat"}`
1715
+ )), 1)
1716
+ ]),
1717
+ key: "0"
1718
+ } : {
1719
+ name: "suffix",
1720
+ fn: g(() => [
1721
+ I(m(n.getCurrencySymbol(i.article.currency)), 1)
1722
+ ]),
1723
+ key: "1"
1724
+ }
1725
+ ]), 1032, ["model-value", "currency", "is-inc-vat", "vat"])
1726
+ ]),
1727
+ _: 1
1728
+ }, 8, ["label"]),
1729
+ l("div", {
1730
+ class: "select-css form-control form-control-right",
1731
+ style: { width: "5em" },
1732
+ onClick: t[11] || (t[11] = (r) => i.updateArticle(
1733
+ i.article.discountType === "percentage" ? "fixed" : "percentage",
1734
+ "discountType"
1735
+ ))
1736
+ }, m(i.article.discountType === "percentage" ? "%" : n.getCurrencySymbol(i.article.currency)), 1)
1737
+ ])) : w("", !0)
1738
+ ], 64)),
1739
+ l("div", fi, [
1740
+ i.useVat ? (a(), c(A, { key: 0 }, [
1741
+ e.feature("regionSE") && Number.isInteger(i.article.vat) ? (a(), c("select", {
1742
+ key: 0,
1743
+ value: i.article.vat,
1744
+ class: "select-css tag-item no-chevron",
1745
+ style: { display: "inline", "min-height": "initial", background: "hsl(0, 0%, 94%)", "border-color": "hsl(0, 0%, 94%)", color: "hsl(0, 0%, 30%)" },
1746
+ onInput: t[12] || (t[12] = (r) => i.updateArticle(Number.parseFloat(r.target.value), "vat"))
1747
+ }, [
1748
+ (a(!0), c(A, null, V(n.vatOptions, ({ translation: r, value: L }, _) => (a(), c("option", {
1749
+ key: _,
1750
+ value: L
1751
+ }, m(e.$t(`vat.${i.vatType}`)) + " " + m(r), 9, ki))), 128))
1752
+ ], 40, yi)) : (a(), c("span", bi, [
1753
+ I(m(s._document.$t("vat").capitalize()) + " ", 1),
1754
+ l("input", {
1755
+ value: i.article.vat || 0,
1756
+ type: "number",
1757
+ style: { width: "calc(2.5 * var(--rem))", display: "inline", background: "hsl(0, 0%, 94%)", "border-color": "hsl(0, 0%, 94%)", color: "hsl(0, 0%, 30%)" },
1758
+ onBlur: t[13] || (t[13] = (...r) => i.onCustomVatBlur && i.onCustomVatBlur(...r)),
1759
+ onInput: t[14] || (t[14] = (...r) => i.onCustomVatInput && i.onCustomVatInput(...r))
1760
+ }, null, 40, wi),
1761
+ t[16] || (t[16] = I(" % "))
1762
+ ]))
1763
+ ], 64)) : w("", !0),
1764
+ i.priceTypeOptions.length ? (a(), c("div", Ii, [
1765
+ (a(!0), c(A, null, V(i.priceTypeOptions, ({ label: r, value: L, onClick: _, tooltip: Y }, he) => D((a(), c("div", {
1766
+ key: r + he,
1767
+ class: x([{ active: L }, "tag-item"]),
1768
+ onClick: _
1769
+ }, [
1770
+ I(m(r), 1)
1771
+ ], 10, $i)), [
1772
+ [$, {
1773
+ content: Y,
1774
+ delay: { show: 300, hide: 0 }
1775
+ }]
1776
+ ])), 128))
1777
+ ])) : w("", !0),
1778
+ l("div", _i, [
1779
+ (a(!0), c(A, null, V(i.checkboxItems, ({ label: r, value: L, onClick: _ }, Y) => (a(), c("div", {
1780
+ key: r + Y,
1781
+ class: x([{ active: L }, "tag-item"]),
1782
+ onClick: _
1783
+ }, m(r), 11, Ti))), 128))
1784
+ ])
1785
+ ])
1786
+ ]))
1787
+ ]),
1788
+ _: 1
1789
+ }),
1790
+ l("div", Ai, [
1791
+ D((a(), T(k, {
1792
+ type: "primary",
1793
+ tabindex: "0",
1794
+ size: "large",
1795
+ style: { padding: "1.75em", height: "4em", "font-size": "16px", "background-color": "hsl(231, 4%, 20%)", "border-color": "hsl(231, 4%, 20%)" },
1796
+ onClick: i.addNewArticle
1797
+ }, {
1798
+ default: g(() => [
1799
+ u(h, {
1800
+ type: "zap",
1801
+ size: "21",
1802
+ style: { margin: "-3px" }
1803
+ })
1804
+ ]),
1805
+ _: 1
1806
+ }, 8, ["onClick"])), [
1807
+ [$, {
1808
+ distance: 7,
1809
+ html: !0,
1810
+ content: `
1811
+ <div style='margin-bottom: 0.6em;'>
1812
+ ${e.$t("saveAndAddTooltip")}
1813
+ </div>
1814
+ <div class='flex items-center justify-center' style='padding-bottom: 0.5em;'>
1815
+ <div style='text-align: center; background-color: hsl(0, 0%, 40%); line-height: 1; border-radius: 0.5em; display: inline-flex; align-items: center; justify-content: center; padding: 0.5em;'>
1816
+ <svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 35 35'><path fill='none' stroke='#ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M11.208 31h12.584V15.895h8.732L17.5 1.39 2.476 15.895h8.732V31z'/></svg>
1817
+ </div>
1818
+ <div style='text-align: center; background-color: hsl(0, 0%, 40%); line-height: 1; border-radius: 0.5em; display: inline-flex; align-items: center; justify-content: center; padding: 0.5em; margin-left: 0.5em;'>
1819
+ <svg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 -12 50 50'><path fill='none' stroke='#ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' stroke d='M45.706.897c.55.002.994.458.993.994l-.036 18.01c0 .55-.44.996-1.008.996H5.12l10.568 8.886-1.467 1.738L0 19.758 14.22 8l1.468 1.738L5.12 18.624h38.987c.162 0 .293-.134.293-.296V3.445c0-.163-.144-.295-.292-.295H32.054c-.278 0-.504-.23-.504-.5v-1.3c0-.277.214-.5.504-.498l13.652.045z'/></svg>
1820
+ </div>
1821
+ </div>
1822
+ `
1823
+ }]
1824
+ ]),
1825
+ u(k, {
1826
+ size: "large",
1827
+ class: "flex-grow",
1828
+ type: "secondary",
1829
+ style: { padding: "1.75em", height: "4em", "font-size": "16px" },
1830
+ "full-width": "",
1831
+ tabindex: "0",
1832
+ onClick: i.onSaveArticle
1833
+ }, {
1834
+ default: g(() => [
1835
+ I(m(e.$t("save")), 1)
1836
+ ]),
1837
+ _: 1
1838
+ }, 8, ["onClick"])
1839
+ ])
1840
+ ])
1841
+ ], 34);
1842
+ }
1843
+ const Pi = /* @__PURE__ */ S(pi, [["render", Ci], ["__scopeId", "data-v-eacf482e"]]), xi = {
1844
+ i18nOptions: {
1845
+ name: "ArticleListEdit",
1846
+ namespaces: "ArticleListEdit",
1847
+ messages: {
1848
+ en: {
1849
+ vatOption: {
1850
+ label: "Enter",
1851
+ message: "You are now entering prices {{- vatOption}}."
1852
+ }
1853
+ },
1854
+ sv: {
1855
+ vatOption: {
1856
+ label: "Ange",
1857
+ message: "Du anger priser {{- vatOption}} nu"
1858
+ }
1859
+ }
1860
+ }
1861
+ },
1862
+ components: {
1863
+ // eslint-disable-next-line vue/no-reserved-component-names
1864
+ Article: jt,
1865
+ ArticleModal: Pi,
1866
+ WithDimensions: je,
1867
+ Sortable: He
1868
+ },
1869
+ expose: ["focusLastArticle", "openLastArticle"],
1870
+ mixins: [F([])],
1871
+ props: {
1872
+ _document: {
1873
+ type: Object,
1874
+ default: () => ({})
1875
+ },
1876
+ articles: {
1877
+ type: Array,
1878
+ required: !0
1879
+ },
1880
+ activeHouseWorkType: {
1881
+ type: String,
1882
+ default: null
1883
+ },
1884
+ rootPriceType: {
1885
+ type: String,
1886
+ default: "fixed"
1887
+ },
1888
+ hideControls: {
1889
+ type: Boolean,
1890
+ default: !1
1891
+ }
1892
+ },
1893
+ setup() {
1894
+ return { articleItem: Re(null) };
1895
+ },
1896
+ emits: [
1897
+ "input",
1898
+ "insert",
1899
+ "move",
1900
+ "remove",
1901
+ "update:setPricesIncVat",
1902
+ "update:currency",
1903
+ "add",
1904
+ "focus"
1905
+ ],
1906
+ data() {
1907
+ return {
1908
+ selectedIndex: null,
1909
+ showModal: !1
1910
+ };
1911
+ },
1912
+ computed: {
1913
+ ...R({
1914
+ hidePriceInput: "settings/allowHideDocArticlePriceInput",
1915
+ hidePriceOnNew: "settings/hidePriceOnNewlyAddedArticles"
1916
+ }),
1917
+ articlesWithTotal() {
1918
+ return X(this.articles);
1919
+ },
1920
+ isIndivid() {
1921
+ return P(this._document, "prices.helpers.isIndivid", !0);
1922
+ },
1923
+ setPricesIncVat() {
1924
+ return P(this, "_document.setPricesIncVat", null);
1925
+ },
1926
+ currency() {
1927
+ return P(this._document, "currency");
1928
+ },
1929
+ useVat() {
1930
+ return P(this, "_document.useVat");
1931
+ },
1932
+ vatType() {
1933
+ return P(this, "_document.vatType");
1934
+ },
1935
+ showVatToggle() {
1936
+ return this.useVat && (this.setPricesIncVat || (this.articles || []).some(({ vat: e }) => e !== null));
1937
+ }
1938
+ },
1939
+ watch: {
1940
+ activeHouseWorkType: {
1941
+ immediate: !0,
1942
+ handler(e) {
1943
+ this.toggleDeductions(e);
1944
+ }
1945
+ },
1946
+ isIndivid(e) {
1947
+ e || this.toggleDeductions(!1);
1948
+ },
1949
+ setPricesIncVat(e) {
1950
+ this.updateArticlesVatOption(), ["extension", "widget"].includes(Le.value) || this.showMessage({
1951
+ type: "info",
1952
+ message: this.$t("vatOption.message", {
1953
+ vatOption: this.$t(`_common:vat.${e ? "incVat" : "exVat"}`, {
1954
+ thing: this.$t("_common:vat.sharedTitle")
1955
+ })
1956
+ })
1957
+ });
1958
+ }
1959
+ },
1960
+ methods: {
1961
+ ...B({
1962
+ showMessage: M.SHOW_MESSAGE
1963
+ }),
1964
+ openModal(e, { focusEl: t = "" } = {}) {
1965
+ this.selectedIndex = e, this.showModal = !0, t && this.$nextTick(() => {
1966
+ this.$nextTick(() => {
1967
+ this.$refs.articleModal && this.$refs.articleModal.focusEl(t);
1968
+ });
1969
+ });
1970
+ },
1971
+ updateArticleObject(e, t) {
1972
+ const s = t;
1973
+ this.isIndivid || (s.isDeductable = !1, s.isRut = !1, s.greenRot15 = !1, s.greenRot20 = !1, s.greenRot50 = !1), this.$emit("input", { index: e, value: s });
1974
+ },
1975
+ onRemoveArticle(e) {
1976
+ this.$emit("remove", e);
1977
+ },
1978
+ onEsc(e, t) {
1979
+ e === this.articles.length - 1 && ["name", "price", "discount"].every((s) => !t[s]) && this.onRemoveArticle(e);
1980
+ },
1981
+ changeVat() {
1982
+ this.$emit("update:setPricesIncVat", !this.setPricesIncVat);
1983
+ },
1984
+ updateArticlesVatOption() {
1985
+ this.articles.forEach((e, t) => {
1986
+ if (e.priceType === "markup") return;
1987
+ let s = z({ amount: e.price }).divide(
1988
+ (100 + e.vat) * 0.01
1989
+ );
1990
+ this.setPricesIncVat || (s = z({ amount: e.price }).multiply(
1991
+ (100 + e.vat) * 0.01
1992
+ )), this.updateArticleObject(
1993
+ t,
1994
+ X({ ...e, price: s.getAmount() })
1995
+ );
1996
+ });
1997
+ },
1998
+ // Method used by parent component
1999
+ focusLastArticle() {
2000
+ this.$nextTick(() => {
2001
+ var e;
2002
+ return (e = this.articleItem) == null ? void 0 : e.focusName();
2003
+ });
2004
+ },
2005
+ openLastArticle() {
2006
+ this.$nextTick(() => this.openModal(this.articles.length - 1));
2007
+ },
2008
+ toggleDeductions(e) {
2009
+ const t = {
2010
+ rot: "isDeductable",
2011
+ rut: "isRut",
2012
+ greenRot15: "greenRot15",
2013
+ greenRot20: "greenRot20",
2014
+ greenRot50: "greenRot50"
2015
+ }, s = (o = []) => o.reduce((n, i) => ({ ...n, [i]: !1 }), {});
2016
+ t[e] ? this.articles.forEach((o, n) => {
2017
+ const i = Object.values(le(t, [e]));
2018
+ if (i.some((y) => !!o[y])) {
2019
+ const y = { ...o, ...s(i) };
2020
+ this.$emit("input", { index: n, value: y });
2021
+ }
2022
+ }) : e === !1 && this.articles.forEach((o, n) => {
2023
+ const i = Object.values(t);
2024
+ if (i.some((y) => !!o[y])) {
2025
+ const y = { ...o, ...s(i) };
2026
+ this.$emit("input", { index: n, value: y });
2027
+ }
2028
+ });
2029
+ },
2030
+ onAdd(e) {
2031
+ const { newIndex: t, item: s } = e, o = s == null ? void 0 : s._data;
2032
+ o && (s == null || s.remove(), this.$emit("insert", { index: t, value: o }));
2033
+ },
2034
+ onRemove(e) {
2035
+ this.$emit("remove", e.oldIndex);
2036
+ },
2037
+ onUpdate(e) {
2038
+ const t = qe(
2039
+ this.articles,
2040
+ e.oldIndex,
2041
+ e.newIndex
2042
+ ).filter(Boolean);
2043
+ this.$emit("move", t);
2044
+ }
2045
+ }
2046
+ }, Vi = {
2047
+ key: 0,
2048
+ class: "label-text"
2049
+ };
2050
+ function Si(e, t, s, o, n, i) {
2051
+ const y = v("Article"), h = v("Sortable"), f = v("WithDimensions"), p = v("ArticleModal"), b = v("Portal");
2052
+ return a(), c("div", null, [
2053
+ i.showVatToggle ? (a(), c("div", Vi, [
2054
+ I(m(e.$t("vatOption.label")) + " ", 1),
2055
+ l("span", {
2056
+ onClick: t[0] || (t[0] = (k) => i.changeVat())
2057
+ }, m(s._document.$t(`vat.${i.setPricesIncVat ? "incVat" : "exVat"}`)), 1)
2058
+ ])) : w("", !0),
2059
+ u(f, null, {
2060
+ default: g(({ width: k }) => [
2061
+ u(h, {
2062
+ "item-key": "_uniqueId",
2063
+ options: {
2064
+ group: "articles",
2065
+ sort: !0,
2066
+ animation: 150,
2067
+ ghostClass: "article-ghost",
2068
+ handle: ".article-draggable-handle",
2069
+ onAdd: i.onAdd,
2070
+ onRemove: i.onRemove,
2071
+ onUpdate: i.onUpdate
2072
+ },
2073
+ list: s.articles,
2074
+ style: { "min-height": "calc(3 * var(--rem))" }
2075
+ }, {
2076
+ item: g(({ item: C, index: d }) => [
2077
+ u(y, {
2078
+ ref: "articleItem",
2079
+ value: C,
2080
+ width: k,
2081
+ "hide-price-input": e.hidePriceInput,
2082
+ "hide-price-on-new": e.hidePriceOnNew,
2083
+ "is-inc-vat": i.setPricesIncVat,
2084
+ "hide-controls": s.hideControls,
2085
+ "root-price-type": s.rootPriceType,
2086
+ "active-house-work-type": s.activeHouseWorkType,
2087
+ class: "article-item",
2088
+ "onUpdate:currency": t[1] || (t[1] = ($) => e.$emit("update:currency", $)),
2089
+ onInput: ($) => i.updateArticleObject(d, $),
2090
+ onFocus: t[2] || (t[2] = ($) => e.$emit("focus")),
2091
+ onRemove: ($) => i.onRemoveArticle(d),
2092
+ onOpenModal: ($) => i.openModal(d, $),
2093
+ onAdd: ($) => d === i.articlesWithTotal.length - 1 ? e.$emit("add") : null,
2094
+ onSelect: ($) => d === i.articlesWithTotal.length - 1 ? e.$emit("add") : null,
2095
+ onEsc: ($) => i.onEsc(d, C)
2096
+ }, null, 8, ["value", "width", "hide-price-input", "hide-price-on-new", "is-inc-vat", "hide-controls", "root-price-type", "active-house-work-type", "onInput", "onRemove", "onOpenModal", "onAdd", "onSelect", "onEsc"])
2097
+ ]),
2098
+ _: 2
2099
+ }, 1032, ["options", "list"])
2100
+ ]),
2101
+ _: 1
2102
+ }),
2103
+ u(b, { to: "modal" }, {
2104
+ default: g(() => [
2105
+ n.showModal && i.articlesWithTotal[n.selectedIndex] ? (a(), T(p, {
2106
+ key: 0,
2107
+ ref: "articleModal",
2108
+ _document: s._document,
2109
+ index: n.selectedIndex,
2110
+ "article-list": i.articlesWithTotal,
2111
+ "hide-price-input": e.hidePriceInput,
2112
+ "hide-price-on-new": e.hidePriceOnNew,
2113
+ "is-inc-vat": i.setPricesIncVat,
2114
+ "root-price-type": s.rootPriceType,
2115
+ currency: i.currency,
2116
+ "active-house-work-type": s.activeHouseWorkType,
2117
+ "view-settings": e.viewSettings,
2118
+ "onUpdate:currency": t[3] || (t[3] = (k) => e.$emit("update:currency", k)),
2119
+ onInput: t[4] || (t[4] = (k) => i.updateArticleObject(n.selectedIndex, k)),
2120
+ onAdd: t[5] || (t[5] = (k) => e.$emit("add", k)),
2121
+ onOpenModal: i.openModal,
2122
+ onClose: t[6] || (t[6] = (k) => n.showModal = !1)
2123
+ }, null, 8, ["_document", "index", "article-list", "hide-price-input", "hide-price-on-new", "is-inc-vat", "root-price-type", "currency", "active-house-work-type", "view-settings", "onOpenModal"])) : w("", !0)
2124
+ ]),
2125
+ _: 1
2126
+ })
2127
+ ]);
2128
+ }
2129
+ const Di = /* @__PURE__ */ S(xi, [["render", Si], ["__scopeId", "data-v-f7bdd8ec"]]), Mi = {
2130
+ name: "MaxTotalInput",
2131
+ i18nOptions: {
2132
+ namespaces: "MaxTotalInput",
2133
+ messages: {
2134
+ en: {
2135
+ maxTotalLabel: "Add a price"
2136
+ },
2137
+ sv: {
2138
+ maxTotalLabel: "Ange ett pris"
2139
+ }
2140
+ }
2141
+ },
2142
+ components: {
2143
+ CPriceInput: K
2144
+ },
2145
+ props: {
2146
+ modelValue: {
2147
+ type: Number,
2148
+ default: null
2149
+ },
2150
+ currency: {
2151
+ type: String,
2152
+ required: !0
2153
+ },
2154
+ vatType: {
2155
+ type: String,
2156
+ required: !0
2157
+ }
2158
+ },
2159
+ emits: ["update:modelValue"],
2160
+ data() {
2161
+ return {
2162
+ getCurrencySymbol: ee
2163
+ };
2164
+ },
2165
+ computed: {
2166
+ ...R({
2167
+ isIncVat: "application/isIncVat"
2168
+ })
2169
+ },
2170
+ watch: {
2171
+ isIncVat(e) {
2172
+ let t = z({ amount: this.modelValue }).divide(
2173
+ 1.25
2174
+ );
2175
+ e || (t = z({ amount: this.modelValue }).multiply(
2176
+ 125 * 0.01
2177
+ )), this.$emit("update:modelValue", t.getAmount());
2178
+ }
2179
+ }
2180
+ }, Ri = { class: "flex w-full justify-end" };
2181
+ function Li(e, t, s, o, n, i) {
2182
+ const y = v("CPriceInput");
2183
+ return a(), c("div", Ri, [
2184
+ u(y, {
2185
+ "model-value": s.modelValue,
2186
+ currency: s.currency,
2187
+ "is-inc-vat": e.isIncVat,
2188
+ vat: 25,
2189
+ placeholder: e.$t("maxTotalLabel"),
2190
+ min: "0",
2191
+ class: "mt-4 max-w-[275px] text-sm",
2192
+ "prefix-class": "text-gray-400",
2193
+ "suffix-class": "text-gray-400",
2194
+ "onUpdate:modelValue": t[0] || (t[0] = (h) => e.$emit("update:modelValue", h))
2195
+ }, {
2196
+ prefix: g(() => [
2197
+ I(m(e.$t("price.maxPrice").capitalize()), 1)
2198
+ ]),
2199
+ suffix: g(() => [
2200
+ l("span", null, m(n.getCurrencySymbol(s.currency)) + " " + m(e.$t(`vat.${e.isIncVat ? "incVat" : "exVat"}`, {
2201
+ thing: e.$t(`vat.${s.vatType}`)
2202
+ })), 1)
2203
+ ]),
2204
+ _: 1
2205
+ }, 8, ["model-value", "currency", "is-inc-vat", "placeholder"])
2206
+ ]);
2207
+ }
2208
+ const Oi = /* @__PURE__ */ S(Mi, [["render", Li]]), Ei = {
2209
+ components: {
2210
+ CDropdown: q,
2211
+ CDropdownItem: G
2212
+ },
2213
+ props: {
2214
+ modelValue: {
2215
+ type: String,
2216
+ default: "fixed"
2217
+ }
2218
+ },
2219
+ emits: ["update:modelValue"],
2220
+ data() {
2221
+ return {
2222
+ priceTypeOptions: ["fixed", "approx", "openAcc", "openAccMaxPrice"]
2223
+ };
2224
+ }
2225
+ }, Ui = { class: "flex justify-end" };
2226
+ function Bi(e, t, s, o, n, i) {
2227
+ const y = v("CButton"), h = v("CDropdownItem"), f = v("CDropdown");
2228
+ return a(), c("div", Ui, [
2229
+ u(f, { "model-value": s.modelValue }, {
2230
+ trigger: g(() => [
2231
+ u(y, { class: "price-type-button" }, {
2232
+ default: g(() => [
2233
+ I(m(e.$t("price.pricing").capitalize()) + ": ", 1),
2234
+ l("span", null, m(e.$t(`price.${s.modelValue}`)), 1)
2235
+ ]),
2236
+ _: 1
2237
+ })
2238
+ ]),
2239
+ default: g(() => [
2240
+ (a(!0), c(A, null, V(n.priceTypeOptions, (p) => (a(), T(h, {
2241
+ key: p,
2242
+ value: p,
2243
+ class: "text-right",
2244
+ onClick: (b) => e.$emit("update:modelValue", p)
2245
+ }, {
2246
+ default: g(() => [
2247
+ I(m(e.$t(`price.${p}`)), 1)
2248
+ ]),
2249
+ _: 2
2250
+ }, 1032, ["value", "onClick"]))), 128))
2251
+ ]),
2252
+ _: 1
2253
+ }, 8, ["model-value"])
2254
+ ]);
2255
+ }
2256
+ const Wi = /* @__PURE__ */ S(Ei, [["render", Bi], ["__scopeId", "data-v-26c5da6c"]]), zi = {
2257
+ name: "EditDeduction",
2258
+ components: {
2259
+ CPriceInput: K
2260
+ },
2261
+ mixins: [F(["houseWorkManualAmount"])],
2262
+ props: {
2263
+ disabled: {
2264
+ type: Boolean,
2265
+ default: !1
2266
+ },
2267
+ total: {
2268
+ type: Number,
2269
+ required: !0
2270
+ },
2271
+ houseWorkType: {
2272
+ type: String,
2273
+ default: "rot"
2274
+ },
2275
+ houseWorkAmount: {
2276
+ type: Number,
2277
+ default: 0
2278
+ }
2279
+ },
2280
+ data() {
2281
+ return {
2282
+ amountUnit: "fixed",
2283
+ internalValue: null,
2284
+ modalName: `deduction-modal-${this.$.uid}`
2285
+ };
2286
+ },
2287
+ watch: {
2288
+ houseWorkType(e) {
2289
+ e || (this.houseWorkManualAmount = null);
2290
+ }
2291
+ },
2292
+ methods: {
2293
+ setDeduction(e) {
2294
+ this.internalValue = z({ amount: this.total }).multiply(e).getAmount();
2295
+ },
2296
+ showModal() {
2297
+ this.internalValue = this.houseWorkAmount, this.$modal.show(this.modalName);
2298
+ }
2299
+ }
2300
+ }, Fi = { class: "deduction-modal flex w-full flex-col items-center justify-between rounded-lg" }, ji = { style: { "font-size": "calc(calc(1 * var(--rem)) + 2px)", "font-weight": "800", "text-align": "center", "margin-bottom": "calc(1.5 * var(--rem))" } }, Ni = { style: { "margin-bottom": "calc(1 * var(--rem))", width: "100%" } }, Hi = { class: "flex w-full flex-wrap justify-center gap-2" }, qi = ["onClick"], Gi = {
2301
+ style: { "margin-right": "0.5em" },
2302
+ viewBox: "0 0 24 24",
2303
+ width: "12",
2304
+ height: "12",
2305
+ stroke: "currentColor",
2306
+ "stroke-width": "2",
2307
+ fill: "none",
2308
+ "stroke-linecap": "round",
2309
+ "stroke-linejoin": "round",
2310
+ class: "css-i6dzq1"
2311
+ };
2312
+ function Ki(e, t, s, o, n, i) {
2313
+ const y = v("CPriceInput"), h = v("CButton"), f = v("modal"), p = v("portal");
2314
+ return a(), c("div", null, [
2315
+ u(f, E({
2316
+ adaptive: !0,
2317
+ height: "auto",
2318
+ width: "90%",
2319
+ maxWidth: 420,
2320
+ classes: "primary"
2321
+ }, { name: n.modalName }), {
2322
+ default: g(() => [
2323
+ l("div", Fi, [
2324
+ l("div", ji, m(e.$t("deduction.manualType", {
2325
+ type: e.$t(`deduction.${s.houseWorkType}`)
2326
+ })), 1),
2327
+ l("div", Ni, [
2328
+ u(y, {
2329
+ modelValue: n.internalValue,
2330
+ "onUpdate:modelValue": t[0] || (t[0] = (b) => n.internalValue = b),
2331
+ modelModifiers: { number: !0 },
2332
+ currency: "SEK",
2333
+ placeholder: e.$t("enterThing", { thing: e.$t("deduction.deduction") }),
2334
+ min: "0",
2335
+ size: "medium",
2336
+ "suffix-class": "text-gray-400"
2337
+ }, {
2338
+ suffix: g(() => [
2339
+ I(m(e.$t("currency.SEK")), 1)
2340
+ ]),
2341
+ _: 1
2342
+ }, 8, ["modelValue", "placeholder"])
2343
+ ]),
2344
+ l("div", Hi, [
2345
+ (a(), c(A, null, V([
2346
+ { v: 0.09, l: "9%" },
2347
+ { v: 0.105, l: "10.5%" },
2348
+ { v: 0.1455, l: "14.55%" },
2349
+ { v: 0.194, l: "19.4%" },
2350
+ { v: 0.21, l: "21%" },
2351
+ { v: 0.485, l: "48.5%" },
2352
+ { v: 0.5, l: "50%" }
2353
+ ], (b) => l("div", {
2354
+ key: b.l,
2355
+ class: x([{
2356
+ active: Math.round(s.total * b.v * 0.01) * 100 === n.internalValue
2357
+ }, "deduction-button"]),
2358
+ onClick: (k) => i.setDeduction(b.v)
2359
+ }, m(b.l), 11, qi)), 64))
2360
+ ]),
2361
+ u(h, {
2362
+ type: "secondary",
2363
+ wide: "",
2364
+ class: "mt-8",
2365
+ onClick: t[1] || (t[1] = () => {
2366
+ e.houseWorkManualAmount = n.internalValue, e.$modal.hide(n.modalName);
2367
+ })
2368
+ }, {
2369
+ default: g(() => [
2370
+ I(m(e.$t("save")), 1)
2371
+ ]),
2372
+ _: 1
2373
+ }),
2374
+ u(h, {
2375
+ type: "secondary",
2376
+ pattern: "tertiary",
2377
+ wide: "",
2378
+ class: "mt-2",
2379
+ onClick: t[2] || (t[2] = () => {
2380
+ e.houseWorkManualAmount = null, e.$modal.hide(n.modalName);
2381
+ })
2382
+ }, {
2383
+ default: g(() => [
2384
+ I(m(e.$t("reset")), 1)
2385
+ ]),
2386
+ _: 1
2387
+ })
2388
+ ])
2389
+ ]),
2390
+ _: 1
2391
+ }, 16, ["name"]),
2392
+ e.houseWorkManualAmount ? (a(), T(p, {
2393
+ key: 0,
2394
+ order: 2,
2395
+ to: "document-nav-bottom"
2396
+ }, {
2397
+ default: g(() => [
2398
+ l("div", {
2399
+ class: "housework-manual-nav",
2400
+ onClick: t[3] || (t[3] = (b) => e.$modal.show(n.modalName))
2401
+ }, [
2402
+ (a(), c("svg", Gi, t[4] || (t[4] = [
2403
+ l("path", { d: "M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" }, null, -1),
2404
+ l("line", {
2405
+ x1: "12",
2406
+ y1: "9",
2407
+ x2: "12",
2408
+ y2: "13"
2409
+ }, null, -1),
2410
+ l("line", {
2411
+ x1: "12",
2412
+ y1: "17",
2413
+ x2: "12.01",
2414
+ y2: "17"
2415
+ }, null, -1)
2416
+ ]))),
2417
+ I(" " + m(e.$t("deduction.manualType", { type: e.$t(`deduction.${s.houseWorkType}`) })) + " " + m(e.$t("using")), 1)
2418
+ ])
2419
+ ]),
2420
+ _: 1
2421
+ })) : w("", !0)
2422
+ ]);
2423
+ }
2424
+ const Yi = /* @__PURE__ */ S(zi, [["render", Ki], ["__scopeId", "data-v-5de18d7b"]]), Zi = {
2425
+ name: "Pricing",
2426
+ components: {
2427
+ EditDeduction: Yi
2428
+ },
2429
+ props: {
2430
+ _document: {
2431
+ type: Object,
2432
+ default: () => ({})
2433
+ },
2434
+ basePath: {
2435
+ type: String,
2436
+ default: "data.prices"
2437
+ },
2438
+ packageId: {
2439
+ type: String,
2440
+ default: null
2441
+ }
2442
+ },
2443
+ emits: ["input"],
2444
+ data() {
2445
+ return {
2446
+ get: P
2447
+ };
2448
+ },
2449
+ computed: {
2450
+ vatType() {
2451
+ return P(this, "_document.vatType");
2452
+ },
2453
+ priceArray() {
2454
+ return [
2455
+ {
2456
+ label: this._document.$t("price.net"),
2457
+ value: this.prices.subTotal
2458
+ },
2459
+ ...this.prices.useVat ? [
2460
+ {
2461
+ label: this._document.$t(`vat.${this.vatType}`),
2462
+ value: this.prices.taxAmount
2463
+ }
2464
+ ] : [],
2465
+ ...this.showHouseWork ? [
2466
+ {
2467
+ label: this._document.$t("deduction.type", {
2468
+ type: this._document.$t(
2469
+ `deduction.${this.prices.region.houseWorkType}${this.prices.region.houseWorkManualAmount === null ? "_percentage" : ""}`
2470
+ )
2471
+ }),
2472
+ value: -this.prices.region.houseWorkAmount,
2473
+ action: () => this.$refs.deduction.showModal()
2474
+ }
2475
+ ] : [],
2476
+ ...this.prices.rounding.enabled && this.prices.rounding.show ? [
2477
+ {
2478
+ label: this._document.$t(
2479
+ "chapters.pricingSummary.blocks.rounding"
2480
+ ),
2481
+ value: this.prices.roundingAmount
2482
+ }
2483
+ ] : [],
2484
+ ...this.prices.helpers.discount ? [
2485
+ {
2486
+ label: this._document.$t("price.discount"),
2487
+ value: -this.prices.helpers.discount
2488
+ }
2489
+ ] : [],
2490
+ {
2491
+ classList: "main",
2492
+ label: this._document.$t("total"),
2493
+ subLabel: this.prices.useVat ? this._document.$t("vat.incVat") : "",
2494
+ prefix: this.prices.type === "approx" ? `${this._document.$t("approx")} ` : "",
2495
+ value: this.prices.total
2496
+ },
2497
+ ...typeof this.prices.maxTotal == "number" ? [
2498
+ {
2499
+ classList: "main",
2500
+ label: this._document.$t("price.maxPrice"),
2501
+ subLabel: this.prices.useVat ? this._document.$t("vat.incVat") : "",
2502
+ value: Math.round(this.prices.maxTotal * 1.25 || 0)
2503
+ // ! Hard coded swedish VAT
2504
+ }
2505
+ ] : []
2506
+ ].map((t) => ({
2507
+ ...t,
2508
+ value: j(t.value, {
2509
+ showZero: !0,
2510
+ decimals: 2,
2511
+ currency: this.prices.currency
2512
+ })
2513
+ }));
2514
+ },
2515
+ prices() {
2516
+ const { prices: e } = this._document.packageGroups.getPackageById(
2517
+ this.packageId
2518
+ );
2519
+ return e;
2520
+ },
2521
+ showHouseWork() {
2522
+ return !!P(this.prices, "region.houseWorkType", !1) || !!P(this.prices, "region.houseWorkManualAmount", !1);
2523
+ }
2524
+ }
2525
+ }, Ji = { class: "price-bubble" }, Qi = { class: "flex w-full items-center justify-between" }, Xi = { class: "price-label" }, es = {
2526
+ key: 0,
2527
+ class: "pricing-sub-label"
2528
+ }, ts = ["onClick"], is = { class: "price-value" };
2529
+ function ss(e, t, s, o, n, i) {
2530
+ const y = v("EditDeduction"), h = O("tooltip");
2531
+ return a(), c("div", Ji, [
2532
+ l("div", Qi, [
2533
+ i.showHouseWork ? (a(), T(y, {
2534
+ key: 0,
2535
+ ref: "deduction",
2536
+ disabled: !n.get(i.prices, "region.houseWorkType", !1),
2537
+ _document: s._document,
2538
+ _value: {
2539
+ houseWorkManualAmount: `${s.basePath}.data.prices.region.houseWorkManualAmount`
2540
+ },
2541
+ "house-work-type": i.prices.region.houseWorkType,
2542
+ "house-work-amount": i.prices.region.houseWorkAmount,
2543
+ total: i.prices.subTotal + i.prices.taxAmount,
2544
+ onInput: t[0] || (t[0] = (f) => e.$emit("input", f))
2545
+ }, null, 8, ["disabled", "_document", "_value", "house-work-type", "house-work-amount", "total"])) : w("", !0)
2546
+ ]),
2547
+ l("div", null, [
2548
+ (a(!0), c(A, null, V(i.priceArray, (f, p) => (a(), c("div", {
2549
+ key: p,
2550
+ class: x([[f.classList || ""], "price-row flex w-full justify-between"])
2551
+ }, [
2552
+ l("div", Xi, [
2553
+ I(m(f.label.capitalize()) + " ", 1),
2554
+ f.subLabel ? (a(), c("span", es, m(f.subLabel), 1)) : w("", !0),
2555
+ f.action ? D((a(), c("span", {
2556
+ key: 1,
2557
+ class: "pricing-action",
2558
+ onClick: (b) => f.action ? f.action() : null
2559
+ }, t[1] || (t[1] = [
2560
+ l("svg", {
2561
+ viewBox: "0 0 24 24",
2562
+ width: "15",
2563
+ height: "15",
2564
+ stroke: "currentColor",
2565
+ "stroke-width": "2.5",
2566
+ fill: "none",
2567
+ "stroke-linecap": "round",
2568
+ "stroke-linejoin": "round"
2569
+ }, [
2570
+ l("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }),
2571
+ l("path", { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" })
2572
+ ], -1)
2573
+ ]), 8, ts)), [
2574
+ [h, e.$t("edit", { thing: e.$t("deduction.deduction") })]
2575
+ ]) : w("", !0)
2576
+ ]),
2577
+ l("div", is, m(f.prefix) + " " + m(f.value), 1)
2578
+ ], 2))), 128))
2579
+ ])
2580
+ ]);
2581
+ }
2582
+ const ns = /* @__PURE__ */ S(Zi, [["render", ss], ["__scopeId", "data-v-90384cd6"]]), as = {
2583
+ name: "PackageItemEdit",
2584
+ i18nOptions: {
2585
+ namespaces: "PackageItemEdit",
2586
+ messages: {
2587
+ en: {
2588
+ base: "Default package",
2589
+ single: "Single option",
2590
+ option: "Selectable package",
2591
+ namePlaceholder: "Package name",
2592
+ textPlaceholder: "Package description",
2593
+ selected: "Pre selected",
2594
+ addButton: "Product / service",
2595
+ advancedButtonTooltip: "Open advanced settings"
2596
+ },
2597
+ sv: {
2598
+ base: "Grundpaket",
2599
+ single: "Ett alternativ",
2600
+ option: "Valbart alternativ",
2601
+ namePlaceholder: "Paketets namn",
2602
+ textPlaceholder: "Beskrivning av paketet",
2603
+ selected: "Förvald",
2604
+ addButton: "Vara / tjänst",
2605
+ advancedButtonTooltip: "Öppna avancerat läge"
2606
+ }
2607
+ }
2608
+ },
2609
+ components: {
2610
+ ArticleList: Di,
2611
+ PriceFormAlternatives: Wi,
2612
+ MaxTotalInput: Oi,
2613
+ Pricing: ns,
2614
+ TextEditor: Ne,
2615
+ CDropdown: q,
2616
+ CDropdownItem: G
2617
+ },
2618
+ emits: [
2619
+ "move",
2620
+ "input",
2621
+ "remove",
2622
+ "update:isSelectedDefault",
2623
+ "update:priceType",
2624
+ "update:setPricesIncVat",
2625
+ "update:currency",
2626
+ "remove-package"
2627
+ ],
2628
+ mixins: [
2629
+ F([
2630
+ "isSelectedDefault",
2631
+ "isSelected",
2632
+ "name",
2633
+ "description",
2634
+ "priceType",
2635
+ "maxTotal",
2636
+ "currency"
2637
+ ])
2638
+ ],
2639
+ props: {
2640
+ packageId: {
2641
+ type: String,
2642
+ required: !0
2643
+ },
2644
+ type: {
2645
+ type: String,
2646
+ required: !0
2647
+ },
2648
+ activeHouseWorkType: {
2649
+ type: String,
2650
+ default: null
2651
+ },
2652
+ toggable: {
2653
+ type: Boolean,
2654
+ default: !0
2655
+ },
2656
+ moveOptions: {
2657
+ type: Object,
2658
+ default: () => ({})
2659
+ }
2660
+ },
2661
+ data() {
2662
+ return {
2663
+ isFocus: !1,
2664
+ isHover: !1
2665
+ };
2666
+ },
2667
+ computed: {
2668
+ ...R({
2669
+ newArticle: "articles/getNewArticle"
2670
+ }),
2671
+ // keep info on original article array indices for updates
2672
+ articles() {
2673
+ return this._document.allArticles;
2674
+ },
2675
+ mappedPackageArticles() {
2676
+ return (this.articles || []).map((e, t) => ({ ...e, i: t })).filter(({ packageId: e }) => e === this.packageId);
2677
+ },
2678
+ internalDescription: {
2679
+ get() {
2680
+ return Oe(
2681
+ this.description,
2682
+ this._document.textTemplateMap,
2683
+ this._document._doc
2684
+ );
2685
+ },
2686
+ set(e) {
2687
+ this.description = Ee(e);
2688
+ }
2689
+ }
2690
+ },
2691
+ watch: {
2692
+ priceType(e, t) {
2693
+ if (!(e && e.startsWith("open") && t && t.startsWith("open"))) {
2694
+ if (e) {
2695
+ const s = e.startsWith("open") ? "openAcc" : e;
2696
+ this.mappedPackageArticles.forEach((o, n) => {
2697
+ this.onArticleInput({
2698
+ index: n,
2699
+ value: {
2700
+ ...o,
2701
+ priceType: s,
2702
+ ...s === "openAcc" && { quantity: 1 }
2703
+ }
2704
+ });
2705
+ });
2706
+ }
2707
+ }
2708
+ e !== "openAccMaxPrice" && (this.maxTotal = null);
2709
+ }
2710
+ },
2711
+ methods: {
2712
+ onRemove() {
2713
+ this.$emit("remove-package");
2714
+ },
2715
+ // Article Methods
2716
+ createEmptyArticle() {
2717
+ const e = this.newArticle({
2718
+ priceType: this.priceType.startsWith("open") ? "openAcc" : this.priceType,
2719
+ packageId: this.packageId,
2720
+ currency: this.currency
2721
+ });
2722
+ this.$emit("input", {
2723
+ key: "articles",
2724
+ value: [...this.articles, e]
2725
+ });
2726
+ },
2727
+ onArticleInput({ index: e, value: t }) {
2728
+ const { i: s } = this.mappedPackageArticles[e], o = Ue(t, [
2729
+ "allowRot",
2730
+ "allowRut",
2731
+ "isIncVat",
2732
+ "rootPriceType",
2733
+ "hideControls"
2734
+ ]);
2735
+ o.currency = this.currency, this.$emit("input", { key: `articles[${[s]}]`, value: o });
2736
+ },
2737
+ onArticleAdd({ openModal: e = !1 } = {}) {
2738
+ this.createEmptyArticle(), e ? this.$refs.articleList.openLastArticle() : this.$refs.articleList.focusLastArticle();
2739
+ },
2740
+ onInsert({ index: e, value: t }) {
2741
+ const s = Be(this.mappedPackageArticles).add(
2742
+ { ...t, packageId: this.packageId },
2743
+ e
2744
+ );
2745
+ this.$emit("input", {
2746
+ key: "articles",
2747
+ value: [
2748
+ ...this.articles.filter(
2749
+ ({ packageId: o }) => o !== this.packageId
2750
+ ),
2751
+ ...s
2752
+ ]
2753
+ });
2754
+ },
2755
+ onArticleRemove(e) {
2756
+ const { i: t } = this.mappedPackageArticles[e];
2757
+ this.$emit("remove", { key: `articles[${[t]}]` });
2758
+ },
2759
+ onArticleMove(e) {
2760
+ this.$emit("input", {
2761
+ key: "articles",
2762
+ value: [
2763
+ ...this.articles.filter(
2764
+ ({ packageId: t }) => t !== this.packageId
2765
+ ),
2766
+ ...e
2767
+ ]
2768
+ });
2769
+ }
2770
+ }
2771
+ }, os = { class: "min-h-0 rounded-md border border-gray-200 bg-white text-black" }, ls = { class: "flex w-full items-center justify-between bg-gray-100 py-1 pl-4 pr-1 text-sm font-medium text-gray-600" }, rs = { class: "p-4" }, cs = { class: "mb-0.5 flex items-center" }, ds = ["id", "placeholder"], us = { class: "mt-2 flex gap-2" };
2772
+ function ps(e, t, s, o, n, i) {
2773
+ const y = v("CButton"), h = v("CDropdownItem"), f = v("CDropdown"), p = v("TextEditor"), b = v("MaxTotalInput"), k = v("PriceFormAlternatives"), C = v("ArticleList"), d = v("CIcon"), $ = v("Pricing"), r = O("tooltip"), L = O("click-outside");
2774
+ return a(), c("div", os, [
2775
+ l("div", ls, [
2776
+ l("div", null, m(s.type === "single" ? e.$t("single") : s.type === "radio" || s.toggable ? e.$t("option") : e.$t("base")), 1),
2777
+ s.type !== "single" ? (a(), T(f, {
2778
+ key: 0,
2779
+ class: "ml-4"
2780
+ }, {
2781
+ trigger: g(() => [
2782
+ u(y, {
2783
+ size: "small",
2784
+ type: "text",
2785
+ pattern: "secondary",
2786
+ class: "is-thinner opacity-70"
2787
+ }, {
2788
+ default: g(() => [
2789
+ I(m(e.$t("_common:change")), 1)
2790
+ ]),
2791
+ _: 1
2792
+ })
2793
+ ]),
2794
+ default: g(() => [
2795
+ s.toggable ? (a(), c(A, { key: 0 }, [
2796
+ u(h, {
2797
+ value: e.isSelectedDefault,
2798
+ toggle: !0,
2799
+ "close-on-click": !1,
2800
+ onClick: t[0] || (t[0] = (_) => e.$emit("update:isSelectedDefault", !e.isSelectedDefault))
2801
+ }, {
2802
+ default: g(() => [
2803
+ I(m(e.$t("selected")), 1)
2804
+ ]),
2805
+ _: 1
2806
+ }, 8, ["value"]),
2807
+ u(h, { separator: "" })
2808
+ ], 64)) : w("", !0),
2809
+ u(h, {
2810
+ "icon-left": "arrow-up",
2811
+ disabled: !s.moveOptions.up,
2812
+ onClick: t[1] || (t[1] = (_) => e.$emit("move", -1))
2813
+ }, {
2814
+ default: g(() => [
2815
+ I(m(e.$t("_common:move", { thing: e.$t("_common:up") })), 1)
2816
+ ]),
2817
+ _: 1
2818
+ }, 8, ["disabled"]),
2819
+ u(h, {
2820
+ "icon-left": "arrow-down",
2821
+ disabled: !s.moveOptions.down,
2822
+ onClick: t[2] || (t[2] = (_) => e.$emit("move", 1))
2823
+ }, {
2824
+ default: g(() => [
2825
+ I(m(e.$t("_common:move", { thing: e.$t("_common:down") })), 1)
2826
+ ]),
2827
+ _: 1
2828
+ }, 8, ["disabled"]),
2829
+ u(h, {
2830
+ "icon-props": {
2831
+ stroke: "red"
2832
+ },
2833
+ "icon-left": "trash",
2834
+ onClick: i.onRemove
2835
+ }, {
2836
+ default: g(() => [
2837
+ I(m(e.$t("_common:remove")), 1)
2838
+ ]),
2839
+ _: 1
2840
+ }, 8, ["onClick"])
2841
+ ]),
2842
+ _: 1
2843
+ })) : w("", !0)
2844
+ ]),
2845
+ l("div", rs, [
2846
+ l("div", cs, [
2847
+ D(l("input", {
2848
+ id: `package-name-${s.packageId}`,
2849
+ "onUpdate:modelValue": t[3] || (t[3] = (_) => e.name = _),
2850
+ placeholder: e.$t("namePlaceholder"),
2851
+ class: "block w-full rounded-lg p-0 text-xl font-bold leading-loose placeholder:text-gray-400",
2852
+ onKeyup: t[4] || (t[4] = W((_) => e.$refs.editor.focus(), ["enter"]))
2853
+ }, null, 40, ds), [
2854
+ [We, e.name]
2855
+ ])
2856
+ ]),
2857
+ u(p, {
2858
+ ref: "editor",
2859
+ modelValue: i.internalDescription,
2860
+ "onUpdate:modelValue": t[5] || (t[5] = (_) => i.internalDescription = _),
2861
+ placeholder: e.$t("textPlaceholder"),
2862
+ mentions: () => e._document.textTemplateItems,
2863
+ snippets: !0,
2864
+ class: "text-editor mb-4"
2865
+ }, null, 8, ["modelValue", "placeholder", "mentions"]),
2866
+ D((a(), c("div", {
2867
+ onMouseoverPassive: t[15] || (t[15] = (_) => n.isHover = !0),
2868
+ onMouseleavePassive: t[16] || (t[16] = (_) => n.isHover = !1)
2869
+ }, [
2870
+ e.priceType === "openAccMaxPrice" ? (a(), T(b, {
2871
+ key: 0,
2872
+ modelValue: e.maxTotal,
2873
+ "onUpdate:modelValue": t[6] || (t[6] = (_) => e.maxTotal = _),
2874
+ currency: e.currency,
2875
+ "vat-type": e._document.vatType,
2876
+ class: "mb-4"
2877
+ }, null, 8, ["modelValue", "currency", "vat-type"])) : w("", !0),
2878
+ u(k, {
2879
+ modelValue: e.priceType,
2880
+ "onUpdate:modelValue": [
2881
+ t[7] || (t[7] = (_) => e.priceType = _),
2882
+ t[8] || (t[8] = (_) => e.$emit("update:priceType", _))
2883
+ ]
2884
+ }, null, 8, ["modelValue"]),
2885
+ u(C, {
2886
+ ref: "articleList",
2887
+ _document: e._document,
2888
+ articles: i.mappedPackageArticles,
2889
+ "root-price-type": e.priceType,
2890
+ "active-house-work-type": s.activeHouseWorkType,
2891
+ "hide-controls": !n.isFocus && !n.isHover,
2892
+ onInput: i.onArticleInput,
2893
+ "onUpdate:setPricesIncVat": t[9] || (t[9] = (_) => e.$emit("update:setPricesIncVat", _)),
2894
+ "onUpdate:currency": t[10] || (t[10] = (_) => e.$emit("update:currency", _)),
2895
+ onMove: i.onArticleMove,
2896
+ onRemove: i.onArticleRemove,
2897
+ onAdd: i.onArticleAdd,
2898
+ onFocus: t[11] || (t[11] = (_) => n.isFocus = !0),
2899
+ onInsert: i.onInsert
2900
+ }, null, 8, ["_document", "articles", "root-price-type", "active-house-work-type", "hide-controls", "onInput", "onMove", "onRemove", "onAdd", "onInsert"]),
2901
+ l("div", us, [
2902
+ l("div", {
2903
+ class: "cursor-pointer rounded-md border border-gray-200 bg-gray-100 p-2.5 text-center text-sm font-medium leading-none text-gray-500 transition-colors hover:border-gray-400 hover:bg-gray-500 hover:text-white",
2904
+ onClick: t[12] || (t[12] = (_) => i.onArticleAdd())
2905
+ }, [
2906
+ u(d, {
2907
+ type: "plus",
2908
+ size: "16",
2909
+ "stroke-width": "3",
2910
+ class: "mr-1"
2911
+ }),
2912
+ I(" " + m(e.$t("addButton")), 1)
2913
+ ]),
2914
+ D((a(), c("div", {
2915
+ class: "cursor-pointer rounded-md border border-gray-200 bg-gray-100 p-2.5 text-center text-sm font-medium leading-none text-gray-500 transition-colors hover:border-gray-400 hover:bg-gray-500 hover:text-white",
2916
+ onClick: t[13] || (t[13] = (_) => i.onArticleAdd({ openModal: !0 }))
2917
+ }, [
2918
+ u(d, {
2919
+ type: "zap",
2920
+ size: "16",
2921
+ "stroke-width": "2.5"
2922
+ })
2923
+ ])), [
2924
+ [r, {
2925
+ content: e.$t("advancedButtonTooltip"),
2926
+ distance: 6
2927
+ }]
2928
+ ])
2929
+ ]),
2930
+ u($, {
2931
+ _document: e._document,
2932
+ "base-path": `${e._value.basePath}`,
2933
+ "package-id": s.packageId,
2934
+ onInput: t[14] || (t[14] = (_) => e.$emit("input", _))
2935
+ }, null, 8, ["_document", "base-path", "package-id"])
2936
+ ], 32)), [
2937
+ [
2938
+ L,
2939
+ () => {
2940
+ n.isFocus = !1, n.isHover = !1;
2941
+ }
2942
+ ]
2943
+ ])
2944
+ ])
2945
+ ]);
2946
+ }
2947
+ const ms = /* @__PURE__ */ S(as, [["render", ps], ["__scopeId", "data-v-b03c63bf"]]), hs = (e) => (e || []).slice(0, 1).map((t) => ({
2948
+ ...t,
2949
+ isSelected: !0,
2950
+ isSelectedDefault: !0,
2951
+ toggable: !1
2952
+ })), gs = (e) => {
2953
+ const t = P(e, "0.data.prices.type") || "fixed";
2954
+ return (e || []).map((s, o) => ({
2955
+ ...s,
2956
+ toggable: !0,
2957
+ ...o === 0 ? {
2958
+ isSelected: !0,
2959
+ isSelectedDefault: !0,
2960
+ toggable: !1
2961
+ } : null,
2962
+ data: {
2963
+ ...s.data,
2964
+ prices: {
2965
+ ...s.data ? s.data.prices : null,
2966
+ type: t
2967
+ }
2968
+ }
2969
+ }));
2970
+ }, vs = (e = []) => {
2971
+ let t = !1;
2972
+ return e.map((s) => {
2973
+ const o = {
2974
+ ...s,
2975
+ // if any earlier pkg is selected, deselect pkg, otherwise keep as is
2976
+ ...t ? {
2977
+ isSelected: !1,
2978
+ isSelectedDefault: !1
2979
+ } : null,
2980
+ toggable: !0
2981
+ };
2982
+ return (o.isSelected || o.isSelectedDefault) && (t = !0), o;
2983
+ }, []);
2984
+ };
2985
+ function fs(e, ...t) {
2986
+ if (e === "single") return hs(...t);
2987
+ if (e === "checkbox") return gs(...t);
2988
+ if (e === "radio") return vs(...t);
2989
+ throw new Error(`Package filter type '${e}' is not implemented`);
2990
+ }
2991
+ const ys = {
2992
+ name: "PackageGroupEdit",
2993
+ i18nOptions: {
2994
+ namespaces: "PackageGroupEdit",
2995
+ messages: {
2996
+ en: {
2997
+ base: "Default package",
2998
+ add: "Add package",
2999
+ basePlaceholder: "Add a default package that's always included.",
3000
+ selectablePlaceholder: "Add packages your client can choose between.",
3001
+ hideGroupPrice: "Hide summary for block",
3002
+ reset: {
3003
+ message: "Package type changed",
3004
+ button: "Revert"
3005
+ },
3006
+ error: {
3007
+ selectType: "Choose price type",
3008
+ minOnePackage: "Add at least 1 package"
3009
+ }
3010
+ },
3011
+ sv: {
3012
+ base: "Grundpaket",
3013
+ add: "Valbart alternativ",
3014
+ basePlaceholder: "Lägg till ett baspaket som alltid ingår.",
3015
+ selectablePlaceholder: "Lägg till valbara paket som din kund kan välja mellan.",
3016
+ hideGroupPrice: "Dölj summering för block",
3017
+ reset: {
3018
+ message: "Pakettyp har ändrats",
3019
+ button: "Återställ"
3020
+ },
3021
+ error: {
3022
+ selectType: "Välj ett prisförslag",
3023
+ minOnePackage: "Lägg till minst 1 paket"
3024
+ }
3025
+ }
3026
+ }
3027
+ },
3028
+ components: {
3029
+ ErrorCallout: se,
3030
+ PackageItem: ms,
3031
+ PackageGroupSelect: At,
3032
+ CCallout: ge,
3033
+ CDropdown: q,
3034
+ CDropdownItem: G
3035
+ },
3036
+ mixins: [
3037
+ F([
3038
+ "type",
3039
+ // 'title',
3040
+ "packages",
3041
+ "articles",
3042
+ "hideGroupPrice"
3043
+ ])
3044
+ ],
3045
+ props: {
3046
+ persistedGroup: {
3047
+ type: Object,
3048
+ default: () => ({})
3049
+ },
3050
+ validator: {
3051
+ type: Object,
3052
+ default: () => ({})
3053
+ }
3054
+ },
3055
+ emits: ["input", "add", "remove", "update:persisted-group"],
3056
+ data() {
3057
+ return {
3058
+ setPricesDirty: !1
3059
+ };
3060
+ },
3061
+ computed: {
3062
+ ...R({
3063
+ getSetting: ["settings/getCompanySetting"],
3064
+ defaultCurrency: "settings/defaultCurrency",
3065
+ newArticle: "articles/getNewArticle"
3066
+ }),
3067
+ internalPackages() {
3068
+ return this.packages.map((e, t) => ({ ...e, index: t }));
3069
+ },
3070
+ topRowPackages() {
3071
+ return this.type === "checkbox" ? this.internalPackages.filter(({ toggable: e }) => e === !1) : this.internalPackages;
3072
+ },
3073
+ bottomRowPackages() {
3074
+ return this.type === "checkbox" ? this.internalPackages.filter(({ toggable: e }) => e === !0) : [];
3075
+ },
3076
+ group() {
3077
+ return this._document.packageGroups.getPackageGroupUniqId(
3078
+ this._value.groupId
3079
+ ) || {};
3080
+ },
3081
+ houseWorkType() {
3082
+ return P(this.group, "prices.region.houseWorkType", null);
3083
+ },
3084
+ isIndivid() {
3085
+ return P(this, "_document.prices.helpers.isIndivid", !0);
3086
+ },
3087
+ setPricesIncVat() {
3088
+ return this._document.setPricesIncVat;
3089
+ },
3090
+ defaultVatInput() {
3091
+ return this.isIndivid ? this.getSetting("priceInputDefault") : this.getSetting("priceInputCompany");
3092
+ },
3093
+ currency() {
3094
+ return this._document.currency;
3095
+ }
3096
+ },
3097
+ watch: {
3098
+ isIndivid() {
3099
+ this.setPricesDirty || this.setPricesIncVatAsDefault();
3100
+ }
3101
+ },
3102
+ created() {
3103
+ this.setPricesIncVat === null && this.setPricesIncVatAsDefault({ ignoreChanges: !0 });
3104
+ },
3105
+ methods: {
3106
+ ...B({
3107
+ showMessage: M.SHOW_MESSAGE
3108
+ }),
3109
+ setPricesIncVatAsDefault(e = {}) {
3110
+ this.$emit("input", {
3111
+ key: "data.formSettings.setPricesIncVat",
3112
+ value: this.defaultVatInput === "incVat",
3113
+ options: e
3114
+ });
3115
+ },
3116
+ onSelectType(e) {
3117
+ this.type = e;
3118
+ const { type: t, packages: s } = this.persistedGroup || {};
3119
+ if (t && s && s.length)
3120
+ this.addPersistedGroup(e), e !== t && this.showMessage({
3121
+ type: "info",
3122
+ message: this.$t("reset.message"),
3123
+ actions: {
3124
+ undo: {
3125
+ text: this.$t("reset.button"),
3126
+ callback: () => {
3127
+ this.addPersistedGroup(t), this.type = t;
3128
+ }
3129
+ }
3130
+ }
3131
+ });
3132
+ else {
3133
+ if (e === "checkbox") return;
3134
+ this.addPackage({});
3135
+ }
3136
+ },
3137
+ addPersistedGroup(e) {
3138
+ if (!this.persistedGroup || !this.persistedGroup.type) return;
3139
+ let { packages: t, articles: s } = this.persistedGroup;
3140
+ if (!t.length) return;
3141
+ if (e !== this.persistedGroup.type && (t = fs(e, t)), e === "single" && s.length) {
3142
+ const [{ packageId: n }] = t;
3143
+ s = s.filter((i) => i.packageId === n);
3144
+ }
3145
+ const o = vt(
3146
+ [...this._document.allArticles || [], ...s || []],
3147
+ (n) => n._uniqueId
3148
+ );
3149
+ this.$emit("input", { key: "articles", value: o }), this.$emit("input", { key: `${[this._value.packages]}`, value: t });
3150
+ },
3151
+ addPackage(e = {}) {
3152
+ const t = ze(), s = this.type === "checkbox" && this.packages.length ? this.packages[0].data.prices.type : "fixed", o = this.currency || this.defaultCurrency, n = {
3153
+ isSelected: this.type === "single",
3154
+ isSelectedDefault: this.type === "single",
3155
+ toggable: !0,
3156
+ packageId: t,
3157
+ data: {
3158
+ name: "",
3159
+ description: "",
3160
+ prices: {
3161
+ type: s,
3162
+ currency: o
3163
+ }
3164
+ },
3165
+ ...e
3166
+ };
3167
+ this.$emit("input", { key: this._value.packages, value: n }), this.$emit("input", {
3168
+ key: "articles",
3169
+ value: this.newArticle({
3170
+ priceType: s.startsWith("open") ? "openAcc" : s,
3171
+ packageId: t,
3172
+ currency: o
3173
+ })
3174
+ }), this.$nextTick(() => {
3175
+ const i = document.getElementById(`package-name-${t}`);
3176
+ i && i.focus();
3177
+ });
3178
+ },
3179
+ onInputPriceType(e, t) {
3180
+ this.type === "checkbox" && this.packages.forEach((s, o) => {
3181
+ o !== e && this.$emit("input", {
3182
+ key: `${[this._value.packages]}[${[o]}].data.prices.type`,
3183
+ value: t
3184
+ });
3185
+ });
3186
+ },
3187
+ onInputSelectedDefault(e, t) {
3188
+ this.type === "radio" && !t || (this.type === "radio" && t && this.packages.forEach((s, o) => {
3189
+ o !== e && (this.$emit("input", {
3190
+ key: `${[this._value.packages]}[${[o]}].isSelectedDefault`,
3191
+ value: !1
3192
+ }), this.$emit("input", {
3193
+ key: `${[this._value.packages]}[${[o]}].isSelected`,
3194
+ value: !1
3195
+ }));
3196
+ }), this.$emit("input", {
3197
+ key: `${[this._value.packages]}[${[e]}].isSelectedDefault`,
3198
+ value: t
3199
+ }), this.$emit("input", {
3200
+ key: `${[this._value.packages]}[${[e]}].isSelected`,
3201
+ value: t
3202
+ }));
3203
+ },
3204
+ removeByIndex(e) {
3205
+ const { packageId: t } = this.packages[e], s = this._document.allArticles.filter(
3206
+ ({ packageId: o }) => o !== t
3207
+ );
3208
+ this.$emit("input", { key: "articles", value: s }), this.$emit("remove", { key: `${[this._value.packages]}[${[e]}]` });
3209
+ },
3210
+ async onResetType() {
3211
+ const e = this.packages.map((o) => o.packageId), [t, s] = this._document.allArticles.reduce(
3212
+ ([o, n], i) => e.includes(i.packageId) ? [[...o, i], n] : [o, [...n, i]],
3213
+ [[], []]
3214
+ );
3215
+ this.$emit("update:persisted-group", {
3216
+ type: this.type,
3217
+ packages: this.packages,
3218
+ articles: t
3219
+ }), this.$emit("input", { key: "articles", value: s }), this.$emit("input", { key: `${[this._value.packages]}`, value: [] }), this.type = "";
3220
+ },
3221
+ moveOptions(e, t) {
3222
+ const s = { up: !1, down: !1 };
3223
+ return e > 0 && (s.up = !0), e < t - 1 && (s.down = !0), s;
3224
+ },
3225
+ moveItem(e, t) {
3226
+ const s = ae(this.packages, e, t);
3227
+ this.$emit("input", { key: this._value.packages, value: s });
3228
+ }
3229
+ }
3230
+ }, ks = { class: "package-group-root font-inter" }, bs = { key: 0 }, ws = { style: { position: "absolute", right: "0", top: "-10px", transform: "translateY(-100%)", "z-index": "2" } }, Is = { class: "pb-4" }, $s = {
3231
+ key: 2,
3232
+ style: { width: "calc(5 * var(--rem))", height: "1px", "margin-left": "calc(50% - calc(2.5 * var(--rem)))", "border-top": "2px dashed hsl(0, 0%, 85%)" }
3233
+ }, _s = {
3234
+ key: 4,
3235
+ class: "flex w-full flex-col items-center justify-center"
3236
+ }, Ts = { style: { width: "100%" } }, As = {
3237
+ key: 0,
3238
+ class: "package-placeholder bg-gray-100",
3239
+ style: { color: "hsl(0, 0%, 24%)", "font-weight": "500" }
3240
+ }, Cs = {
3241
+ style: { "vertical-align": "text-bottom", "margin-right": "3px" },
3242
+ width: "16",
3243
+ height: "16",
3244
+ viewBox: "0 0 18 14",
3245
+ xmlns: "http://www.w3.org/2000/svg"
3246
+ }, Ps = { class: "flex w-full" };
3247
+ function xs(e, t, s, o, n, i) {
3248
+ const y = v("PackageGroupSelect"), h = v("ErrorCallout"), f = v("CButton"), p = v("CDropdownItem"), b = v("CDropdown"), k = v("CCallout"), C = v("PackageItem");
3249
+ return a(), c("div", ks, [
3250
+ e.type ? (a(), c(A, { key: 1 }, [
3251
+ l("div", ws, [
3252
+ u(b, null, {
3253
+ trigger: g(() => [
3254
+ u(f, {
3255
+ type: "none",
3256
+ size: "normal",
3257
+ pattern: "secondary",
3258
+ icon: "more-horizontal",
3259
+ circle: ""
3260
+ })
3261
+ ]),
3262
+ default: g(() => [
3263
+ u(p, { onClick: i.onResetType }, {
3264
+ default: g(() => [
3265
+ I(m(e.$t("_common:change", {
3266
+ thing: e.$t("_common:price.proposal").toLowerCase()
3267
+ })), 1)
3268
+ ]),
3269
+ _: 1
3270
+ }, 8, ["onClick"]),
3271
+ u(p, {
3272
+ value: !!e.hideGroupPrice,
3273
+ "close-on-click": !1,
3274
+ toggle: "",
3275
+ onInput: t[1] || (t[1] = (d) => e.hideGroupPrice = d)
3276
+ }, {
3277
+ default: g(() => [
3278
+ I(m(e.$t("hideGroupPrice")), 1)
3279
+ ]),
3280
+ _: 1
3281
+ }, 8, ["value"])
3282
+ ]),
3283
+ _: 1
3284
+ })
3285
+ ]),
3286
+ e.type === "checkbox" && !i.internalPackages.find((d) => d.toggable === !1) ? (a(), T(k, {
3287
+ key: 0,
3288
+ title: e.$t("base"),
3289
+ class: "w-full"
3290
+ }, {
3291
+ default: g(() => [
3292
+ l("div", Is, m(e.$t("basePlaceholder")), 1),
3293
+ u(f, {
3294
+ type: "secondary",
3295
+ size: "small",
3296
+ style: { "font-weight": "600" },
3297
+ onClick: t[2] || (t[2] = (d) => i.addPackage({
3298
+ isSelected: !0,
3299
+ isSelectedDefault: !0,
3300
+ toggable: !1
3301
+ }))
3302
+ }, {
3303
+ default: g(() => [
3304
+ I(m(e.$t("_common:add", { thing: e.$t("base").toLowerCase() })), 1)
3305
+ ]),
3306
+ _: 1
3307
+ })
3308
+ ]),
3309
+ _: 1
3310
+ }, 8, ["title"])) : (a(), T(te, {
3311
+ key: 1,
3312
+ name: "section-list",
3313
+ tag: "div"
3314
+ }, {
3315
+ default: g(() => [
3316
+ (a(!0), c(A, null, V(i.topRowPackages, (d, $) => (a(), c("div", {
3317
+ key: d.packageId,
3318
+ class: "section-item pb-4"
3319
+ }, [
3320
+ u(C, {
3321
+ _document: e._document,
3322
+ _value: {
3323
+ isSelectedDefault: `${e._value.packages}[${d.index}].isSelectedDefault`,
3324
+ isSelected: `${e._value.packages}[${d.index}].isSelected`,
3325
+ name: `${e._value.packages}[${d.index}].data.name`,
3326
+ description: `${e._value.packages}[${d.index}].data.description`,
3327
+ priceType: `${e._value.packages}[${d.index}].data.prices.type`,
3328
+ maxTotal: `${e._value.packages}[${d.index}].data.prices.maxTotal`,
3329
+ basePath: `${e._value.packages}[${d.index}]`,
3330
+ currency: `${e._value.packages}[${d.index}].data.prices.currency`
3331
+ },
3332
+ type: e.type,
3333
+ "active-house-work-type": i.houseWorkType,
3334
+ toggable: d.toggable,
3335
+ "package-id": d.packageId,
3336
+ "move-options": i.moveOptions($, i.topRowPackages.length),
3337
+ onInput: t[3] || (t[3] = (r) => e.$emit("input", r)),
3338
+ onAdd: t[4] || (t[4] = (r) => e.$emit("add", r)),
3339
+ "onUpdate:isSelectedDefault": (r) => i.onInputSelectedDefault(d.index, r),
3340
+ "onUpdate:priceType": (r) => i.onInputPriceType(d.index, r),
3341
+ "onUpdate:setPricesIncVat": t[5] || (t[5] = (r) => {
3342
+ e.$emit("input", {
3343
+ key: "data.formSettings.setPricesIncVat",
3344
+ value: r
3345
+ }), n.setPricesDirty = !0;
3346
+ }),
3347
+ "onUpdate:currency": t[6] || (t[6] = (r) => e.$emit("input", { key: "currency", value: r })),
3348
+ onRemove: t[7] || (t[7] = (r) => e.$emit("remove", r)),
3349
+ onRemovePackage: (r) => i.removeByIndex(d.index),
3350
+ onMove: (r) => i.moveItem(d.index, i.topRowPackages[$ + r].index)
3351
+ }, null, 8, ["_document", "_value", "type", "active-house-work-type", "toggable", "package-id", "move-options", "onUpdate:isSelectedDefault", "onUpdate:priceType", "onRemovePackage", "onMove"])
3352
+ ]))), 128))
3353
+ ]),
3354
+ _: 1
3355
+ })),
3356
+ e.type === "checkbox" && i.topRowPackages.length && i.bottomRowPackages.length ? (a(), c("div", $s)) : w("", !0),
3357
+ e.type === "checkbox" ? (a(), T(te, {
3358
+ key: 3,
3359
+ name: "section-list",
3360
+ tag: "div",
3361
+ style: { "margin-bottom": "calc(1 * var(--rem))" }
3362
+ }, {
3363
+ default: g(() => [
3364
+ (a(!0), c(A, null, V(i.bottomRowPackages, (d, $) => (a(), c("div", {
3365
+ key: d.packageId,
3366
+ class: "section-item",
3367
+ style: { padding: "calc(1 * var(--rem)) 0" }
3368
+ }, [
3369
+ u(C, {
3370
+ _document: e._document,
3371
+ _value: {
3372
+ isSelectedDefault: `${e._value.packages}[${d.index}].isSelectedDefault`,
3373
+ isSelected: `${e._value.packages}[${d.index}].isSelected`,
3374
+ name: `${e._value.packages}[${d.index}].data.name`,
3375
+ description: `${e._value.packages}[${d.index}].data.description`,
3376
+ priceType: `${e._value.packages}[${d.index}].data.prices.type`,
3377
+ maxTotal: `${e._value.packages}[${d.index}].data.prices.maxTotal`,
3378
+ basePath: `${e._value.packages}[${d.index}]`,
3379
+ currency: `${e._value.packages}[${d.index}].data.prices.currency`
3380
+ },
3381
+ type: e.type,
3382
+ "active-house-work-type": i.houseWorkType,
3383
+ "package-id": d.packageId,
3384
+ "move-options": i.moveOptions($, i.bottomRowPackages.length),
3385
+ class: "package-item",
3386
+ onInput: t[8] || (t[8] = (r) => e.$emit("input", r)),
3387
+ onAdd: t[9] || (t[9] = (r) => e.$emit("add", r)),
3388
+ "onUpdate:isSelectedDefault": (r) => i.onInputSelectedDefault(d.index, r),
3389
+ "onUpdate:priceType": (r) => i.onInputPriceType(d.index, r),
3390
+ "onUpdate:setPricesIncVat": t[10] || (t[10] = (r) => {
3391
+ e.$emit("input", {
3392
+ key: "data.formSettings.setPricesIncVat",
3393
+ value: r
3394
+ }), n.setPricesDirty = !0;
3395
+ }),
3396
+ onRemove: t[11] || (t[11] = (r) => e.$emit("remove", r)),
3397
+ onRemovePackage: (r) => i.removeByIndex(d.index),
3398
+ onMove: (r) => i.moveItem(d.index, i.bottomRowPackages[$ + r].index)
3399
+ }, null, 8, ["_document", "_value", "type", "active-house-work-type", "package-id", "move-options", "onUpdate:isSelectedDefault", "onUpdate:priceType", "onRemovePackage", "onMove"])
3400
+ ]))), 128))
3401
+ ]),
3402
+ _: 1
3403
+ })) : w("", !0),
3404
+ e.type !== "single" || !e.packages.length ? (a(), c("div", _s, [
3405
+ l("div", Ts, [
3406
+ e.type === "radio" && !e.packages.length ? (a(), c("div", As, [
3407
+ (a(), c("svg", Cs, t[13] || (t[13] = [
3408
+ l("path", {
3409
+ d: "M8.03.22c.3.3.3.77 0 1.06L5.56 3.75h6.88L9.97 1.28A.75.75 0 1111.03.21l3.53 3.54h2.69a.75.75 0 010 1.5h-.12l-1.17 6.4a2.25 2.25 0 01-2.21 1.85h-9.5a2.25 2.25 0 01-2.21-1.84L.87 5.26H.75a.75.75 0 010-1.5h2.69L6.97.21c.3-.3.77-.3 1.06 0zM2.4 5.25L3.5 11.4c.07.35.38.61.74.61h9.5c.36 0 .67-.26.74-.61l1.11-6.14H2.4zm3.1 1.5c.41-.06.8.22.86.63l.38 2.25a.75.75 0 11-1.48.24l-.37-2.25c-.07-.4.2-.8.61-.86zm7 0c.4.08.68.47.61.87l-.37 2.25a.75.75 0 11-1.48-.24l.38-2.25a.75.75 0 01.86-.62zm-3.5 0c.41 0 .75.34.75.75v2.25a.75.75 0 01-1.5 0V7.5c0-.41.34-.75.75-.75z",
3410
+ fill: "#000",
3411
+ "fill-rule": "evenodd"
3412
+ }, null, -1)
3413
+ ]))),
3414
+ I(" " + m(e.$t("selectablePlaceholder")), 1)
3415
+ ])) : w("", !0)
3416
+ ]),
3417
+ s.validator.$invalid && s.validator.$dirty ? (a(), T(h, {
3418
+ key: 0,
3419
+ message: e.$t("error.minOnePackage"),
3420
+ style: { margin: "calc(1 * var(--rem)) 0 calc(1 * var(--rem)) 0" }
3421
+ }, null, 8, ["message"])) : w("", !0),
3422
+ l("div", Ps, [
3423
+ u(f, {
3424
+ type: "secondary",
3425
+ outlined: "",
3426
+ "icon-left": "plus",
3427
+ style: { "border-color": "hsl(0, 0%, 82%)" },
3428
+ onClick: t[12] || (t[12] = (d) => i.addPackage())
3429
+ }, {
3430
+ default: g(() => [
3431
+ I(m(e.$t("add")), 1)
3432
+ ]),
3433
+ _: 1
3434
+ })
3435
+ ])
3436
+ ])) : w("", !0)
3437
+ ], 64)) : (a(), c("div", bs, [
3438
+ u(y, {
3439
+ onInput: t[0] || (t[0] = (d) => i.onSelectType(d))
3440
+ }),
3441
+ s.validator.$invalid && s.validator.$dirty ? (a(), T(h, {
3442
+ key: 0,
3443
+ message: e.$t("error.selectType"),
3444
+ style: { "padding-bottom": "calc(1.5 * var(--rem))" }
3445
+ }, null, 8, ["message"])) : w("", !0)
3446
+ ]))
3447
+ ]);
3448
+ }
3449
+ const Ns = /* @__PURE__ */ S(ys, [["render", xs], ["__scopeId", "data-v-03549668"]]);
3450
+ export {
3451
+ Ns as default
3452
+ };