@dropins/storefront-quote-management 1.1.2 → 1.2.0-beta.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 (98) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/api.js +1172 -5
  3. package/api.js.map +1 -1
  4. package/chunks/ItemsQuoted.js +1 -1
  5. package/chunks/ItemsQuoted.js.map +1 -1
  6. package/chunks/ItemsQuotedTemplate.js +1 -1
  7. package/chunks/ItemsQuotedTemplate.js.map +1 -1
  8. package/chunks/QuoteCommentsList.js +1 -1
  9. package/chunks/QuoteCommentsList.js.map +1 -1
  10. package/chunks/QuoteHistoryLog.js +1 -1
  11. package/chunks/QuoteHistoryLog.js.map +1 -1
  12. package/chunks/QuoteTemplateCommentsList.js +1 -1
  13. package/chunks/QuoteTemplateCommentsList.js.map +1 -1
  14. package/chunks/QuoteTemplateHistoryLog.js +1 -1
  15. package/chunks/QuoteTemplateHistoryLog.js.map +1 -1
  16. package/chunks/ShippingAddressDisplay.js +1 -1
  17. package/chunks/ShippingAddressDisplay.js.map +1 -1
  18. package/chunks/components.js +4 -0
  19. package/chunks/components.js.map +1 -0
  20. package/containers/ItemsQuoted.js +1 -1
  21. package/containers/ItemsQuotedTemplate.js +1 -1
  22. package/containers/ManageNegotiableQuote.js +1 -1
  23. package/containers/ManageNegotiableQuote.js.map +1 -1
  24. package/containers/ManageNegotiableQuoteTemplate.js +2 -2
  25. package/containers/ManageNegotiableQuoteTemplate.js.map +1 -1
  26. package/containers/OrderSummary.js +1 -1
  27. package/containers/OrderSummary.js.map +1 -1
  28. package/containers/OrderSummaryLine.js +1 -1
  29. package/containers/QuoteCommentsList.js +1 -1
  30. package/containers/QuoteHistoryLog.js +1 -1
  31. package/containers/QuoteSummaryList.js +1 -1
  32. package/containers/QuoteSummaryList.js.map +1 -1
  33. package/containers/QuoteTemplateCommentsList.js +1 -1
  34. package/containers/QuoteTemplateHistoryLog.js +1 -1
  35. package/containers/QuoteTemplatesListTable.js +1 -1
  36. package/containers/QuoteTemplatesListTable.js.map +1 -1
  37. package/containers/QuotesListTable.js +1 -1
  38. package/containers/QuotesListTable.js.map +1 -1
  39. package/containers/RequestNegotiableQuoteForm.js +1 -1
  40. package/containers/RequestNegotiableQuoteForm.js.map +1 -1
  41. package/containers/ShippingAddressDisplay.js +1 -1
  42. package/package.json +1 -1
  43. package/render.js +2 -7
  44. package/render.js.map +1 -1
  45. package/chunks/AttachedFilesList.js +0 -4
  46. package/chunks/AttachedFilesList.js.map +0 -1
  47. package/chunks/CheckWithCircle.js +0 -4
  48. package/chunks/CheckWithCircle.js.map +0 -1
  49. package/chunks/ChevronDown.js +0 -4
  50. package/chunks/ChevronDown.js.map +0 -1
  51. package/chunks/ConfirmationModal.js +0 -4
  52. package/chunks/ConfirmationModal.js.map +0 -1
  53. package/chunks/LineItemNoteModal.js +0 -4
  54. package/chunks/LineItemNoteModal.js.map +0 -1
  55. package/chunks/NegotiableQuoteFragment.js +0 -396
  56. package/chunks/NegotiableQuoteFragment.js.map +0 -1
  57. package/chunks/NegotiableQuoteTemplateFragment.js +0 -342
  58. package/chunks/NegotiableQuoteTemplateFragment.js.map +0 -1
  59. package/chunks/OrderSummaryLine.js +0 -4
  60. package/chunks/OrderSummaryLine.js.map +0 -1
  61. package/chunks/QuoteCommentsList3.js +0 -4
  62. package/chunks/QuoteCommentsList3.js.map +0 -1
  63. package/chunks/QuoteHistoryLog3.js +0 -4
  64. package/chunks/QuoteHistoryLog3.js.map +0 -1
  65. package/chunks/RenameQuoteModal.js +0 -4
  66. package/chunks/RenameQuoteModal.js.map +0 -1
  67. package/chunks/WarningFilled.js +0 -4
  68. package/chunks/WarningFilled.js.map +0 -1
  69. package/chunks/addQuoteTemplateLineItemNote.js +0 -33
  70. package/chunks/addQuoteTemplateLineItemNote.js.map +0 -1
  71. package/chunks/dateUtils.js +0 -4
  72. package/chunks/dateUtils.js.map +0 -1
  73. package/chunks/duplicateNegotiableQuote.js +0 -109
  74. package/chunks/duplicateNegotiableQuote.js.map +0 -1
  75. package/chunks/generateQuoteFromTemplate.js +0 -12
  76. package/chunks/generateQuoteFromTemplate.js.map +0 -1
  77. package/chunks/getQuoteData.js +0 -16
  78. package/chunks/getQuoteData.js.map +0 -1
  79. package/chunks/getQuoteTemplateData.js +0 -28
  80. package/chunks/getQuoteTemplateData.js.map +0 -1
  81. package/chunks/getQuoteTemplates.js +0 -52
  82. package/chunks/getQuoteTemplates.js.map +0 -1
  83. package/chunks/negotiableQuotes.js +0 -77
  84. package/chunks/negotiableQuotes.js.map +0 -1
  85. package/chunks/openQuoteTemplate.js +0 -62
  86. package/chunks/openQuoteTemplate.js.map +0 -1
  87. package/chunks/requestNegotiableQuote.js +0 -25
  88. package/chunks/requestNegotiableQuote.js.map +0 -1
  89. package/chunks/setLineItemNote.js +0 -47
  90. package/chunks/setLineItemNote.js.map +0 -1
  91. package/chunks/state.js +0 -4
  92. package/chunks/state.js.map +0 -1
  93. package/chunks/transform-quote-template.js +0 -4
  94. package/chunks/transform-quote-template.js.map +0 -1
  95. package/chunks/transform-quote.js +0 -4
  96. package/chunks/transform-quote.js.map +0 -1
  97. package/chunks/uploadFile.js +0 -20
  98. package/chunks/uploadFile.js.map +0 -1
