@cling-se/widget 0.17.3 → 0.18.0

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