package/api.js CHANGED
@@ -1,6 +1,552 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{r as G}from"./chunks/requestNegotiableQuote.js";import{g as $}from"./chunks/getQuoteData.js";import{F as L,N as M,S as B,n as R}from"./chunks/negotiableQuotes.js";import{c as C,a as k,g as j,i as z}from"./chunks/getQuoteTemplateData.js";import{c as K,a as V,d as W,b as X,r as Y,s as Z}from"./chunks/duplicateNegotiableQuote.js";import{events as u}from"@dropins/tools/event-bus.js";import{f as m,t as c}from"./chunks/transform-quote.js";import{h as te,r as se,s as re,d as de,e as oe}from"./chunks/transform-quote.js";import{s as p}from"./chunks/state.js";import{N as A}from"./chunks/NegotiableQuoteFragment.js";import{u as ie}from"./chunks/uploadFile.js";import{Q as pe,a as ue,S as me,g as le}from"./chunks/getQuoteTemplates.js";import{b as he,c as ce,d as Ae,o as Te,s as fe,a as Ee}from"./chunks/openQuoteTemplate.js";import{a as T}from"./chunks/transform-quote-template.js";import{N as f}from"./chunks/NegotiableQuoteTemplateFragment.js";import{a as Ie,r as _e,u as Ne}from"./chunks/addQuoteTemplateLineItemNote.js";import{g as De}from"./chunks/generateQuoteFromTemplate.js";import{r as we,s as ve,u as Fe}from"./chunks/setLineItemNote.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";const E=`
3
+ import{events as _}from"@dropins/tools/event-bus.js";import{FetchGraphQL as F}from"@dropins/tools/fetch-graphql.js";import{Initializer as $}from"@dropins/tools/lib.js";var N=(e=>(e.NEW="NEW",e.SUBMITTED="SUBMITTED",e.PENDING="PENDING",e.UPDATED="UPDATED",e.OPEN="OPEN",e.ORDERED="ORDERED",e.CLOSED="CLOSED",e.DECLINED="DECLINED",e.EXPIRED="EXPIRED",e.DRAFT="DRAFT",e))(N||{}),g=(e=>(e.ACTIVE="Active",e.IN_REVIEW="In Review",e.INACTIVE="Inactive",e.SUBMITTED="Submitted",e.PENDING="Pending",e.CLOSED="Closed",e.OPEN="Open",e.UPDATED="Updated",e.EDITED="Edited",e.NEW="New",e.DRAFT="Draft",e.DECLINED="Declined",e.CANCELED="Canceled",e.EXPIRED="Expired",e))(g||{}),y=(e=>(e[e.TAX_EXCLUDED=1]="TAX_EXCLUDED",e[e.TAX_INCLUDED=2]="TAX_INCLUDED",e[e.TAX_INCLUDED_AND_EXCLUDED=3]="TAX_INCLUDED_AND_EXCLUDED",e))(y||{});const b={requestQuote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1,viewQuoteTemplates:!1,manageQuoteTemplates:!1,generateQuoteFromTemplate:!1},A={quoteSummaryDisplayTotal:1,quoteSummaryMaxItems:10,quoteDisplaySettings:{zeroTax:!1,subtotal:y.TAX_INCLUDED,price:y.TAX_INCLUDED,shipping:y.TAX_INCLUDED,fullSummary:!1,grandTotal:!0},useConfigurableParentThumbnail:!0,quoteMinimumAmount:null,quoteMinimumAmountMessage:null},C={authenticated:!1,permissions:b,config:A,initialized:!1,quoteDataLoaded:!1,quoteDataInitialized:!1},l=new Proxy(C,{get:(e,a)=>e[a],set:(e,a,t)=>(e[a]=t,!0)});function R(e){if(!e||typeof e!="object")return{requestQuote:!1,editQuote:!1,deleteQuote:!1,checkoutQuote:!1,viewQuoteTemplates:!1,manageQuoteTemplates:!1,generateQuoteFromTemplate:!1};if(e.all===!0)return{requestQuote:!0,editQuote:!0,deleteQuote:!0,checkoutQuote:!0,viewQuoteTemplates:!0,manageQuoteTemplates:!0,generateQuoteFromTemplate:!0};const a=e["Magento_NegotiableQuote::all"]===!0,t=e["Magento_NegotiableQuoteTemplate::all"]===!0,r=a||e["Magento_NegotiableQuote::manage"]===!0;return{requestQuote:r,editQuote:r,deleteQuote:r,checkoutQuote:a||e["Magento_NegotiableQuote::checkout"]===!0,viewQuoteTemplates:t||e["Magento_NegotiableQuoteTemplate::view_template"]===!0,manageQuoteTemplates:t||e["Magento_NegotiableQuoteTemplate::manage"]===!0,generateQuoteFromTemplate:t||e["Magento_NegotiableQuoteTemplate::generate_quote"]===!0}}function w(e){if(l.quoteDataLoaded)return;const a=v.config.getConfig(),{quoteId:t,quoteTemplateId:r}=a;!e.editQuote||!t&&!r||(l.quoteDataLoaded=!0,t&&ue(t).then(o=>{l.quoteDataInitialized||_.emit("quote-management/quote-data/initialized",{quote:o,permissions:e}),l.quoteDataInitialized=!0}).catch(o=>{l.quoteDataLoaded=!1,_.emit("quote-management/quote-data/error",{error:o})}),r&&Ae(r).catch(o=>{l.quoteDataLoaded=!1,_.emit("quote-management/quote-template-data/error",{error:o})}))}const v=new $({init:async e=>{const a={};v.config.setConfig({...a,...e}),await Ee().then(t=>{l.config=t}).catch(t=>{console.error("Failed to fetch store config: ",t),l.config=A}),l.initialized=!0,_.emit("quote-management/initialized",{config:l.config})},listeners:()=>[_.on("authenticated",async e=>{l.authenticated=!!e,e||(l.permissions=b,l.quoteDataLoaded=!1,_.emit("quote-management/permissions",b))},{eager:!0}),_.on("auth/permissions",async e=>{const a=R(e);l.permissions=a,l.quoteDataLoaded=!1,_.emit("quote-management/permissions",l.permissions)},{eager:!0}),_.on("quote-management/permissions",async e=>{l.initialized&&w(e)},{eager:!0}),_.on("quote-management/initialized",async()=>{w(l.permissions)},{eager:!0}),_.on("checkout/updated",async e=>{l.initialized&&(e==null?void 0:e.type)==="quote"&&(l.quoteDataLoaded=!1,w(l.permissions))},{eager:!0})]}),Ye=v.config,{setEndpoint:Ke,setFetchGraphQlHeader:Je,removeFetchGraphQlHeader:Ze,setFetchGraphQlHeaders:et,fetchGraphQl:p,getConfig:tt}=new F().getMethods(),G=`
4
+ fragment SELECTED_SHIPPING_METHOD_FRAGMENT on SelectedShippingMethod {
5
+ amount {
6
+ currency
7
+ value
8
+ }
9
+ carrier_code
10
+ carrier_title
11
+ method_code
12
+ method_title
13
+ price_excl_tax {
14
+ value
15
+ currency
16
+ }
17
+ price_incl_tax {
18
+ value
19
+ currency
20
+ }
21
+ }
22
+ `,z=`
23
+ fragment NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_FRAGMENT on NegotiableQuoteShippingAddress {
24
+ uid
25
+ firstname
26
+ lastname
27
+ company
28
+ street
29
+ city
30
+ region {
31
+ code
32
+ label
33
+ region_id
34
+ }
35
+ postcode
36
+ country {
37
+ code
38
+ label
39
+ }
40
+ telephone
41
+
42
+ selected_shipping_method {
43
+ ...SELECTED_SHIPPING_METHOD_FRAGMENT
44
+ }
45
+ }
46
+
47
+ ${G}
48
+ `,I=`
49
+ fragment NegotiableQuoteFragment on NegotiableQuote {
50
+ uid
51
+ name
52
+ created_at
53
+ is_virtual
54
+ status
55
+ sales_rep_name
56
+ expiration_date
57
+ updated_at
58
+ buyer {
59
+ firstname
60
+ lastname
61
+ }
62
+ email
63
+ comments {
64
+ uid
65
+ created_at
66
+ author {
67
+ firstname
68
+ lastname
69
+ }
70
+ text
71
+ attachments {
72
+ name
73
+ url
74
+ }
75
+ }
76
+ template_id
77
+ template_name
78
+ total_quantity
79
+ items {
80
+ __typename
81
+ uid
82
+ product {
83
+ name
84
+ sku
85
+ uid
86
+ stock_status
87
+ quantity
88
+ thumbnail {
89
+ label
90
+ url
91
+ }
92
+ price_range {
93
+ minimum_price {
94
+ regular_price {
95
+ value
96
+ currency
97
+ }
98
+ final_price {
99
+ value
100
+ currency
101
+ }
102
+ discount {
103
+ percent_off
104
+ amount_off
105
+ }
106
+ }
107
+ maximum_price {
108
+ regular_price {
109
+ value
110
+ currency
111
+ }
112
+ final_price {
113
+ value
114
+ currency
115
+ }
116
+ discount {
117
+ percent_off
118
+ amount_off
119
+ }
120
+ }
121
+ }
122
+ price_tiers {
123
+ quantity
124
+ final_price {
125
+ value
126
+ }
127
+ discount {
128
+ amount_off
129
+ percent_off
130
+ }
131
+ }
132
+ }
133
+ prices {
134
+ price {
135
+ currency
136
+ value
137
+ }
138
+ price_including_tax {
139
+ value
140
+ currency
141
+ }
142
+ original_item_price {
143
+ currency
144
+ value
145
+ }
146
+ original_row_total {
147
+ currency
148
+ value
149
+ }
150
+ row_total {
151
+ currency
152
+ value
153
+ }
154
+ row_total_including_tax {
155
+ value
156
+ currency
157
+ }
158
+ catalog_discount {
159
+ amount_off
160
+ percent_off
161
+ }
162
+ row_catalog_discount {
163
+ amount_off
164
+ percent_off
165
+ }
166
+ discounts {
167
+ label
168
+ value
169
+ amount {
170
+ currency
171
+ value
172
+ }
173
+ }
174
+ }
175
+ quantity
176
+ is_available
177
+ note_from_buyer {
178
+ created_at
179
+ creator_id
180
+ creator_type
181
+ negotiable_quote_item_uid
182
+ note
183
+ note_uid
184
+ __typename
185
+ }
186
+ note_from_seller {
187
+ created_at
188
+ creator_id
189
+ creator_type
190
+ negotiable_quote_item_uid
191
+ note
192
+ note_uid
193
+ __typename
194
+ }
195
+ ... on SimpleCartItem {
196
+ customizable_options {
197
+ type
198
+ label
199
+ values {
200
+ label
201
+ value
202
+ }
203
+ }
204
+ }
205
+ ... on ConfigurableCartItem {
206
+ configurable_options {
207
+ option_label
208
+ value_label
209
+ }
210
+ configured_variant {
211
+ uid
212
+ sku
213
+ stock_status
214
+ thumbnail {
215
+ label
216
+ url
217
+ }
218
+ price_range {
219
+ minimum_price {
220
+ regular_price {
221
+ value
222
+ currency
223
+ }
224
+ final_price {
225
+ value
226
+ currency
227
+ }
228
+ discount {
229
+ percent_off
230
+ amount_off
231
+ }
232
+ }
233
+ maximum_price {
234
+ regular_price {
235
+ value
236
+ currency
237
+ }
238
+ final_price {
239
+ value
240
+ currency
241
+ }
242
+ discount {
243
+ percent_off
244
+ amount_off
245
+ }
246
+ }
247
+ }
248
+ price_tiers {
249
+ quantity
250
+ final_price {
251
+ value
252
+ }
253
+ discount {
254
+ amount_off
255
+ percent_off
256
+ }
257
+ }
258
+ }
259
+ customizable_options {
260
+ type
261
+ label
262
+ values {
263
+ label
264
+ value
265
+ }
266
+ }
267
+ }
268
+ ... on BundleCartItem {
269
+ bundle_options {
270
+ label
271
+ values {
272
+ label
273
+ quantity
274
+ original_price {
275
+ currency
276
+ value
277
+ }
278
+ priceV2 {
279
+ currency
280
+ value
281
+ }
282
+ }
283
+ }
284
+ }
285
+ ... on DownloadableCartItem {
286
+ links {
287
+ sort_order
288
+ title
289
+ }
290
+ customizable_options {
291
+ type
292
+ label
293
+ values {
294
+ label
295
+ value
296
+ }
297
+ }
298
+ }
299
+ }
300
+ history {
301
+ uid
302
+ created_at
303
+ author {
304
+ firstname
305
+ lastname
306
+ }
307
+ change_type
308
+ changes {
309
+ comment_added {
310
+ comment
311
+ }
312
+ custom_changes {
313
+ new_value
314
+ old_value
315
+ title
316
+ }
317
+ statuses {
318
+ changes {
319
+ new_status
320
+ old_status
321
+ }
322
+ }
323
+ expiration {
324
+ new_expiration
325
+ old_expiration
326
+ }
327
+ total {
328
+ new_price {
329
+ currency
330
+ value
331
+ }
332
+ old_price {
333
+ currency
334
+ value
335
+ }
336
+ }
337
+ products_removed {
338
+ products_removed_from_catalog
339
+ products_removed_from_quote {
340
+ uid
341
+ name
342
+ sku
343
+ quantity
344
+ }
345
+ }
346
+ }
347
+ }
348
+ prices {
349
+ subtotal_with_discount_excluding_tax {
350
+ currency
351
+ value
352
+ }
353
+ subtotal_including_tax {
354
+ currency
355
+ value
356
+ }
357
+ subtotal_excluding_tax {
358
+ currency
359
+ value
360
+ }
361
+ grand_total {
362
+ currency
363
+ value
364
+ }
365
+ grand_total_excluding_tax {
366
+ currency
367
+ value
368
+ }
369
+ applied_taxes {
370
+ label
371
+ amount {
372
+ value
373
+ currency
374
+ }
375
+ }
376
+ discounts {
377
+ amount {
378
+ value
379
+ currency
380
+ }
381
+ label
382
+ coupon {
383
+ code
384
+ }
385
+ applied_to
386
+ }
387
+ }
388
+
389
+ shipping_addresses {
390
+ ...NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_FRAGMENT
391
+ }
392
+ }
393
+
394
+ ${z}
395
+ `,k=`
396
+ mutation REQUEST_NEGOTIABLE_QUOTE_MUTATION(
397
+ $cartId: ID!
398
+ $quoteName: String!
399
+ $comment: NegotiableQuoteCommentInput!
400
+ $isDraft: Boolean
401
+ ) {
402
+ requestNegotiableQuote(
403
+ input: {
404
+ cart_id: $cartId
405
+ quote_name: $quoteName
406
+ comment: $comment
407
+ is_draft: $isDraft
408
+ }
409
+ ) {
410
+ quote {
411
+ ...NegotiableQuoteFragment
412
+ }
413
+ }
414
+ }
415
+ ${I}
416
+ `;function B(e){if(!e)return A;const a=t=>[y.TAX_EXCLUDED,y.TAX_INCLUDED,y.TAX_INCLUDED_AND_EXCLUDED].includes(t)?t:y.TAX_EXCLUDED;return{quoteSummaryDisplayTotal:e.cart_summary_display_quantity,quoteSummaryMaxItems:e.max_items_in_order_summary,quoteDisplaySettings:{zeroTax:e.shopping_cart_display_zero_tax,subtotal:a(e.shopping_cart_display_subtotal),price:a(e.shopping_cart_display_price),shipping:a(e.shopping_cart_display_shipping),fullSummary:e.shopping_cart_display_full_summary,grandTotal:e.shopping_cart_display_grand_total},useConfigurableParentThumbnail:e.configurable_thumbnail_source==="parent",quoteMinimumAmount:e.quote_minimum_amount??null,quoteMinimumAmountMessage:e.quote_minimum_amount_message??null}}function j(e){var a,t,r,o,n,c,d;return{uid:e.uid,createdAt:e.created_at,author:{firstname:e.author.firstname,lastname:e.author.lastname},changeType:e.change_type,changes:{commentAdded:((a=e.changes)==null?void 0:a.comment_added)&&{comment:e.changes.comment_added.comment},customChanges:((t=e.changes)==null?void 0:t.custom_changes)&&{new_value:e.changes.custom_changes.new_value,old_value:e.changes.custom_changes.old_value,title:e.changes.custom_changes.title},expiration:((r=e.changes)==null?void 0:r.expiration)&&{newExpiration:e.changes.expiration.new_expiration,oldExpiration:e.changes.expiration.old_expiration},productsRemoved:((o=e.changes)==null?void 0:o.products_removed)&&{productsRemovedFromCatalog:e.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:e.changes.products_removed.products_removed_from_quote||[]},statuses:((n=e.changes)==null?void 0:n.statuses)&&{changes:((c=e.changes.statuses.changes)==null?void 0:c.map(u=>({newStatus:u==null?void 0:u.new_status,oldStatus:u==null?void 0:u.old_status})))||[]},total:((d=e.changes)==null?void 0:d.total)&&e.changes.total.new_price&&e.changes.total.old_price&&{newPrice:{value:e.changes.total.new_price.value,currency:e.changes.total.new_price.currency},oldPrice:{value:e.changes.total.old_price.value,currency:e.changes.total.old_price.currency}}}}}function q(e){if(e)return e.map(j)}function D(e,a){return e!=null&&e.length&&[...e].sort((r,o)=>o.quantity-r.quantity).find(r=>a>=r.quantity)||null}function X(e){var t,r,o,n;const a=l.config;return{src:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.url:((r=(t=e.configured_variant)==null?void 0:t.thumbnail)==null?void 0:r.url)||e.product.thumbnail.url,alt:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.label:((n=(o=e.configured_variant)==null?void 0:o.thumbnail)==null?void 0:n.label)||e.product.thumbnail.label}}function V(e){var a;return((a=e.links)==null?void 0:a.length)>0?{count:e.links.length,result:e.links.map(t=>t.title).join(", ")}:null}function H(e){var c,d,u,i;const a=e.quantity,t=e.__typename==="ConfigurableCartItem",r=t?(c=e.configured_variant)==null?void 0:c.price_tiers:e.product.price_tiers,o=t?(d=e.configured_variant)==null?void 0:d.price_range:e.product.price_range,n=D(r,a);return n?n.discount.amount_off>0:(((i=(u=o==null?void 0:o.maximum_price)==null?void 0:u.discount)==null?void 0:i.amount_off)??0)>0}function W(e){var o,n,c,d,u,i,s,m;const a=e.quantity,t=D(e.product.price_tiers,a);if(t)return Math.round(t.discount.percent_off);let r;if(e.__typename==="ConfigurableCartItem")r=(d=(c=(n=(o=e==null?void 0:e.configured_variant)==null?void 0:o.price_range)==null?void 0:n.maximum_price)==null?void 0:c.discount)==null?void 0:d.percent_off;else{if(e.__typename==="BundleCartItem")return;r=(m=(s=(i=(u=e==null?void 0:e.product)==null?void 0:u.price_range)==null?void 0:i.maximum_price)==null?void 0:s.discount)==null?void 0:m.percent_off}if(r!==0)return Math.round(r)}function Y(e){var a,t,r,o;return e.__typename==="ConfigurableCartItem"?{value:(t=(a=e.configured_variant)==null?void 0:a.price_range)==null?void 0:t.maximum_price.regular_price.value,currency:(o=(r=e.configured_variant)==null?void 0:r.price_range)==null?void 0:o.maximum_price.regular_price.currency}:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency}}function K(e){var r,o,n,c,d,u;let a,t;if(a=((o=(r=e==null?void 0:e.prices)==null?void 0:r.original_row_total)==null?void 0:o.value)-((c=(n=e==null?void 0:e.prices)==null?void 0:n.row_total)==null?void 0:c.value),t=(u=(d=e==null?void 0:e.prices)==null?void 0:d.row_total)==null?void 0:u.currency,a!==0)return{value:a,currency:t}}function J(e){var a,t,r,o,n,c,d,u;return{itemType:e.__typename,uid:e.uid,product:{uid:e.product.uid,sku:e.product.sku,name:e.product.name,priceRange:{maximumPrice:{regularPrice:{value:e.product.price_range.maximum_price.regular_price.value,currency:e.product.price_range.maximum_price.regular_price.currency}}}},image:X(e),links:V(e),discounted:H(e),discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},catalogDiscount:{amountOff:e.prices.catalog_discount.amount_off,percentOff:e.prices.catalog_discount.percent_off},rowCatalogDiscount:{amountOff:e.prices.row_catalog_discount.amount_off,percentOff:e.prices.row_catalog_discount.percent_off},discounts:((t=(a=e.prices)==null?void 0:a.discounts)==null?void 0:t.map(i=>({label:i.label,value:i.value,amount:{value:i.amount.value,currency:i.amount.currency}})))??[],discountPercentage:W(e),insufficientQuantity:(e.__typename==="ConfigurableCartItem"?((r=e.configured_variant)==null?void 0:r.stock_status)??e.product.stock_status:e.product.stock_status)==="IN_STOCK"&&!e.is_available,outOfStock:e.product.stock_status==="OUT_OF_STOCK",stockStatus:e.product.stock_status,quantity:e.quantity,prices:{regularPrice:Y(e),priceIncludingTax:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},originalItemPrice:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency},originalRowTotal:{value:e.prices.original_row_total.value,currency:e.prices.original_row_total.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency}},savingsAmount:K(e),noteFromBuyer:(o=e.note_from_buyer)==null?void 0:o.map(i=>({createdAt:i.created_at,creatorId:i.creator_id,creatorType:i.creator_type,negotiableQuoteItemUid:i.negotiable_quote_item_uid,note:i.note,noteUid:i.note_uid})),noteFromSeller:(n=e.note_from_seller)==null?void 0:n.map(i=>({createdAt:i.created_at,creatorId:i.creator_id,creatorType:i.creator_type,negotiableQuoteItemUid:i.negotiable_quote_item_uid,note:i.note,noteUid:i.note_uid})),configurableOptions:(c=e.configurable_options)==null?void 0:c.map(i=>({optionLabel:i.option_label,valueLabel:i.value_label})),bundleOptions:(d=e.bundle_options)==null?void 0:d.map(i=>({label:i.label,values:i.values.map(s=>({label:s.label,quantity:s.quantity,originalPrice:{value:s.original_price.value,currency:s.original_price.currency},price:{value:s.priceV2.value,currency:s.priceV2.currency}}))})),customizableOptions:(u=e.customizable_options)==null?void 0:u.map(i=>({type:i.type,label:i.label,values:i.values.map(s=>({label:s.label,value:s.value}))}))}}function O(e){return e?e.map(J):[]}const Q=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function Z(e){if(!e.items)return 0;const a=l.config;return(a==null?void 0:a.quoteSummaryDisplayTotal)===0?e.items.length:(a==null?void 0:a.quoteSummaryDisplayTotal)===1?e.total_quantity:e.items.length}function ee(e){return e.every(a=>!a.outOfStock&&!a.insufficientQuantity)}function te(e){var o,n,c,d,u,i;const a=P(e),t=!!((o=e.template_name)!=null&&o.trim()),r=O(e.items);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:a?N.NEW:e.status,isVirtual:!!e.is_virtual,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},email:e.email,templateName:e.template_name,totalQuantity:Z(e),comments:(n=e.comments)==null?void 0:n.map(s=>{const m={uid:s.uid,createdAt:s.created_at,author:{firstname:s.author.firstname,lastname:s.author.lastname},text:s.text};return Array.isArray(s.attachments)&&s.attachments.length>0&&(m.attachments=s.attachments.map(E=>({name:E.name,url:E.url}))),m}),prices:e.prices&&{appliedDiscounts:(c=e.prices.discounts)==null?void 0:c.map(s=>({amount:{value:s.amount.value,currency:s.amount.currency},label:s.label,coupon:s.coupon})),appliedTaxes:(d=e.prices.applied_taxes)==null?void 0:d.map(s=>({amount:{value:s.amount.value,currency:s.amount.currency},label:s.label})),discount:e.prices.discounts&&e.prices.grand_total&&U(e.prices.discounts,e.prices.grand_total.currency),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency},grandTotalExcludingTax:e.prices.grand_total_excluding_tax&&{value:e.prices.grand_total_excluding_tax.value,currency:e.prices.grand_total_excluding_tax.currency},subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},...oe(e),totalTax:e.prices.applied_taxes&&e.prices.grand_total&&U(e.prices.applied_taxes,e.prices.grand_total.currency)},history:q(e.history),items:r,shippingAddresses:(u=e.shipping_addresses)==null?void 0:u.map(s=>{const m={uid:s.uid,firstname:s.firstname,lastname:s.lastname,company:s.company,street:s.street,city:s.city,postcode:s.postcode,country:{code:s.country.code,label:s.country.label},telephone:s.telephone};return s.region&&(m.region={code:s.region.code,label:s.region.label,regionId:s.region.region_id}),m}),canCheckout:["UPDATED","DECLINED"].includes(e.status)&&l.permissions.checkoutQuote&&((i=e.shipping_addresses)==null?void 0:i.length)>0&&ee(r),canSendForReview:!t&&(a||Q.includes(e.status))&&l.permissions.editQuote,canUpdateQuote:!t&&(a||Q.includes(e.status))&&l.permissions.editQuote,canDelete:!t&&!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&l.permissions.deleteQuote,canClose:e.status?!t&&!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1,readOnly:t||!a&&["ORDERED","SUBMITTED","CLOSED","PENDING"].includes(e.status)||!l.permissions.editQuote}}function h(e){return e?te(e):null}function P(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(a=>{var t,r;return a.change_type==="UPDATED"&&(((r=(t=a.changes)==null?void 0:t.statuses)==null?void 0:r.changes)??[]).length>0})}function re(e){const a=P(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:a?N.NEW:e.status,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,prices:{grandTotal:{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}}}}function ae(e){var r;if(!e)return null;const a={items:((r=e.items)==null?void 0:r.filter(o=>o==null?void 0:o.uid).map(re))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0},t=x(a);return{...a,paginationInfo:t||void 0}}function x(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:a,pageSize:t,totalPages:r}=e.pageInfo,{totalCount:o}=e,n=o>0?(a-1)*t+1:0,c=Math.min(a*t,o);return{currentPage:a,totalCount:o,pageSize:t,startItem:n,endItem:c,totalPages:r,pageSizeOptions:[20,30,50,100,200]}}const rt=()=>[20,30,50,100,200];function U(e,a){return e!=null&&e.length?e.reduce((t,r)=>({value:t.value+r.amount.value,currency:r.amount.currency}),{value:0,currency:a}):{value:0,currency:a}}function oe(e){var r;if(!e||!((r=e.shipping_addresses)!=null&&r.length))return{};const t=e.shipping_addresses[0].selected_shipping_method;return t?{shippingIncludingTax:t.price_incl_tax&&{value:t.price_incl_tax.value,currency:t.price_incl_tax.currency},shippingExcludingTax:t.price_excl_tax&&{value:t.price_excl_tax.value,currency:t.price_excl_tax.currency}}:{}}function f(e){var a,t,r,o;return e?{id:e.template_id,uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:e.status,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},comments:(a=e.comments)==null?void 0:a.map(n=>{var c;return{uid:n.uid,createdAt:n.created_at,author:{firstname:n.author.firstname,lastname:n.author.lastname},text:n.text,attachments:(c=n.attachments)==null?void 0:c.map(d=>({name:d.name,url:d.url}))}}),prices:e.prices&&{subtotalExcludingTax:e.prices.subtotal_excluding_tax&&{value:e.prices.subtotal_excluding_tax.value,currency:e.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:e.prices.subtotal_including_tax&&{value:e.prices.subtotal_including_tax.value,currency:e.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:e.prices.subtotal_with_discount_excluding_tax&&{value:e.prices.subtotal_with_discount_excluding_tax.value,currency:e.prices.subtotal_with_discount_excluding_tax.currency},appliedTaxes:(t=e.prices.applied_taxes)==null?void 0:t.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})),grandTotal:e.prices.grand_total&&{value:e.prices.grand_total.value,currency:e.prices.grand_total.currency}},history:q(e.history),items:O(e.items),shippingAddresses:(r=e.shipping_addresses)==null?void 0:r.map(n=>({uid:n.uid,firstname:n.firstname,lastname:n.lastname,company:n.company,street:n.street,city:n.city,postcode:n.postcode,country:{code:n.country.code,label:n.country.label},telephone:n.telephone,region:n.region?{code:n.region.code,label:n.region.label,regionId:n.region.region_id}:void 0})),referenceDocuments:(o=e.reference_document_links)==null?void 0:o.map(n=>({uid:n.link_id,name:n.document_name,identifier:n.document_identifier,url:n.reference_document_url})),canAccept:[g.SUBMITTED,g.PENDING,g.OPEN].includes(e.status),canDelete:e.status===g.DRAFT,canReopen:[g.DECLINED,g.CANCELED,g.EXPIRED].includes(e.status),canCancel:[g.SUBMITTED,g.PENDING,g.OPEN,g.ACTIVE,g.EDITED].includes(e.status),canSendForReview:[g.OPEN,g.DRAFT,g.NEW,g.EDITED].includes(e.status),canGenerateQuoteFromTemplate:[g.ACTIVE].includes(e.status),canEditTemplateItems:[g.SUBMITTED,g.DRAFT,g.OPEN,g.EDITED].includes(e.status)}:null}function ne(e){var r;if(!e)return null;const a={items:((r=e.items)==null?void 0:r.map(o=>{var n,c,d;return{id:o.template_id,uid:o.uid,name:o.name,createdAt:o.created_at,updatedAt:o.updated_at,status:o.status,state:o.state,prices:{grandTotal:(n=o.prices)!=null&&n.grand_total?{value:o.prices.grand_total.value,currency:o.prices.grand_total.currency}:{value:0,currency:"USD"},minNegotiatedGrandTotal:{value:o.min_negotiated_grand_total,currency:((d=(c=o.prices)==null?void 0:c.grand_total)==null?void 0:d.currency)||"USD"}},lastSharedAt:o.last_shared_at,lastOrderedAt:o.last_ordered_at,expirationDate:o.expiration_date,ordersPlaced:o.orders_placed,canGenerateQuoteFromTemplate:[g.ACTIVE].includes(o.status)}}))||[],pageInfo:{currentPage:e.page_info.current_page,pageSize:e.page_info.page_size,totalPages:e.page_info.total_pages},totalCount:e.total_count,sortFields:e.sort_fields?{default:e.sort_fields.default,options:e.sort_fields.options}:void 0},t=x(a);return{...a,paginationInfo:t||void 0}}const at=async e=>{const{cartId:a,quoteName:t,comment:r,attachments:o,isDraft:n}=e;if(!a)throw new Error("Cart ID is required");if(!t)throw new Error("Quote name is required");if(!r)throw new Error("Comment is required");return p(k,{variables:{cartId:a,quoteName:t,comment:o!=null&&o.length?{comment:r,attachments:o}:{comment:r},isDraft:n}}).then(c=>{var i,s;const{errors:d}=c;if(d){const m=d.map(E=>E.message).join("; ");throw new Error(`Failed to request negotiable quote: ${m}`)}const u=h((s=(i=c.data)==null?void 0:i.requestNegotiableQuote)==null?void 0:s.quote);if(!u)throw new Error("Failed to transform quote data: Invalid response structure");return _.emit("quote-management/negotiable-quote-requested",{quote:u,input:{cartId:a,quoteName:t,comment:r,attachments:o,isDraft:n}}),u})},ie=`
417
+ query QUOTE_DATA_QUERY(
418
+ $quoteId: ID!
419
+ ) {
420
+ negotiableQuote(
421
+ uid: $quoteId
422
+ ) {
423
+ ...NegotiableQuoteFragment
424
+ }
425
+ }
426
+
427
+ ${I}
428
+ `,ue=async e=>{var a;if(!l.authenticated)return Promise.reject(new Error("Unauthorized"));if(!l.permissions.editQuote)return Promise.reject(new Error("Unauthorized"));try{const t=await p(ie,{variables:{quoteId:e}}),r=h((a=t==null?void 0:t.data)==null?void 0:a.negotiableQuote);if(!r)throw new Error("Failed to transform quote data");return _.emit("quote-management/quote-data",{quote:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},se=`
429
+ fragment NegotiableQuoteListFragment on NegotiableQuote {
430
+ uid
431
+ name
432
+ created_at
433
+ updated_at
434
+ status
435
+ buyer {
436
+ firstname
437
+ lastname
438
+ }
439
+ template_name
440
+ prices {
441
+ grand_total {
442
+ value
443
+ currency
444
+ }
445
+ }
446
+ history {
447
+ change_type
448
+ changes {
449
+ statuses {
450
+ changes {
451
+ new_status
452
+ old_status
453
+ }
454
+ }
455
+ }
456
+ }
457
+ }
458
+ `,ce=`
459
+ fragment SearchResultPageInfoFragment on SearchResultPageInfo {
460
+ current_page
461
+ page_size
462
+ total_pages
463
+ }
464
+ `,le=`
465
+ fragment SortFieldsFragment on SortFields {
466
+ default
467
+ options {
468
+ label
469
+ value
470
+ }
471
+ }
472
+ `,de=`
473
+ query negotiableQuotes(
474
+ $filter: NegotiableQuoteFilterInput
475
+ $pageSize: Int
476
+ $currentPage: Int
477
+ $sort: NegotiableQuoteSortInput
478
+ ) {
479
+ negotiableQuotes(
480
+ filter: $filter
481
+ pageSize: $pageSize
482
+ currentPage: $currentPage
483
+ sort: $sort
484
+ ) {
485
+ items {
486
+ ...NegotiableQuoteListFragment
487
+ }
488
+ page_info {
489
+ ...SearchResultPageInfoFragment
490
+ }
491
+ sort_fields {
492
+ ...SortFieldsFragment
493
+ }
494
+ total_count
495
+ }
496
+ }
497
+
498
+ ${se}
499
+ ${ce}
500
+ ${le}
501
+ `;var _e=(e=>(e.FULL="FULL",e.PARTIAL="PARTIAL",e))(_e||{}),me=(e=>(e.ASC="ASC",e.DESC="DESC",e))(me||{}),pe=(e=>(e.QUOTE_NAME="QUOTE_NAME",e.CREATED_AT="CREATED_AT",e.UPDATED_AT="UPDATED_AT",e))(pe||{});const ot=async(e={})=>{var t;if(!l.authenticated)return Promise.reject(new Error("Unauthorized"));const a={filter:e.filter||null,pageSize:e.pageSize||20,currentPage:e.currentPage||1,sort:e.sort||null};try{const r=await p(de,{variables:a});if(!((t=r==null?void 0:r.data)!=null&&t.negotiableQuotes))throw new Error("No quotes data received");const o=ae(r.data.negotiableQuotes);if(!o)throw new Error("Failed to transform quotes data");return o}catch(r){return Promise.reject(r)}},ge=`
502
+ query STORE_CONFIG_QUERY {
503
+ storeConfig {
504
+ cart_summary_display_quantity
505
+ max_items_in_order_summary
506
+ shopping_cart_display_full_summary
507
+ shopping_cart_display_grand_total
508
+ shopping_cart_display_price
509
+ shopping_cart_display_shipping
510
+ shopping_cart_display_subtotal
511
+ shopping_cart_display_zero_tax
512
+ configurable_thumbnail_source
513
+ quote_minimum_amount
514
+ quote_minimum_amount_message
515
+ }
516
+ }
517
+ `,Ee=async()=>p(ge,{method:"GET",cache:"force-cache"}).then(({errors:e,data:a})=>{if(e){const t=e.map(r=>r.message).join(", ");throw new Error(`Failed to get store config: ${t}`)}return B(a.storeConfig)}),fe=`
518
+ mutation DELETE_QUOTE_MUTATION($quoteUids: [ID!]!) {
519
+ deleteNegotiableQuotes(
520
+ input: {
521
+ quote_uids: $quoteUids
522
+ }
523
+ ) {
524
+ result_status
525
+ operation_results {
526
+ __typename
527
+ ... on NegotiableQuoteUidOperationSuccess {
528
+ quote_uid
529
+ }
530
+ ... on DeleteNegotiableQuoteOperationFailure {
531
+ quote_uid
532
+ errors {
533
+ __typename
534
+ ... on ErrorInterface {
535
+ message
536
+ }
537
+ ... on NoSuchEntityUidError {
538
+ uid
539
+ message
540
+ }
541
+ ... on NegotiableQuoteInvalidStateError {
542
+ message
543
+ }
544
+ }
545
+ }
546
+ }
547
+ }
548
+ }
549
+ `,nt=async e=>{var t;if(!l.authenticated)return Promise.reject(new Error("Unauthorized"));const a=Array.isArray(e)?e:[e];try{const r=await p(fe,{variables:{quoteUids:a}}),{errors:o}=r||{};if(o&&o.length){const u=o.map(i=>i==null?void 0:i.message).filter(Boolean).join("; ");throw new Error(u||"Failed to delete negotiable quotes")}const n=(t=r==null?void 0:r.data)==null?void 0:t.deleteNegotiableQuotes;if(!n)throw new Error("No delete result returned");const c={resultStatus:n.result_status,operationResults:(n.operation_results||[]).map(u=>(u==null?void 0:u.__typename)==="NegotiableQuoteUidOperationSuccess"?{__typename:"NegotiableQuoteUidOperationSuccess",quoteUid:u==null?void 0:u.quote_uid}:{__typename:"DeleteNegotiableQuoteOperationFailure",quoteUid:u==null?void 0:u.quote_uid,errors:((u==null?void 0:u.errors)||[]).map(m=>({__typename:m==null?void 0:m.__typename,message:m==null?void 0:m.message,uid:m==null?void 0:m.uid}))})},d=c.operationResults.filter(u=>u.__typename==="NegotiableQuoteUidOperationSuccess").map(u=>u.quoteUid);return d.length>0&&_.emit("quote-management/negotiable-quote-deleted",{deletedQuoteUids:d,resultStatus:c.resultStatus}),c}catch(r){return _.emit("quote-management/negotiable-quote-delete-error",{error:r instanceof Error?r:new Error(String(r)),attemptedQuoteUids:a}),Promise.reject(r)}},Te=`
4
550
  mutation SET_NEGOTIABLE_QUOTE_SHIPPING_ADDRESS_MUTATION(
5
551
  $quoteUid: ID!
6
552
  $addressId: ID
@@ -20,8 +566,531 @@ import{r as G}from"./chunks/requestNegotiableQuote.js";import{g as $}from"./chun
20
566
  }
21
567
  }
22
568
  }
23
- ${A}
24
- `;function Q(e){const{additionalInput:r,...t}=e,s={city:t.city,company:t.company,country_code:t.countryCode,firstname:t.firstname,lastname:t.lastname,postcode:t.postcode,region:t.region,region_id:t.regionId,save_in_address_book:t.saveInAddressBook,street:t.street,telephone:t.telephone};return{...r||{},...s}}const x=async e=>{const{quoteUid:r,addressId:t,addressData:s}=e;if(!r)throw new Error("Quote UID is required");if(t===void 0&&!s)throw new Error("Either addressId or addressData must be provided");if(t!==void 0&&s)throw new Error("Cannot provide both addressId and addressData");const l=s?Q(s):null;return m(E,{variables:{quoteUid:r,addressId:t||null,addressData:l}}).then(o=>{var i,n;const{errors:a}=o;if(a){const g=a.map(h=>h.message).join("; ");throw new Error(`Failed to set shipping address: ${g}`)}const d=c((n=(i=o.data)==null?void 0:i.setNegotiableQuoteShippingAddress)==null?void 0:n.quote);if(!d)throw new Error("Failed to transform quote data: Invalid response structure");return u.emit("quote-management/shipping-address-set",{quote:d,input:{quoteUid:r,addressId:t,addressData:s}}),d})},I=`
569
+ ${I}
570
+ `;function Ie(e){const{additionalInput:a,...t}=e,r={city:t.city,company:t.company,country_code:t.countryCode,firstname:t.firstname,lastname:t.lastname,postcode:t.postcode,region:t.region,region_id:t.regionId,save_in_address_book:t.saveInAddressBook,street:t.street,telephone:t.telephone};return{...a||{},...r}}const it=async e=>{const{quoteUid:a,addressId:t,addressData:r}=e;if(!a)throw new Error("Quote UID is required");if(t===void 0&&!r)throw new Error("Either addressId or addressData must be provided");if(t!==void 0&&r)throw new Error("Cannot provide both addressId and addressData");const o=r?Ie(r):null;return p(Te,{variables:{quoteUid:a,addressId:t||null,addressData:o}}).then(n=>{var u,i;const{errors:c}=n;if(c){const s=c.map(m=>m.message).join("; ");throw new Error(`Failed to set shipping address: ${s}`)}const d=h((i=(u=n.data)==null?void 0:u.setNegotiableQuoteShippingAddress)==null?void 0:i.quote);if(!d)throw new Error("Failed to transform quote data: Invalid response structure");return _.emit("quote-management/shipping-address-set",{quote:d,input:{quoteUid:a,addressId:t,addressData:r}}),d})},he=`
571
+ mutation SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION(
572
+ $quoteUid: ID!
573
+ $comment: NegotiableQuoteCommentInput
574
+ ) {
575
+ sendNegotiableQuoteForReview(
576
+ input: {
577
+ quote_uid: $quoteUid
578
+ comment: $comment
579
+ }
580
+ ) {
581
+ quote {
582
+ ...NegotiableQuoteFragment
583
+ }
584
+ }
585
+ }
586
+ ${I}
587
+ `,ut=async e=>{const{quoteUid:a,comment:t,attachments:r}=e;if(!a)throw new Error("Quote UID is required");const o=r!=null&&r.length?{comment:t||"",attachments:r}:t?{comment:t}:null;return p(he,{variables:{quoteUid:a,comment:o}}).then(n=>{var u,i;const{errors:c}=n;if(c){const s=c.map(m=>m.message).join("; ");throw new Error(`Failed to send quote for review: ${s}`)}const d=h((i=(u=n.data)==null?void 0:u.sendNegotiableQuoteForReview)==null?void 0:i.quote);if(!d)throw new Error("Failed to transform quote data: Invalid response structure");return _.emit("quote-management/quote-sent-for-review",{quote:d,input:{quoteUid:a,comment:t,attachments:r}}),d})},ye=`
588
+ mutation INITIATE_UPLOAD_MUTATION($input: initiateUploadInput!) {
589
+ initiateUpload(input: $input) {
590
+ upload_url
591
+ key
592
+ expires_at
593
+ }
594
+ }
595
+ `,we=`
596
+ mutation FINISH_UPLOAD_MUTATION($input: finishUploadInput!) {
597
+ finishUpload(input: $input) {
598
+ success
599
+ key
600
+ message
601
+ }
602
+ }
603
+ `,st=async e=>{const a="NEGOTIABLE_QUOTE_ATTACHMENT";try{const t=e==null?void 0:e.name;if(!e||!t)throw new Error("Invalid file");const r=M=>M.map(L=>L.message).join("; "),{data:o,errors:n}=await p(ye,{variables:{input:{key:t,media_resource_type:a}}});if(n&&n.length)throw new Error(r(n));const{upload_url:c,key:d}=(o==null?void 0:o.initiateUpload)||{};if(!c||!d)throw new Error("Failed to initiate upload");const u=await fetch(c,{method:"PUT",body:e});if(!u.ok)throw new Error(`Upload failed: ${u.status} ${u.statusText}`);const{data:i,errors:s}=await p(we,{variables:{input:{key:d,media_resource_type:a}}});if(s&&s.length)throw new Error(r(s));const{success:m,key:E,message:S}=(i==null?void 0:i.finishUpload)||{};if(!m||!E)throw new Error(S||"Failed to finish upload");return{key:E}}catch(t){throw _.emit("quote-management/file-upload-error",{error:(t==null?void 0:t.message)||"File upload failed",fileName:e==null?void 0:e.name}),t instanceof Error?t:new Error("File upload failed")}},be=`
604
+ mutation CLOSE_NEGOTIABLE_QUOTE_MUTATION(
605
+ $quoteUids: [ID!]!
606
+ ) {
607
+ closeNegotiableQuotes(input: { quote_uids: $quoteUids }) {
608
+ result_status
609
+ operation_results {
610
+ ... on NegotiableQuoteUidOperationSuccess {
611
+ __typename
612
+ quote_uid
613
+ }
614
+ ... on CloseNegotiableQuoteOperationFailure {
615
+ __typename
616
+ quote_uid
617
+ errors {
618
+ __typename
619
+ ... on ErrorInterface {
620
+ message
621
+ }
622
+ ... on NoSuchEntityUidError {
623
+ uid
624
+ }
625
+ ... on NegotiableQuoteInvalidStateError {
626
+ message
627
+ }
628
+ }
629
+ }
630
+ }
631
+ }
632
+ }
633
+ `,ct=async e=>{var t;if(!l.authenticated)return Promise.reject(new Error("Unauthorized"));const{quoteUids:a}=e;if(!a||a.length===0)throw new Error("Quote UIDs are required");try{const r=await p(be,{variables:{quoteUids:a}}),{errors:o}=r||{};if(o&&o.length){const i=o.map(s=>s==null?void 0:s.message).filter(Boolean).join("; ");throw new Error(i||"Failed to close negotiable quotes")}const n=(t=r==null?void 0:r.data)==null?void 0:t.closeNegotiableQuotes;if(!n)throw new Error("No close result returned");const c={resultStatus:n.result_status,operationResults:(n.operation_results||[]).map(i=>(i==null?void 0:i.__typename)==="NegotiableQuoteUidOperationSuccess"?{__typename:"NegotiableQuoteUidOperationSuccess",quoteUid:i==null?void 0:i.quote_uid}:{__typename:"CloseNegotiableQuoteOperationFailure",quoteUid:i==null?void 0:i.quote_uid,errors:((i==null?void 0:i.errors)||[]).map(E=>({__typename:E==null?void 0:E.__typename,message:E==null?void 0:E.message,uid:E==null?void 0:E.uid}))})},d=c.operationResults.filter(i=>i.__typename==="CloseNegotiableQuoteOperationFailure").map(i=>i);if(d.length>0){const i=d.map(s=>s.errors&&s.errors.length>0?s.errors.map(m=>m.message||`Failed to close quote ${s.quoteUid}`).join(", "):`Failed to close quote ${s.quoteUid}`).join("; ");throw new Error(i)}const u=c.operationResults.filter(i=>i.__typename==="NegotiableQuoteUidOperationSuccess").map(i=>i.quoteUid);return u.length>0&&_.emit("quote-management/negotiable-quote-closed",{closedQuoteUids:u,resultStatus:c.resultStatus}),c}catch(r){return _.emit("quote-management/negotiable-quote-close-error",{error:r instanceof Error?r:new Error(String(r)),attemptedQuoteUids:a}),Promise.reject(r)}},T=`
634
+ fragment NegotiableQuoteTemplateFragment on NegotiableQuoteTemplate {
635
+ uid
636
+ template_id
637
+ name
638
+ created_at
639
+ updated_at
640
+ status
641
+ sales_rep_name
642
+ expiration_date
643
+ buyer {
644
+ firstname
645
+ lastname
646
+ }
647
+ comments {
648
+ uid
649
+ created_at
650
+ author {
651
+ firstname
652
+ lastname
653
+ }
654
+ text
655
+ attachments {
656
+ name
657
+ url
658
+ }
659
+ }
660
+ items {
661
+ __typename
662
+ uid
663
+ product {
664
+ name
665
+ sku
666
+ uid
667
+ stock_status
668
+ quantity
669
+ thumbnail {
670
+ label
671
+ url
672
+ }
673
+ price_range {
674
+ minimum_price {
675
+ regular_price {
676
+ value
677
+ currency
678
+ }
679
+ final_price {
680
+ value
681
+ currency
682
+ }
683
+ discount {
684
+ percent_off
685
+ amount_off
686
+ }
687
+ }
688
+ maximum_price {
689
+ regular_price {
690
+ value
691
+ currency
692
+ }
693
+ final_price {
694
+ value
695
+ currency
696
+ }
697
+ discount {
698
+ percent_off
699
+ amount_off
700
+ }
701
+ }
702
+ }
703
+ price_tiers {
704
+ quantity
705
+ final_price {
706
+ value
707
+ }
708
+ discount {
709
+ amount_off
710
+ percent_off
711
+ }
712
+ }
713
+ }
714
+ prices {
715
+ price {
716
+ currency
717
+ value
718
+ }
719
+ price_including_tax {
720
+ value
721
+ currency
722
+ }
723
+ original_item_price {
724
+ currency
725
+ value
726
+ }
727
+ original_row_total {
728
+ currency
729
+ value
730
+ }
731
+ row_total {
732
+ currency
733
+ value
734
+ }
735
+ row_total_including_tax {
736
+ value
737
+ currency
738
+ }
739
+ catalog_discount {
740
+ amount_off
741
+ percent_off
742
+ }
743
+ row_catalog_discount {
744
+ amount_off
745
+ percent_off
746
+ }
747
+ discounts {
748
+ label
749
+ value
750
+ amount {
751
+ currency
752
+ value
753
+ }
754
+ }
755
+ }
756
+ quantity
757
+ is_available
758
+ note_from_buyer {
759
+ created_at
760
+ creator_id
761
+ creator_type
762
+ negotiable_quote_item_uid
763
+ note
764
+ note_uid
765
+ __typename
766
+ }
767
+ note_from_seller {
768
+ created_at
769
+ creator_id
770
+ creator_type
771
+ negotiable_quote_item_uid
772
+ note
773
+ note_uid
774
+ __typename
775
+ }
776
+ ... on SimpleCartItem {
777
+ customizable_options {
778
+ type
779
+ label
780
+ values {
781
+ label
782
+ value
783
+ }
784
+ }
785
+ }
786
+ ... on ConfigurableCartItem {
787
+ configurable_options {
788
+ option_label
789
+ value_label
790
+ }
791
+ configured_variant {
792
+ uid
793
+ sku
794
+ stock_status
795
+ thumbnail {
796
+ label
797
+ url
798
+ }
799
+ price_range {
800
+ minimum_price {
801
+ regular_price {
802
+ value
803
+ currency
804
+ }
805
+ final_price {
806
+ value
807
+ currency
808
+ }
809
+ discount {
810
+ percent_off
811
+ amount_off
812
+ }
813
+ }
814
+ maximum_price {
815
+ regular_price {
816
+ value
817
+ currency
818
+ }
819
+ final_price {
820
+ value
821
+ currency
822
+ }
823
+ discount {
824
+ percent_off
825
+ amount_off
826
+ }
827
+ }
828
+ }
829
+ price_tiers {
830
+ quantity
831
+ final_price {
832
+ value
833
+ }
834
+ discount {
835
+ amount_off
836
+ percent_off
837
+ }
838
+ }
839
+ }
840
+ customizable_options {
841
+ type
842
+ label
843
+ values {
844
+ label
845
+ value
846
+ }
847
+ }
848
+ }
849
+ ... on BundleCartItem {
850
+ bundle_options {
851
+ label
852
+ values {
853
+ label
854
+ quantity
855
+ original_price {
856
+ currency
857
+ value
858
+ }
859
+ priceV2 {
860
+ currency
861
+ value
862
+ }
863
+ }
864
+ }
865
+ }
866
+ ... on DownloadableCartItem {
867
+ links {
868
+ sort_order
869
+ title
870
+ }
871
+ customizable_options {
872
+ type
873
+ label
874
+ values {
875
+ label
876
+ value
877
+ }
878
+ }
879
+ }
880
+ }
881
+ history {
882
+ uid
883
+ created_at
884
+ author {
885
+ firstname
886
+ lastname
887
+ }
888
+ change_type
889
+ changes {
890
+ comment_added {
891
+ comment
892
+ }
893
+ custom_changes {
894
+ new_value
895
+ old_value
896
+ title
897
+ }
898
+ statuses {
899
+ changes {
900
+ new_status
901
+ old_status
902
+ }
903
+ }
904
+ expiration {
905
+ new_expiration
906
+ old_expiration
907
+ }
908
+ total {
909
+ new_price {
910
+ currency
911
+ value
912
+ }
913
+ old_price {
914
+ currency
915
+ value
916
+ }
917
+ }
918
+ }
919
+ }
920
+ prices {
921
+ subtotal_excluding_tax {
922
+ currency
923
+ value
924
+ }
925
+ subtotal_including_tax {
926
+ currency
927
+ value
928
+ }
929
+ subtotal_with_discount_excluding_tax {
930
+ currency
931
+ value
932
+ }
933
+ applied_taxes {
934
+ amount {
935
+ currency
936
+ value
937
+ }
938
+ label
939
+ }
940
+ grand_total {
941
+ currency
942
+ value
943
+ }
944
+ }
945
+ shipping_addresses {
946
+ uid
947
+ firstname
948
+ lastname
949
+ company
950
+ street
951
+ city
952
+ region {
953
+ code
954
+ label
955
+ region_id
956
+ }
957
+ postcode
958
+ country {
959
+ code
960
+ label
961
+ }
962
+ telephone
963
+ }
964
+ reference_document_links {
965
+ link_id
966
+ document_name
967
+ document_identifier
968
+ reference_document_url
969
+ }
970
+ }
971
+ `,Ne=`
972
+ query QUOTE_TEMPLATE_DATA_QUERY($templateId: ID!) {
973
+ negotiableQuoteTemplate(templateId: $templateId) {
974
+ ...NegotiableQuoteTemplateFragment
975
+ }
976
+ }
977
+
978
+ ${T}
979
+ `,Ae=async e=>{var a;if(!l.authenticated)throw new Error("Unauthorized");if(!e)throw new Error("Template ID is required");try{const t=await p(Ne,{variables:{templateId:e}});if(!((a=t==null?void 0:t.data)!=null&&a.negotiableQuoteTemplate))throw new Error("Quote template not found");const r=f(t.data.negotiableQuoteTemplate);if(!r)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},ve=`
980
+ mutation CREATE_QUOTE_TEMPLATE_MUTATION($cartId: ID!) {
981
+ requestNegotiableQuoteTemplateFromQuote(input: { cart_id: $cartId }) {
982
+ ...NegotiableQuoteTemplateFragment
983
+ }
984
+ }
985
+
986
+ ${T}
987
+ `,lt=async e=>{var a;if(!l.authenticated)throw new Error("Unauthorized");if(!e)throw new Error("Cart ID is required");try{const t=await p(ve,{variables:{cartId:e}});if(!((a=t==null?void 0:t.data)!=null&&a.requestNegotiableQuoteTemplateFromQuote))throw new Error("Failed to create quote template");const r=f(t.data.requestNegotiableQuoteTemplateFromQuote);if(!r)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},Qe=`
988
+ query QUOTE_TEMPLATES_QUERY(
989
+ $filter: NegotiableQuoteTemplateFilterInput
990
+ $pageSize: Int
991
+ $currentPage: Int
992
+ $sort: NegotiableQuoteTemplateSortInput
993
+ ) {
994
+ negotiableQuoteTemplates(
995
+ filter: $filter
996
+ pageSize: $pageSize
997
+ currentPage: $currentPage
998
+ sort: $sort
999
+ ) {
1000
+ items {
1001
+ uid
1002
+ template_id
1003
+ name
1004
+ created_at
1005
+ updated_at
1006
+ last_ordered_at
1007
+ status
1008
+ state
1009
+ min_negotiated_grand_total
1010
+ last_shared_at
1011
+ expiration_date
1012
+ orders_placed
1013
+ prices {
1014
+ grand_total {
1015
+ currency
1016
+ value
1017
+ }
1018
+ }
1019
+ }
1020
+ page_info {
1021
+ current_page
1022
+ page_size
1023
+ total_pages
1024
+ }
1025
+ total_count
1026
+ sort_fields {
1027
+ default
1028
+ options {
1029
+ label
1030
+ value
1031
+ }
1032
+ }
1033
+ }
1034
+ }
1035
+ `;var Ue=(e=>(e.ACTIVE="ACTIVE",e.IN_REVIEW="IN_REVIEW",e.INACTIVE="INACTIVE",e))(Ue||{}),qe=(e=>(e.NAME="NAME",e.CREATED_AT="CREATED_AT",e.UPDATED_AT="UPDATED_AT",e))(qe||{}),De=(e=>(e.ASC="ASC",e.DESC="DESC",e))(De||{});const dt=async(e={})=>{var a;if(!l.authenticated)throw new Error("Unauthorized");try{const t=await p(Qe,{variables:{filter:e.filter||null,pageSize:e.pageSize||20,currentPage:e.currentPage||1,sort:e.sort||null}});if(!((a=t==null?void 0:t.data)!=null&&a.negotiableQuoteTemplates))throw new Error("No quote templates data received");const r=ne(t.data.negotiableQuoteTemplates);if(!r)throw new Error("Failed to transform quote templates data");return _.emit("quote-management/quote-templates-data",{quoteTemplates:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},Oe=`
1036
+ mutation SEND_QUOTE_TEMPLATE_FOR_REVIEW_MUTATION(
1037
+ $templateId: ID!
1038
+ $comment: String
1039
+ $name: String
1040
+ $referenceDocumentLinks: [NegotiableQuoteTemplateReferenceDocumentLinkInput]
1041
+ $attachments: [NegotiableQuoteCommentAttachmentInput]
1042
+ ) {
1043
+ submitNegotiableQuoteTemplateForReview(input: { template_id: $templateId, name: $name, comment: $comment, reference_document_links: $referenceDocumentLinks, attachments: $attachments }) {
1044
+ ...NegotiableQuoteTemplateFragment
1045
+ }
1046
+ }
1047
+ ${T}
1048
+ `,_t=async e=>{var a,t,r;if(!e.templateId)throw new Error("Template ID is required");if(!l.authenticated)throw new Error("Unauthorized");try{const o=(a=e.referenceDocumentLinks)==null?void 0:a.map(u=>({link_id:u.uid,document_name:u.name,document_identifier:u.identifier,reference_document_url:u.url})),n=(t=e.attachments)!=null&&t.length?e.attachments.map(u=>({key:u.key})):void 0,c=await p(Oe,{variables:{templateId:e.templateId,name:e.name,comment:e.comment||void 0,referenceDocumentLinks:o,attachments:n}});if(!((r=c==null?void 0:c.data)!=null&&r.submitNegotiableQuoteTemplateForReview))throw new Error("No quote template data received");const d=f(c.data.submitNegotiableQuoteTemplateForReview);if(!d)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:d,permissions:l.permissions}),d}catch(o){return Promise.reject(o)}},Pe=`
1049
+ mutation SET_QUOTE_TEMPLATE_EXPIRATION_DATE_MUTATION(
1050
+ $templateId: ID!
1051
+ $expirationDate: String!
1052
+ ) {
1053
+ setQuoteTemplateExpirationDate(input: { template_id: $templateId, expiration_date: $expirationDate }) {
1054
+ ...NegotiableQuoteTemplateFragment
1055
+ }
1056
+ }
1057
+ ${T}
1058
+ `,mt=async e=>{var a;if(!l.authenticated)throw new Error("Unauthorized");if(!e.templateId)throw new Error("Template ID is required");if(!e.expirationDate)throw new Error("Expiration date is required");try{const t=await p(Pe,{variables:{templateId:e.templateId,expirationDate:e.expirationDate}});if(!((a=t==null?void 0:t.data)!=null&&a.setQuoteTemplateExpirationDate))throw new Error("Failed to set expiration date");const r=f(t.data.setQuoteTemplateExpirationDate);if(!r)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},xe=`
1059
+ mutation ACCEPT_QUOTE_TEMPLATE_MUTATION($templateId: ID!) {
1060
+ acceptNegotiableQuoteTemplate(input: { template_id: $templateId }) {
1061
+ ...NegotiableQuoteTemplateFragment
1062
+ }
1063
+ }
1064
+
1065
+ ${T}
1066
+ `,pt=async e=>{var a;if(!e.templateId)throw new Error("Template ID is required");if(!l.authenticated)throw new Error("Unauthorized");try{const t=await p(xe,{variables:{templateId:e.templateId}});if(!((a=t==null?void 0:t.data)!=null&&a.acceptNegotiableQuoteTemplate))throw new Error("No quote template data received");const r=f(t.data.acceptNegotiableQuoteTemplate);if(!r)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},Se=`
1067
+ mutation CANCEL_QUOTE_TEMPLATE_MUTATION(
1068
+ $templateId: ID!
1069
+ $comment: String
1070
+ ) {
1071
+ cancelNegotiableQuoteTemplate(
1072
+ input: {
1073
+ template_id: $templateId
1074
+ cancellation_comment: $comment
1075
+ }
1076
+ ) {
1077
+ ...NegotiableQuoteTemplateFragment
1078
+ }
1079
+ }
1080
+ ${T}
1081
+ `,gt=async e=>{var a;if(!e.templateId)throw new Error("Template ID is required");if(!l.authenticated)throw new Error("Unauthorized");try{const t=await p(Se,{variables:{templateId:e.templateId,comment:e.comment}});if(!((a=t==null?void 0:t.data)!=null&&a.cancelNegotiableQuoteTemplate))throw new Error("No quote template data received");const r=f(t.data.cancelNegotiableQuoteTemplate);if(!r)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},Me=`
1082
+ mutation DELETE_QUOTE_TEMPLATE_MUTATION($templateId: ID!) {
1083
+ deleteNegotiableQuoteTemplate(input: { template_id: $templateId })
1084
+ }
1085
+ `,Et=async e=>{var a;if(!e.templateId)throw new Error("Template ID is required");if(!l.authenticated)throw new Error("Unauthorized");try{const t=await p(Me,{variables:{templateId:e.templateId}});if(t!=null&&t.errors&&t.errors.length>0){const o=t.errors.map(n=>n==null?void 0:n.message).filter(Boolean).join("; ");throw new Error(o||"Failed to delete quote template")}if(!((a=t==null?void 0:t.data)==null?void 0:a.deleteNegotiableQuoteTemplate))throw new Error("Failed to delete quote template");return _.emit("quote-management/quote-template-deleted",{templateId:e.templateId}),{templateId:e.templateId}}catch(t){return Promise.reject(t)}},Le=`
1086
+ mutation OPEN_QUOTE_TEMPLATE_MUTATION($templateId: ID!) {
1087
+ openNegotiableQuoteTemplate(input: { template_id: $templateId }) {
1088
+ ...NegotiableQuoteTemplateFragment
1089
+ }
1090
+ }
1091
+
1092
+ ${T}
1093
+ `,ft=async e=>{var a;if(!e.templateId)throw new Error("Template ID is required");if(!l.authenticated)throw new Error("Unauthorized");try{const t=await p(Le,{variables:{templateId:e.templateId}});if(!((a=t==null?void 0:t.data)!=null&&a.openNegotiableQuoteTemplate))throw new Error("No quote template data received");const r=f(t.data.openNegotiableQuoteTemplate);if(!r)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},Fe=`
25
1094
  mutation SET_NEGOTIABLE_QUOTE_TEMPLATE_SHIPPING_ADDRESS_MUTATION(
26
1095
  $templateId: ID!
27
1096
  $shippingAddress: NegotiableQuoteTemplateShippingAddressInput!
@@ -36,6 +1105,104 @@ import{r as G}from"./chunks/requestNegotiableQuote.js";import{g as $}from"./chun
36
1105
  }
37
1106
  }
38
1107
 
39
- ${f}
40
- `,q=async e=>{var r;if(!e.templateId)throw new Error("Template ID is required");if(!e.shippingAddress)throw new Error("Shipping address is required");if(!p.authenticated)throw new Error("Unauthorized");if(!e.shippingAddress.address&&!e.shippingAddress.customerAddressUid)throw new Error("Either address or customerAddressUid must be provided");try{const t=await m(I,{variables:{templateId:e.templateId,shippingAddress:{address:e.shippingAddress.address?{city:e.shippingAddress.address.city,company:e.shippingAddress.address.company,country_code:e.shippingAddress.address.countryCode,fax:e.shippingAddress.address.fax,firstname:e.shippingAddress.address.firstname,lastname:e.shippingAddress.address.lastname,middlename:e.shippingAddress.address.middlename,postcode:e.shippingAddress.address.postcode,prefix:e.shippingAddress.address.prefix,region:e.shippingAddress.address.region,region_id:e.shippingAddress.address.regionId,save_in_address_book:e.shippingAddress.address.saveInAddressBook,street:e.shippingAddress.address.street,suffix:e.shippingAddress.address.suffix,telephone:e.shippingAddress.address.telephone,vat_id:e.shippingAddress.address.vatId}:void 0,customer_address_uid:e.shippingAddress.customerAddressUid,customer_notes:e.shippingAddress.customerNotes}}});if(!((r=t==null?void 0:t.data)!=null&&r.setNegotiableQuoteTemplateShippingAddress))throw new Error("No quote template data received");const s=T(t.data.setNegotiableQuoteTemplateShippingAddress);if(!s)throw new Error("Failed to transform quote template data");return u.emit("quote-management/quote-template-data",{quoteTemplate:s,permissions:p.permissions}),s}catch(t){return Promise.reject(t)}};export{L as FilterMatchTypeEnum,M as NegotiableQuoteSortableField,pe as QuoteTemplateFilterStatus,ue as QuoteTemplateSortField,me as SortDirection,B as SortEnum,he as acceptQuoteTemplate,Ie as addQuoteTemplateLineItemNote,q as addQuoteTemplateShippingAddress,ce as cancelQuoteTemplate,K as closeNegotiableQuote,C as config,V as createQuoteTemplate,W as deleteQuote,Ae as deleteQuoteTemplate,X as duplicateQuote,m as fetchGraphQl,De as generateQuoteFromTemplate,te as getConfig,$ as getQuoteData,k as getQuoteTemplateData,le as getQuoteTemplates,j as getStoreConfig,z as initialize,R as negotiableQuotes,Te as openQuoteTemplate,se as removeFetchGraphQlHeader,we as removeNegotiableQuoteItems,_e as removeQuoteTemplateItems,Y as renameNegotiableQuote,G as requestNegotiableQuote,Z as sendForReview,fe as sendQuoteTemplateForReview,re as setEndpoint,de as setFetchGraphQlHeader,oe as setFetchGraphQlHeaders,ve as setLineItemNote,Ee as setQuoteTemplateExpirationDate,x as setShippingAddress,Fe as updateQuantities,Ne as updateQuoteTemplateItemQuantities,ie as uploadFile};
1108
+ ${T}
1109
+ `,Tt=async e=>{var a;if(!e.templateId)throw new Error("Template ID is required");if(!e.shippingAddress)throw new Error("Shipping address is required");if(!l.authenticated)throw new Error("Unauthorized");if(!e.shippingAddress.address&&!e.shippingAddress.customerAddressUid)throw new Error("Either address or customerAddressUid must be provided");try{const t=await p(Fe,{variables:{templateId:e.templateId,shippingAddress:{address:e.shippingAddress.address?{city:e.shippingAddress.address.city,company:e.shippingAddress.address.company,country_code:e.shippingAddress.address.countryCode,fax:e.shippingAddress.address.fax,firstname:e.shippingAddress.address.firstname,lastname:e.shippingAddress.address.lastname,middlename:e.shippingAddress.address.middlename,postcode:e.shippingAddress.address.postcode,prefix:e.shippingAddress.address.prefix,region:e.shippingAddress.address.region,region_id:e.shippingAddress.address.regionId,save_in_address_book:e.shippingAddress.address.saveInAddressBook,street:e.shippingAddress.address.street,suffix:e.shippingAddress.address.suffix,telephone:e.shippingAddress.address.telephone,vat_id:e.shippingAddress.address.vatId}:void 0,customer_address_uid:e.shippingAddress.customerAddressUid,customer_notes:e.shippingAddress.customerNotes}}});if(!((a=t==null?void 0:t.data)!=null&&a.setNegotiableQuoteTemplateShippingAddress))throw new Error("No quote template data received");const r=f(t.data.setNegotiableQuoteTemplateShippingAddress);if(!r)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},$e=`
1110
+ mutation UPDATE_NEGOTIABLE_QUOTE_TEMPLATE_QUANTITIES_MUTATION(
1111
+ $input: UpdateNegotiableQuoteTemplateQuantitiesInput!
1112
+ ) {
1113
+ updateNegotiableQuoteTemplateQuantities(input: $input) {
1114
+ quote_template {
1115
+ ...NegotiableQuoteTemplateFragment
1116
+ }
1117
+ }
1118
+ }
1119
+ ${T}
1120
+ `,It=async e=>{var a,t;if(!e.templateId)throw new Error("Template ID is required");if(!e.items||e.items.length===0)throw new Error("Items array is required and must not be empty");if(!l.authenticated)throw new Error("Unauthorized");try{const r=await p($e,{variables:{input:{template_id:e.templateId,items:e.items.map(n=>({item_id:n.itemId,quantity:n.quantity,min_qty:n.minQty,max_qty:n.maxQty}))}}});if(!((t=(a=r==null?void 0:r.data)==null?void 0:a.updateNegotiableQuoteTemplateQuantities)!=null&&t.quote_template))throw new Error("No quote template data received");const o=f(r.data.updateNegotiableQuoteTemplateQuantities.quote_template);if(!o)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:o,permissions:l.permissions}),o}catch(r){return Promise.reject(r)}},Ce=`
1121
+ mutation REMOVE_NEGOTIABLE_QUOTE_TEMPLATE_ITEMS_MUTATION(
1122
+ $input: RemoveNegotiableQuoteTemplateItemsInput!
1123
+ ) {
1124
+ removeNegotiableQuoteTemplateItems(input: $input) {
1125
+ ...NegotiableQuoteTemplateFragment
1126
+ }
1127
+ }
1128
+ ${T}
1129
+ `,ht=async e=>{var a;if(!e.templateId)throw new Error("Template ID is required");if(!e.itemUids||e.itemUids.length===0)throw new Error("Item UIDs array is required and must not be empty");if(!l.authenticated)throw new Error("Unauthorized");try{const t=await p(Ce,{variables:{input:{template_id:e.templateId,item_uids:e.itemUids}}});if(!((a=t==null?void 0:t.data)!=null&&a.removeNegotiableQuoteTemplateItems))throw new Error("No quote template data received");const r=f(t.data.removeNegotiableQuoteTemplateItems);if(!r)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},Re=`
1130
+ mutation SET_QUOTE_TEMPLATE_LINE_ITEM_NOTE_MUTATION(
1131
+ $input: QuoteTemplateLineItemNoteInput!
1132
+ ) {
1133
+ setQuoteTemplateLineItemNote(input: $input) {
1134
+ ...NegotiableQuoteTemplateFragment
1135
+ }
1136
+ }
1137
+ ${T}
1138
+ `,yt=async e=>{var a;if(!e.templateId)throw new Error("Template ID is required");if(!e.itemId)throw new Error("Item ID is required");if(!l.authenticated)throw new Error("Unauthorized");try{const t=await p(Re,{variables:{input:{templateId:e.templateId,item_uid:e.itemId,note:e.note}}});if(!((a=t==null?void 0:t.data)!=null&&a.setQuoteTemplateLineItemNote))throw new Error("No quote template data received");const r=f(t.data.setQuoteTemplateLineItemNote);if(!r)throw new Error("Failed to transform quote template data");return _.emit("quote-management/quote-template-data",{quoteTemplate:r,permissions:l.permissions}),r}catch(t){return Promise.reject(t)}},Ge=`
1139
+ mutation GENERATE_NEGOTIABLE_QUOTE_FROM_TEMPLATE_MUTATION(
1140
+ $input: GenerateNegotiableQuoteFromTemplateInput!
1141
+ ) {
1142
+ generateNegotiableQuoteFromTemplate(input: $input) {
1143
+ negotiable_quote_uid
1144
+ }
1145
+ }
1146
+ `,wt=async e=>{var a,t;if(!e.templateId)throw new Error("Template ID is required");if(!l.authenticated)throw new Error("Unauthorized");try{const r=await p(Ge,{variables:{input:{template_id:e.templateId}}});if(!((t=(a=r==null?void 0:r.data)==null?void 0:a.generateNegotiableQuoteFromTemplate)!=null&&t.negotiable_quote_uid))throw new Error("No quote UID received");const o=r.data.generateNegotiableQuoteFromTemplate.negotiable_quote_uid;return _.emit("quote-management/quote-template-generated",{quoteId:o}),{quoteId:o}}catch(r){return Promise.reject(r)}},ze=`
1147
+ mutation renameNegotiableQuote($input: RenameNegotiableQuoteInput!) {
1148
+ renameNegotiableQuote(input: $input) {
1149
+ quote {
1150
+ ...NegotiableQuoteFragment
1151
+ }
1152
+ }
1153
+ }
1154
+ ${I}
1155
+ `,bt=async e=>{const{quoteUid:a,quoteName:t,quoteComment:r}=e;if(!a)throw new Error("Quote UID is required");if(!t)throw new Error("Quote name is required");return p(ze,{variables:{input:{quote_uid:a,quote_name:t,quote_comment:r||""}}}).then(n=>{var u,i;const{errors:c}=n;if(c){const s=c.map(m=>m.message).join("; ");throw new Error(`Failed to rename quote: ${s}`)}const d=h((i=(u=n.data)==null?void 0:u.renameNegotiableQuote)==null?void 0:i.quote);if(!d)throw new Error("Failed to transform quote data: Invalid response structure");return _.emit("quote-management/quote-renamed",{quote:d,input:{quoteUid:a,quoteName:t,quoteComment:r}}),d})},ke=`
1156
+ mutation DUPLICATE_NEGOTIABLE_QUOTE_MUTATION($quoteUid: ID!, $duplicatedQuoteUid: ID!) {
1157
+ duplicateNegotiableQuote(input: { quote_uid: $quoteUid, duplicated_quote_uid: $duplicatedQuoteUid }) {
1158
+ quote {
1159
+ ...NegotiableQuoteFragment
1160
+ }
1161
+ }
1162
+ }
1163
+ ${I}
1164
+ `,Nt=async e=>{if(!l.authenticated)throw new Error("Unauthorized");const{quoteUid:a,duplicatedQuoteUid:t,hasOutOfStockItems:r}=e;if(!a||!a.trim())throw new Error("Quote UID is required");if(!t||!t.trim())throw new Error("Duplicated Quote UID is required");return p(ke,{variables:{quoteUid:a,duplicatedQuoteUid:t}}).then(o=>{var d,u;const{errors:n}=o;if(n){const i=n.map(s=>s.message).join("; ");throw new Error(`Failed to duplicate quote: ${i}`)}const c=h((u=(d=o.data)==null?void 0:d.duplicateNegotiableQuote)==null?void 0:u.quote);if(!c)throw new Error("Failed to transform quote data: Invalid response structure");return _.emit("quote-management/quote-duplicated",{quote:c,input:{quoteUid:a,duplicatedQuoteUid:t},hasOutOfStockItems:r}),c})},Be=`
1165
+ mutation UPDATE_NEGOTIABLE_QUOTE_QUANTITIES_MUTATION(
1166
+ $quoteUid: ID!
1167
+ $items: [NegotiableQuoteItemQuantityInput!]!
1168
+ ) {
1169
+ updateNegotiableQuoteQuantities(
1170
+ input: {
1171
+ quote_uid: $quoteUid
1172
+ items: $items
1173
+ }
1174
+ ) {
1175
+ quote {
1176
+ ...NegotiableQuoteFragment
1177
+ }
1178
+ }
1179
+ }
1180
+ ${I}
1181
+ `,At=async e=>{if(!l.authenticated)return Promise.reject(new Error("Unauthorized"));const{quoteUid:a,items:t}=e;if(!a)throw new Error("Quote UID is required");if(!t||!Array.isArray(t)||t.length===0)throw new Error("Items array is required and must not be empty");for(const o of t){if(!o.quoteItemUid)throw new Error("Each item must have a quoteItemUid");if(typeof o.quantity!="number"||o.quantity<=0)throw new Error(`Invalid quantity for item ${o.quoteItemUid}: quantity must be a positive number`);if(!Number.isInteger(o.quantity))throw new Error(`Invalid quantity for item ${o.quoteItemUid}: quantity must be an integer`)}const r=t.map(o=>({quote_item_uid:o.quoteItemUid,quantity:o.quantity}));return p(Be,{variables:{quoteUid:a,items:r}}).then(o=>{var d,u;const{errors:n}=o;if(n){const i=n.map(s=>s.message).join("; ");throw new Error(`Failed to update quote quantities: ${i}`)}const c=h((u=(d=o.data)==null?void 0:d.updateNegotiableQuoteQuantities)==null?void 0:u.quote);if(!c)throw new Error("Failed to transform quote data: Invalid response structure");return _.emit("quote-management/quantities-updated",{quote:c,input:{quoteUid:a,items:t}}),c})},je=`
1182
+ mutation REMOVE_NEGOTIABLE_QUOTE_ITEMS_MUTATION(
1183
+ $quoteUid: ID!
1184
+ $quoteItemUids: [ID!]!
1185
+ ) {
1186
+ removeNegotiableQuoteItems(
1187
+ input: {
1188
+ quote_uid: $quoteUid
1189
+ quote_item_uids: $quoteItemUids
1190
+ }
1191
+ ) {
1192
+ quote {
1193
+ ...NegotiableQuoteFragment
1194
+ }
1195
+ }
1196
+ }
1197
+ ${I}
1198
+ `,vt=async e=>{var d;if(!l.authenticated)return Promise.reject(new Error("Unauthorized"));const{quoteUid:a,quoteItemUids:t}=e;if(!a)throw new Error("Quote UID is required");if(!Array.isArray(t)||t.length===0)throw new Error("At least one quote item UID is required");const r=await p(je,{variables:{quoteUid:a,quoteItemUids:t}}),{errors:o,data:n}=r;if(o!=null&&o.length){const u=o.map(i=>i.message).join("; ");throw new Error(`Failed to remove negotiable quote items: ${u}`)}const c=h((d=n==null?void 0:n.removeNegotiableQuoteItems)==null?void 0:d.quote);if(!c)throw new Error("Failed to transform quote data: Invalid response structure");return _.emit("quote-management/quote-items-removed",{quote:c,removedItemUids:t,input:e}),c},Xe=`
1199
+ mutation SET_LINE_ITEM_NOTE_MUTATION($input: LineItemNoteInput!) {
1200
+ setLineItemNote(input: $input) {
1201
+ quote {
1202
+ ...NegotiableQuoteFragment
1203
+ }
1204
+ }
1205
+ }
1206
+ ${I}
1207
+ `,Qt=async e=>{if(!l.authenticated)throw new Error("Unauthorized");const{quoteUid:a,itemUid:t,note:r,quantity:o}=e;if(!a)throw new Error("Quote UID is required");if(!t)throw new Error("Item UID is required");if(!r)throw new Error("Note is required");const n={quote_uid:a,quote_item_uid:t,note:r.trim()};return p(Xe,{variables:{input:n}}).then(c=>{var i,s;const{errors:d}=c;if(d){const m=d.map(E=>E.message).join("; ");throw new Error(`Failed to set line item note: ${m}`)}const u=h((s=(i=c.data)==null?void 0:i.setLineItemNote)==null?void 0:s.quote);if(!u)throw new Error("Failed to transform quote data: Invalid response structure");return _.emit("quote-management/line-item-note-set",{quote:u,input:{quoteUid:a,itemUid:t,note:r,quantity:o}}),_.emit("quote-management/quote-data",{quote:u,permissions:l.permissions}),u})};export{_e as FilterMatchTypeEnum,g as N,pe as NegotiableQuoteSortableField,y as Q,Ue as QuoteTemplateFilterStatus,qe as QuoteTemplateSortField,De as SortDirection,me as SortEnum,pt as acceptQuoteTemplate,yt as addQuoteTemplateLineItemNote,Tt as addQuoteTemplateShippingAddress,gt as cancelQuoteTemplate,ct as closeNegotiableQuote,Ye as config,lt as createQuoteTemplate,nt as deleteQuote,Et as deleteQuoteTemplate,Nt as duplicateQuote,p as fetchGraphQl,rt as g,wt as generateQuoteFromTemplate,tt as getConfig,ue as getQuoteData,Ae as getQuoteTemplateData,dt as getQuoteTemplates,Ee as getStoreConfig,v as initialize,ot as negotiableQuotes,ft as openQuoteTemplate,Ze as removeFetchGraphQlHeader,vt as removeNegotiableQuoteItems,ht as removeQuoteTemplateItems,bt as renameNegotiableQuote,at as requestNegotiableQuote,l as s,ut as sendForReview,_t as sendQuoteTemplateForReview,Ke as setEndpoint,Je as setFetchGraphQlHeader,et as setFetchGraphQlHeaders,Qt as setLineItemNote,mt as setQuoteTemplateExpirationDate,it as setShippingAddress,At as updateQuantities,It as updateQuoteTemplateItemQuantities,st as uploadFile};
41
1208
  //# sourceMappingURL=api.js.map